@vellumai/web 0.11.0-staging.1 → 0.11.0-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 (148) hide show
  1. package/dist/assets/access-DS79PSR3.js +1 -0
  2. package/dist/assets/{account-page-BQkbkIBf.js → account-page-D3ERiewh.js} +1 -1
  3. package/dist/assets/{acp-run-actions-BWR9i8MT.js → acp-run-actions-BH8wuBAL.js} +1 -1
  4. package/dist/assets/{acp-run-detail-panel-np07jHCY.js → acp-run-detail-panel-dqVK6rPq.js} +1 -1
  5. package/dist/assets/{activity-steps-panel-DA5HdB61.js → activity-steps-panel-xxl2hu3E.js} +1 -1
  6. package/dist/assets/{add-credential-modal-rP3DdyDH.js → add-credential-modal-CY_--m8L.js} +1 -1
  7. package/dist/assets/{ai-page-eBXLZw6t.js → ai-page-B02NwVRu.js} +1 -1
  8. package/dist/assets/{api-CI6Y6DLb.js → api-C3QSs67k.js} +1 -1
  9. package/dist/assets/{api-BlN0EOWF.js → api-LG8zI3nK.js} +1 -1
  10. package/dist/assets/{api-key-screen-B6aLgYrf.js → api-key-screen-CvBdN6Ae.js} +1 -1
  11. package/dist/assets/{app-card-A7PMnlAT.js → app-card-CAaFL1oB.js} +1 -1
  12. package/dist/assets/{assistant-feature-flag-store-DV5Zr1c4.js → assistant-feature-flag-store-CAdgpPiS.js} +1 -1
  13. package/dist/assets/{assistant-status-panel-CxMEVjFY.js → assistant-status-panel-BTnD-jhG.js} +1 -1
  14. package/dist/assets/{auth-store-BW4V6iLb.js → auth-store-5qq59BAN.js} +1 -1
  15. package/dist/assets/{avatar-random-BiEMZGl7.js → avatar-random-BMSYTcJK.js} +1 -1
  16. package/dist/assets/{background-task-actions-Y-aaTGGd.js → background-task-actions-DmP5s0oO.js} +1 -1
  17. package/dist/assets/{background-task-detail-panel-CGAeD1Ym.js → background-task-detail-panel-BCYAElGc.js} +1 -1
  18. package/dist/assets/{billing-page-5GkNMPN6.js → billing-page-B5j5TW_S.js} +1 -1
  19. package/dist/assets/{bookmarks-page-B1-9GBEx.js → bookmarks-page-D_Jr-a4Q.js} +1 -1
  20. package/dist/assets/build-state-m0LQ5Iis.js +1 -0
  21. package/dist/assets/{channels-page-route-BLy5uT8z.js → channels-page-route-BYP9SOw5.js} +1 -1
  22. package/dist/assets/{chat-avatar-DQx81apI.js → chat-avatar-CvEA6z0H.js} +1 -1
  23. package/dist/assets/{chat-markdown-message-CdM44BjA.js → chat-markdown-message-rxPKNeTx.js} +1 -1
  24. package/dist/assets/{checkout-continuation-DIMnSvv3.js → checkout-continuation-U3Pd2nxi.js} +1 -1
  25. package/dist/assets/{checkout-page-BZQpdPLT.js → checkout-page-C5_9GbP-.js} +1 -1
  26. package/dist/assets/{client-feature-flag-store-BDrcV52r.js → client-feature-flag-store-CMncoan8.js} +1 -1
  27. package/dist/assets/{command-palette-window-page-DAC710zo.js → command-palette-window-page-gq0zowBe.js} +1 -1
  28. package/dist/assets/{contacts-page-route-BF8J2JDt.js → contacts-page-route-DNoCUXE7.js} +1 -1
  29. package/dist/assets/{conversation-cache-DU44A0zv.js → conversation-cache-DKvwwWNo.js} +1 -1
  30. package/dist/assets/{conversation-list-fetchers-DLZho4T7.js → conversation-list-fetchers-DM-Y61u5.js} +1 -1
  31. package/dist/assets/conversation-navigation-DsN0hcpL.js +1 -0
  32. package/dist/assets/{conversation-queries-Bvh4bAZ6.js → conversation-queries-CWvK6RLK.js} +1 -1
  33. package/dist/assets/{credentials-page-DzlUvhn4.js → credentials-page-BsJFuOc9.js} +1 -1
  34. package/dist/assets/{debug-page-TgklOyxq.js → debug-page-BziypDgA.js} +1 -1
  35. package/dist/assets/{deploy-dialogs-Day3_9Lh.js → deploy-dialogs-DZSd5o9b.js} +1 -1
  36. package/dist/assets/{deploy-store-Brp7LoZ_.js → deploy-store-D6snB1j5.js} +1 -1
  37. package/dist/assets/{developer-page-BobJIDnJ.js → developer-page-QMFEIyBS.js} +1 -1
  38. package/dist/assets/{document-viewer-container-BIS1iPUz.js → document-viewer-container-B7TEDeV0.js} +1 -1
  39. package/dist/assets/{document-viewer-page-CcGTGI8C.js → document-viewer-page-3Eq8L562.js} +1 -1
  40. package/dist/assets/{emails-page-CbAcUM70.js → emails-page-Wr4wPSYl.js} +1 -1
  41. package/dist/assets/{eye-bbox-DU39FEUp.js → eye-bbox-C_V87iLg.js} +1 -1
  42. package/dist/assets/feature-flag-catalog-I9-eJQP_.js +1 -0
  43. package/dist/assets/{first-run-scope-DKYDP-Kz.js → first-run-scope-CL5YbC3b.js} +1 -1
  44. package/dist/assets/{general-page-CtfWmXZi.js → general-page-lbkufqHg.js} +1 -1
  45. package/dist/assets/{get-memory-stats-DMSpgqW_.js → get-memory-stats-BCYSpBF6.js} +1 -1
  46. package/dist/assets/hatching-screen-D81diZoa.js +1 -0
  47. package/dist/assets/{home-page-route-BV2GBxZi.js → home-page-route-CHe8eoLz.js} +1 -1
  48. package/dist/assets/{hosting-screen-CTtZrpXi.js → hosting-screen-D9atAksQ.js} +1 -1
  49. package/dist/assets/{identity-page-route-DsU3eoey.js → identity-page-route-CK3YsXCN.js} +1 -1
  50. package/dist/assets/{index-DMFNBbtE.js → index-0f48hi7h.js} +1 -1
  51. package/dist/assets/{inspect-page-BcTmA6nR.js → inspect-page-COwvbHtX.js} +1 -1
  52. package/dist/assets/{installed-plugins-query-C29LGAEV.js → installed-plugins-query-Cgek0q7G.js} +1 -1
  53. package/dist/assets/{integrations-page-CTST1yxp.js → integrations-page-CJOBwxXp.js} +1 -1
  54. package/dist/assets/{invalidate-plugin-queries-DamxiwYv.js → invalidate-plugin-queries-C3NTXkCX.js} +1 -1
  55. package/dist/assets/{latest-assistant-text-C0pZSmc9.js → latest-assistant-text-DOepZ_Io.js} +2 -2
  56. package/dist/assets/{library-detail-page-CI4p4bVi.js → library-detail-page-DVwI94NZ.js} +1 -1
  57. package/dist/assets/{library-page-SAKHIHZb.js → library-page-CNA794WY.js} +1 -1
  58. package/dist/assets/{local-runtime-upgrade-CoFpjlw3.js → local-runtime-upgrade-Bqn3d7Q7.js} +1 -1
  59. package/dist/assets/{login-flow-B4pa-3II.js → login-flow-CD9tyuFG.js} +1 -1
  60. package/dist/assets/{login-page-CVnwfJ3R.js → login-page-BNStrcnU.js} +1 -1
  61. package/dist/assets/{logout-page-km3RHlGI.js → logout-page-CpFeuLA_.js} +1 -1
  62. package/dist/assets/{logs-layout-D4Ubybh3.js → logs-layout-BUiPeZ4I.js} +1 -1
  63. package/dist/assets/{memory-page-route-JRgoyHnC.js → memory-page-route-C0cBV7HD.js} +1 -1
  64. package/dist/assets/{memory-router-playground-page-DvbF6E2-.js → memory-router-playground-page-D4UIq8mw.js} +1 -1
  65. package/dist/assets/{messages-Coz9buJR.js → messages-CFcAW4iz.js} +2 -2
  66. package/dist/assets/navigation-resolver-DPJxzx0h.js +1 -0
  67. package/dist/assets/{notifications-page-CWtQZnHw.js → notifications-page-ClfcJeLf.js} +1 -1
  68. package/dist/assets/{open-workspace-file-DNaU5wg2.js → open-workspace-file-DtK3a84K.js} +2 -2
  69. package/dist/assets/{page-empty-state-L-3_3LSi.js → page-empty-state-DT-tC1u6.js} +1 -1
  70. package/dist/assets/{personality-page-B621HU2-.js → personality-page-BJpW3UXD.js} +1 -1
  71. package/dist/assets/{plans-page-DAVt4mwm.js → plans-page-BDKqdYNM.js} +1 -1
  72. package/dist/assets/{platform-login-notice-BaCrIk0m.js → platform-login-notice-CdYiKsE8.js} +1 -1
  73. package/dist/assets/{platform-loopback-page-jBGJSmyh.js → platform-loopback-page-D0gXCm2S.js} +1 -1
  74. package/dist/assets/{privacy-page-DZEcN0PF.js → privacy-page-B0QN4qZO.js} +1 -1
  75. package/dist/assets/privacy-screen-vp4uUpm6.js +1 -0
  76. package/dist/assets/{provider-callback-page-BeDYWdc_.js → provider-callback-page-BH6DES7c.js} +1 -1
  77. package/dist/assets/{provider-key-1rLTitmu.js → provider-key-D2Nsf9zh.js} +1 -1
  78. package/dist/assets/{provider-signup-page-CVKaVhiB.js → provider-signup-page-BAPcG_iJ.js} +1 -1
  79. package/dist/assets/{react-query.gen-r3I6j8-1.js → react-query.gen-C5c1Acuq.js} +1 -1
  80. package/dist/assets/{research-onboarding-route-DwRSK3R4.js → research-onboarding-route-CFL3q__m.js} +2 -2
  81. package/dist/assets/{retire-confirm-dialog-BuS97P1t.js → retire-confirm-dialog-CsSY2-T8.js} +1 -1
  82. package/dist/assets/{review-terms-screen-CTNEkesk.js → review-terms-screen-BhyRQBjl.js} +1 -1
  83. package/dist/assets/{risk-DmicWnoH.js → risk-CdT92Vqr.js} +1 -1
  84. package/dist/assets/{routes-Bzk5oLRb.js → routes-CaP5Tqj7.js} +14 -14
  85. package/dist/assets/{runtime-upgrade-banner-DPMpuefs.js → runtime-upgrade-banner-DPqzKtZU.js} +1 -1
  86. package/dist/assets/{schedules-DIpn4jGl.js → schedules-6hzhR_C_.js} +1 -1
  87. package/dist/assets/{schedules-page-A9pwMmex.js → schedules-page-DVnUeaoB.js} +1 -1
  88. package/dist/assets/{sdk.gen-BVAVE6A_.js → sdk.gen-BHZ0fJla.js} +1 -1
  89. package/dist/assets/{select-assistant-screen-BPXqMOtp.js → select-assistant-screen-CVV3iqMy.js} +1 -1
  90. package/dist/assets/{settings-layout-CrOIplp2.js → settings-layout-B_4PKJr9.js} +1 -1
  91. package/dist/assets/{settings-navigation-Ccol_TOM.js → settings-navigation-CSG7jiyJ.js} +1 -1
  92. package/dist/assets/{share-feedback-modal-IyuFKIAE.js → share-feedback-modal-BoWCg4KH.js} +1 -1
  93. package/dist/assets/{sidebar-tree-_HwQiPki.js → sidebar-tree-C_PPNHe5.js} +1 -1
  94. package/dist/assets/{signup-page-D44Im_Pf.js → signup-page-D0S_8XYw.js} +1 -1
  95. package/dist/assets/{site-favicon-DzmWythg.js → site-favicon-BB1pYWLF.js} +1 -1
  96. package/dist/assets/{skill-detail-page-HW_A5KMG.js → skill-detail-page-CTobyK6L.js} +1 -1
  97. package/dist/assets/{skill-detail-panel-CrwVImjM.js → skill-detail-panel-CNzionF7.js} +1 -1
  98. package/dist/assets/{skills-Djg056es.js → skills-Cum1XWT2.js} +1 -1
  99. package/dist/assets/{sound-manager-DlaDOZ8r.js → sound-manager-Bx-OcMAz.js} +1 -1
  100. package/dist/assets/{sounds-page-CtII5pFQ.js → sounds-page-C45-RF4i.js} +1 -1
  101. package/dist/assets/{subagent-detail-panel-tuHcbKyo.js → subagent-detail-panel-DyyMdaNO.js} +1 -1
  102. package/dist/assets/subagent-store-MDi6lBXs.js +3 -0
  103. package/dist/assets/{superpowers-page-f4EChE6q.js → superpowers-page-CaLzK5D-.js} +1 -1
  104. package/dist/assets/{system-events-page-oxkNLamU.js → system-events-page-DXAU01ZO.js} +1 -1
  105. package/dist/assets/{theme-stage-page-5wL3M-2c.js → theme-stage-page-BDTCmutO.js} +1 -1
  106. package/dist/assets/{tool-detail-panel-BqhEUAMJ.js → tool-detail-panel-DFrWEWKG.js} +1 -1
  107. package/dist/assets/{transcript-message-body-shared-D3uxHQt5.js → transcript-message-body-shared-D9_d2c2X.js} +1 -1
  108. package/dist/assets/{upgrade-cancel-page-BRA25NVC.js → upgrade-cancel-page-eiJEAvFz.js} +1 -1
  109. package/dist/assets/{upgrade-success-page-BlZDEVkm.js → upgrade-success-page-Cb1Gl4MM.js} +1 -1
  110. package/dist/assets/{use-app-theme-CGie3Dma.js → use-app-theme-Dg8A6vPA.js} +1 -1
  111. package/dist/assets/{use-assistant-avatar-IcRIy2-c.js → use-assistant-avatar-bwLHcMz4.js} +1 -1
  112. package/dist/assets/{use-assistant-capability-C8pZDYlr.js → use-assistant-capability-CDS7GbSO.js} +1 -1
  113. package/dist/assets/{use-assistant-identity-details-CE6-JkNE.js → use-assistant-identity-details-9JRWxXTQ.js} +1 -1
  114. package/dist/assets/{use-bookmarks-CIhaNp5_.js → use-bookmarks-CK-nOiT-.js} +1 -1
  115. package/dist/assets/{use-checkout-dismiss-refresh-BpmG1OQ0.js → use-checkout-dismiss-refresh-CqGR_OsB.js} +1 -1
  116. package/dist/assets/{use-command-palette-sections-CXU-OW-6.js → use-command-palette-sections-CkpUaAKs.js} +1 -1
  117. package/dist/assets/{use-edit-app-CYK9-rGD.js → use-edit-app-B_Nequzs.js} +1 -1
  118. package/dist/assets/{use-invite-link-dialog-DdiGDpLS.js → use-invite-link-dialog-CPPOduk8.js} +1 -1
  119. package/dist/assets/{use-ios-app-nudge-t0SIn8xv.js → use-ios-app-nudge-B-ojl-b1.js} +1 -1
  120. package/dist/assets/{use-is-org-ready-D0q2NIZU.js → use-is-org-ready-C5xlYywh.js} +1 -1
  121. package/dist/assets/{use-onboarding-login-BmYpiSIt.js → use-onboarding-login-DI5gvqEG.js} +1 -1
  122. package/dist/assets/{use-platform-assistant-id-Cm5BfOD8.js → use-platform-assistant-id-DOsSt6k1.js} +1 -1
  123. package/dist/assets/{use-platform-gate-bFyCaLbM.js → use-platform-gate-C65D14xY.js} +1 -1
  124. package/dist/assets/{use-save-twilio-credentials-Bm-WW_5V.js → use-save-twilio-credentials-c9xG9RPK.js} +1 -1
  125. package/dist/assets/{use-skill-actions-C4J1lG_r.js → use-skill-actions-BAAx1Eia.js} +1 -1
  126. package/dist/assets/{use-skill-detail-files-BKtCag3o.js → use-skill-detail-files-BvOKvY0-.js} +1 -1
  127. package/dist/assets/{use-sticky-profiles-mC9bd8xU.js → use-sticky-profiles-CdWX0mgI.js} +1 -1
  128. package/dist/assets/{use-subagent-card-data-Dp1wCoRB.js → use-subagent-card-data-DHuNtSy9.js} +1 -1
  129. package/dist/assets/{utils-BCDvGOqU.js → utils-B0rBxtYP.js} +1 -1
  130. package/dist/assets/{viewer-store-Ct0SDE-n.js → viewer-store-DLk-jp8U.js} +1 -1
  131. package/dist/assets/{voice-list-IdN1mqlX.js → voice-list-CW8mzaHU.js} +1 -1
  132. package/dist/assets/{voice-page-CxWJ-zo7.js → voice-page-0zsCIOdT.js} +1 -1
  133. package/dist/assets/{voice-picker-modal-BHRanF0C.js → voice-picker-modal-PdsZwrsV.js} +1 -1
  134. package/dist/assets/{welcome-screen-jOvMiW_R.js → welcome-screen-DwOAZpZS.js} +1 -1
  135. package/dist/assets/{workflow-store-CMNMu-fc.js → workflow-store-lM7yKbUo.js} +1 -1
  136. package/dist/assets/workspace-page-D4NvhCv1.js +1 -0
  137. package/dist/assets/{workspace-tree-query-COH0vdQ-.js → workspace-tree-query-B1A-efgV.js} +1 -1
  138. package/dist/index.html +61 -61
  139. package/package.json +1 -1
  140. package/dist/assets/access-CHoOc28F.js +0 -1
  141. package/dist/assets/build-state-DaLynPsy.js +0 -1
  142. package/dist/assets/conversation-navigation-Bo95jhXQ.js +0 -1
  143. package/dist/assets/feature-flag-catalog-TjLF99gJ.js +0 -1
  144. package/dist/assets/hatching-screen-Btkqf3MF.js +0 -1
  145. package/dist/assets/navigation-resolver-D4jPigYv.js +0 -1
  146. package/dist/assets/privacy-screen-DXkQbNvk.js +0 -1
  147. package/dist/assets/subagent-store-CQKOOAm6.js +0 -3
  148. package/dist/assets/workspace-page-BZBNul96.js +0 -1
@@ -0,0 +1 @@
1
+ import{n as e}from"./auth-store-5qq59BAN.js";import{t}from"./assistant-feature-flag-store-CAdgpPiS.js";function n(e,t){return t||e?.isStaff===!0||e?.email?.toLowerCase().endsWith(`@vellum.ai`)===!0}function r(){return n(e.use.user(),t.use.settingsDeveloperNav()===!0)}export{r as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{a as i,n as a,s as o}from"./auth-store-BW4V6iLb.js";import{f as s}from"./native-biometric-BAMIyaSS.js";import{u as c}from"./routes-D9sNqB_o.js";import{t as l}from"./hard-navigate-DyUrcxe0.js";import{n as u,t as d}from"./login-flow-B4pa-3II.js";import{r as f,t as p}from"./account-shell-Dk4aC-Ls.js";var m=e(t(),1),h=r();function g(){let e=i(),t=o(),r=a.use.user(),g=a.use.logout(),[_,v]=(0,m.useState)(null),[y,b]=(0,m.useState)(!1),x=async()=>{v(null),b(!0);try{await s(u,d)}catch(e){console.error(`[account] auth flow failed:`,e),v(`Something went wrong. Please try again.`),b(!1)}};return t?(0,h.jsx)(p,{children:(0,h.jsx)(f,{title:`Loading...`})}):e?(0,h.jsxs)(p,{children:[(0,h.jsx)(f,{title:`Welcome${r?.username?`, ${r.username}`:``}!`,subtitle:`You are signed in.`}),(0,h.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,h.jsx)(n,{to:c.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:`Go to your assistant`}),(0,h.jsx)(`button`,{type:`button`,onClick:async()=>{await g(),l(c.account.login)},className:`cursor-pointer bg-transparent text-sm font-normal text-[var(--content-secondary)] transition-colors hover:text-[var(--content-default)]`,children:`Sign out`})]})]}):(0,h.jsxs)(p,{children:[(0,h.jsx)(f,{title:`Welcome to Vellum`,subtitle:`Sign in to get started.`}),_&&(0,h.jsx)(`p`,{className:`text-center text-sm text-[var(--system-negative-strong)]`,children:_}),(0,h.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,h.jsx)(`button`,{type:`button`,onClick:()=>void x(),disabled:y,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:`Sign in`})})]})}export{g as AccountPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{a as i,n as a,s as o}from"./auth-store-5qq59BAN.js";import{f as s}from"./native-biometric-BAMIyaSS.js";import{u as c}from"./routes-D9sNqB_o.js";import{t as l}from"./hard-navigate-DyUrcxe0.js";import{n as u,t as d}from"./login-flow-CD9tyuFG.js";import{r as f,t as p}from"./account-shell-Dk4aC-Ls.js";var m=e(t(),1),h=r();function g(){let e=i(),t=o(),r=a.use.user(),g=a.use.logout(),[_,v]=(0,m.useState)(null),[y,b]=(0,m.useState)(!1),x=async()=>{v(null),b(!0);try{await s(u,d)}catch(e){console.error(`[account] auth flow failed:`,e),v(`Something went wrong. Please try again.`),b(!1)}};return t?(0,h.jsx)(p,{children:(0,h.jsx)(f,{title:`Loading...`})}):e?(0,h.jsxs)(p,{children:[(0,h.jsx)(f,{title:`Welcome${r?.username?`, ${r.username}`:``}!`,subtitle:`You are signed in.`}),(0,h.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,h.jsx)(n,{to:c.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:`Go to your assistant`}),(0,h.jsx)(`button`,{type:`button`,onClick:async()=>{await g(),l(c.account.login)},className:`cursor-pointer bg-transparent text-sm font-normal text-[var(--content-secondary)] transition-colors hover:text-[var(--content-default)]`,children:`Sign out`})]})]}):(0,h.jsxs)(p,{children:[(0,h.jsx)(f,{title:`Welcome to Vellum`,subtitle:`Sign in to get started.`}),_&&(0,h.jsx)(`p`,{className:`text-center text-sm text-[var(--system-negative-strong)]`,children:_}),(0,h.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,h.jsx)(`button`,{type:`button`,onClick:()=>void x(),disabled:y,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:`Sign in`})})]})}export{g as AccountPage};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-D3ZM-ToX.js";import{t}from"./createLucideIcon-CAM1RhH8.js";import{t as n}from"./code-qafFA0_-.js";import{n as r}from"./resolved-assistants-store-Dw5UuGyB.js";import{Ur as i}from"./sdk.gen-BVAVE6A_.js";import{t as a}from"./public-asset-BBVUuTT_.js";import{r as o}from"./acp-run-store-B_eDLRwl.js";var s=t(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),c=t(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),l=t(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),u=e();function d(e){let t=e.toLowerCase();if(t.includes(`claude`))return`/images/prior-assistants/claude.svg`;if(t.includes(`codex`)||t.includes(`openai`)||t.includes(`gpt`))return`/images/prior-assistants/chatgpt.svg`;if(t.includes(`copilot`))return`/images/prior-assistants/copilot.svg`}function f({agent:e,className:t=`h-4 w-4 shrink-0`}){let r=e?d(e):void 0;return r?(0,u.jsx)(`img`,{src:a(r),alt:``,"aria-hidden":!0,"data-testid":`acp-agent-icon-brand`,className:t}):(0,u.jsx)(n,{className:`${t} text-[var(--content-secondary)]`,"aria-hidden":!0})}function p(){let e=r.getState().activeAssistantId;if(!e)throw Error(`No active assistant`);return e}async function m(e){let t=p(),n=o.getState(),r=n.byId[e]?.status;n.cancelRun({acpSessionId:e,completedAt:Date.now()});try{let{response:n}=await i.post({url:`/v1/assistants/{assistant_id}/acp/{id}/cancel`,path:{assistant_id:t,id:e},body:{}});if(!n?.ok)throw Error(`Failed to stop ACP run: ${n?.status}`)}catch(t){throw r!==void 0&&o.getState().restoreRunStatus({acpSessionId:e,status:r}),t}}async function h(e,t){let{data:n,response:r}=await i.post({url:`/v1/assistants/{assistant_id}/acp/{id}/steer`,path:{assistant_id:p(),id:e},body:{instruction:t}});if(!r?.ok)throw Error(`Failed to steer ACP run: ${r?.status}`);return n}export{c as a,l as i,m as n,s as o,f as r,h as t};
1
+ import{t as e}from"./jsx-runtime-D3ZM-ToX.js";import{t}from"./createLucideIcon-CAM1RhH8.js";import{t as n}from"./code-qafFA0_-.js";import{n as r}from"./resolved-assistants-store-Dw5UuGyB.js";import{Wr as i}from"./sdk.gen-BHZ0fJla.js";import{t as a}from"./public-asset-BBVUuTT_.js";import{r as o}from"./acp-run-store-B_eDLRwl.js";var s=t(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),c=t(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),l=t(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),u=e();function d(e){let t=e.toLowerCase();if(t.includes(`claude`))return`/images/prior-assistants/claude.svg`;if(t.includes(`codex`)||t.includes(`openai`)||t.includes(`gpt`))return`/images/prior-assistants/chatgpt.svg`;if(t.includes(`copilot`))return`/images/prior-assistants/copilot.svg`}function f({agent:e,className:t=`h-4 w-4 shrink-0`}){let r=e?d(e):void 0;return r?(0,u.jsx)(`img`,{src:a(r),alt:``,"aria-hidden":!0,"data-testid":`acp-agent-icon-brand`,className:t}):(0,u.jsx)(n,{className:`${t} text-[var(--content-secondary)]`,"aria-hidden":!0})}function p(){let e=r.getState().activeAssistantId;if(!e)throw Error(`No active assistant`);return e}async function m(e){let t=p(),n=o.getState(),r=n.byId[e]?.status;n.cancelRun({acpSessionId:e,completedAt:Date.now()});try{let{response:n}=await i.post({url:`/v1/assistants/{assistant_id}/acp/{id}/cancel`,path:{assistant_id:t,id:e},body:{}});if(!n?.ok)throw Error(`Failed to stop ACP run: ${n?.status}`)}catch(t){throw r!==void 0&&o.getState().restoreRunStatus({acpSessionId:e,status:r}),t}}async function h(e,t){let{data:n,response:r}=await i.post({url:`/v1/assistants/{assistant_id}/acp/{id}/steer`,path:{assistant_id:p(),id:e},body:{instruction:t}});if(!r?.ok)throw Error(`Failed to steer ACP run: ${r?.status}`);return n}export{c as a,l as i,m as n,s as o,f as r,h as t};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-Bj8_eutd.js";import{t as n}from"./react-BFJW0bSv.js";import{t as r}from"./button-Dy5001j6.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./typography-DEI9Ra9z.js";import{t as o}from"./createLucideIcon-CAM1RhH8.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./acp-run-actions-BWR9i8MT.js";import{t as p}from"./arrow-left-C2ylPLHq.js";import{t as m}from"./brain-BIzJCPA6.js";import{t as h}from"./chevron-down-B5A-0g8A.js";import{t as g}from"./chevron-right-HU6H84S0.js";import{t as _}from"./circle-check-CjGnAahM.js";import{t as v}from"./circle-minus-DNfBAj4g.js";import{w as y}from"./menu-BvjhxZo7.js";import{t as b}from"./code-qafFA0_-.js";import{t as x}from"./file-text-Br730Q4B.js";import{t as ee}from"./globe-CMtjL_s_.js";import{t as te}from"./repeat-GCVYEp1h.js";import{t as ne}from"./search-BVW-n8to.js";import{t as S}from"./send-Q71Exj3z.js";import{t as re}from"./square-D_e8nR-F.js";import{t as C}from"./terminal-CdCI6wMV.js";import{t as ie}from"./trash-2-L5LNgw9o.js";import{t as ae}from"./triangle-alert-CQfiAg_t.js";import{t as oe}from"./x-JBAsSOmg.js";import"./src-te3YTBG-.js";import{t as se}from"./tag-NXcyiTkK.js";import{t as w}from"./chat-markdown-message-CdM44BjA.js";import{a as T,i as ce,n as E,r as D}from"./acp-run-store-B_eDLRwl.js";import{t as O}from"./three-dot-indicator-BMvKQ_On.js";import{t as le}from"./status-badge-pill-wJPMXQk1.js";var ue=o(`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`}]]),k=e(n(),1),A=``;function j(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 de(e){return(e.messageId?.startsWith(`local-marker-`)??!1)||(e.content?.startsWith(`↻ Steering: `)??!1)}function M(e){let t=e??``;return t.startsWith(`↻ Steering: `)?t.slice(E.length):t}function N(e){let t=e[e.length-1];t&&(t.kind===`agent`||t.kind===`thinking`)&&!t.isComplete&&(e[e.length-1]={...t,isComplete:!0})}function P(e,t){if(t.updateType===`agent_message_chunk`&&de(t)){N(e),e.push({kind:`user`,id:t.messageId??`steer-${e.length}`,content:M(t.content)});return}switch(t.updateType){case`user_message_chunk`:{let n=t.messageId??A,r=M(t.content),i=e[e.length-1];i&&i.kind===`user`&&i.id===n?e[e.length-1]={...i,content:i.content+r}:(N(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??A,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!==A&&r&&r.kind===`agent`&&r.messageId===A&&!r.isComplete&&r.content===(t.content??``)){e[e.length-1]={...r,messageId:n};return}N(e),e.push({kind:`agent`,messageId:n,content:t.content??``,isComplete:!1});return}case`agent_thought_chunk`:{let n=t.messageId??A,r=e[e.length-1];if(r&&r.kind===`thinking`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}N(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;N(e),e.push({kind:`tool`,toolCallId:n,title:t.toolTitle??``,toolKind:t.toolKind,status:j(t.toolStatus,`running`),content:t.content,locations:F(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=F(t);e[r]={...i,title:t.toolTitle??i.title,toolKind:t.toolKind??i.toolKind,status:j(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=fe(t.content);if(n===null)return;let r=e.findIndex(e=>e.kind===`plan`),i={kind:`plan`,entries:n};r===-1?(N(e),e.push(i)):e[r]=i;return}}}function F(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 fe(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 pe(e){let t=[];for(let n of e)P(t,n);return t}function me(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 I(){let e=null,t=[];function n(n){return t=pe(n),e=n,t}function r(r){let i=me(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++)P(n,r[e]);return e=r,t=n,t}case`mutate-last`:case`fallback`:return n(r)}}return{project:r}}function L(e){let t=(0,k.useRef)(null);return t.current??=I(),t.current.project(e)}function R(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=z(e);t&&r.push(t)}return r}function z(e){if(typeof e!=`object`||!e)return null;let t=e;switch(t.type){case`content`:return{type:`content`,text:he(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=ge(t);return e===void 0?{type:`terminal`}:{type:`terminal`,text:e}}default:return null}}function he(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.text;if(typeof t==`string`)return t}return``}function ge(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 B(e){if(typeof e!=`object`||!e)return;let t=e.command;return typeof t==`string`?t:void 0}function V(e){return R(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"./chunk-jRWAZmH_.js";import{t}from"./capture-error-Bj8_eutd.js";import{t as n}from"./react-BFJW0bSv.js";import{t as r}from"./button-Dy5001j6.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./typography-DEI9Ra9z.js";import{t as o}from"./createLucideIcon-CAM1RhH8.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./acp-run-actions-BH8wuBAL.js";import{t as p}from"./arrow-left-C2ylPLHq.js";import{t as m}from"./brain-BIzJCPA6.js";import{t as h}from"./chevron-down-B5A-0g8A.js";import{t as g}from"./chevron-right-HU6H84S0.js";import{t as _}from"./circle-check-CjGnAahM.js";import{t as v}from"./circle-minus-DNfBAj4g.js";import{w as y}from"./menu-BvjhxZo7.js";import{t as b}from"./code-qafFA0_-.js";import{t as x}from"./file-text-Br730Q4B.js";import{t as ee}from"./globe-CMtjL_s_.js";import{t as te}from"./repeat-GCVYEp1h.js";import{t as ne}from"./search-BVW-n8to.js";import{t as S}from"./send-Q71Exj3z.js";import{t as re}from"./square-D_e8nR-F.js";import{t as C}from"./terminal-CdCI6wMV.js";import{t as ie}from"./trash-2-L5LNgw9o.js";import{t as ae}from"./triangle-alert-CQfiAg_t.js";import{t as oe}from"./x-JBAsSOmg.js";import"./src-te3YTBG-.js";import{t as se}from"./tag-NXcyiTkK.js";import{t as w}from"./chat-markdown-message-rxPKNeTx.js";import{a as T,i as ce,n as E,r as D}from"./acp-run-store-B_eDLRwl.js";import{t as O}from"./three-dot-indicator-BMvKQ_On.js";import{t as le}from"./status-badge-pill-wJPMXQk1.js";var ue=o(`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`}]]),k=e(n(),1),A=``;function j(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 de(e){return(e.messageId?.startsWith(`local-marker-`)??!1)||(e.content?.startsWith(`↻ Steering: `)??!1)}function M(e){let t=e??``;return t.startsWith(`↻ Steering: `)?t.slice(E.length):t}function N(e){let t=e[e.length-1];t&&(t.kind===`agent`||t.kind===`thinking`)&&!t.isComplete&&(e[e.length-1]={...t,isComplete:!0})}function P(e,t){if(t.updateType===`agent_message_chunk`&&de(t)){N(e),e.push({kind:`user`,id:t.messageId??`steer-${e.length}`,content:M(t.content)});return}switch(t.updateType){case`user_message_chunk`:{let n=t.messageId??A,r=M(t.content),i=e[e.length-1];i&&i.kind===`user`&&i.id===n?e[e.length-1]={...i,content:i.content+r}:(N(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??A,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!==A&&r&&r.kind===`agent`&&r.messageId===A&&!r.isComplete&&r.content===(t.content??``)){e[e.length-1]={...r,messageId:n};return}N(e),e.push({kind:`agent`,messageId:n,content:t.content??``,isComplete:!1});return}case`agent_thought_chunk`:{let n=t.messageId??A,r=e[e.length-1];if(r&&r.kind===`thinking`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}N(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;N(e),e.push({kind:`tool`,toolCallId:n,title:t.toolTitle??``,toolKind:t.toolKind,status:j(t.toolStatus,`running`),content:t.content,locations:F(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=F(t);e[r]={...i,title:t.toolTitle??i.title,toolKind:t.toolKind??i.toolKind,status:j(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=fe(t.content);if(n===null)return;let r=e.findIndex(e=>e.kind===`plan`),i={kind:`plan`,entries:n};r===-1?(N(e),e.push(i)):e[r]=i;return}}}function F(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 fe(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 pe(e){let t=[];for(let n of e)P(t,n);return t}function me(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 I(){let e=null,t=[];function n(n){return t=pe(n),e=n,t}function r(r){let i=me(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++)P(n,r[e]);return e=r,t=n,t}case`mutate-last`:case`fallback`:return n(r)}}return{project:r}}function L(e){let t=(0,k.useRef)(null);return t.current??=I(),t.current.project(e)}function R(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=z(e);t&&r.push(t)}return r}function z(e){if(typeof e!=`object`||!e)return null;let t=e;switch(t.type){case`content`:return{type:`content`,text:he(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=ge(t);return e===void 0?{type:`terminal`}:{type:`terminal`,text:e}}default:return null}}function he(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.text;if(typeof t==`string`)return t}return``}function ge(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 B(e){if(typeof e!=`object`||!e)return;let t=e.command;return typeof t==`string`?t:void 0}function V(e){return R(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 H(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 U(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 W=i();function _e({content:e,isComplete:t}){return(0,W.jsxs)(`div`,{"data-testid":`acp-chat-agent-message`,className:`flex w-full flex-col items-start text-chat text-[var(--content-default)]`,children:[(0,W.jsx)(w,{content:e}),!t&&(0,W.jsx)(O,{className:`mt-1`,"data-testid":`acp-chat-agent-streaming`})]})}function ve({entries:e}){return e.length===0?null:(0,W.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,W.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-[var(--content-tertiary)]`,children:[(0,W.jsx)(c,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(a,{variant:`body-small-emphasised`,className:`text-inherit`,children:`Plan`})]}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.map((e,t)=>(0,W.jsxs)(`li`,{"data-testid":`acp-chat-plan-entry`,"data-checked":e.checked,className:`flex items-start gap-2`,children:[e.checked?(0,W.jsx)(_,{"aria-hidden":!0,className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}):(0,W.jsx)(y,{"aria-hidden":!0,className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-disabled)]`}),(0,W.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 ye(e){switch(e){case`max_tokens`:case`max_turn_requests`:return`Stopped: limit reached`;case`refusal`:return`Refused`;case`cancelled`:return`Cancelled`;default:return`Completed`}}function be(e){return new Date(e).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function G({completedAt:e}){return e===void 0?null:(0,W.jsxs)(`span`,{"data-testid":`acp-chat-terminal-time`,children:[`at `,be(e)]})}function xe({status:e,stopReason:t,error:n,completedAt:r}){if(T(e))return null;if(e===`failed`)return(0,W.jsxs)(`div`,{"data-testid":`acp-chat-terminal-block`,"data-terminal-kind":`failed`,className:`flex items-start gap-2 rounded-lg bg-[var(--system-negative-weak)] px-3 py-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,W.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,W.jsx)(ae,{className:`h-4 w-4`})}),(0,W.jsx)(`span`,{children:n??`Run failed`})]});if(e===`cancelled`)return(0,W.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,W.jsx)(v,{"aria-hidden":!0,className:`h-4 w-4 shrink-0`}),(0,W.jsx)(`span`,{children:`Cancelled`}),(0,W.jsx)(G,{completedAt:r})]});let i=ye(t);return(0,W.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,W.jsx)(_,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,W.jsx)(`span`,{children:i}),(0,W.jsx)(G,{completedAt:r})]})}function Se({showDot:e,isLast:t,children:n}){return(0,W.jsxs)(`div`,{className:`relative flex items-start gap-2${t?``:` pb-4`}`,children:[!t&&(0,W.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,W.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,W.jsx)(`span`,{className:`h-[5px] w-[5px] rounded-full bg-[var(--content-disabled)]`})}):(0,W.jsx)(`span`,{"aria-hidden":!0,className:`h-[14px] w-[14px] shrink-0`}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:n})]})}function Ce({content:e,isComplete:t}){let[n,r]=(0,k.useState)(null),i=n??!t,a=e.trim().length>0,o=t?`Thought process`:`Thinking`,s=t?(0,W.jsx)(m,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,W.jsx)(O,{dotSize:5,className:`shrink-0`,"data-testid":`acp-chat-thinking-streaming`});return a?(0,W.jsxs)(`div`,{"data-testid":`acp-chat-thinking-block`,className:`w-full`,children:[(0,W.jsxs)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>r(!i),"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:[i?(0,W.jsx)(h,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,W.jsx)(g,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),s,(0,W.jsx)(`span`,{children:o})]}),i&&(0,W.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,W.jsx)(w,{content:e})})]}):(0,W.jsx)(`div`,{"data-testid":`acp-chat-thinking-block`,className:`w-full`,children:(0,W.jsxs)(`div`,{className:`flex w-full items-center gap-1.5 text-body-small-default text-[var(--content-tertiary)]`,children:[s,(0,W.jsx)(`span`,{children:o})]})})}var we={running:`neutral`,completed:`positive`,error:`negative`,ended:`neutral`},Te={running:`Running`,completed:`Completed`,error:`Failed`,ended:`Ended`},Ee={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`},De=`Tool call`,Oe={read:x,edit:ue,delete:ie,move:s,search:ne,execute:C,think:m,fetch:ee,switch_mode:te},ke=new Set([`read`,`edit`,`delete`,`move`]);function Ae({toolKind:e}){return(0,W.jsx)(e&&Oe[e]||b,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`})}function K({label:e,value:t,testId:n}){return(0,W.jsxs)(`div`,{"data-testid":n,children:[(0,W.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-tertiary)]`,children:e}),(0,W.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 je({block:e,isTerminal:t=!1,onOpenDiff:n,onOpenOutput:r}){let[i,o]=(0,k.useState)(!1),s=(0,k.useMemo)(()=>R(e.content),[e.content]),c=(0,k.useMemo)(()=>V(e.content),[e.content]),l=(0,k.useMemo)(()=>c.split(`
3
3
  `).map(e=>e.trim()).find(e=>e.length>0&&!e.startsWith("```"))||`View output`,[c]),u=(0,k.useMemo)(()=>U(s,e.locations),[s,e.locations]),d=t&&e.status===`running`?`ended`:e.status,f=d===`running`,p=e.toolKind&&Ee[e.toolKind]||De,m=B(e.rawInput)??e.title,_=m&&m!==p&&(!ke.has(e.toolKind??``)||u.length===0)?m:null,v=H(e.rawInput),y=H(e.rawOutput),b=v!==void 0||y!==void 0;return(0,W.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,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Ae,{toolKind:e.toolKind}),(0,W.jsx)(a,{variant:`body-small-emphasised`,className:`min-w-0 flex-1 truncate text-[var(--content-default)]`,title:e.title,children:p}),(0,W.jsx)(se,{tone:we[d],"data-testid":`acp-chat-tool-status`,children:Te[d]}),f&&(0,W.jsx)(O,{className:`shrink-0`,"data-testid":`acp-chat-tool-running`})]}),_&&(0,W.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:_}),u.length>0&&(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:u.map(t=>{let r=t.oldText!==void 0||t.newText!==void 0,i=`flex max-w-full items-center gap-1.5 rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] px-2 py-1 text-body-small-default text-[var(--content-secondary)]`;return r?(0,W.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-file-chip`,onClick:()=>n(e.toolCallId,t),title:t.path,className:`${i} cursor-pointer transition-colors hover:bg-[var(--surface-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--border-focus)]`,children:[(0,W.jsx)(x,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`truncate font-mono`,children:t.path})]},t.path):(0,W.jsxs)(`span`,{"data-testid":`acp-chat-tool-file-ref`,title:t.path,className:i,children:[(0,W.jsx)(x,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`truncate font-mono`,children:t.path})]},t.path)})}),c.length>0&&(0,W.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-output-open`,onClick:()=>r?.(e.toolCallId),className:`mt-2 flex w-full items-center gap-2 rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--surface-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--border-focus)]`,children:[(0,W.jsx)(C,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-body-small-default text-[var(--content-secondary)]`,children:l}),(0,W.jsx)(g,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`})]}),b&&(0,W.jsxs)(`div`,{className:`mt-2`,"data-testid":`acp-chat-tool-raw`,children:[(0,W.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-raw-toggle`,"aria-expanded":i,onClick:()=>o(e=>!e),className:`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-default)]`,children:[i?(0,W.jsx)(h,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,W.jsx)(g,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(`span`,{children:i?`Hide raw input/output`:`Show raw input/output`})]}),i&&(0,W.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-2`,children:[v!==void 0&&(0,W.jsx)(K,{label:`Raw input`,value:v,testId:`acp-chat-tool-raw-input`}),y!==void 0&&(0,W.jsx)(K,{label:`Raw output`,value:y,testId:`acp-chat-tool-raw-output`})]})]})]})}function Me({content:e}){return(0,W.jsx)(`div`,{"data-testid":`acp-chat-user-turn`,className:`flex w-full justify-end`,children:(0,W.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 Ne(e,t){let n=e=>new Intl.NumberFormat(void 0,{style:`currency`,currency:t}).format(e);return e>0&&e<.01?`<${n(.01)}`:n(e)}var q=new Intl.NumberFormat(`en-US`);function J({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`flex items-baseline gap-1`,"data-usage-stat":e.toLowerCase(),children:[(0,W.jsx)(a,{variant:`label-small-default`,className:`text-[var(--content-tertiary)]`,children:e}),(0,W.jsx)(a,{variant:`body-small-default`,className:`text-[var(--content-secondary)] tabular-nums`,children:t})]})}function Pe({entry:e}){let{inputTokens:t,outputTokens:n,costAmount:r,costCurrency:i}=e;if(t===void 0&&n===void 0)return null;let a=t??0,o=n??0,s=r!=null&&i!=null;return(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,"data-testid":`acp-usage-meter`,children:[(0,W.jsx)(J,{label:`Input`,value:q.format(a)}),(0,W.jsx)(J,{label:`Output`,value:q.format(o)}),s&&(0,W.jsx)(J,{label:`Cost`,value:Ne(r,i)})]})}function Fe({content:e}){return(0,W.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,W.jsx)(w,{content:V(e),hardLineBreaks:!0})})}var Y=2e3;function X(e){if(e===``)return[];let t=e.split(`
4
4
  `);return e.endsWith(`
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{t as i}from"./typography-DEI9Ra9z.js";import{H as a,S as o,c as s,l as c,x as l}from"./risk-DmicWnoH.js";import{_ as u,a as d,f,g as p,i as m,r as h,v as g,y as _}from"./transcript-message-body-shared-D3uxHQt5.js";import{t as v}from"./chevron-left-CytMddTB.js";import"./src-te3YTBG-.js";import{t as y}from"./chat-markdown-message-CdM44BjA.js";import{t as b}from"./workflow-store-CMNMu-fc.js";import{t as x}from"./background-task-store-DMP8ByUq.js";import{r as S}from"./acp-run-store-B_eDLRwl.js";import{C,a as w,i as T,n as E,r as D,s as O,y as k}from"./site-favicon-DzmWythg.js";import{t as A}from"./detail-shell-Cyqr5FXJ.js";import{ToolDetailBody as j,t as M}from"./tool-detail-panel-BqhEUAMJ.js";var N=e(t(),1);function P(e,t,n){let r=m(t,n.workflow),i=e=>{let t=f(e,n.workflow.byToolUseId);if(t!==null&&r.has(t))return!0;let i=h(e,n.acpByToolUseId);if(i!==null&&n.acpById[i]!==void 0)return!0;let a=d(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 F(e,t){let n=o(),r=b.use.byId(),i=b.use.byToolUseId(),l=b.use.notFoundRunIds(),u=b.use.hydrationFailedRunIds(),d=S.use.byId(),f=S.use.byToolUseId(),p=x.use.byId();return(0,N.useMemo)(()=>{if(!e||t==null)return null;let o=n.find(t=>a(t).includes(e));if(!o)return null;let m=c(o.contentBlocks??[],{splitInlineThinking:o.role!==`user`})[t];if(!m||m.type!==`activity`)return null;let{cardItems:h,toolCalls:g}=s(m.items);return P(h,g,{workflow:{byId:r,byToolUseId:i,notFoundRunIds:l,hydrationFailedRunIds:u},acpById:d,acpByToolUseId:f,backgroundTaskById:p})},[n,e,t,r,i,l,u,d,f,p])}var I=r(),L=60;function R({payload:e,onClose:t}){let[r,a]=(0,N.useState)(null),o=F(e.messageId,e.groupIndex),s=o?.items??e.items,c=o?.toolCalls??e.toolCalls,l=_(s),d=u(l.steps),f=g(l.state,l.steps),m=f===`loading`,h=p(f,l.totalDurationLabel??``,d.failed),y=m&&l.currentStepTitle||h,b=new Map(c.map(e=>[e.id,e])),x=r?r.kind===`thinking`?`Thinking`:r.activity||r.title:``;return(0,I.jsx)(A,{titleNode:r?(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 py-0.5`,children:[(0,I.jsx)(n,{variant:`ghost`,iconOnly:(0,I.jsx)(v,{}),"aria-label":`Back to all steps`,tooltip:`All steps`,onClick:()=>a(null),className:`-ml-2.5 shrink-0`}),(0,I.jsx)(i,{variant:`title-medium`,className:`min-w-0 shrink truncate leading-snug text-[var(--content-default)]`,children:x})]}):(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 py-0.5`,children:[(0,I.jsx)(i,{variant:`title-medium`,className:`min-w-0 shrink truncate leading-snug text-[var(--content-default)]`,children:m?(0,I.jsx)(C,{children:y}):y}),l.stepCount?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{"aria-hidden":!0,className:`size-[3px] shrink-0 rounded-full bg-[var(--content-tertiary)]`}),(0,I.jsx)(i,{variant:`title-medium`,className:`shrink-0 whitespace-nowrap leading-snug text-[var(--content-secondary)]`,children:l.stepCount})]}):null]}),closeLabel:`Close steps`,onClose:t,children:r?(0,I.jsx)(B,{detail:r}):(0,I.jsx)(O,{steps:l.steps,timeline:!0,renderStep:t=>(0,I.jsx)(z,{step:t,activeDetail:r,onOpenDetail:a,lookupToolCall:e=>b.get(e),messageId:e.messageId,groupIndex:e.groupIndex})})})}function z({step:e,activeDetail:t,onOpenDetail:n,lookupToolCall:r,messageId:i,groupIndex:a}){if(e.kind===`thinking`){let t=i!=null&&e.thinkingItemIndex!=null?{messageId:i,thinkingGroupIndex:a,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,I.jsx)(T,{iconName:`brain`,label:l(e.text,L),ariaLabel:`View thinking`,active:!1,onClick:()=>n({kind:`thinking`,toolCallId:``,toolName:``,title:`Thinking`,activity:``,input:{},status:`completed`,thinkingText:e.text,...t})})}if(e.kind===`web_search`)return(0,I.jsx)(D,{step:e});if(e.kind===`web_search_error`)return(0,I.jsx)(E,{step:e});if(e.kind!==`tool`)return(0,I.jsx)(w,{step:e});let o=r(e.toolCallId);return(0,I.jsx)(T,{iconName:e.iconName,label:e.activity||e.info||e.title,active:t?.toolCallId===e.toolCallId,onClick:()=>{o&&n(k(o))}})}function B({detail:e}){let t=M(e.kind===`thinking`?e.messageId:void 0,e.thinkingGroupIndex,e.thinkingItemIndex);return(0,I.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.kind===`thinking`?(0,I.jsx)(y,{content:t??e.thinkingText??``,hardLineBreaks:!0}):(0,I.jsx)(j,{detail:e})})}export{R as ActivityStepsPanel};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{t as i}from"./typography-DEI9Ra9z.js";import{H as a,S as o,c as s,l as c,x as l}from"./risk-CdT92Vqr.js";import{_ as u,a as d,f,g as p,i as m,r as h,v as g,y as _}from"./transcript-message-body-shared-D9_d2c2X.js";import{t as v}from"./chevron-left-CytMddTB.js";import"./src-te3YTBG-.js";import{t as y}from"./chat-markdown-message-rxPKNeTx.js";import{t as b}from"./workflow-store-lM7yKbUo.js";import{t as x}from"./background-task-store-DMP8ByUq.js";import{r as S}from"./acp-run-store-B_eDLRwl.js";import{C,a as w,i as T,n as E,r as D,s as O,y as k}from"./site-favicon-BB1pYWLF.js";import{t as A}from"./detail-shell-Cyqr5FXJ.js";import{ToolDetailBody as j,t as M}from"./tool-detail-panel-DFrWEWKG.js";var N=e(t(),1);function P(e,t,n){let r=m(t,n.workflow),i=e=>{let t=f(e,n.workflow.byToolUseId);if(t!==null&&r.has(t))return!0;let i=h(e,n.acpByToolUseId);if(i!==null&&n.acpById[i]!==void 0)return!0;let a=d(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 F(e,t){let n=o(),r=b.use.byId(),i=b.use.byToolUseId(),l=b.use.notFoundRunIds(),u=b.use.hydrationFailedRunIds(),d=S.use.byId(),f=S.use.byToolUseId(),p=x.use.byId();return(0,N.useMemo)(()=>{if(!e||t==null)return null;let o=n.find(t=>a(t).includes(e));if(!o)return null;let m=c(o.contentBlocks??[],{splitInlineThinking:o.role!==`user`})[t];if(!m||m.type!==`activity`)return null;let{cardItems:h,toolCalls:g}=s(m.items);return P(h,g,{workflow:{byId:r,byToolUseId:i,notFoundRunIds:l,hydrationFailedRunIds:u},acpById:d,acpByToolUseId:f,backgroundTaskById:p})},[n,e,t,r,i,l,u,d,f,p])}var I=r(),L=60;function R({payload:e,onClose:t}){let[r,a]=(0,N.useState)(null),o=F(e.messageId,e.groupIndex),s=o?.items??e.items,c=o?.toolCalls??e.toolCalls,l=_(s),d=u(l.steps),f=g(l.state,l.steps),m=f===`loading`,h=p(f,l.totalDurationLabel??``,d.failed),y=m&&l.currentStepTitle||h,b=new Map(c.map(e=>[e.id,e])),x=r?r.kind===`thinking`?`Thinking`:r.activity||r.title:``;return(0,I.jsx)(A,{titleNode:r?(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 py-0.5`,children:[(0,I.jsx)(n,{variant:`ghost`,iconOnly:(0,I.jsx)(v,{}),"aria-label":`Back to all steps`,tooltip:`All steps`,onClick:()=>a(null),className:`-ml-2.5 shrink-0`}),(0,I.jsx)(i,{variant:`title-medium`,className:`min-w-0 shrink truncate leading-snug text-[var(--content-default)]`,children:x})]}):(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 py-0.5`,children:[(0,I.jsx)(i,{variant:`title-medium`,className:`min-w-0 shrink truncate leading-snug text-[var(--content-default)]`,children:m?(0,I.jsx)(C,{children:y}):y}),l.stepCount?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{"aria-hidden":!0,className:`size-[3px] shrink-0 rounded-full bg-[var(--content-tertiary)]`}),(0,I.jsx)(i,{variant:`title-medium`,className:`shrink-0 whitespace-nowrap leading-snug text-[var(--content-secondary)]`,children:l.stepCount})]}):null]}),closeLabel:`Close steps`,onClose:t,children:r?(0,I.jsx)(B,{detail:r}):(0,I.jsx)(O,{steps:l.steps,timeline:!0,renderStep:t=>(0,I.jsx)(z,{step:t,activeDetail:r,onOpenDetail:a,lookupToolCall:e=>b.get(e),messageId:e.messageId,groupIndex:e.groupIndex})})})}function z({step:e,activeDetail:t,onOpenDetail:n,lookupToolCall:r,messageId:i,groupIndex:a}){if(e.kind===`thinking`){let t=i!=null&&e.thinkingItemIndex!=null?{messageId:i,thinkingGroupIndex:a,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,I.jsx)(T,{iconName:`brain`,label:l(e.text,L),ariaLabel:`View thinking`,active:!1,onClick:()=>n({kind:`thinking`,toolCallId:``,toolName:``,title:`Thinking`,activity:``,input:{},status:`completed`,thinkingText:e.text,...t})})}if(e.kind===`web_search`)return(0,I.jsx)(D,{step:e});if(e.kind===`web_search_error`)return(0,I.jsx)(E,{step:e});if(e.kind!==`tool`)return(0,I.jsx)(w,{step:e});let o=r(e.toolCallId);return(0,I.jsx)(T,{iconName:e.iconName,label:e.activity||e.info||e.title,active:t?.toolCallId===e.toolCallId,onClick:()=>{o&&n(k(o))}})}function B({detail:e}){let t=M(e.kind===`thinking`?e.messageId:void 0,e.thinkingGroupIndex,e.thinkingItemIndex);return(0,I.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.kind===`thinking`?(0,I.jsx)(y,{content:t??e.thinkingText??``,hardLineBreaks:!0}):(0,I.jsx)(j,{detail:e})})}export{R as ActivityStepsPanel};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{n as r}from"./QueryClientProvider-CMu7CkQU.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./key-round-0Zop_GsZ.js";import{t as o}from"./loader-circle-XREx3i4W.js";import{t as s}from"./input-hw3el2GJ.js";import{t as c}from"./modal-BR4CUFBd.js";import{n as l}from"./toast-LgLp4obE.js";import{Gt as u}from"./react-query.gen-r3I6j8-1.js";import{t as d}from"./use-active-assistant-id-CldxA_-M.js";var f=e(t(),1),p=i();function m(e){return[`credentials-list`,e]}function h({open:e,onClose:t,onSaved:i,initialValues:h,successToastMessage:g=`Credential saved.`}){let _=d(),v=r(),[y,b]=(0,f.useState)(h?.service??``),[x,S]=(0,f.useState)(h?.field??``),[C,w]=(0,f.useState)(h?.value??``),[T,E]=(0,f.useState)(h?.label??``),D=(0,f.useRef)(h);(0,f.useLayoutEffect)(()=>{D.current=h},[h]),(0,f.useEffect)(()=>{if(e){let e=D.current;b(e?.service??``),S(e?.field??``),w(e?.value??``),E(e?.label??``)}},[e]);let O=u({onError:e=>{l.error(e.message||`Failed to save credential`)}}),k=O.isPending,A=()=>{b(``),S(``),w(``),E(``),t()};return(0,p.jsx)(c.Root,{open:e,onOpenChange:e=>{!e&&!k&&A()},children:(0,p.jsx)(c.Content,{size:`sm`,children:(0,p.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=y.trim(),n=x.trim();if(!t||!n||!C.trim())return;let r=T.trim()||void 0;O.mutate({path:{assistant_id:_},body:{service:t,field:n,value:C,label:r}},{onSuccess:()=>{v.invalidateQueries({queryKey:m(_)}),l.success(g),i?.({service:t,field:n,label:r}),A()}})},children:[(0,p.jsxs)(c.Header,{children:[(0,p.jsx)(c.Title,{icon:a,children:`Add credential`}),(0,p.jsx)(c.Description,{children:`Add an API key or token to let tools and integrations use it.`})]}),(0,p.jsxs)(c.Body,{className:`flex flex-col gap-3`,children:[(0,p.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row`,children:[(0,p.jsx)(s,{label:`Service`,type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`e.g. github`,autoFocus:!0,fullWidth:!0}),(0,p.jsx)(s,{label:`Field`,type:`text`,value:x,onChange:e=>S(e.target.value),placeholder:`e.g. api_token`,fullWidth:!0})]}),(0,p.jsx)(s,{label:`Value`,type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:`Enter the secret value`,fullWidth:!0}),(0,p.jsx)(s,{label:`Label (optional)`,type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`e.g. GitHub personal access token`,fullWidth:!0})]}),(0,p.jsxs)(c.Footer,{children:[(0,p.jsx)(n,{type:`button`,variant:`outlined`,onClick:A,disabled:k,children:`Cancel`}),(0,p.jsx)(n,{type:`submit`,variant:`primary`,disabled:k||!y.trim()||!x.trim()||!C.trim(),leftIcon:k?(0,p.jsx)(o,{className:`animate-spin`,"aria-hidden":!0}):void 0,children:`Save`})]})]})})})}export{m as n,h as t};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{n as r}from"./QueryClientProvider-CMu7CkQU.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./key-round-0Zop_GsZ.js";import{t as o}from"./loader-circle-XREx3i4W.js";import{t as s}from"./input-hw3el2GJ.js";import{t as c}from"./modal-BR4CUFBd.js";import{n as l}from"./toast-LgLp4obE.js";import{Gt as u}from"./react-query.gen-C5c1Acuq.js";import{t as d}from"./use-active-assistant-id-CldxA_-M.js";var f=e(t(),1),p=i();function m(e){return[`credentials-list`,e]}function h({open:e,onClose:t,onSaved:i,initialValues:h,successToastMessage:g=`Credential saved.`}){let _=d(),v=r(),[y,b]=(0,f.useState)(h?.service??``),[x,S]=(0,f.useState)(h?.field??``),[C,w]=(0,f.useState)(h?.value??``),[T,E]=(0,f.useState)(h?.label??``),D=(0,f.useRef)(h);(0,f.useLayoutEffect)(()=>{D.current=h},[h]),(0,f.useEffect)(()=>{if(e){let e=D.current;b(e?.service??``),S(e?.field??``),w(e?.value??``),E(e?.label??``)}},[e]);let O=u({onError:e=>{l.error(e.message||`Failed to save credential`)}}),k=O.isPending,A=()=>{b(``),S(``),w(``),E(``),t()};return(0,p.jsx)(c.Root,{open:e,onOpenChange:e=>{!e&&!k&&A()},children:(0,p.jsx)(c.Content,{size:`sm`,children:(0,p.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=y.trim(),n=x.trim();if(!t||!n||!C.trim())return;let r=T.trim()||void 0;O.mutate({path:{assistant_id:_},body:{service:t,field:n,value:C,label:r}},{onSuccess:()=>{v.invalidateQueries({queryKey:m(_)}),l.success(g),i?.({service:t,field:n,label:r}),A()}})},children:[(0,p.jsxs)(c.Header,{children:[(0,p.jsx)(c.Title,{icon:a,children:`Add credential`}),(0,p.jsx)(c.Description,{children:`Add an API key or token to let tools and integrations use it.`})]}),(0,p.jsxs)(c.Body,{className:`flex flex-col gap-3`,children:[(0,p.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row`,children:[(0,p.jsx)(s,{label:`Service`,type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`e.g. github`,autoFocus:!0,fullWidth:!0}),(0,p.jsx)(s,{label:`Field`,type:`text`,value:x,onChange:e=>S(e.target.value),placeholder:`e.g. api_token`,fullWidth:!0})]}),(0,p.jsx)(s,{label:`Value`,type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:`Enter the secret value`,fullWidth:!0}),(0,p.jsx)(s,{label:`Label (optional)`,type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`e.g. GitHub personal access token`,fullWidth:!0})]}),(0,p.jsxs)(c.Footer,{children:[(0,p.jsx)(n,{type:`button`,variant:`outlined`,onClick:A,disabled:k,children:`Cancel`}),(0,p.jsx)(n,{type:`submit`,variant:`primary`,disabled:k||!y.trim()||!x.trim()||!C.trim(),leftIcon:k?(0,p.jsx)(o,{className:`animate-spin`,"aria-hidden":!0}):void 0,children:`Save`})]})]})})})}export{m as n,h as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{a as t,c as n,i as r}from"./local-settings-C-dW2vkq.js";import{r as i,t as a}from"./capture-error-Bj8_eutd.js";import{t as o}from"./react-BFJW0bSv.js";import{t as s}from"./button-Dy5001j6.js";import{m as c,u as l}from"./chunk-5KNZJZUH-Bsoom5--.js";import{n as u}from"./QueryClientProvider-CMu7CkQU.js";import{t as d}from"./useQuery-Bz-fbQ-m.js";import{t as f}from"./useMutation-CXGTrp4W.js";import{t as p}from"./jsx-runtime-D3ZM-ToX.js";import{t as m}from"./cn-CJf7MmLX.js";import{t as h}from"./typography-DEI9Ra9z.js";import{t as g}from"./createLucideIcon-CAM1RhH8.js";import{t as _}from"./check-sC49_hjU.js";import{t as v}from"./chevron-down-B5A-0g8A.js";import{t as y}from"./circle-alert-DVCpoZrc.js";import{t as b}from"./circle-check-CjGnAahM.js";import{t as x}from"./clock-BYTc0Ds9.js";import{t as S}from"./external-link-CS0aVYGt.js";import{t as C}from"./info-vgPTIsGI.js";import{t as w}from"./list-DNbTcxAh.js";import{t as T}from"./loader-circle-XREx3i4W.js";import{t as E}from"./mail-CMdPNysl.js";import{t as D}from"./search-BVW-n8to.js";import{t as O}from"./trash-2-L5LNgw9o.js";import{t as k}from"./triangle-alert-CQfiAg_t.js";import{t as A}from"./notice-BMK7xqUw.js";import{M as j}from"./src-te3YTBG-.js";import{t as M}from"./tag-NXcyiTkK.js";import{t as N}from"./popover-BRpYVASI.js";import{t as P}from"./input-hw3el2GJ.js";import{t as F}from"./toggle-lfnhEAcN.js";import{t as I}from"./modal-BR4CUFBd.js";import{n as L}from"./toast-LgLp4obE.js";import{t as R}from"./confirm-dialog-UYFm4osC.js";import{t as z}from"./dropdown-BCfnSdIZ.js";import{$ as B,B as V,C as H,F as U,G as W,H as G,I as ee,J as K,K as q,L as te,M as ne,N as J,P as Y,Q as X,R as re,S as ie,T as ae,U as oe,V as se,W as ce,X as le,Y as ue,Z as de,_ as fe,a as pe,at as me,c as he,ct as ge,d as _e,et as ve,f as ye,g as be,h as xe,i as Se,it as Ce,j as we,l as Te,lt as Ee,m as De,n as Oe,nt as ke,o as Ae,ot as je,p as Me,q as Ne,r as Pe,rt as Fe,s as Ie,st as Le,t as Re,tt as ze,u as Be,v as Ve,w as He,x as Ue,y as We,z as Ge}from"./use-sticky-profiles-mC9bd8xU.js";import{Ut as Ke,Wt as qe,ar as Je,ft as Ye,j as Xe,lt as Ze,wn as Qe}from"./sdk.gen-BVAVE6A_.js";import{Bt as $e,Ft as et,H as tt,V as nt,_t as rt,c as it,d as at,f as ot,l as st,m as ct,p as lt,u as ut}from"./react-query.gen-r3I6j8-1.js";import{t as dt}from"./assistant-identity-store-DIyVo8LV.js";import{i as ft,r as pt,t as mt}from"./utils-CnB60ZJN.js";import{r as ht}from"./api-errors-CFiCT7Ap.js";import{u as gt}from"./routes-D9sNqB_o.js";import{i as _t}from"./use-platform-gate-bFyCaLbM.js";import{r as vt}from"./use-is-org-ready-D0q2NIZU.js";import{c as yt,d as bt,f as xt,g as St,h as Ct,l as wt,lt as Tt,m as Et,o as Dt,p as Ot,s as kt,u as At,v as jt,y as Mt}from"./react-query.gen-BC3STDmV.js";import{a as Nt,i as Pt,n as Ft,o as It}from"./voice-list-IdN1mqlX.js";import{t as Lt}from"./platform-login-notice-BaCrIk0m.js";import{t as Rt}from"./use-active-assistant-id-CldxA_-M.js";import{t as zt}from"./detail-card-Du8OuE3q.js";import{t as Bt}from"./use-platform-assistant-id-Cm5BfOD8.js";import{t as Vt}from"./environment-store-Bft0lpgv.js";var Ht=g(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Z=e(o(),1),Q=p();function Ut({mode:e,onChange:t}){return(0,Q.jsx)(`div`,{className:`max-w-[280px]`,children:(0,Q.jsx)(j,{ariaLabel:`Service mode`,value:e,onChange:t,items:[{value:`managed`,label:`Managed`},{value:`your-own`,label:`Your Own`}]})})}function Wt({id:e,title:t,subtitle:n,mode:r,onModeChange:i,children:a}){return(0,Q.jsxs)(zt,{id:e,title:t,subtitle:n,accessory:(0,Q.jsx)(Ut,{mode:r,onChange:i}),children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:a})]})}function Gt({id:e,title:t,subtitle:n,children:r}){return(0,Q.jsxs)(zt,{id:e,title:t,subtitle:n,children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:r})]})}function Kt(){return(0,Q.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,Q.jsx)(C,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsxs)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:[`Managed services are metered and deducted from your Vellum account balance.`,` `,(0,Q.jsxs)(`a`,{href:`https://www.vellum.ai/docs/pricing`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--primary-base)] hover:underline`,children:[`View pricing`,(0,Q.jsx)(S,{className:`h-3.5 w-3.5`})]})]})]})}function qt({status:e,message:t,isLoading:n}){return n?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,children:[(0,Q.jsx)(T,{className:`h-3 w-3 animate-spin`}),`Checking domain…`]}):e?e===`verified`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-positive-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-positive-strong)]`,title:`DNS records have been verified. Your domain is ready to send and receive email.`,children:[(0,Q.jsx)(_,{className:`h-3 w-3`}),`Domain verified`]}):e===`pending`||e===`not_started`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-mid-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-mid-strong)]`,title:`DNS records have been provisioned. Waiting for the email provider to verify them — this usually takes a few minutes.`,children:[(0,Q.jsx)(x,{className:`h-3 w-3`}),`Verifying domain…`]}):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-negative-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-negative-strong)]`,title:`Domain verification failed. DNS records may not have propagated correctly. You could try releasing and re-registering the domain.`,children:[(0,Q.jsx)(y,{className:`h-3 w-3`}),`Verification failed`]}):(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,title:`Unable to retrieve domain verification status.`,children:`Unknown status`})}function Jt({onClick:e,disabled:t}){return(0,Q.jsx)(s,{onClick:e,disabled:t,children:`Save`})}function Yt({onClick:e,filled:t=!1}){return(0,Q.jsx)(s,{variant:t?`danger`:`dangerGhost`,onClick:e,children:`Reset`})}function Xt({guide:e}){return(0,Q.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,Q.jsx)(C,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{children:e.description}),(0,Q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[e.linkLabel,(0,Q.jsx)(S,{className:`h-3 w-3`})]})]})]})}var Zt=`__custom__`;function Qt(e){return e?!!(e.profile||e.provider||e.model):!1}function $t(e,t){let n=Qt(e);return n===Qt(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function en({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,onDraftChange:o,onToggle:s}){let c=Qt(i),l=!i||!c?``:i.provider||i.model?Zt:i.profile??``,u=l===Zt,d=se(),f=d[0]??me[0],p=d.find(e=>e===i?.provider)??f,m=Ee(p).map(e=>({value:e.id,label:e.displayName})),h=!!i?.provider&&!i?.model;function g(t){t===`__custom__`?o(e,{profile:null,provider:f,model:ge(f)??``}):t===``?o(e,null):o(e,{profile:t,provider:null,model:null})}function _(t){let n=ge(t)??``;o(e,{...i??{},profile:null,provider:t,model:n})}function v(t){o(e,{...i??{},model:t})}return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,Q.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,Q.jsxs)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:[`· Default: `,r]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c&&(0,Q.jsx)(z,{value:l,onChange:g,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,Q.jsx)(F,{checked:c,onChange:t=>s(e,t),"aria-label":`Override ${t}`})]})]}),c&&u&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{value:p??``,onChange:_,options:d.map(e=>({value:e,label:Le[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,Q.jsx)(z,{value:i?.model??``,onChange:v,options:m})]})]}),h&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:`Pick a model`})]})]})}function tn({isOpen:e,onClose:t,assistantId:n}){let r=(0,Z.useRef)(!1);return(0,Q.jsx)(I.Root,{open:e,onOpenChange:e=>{!e&&!r.current&&t()},children:e?(0,Q.jsx)(nn,{assistantId:n,onClose:t,onSavingChange:e=>{r.current=e}}):null})}function nn({assistantId:e,onClose:t,onSavingChange:n}){let r=u(),{data:i}=d({...it({path:{assistant_id:e}}),staleTime:3e4}),o=(0,Z.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),c=(0,Z.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),l=(0,Z.useMemo)(()=>i?.llm?.callSites??{},[i?.llm?.callSites]),f=(0,Z.useMemo)(()=>Ne(o,c),[o,c]),p=se(),m=$e({onSuccess:t=>{ut(r,{path:{assistant_id:e}},t)}}),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)({}),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),{data:E,isLoading:O,isError:k,refetch:A}=d({...at({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),j=(0,Z.useMemo)(()=>(E?.callSites??[]).filter(e=>e.id!==`mainAgent`),[E]),M=!O&&!k&&!!E&&!!i,N=(0,Z.useMemo)(()=>j.map(e=>e.id),[j]),F=(0,Z.useMemo)(()=>{if(!M)return{};let e={};for(let t of N)if(t in y)e[t]=y[t];else{let n=l[t];e[t]=n?{...n}:{}}return e},[M,N,l,y]),B=(0,Z.useMemo)(()=>new Set(N),[N]),V=(0,Z.useMemo)(()=>Object.entries(l).some(([e,t])=>B.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[l,B]),H=(0,Z.useMemo)(()=>{if(!M)return!1;for(let e of Object.keys(F))if(!$t(F[e],l[e]))return!0;return!1},[M,F,l]),U=(0,Z.useMemo)(()=>Object.values(F).some(e=>Qt(e)&&!!e?.provider&&!e?.model),[F]),W=(0,Z.useMemo)(()=>Se(f,[]).map(e=>({value:e.name,label:Oe(e)})),[f]),G=(0,Z.useCallback)(()=>{if(!_)return;let e={};for(let t of N)e[t]={profile:_};b(e)},[_,N]),ee=(0,Z.useCallback)(e=>[...Se(f,[e]).map(e=>({value:e.name,label:Oe(e)})),{value:Zt,label:`Custom`}],[f]),K=(0,Z.useMemo)(()=>{if(!h.trim())return j;let e=h.toLowerCase();return j.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[j,h]),q=(0,Z.useMemo)(()=>{if(!E)return[];let e=E.domains.map(e=>e.id),t=new Map(E.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=K.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let r=new Set(e),i=K.filter(e=>!r.has(e.domain));return i.length>0&&n.push({domain:{id:`other`,displayName:`Other`},sites:i}),n},[E,K]),te=(0,Z.useCallback)((e,t)=>{b(n=>({...n,[e]:t}))},[]),ne=(0,Z.useCallback)((e,t)=>{if(!t){b(t=>({...t,[e]:null}));return}let n=Pe(f,j.find(t=>t.id===e)?.defaultProfile);if(n)b(t=>({...t,[e]:{profile:n}}));else{let t=p[0]??me[0],n=ge(t)??``;b(r=>({...r,[e]:{provider:t,model:n}}))}},[j,f,p]),J=(0,Z.useCallback)(async()=>{S(!0),n?.(!0);try{let n={};for(let e of Object.keys(F)){let t=F[e]??null;n[e]=Qt(t)?{profile:t?.profile??null,provider:t?.provider??null,model:t?.model??null}:null}await m.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),L.success(`Overrides saved.`)}catch(e){L.error(`Failed to save overrides. Please try again.`),a(e,{context:`call_site_overrides_save`})}finally{S(!1),n?.(!1)}},[F,t,m,n,e]),Y=(0,Z.useCallback)(async()=>{S(!0),n?.(!0);try{let n={};for(let e of Object.keys(F))n[e]=null;await m.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),L.success(`Overrides reset.`)}catch(e){L.error(`Failed to reset overrides. Please try again.`),a(e,{context:`call_site_overrides_reset`})}finally{S(!1),n?.(!1)}},[F,t,m,n,e]);return(0,Q.jsxs)(I.Content,{size:`lg`,hideCloseButton:!0,children:[(0,Q.jsxs)(I.Header,{children:[(0,Q.jsx)(I.Title,{children:`Action Overrides`}),(0,Q.jsx)(I.Description,{children:`Customize which model profile specific actions should use. Uses your default profile if no override is set.`})]}),(0,Q.jsxs)(I.Body,{children:[(0,Q.jsx)(`div`,{className:`mb-4`,children:(0,Q.jsx)(P,{type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:`Search actions…`,leftIcon:(0,Q.jsx)(D,{className:`h-4 w-4`}),fullWidth:!0})}),W.length>0&&(0,Q.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-body-medium-default text-[var(--content-default)]`,children:`Use one profile for all actions`}),(0,Q.jsx)(z,{value:_,onChange:v,options:W,placeholder:`Choose profile…`,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:G,disabled:!_||!M||x,children:`Apply to all`})]}),O&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(T,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),k&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Couldn't load actions`}),(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Make sure your assistant is running`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>void A(),children:`Retry`})]}),!O&&!k&&E&&(0,Q.jsx)(`div`,{className:`space-y-4`,children:q.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No actions match your search.`}):q.map(({domain:e,sites:t})=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>{let t=(()=>{let t=F[e.id]??null;return!t||!Qt(t)?``:t.provider||t.model?`__custom__`:t.profile??``})(),n=e.defaultProfile?f.find(t=>t.name===e.defaultProfile)?.label??e.defaultProfile:null;return(0,Q.jsx)(en,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:n,draft:F[e.id]??null,profileOptions:ee(t===``||t===`__custom__`?null:t),onDraftChange:te,onToggle:ne},e.id)})})]},e.id))})]}),(0,Q.jsxs)(I.Footer,{children:[V&&(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>w(!0),disabled:x||!M,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:`Reset to Defaults`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:t,disabled:x,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,onClick:()=>void J(),disabled:!H||U||x,children:x?(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin`}):`Save`})]}),(0,Q.jsx)(R,{open:C,title:`Reset to Defaults`,message:`Every task override will be reset and will follow your active profile. This cannot be undone.`,confirmLabel:`Reset to Defaults`,destructive:!0,onConfirm:()=>{w(!1),Y()},onCancel:()=>w(!1)})]})}function rn({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:c}){let l=``;if(e){let t=e.label||e.name;l=e.isActive&&e.callSiteIds.length>0?`"${t}" is the active profile and is used by ${e.callSiteIds.length} call site(s). Pick a replacement profile.`:e.isActive?`"${t}" is the active profile. Pick a different active profile before deleting, or select a replacement below.`:`"${t}" is used by ${e.callSiteIds.length} call site(s). Select a replacement profile to reassign them before deleting.`}return(0,Q.jsx)(I.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,Q.jsxs)(I.Content,{size:`sm`,children:[(0,Q.jsx)(I.Header,{children:(0,Q.jsx)(I.Title,{children:`Can't Delete Profile`})}),(0,Q.jsxs)(I.Body,{className:`space-y-4`,children:[(0,Q.jsx)(h,{variant:`body-medium-default`,as:`p`,children:l}),e&&e.callSiteIds.length>0&&(0,Q.jsx)(`ul`,{className:`space-y-1 pl-1`,children:e.callSiteIds.map(e=>(0,Q.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,(0,Q.jsx)(`code`,{children:e})]},e))}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Replacement profile`}),(0,Q.jsx)(z,{"aria-label":`Replacement profile`,value:n,onChange:r,options:[{value:``,label:`Select a replacement…`},...t.map(e=>({value:e.name,label:e.label??e.name}))]})]}),i&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,Q.jsxs)(I.Footer,{children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:c,children:a?`Saving…`:`Reassign and Delete`})]})]})})}function an(e,t){if(e){let n=Ee(e).find(e=>e.id===t);if(n)return n.displayName}let n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t}function on(e,t){let n=[];e.description&&n.push(e.description);let r=e.provider_connection===`vellum`&&t?`vellum`:e.provider,i=[];if(e.model&&i.push(an(r,e.model)),r){let e=Le[r]??r;i.push(`hosted by ${e}`)}return i.length>0&&n.push(i.join(` `)),n.join(` – `)}function sn({profile:e,vellumIsManaged:t,isDragging:n,dropTarget:r,isDeleting:i,deleteError:a,isToggling:o,onDragStart:c,onDragEnd:l,onDragOver:u,onDragLeave:d,onDrop:f,onEditClick:p,onDeleteClick:m,onStatusToggle:g}){let _=e.source===`managed`,v=e.invariant===!0,y=e.status!==`disabled`;return(0,Q.jsxs)(`div`,{className:`relative`,children:[r?.name===e.name&&!r.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg pr-2 py-2${n?` opacity-50`:``}`,draggable:!_,onDragStart:c,onDragEnd:l,onDragOver:u,onDragLeave:d,onDrop:f,children:[(0,Q.jsx)(Ht,{className:`h-4 w-4 shrink-0 ${_?`invisible`:`cursor-grab text-[var(--content-tertiary)]`}`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1${y?``:` opacity-55`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(h,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:e.label??e.name}),_&&(0,Q.jsx)(M,{tone:`positive`,title:`Managed by Platform — this profile cannot be disabled, deleted, or renamed.`,children:`Platform`})]}),e.description||e.model||e.provider?(0,Q.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:on(e,t)}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(!v||!y)&&(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center`,title:y?`Active — toggle to hide from pickers`:`Disabled — toggle to show in pickers`,children:(0,Q.jsx)(F,{checked:y,onChange:e=>g(e),disabled:o,"aria-label":`${y?`Disable`:`Enable`} ${e.label??e.name}`})}),(0,Q.jsxs)(`div`,{className:`flex w-[92px] items-center justify-end gap-2`,children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:p,children:_||v?`View`:`Edit`}),(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(O,{}),"aria-label":`Delete ${e.label??e.name}`,disabled:_||v||i,title:_||v?`Managed profiles cannot be deleted`:void 0,onClick:m,tintColor:`var(--system-negative-strong)`})]})]})]}),r?.name===e.name&&r.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),a?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:a}):null]})}function cn({isOpen:e,assistantId:t,onClose:n}){let r=u(),{data:i}=d({...it({path:{assistant_id:t}}),staleTime:3e4}),o=(0,Z.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),s=(0,Z.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),c=i?.llm?.activeProfile??null,l=i?.llm?.callSites??{},f=(0,Z.useMemo)(()=>Ne(o,s),[o,s]),p=$e({onSuccess:e=>{ut(r,{path:{assistant_id:t}},e)}}),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),{data:v}=d({...nt({path:{assistant_id:t}}),enabled:e}),y=v?.connections,b=y?.some(e=>e.name===`vellum`&&e.provider===`vellum`)??!1,x=Object.keys(o);async function S(e,n,r){let i=r?.mode??`replace`,c=!(e in o);if(i===`merge`&&!c){await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:n}}}}),h(!1),_(null);return}let l={profiles:{[e]:n}};if(c&&(l.profileOrder=s.includes(e)?s:[...s,e]),c)await p.mutateAsync({path:{assistant_id:t},body:{llm:l}});else{let n=o[e];await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:null}}}});try{await p.mutateAsync({path:{assistant_id:t},body:{llm:l}})}catch(r){throw a(r,{context:`settings-ai-profile-edit-recreate`}),n!=null&&await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:n}}}}).catch(()=>{}),r}}c&&L.success(`Profile "${n.label??e}" created`),h(!1),_(null)}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(I.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,Q.jsx)(ln,{assistantId:t,vellumIsManaged:b,profiles:o,profileOrder:s,orderedProfiles:f,activeProfile:c,callSiteOverrides:l,onClose:n,onEditClick:e=>{_(e),h(!0)},onNewClick:()=>{_(null),h(!0)}}):null}),(0,Q.jsx)(we,{isOpen:m,mode:g?g.source===`managed`||g.invariant===!0?`view`:`edit`:`create`,profileName:g?.name,initialValues:g??void 0,existingNames:x,connections:y,assistantId:t,onSave:S,onCancel:()=>{h(!1),_(null)}})]})}function ln({assistantId:e,vellumIsManaged:t,profiles:n,profileOrder:r,orderedProfiles:i,activeProfile:o,callSiteOverrides:c,onClose:l,onEditClick:d,onNewClick:f}){let p=u(),m=$e({onSuccess:t=>{ut(p,{path:{assistant_id:e}},t)}}),[g,_]=(0,Z.useState)({}),[v,y]=(0,Z.useState)({}),[b,x]=(0,Z.useState)(new Set),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(null),A=(0,Z.useRef)(null),j=(0,Z.useRef)(null),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(``),[z,B]=(0,Z.useState)(!1),V=(0,Z.useMemo)(()=>i,[i]);async function H(t,r){if(b.has(t.name))return!1;x(e=>new Set(e).add(t.name)),C(null);let i=r?`active`:`disabled`;if(!n[t.name])return x(e=>{let n=new Set(e);return n.delete(t.name),n}),!1;try{return await m.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[t.name]:{status:i}}}}}),!0}catch(e){return a(e,{context:`settings-ai-profile-toggle`}),C(`Couldn't update "${t.label??t.name}". Please try again.`),!1}finally{x(e=>{let n=new Set(e);return n.delete(t.name),n})}}async function U(t){y(e=>({...e,[t]:!0})),_(e=>{let n={...e};return delete n[t],n});try{let n=r.filter(e=>e!==t);await m.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[t]:null},profileOrder:n}}})}catch(e){a(e,{context:`settings-ai-profile-delete`}),_(e=>({...e,[t]:`Failed to delete profile. Please try again.`}))}finally{y(e=>{let n={...e};return delete n[t],n})}}function W(e){let t=V.find(t=>t.name===e)?.label??e,n=e===o,r=Object.entries(c).filter(([t,n])=>t!==`mainAgent`&&n?.profile===e).map(([e])=>e);if(n||r.length>0){N({name:e,label:t,isActive:n,callSiteIds:r}),R(``),F(null);return}U(e)}async function G(){if(!M||!L)return;B(!0),F(null);let t={};if(M.isActive&&(t.activeProfile=L),M.callSiteIds.length>0){let e={};for(let t of M.callSiteIds)e[t]={profile:L};t.callSites=e}if(Object.keys(t).length>0)try{await m.mutateAsync({path:{assistant_id:e},body:{llm:t}})}catch(e){a(e,{context:`settings-ai-profile-reassign-delete`}),F(`Failed to reassign references. Please try again.`),B(!1);return}let n=M.name;N(null),B(!1),U(n)}async function ee(t,n){if(t===n.name)return;k(null);let i=r.filter(e=>e!==t),o=i.indexOf(n.name);if(o===-1)return;n.after&&(o+=1);let s=[...i.slice(0,o),t,...i.slice(o)];try{await m.mutateAsync({path:{assistant_id:e},body:{llm:{profileOrder:s}}})}catch(e){a(e,{context:`settings-ai-profile-reorder`}),k(`Failed to reorder profiles. Please try again.`)}}let K=V.filter(e=>e.name!==M?.name&&e.source!==`managed`),q=K.length>0?K:V.filter(e=>e.name!==M?.name);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(I.Content,{size:`md`,children:[(0,Q.jsxs)(I.Header,{children:[(0,Q.jsx)(I.Title,{children:`Model Profiles`}),(0,Q.jsx)(I.Description,{children:`Bundle a provider and model into a named profile. Assign profiles to specific actions or swap between them when chatting.`})]}),(0,Q.jsxs)(I.Body,{children:[V.length===0?(0,Q.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No profiles yet. Create one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:V.map(e=>(0,Q.jsx)(sn,{profile:e,vellumIsManaged:t,isDragging:w===e.name,dropTarget:E,isDeleting:v[e.name]??!1,deleteError:g[e.name],isToggling:b.has(e.name),onDragStart:t=>{A.current=e.name,T(e.name),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{A.current=null,j.current=null,T(null),D(null)},onDragOver:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>n.top+n.height/2,i={name:e.name,after:r};j.current=i,D(i)},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||(j.current=null,D(t=>t?.name===e.name?null:t))},onDrop:e=>{e.preventDefault();let t=A.current,n=j.current;A.current=null,j.current=null,T(null),D(null),t&&n&&ee(t,n)},onEditClick:()=>d(e),onDeleteClick:()=>W(e.name),onStatusToggle:t=>void H(e,t)},e.name))}),O&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:O}),S&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:S})]}),(0,Q.jsxs)(I.Footer,{className:`justify-between`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:f,children:`+ New Profile`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Done`})]})]}),(0,Q.jsx)(rn,{blocked:M,availableReplacements:q,replacement:L,onReplacementChange:R,error:P,saving:z,onClose:()=>{N(null),F(null)},onConfirm:()=>void G()})]})}var un=`0.10.8`;function dn(){return pt(un)}function fn({mode:e,connection:t,assistantId:n,existingNames:r,connections:i,onSave:a,onCancel:o}){let[c,l]=(0,Z.useState)(t?.label??``),d=t?.name??``,f=t?.provider??`anthropic`,p=t?.auth.type??`api_key`,[m,g]=(0,Z.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[_,v]=(0,Z.useState)(t?.baseUrl??``),[y,b]=(0,Z.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),T=f===`openai-compatible`,[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(!1),A=u(),j=(0,Z.useMemo)(()=>oe(m),[m]),M=p===`api_key`&&j!==null,{hasStoredCredential:N,isLoading:F}=V({assistantId:n,credentialKind:`credential`,credentialName:j?`${j.service}:${j.field}`:``,enabled:M}),{credentials:L}=J({assistantId:n,enabled:p===`api_key`});(0,Z.useEffect)(()=>{let e=t?.provider??`anthropic`;l(t?.label??``),t?.auth.type===`api_key`?g(t.auth.credential):g(t?``:`credential/${e}/api_key`),w(null),v(t?.baseUrl??``),b(t?.models?t.models.map(e=>e.id).join(`, `):``),D(``),k(!1)},[t]);let R=c.trim()!==(t?.label??``).trim(),z=T&&R?te(c,i,t?.name):null,B=d.trim().length>0&&z===null;async function H(){if(B){S(!0),w(null);try{let e;if(p===`api_key`){let t=m.trim()||`credential/${f}/api_key`,r=E.trim();if(r){k(!0);try{let e=oe(t);await Je({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:f,value:r},throwOnError:!0});let i=Ge(n,`credential`,e?`${e.service}:${e.field}`:``);A.setQueryData(i,!0),A.invalidateQueries({queryKey:rt({path:{assistant_id:n}})})}catch{w(`Failed to save API key. Please try again.`);return}finally{k(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{w(`Nothing to edit. Close and try again.`);return}let r=c.trim()||null,i={auth:e,label:r,...T&&{base_url:_.trim()||null,models:y.trim()?y.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:o,error:s,response:l}=await qe({path:{assistant_id:n,name:t?.name??d.trim()},body:i});if(!l?.ok){w(W(l?.status,s)??G(l?.status));return}if(!o){w(`Server returned an empty response. Please try again.`);return}a(o)}catch{w(`Failed to save provider. Please try again.`)}finally{S(!1)}}}let K=L.filter(e=>e.service===f),q=e!==`create`&&t?.auth.type===`api_key`,X=K.length>0||q,ie=Y(`Enter your API key`,N);return e===`create`?(0,Q.jsx)(ne,{variant:`modal`,assistantId:n,existingNames:r,connections:i,defaultProviderType:f,onCreated:a,onCancel:o}):(0,Q.jsxs)(I.Content,{size:`md`,children:[(0,Q.jsxs)(I.Header,{children:[(0,Q.jsx)(I.Title,{children:`Edit Provider`}),(0,Q.jsx)(I.Description,{children:t?`Editing ${ce(t)}.`:`Edit provider settings.`})]}),(0,Q.jsxs)(I.Body,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[`Display Name`,` `,(0,Q.jsx)(`span`,{className:`text-[var(--content-disabled)]`,children:`(optional)`})]}),(0,Q.jsx)(P,{value:c,onChange:e=>l(e.target.value),placeholder:`e.g. My Anthropic Key`,fullWidth:!0}),z?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:ee[z]}):null]}),T&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,Q.jsx)(P,{value:_,onChange:e=>v(e.target.value),placeholder:`https://api.example.com/v1`,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,Q.jsx)(P,{value:y,onChange:e=>b(e.target.value),placeholder:`model-1, model-2`,fullWidth:!0}),(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),p===`api_key`&&(0,Q.jsx)(U,{apiKeyValue:E,onApiKeyChange:D,credential:m,onCredentialChange:g,isLoadingCredential:F,apiKeyPlaceholder:ie,provider:f,providerCredentials:K,showAdvancedSection:X,onError:w}),p===`oauth_subscription`&&(0,Q.jsx)(re,{assistantId:n,onConnected:a}),C&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:C})]}),(0,Q.jsxs)(I.Footer,{children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,disabled:!B||x||O,onClick:()=>void H(),children:x?`Saving…`:`Save`})]})]})}var pn={anthropic:!0,openai:!0,gemini:!0,fireworks:!0,openrouter:!0,vellum:!0};function mn(e){return e in pn}function hn(e){let t=e.baseUrl??``;try{e.baseUrl&&(t=new URL(e.baseUrl).host)}catch{}let 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 gn({isOpen:e,assistantId:t,onClose:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=u(),{data:c,isLoading:l,isError:f}=d({...nt({path:{assistant_id:t}}),enabled:e}),p=dn(),{data:m}=d({...ot({path:{assistant_id:t}}),enabled:e&&p}),h=(0,Z.useMemo)(()=>{let e=c?.connections??[];return[...e.filter(e=>e.provider===je),...e.filter(e=>e.provider!==je)]},[c]);function g(){s.invalidateQueries({queryKey:lt({path:{assistant_id:t}})}),s.invalidateQueries({queryKey:st({path:{assistant_id:t}})})}function _(e){s.invalidateQueries({queryKey:tt({path:{assistant_id:t}})}),i(!1),o(null)}let v=h.map(e=>e.name),y=()=>{i(!1),o(null)};return(0,Q.jsx)(I.Root,{open:e,onOpenChange:e=>{e||(r?y():n())},children:e?r?(0,Q.jsx)(fn,{mode:a?`edit`:`create`,connection:a??void 0,assistantId:t,existingNames:v,connections:h,onSave:_,onCancel:y}):(0,Q.jsx)(_n,{connections:h,loading:l,isError:f,assistantId:t,supportsDefaultProvider:p,defaultConnectionName:p?m?.resolvedConnectionName??null:null,onDefaultChanged:g,onClose:n,onEditClick:e=>{o(e),i(!0)},onNewClick:()=>{o(null),i(!0)},onConnectionDeleted:()=>{s.invalidateQueries({queryKey:tt({path:{assistant_id:t}})})}}):null})}function _n({connections:e,loading:t,isError:n,assistantId:r,supportsDefaultProvider:i,defaultConnectionName:o,onDefaultChanged:c,onClose:l,onEditClick:u,onNewClick:d,onConnectionDeleted:p}){let[m,g]=(0,Z.useState)({}),[_,v]=(0,Z.useState)({}),y=f({...ct(),onMutate:e=>{let t=e.body?.connectionName;t&&g(e=>{let n={...e};return delete n[t],n})},onSuccess:c,onError:(e,t)=>{a(e,{context:`settings-ai-set-default-provider`});let n=t.body?.connectionName;n&&g(e=>({...e,[n]:`Failed to set default provider. Please try again.`}))}});function b(e){mn(e.provider)&&y.mutate({path:{assistant_id:r},body:{provider:e.provider,connectionName:e.name}})}async function x(e){v(t=>({...t,[e]:!0})),g(t=>{let n={...t};return delete n[e],n});try{let{response:t}=await Ke({path:{assistant_id:r,name:e}});t?.ok||t?.status===404?p(e):t?.status===409?g(t=>({...t,[e]:`This provider is in use by a profile or as the default provider. Update those settings before deleting it.`})):g(t=>({...t,[e]:`Failed to delete provider. Please try again.`}))}catch{g(t=>({...t,[e]:`Failed to delete provider. Please try again.`}))}finally{v(t=>{let n={...t};return delete n[e],n})}}return(0,Q.jsxs)(I.Content,{size:`md`,children:[(0,Q.jsxs)(I.Header,{children:[(0,Q.jsx)(I.Title,{children:`Providers`}),(0,Q.jsx)(I.Description,{children:`Manage the model providers your assistant can use.`})]}),(0,Q.jsx)(I.Body,{children:t?(0,Q.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`h-10 animate-pulse rounded-lg bg-[var(--surface-active)]`},e))}):n?(0,Q.jsx)(h,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:`Failed to load providers. Please try again.`}):e.length===0?(0,Q.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No providers yet. Add one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>{let t=_[e.name]??!1,n=m[e.name],r=e.isManaged??!1,a=e.name===o,c=mn(e.provider),l=y.isPending&&y.variables?.body?.connectionName===e.name;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg px-2 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(h,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:ce(e)}),r&&(0,Q.jsx)(M,{tone:`positive`,title:`Managed by Platform — you can rename this provider, but not edit it.`,children:`Platform`}),a&&(0,Q.jsx)(M,{tone:`info`,title:`Built-in profiles (Balanced, Quality, Speed) use this provider.`,children:`Default`}),e.provider===`vellum`?null:e.provider===`openai-compatible`&&(0,Q.jsx)(M,{tone:`neutral`,title:`A provider you created — served by an OpenAI-compatible endpoint.`,children:`Custom`})]}),e.provider===`openai-compatible`?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--content-tertiary)`,children:hn(e)}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[i&&!a&&(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,disabled:!c||l,title:c?`Use this provider for the built-in profiles.`:`Built-in profiles can't run on this provider.`,onClick:()=>b(e),children:`Set as default`}),!r&&(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:()=>u(e),children:`Edit`}),(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(O,{}),"aria-label":`Delete ${ce(e)}`,disabled:r||a||t,title:r?`The Vellum provider cannot be removed`:a?`This is your default provider. Set another provider as default first.`:void 0,onClick:()=>void x(e.name),tintColor:`var(--system-negative-strong)`})]})]}),n?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:n}):null]},e.name)})})}),(0,Q.jsxs)(I.Footer,{className:`justify-between`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:d,children:`+ Add Provider`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Done`})]})]})}function $(e){let[t,n]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Z.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}function vn(){let e=Rt(),t=u(),{data:n}=d({...it({path:{assistant_id:e}}),staleTime:3e4}),r=dn(),{data:i,refetch:o}=d({...ot({path:{assistant_id:e}}),enabled:r}),c=i?.availability,l=n?.llm?.activeProfile??null,f=n?.llm?.advisorProfile??null,p=n?.llm?.callSites??{},{profiles:m,profileOrder:g}=Re(n?.llm,e),_=(0,Z.useMemo)(()=>Ne(m,g),[m,g]),v=$e({onSuccess:n=>{ut(t,{path:{assistant_id:e}},n)}}),[y,b]=$(l),[x,S]=$(f),[C,w]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(!1),j=(0,Z.useMemo)(()=>Se(_,[y]),[_,y]),M=(0,Z.useMemo)(()=>Se(_,[x]),[_,x]),N=Object.entries(p).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length,P=N===1?`1 Override`:N>0?`${N} Overrides`:`Overrides`,F=y!==l,I=x!==f,R=(0,Z.useCallback)(async()=>{try{let t={};F&&(t.activeProfile=y),I&&(t.advisorProfile=x),await v.mutateAsync({path:{assistant_id:e},body:{llm:t}}),L.success(`Saved.`)}catch(e){L.error(`Failed to save. Please try again.`),a(e,{context:`settings-ai-language-model-save`})}},[F,I,y,x,v,e]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Gt,{title:`Language Model`,subtitle:`Configure the LLMs that power your assistant`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[c&&c.status!==`ok`&&(0,Q.jsx)(A,{tone:c.status===`unknown`?`warning`:`error`,children:c.message??`Your default provider is not available.`}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Default Profile`}),(0,Q.jsx)(z,{value:y??``,onChange:e=>{b(e===``?null:e)},placeholder:`Select a default profile…`,options:j.map(e=>({value:e.name,label:Oe(e)}))}),j.length===0?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`No profiles yet. Click Profiles below to create one.`}):null]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Advisor Profile`}),(0,Q.jsx)(z,{value:x??``,onChange:e=>{S(e===``?null:e)},placeholder:`Select an advisor profile…`,options:M.map(e=>({value:e.name,label:Oe(e)}))}),(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`Which model your assistant consults for a second opinion`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>k(!0),children:`Providers`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>w(!0),children:`Profiles`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>D(!0),children:P})]}),(F||I)&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Jt,{onClick:R,disabled:v.isPending}),v.isPending&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]})}),e&&(0,Q.jsx)(cn,{isOpen:C,assistantId:e,onClose:()=>w(!1)}),e&&(0,Q.jsx)(tn,{isOpen:E,onClose:()=>D(!1),assistantId:e}),e&&(0,Q.jsx)(gn,{isOpen:O,assistantId:e,onClose:()=>{k(!1),r&&o()}})]})}function yn(){let e=Rt();return(0,Z.useCallback)(async(t,n)=>{try{let{data:r}=await Je({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});q(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?L.error(`Assistant not ready. Please try again.`):L.error(`Failed to save ${t} API key. Please try again.`),a(e,{context:`provision_provider_key`}),e}},[e])}var bn=`0.10.12`;function xn(){return mt(bn)}function Sn(){let e=Rt(),i=u(),o=vt(),{data:s}=d({...it({path:{assistant_id:e}}),enabled:o,staleTime:3e4}),c=$e({onSuccess:t=>{ut(i,{path:{assistant_id:e}},t)}}),l=yn(),f=(0,Z.useMemo)(()=>{if(!s)return r(xe,`inference-provider-native`);let e=s.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||r(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[s]),[p,m]=(0,Z.useState)(!1),[h,g]=$(f),[_,v]=(0,Z.useState)(``),y=de.has(h),{hasStoredCredential:b}=V({assistantId:e,credentialKind:`api_key`,credentialName:h,enabled:y}),x=_.trim().length>0,S=p||y&&!b&&!x||h===f&&!x,C=Y(ve[h]??`Enter your API key`,b),w=(0,Z.useCallback)(async()=>{m(!0);let t=_.trim(),r=ue(h),o=y&&t.length>0;try{o&&await l(h,t),await ft();let n=h===`vellum`?xn()?{provider:`vellum`,mode:`managed`}:{mode:`managed`}:{provider:h,mode:`your-own`};await c.mutateAsync({path:{assistant_id:e},body:{services:{"web-search":n}}}).catch(e=>{throw L.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{m(!1);return}m(!1);try{if(n(xe,h),o){r&&n(r,t);let a=Ge(e,`api_key`,h);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),v(``)}L.success(`Web search settings saved.`)}catch(e){a(e,{context:`settings-ai-web-search-persist-local`}),L.error(`Saved, but local preferences could not be written.`)}},[y,c,l,i,e,_,h]),E=(0,Z.useCallback)(()=>{let e=ue(h);e&&t(e),v(``),g(`inference-provider-native`),n(xe,`inference-provider-native`)},[h,g]);return(0,Q.jsx)(Gt,{title:`Web Search`,subtitle:`Configure how your assistant should search the web`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{"aria-label":`Web search provider`,value:h,onChange:g,options:B.map(e=>({value:e,label:X[e]??e}))})]}),h===`vellum`&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Search runs through your Vellum account.`}),y&&(0,Q.jsx)(P,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:C,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Jt,{onClick:w,disabled:S}),p&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),y&&(0,Q.jsx)(Yt,{onClick:E,filled:!0})]})]})})}var Cn=`default`;function wn(){let e=Rt(),i=u(),{data:o}=d({...it({path:{assistant_id:e}}),staleTime:3e4}),s=$e({onSuccess:t=>{ut(i,{path:{assistant_id:e}},t)}}),c=yn(),l=(0,Z.useMemo)(()=>o?o.services?.[`web-fetch`]?.provider||r(`vellum:ai:webFetchProvider`,Cn):r(De,Cn),[o]),[f,p]=(0,Z.useState)(!1),[m,h]=$(l),[g,_]=(0,Z.useState)(``),v=ze.has(m),{hasStoredCredential:y}=V({assistantId:e,credentialKind:`api_key`,credentialName:m,enabled:v}),b=g.trim().length>0,x=f||v&&!y&&!b||m===l&&!b,S=Y(Ce[m]??`Enter your API key`,y),C=(0,Z.useCallback)(async()=>{p(!0);let t=g.trim(),r=v&&t.length>0;try{r&&await c(m,t),await s.mutateAsync({path:{assistant_id:e},body:{services:{"web-fetch":{provider:m}}}}).catch(e=>{throw L.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{p(!1);return}p(!1);try{if(n(De,m),r){let r=K(m);r&&n(r,t);let a=Ge(e,`api_key`,m);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),_(``)}L.success(`Web fetch settings saved.`)}catch(e){a(e,{context:`settings-ai-web-fetch-persist-local`}),L.error(`Saved, but local preferences could not be written.`)}},[v,s,c,i,e,g,m]),w=(0,Z.useCallback)(()=>{let e=K(m);e&&t(e),_(``),h(Cn),n(De,Cn)},[m,h]);return(0,Q.jsx)(Gt,{id:`web-fetch`,title:`Web Fetch`,subtitle:`Configure how your assistant reads individual web pages`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{value:m,onChange:h,options:Fe.map(e=>({value:e,label:ke[e]??e}))})]}),v&&(0,Q.jsx)(P,{label:`API Key`,type:`password`,value:g,onChange:e=>_(e.target.value),placeholder:S,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Jt,{onClick:C,disabled:x}),f&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),v&&(0,Q.jsx)(Yt,{onClick:w,filled:!0})]})]})})}function Tn({subdomain:e,onSubdomainChange:t,domainSuffix:n,subdomainPlaceholder:r=`my-assistant`,disabled:i,autoFocus:a,prefix:o,error:s,locked:c,lockedMessage:l}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex h-9 w-full items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${s?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[o,(0,Q.jsx)(`input`,{value:e,onChange:e=>t(e.target.value.toLowerCase().trim()),disabled:i||c,readOnly:c,autoFocus:a,placeholder:r,"aria-label":`Subdomain`,"aria-invalid":!!s,className:`h-full min-w-0 flex-1 bg-transparent ${o?`pl-1.5`:`pl-3`} pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none disabled:cursor-not-allowed disabled:opacity-60`}),(0,Q.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`.`,n]})]}),s&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--system-negative-strong)]`,children:s}),c&&l&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--content-tertiary)]`,children:l})]})}function En({assistantId:e,assistantHandle:t,emailRootDomain:n}){let r=u(),i=l(),[o,p]=c(),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(``),[S,C]=(0,Z.useState)(null),[w,D]=(0,Z.useState)(!1),[k,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{g||!t||m||(h(t),_(!0))},[t,g,m]);let P=d({...Tt(),enabled:!0}),F=P.data,I=F?.entitlements,z=I?.managed_email===!0,B=!!I&&!z,V=!F&&P.isError&&!P.isFetching,H=d({...yt({path:{assistant_id:e}}),enabled:!B}),U=d({...Ot({path:{assistant_id:e}}),enabled:!B}),W=H.data?.results?.[0],G=U.data?.results?.[0],ee=W?`${W.subdomain}.${n}`:null,K=d({...Ct({path:{assistant_id:e,id:G?.id??``}}),enabled:!!G?.id,refetchOnWindowFocus:!1}),q=d({...At({path:{assistant_id:e,id:W?.id??``}}),enabled:!!W?.id,refetchInterval:e=>{let t=e.state.data?.status;return t===`verified`||t===`failed`?!1:1e4},refetchOnWindowFocus:!0});(0,Z.useEffect)(()=>{o.get(`release`)!==`1`||!W||G||(j(!0),p(e=>{let t=new URLSearchParams(e);return t.delete(`release`),t},{replace:!0}))},[G,W,o,p]);let te=f(Dt()),ne=f(kt()),J=f(bt()),Y=f(xt()),X=(0,Z.useCallback)(()=>{let t={assistant_id:e};r.invalidateQueries({queryKey:wt({path:t})}),r.invalidateQueries({queryKey:Et({path:t})}),G?.id&&r.invalidateQueries({queryKey:St({path:{...t,id:G.id}})}),r.invalidateQueries({queryKey:Mt()})},[G?.id,e,r]),re=(0,Z.useCallback)(async()=>{let t=m.trim().toLowerCase();if(!t){y(`Enter a subdomain.`);return}D(!1);try{await te.mutateAsync({path:{assistant_id:e},body:{subdomain:t}}),h(``),y(null),X(),L.success(`Domain ${t}.${n} registered.`)}catch(e){y(ht(e,void 0,`Failed to register domain.`))}},[e,n,X,te,m]),ie=(0,Z.useCallback)(async()=>{let t=b.trim().toLowerCase();if(!t){C(`Enter an email username.`);return}try{await J.mutateAsync({path:{assistant_id:e},body:{username:t}}),x(``),C(null),X(),L.success(`Email address created.`)}catch(e){C(ht(e,void 0,`Failed to create email address.`))}},[e,X,J,b]),ae=(0,Z.useCallback)(async()=>{if(G?.id){N(!1);try{await Y.mutateAsync({path:{assistant_id:e,id:G.id}}),X(),L.success(`Email address removed.`)}catch(e){a(e,{context:`email_address_delete`}),L.error(`Failed to remove email address.`)}}},[G?.id,e,Y,X]),oe=(0,Z.useCallback)(async()=>{if(!W?.id)return;if(G){L.error(`Remove the email address first.`);return}j(!1);let t=W.subdomain;try{await ne.mutateAsync({path:{assistant_id:e,id:W.id}}),h(t),X(),L.success(`Domain released.`)}catch(e){a(e,{context:`email_domain_release`}),L.error(`Failed to release domain.`)}},[G,e,ne,W?.id,W?.subdomain,X]);if(P.isLoading)return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin`}),`Checking subscription…`]});if(B)return(0,Q.jsx)(A,{tone:`info`,icon:(0,Q.jsx)(E,{className:`h-4 w-4`,"aria-hidden":!0}),title:`Give your assistant its own email address`,actions:(0,Q.jsx)(s,{size:`compact`,onClick:()=>i(gt.plans),children:`Upgrade`}),children:`Upgrade to a plan that includes an email address for your assistant. No provider setup required.`});let se=V?(0,Q.jsx)(A,{tone:`warning`,title:`Couldn't verify subscription status`,actions:(0,Q.jsx)(s,{size:`compact`,variant:`outlined`,onClick:()=>P.refetch(),children:`Retry`}),children:`We couldn't reach the billing service. The form below assumes managed email is enabled for your org — if it isn't, registering a domain will fail.`}):null;return W?G?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[se,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:G.address}),(0,Q.jsx)(qt,{status:q.data?.status,message:q.data?.message,isLoading:q.isLoading}),(0,Q.jsx)(s,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(O,{}),onClick:()=>N(!0),disabled:Y.isPending,"aria-label":`Remove email address`})]}),(0,Q.jsx)(R,{open:M,title:`Remove Email Address`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to remove `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:G.address}),`? Your assistant will no longer be able to send or receive email at this address.`]}),confirmLabel:`Remove`,destructive:!0,onConfirm:ae,onCancel:()=>N(!1)})]}),K.data?.usage&&(0,Q.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[K.data.usage.sent_today,` /`,` `,K.data.usage.daily_limit,` sent today ·`,` `,K.data.usage.received_today,` received`]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[se,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Domain`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:[W.subdomain,`.`,n]}),(0,Q.jsx)(qt,{status:q.data?.status,message:q.data?.message,isLoading:q.isLoading}),(0,Q.jsx)(s,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(O,{}),onClick:()=>j(!0),disabled:ne.isPending,"aria-label":`Release domain`})]}),(0,Q.jsx)(R,{open:k,title:`Release Domain`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to release `,(0,Q.jsxs)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:[W.subdomain,`.`,n]}),`? The subdomain will become available for others to claim.`]}),confirmLabel:`Release`,destructive:!0,onConfirm:oe,onCancel:()=>j(!1)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Email address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex h-9 min-w-0 flex-1 items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${S?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[(0,Q.jsx)(`input`,{value:b,onChange:e=>{x(e.target.value.toLowerCase()),S&&C(null)},placeholder:`hi`,"aria-label":`Email username`,"aria-invalid":!!S,className:`h-full min-w-0 flex-1 bg-transparent pl-3 pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`}),(0,Q.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`@`,ee]})]}),(0,Q.jsx)(s,{onClick:ie,disabled:J.isPending||!b.trim(),children:J.isPending?`Creating…`:`Create`})]}),S&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:S})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[se,(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Subdomain`}),(0,Q.jsx)(Tn,{subdomain:m,onSubdomainChange:e=>{h(e),v&&y(null)},domainSuffix:n,subdomainPlaceholder:`my-assistant`,error:v}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Each assistant gets its own subdomain. Lowercase letters, numbers, and hyphens only.`}),(0,Q.jsx)(s,{onClick:()=>D(!0),disabled:te.isPending||!m.trim(),children:te.isPending?`Registering…`:`Register`}),(0,Q.jsx)(R,{open:w,title:`Set Subdomain`,message:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:m.trim().toLowerCase()||`subdomain`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),confirmLabel:`Confirm`,onConfirm:re,onCancel:()=>D(!1)})]})}function Dn(){let e=Rt(),t=vt(),{data:o}=d({...jt(),enabled:t}),s=o?.results?.[0]?.handle,c=Vt.use.emailRootDomain(),l=_t(),[u,f]=(0,Z.useState)(()=>l===`gated`?`your-own`:le(r(Ae,`managed`),`managed`)),[p,m]=(0,Z.useState)(()=>{let e=r(pe,`resend`);return e===`mailgun`||e===`resend`?e:`resend`}),{platformAssistantId:h,error:g}=Bt(e,l===`full`&&u===`managed`),_=h??(g?e:null),v=d({queryKey:[`byoEmailCredential`,e,p],queryFn:async()=>{let{data:t}=await Ze({path:{assistant_id:e},body:{service:p,field:`api_key`},throwOnError:!0});return t},enabled:u===`your-own`||l===`gated`,staleTime:6e4,retry:i,meta:{errorContext:`byo_email_credential_check`}});(0,Z.useEffect)(()=>{v.error&&a(v.error,{context:`byo_email_credential_check`,bestEffort:!0})},[v.error]);let y=v.data?.hasSecret===!0,x=(0,Z.useCallback)(e=>{f(e),n(Ae,e)},[]),w=(0,Z.useCallback)(()=>{n(pe,p),L.success(`Email settings saved.`)},[p]),E=(0,Z.useMemo)(()=>be.find(e=>e.id===p)??be[0],[p]),D=(0,Q.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,Q.jsx)(C,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{children:[`Configure `,E.displayName,` via the assistant CLI: ask the assistant to run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:E.setupSkill}),` `,`skill. It walks you through storing the API key, detecting the domain, and (optionally) wiring up an inbound webhook.`]}),(0,Q.jsxs)(`a`,{href:E.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,E.displayName,(0,Q.jsx)(S,{className:`h-3 w-3`})]})]})]}),O=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{value:p,onChange:e=>{(e===`mailgun`||e===`resend`)&&m(e)},options:be.map(e=>({value:e.id,label:e.displayName}))})]}),y?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--system-positive-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-default)]`,children:[(0,Q.jsx)(b,{className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`span`,{children:[E.displayName,` API key configured. To reconfigure, run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:E.setupSkill}),` `,`skill.`]})]}),(0,Q.jsxs)(`a`,{href:E.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-body-small-default text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,E.displayName,(0,Q.jsx)(S,{className:`h-3 w-3`})]})]}):D,(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)(Jt,{onClick:w,disabled:!1})})]});return l===`gated`?(0,Q.jsx)(Gt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,children:O}):(0,Q.jsx)(Wt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,mode:u,onModeChange:x,children:u===`managed`?(0,Q.jsx)(`div`,{className:`space-y-4`,children:l===`disabled`?(0,Q.jsx)(Lt,{children:`Log in to the Vellum platform to manage email settings.`}):_===null?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin`}),`Connecting to the Vellum platform…`]}):(0,Q.jsx)(En,{assistantId:_,assistantHandle:s,emailRootDomain:c})}):O})}var On=`0.10.13`;function kn(){return mt(On)}var An=`gemini-3.1-flash-image-preview`;function jn(){let e=Rt(),t=u(),i=vt(),{data:o}=d({...it({path:{assistant_id:e}}),enabled:i,staleTime:3e4}),s=$e({onSuccess:n=>{ut(t,{path:{assistant_id:e}},n)}}),c=yn(),[l,f]=$((0,Z.useMemo)(()=>{if(!o)return r(he,`gemini`);let e=o.services?.[`image-generation`];return e?.mode===`managed`?`vellum`:e?.provider||r(`vellum:ai:imageGenProvider`,`gemini`)},[o])),[p,m]=(0,Z.useState)(()=>r(Ie,An)),h=H(l),g=h.includes(p)?p:h[0]??An,[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(!1),x=Ve.map(e=>({value:e,label:We[e]??e})),S=(0,Z.useMemo)(()=>H(l).map(e=>({value:e,label:fe[e]??e})),[l]),C=l===`gemini`||l===`openai`,{hasStoredCredential:w}=V({assistantId:e,credentialKind:`api_key`,credentialName:l,enabled:C}),E=f,D=(0,Z.useCallback)(async()=>{b(!0);let r=_.trim(),i=C&&r.length>0;try{i&&await c(He(g),r),await ft();let n=l===`vellum`&&!kn()?{mode:`managed`}:{provider:l,mode:l===`vellum`?`managed`:`your-own`};await s.mutateAsync({path:{assistant_id:e},body:{services:{"image-generation":n}}}).catch(e=>{throw L.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e});try{await Qe({path:{assistant_id:e},body:{modelId:g},throwOnError:!0})}catch(e){throw L.error(`Failed to update image generation model. Please try again.`),a(e,{context:`set_image_gen_model`}),e}finally{t.invalidateQueries({queryKey:st({path:{assistant_id:e}})})}}catch{b(!1);return}b(!1);try{if(n(he,l),n(Ie,g),i){let n=Ge(e,`api_key`,l);t.setQueryData(n,!0),t.invalidateQueries({queryKey:n}),v(``)}L.success(`Image generation settings saved.`)}catch(e){a(e,{context:`settings-ai-image-gen-persist-local`}),L.error(`Saved, but local preferences could not be written.`)}},[_,l,C,g,e,s,c,t]),O=(0,Z.useCallback)(()=>{v(``),m(An),n(Ie,An)},[]);return(0,Q.jsx)(Gt,{title:`Image Generation`,subtitle:`Configure which model your assistant uses to generate images`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{"aria-label":`Image generation provider`,value:l,onChange:E,options:x})]}),l===`vellum`&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Image generation runs through your Vellum account.`}),C&&(0,Q.jsx)(P,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:Y(l===`openai`?`Enter your OpenAI API key`:`Enter your Gemini API key`,w),fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsx)(z,{"aria-label":`Image generation model`,value:g,onChange:m,options:S})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Jt,{onClick:D,disabled:y}),y&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),C&&(0,Q.jsx)(Yt,{onClick:O})]})]})})}async function Mn(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 Nn(n,r,i):t===`deepgram`?await Pn(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 Nn(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 Fn(i,`ElevenLabs rejected the request.`)}}async function Pn(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 Fn(n,`Deepgram rejected the request.`)}}async function Fn(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 In({assistantId:e,value:t,onChange:n,className:r}){let[i,a]=(0,Z.useState)(!1),{voices:o}=Nt(e);if(o.length===0)return null;let s=o.find(e=>e.model===t)??o[0];return(0,Q.jsxs)(N.Root,{open:i,onOpenChange:a,children:[(0,Q.jsx)(N.Trigger,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Voice`,className:m(`flex h-9 w-full items-center gap-2 rounded-md border border-[var(--field-border)] bg-[var(--field-bg)] px-3 text-left text-body-medium-lighter text-[var(--content-default)] transition-colors focus:outline-none data-[state=open]:border-[var(--border-active)]`,r),children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:s?Pt(s.description):`Select a voice`}),(0,Q.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0})]})}),(0,Q.jsx)(N.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,Q.jsx)(Ft,{assistantId:e,value:t,onChange:n,onSelect:()=>a(!1),showSource:!0})})]})}var Ln={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function Rn({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=Rt(),c=e??o,l=dt.use.name()??`your assistant`,f=vt(),p=u(),{data:m}=d({...et({path:{assistant_id:c}}),enabled:f,staleTime:1/0}),h=(0,Z.useMemo)(()=>{let e=m?.providers;if(!e)return ie;if(e.some(e=>e.id===`vellum`))return e;let t=ie.find(e=>e.id===`vellum`);return t?[t,...e]:e},[m]),{data:g}=d({...it({path:{assistant_id:c}}),enabled:f,staleTime:3e4}),_=g?.services?.tts,v=_?.mode===`managed`?`vellum`:_?.provider,y=`elevenlabs`,b=(0,Z.useMemo)(()=>v??r(`vellum:voice:ttsProvider`,y),[v,y]),x=!!v,[S,C]=$(b),[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)(``),[k,A]=(0,Z.useState)(``),[j,M]=(0,Z.useState)(!1),[N,F]=(0,Z.useState)(!1),[I,R]=(0,Z.useState)(!1),{voices:B,defaultModel:V,fetched:H}=It(c,{enabled:S===`vellum`}),U=_?.providers?.vellum?.model??V??``,[W,G]=$(U),ee=B.find(e=>e.model===W)??B[0],[K,q]=(0,Z.useState)(null),te=B.some(e=>e.model===U),ne=K??(H&&U!==``&&!te),J=(0,Z.useMemo)(()=>h.find(e=>e.id===S)??h[0],[S,h]),Y=S===`vellum`&&J.supportsVoiceSelection&&W.trim()!==``&&W.trim()!==U,X=(0,Z.useCallback)(e=>{let t=r(_e+e,``),n=r(Me+e,``);M(t.length>0),O(n),A(n),E(``)},[]);(0,Z.useEffect)(()=>{X(S)},[S,X]);let re=(0,Z.useMemo)(()=>{let e=S!==b,t=T.trim().length>0,n=D.trim()!==k;return e||t||n||Y},[S,b,T,D,k,Y]),ae=(0,Z.useCallback)(async()=>{let e=T.trim(),t=D.trim(),i=J.id;n(ye,i),e.length>0&&n(_e+i,e),n(Me+i,t);let a=e.length>0?e:r(_e+i,``),o=Ln[i];R(!0);try{if(a.length>0){let{response:e}=await Ye({path:{assistant_id:c},body:{service:i,field:`api_key`,value:a,label:`${J.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...S!==b||!x?{provider:i,mode:i===`vellum`?`managed`:`your-own`}:{},...o?{providers:{[i]:{[o]:t}}}:{},...Y?{providers:{vellum:{model:W.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await Xe({path:{assistant_id:c},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return M(a.length>0),A(t),E(``),p.invalidateQueries({queryKey:st({path:{assistant_id:c}})}),L.success(`Text-to-speech settings saved`),!0}catch(e){return L.error(e instanceof Error?e.message:`Failed to save text-to-speech settings`),!1}finally{R(!1)}},[c,S,W,Y,T,D,J,b,x,p]);(0,Z.useEffect)(()=>{a?.({hasChanges:re,saving:I,save:ae})},[a,re,I,ae]);let oe=(0,Z.useCallback)(()=>{n(_e+S,``),M(!1),E(``)},[S]),se=(0,Z.useCallback)(async()=>{F(!0);try{let e=r(_e+S,``),t=T.trim(),n=t.length>0?t:e;if(n.length===0){L.error(`Save an API key for this provider before testing.`);return}let i=r(Me+S,``),a=D.trim(),o=await Mn({provider:S,apiKey:n,voiceId:a.length>0?a:i,text:`Hey! It's ${l}. How does this sound?`});if(o.kind!==`audio`){L.error(o.message);return}let s=URL.createObjectURL(o.blob);try{let e=new Audio(s);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(s)}}finally{F(!1)}},[l,T,S,D]),ce=j?`•••••••• (Enter a new key to replace)`:J.apiKeyPlaceholder,le=S===`vellum`,ue=le&&J.supportsVoiceSelection,de=(0,Q.jsxs)(s,{variant:`link`,size:`compact`,className:`inline-flex h-auto items-center gap-1 px-0 underline [--vbtn-fg:var(--content-tertiary)]`,onClick:()=>{q(!1),B.some(e=>e.model===W)||G(V||B[0]?.model||``)},children:[(0,Q.jsx)(w,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Choose from catalog`]}),fe=ue&&ne&&B.length>0?de:null;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{value:S,onChange:C,options:h.map(e=>({value:e.id,label:e.displayName})),"aria-label":`TTS provider`})]}),!le&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(P,{type:`password`,value:T,onChange:e=>E(e.target.value),placeholder:ce,fullWidth:!0})]}),ue&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice`}),ne?(0,Q.jsx)(P,{type:`text`,value:W,onChange:e=>G(e.target.value),placeholder:`Enter a voice ID`,"aria-label":`Custom voice ID`,fullWidth:!0}):ee?(0,Q.jsx)(In,{assistantId:c,value:W,onChange:G}):H&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`No managed voices are currently available.`})]}),J.supportsVoiceSelection&&!le&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice ID`}),(0,Q.jsx)(P,{type:`text`,value:D,onChange:e=>O(e.target.value),placeholder:`Enter a voice ID`,fullWidth:!0})]}),!i&&!le&&(0,Q.jsx)(Xt,{guide:J.credentialsGuide}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!le&&(0,Q.jsx)(s,{variant:`outlined`,onClick:se,disabled:N,children:N?`Testing…`:`Test`}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[fe,!t&&(0,Q.jsx)(Jt,{onClick:ae,disabled:!re||I}),j&&!le&&(0,Q.jsx)(Yt,{onClick:oe})]})]})]})}function zn(){return(0,Q.jsx)(Gt,{id:`text-to-speech`,title:`Text-to-Speech`,subtitle:`Configure how your assistant speaks`,children:(0,Q.jsx)(Rn,{})})}var Bn={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},Vn={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},Hn=`deepgram`;function Un({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=Rt(),s=e??o,c=vt(),l=u(),[f]=(0,Z.useState)(()=>Ue.filter(e=>!e.requiresNativeDictation||ae())),p=Hn,{data:m}=d({...it({path:{assistant_id:s}}),enabled:c,staleTime:3e4}),h=m?.services?.stt,g=h?.mode===`managed`?`vellum`:h?.provider,_=(0,Z.useMemo)(()=>{let e=g?Vn[g]:void 0;if(e&&f.some(t=>t.id===e))return e;let t=r(Be,p);return f.some(e=>e.id===t)?t:p},[g,f,p]),v=!!g,[y,b]=$(_),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let e=r(Be,p);e===`macos-native`&&!f.some(t=>t.id===e)&&n(Be,p)},[f,p]);let D=(0,Z.useMemo)(()=>f.find(e=>e.id===y)??f[0],[f,y]),O=D.apiKeyPlaceholder!==void 0;(0,Z.useEffect)(()=>{w(r(Te+y,``).length>0),S(``)},[y]);let A=(0,Z.useMemo)(()=>{let e=y!==_,t=x.trim().length>0;return e||t},[y,_,x]),j=(0,Z.useCallback)(async()=>{let e=x.trim();n(Be,y),e.length>0&&n(Te+y,e);let t=Bn[y];E(!0);try{if(t?.credentialService){let n=e.length>0?e:r(Te+y,``);if(n.length>0){let{response:e}=await Ye({path:{assistant_id:s},body:{service:t.credentialService,field:`api_key`,value:n,label:`${D.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(t&&(y!==_||!v)||g===`vellum`&&y!==`vellum`){let e=t?.provider??Hn,{response:n}=await Xe({path:{assistant_id:s},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&&w(!0),S(``),l.invalidateQueries({queryKey:st({path:{assistant_id:s}})}),L.success(`Speech-to-text settings saved`),!0}catch(e){return L.error(e instanceof Error?e.message:`Failed to save speech-to-text settings`),!1}finally{E(!1)}},[s,y,x,D,_,v,g,l]);(0,Z.useEffect)(()=>{a?.({hasChanges:A,saving:T,save:j})},[a,A,T,j]);let M=(0,Z.useCallback)(()=>{n(Te+y,``),w(!1),S(``)},[y]),N=C?`•••••••• (Enter a new key to replace)`:D.apiKeyPlaceholder;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{value:y,onChange:b,options:f.map(e=>({value:e.id,label:e.displayName})),"aria-label":`STT provider`})]}),O&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(P,{type:`password`,value:x,onChange:e=>S(e.target.value),placeholder:N,fullWidth:!0})]}),D.setupWarning&&(0,Q.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,Q.jsx)(k,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,Q.jsx)(`span`,{children:D.setupWarning})]}),!i&&D.credentialsGuide&&(0,Q.jsx)(Xt,{guide:D.credentialsGuide}),y===`vellum`&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Transcription runs through your Vellum account.`}),(!t||C)&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[!t&&(0,Q.jsx)(Jt,{onClick:j,disabled:!A||T}),C&&(0,Q.jsx)(Yt,{onClick:M})]})]})}function Wn(){return(0,Q.jsx)(Gt,{title:`Speech-to-Text`,subtitle:`Configure how your assistant transcribes speech`,children:(0,Q.jsx)(Un,{})})}function Gn(){return(0,Z.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]),(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsx)(Kt,{}),(0,Q.jsx)(vn,{}),(0,Q.jsx)(Sn,{}),(0,Q.jsx)(wn,{}),(0,Q.jsx)(Dn,{}),(0,Q.jsx)(jn,{}),(0,Q.jsx)(zn,{}),(0,Q.jsx)(Wn,{})]})}export{Gn as AiPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{a as t,c as n,i as r}from"./local-settings-C-dW2vkq.js";import{r as i,t as a}from"./capture-error-Bj8_eutd.js";import{t as o}from"./react-BFJW0bSv.js";import{t as s}from"./button-Dy5001j6.js";import{m as c,u as l}from"./chunk-5KNZJZUH-Bsoom5--.js";import{n as u}from"./QueryClientProvider-CMu7CkQU.js";import{t as d}from"./useQuery-Bz-fbQ-m.js";import{t as f}from"./useMutation-CXGTrp4W.js";import{t as p}from"./jsx-runtime-D3ZM-ToX.js";import{t as m}from"./cn-CJf7MmLX.js";import{t as h}from"./typography-DEI9Ra9z.js";import{t as g}from"./createLucideIcon-CAM1RhH8.js";import{t as _}from"./check-sC49_hjU.js";import{t as v}from"./chevron-down-B5A-0g8A.js";import{t as y}from"./circle-alert-DVCpoZrc.js";import{t as b}from"./circle-check-CjGnAahM.js";import{t as x}from"./clock-BYTc0Ds9.js";import{t as S}from"./external-link-CS0aVYGt.js";import{t as C}from"./info-vgPTIsGI.js";import{t as w}from"./list-DNbTcxAh.js";import{t as T}from"./loader-circle-XREx3i4W.js";import{t as E}from"./mail-CMdPNysl.js";import{t as D}from"./search-BVW-n8to.js";import{t as O}from"./trash-2-L5LNgw9o.js";import{t as k}from"./triangle-alert-CQfiAg_t.js";import{t as A}from"./notice-BMK7xqUw.js";import{M as j}from"./src-te3YTBG-.js";import{t as M}from"./tag-NXcyiTkK.js";import{t as N}from"./popover-BRpYVASI.js";import{t as P}from"./input-hw3el2GJ.js";import{t as F}from"./toggle-lfnhEAcN.js";import{t as I}from"./modal-BR4CUFBd.js";import{n as L}from"./toast-LgLp4obE.js";import{t as R}from"./confirm-dialog-UYFm4osC.js";import{t as z}from"./dropdown-BCfnSdIZ.js";import{$ as B,B as V,C as H,F as U,G as W,H as G,I as ee,J as K,K as q,L as te,M as ne,N as J,P as Y,Q as X,R as re,S as ie,T as ae,U as oe,V as se,W as ce,X as le,Y as ue,Z as de,_ as fe,a as pe,at as me,c as he,ct as ge,d as _e,et as ve,f as ye,g as be,h as xe,i as Se,it as Ce,j as we,l as Te,lt as Ee,m as De,n as Oe,nt as ke,o as Ae,ot as je,p as Me,q as Ne,r as Pe,rt as Fe,s as Ie,st as Le,t as Re,tt as ze,u as Be,v as Ve,w as He,x as Ue,y as We,z as Ge}from"./use-sticky-profiles-CdWX0mgI.js";import{Ut as Ke,Wt as qe,ar as Je,ft as Ye,j as Xe,lt as Ze,wn as Qe}from"./sdk.gen-BHZ0fJla.js";import{Bt as $e,Ft as et,H as tt,V as nt,_t as rt,c as it,d as at,f as ot,l as st,m as ct,p as lt,u as ut}from"./react-query.gen-C5c1Acuq.js";import{t as dt}from"./assistant-identity-store-DIyVo8LV.js";import{i as ft,r as pt,t as mt}from"./utils-CnB60ZJN.js";import{r as ht}from"./api-errors-CFiCT7Ap.js";import{u as gt}from"./routes-D9sNqB_o.js";import{i as _t}from"./use-platform-gate-C65D14xY.js";import{r as vt}from"./use-is-org-ready-C5xlYywh.js";import{c as yt,d as bt,f as xt,g as St,h as Ct,l as wt,lt as Tt,m as Et,o as Dt,p as Ot,s as kt,u as At,v as jt,y as Mt}from"./react-query.gen-BC3STDmV.js";import{a as Nt,i as Pt,n as Ft,o as It}from"./voice-list-CW8mzaHU.js";import{t as Lt}from"./platform-login-notice-CdYiKsE8.js";import{t as Rt}from"./use-active-assistant-id-CldxA_-M.js";import{t as zt}from"./detail-card-Du8OuE3q.js";import{t as Bt}from"./use-platform-assistant-id-DOsSt6k1.js";import{t as Vt}from"./environment-store-Bft0lpgv.js";var Ht=g(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Z=e(o(),1),Q=p();function Ut({mode:e,onChange:t}){return(0,Q.jsx)(`div`,{className:`max-w-[280px]`,children:(0,Q.jsx)(j,{ariaLabel:`Service mode`,value:e,onChange:t,items:[{value:`managed`,label:`Managed`},{value:`your-own`,label:`Your Own`}]})})}function Wt({id:e,title:t,subtitle:n,mode:r,onModeChange:i,children:a}){return(0,Q.jsxs)(zt,{id:e,title:t,subtitle:n,accessory:(0,Q.jsx)(Ut,{mode:r,onChange:i}),children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:a})]})}function Gt({id:e,title:t,subtitle:n,children:r}){return(0,Q.jsxs)(zt,{id:e,title:t,subtitle:n,children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:r})]})}function Kt(){return(0,Q.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,Q.jsx)(C,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsxs)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:[`Managed services are metered and deducted from your Vellum account balance.`,` `,(0,Q.jsxs)(`a`,{href:`https://www.vellum.ai/docs/pricing`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--primary-base)] hover:underline`,children:[`View pricing`,(0,Q.jsx)(S,{className:`h-3.5 w-3.5`})]})]})]})}function qt({status:e,message:t,isLoading:n}){return n?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,children:[(0,Q.jsx)(T,{className:`h-3 w-3 animate-spin`}),`Checking domain…`]}):e?e===`verified`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-positive-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-positive-strong)]`,title:`DNS records have been verified. Your domain is ready to send and receive email.`,children:[(0,Q.jsx)(_,{className:`h-3 w-3`}),`Domain verified`]}):e===`pending`||e===`not_started`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-mid-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-mid-strong)]`,title:`DNS records have been provisioned. Waiting for the email provider to verify them — this usually takes a few minutes.`,children:[(0,Q.jsx)(x,{className:`h-3 w-3`}),`Verifying domain…`]}):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-negative-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-negative-strong)]`,title:`Domain verification failed. DNS records may not have propagated correctly. You could try releasing and re-registering the domain.`,children:[(0,Q.jsx)(y,{className:`h-3 w-3`}),`Verification failed`]}):(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,title:`Unable to retrieve domain verification status.`,children:`Unknown status`})}function Jt({onClick:e,disabled:t}){return(0,Q.jsx)(s,{onClick:e,disabled:t,children:`Save`})}function Yt({onClick:e,filled:t=!1}){return(0,Q.jsx)(s,{variant:t?`danger`:`dangerGhost`,onClick:e,children:`Reset`})}function Xt({guide:e}){return(0,Q.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,Q.jsx)(C,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{children:e.description}),(0,Q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[e.linkLabel,(0,Q.jsx)(S,{className:`h-3 w-3`})]})]})]})}var Zt=`__custom__`;function Qt(e){return e?!!(e.profile||e.provider||e.model):!1}function $t(e,t){let n=Qt(e);return n===Qt(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function en({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,onDraftChange:o,onToggle:s}){let c=Qt(i),l=!i||!c?``:i.provider||i.model?Zt:i.profile??``,u=l===Zt,d=se(),f=d[0]??me[0],p=d.find(e=>e===i?.provider)??f,m=Ee(p).map(e=>({value:e.id,label:e.displayName})),h=!!i?.provider&&!i?.model;function g(t){t===`__custom__`?o(e,{profile:null,provider:f,model:ge(f)??``}):t===``?o(e,null):o(e,{profile:t,provider:null,model:null})}function _(t){let n=ge(t)??``;o(e,{...i??{},profile:null,provider:t,model:n})}function v(t){o(e,{...i??{},model:t})}return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,Q.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,Q.jsxs)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:[`· Default: `,r]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c&&(0,Q.jsx)(z,{value:l,onChange:g,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,Q.jsx)(F,{checked:c,onChange:t=>s(e,t),"aria-label":`Override ${t}`})]})]}),c&&u&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{value:p??``,onChange:_,options:d.map(e=>({value:e,label:Le[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,Q.jsx)(z,{value:i?.model??``,onChange:v,options:m})]})]}),h&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:`Pick a model`})]})]})}function tn({isOpen:e,onClose:t,assistantId:n}){let r=(0,Z.useRef)(!1);return(0,Q.jsx)(I.Root,{open:e,onOpenChange:e=>{!e&&!r.current&&t()},children:e?(0,Q.jsx)(nn,{assistantId:n,onClose:t,onSavingChange:e=>{r.current=e}}):null})}function nn({assistantId:e,onClose:t,onSavingChange:n}){let r=u(),{data:i}=d({...it({path:{assistant_id:e}}),staleTime:3e4}),o=(0,Z.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),c=(0,Z.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),l=(0,Z.useMemo)(()=>i?.llm?.callSites??{},[i?.llm?.callSites]),f=(0,Z.useMemo)(()=>Ne(o,c),[o,c]),p=se(),m=$e({onSuccess:t=>{ut(r,{path:{assistant_id:e}},t)}}),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)({}),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),{data:E,isLoading:O,isError:k,refetch:A}=d({...at({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),j=(0,Z.useMemo)(()=>(E?.callSites??[]).filter(e=>e.id!==`mainAgent`),[E]),M=!O&&!k&&!!E&&!!i,N=(0,Z.useMemo)(()=>j.map(e=>e.id),[j]),F=(0,Z.useMemo)(()=>{if(!M)return{};let e={};for(let t of N)if(t in y)e[t]=y[t];else{let n=l[t];e[t]=n?{...n}:{}}return e},[M,N,l,y]),B=(0,Z.useMemo)(()=>new Set(N),[N]),V=(0,Z.useMemo)(()=>Object.entries(l).some(([e,t])=>B.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[l,B]),H=(0,Z.useMemo)(()=>{if(!M)return!1;for(let e of Object.keys(F))if(!$t(F[e],l[e]))return!0;return!1},[M,F,l]),U=(0,Z.useMemo)(()=>Object.values(F).some(e=>Qt(e)&&!!e?.provider&&!e?.model),[F]),W=(0,Z.useMemo)(()=>Se(f,[]).map(e=>({value:e.name,label:Oe(e)})),[f]),G=(0,Z.useCallback)(()=>{if(!_)return;let e={};for(let t of N)e[t]={profile:_};b(e)},[_,N]),ee=(0,Z.useCallback)(e=>[...Se(f,[e]).map(e=>({value:e.name,label:Oe(e)})),{value:Zt,label:`Custom`}],[f]),K=(0,Z.useMemo)(()=>{if(!h.trim())return j;let e=h.toLowerCase();return j.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[j,h]),q=(0,Z.useMemo)(()=>{if(!E)return[];let e=E.domains.map(e=>e.id),t=new Map(E.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=K.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let r=new Set(e),i=K.filter(e=>!r.has(e.domain));return i.length>0&&n.push({domain:{id:`other`,displayName:`Other`},sites:i}),n},[E,K]),te=(0,Z.useCallback)((e,t)=>{b(n=>({...n,[e]:t}))},[]),ne=(0,Z.useCallback)((e,t)=>{if(!t){b(t=>({...t,[e]:null}));return}let n=Pe(f,j.find(t=>t.id===e)?.defaultProfile);if(n)b(t=>({...t,[e]:{profile:n}}));else{let t=p[0]??me[0],n=ge(t)??``;b(r=>({...r,[e]:{provider:t,model:n}}))}},[j,f,p]),J=(0,Z.useCallback)(async()=>{S(!0),n?.(!0);try{let n={};for(let e of Object.keys(F)){let t=F[e]??null;n[e]=Qt(t)?{profile:t?.profile??null,provider:t?.provider??null,model:t?.model??null}:null}await m.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),L.success(`Overrides saved.`)}catch(e){L.error(`Failed to save overrides. Please try again.`),a(e,{context:`call_site_overrides_save`})}finally{S(!1),n?.(!1)}},[F,t,m,n,e]),Y=(0,Z.useCallback)(async()=>{S(!0),n?.(!0);try{let n={};for(let e of Object.keys(F))n[e]=null;await m.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),L.success(`Overrides reset.`)}catch(e){L.error(`Failed to reset overrides. Please try again.`),a(e,{context:`call_site_overrides_reset`})}finally{S(!1),n?.(!1)}},[F,t,m,n,e]);return(0,Q.jsxs)(I.Content,{size:`lg`,hideCloseButton:!0,children:[(0,Q.jsxs)(I.Header,{children:[(0,Q.jsx)(I.Title,{children:`Action Overrides`}),(0,Q.jsx)(I.Description,{children:`Customize which model profile specific actions should use. Uses your default profile if no override is set.`})]}),(0,Q.jsxs)(I.Body,{children:[(0,Q.jsx)(`div`,{className:`mb-4`,children:(0,Q.jsx)(P,{type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:`Search actions…`,leftIcon:(0,Q.jsx)(D,{className:`h-4 w-4`}),fullWidth:!0})}),W.length>0&&(0,Q.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 text-body-medium-default text-[var(--content-default)]`,children:`Use one profile for all actions`}),(0,Q.jsx)(z,{value:_,onChange:v,options:W,placeholder:`Choose profile…`,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:G,disabled:!_||!M||x,children:`Apply to all`})]}),O&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(T,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),k&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Couldn't load actions`}),(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Make sure your assistant is running`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>void A(),children:`Retry`})]}),!O&&!k&&E&&(0,Q.jsx)(`div`,{className:`space-y-4`,children:q.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No actions match your search.`}):q.map(({domain:e,sites:t})=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>{let t=(()=>{let t=F[e.id]??null;return!t||!Qt(t)?``:t.provider||t.model?`__custom__`:t.profile??``})(),n=e.defaultProfile?f.find(t=>t.name===e.defaultProfile)?.label??e.defaultProfile:null;return(0,Q.jsx)(en,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:n,draft:F[e.id]??null,profileOptions:ee(t===``||t===`__custom__`?null:t),onDraftChange:te,onToggle:ne},e.id)})})]},e.id))})]}),(0,Q.jsxs)(I.Footer,{children:[V&&(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>w(!0),disabled:x||!M,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:`Reset to Defaults`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:t,disabled:x,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,onClick:()=>void J(),disabled:!H||U||x,children:x?(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin`}):`Save`})]}),(0,Q.jsx)(R,{open:C,title:`Reset to Defaults`,message:`Every task override will be reset and will follow your active profile. This cannot be undone.`,confirmLabel:`Reset to Defaults`,destructive:!0,onConfirm:()=>{w(!1),Y()},onCancel:()=>w(!1)})]})}function rn({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:c}){let l=``;if(e){let t=e.label||e.name;l=e.isActive&&e.callSiteIds.length>0?`"${t}" is the active profile and is used by ${e.callSiteIds.length} call site(s). Pick a replacement profile.`:e.isActive?`"${t}" is the active profile. Pick a different active profile before deleting, or select a replacement below.`:`"${t}" is used by ${e.callSiteIds.length} call site(s). Select a replacement profile to reassign them before deleting.`}return(0,Q.jsx)(I.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,Q.jsxs)(I.Content,{size:`sm`,children:[(0,Q.jsx)(I.Header,{children:(0,Q.jsx)(I.Title,{children:`Can't Delete Profile`})}),(0,Q.jsxs)(I.Body,{className:`space-y-4`,children:[(0,Q.jsx)(h,{variant:`body-medium-default`,as:`p`,children:l}),e&&e.callSiteIds.length>0&&(0,Q.jsx)(`ul`,{className:`space-y-1 pl-1`,children:e.callSiteIds.map(e=>(0,Q.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,(0,Q.jsx)(`code`,{children:e})]},e))}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Replacement profile`}),(0,Q.jsx)(z,{"aria-label":`Replacement profile`,value:n,onChange:r,options:[{value:``,label:`Select a replacement…`},...t.map(e=>({value:e.name,label:e.label??e.name}))]})]}),i&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,Q.jsxs)(I.Footer,{children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:c,children:a?`Saving…`:`Reassign and Delete`})]})]})})}function an(e,t){if(e){let n=Ee(e).find(e=>e.id===t);if(n)return n.displayName}let n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t}function on(e,t){let n=[];e.description&&n.push(e.description);let r=e.provider_connection===`vellum`&&t?`vellum`:e.provider,i=[];if(e.model&&i.push(an(r,e.model)),r){let e=Le[r]??r;i.push(`hosted by ${e}`)}return i.length>0&&n.push(i.join(` `)),n.join(` – `)}function sn({profile:e,vellumIsManaged:t,isDragging:n,dropTarget:r,isDeleting:i,deleteError:a,isToggling:o,onDragStart:c,onDragEnd:l,onDragOver:u,onDragLeave:d,onDrop:f,onEditClick:p,onDeleteClick:m,onStatusToggle:g}){let _=e.source===`managed`,v=e.invariant===!0,y=e.status!==`disabled`;return(0,Q.jsxs)(`div`,{className:`relative`,children:[r?.name===e.name&&!r.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg pr-2 py-2${n?` opacity-50`:``}`,draggable:!_,onDragStart:c,onDragEnd:l,onDragOver:u,onDragLeave:d,onDrop:f,children:[(0,Q.jsx)(Ht,{className:`h-4 w-4 shrink-0 ${_?`invisible`:`cursor-grab text-[var(--content-tertiary)]`}`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1${y?``:` opacity-55`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(h,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:e.label??e.name}),_&&(0,Q.jsx)(M,{tone:`positive`,title:`Managed by Platform — this profile cannot be disabled, deleted, or renamed.`,children:`Platform`})]}),e.description||e.model||e.provider?(0,Q.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:on(e,t)}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(!v||!y)&&(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center`,title:y?`Active — toggle to hide from pickers`:`Disabled — toggle to show in pickers`,children:(0,Q.jsx)(F,{checked:y,onChange:e=>g(e),disabled:o,"aria-label":`${y?`Disable`:`Enable`} ${e.label??e.name}`})}),(0,Q.jsxs)(`div`,{className:`flex w-[92px] items-center justify-end gap-2`,children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:p,children:_||v?`View`:`Edit`}),(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(O,{}),"aria-label":`Delete ${e.label??e.name}`,disabled:_||v||i,title:_||v?`Managed profiles cannot be deleted`:void 0,onClick:m,tintColor:`var(--system-negative-strong)`})]})]})]}),r?.name===e.name&&r.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),a?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:a}):null]})}function cn({isOpen:e,assistantId:t,onClose:n}){let r=u(),{data:i}=d({...it({path:{assistant_id:t}}),staleTime:3e4}),o=(0,Z.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),s=(0,Z.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),c=i?.llm?.activeProfile??null,l=i?.llm?.callSites??{},f=(0,Z.useMemo)(()=>Ne(o,s),[o,s]),p=$e({onSuccess:e=>{ut(r,{path:{assistant_id:t}},e)}}),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),{data:v}=d({...nt({path:{assistant_id:t}}),enabled:e}),y=v?.connections,b=y?.some(e=>e.name===`vellum`&&e.provider===`vellum`)??!1,x=Object.keys(o);async function S(e,n,r){let i=r?.mode??`replace`,c=!(e in o);if(i===`merge`&&!c){await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:n}}}}),h(!1),_(null);return}let l={profiles:{[e]:n}};if(c&&(l.profileOrder=s.includes(e)?s:[...s,e]),c)await p.mutateAsync({path:{assistant_id:t},body:{llm:l}});else{let n=o[e];await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:null}}}});try{await p.mutateAsync({path:{assistant_id:t},body:{llm:l}})}catch(r){throw a(r,{context:`settings-ai-profile-edit-recreate`}),n!=null&&await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:n}}}}).catch(()=>{}),r}}c&&L.success(`Profile "${n.label??e}" created`),h(!1),_(null)}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(I.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,Q.jsx)(ln,{assistantId:t,vellumIsManaged:b,profiles:o,profileOrder:s,orderedProfiles:f,activeProfile:c,callSiteOverrides:l,onClose:n,onEditClick:e=>{_(e),h(!0)},onNewClick:()=>{_(null),h(!0)}}):null}),(0,Q.jsx)(we,{isOpen:m,mode:g?g.source===`managed`||g.invariant===!0?`view`:`edit`:`create`,profileName:g?.name,initialValues:g??void 0,existingNames:x,connections:y,assistantId:t,onSave:S,onCancel:()=>{h(!1),_(null)}})]})}function ln({assistantId:e,vellumIsManaged:t,profiles:n,profileOrder:r,orderedProfiles:i,activeProfile:o,callSiteOverrides:c,onClose:l,onEditClick:d,onNewClick:f}){let p=u(),m=$e({onSuccess:t=>{ut(p,{path:{assistant_id:e}},t)}}),[g,_]=(0,Z.useState)({}),[v,y]=(0,Z.useState)({}),[b,x]=(0,Z.useState)(new Set),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(null),A=(0,Z.useRef)(null),j=(0,Z.useRef)(null),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(``),[z,B]=(0,Z.useState)(!1),V=(0,Z.useMemo)(()=>i,[i]);async function H(t,r){if(b.has(t.name))return!1;x(e=>new Set(e).add(t.name)),C(null);let i=r?`active`:`disabled`;if(!n[t.name])return x(e=>{let n=new Set(e);return n.delete(t.name),n}),!1;try{return await m.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[t.name]:{status:i}}}}}),!0}catch(e){return a(e,{context:`settings-ai-profile-toggle`}),C(`Couldn't update "${t.label??t.name}". Please try again.`),!1}finally{x(e=>{let n=new Set(e);return n.delete(t.name),n})}}async function U(t){y(e=>({...e,[t]:!0})),_(e=>{let n={...e};return delete n[t],n});try{let n=r.filter(e=>e!==t);await m.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[t]:null},profileOrder:n}}})}catch(e){a(e,{context:`settings-ai-profile-delete`}),_(e=>({...e,[t]:`Failed to delete profile. Please try again.`}))}finally{y(e=>{let n={...e};return delete n[t],n})}}function W(e){let t=V.find(t=>t.name===e)?.label??e,n=e===o,r=Object.entries(c).filter(([t,n])=>t!==`mainAgent`&&n?.profile===e).map(([e])=>e);if(n||r.length>0){N({name:e,label:t,isActive:n,callSiteIds:r}),R(``),F(null);return}U(e)}async function G(){if(!M||!L)return;B(!0),F(null);let t={};if(M.isActive&&(t.activeProfile=L),M.callSiteIds.length>0){let e={};for(let t of M.callSiteIds)e[t]={profile:L};t.callSites=e}if(Object.keys(t).length>0)try{await m.mutateAsync({path:{assistant_id:e},body:{llm:t}})}catch(e){a(e,{context:`settings-ai-profile-reassign-delete`}),F(`Failed to reassign references. Please try again.`),B(!1);return}let n=M.name;N(null),B(!1),U(n)}async function ee(t,n){if(t===n.name)return;k(null);let i=r.filter(e=>e!==t),o=i.indexOf(n.name);if(o===-1)return;n.after&&(o+=1);let s=[...i.slice(0,o),t,...i.slice(o)];try{await m.mutateAsync({path:{assistant_id:e},body:{llm:{profileOrder:s}}})}catch(e){a(e,{context:`settings-ai-profile-reorder`}),k(`Failed to reorder profiles. Please try again.`)}}let K=V.filter(e=>e.name!==M?.name&&e.source!==`managed`),q=K.length>0?K:V.filter(e=>e.name!==M?.name);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(I.Content,{size:`md`,children:[(0,Q.jsxs)(I.Header,{children:[(0,Q.jsx)(I.Title,{children:`Model Profiles`}),(0,Q.jsx)(I.Description,{children:`Bundle a provider and model into a named profile. Assign profiles to specific actions or swap between them when chatting.`})]}),(0,Q.jsxs)(I.Body,{children:[V.length===0?(0,Q.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No profiles yet. Create one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:V.map(e=>(0,Q.jsx)(sn,{profile:e,vellumIsManaged:t,isDragging:w===e.name,dropTarget:E,isDeleting:v[e.name]??!1,deleteError:g[e.name],isToggling:b.has(e.name),onDragStart:t=>{A.current=e.name,T(e.name),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{A.current=null,j.current=null,T(null),D(null)},onDragOver:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>n.top+n.height/2,i={name:e.name,after:r};j.current=i,D(i)},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||(j.current=null,D(t=>t?.name===e.name?null:t))},onDrop:e=>{e.preventDefault();let t=A.current,n=j.current;A.current=null,j.current=null,T(null),D(null),t&&n&&ee(t,n)},onEditClick:()=>d(e),onDeleteClick:()=>W(e.name),onStatusToggle:t=>void H(e,t)},e.name))}),O&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:O}),S&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:S})]}),(0,Q.jsxs)(I.Footer,{className:`justify-between`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:f,children:`+ New Profile`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Done`})]})]}),(0,Q.jsx)(rn,{blocked:M,availableReplacements:q,replacement:L,onReplacementChange:R,error:P,saving:z,onClose:()=>{N(null),F(null)},onConfirm:()=>void G()})]})}var un=`0.10.8`;function dn(){return pt(un)}function fn({mode:e,connection:t,assistantId:n,existingNames:r,connections:i,onSave:a,onCancel:o}){let[c,l]=(0,Z.useState)(t?.label??``),d=t?.name??``,f=t?.provider??`anthropic`,p=t?.auth.type??`api_key`,[m,g]=(0,Z.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[_,v]=(0,Z.useState)(t?.baseUrl??``),[y,b]=(0,Z.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),T=f===`openai-compatible`,[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(!1),A=u(),j=(0,Z.useMemo)(()=>oe(m),[m]),M=p===`api_key`&&j!==null,{hasStoredCredential:N,isLoading:F}=V({assistantId:n,credentialKind:`credential`,credentialName:j?`${j.service}:${j.field}`:``,enabled:M}),{credentials:L}=J({assistantId:n,enabled:p===`api_key`});(0,Z.useEffect)(()=>{let e=t?.provider??`anthropic`;l(t?.label??``),t?.auth.type===`api_key`?g(t.auth.credential):g(t?``:`credential/${e}/api_key`),w(null),v(t?.baseUrl??``),b(t?.models?t.models.map(e=>e.id).join(`, `):``),D(``),k(!1)},[t]);let R=c.trim()!==(t?.label??``).trim(),z=T&&R?te(c,i,t?.name):null,B=d.trim().length>0&&z===null;async function H(){if(B){S(!0),w(null);try{let e;if(p===`api_key`){let t=m.trim()||`credential/${f}/api_key`,r=E.trim();if(r){k(!0);try{let e=oe(t);await Je({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:f,value:r},throwOnError:!0});let i=Ge(n,`credential`,e?`${e.service}:${e.field}`:``);A.setQueryData(i,!0),A.invalidateQueries({queryKey:rt({path:{assistant_id:n}})})}catch{w(`Failed to save API key. Please try again.`);return}finally{k(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{w(`Nothing to edit. Close and try again.`);return}let r=c.trim()||null,i={auth:e,label:r,...T&&{base_url:_.trim()||null,models:y.trim()?y.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:o,error:s,response:l}=await qe({path:{assistant_id:n,name:t?.name??d.trim()},body:i});if(!l?.ok){w(W(l?.status,s)??G(l?.status));return}if(!o){w(`Server returned an empty response. Please try again.`);return}a(o)}catch{w(`Failed to save provider. Please try again.`)}finally{S(!1)}}}let K=L.filter(e=>e.service===f),q=e!==`create`&&t?.auth.type===`api_key`,X=K.length>0||q,ie=Y(`Enter your API key`,N);return e===`create`?(0,Q.jsx)(ne,{variant:`modal`,assistantId:n,existingNames:r,connections:i,defaultProviderType:f,onCreated:a,onCancel:o}):(0,Q.jsxs)(I.Content,{size:`md`,children:[(0,Q.jsxs)(I.Header,{children:[(0,Q.jsx)(I.Title,{children:`Edit Provider`}),(0,Q.jsx)(I.Description,{children:t?`Editing ${ce(t)}.`:`Edit provider settings.`})]}),(0,Q.jsxs)(I.Body,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[`Display Name`,` `,(0,Q.jsx)(`span`,{className:`text-[var(--content-disabled)]`,children:`(optional)`})]}),(0,Q.jsx)(P,{value:c,onChange:e=>l(e.target.value),placeholder:`e.g. My Anthropic Key`,fullWidth:!0}),z?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:ee[z]}):null]}),T&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,Q.jsx)(P,{value:_,onChange:e=>v(e.target.value),placeholder:`https://api.example.com/v1`,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,Q.jsx)(P,{value:y,onChange:e=>b(e.target.value),placeholder:`model-1, model-2`,fullWidth:!0}),(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),p===`api_key`&&(0,Q.jsx)(U,{apiKeyValue:E,onApiKeyChange:D,credential:m,onCredentialChange:g,isLoadingCredential:F,apiKeyPlaceholder:ie,provider:f,providerCredentials:K,showAdvancedSection:X,onError:w}),p===`oauth_subscription`&&(0,Q.jsx)(re,{assistantId:n,onConnected:a}),C&&(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:C})]}),(0,Q.jsxs)(I.Footer,{children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,disabled:!B||x||O,onClick:()=>void H(),children:x?`Saving…`:`Save`})]})]})}var pn={anthropic:!0,openai:!0,gemini:!0,fireworks:!0,openrouter:!0,vellum:!0};function mn(e){return e in pn}function hn(e){let t=e.baseUrl??``;try{e.baseUrl&&(t=new URL(e.baseUrl).host)}catch{}let 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 gn({isOpen:e,assistantId:t,onClose:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=u(),{data:c,isLoading:l,isError:f}=d({...nt({path:{assistant_id:t}}),enabled:e}),p=dn(),{data:m}=d({...ot({path:{assistant_id:t}}),enabled:e&&p}),h=(0,Z.useMemo)(()=>{let e=c?.connections??[];return[...e.filter(e=>e.provider===je),...e.filter(e=>e.provider!==je)]},[c]);function g(){s.invalidateQueries({queryKey:lt({path:{assistant_id:t}})}),s.invalidateQueries({queryKey:st({path:{assistant_id:t}})})}function _(e){s.invalidateQueries({queryKey:tt({path:{assistant_id:t}})}),i(!1),o(null)}let v=h.map(e=>e.name),y=()=>{i(!1),o(null)};return(0,Q.jsx)(I.Root,{open:e,onOpenChange:e=>{e||(r?y():n())},children:e?r?(0,Q.jsx)(fn,{mode:a?`edit`:`create`,connection:a??void 0,assistantId:t,existingNames:v,connections:h,onSave:_,onCancel:y}):(0,Q.jsx)(_n,{connections:h,loading:l,isError:f,assistantId:t,supportsDefaultProvider:p,defaultConnectionName:p?m?.resolvedConnectionName??null:null,onDefaultChanged:g,onClose:n,onEditClick:e=>{o(e),i(!0)},onNewClick:()=>{o(null),i(!0)},onConnectionDeleted:()=>{s.invalidateQueries({queryKey:tt({path:{assistant_id:t}})})}}):null})}function _n({connections:e,loading:t,isError:n,assistantId:r,supportsDefaultProvider:i,defaultConnectionName:o,onDefaultChanged:c,onClose:l,onEditClick:u,onNewClick:d,onConnectionDeleted:p}){let[m,g]=(0,Z.useState)({}),[_,v]=(0,Z.useState)({}),y=f({...ct(),onMutate:e=>{let t=e.body?.connectionName;t&&g(e=>{let n={...e};return delete n[t],n})},onSuccess:c,onError:(e,t)=>{a(e,{context:`settings-ai-set-default-provider`});let n=t.body?.connectionName;n&&g(e=>({...e,[n]:`Failed to set default provider. Please try again.`}))}});function b(e){mn(e.provider)&&y.mutate({path:{assistant_id:r},body:{provider:e.provider,connectionName:e.name}})}async function x(e){v(t=>({...t,[e]:!0})),g(t=>{let n={...t};return delete n[e],n});try{let{response:t}=await Ke({path:{assistant_id:r,name:e}});t?.ok||t?.status===404?p(e):t?.status===409?g(t=>({...t,[e]:`This provider is in use by a profile or as the default provider. Update those settings before deleting it.`})):g(t=>({...t,[e]:`Failed to delete provider. Please try again.`}))}catch{g(t=>({...t,[e]:`Failed to delete provider. Please try again.`}))}finally{v(t=>{let n={...t};return delete n[e],n})}}return(0,Q.jsxs)(I.Content,{size:`md`,children:[(0,Q.jsxs)(I.Header,{children:[(0,Q.jsx)(I.Title,{children:`Providers`}),(0,Q.jsx)(I.Description,{children:`Manage the model providers your assistant can use.`})]}),(0,Q.jsx)(I.Body,{children:t?(0,Q.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`h-10 animate-pulse rounded-lg bg-[var(--surface-active)]`},e))}):n?(0,Q.jsx)(h,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:`Failed to load providers. Please try again.`}):e.length===0?(0,Q.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No providers yet. Add one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>{let t=_[e.name]??!1,n=m[e.name],r=e.isManaged??!1,a=e.name===o,c=mn(e.provider),l=y.isPending&&y.variables?.body?.connectionName===e.name;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg px-2 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(h,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:ce(e)}),r&&(0,Q.jsx)(M,{tone:`positive`,title:`Managed by Platform — you can rename this provider, but not edit it.`,children:`Platform`}),a&&(0,Q.jsx)(M,{tone:`info`,title:`Built-in profiles (Balanced, Quality, Speed) use this provider.`,children:`Default`}),e.provider===`vellum`?null:e.provider===`openai-compatible`&&(0,Q.jsx)(M,{tone:`neutral`,title:`A provider you created — served by an OpenAI-compatible endpoint.`,children:`Custom`})]}),e.provider===`openai-compatible`?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--content-tertiary)`,children:hn(e)}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[i&&!a&&(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,disabled:!c||l,title:c?`Use this provider for the built-in profiles.`:`Built-in profiles can't run on this provider.`,onClick:()=>b(e),children:`Set as default`}),!r&&(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:()=>u(e),children:`Edit`}),(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(O,{}),"aria-label":`Delete ${ce(e)}`,disabled:r||a||t,title:r?`The Vellum provider cannot be removed`:a?`This is your default provider. Set another provider as default first.`:void 0,onClick:()=>void x(e.name),tintColor:`var(--system-negative-strong)`})]})]}),n?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:n}):null]},e.name)})})}),(0,Q.jsxs)(I.Footer,{className:`justify-between`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:d,children:`+ Add Provider`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Done`})]})]})}function $(e){let[t,n]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Z.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}function vn(){let e=Rt(),t=u(),{data:n}=d({...it({path:{assistant_id:e}}),staleTime:3e4}),r=dn(),{data:i,refetch:o}=d({...ot({path:{assistant_id:e}}),enabled:r}),c=i?.availability,l=n?.llm?.activeProfile??null,f=n?.llm?.advisorProfile??null,p=n?.llm?.callSites??{},{profiles:m,profileOrder:g}=Re(n?.llm,e),_=(0,Z.useMemo)(()=>Ne(m,g),[m,g]),v=$e({onSuccess:n=>{ut(t,{path:{assistant_id:e}},n)}}),[y,b]=$(l),[x,S]=$(f),[C,w]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(!1),j=(0,Z.useMemo)(()=>Se(_,[y]),[_,y]),M=(0,Z.useMemo)(()=>Se(_,[x]),[_,x]),N=Object.entries(p).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length,P=N===1?`1 Override`:N>0?`${N} Overrides`:`Overrides`,F=y!==l,I=x!==f,R=(0,Z.useCallback)(async()=>{try{let t={};F&&(t.activeProfile=y),I&&(t.advisorProfile=x),await v.mutateAsync({path:{assistant_id:e},body:{llm:t}}),L.success(`Saved.`)}catch(e){L.error(`Failed to save. Please try again.`),a(e,{context:`settings-ai-language-model-save`})}},[F,I,y,x,v,e]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Gt,{title:`Language Model`,subtitle:`Configure the LLMs that power your assistant`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[c&&c.status!==`ok`&&(0,Q.jsx)(A,{tone:c.status===`unknown`?`warning`:`error`,children:c.message??`Your default provider is not available.`}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Default Profile`}),(0,Q.jsx)(z,{value:y??``,onChange:e=>{b(e===``?null:e)},placeholder:`Select a default profile…`,options:j.map(e=>({value:e.name,label:Oe(e)}))}),j.length===0?(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`No profiles yet. Click Profiles below to create one.`}):null]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Advisor Profile`}),(0,Q.jsx)(z,{value:x??``,onChange:e=>{S(e===``?null:e)},placeholder:`Select an advisor profile…`,options:M.map(e=>({value:e.name,label:Oe(e)}))}),(0,Q.jsx)(h,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`Which model your assistant consults for a second opinion`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>k(!0),children:`Providers`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>w(!0),children:`Profiles`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>D(!0),children:P})]}),(F||I)&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Jt,{onClick:R,disabled:v.isPending}),v.isPending&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]})}),e&&(0,Q.jsx)(cn,{isOpen:C,assistantId:e,onClose:()=>w(!1)}),e&&(0,Q.jsx)(tn,{isOpen:E,onClose:()=>D(!1),assistantId:e}),e&&(0,Q.jsx)(gn,{isOpen:O,assistantId:e,onClose:()=>{k(!1),r&&o()}})]})}function yn(){let e=Rt();return(0,Z.useCallback)(async(t,n)=>{try{let{data:r}=await Je({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});q(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?L.error(`Assistant not ready. Please try again.`):L.error(`Failed to save ${t} API key. Please try again.`),a(e,{context:`provision_provider_key`}),e}},[e])}var bn=`0.10.12`;function xn(){return mt(bn)}function Sn(){let e=Rt(),i=u(),o=vt(),{data:s}=d({...it({path:{assistant_id:e}}),enabled:o,staleTime:3e4}),c=$e({onSuccess:t=>{ut(i,{path:{assistant_id:e}},t)}}),l=yn(),f=(0,Z.useMemo)(()=>{if(!s)return r(xe,`inference-provider-native`);let e=s.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||r(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[s]),[p,m]=(0,Z.useState)(!1),[h,g]=$(f),[_,v]=(0,Z.useState)(``),y=de.has(h),{hasStoredCredential:b}=V({assistantId:e,credentialKind:`api_key`,credentialName:h,enabled:y}),x=_.trim().length>0,S=p||y&&!b&&!x||h===f&&!x,C=Y(ve[h]??`Enter your API key`,b),w=(0,Z.useCallback)(async()=>{m(!0);let t=_.trim(),r=ue(h),o=y&&t.length>0;try{o&&await l(h,t),await ft();let n=h===`vellum`?xn()?{provider:`vellum`,mode:`managed`}:{mode:`managed`}:{provider:h,mode:`your-own`};await c.mutateAsync({path:{assistant_id:e},body:{services:{"web-search":n}}}).catch(e=>{throw L.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{m(!1);return}m(!1);try{if(n(xe,h),o){r&&n(r,t);let a=Ge(e,`api_key`,h);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),v(``)}L.success(`Web search settings saved.`)}catch(e){a(e,{context:`settings-ai-web-search-persist-local`}),L.error(`Saved, but local preferences could not be written.`)}},[y,c,l,i,e,_,h]),E=(0,Z.useCallback)(()=>{let e=ue(h);e&&t(e),v(``),g(`inference-provider-native`),n(xe,`inference-provider-native`)},[h,g]);return(0,Q.jsx)(Gt,{title:`Web Search`,subtitle:`Configure how your assistant should search the web`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{"aria-label":`Web search provider`,value:h,onChange:g,options:B.map(e=>({value:e,label:X[e]??e}))})]}),h===`vellum`&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Search runs through your Vellum account.`}),y&&(0,Q.jsx)(P,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:C,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Jt,{onClick:w,disabled:S}),p&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),y&&(0,Q.jsx)(Yt,{onClick:E,filled:!0})]})]})})}var Cn=`default`;function wn(){let e=Rt(),i=u(),{data:o}=d({...it({path:{assistant_id:e}}),staleTime:3e4}),s=$e({onSuccess:t=>{ut(i,{path:{assistant_id:e}},t)}}),c=yn(),l=(0,Z.useMemo)(()=>o?o.services?.[`web-fetch`]?.provider||r(`vellum:ai:webFetchProvider`,Cn):r(De,Cn),[o]),[f,p]=(0,Z.useState)(!1),[m,h]=$(l),[g,_]=(0,Z.useState)(``),v=ze.has(m),{hasStoredCredential:y}=V({assistantId:e,credentialKind:`api_key`,credentialName:m,enabled:v}),b=g.trim().length>0,x=f||v&&!y&&!b||m===l&&!b,S=Y(Ce[m]??`Enter your API key`,y),C=(0,Z.useCallback)(async()=>{p(!0);let t=g.trim(),r=v&&t.length>0;try{r&&await c(m,t),await s.mutateAsync({path:{assistant_id:e},body:{services:{"web-fetch":{provider:m}}}}).catch(e=>{throw L.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{p(!1);return}p(!1);try{if(n(De,m),r){let r=K(m);r&&n(r,t);let a=Ge(e,`api_key`,m);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),_(``)}L.success(`Web fetch settings saved.`)}catch(e){a(e,{context:`settings-ai-web-fetch-persist-local`}),L.error(`Saved, but local preferences could not be written.`)}},[v,s,c,i,e,g,m]),w=(0,Z.useCallback)(()=>{let e=K(m);e&&t(e),_(``),h(Cn),n(De,Cn)},[m,h]);return(0,Q.jsx)(Gt,{id:`web-fetch`,title:`Web Fetch`,subtitle:`Configure how your assistant reads individual web pages`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{value:m,onChange:h,options:Fe.map(e=>({value:e,label:ke[e]??e}))})]}),v&&(0,Q.jsx)(P,{label:`API Key`,type:`password`,value:g,onChange:e=>_(e.target.value),placeholder:S,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Jt,{onClick:C,disabled:x}),f&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),v&&(0,Q.jsx)(Yt,{onClick:w,filled:!0})]})]})})}function Tn({subdomain:e,onSubdomainChange:t,domainSuffix:n,subdomainPlaceholder:r=`my-assistant`,disabled:i,autoFocus:a,prefix:o,error:s,locked:c,lockedMessage:l}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex h-9 w-full items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${s?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[o,(0,Q.jsx)(`input`,{value:e,onChange:e=>t(e.target.value.toLowerCase().trim()),disabled:i||c,readOnly:c,autoFocus:a,placeholder:r,"aria-label":`Subdomain`,"aria-invalid":!!s,className:`h-full min-w-0 flex-1 bg-transparent ${o?`pl-1.5`:`pl-3`} pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none disabled:cursor-not-allowed disabled:opacity-60`}),(0,Q.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`.`,n]})]}),s&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--system-negative-strong)]`,children:s}),c&&l&&(0,Q.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--content-tertiary)]`,children:l})]})}function En({assistantId:e,assistantHandle:t,emailRootDomain:n}){let r=u(),i=l(),[o,p]=c(),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(``),[S,C]=(0,Z.useState)(null),[w,D]=(0,Z.useState)(!1),[k,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{g||!t||m||(h(t),_(!0))},[t,g,m]);let P=d({...Tt(),enabled:!0}),F=P.data,I=F?.entitlements,z=I?.managed_email===!0,B=!!I&&!z,V=!F&&P.isError&&!P.isFetching,H=d({...yt({path:{assistant_id:e}}),enabled:!B}),U=d({...Ot({path:{assistant_id:e}}),enabled:!B}),W=H.data?.results?.[0],G=U.data?.results?.[0],ee=W?`${W.subdomain}.${n}`:null,K=d({...Ct({path:{assistant_id:e,id:G?.id??``}}),enabled:!!G?.id,refetchOnWindowFocus:!1}),q=d({...At({path:{assistant_id:e,id:W?.id??``}}),enabled:!!W?.id,refetchInterval:e=>{let t=e.state.data?.status;return t===`verified`||t===`failed`?!1:1e4},refetchOnWindowFocus:!0});(0,Z.useEffect)(()=>{o.get(`release`)!==`1`||!W||G||(j(!0),p(e=>{let t=new URLSearchParams(e);return t.delete(`release`),t},{replace:!0}))},[G,W,o,p]);let te=f(Dt()),ne=f(kt()),J=f(bt()),Y=f(xt()),X=(0,Z.useCallback)(()=>{let t={assistant_id:e};r.invalidateQueries({queryKey:wt({path:t})}),r.invalidateQueries({queryKey:Et({path:t})}),G?.id&&r.invalidateQueries({queryKey:St({path:{...t,id:G.id}})}),r.invalidateQueries({queryKey:Mt()})},[G?.id,e,r]),re=(0,Z.useCallback)(async()=>{let t=m.trim().toLowerCase();if(!t){y(`Enter a subdomain.`);return}D(!1);try{await te.mutateAsync({path:{assistant_id:e},body:{subdomain:t}}),h(``),y(null),X(),L.success(`Domain ${t}.${n} registered.`)}catch(e){y(ht(e,void 0,`Failed to register domain.`))}},[e,n,X,te,m]),ie=(0,Z.useCallback)(async()=>{let t=b.trim().toLowerCase();if(!t){C(`Enter an email username.`);return}try{await J.mutateAsync({path:{assistant_id:e},body:{username:t}}),x(``),C(null),X(),L.success(`Email address created.`)}catch(e){C(ht(e,void 0,`Failed to create email address.`))}},[e,X,J,b]),ae=(0,Z.useCallback)(async()=>{if(G?.id){N(!1);try{await Y.mutateAsync({path:{assistant_id:e,id:G.id}}),X(),L.success(`Email address removed.`)}catch(e){a(e,{context:`email_address_delete`}),L.error(`Failed to remove email address.`)}}},[G?.id,e,Y,X]),oe=(0,Z.useCallback)(async()=>{if(!W?.id)return;if(G){L.error(`Remove the email address first.`);return}j(!1);let t=W.subdomain;try{await ne.mutateAsync({path:{assistant_id:e,id:W.id}}),h(t),X(),L.success(`Domain released.`)}catch(e){a(e,{context:`email_domain_release`}),L.error(`Failed to release domain.`)}},[G,e,ne,W?.id,W?.subdomain,X]);if(P.isLoading)return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin`}),`Checking subscription…`]});if(B)return(0,Q.jsx)(A,{tone:`info`,icon:(0,Q.jsx)(E,{className:`h-4 w-4`,"aria-hidden":!0}),title:`Give your assistant its own email address`,actions:(0,Q.jsx)(s,{size:`compact`,onClick:()=>i(gt.plans),children:`Upgrade`}),children:`Upgrade to a plan that includes an email address for your assistant. No provider setup required.`});let se=V?(0,Q.jsx)(A,{tone:`warning`,title:`Couldn't verify subscription status`,actions:(0,Q.jsx)(s,{size:`compact`,variant:`outlined`,onClick:()=>P.refetch(),children:`Retry`}),children:`We couldn't reach the billing service. The form below assumes managed email is enabled for your org — if it isn't, registering a domain will fail.`}):null;return W?G?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[se,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:G.address}),(0,Q.jsx)(qt,{status:q.data?.status,message:q.data?.message,isLoading:q.isLoading}),(0,Q.jsx)(s,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(O,{}),onClick:()=>N(!0),disabled:Y.isPending,"aria-label":`Remove email address`})]}),(0,Q.jsx)(R,{open:M,title:`Remove Email Address`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to remove `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:G.address}),`? Your assistant will no longer be able to send or receive email at this address.`]}),confirmLabel:`Remove`,destructive:!0,onConfirm:ae,onCancel:()=>N(!1)})]}),K.data?.usage&&(0,Q.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[K.data.usage.sent_today,` /`,` `,K.data.usage.daily_limit,` sent today ·`,` `,K.data.usage.received_today,` received`]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[se,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Domain`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:[W.subdomain,`.`,n]}),(0,Q.jsx)(qt,{status:q.data?.status,message:q.data?.message,isLoading:q.isLoading}),(0,Q.jsx)(s,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(O,{}),onClick:()=>j(!0),disabled:ne.isPending,"aria-label":`Release domain`})]}),(0,Q.jsx)(R,{open:k,title:`Release Domain`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to release `,(0,Q.jsxs)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:[W.subdomain,`.`,n]}),`? The subdomain will become available for others to claim.`]}),confirmLabel:`Release`,destructive:!0,onConfirm:oe,onCancel:()=>j(!1)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Email address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex h-9 min-w-0 flex-1 items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${S?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[(0,Q.jsx)(`input`,{value:b,onChange:e=>{x(e.target.value.toLowerCase()),S&&C(null)},placeholder:`hi`,"aria-label":`Email username`,"aria-invalid":!!S,className:`h-full min-w-0 flex-1 bg-transparent pl-3 pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`}),(0,Q.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`@`,ee]})]}),(0,Q.jsx)(s,{onClick:ie,disabled:J.isPending||!b.trim(),children:J.isPending?`Creating…`:`Create`})]}),S&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:S})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[se,(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Subdomain`}),(0,Q.jsx)(Tn,{subdomain:m,onSubdomainChange:e=>{h(e),v&&y(null)},domainSuffix:n,subdomainPlaceholder:`my-assistant`,error:v}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Each assistant gets its own subdomain. Lowercase letters, numbers, and hyphens only.`}),(0,Q.jsx)(s,{onClick:()=>D(!0),disabled:te.isPending||!m.trim(),children:te.isPending?`Registering…`:`Register`}),(0,Q.jsx)(R,{open:w,title:`Set Subdomain`,message:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:m.trim().toLowerCase()||`subdomain`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),confirmLabel:`Confirm`,onConfirm:re,onCancel:()=>D(!1)})]})}function Dn(){let e=Rt(),t=vt(),{data:o}=d({...jt(),enabled:t}),s=o?.results?.[0]?.handle,c=Vt.use.emailRootDomain(),l=_t(),[u,f]=(0,Z.useState)(()=>l===`gated`?`your-own`:le(r(Ae,`managed`),`managed`)),[p,m]=(0,Z.useState)(()=>{let e=r(pe,`resend`);return e===`mailgun`||e===`resend`?e:`resend`}),{platformAssistantId:h,error:g}=Bt(e,l===`full`&&u===`managed`),_=h??(g?e:null),v=d({queryKey:[`byoEmailCredential`,e,p],queryFn:async()=>{let{data:t}=await Ze({path:{assistant_id:e},body:{service:p,field:`api_key`},throwOnError:!0});return t},enabled:u===`your-own`||l===`gated`,staleTime:6e4,retry:i,meta:{errorContext:`byo_email_credential_check`}});(0,Z.useEffect)(()=>{v.error&&a(v.error,{context:`byo_email_credential_check`,bestEffort:!0})},[v.error]);let y=v.data?.hasSecret===!0,x=(0,Z.useCallback)(e=>{f(e),n(Ae,e)},[]),w=(0,Z.useCallback)(()=>{n(pe,p),L.success(`Email settings saved.`)},[p]),E=(0,Z.useMemo)(()=>be.find(e=>e.id===p)??be[0],[p]),D=(0,Q.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,Q.jsx)(C,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{children:[`Configure `,E.displayName,` via the assistant CLI: ask the assistant to run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:E.setupSkill}),` `,`skill. It walks you through storing the API key, detecting the domain, and (optionally) wiring up an inbound webhook.`]}),(0,Q.jsxs)(`a`,{href:E.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,E.displayName,(0,Q.jsx)(S,{className:`h-3 w-3`})]})]})]}),O=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{value:p,onChange:e=>{(e===`mailgun`||e===`resend`)&&m(e)},options:be.map(e=>({value:e.id,label:e.displayName}))})]}),y?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--system-positive-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-default)]`,children:[(0,Q.jsx)(b,{className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`span`,{children:[E.displayName,` API key configured. To reconfigure, run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:E.setupSkill}),` `,`skill.`]})]}),(0,Q.jsxs)(`a`,{href:E.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-body-small-default text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,E.displayName,(0,Q.jsx)(S,{className:`h-3 w-3`})]})]}):D,(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)(Jt,{onClick:w,disabled:!1})})]});return l===`gated`?(0,Q.jsx)(Gt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,children:O}):(0,Q.jsx)(Wt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,mode:u,onModeChange:x,children:u===`managed`?(0,Q.jsx)(`div`,{className:`space-y-4`,children:l===`disabled`?(0,Q.jsx)(Lt,{children:`Log in to the Vellum platform to manage email settings.`}):_===null?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin`}),`Connecting to the Vellum platform…`]}):(0,Q.jsx)(En,{assistantId:_,assistantHandle:s,emailRootDomain:c})}):O})}var On=`0.11.0`;function kn(){return mt(On)}var An=`gemini-3.1-flash-image-preview`;function jn(){let e=Rt(),t=u(),i=vt(),{data:o}=d({...it({path:{assistant_id:e}}),enabled:i,staleTime:3e4}),s=$e({onSuccess:n=>{ut(t,{path:{assistant_id:e}},n)}}),c=yn(),[l,f]=$((0,Z.useMemo)(()=>{if(!o)return r(he,`gemini`);let e=o.services?.[`image-generation`];return e?.mode===`managed`?`vellum`:e?.provider||r(`vellum:ai:imageGenProvider`,`gemini`)},[o])),[p,m]=(0,Z.useState)(()=>r(Ie,An)),h=H(l),g=h.includes(p)?p:h[0]??An,[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(!1),x=Ve.map(e=>({value:e,label:We[e]??e})),S=(0,Z.useMemo)(()=>H(l).map(e=>({value:e,label:fe[e]??e})),[l]),C=l===`gemini`||l===`openai`,{hasStoredCredential:w}=V({assistantId:e,credentialKind:`api_key`,credentialName:l,enabled:C}),E=f,D=(0,Z.useCallback)(async()=>{b(!0);let r=_.trim(),i=C&&r.length>0;try{i&&await c(He(g),r),await ft();let n=l===`vellum`&&!kn()?{mode:`managed`}:{provider:l,mode:l===`vellum`?`managed`:`your-own`};await s.mutateAsync({path:{assistant_id:e},body:{services:{"image-generation":n}}}).catch(e=>{throw L.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e});try{await Qe({path:{assistant_id:e},body:{modelId:g},throwOnError:!0})}catch(e){throw L.error(`Failed to update image generation model. Please try again.`),a(e,{context:`set_image_gen_model`}),e}finally{t.invalidateQueries({queryKey:st({path:{assistant_id:e}})})}}catch{b(!1);return}b(!1);try{if(n(he,l),n(Ie,g),i){let n=Ge(e,`api_key`,l);t.setQueryData(n,!0),t.invalidateQueries({queryKey:n}),v(``)}L.success(`Image generation settings saved.`)}catch(e){a(e,{context:`settings-ai-image-gen-persist-local`}),L.error(`Saved, but local preferences could not be written.`)}},[_,l,C,g,e,s,c,t]),O=(0,Z.useCallback)(()=>{v(``),m(An),n(Ie,An)},[]);return(0,Q.jsx)(Gt,{title:`Image Generation`,subtitle:`Configure which model your assistant uses to generate images`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{"aria-label":`Image generation provider`,value:l,onChange:E,options:x})]}),l===`vellum`&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Image generation runs through your Vellum account.`}),C&&(0,Q.jsx)(P,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:Y(l===`openai`?`Enter your OpenAI API key`:`Enter your Gemini API key`,w),fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsx)(z,{"aria-label":`Image generation model`,value:g,onChange:m,options:S})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Jt,{onClick:D,disabled:y}),y&&(0,Q.jsx)(T,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),C&&(0,Q.jsx)(Yt,{onClick:O})]})]})})}async function Mn(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 Nn(n,r,i):t===`deepgram`?await Pn(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 Nn(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 Fn(i,`ElevenLabs rejected the request.`)}}async function Pn(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 Fn(n,`Deepgram rejected the request.`)}}async function Fn(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 In({assistantId:e,value:t,onChange:n,className:r}){let[i,a]=(0,Z.useState)(!1),{voices:o}=Nt(e);if(o.length===0)return null;let s=o.find(e=>e.model===t)??o[0];return(0,Q.jsxs)(N.Root,{open:i,onOpenChange:a,children:[(0,Q.jsx)(N.Trigger,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Voice`,className:m(`flex h-9 w-full items-center gap-2 rounded-md border border-[var(--field-border)] bg-[var(--field-bg)] px-3 text-left text-body-medium-lighter text-[var(--content-default)] transition-colors focus:outline-none data-[state=open]:border-[var(--border-active)]`,r),children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:s?Pt(s.description):`Select a voice`}),(0,Q.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0})]})}),(0,Q.jsx)(N.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,Q.jsx)(Ft,{assistantId:e,value:t,onChange:n,onSelect:()=>a(!1),showSource:!0})})]})}var Ln={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function Rn({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=Rt(),c=e??o,l=dt.use.name()??`your assistant`,f=vt(),p=u(),{data:m}=d({...et({path:{assistant_id:c}}),enabled:f,staleTime:1/0}),h=(0,Z.useMemo)(()=>{let e=m?.providers;if(!e)return ie;if(e.some(e=>e.id===`vellum`))return e;let t=ie.find(e=>e.id===`vellum`);return t?[t,...e]:e},[m]),{data:g}=d({...it({path:{assistant_id:c}}),enabled:f,staleTime:3e4}),_=g?.services?.tts,v=_?.mode===`managed`?`vellum`:_?.provider,y=`elevenlabs`,b=(0,Z.useMemo)(()=>v??r(`vellum:voice:ttsProvider`,y),[v,y]),x=!!v,[S,C]=$(b),[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)(``),[k,A]=(0,Z.useState)(``),[j,M]=(0,Z.useState)(!1),[N,F]=(0,Z.useState)(!1),[I,R]=(0,Z.useState)(!1),{voices:B,defaultModel:V,fetched:H}=It(c,{enabled:S===`vellum`}),U=_?.providers?.vellum?.model??V??``,[W,G]=$(U),ee=B.find(e=>e.model===W)??B[0],[K,q]=(0,Z.useState)(null),te=B.some(e=>e.model===U),ne=K??(H&&U!==``&&!te),J=(0,Z.useMemo)(()=>h.find(e=>e.id===S)??h[0],[S,h]),Y=S===`vellum`&&J.supportsVoiceSelection&&W.trim()!==``&&W.trim()!==U,X=(0,Z.useCallback)(e=>{let t=r(_e+e,``),n=r(Me+e,``);M(t.length>0),O(n),A(n),E(``)},[]);(0,Z.useEffect)(()=>{X(S)},[S,X]);let re=(0,Z.useMemo)(()=>{let e=S!==b,t=T.trim().length>0,n=D.trim()!==k;return e||t||n||Y},[S,b,T,D,k,Y]),ae=(0,Z.useCallback)(async()=>{let e=T.trim(),t=D.trim(),i=J.id;n(ye,i),e.length>0&&n(_e+i,e),n(Me+i,t);let a=e.length>0?e:r(_e+i,``),o=Ln[i];R(!0);try{if(a.length>0){let{response:e}=await Ye({path:{assistant_id:c},body:{service:i,field:`api_key`,value:a,label:`${J.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...S!==b||!x?{provider:i,mode:i===`vellum`?`managed`:`your-own`}:{},...o?{providers:{[i]:{[o]:t}}}:{},...Y?{providers:{vellum:{model:W.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await Xe({path:{assistant_id:c},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return M(a.length>0),A(t),E(``),p.invalidateQueries({queryKey:st({path:{assistant_id:c}})}),L.success(`Text-to-speech settings saved`),!0}catch(e){return L.error(e instanceof Error?e.message:`Failed to save text-to-speech settings`),!1}finally{R(!1)}},[c,S,W,Y,T,D,J,b,x,p]);(0,Z.useEffect)(()=>{a?.({hasChanges:re,saving:I,save:ae})},[a,re,I,ae]);let oe=(0,Z.useCallback)(()=>{n(_e+S,``),M(!1),E(``)},[S]),se=(0,Z.useCallback)(async()=>{F(!0);try{let e=r(_e+S,``),t=T.trim(),n=t.length>0?t:e;if(n.length===0){L.error(`Save an API key for this provider before testing.`);return}let i=r(Me+S,``),a=D.trim(),o=await Mn({provider:S,apiKey:n,voiceId:a.length>0?a:i,text:`Hey! It's ${l}. How does this sound?`});if(o.kind!==`audio`){L.error(o.message);return}let s=URL.createObjectURL(o.blob);try{let e=new Audio(s);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(s)}}finally{F(!1)}},[l,T,S,D]),ce=j?`•••••••• (Enter a new key to replace)`:J.apiKeyPlaceholder,le=S===`vellum`,ue=le&&J.supportsVoiceSelection,de=(0,Q.jsxs)(s,{variant:`link`,size:`compact`,className:`inline-flex h-auto items-center gap-1 px-0 underline [--vbtn-fg:var(--content-tertiary)]`,onClick:()=>{q(!1),B.some(e=>e.model===W)||G(V||B[0]?.model||``)},children:[(0,Q.jsx)(w,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Choose from catalog`]}),fe=ue&&ne&&B.length>0?de:null;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{value:S,onChange:C,options:h.map(e=>({value:e.id,label:e.displayName})),"aria-label":`TTS provider`})]}),!le&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(P,{type:`password`,value:T,onChange:e=>E(e.target.value),placeholder:ce,fullWidth:!0})]}),ue&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice`}),ne?(0,Q.jsx)(P,{type:`text`,value:W,onChange:e=>G(e.target.value),placeholder:`Enter a voice ID`,"aria-label":`Custom voice ID`,fullWidth:!0}):ee?(0,Q.jsx)(In,{assistantId:c,value:W,onChange:G}):H&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`No managed voices are currently available.`})]}),J.supportsVoiceSelection&&!le&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice ID`}),(0,Q.jsx)(P,{type:`text`,value:D,onChange:e=>O(e.target.value),placeholder:`Enter a voice ID`,fullWidth:!0})]}),!i&&!le&&(0,Q.jsx)(Xt,{guide:J.credentialsGuide}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!le&&(0,Q.jsx)(s,{variant:`outlined`,onClick:se,disabled:N,children:N?`Testing…`:`Test`}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[fe,!t&&(0,Q.jsx)(Jt,{onClick:ae,disabled:!re||I}),j&&!le&&(0,Q.jsx)(Yt,{onClick:oe})]})]})]})}function zn(){return(0,Q.jsx)(Gt,{id:`text-to-speech`,title:`Text-to-Speech`,subtitle:`Configure how your assistant speaks`,children:(0,Q.jsx)(Rn,{})})}var Bn={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},Vn={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},Hn=`deepgram`;function Un({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=Rt(),s=e??o,c=vt(),l=u(),[f]=(0,Z.useState)(()=>Ue.filter(e=>!e.requiresNativeDictation||ae())),p=Hn,{data:m}=d({...it({path:{assistant_id:s}}),enabled:c,staleTime:3e4}),h=m?.services?.stt,g=h?.mode===`managed`?`vellum`:h?.provider,_=(0,Z.useMemo)(()=>{let e=g?Vn[g]:void 0;if(e&&f.some(t=>t.id===e))return e;let t=r(Be,p);return f.some(e=>e.id===t)?t:p},[g,f,p]),v=!!g,[y,b]=$(_),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let e=r(Be,p);e===`macos-native`&&!f.some(t=>t.id===e)&&n(Be,p)},[f,p]);let D=(0,Z.useMemo)(()=>f.find(e=>e.id===y)??f[0],[f,y]),O=D.apiKeyPlaceholder!==void 0;(0,Z.useEffect)(()=>{w(r(Te+y,``).length>0),S(``)},[y]);let A=(0,Z.useMemo)(()=>{let e=y!==_,t=x.trim().length>0;return e||t},[y,_,x]),j=(0,Z.useCallback)(async()=>{let e=x.trim();n(Be,y),e.length>0&&n(Te+y,e);let t=Bn[y];E(!0);try{if(t?.credentialService){let n=e.length>0?e:r(Te+y,``);if(n.length>0){let{response:e}=await Ye({path:{assistant_id:s},body:{service:t.credentialService,field:`api_key`,value:n,label:`${D.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(t&&(y!==_||!v)||g===`vellum`&&y!==`vellum`){let e=t?.provider??Hn,{response:n}=await Xe({path:{assistant_id:s},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&&w(!0),S(``),l.invalidateQueries({queryKey:st({path:{assistant_id:s}})}),L.success(`Speech-to-text settings saved`),!0}catch(e){return L.error(e instanceof Error?e.message:`Failed to save speech-to-text settings`),!1}finally{E(!1)}},[s,y,x,D,_,v,g,l]);(0,Z.useEffect)(()=>{a?.({hasChanges:A,saving:T,save:j})},[a,A,T,j]);let M=(0,Z.useCallback)(()=>{n(Te+y,``),w(!1),S(``)},[y]),N=C?`•••••••• (Enter a new key to replace)`:D.apiKeyPlaceholder;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(z,{value:y,onChange:b,options:f.map(e=>({value:e.id,label:e.displayName})),"aria-label":`STT provider`})]}),O&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(P,{type:`password`,value:x,onChange:e=>S(e.target.value),placeholder:N,fullWidth:!0})]}),D.setupWarning&&(0,Q.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,Q.jsx)(k,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,Q.jsx)(`span`,{children:D.setupWarning})]}),!i&&D.credentialsGuide&&(0,Q.jsx)(Xt,{guide:D.credentialsGuide}),y===`vellum`&&(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Transcription runs through your Vellum account.`}),(!t||C)&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[!t&&(0,Q.jsx)(Jt,{onClick:j,disabled:!A||T}),C&&(0,Q.jsx)(Yt,{onClick:M})]})]})}function Wn(){return(0,Q.jsx)(Gt,{title:`Speech-to-Text`,subtitle:`Configure how your assistant transcribes speech`,children:(0,Q.jsx)(Un,{})})}function Gn(){return(0,Z.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]),(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsx)(Kt,{}),(0,Q.jsx)(vn,{}),(0,Q.jsx)(Sn,{}),(0,Q.jsx)(wn,{}),(0,Q.jsx)(Dn,{}),(0,Q.jsx)(jn,{}),(0,Q.jsx)(zn,{}),(0,Q.jsx)(Wn,{})]})}export{Gn as AiPage};