@vellumai/web 0.11.3-staging.2 → 0.11.3-staging.4

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 (142) hide show
  1. package/dist/assets/{access-DWtJQvRI.js → access-RDaLlBt5.js} +1 -1
  2. package/dist/assets/{account-page-D03pCcnz.js → account-page-JyXn859b.js} +1 -1
  3. package/dist/assets/{account-shell-DmVQwtZ0.js → account-shell-DuR-x14B.js} +1 -1
  4. package/dist/assets/{acp-run-detail-panel-COs66Yrd.js → acp-run-detail-panel-BsGRKgJi.js} +1 -1
  5. package/dist/assets/{activity-steps-panel-CLjBxqNs.js → activity-steps-panel-DGS78a-e.js} +1 -1
  6. package/dist/assets/{ai-page-D4GbPprS.js → ai-page-84Y9c_q2.js} +1 -1
  7. package/dist/assets/{app-card-B7C46-7O.js → app-card-Df-Gy7pD.js} +1 -1
  8. package/dist/assets/{assistant-status-panel-CDUAp33H.js → assistant-status-panel-C92c678g.js} +1 -1
  9. package/dist/assets/{auth-store-DkOiOQNx.js → auth-store-BJdkkmzu.js} +1 -1
  10. package/dist/assets/{background-task-detail-panel-xFGqYCUz.js → background-task-detail-panel-Dq1DgR5i.js} +1 -1
  11. package/dist/assets/billing-page-CAFoZYGH.js +3 -0
  12. package/dist/assets/{bookmarks-page-DqXq2CVJ.js → bookmarks-page-EeUOpkIO.js} +1 -1
  13. package/dist/assets/{build-state-B0f3Jn2o.js → build-state-DJaFMxtL.js} +1 -1
  14. package/dist/assets/{channels-page-route-CbV05RLi.js → channels-page-route-DS9XLjMy.js} +1 -1
  15. package/dist/assets/chat-markdown-message-C6oOqDdl.js +1 -0
  16. package/dist/assets/{checkout-page-BxYwG3J8.js → checkout-page-BqIlZAum.js} +1 -1
  17. package/dist/assets/{command-palette-DSxHNf_m.js → command-palette-D6aRon6x.js} +1 -1
  18. package/dist/assets/{command-palette-window-page-9lbssBKp.js → command-palette-window-page-B1jt_AiM.js} +1 -1
  19. package/dist/assets/{composer-settings-MHDtr31Y.js → composer-settings-Du4kV9LG.js} +1 -1
  20. package/dist/assets/{contacts-page-route-BE3oNfhk.js → contacts-page-route-B4eanbVf.js} +1 -1
  21. package/dist/assets/{conversation-navigation-DbQqV_fs.js → conversation-navigation-gR_RLe1J.js} +1 -1
  22. package/dist/assets/{conversation-queries-CMEwcap1.js → conversation-queries-Bx_JApUN.js} +1 -1
  23. package/dist/assets/{credentials-page-DKfIMfUB.js → credentials-page-BLMs_5u_.js} +1 -1
  24. package/dist/assets/{csv-preview-DB8q0b_y.js → csv-preview-B0xuZwnc.js} +1 -1
  25. package/dist/assets/{debug-page-DpWI-aFX.js → debug-page-7plKE23B.js} +2 -2
  26. package/dist/assets/{deploy-dialogs-BhY-urVH.js → deploy-dialogs-Bjz3OS-8.js} +1 -1
  27. package/dist/assets/{deploy-store-OFWDAEgC.js → deploy-store-BGcHwvB5.js} +1 -1
  28. package/dist/assets/{detail-card-Dsnf52vg.js → detail-card-hWrhardR.js} +1 -1
  29. package/dist/assets/{detail-drawer-AKY7keIJ.js → detail-drawer-s-zfqqMy.js} +1 -1
  30. package/dist/assets/{detail-panel-stop-button-Cvnn4hYA.js → detail-panel-stop-button-CC6QoK-R.js} +1 -1
  31. package/dist/assets/{detail-shell-g6Pw4jiP.js → detail-shell-PCaxY4Tf.js} +1 -1
  32. package/dist/assets/{developer-page-CSFTdMiT.js → developer-page-CV5m0xk-.js} +1 -1
  33. package/dist/assets/{document-viewer-container-Bousf9D9.js → document-viewer-container-wjJ6ACJv.js} +2 -2
  34. package/dist/assets/{document-viewer-page-CJuMnNZk.js → document-viewer-page-C8YfZSmS.js} +1 -1
  35. package/dist/assets/{emails-page-CMoX6WSY.js → emails-page-BqvrSqnK.js} +1 -1
  36. package/dist/assets/{file-editor-BwWJX7zO.js → file-editor-DOnVeKOG.js} +1 -1
  37. package/dist/assets/file-markdown-CGC6ZrPT.js +2 -0
  38. package/dist/assets/{first-run-scope-jh9sT0_v.js → first-run-scope-DKd0ZevK.js} +1 -1
  39. package/dist/assets/{general-page-Biad-auh.js → general-page-C7kX0xLP.js} +1 -1
  40. package/dist/assets/{hatching-screen-DtMbgBm6.js → hatching-screen-Dws0nCOf.js} +1 -1
  41. package/dist/assets/{home-page-route-k81d1Zsb.js → home-page-route-Qs5WbFPD.js} +1 -1
  42. package/dist/assets/home-tool-permission-card-Do3YeiVC.js +1 -0
  43. package/dist/assets/{hosting-screen-C-6MdEhq.js → hosting-screen-BJB_azfa.js} +1 -1
  44. package/dist/assets/{identity-page-route-BEobbSBV.js → identity-page-route-uZNXQbMq.js} +1 -1
  45. package/dist/assets/{index-BI5VpYa-.js → index-DRExgbkb.js} +1 -1
  46. package/dist/assets/index-Q1K0w5kB.css +2 -0
  47. package/dist/assets/{inspect-page-BSPJgPij.js → inspect-page-C1dITgHA.js} +1 -1
  48. package/dist/assets/{integrations-page-DNYDhZHQ.js → integrations-page-D4EH9FG0.js} +1 -1
  49. package/dist/assets/{intelligence-layout-CDcBeu8K.js → intelligence-layout-ByKfD_gm.js} +1 -1
  50. package/dist/assets/{library-detail-page-D5EeSRdZ.js → library-detail-page-BciW_57s.js} +1 -1
  51. package/dist/assets/{library-page-wPVeE7u1.js → library-page-CMO0VZux.js} +1 -1
  52. package/dist/assets/{local-runtime-upgrade-DyHUCz7A.js → local-runtime-upgrade-CXKbgZ4c.js} +1 -1
  53. package/dist/assets/{login-flow-B8CUFAeg.js → login-flow-CN5J4YsY.js} +1 -1
  54. package/dist/assets/{login-page-BgXMUzWB.js → login-page-5jtwkaF1.js} +1 -1
  55. package/dist/assets/{logout-page-COe8dRLu.js → logout-page-Bz0x8UvE.js} +1 -1
  56. package/dist/assets/{logs-layout-BGd_aSZ_.js → logs-layout-B_GC1zBM.js} +1 -1
  57. package/dist/assets/{memory-page-route-BGEmbUCl.js → memory-page-route-BtL6zJZb.js} +1 -1
  58. package/dist/assets/{memory-router-playground-page-B4DX4CON.js → memory-router-playground-page-e4uW8QiT.js} +1 -1
  59. package/dist/assets/{message-files-panel-DTDXhD0C.js → message-files-panel-DxmbSrm8.js} +1 -1
  60. package/dist/assets/{messages-D2OJUCHs.js → messages-DSdy6Lfi.js} +1 -1
  61. package/dist/assets/{metric-card-DgbUgyv7.js → metric-card-BSJPacNm.js} +1 -1
  62. package/dist/assets/{mobile-sidebar-drawer-CRXVtqcP.js → mobile-sidebar-drawer-BGHwfePU.js} +1 -1
  63. package/dist/assets/{multi-activity-group-Chyfm08f.js → multi-activity-group-D_OVaru-.js} +1 -1
  64. package/dist/assets/{open-workspace-file-C4HWMBzn.js → open-workspace-file-DViQQLp4.js} +2 -2
  65. package/dist/assets/{page-shell-CkfnwmIw.js → page-shell-Tpt9AIL2.js} +1 -1
  66. package/dist/assets/{personality-page-CEbJMhDR.js → personality-page-avdvL3Dx.js} +1 -1
  67. package/dist/assets/{plans-page-DXCrcLo8.js → plans-page-CdNdqHks.js} +1 -1
  68. package/dist/assets/{platform-login-notice-CIpebDVw.js → platform-login-notice-BEDBlins.js} +1 -1
  69. package/dist/assets/{platform-loopback-page-BJf6yE-E.js → platform-loopback-page-DcHVugCF.js} +1 -1
  70. package/dist/assets/{preview-error-CihmwI1t.js → preview-error-CVMngD78.js} +1 -1
  71. package/dist/assets/{privacy-page-CxAYEG0r.js → privacy-page-CfJXPReU.js} +1 -1
  72. package/dist/assets/{privacy-screen-DAzWoGQI.js → privacy-screen-4GElE18b.js} +1 -1
  73. package/dist/assets/{provider-callback-page--oWycq5i.js → provider-callback-page-rNJpxKm4.js} +1 -1
  74. package/dist/assets/{provider-signup-page-BaGT8Jl4.js → provider-signup-page-BG-fVW-J.js} +1 -1
  75. package/dist/assets/{remove-from-device-dialog-C0eaWxwl.js → remove-from-device-dialog-BGqwuQw9.js} +1 -1
  76. package/dist/assets/{research-onboarding-route-CXimVFK6.js → research-onboarding-route-s_8BLTOQ.js} +1 -1
  77. package/dist/assets/{retire-confirm-dialog-B1bvTlHS.js → retire-confirm-dialog-Bm7A3sZF.js} +1 -1
  78. package/dist/assets/{review-terms-screen-BxxGJL-B.js → review-terms-screen-CpWYZlRr.js} +1 -1
  79. package/dist/assets/routes-DE2XWIds.js +23 -0
  80. package/dist/assets/{runtime-upgrade-banner--bSmfygH.js → runtime-upgrade-banner-DtzsX2m0.js} +1 -1
  81. package/dist/assets/{sandbox-bridge-BlniBIsp.js → sandbox-bridge-WZhWtkZd.js} +1 -1
  82. package/dist/assets/{schedules-page-DCUj-YbP.js → schedules-page-Cfala7Km.js} +1 -1
  83. package/dist/assets/{select-assistant-screen-C5Cl_pCp.js → select-assistant-screen-BqObBI5Z.js} +1 -1
  84. package/dist/assets/{settings-divider-BuDc875f.js → settings-divider-Dyvf7Uk6.js} +1 -1
  85. package/dist/assets/{settings-layout-Clnlm1aB.js → settings-layout-DfPO11SQ.js} +1 -1
  86. package/dist/assets/{settings-navigation-Cn3KCxOe.js → settings-navigation-C1wEuU56.js} +1 -1
  87. package/dist/assets/{share-feedback-modal-COUhsUqF.js → share-feedback-modal-Ctgazbnj.js} +1 -1
  88. package/dist/assets/{sidebar-tree-BXbcoj07.js → sidebar-tree-VXRWtsy4.js} +1 -1
  89. package/dist/assets/{signup-page-C9ZrCSVo.js → signup-page-CLf-r4oP.js} +1 -1
  90. package/dist/assets/{site-favicon-B3DMFtr3.js → site-favicon-DfuXzZcN.js} +1 -1
  91. package/dist/assets/{skill-detail-page-Ckw6_1PG.js → skill-detail-page-ChpWru-e.js} +2 -2
  92. package/dist/assets/{skill-detail-panel-DdYbYHuj.js → skill-detail-panel-DU0bdJUl.js} +1 -1
  93. package/dist/assets/{skills-Lf85mR9L.js → skills-B4bfakyU.js} +1 -1
  94. package/dist/assets/{src-hNk11eS3.js → src-DyqTPMO2.js} +1 -1
  95. package/dist/assets/{stt-language-picker-modal-B5MO-3gk.js → stt-language-picker-modal-BiWHaqFq.js} +1 -1
  96. package/dist/assets/{subagent-detail-panel-BKhU7VAv.js → subagent-detail-panel-Gi0UOlsn.js} +1 -1
  97. package/dist/assets/superpowers-page-nHT_hb33.js +1 -0
  98. package/dist/assets/{system-events-page-DbcoH4sh.js → system-events-page-Bfpn0HzE.js} +1 -1
  99. package/dist/assets/{telegram-setup-wizard-C4E0wi1B.js → telegram-setup-wizard-GetgaQy5.js} +1 -1
  100. package/dist/assets/{text-preview-KOyX3OrO.js → text-preview-CEL0P-WV.js} +1 -1
  101. package/dist/assets/{theme-stage-page-D4DYc_C8.js → theme-stage-page-CEBFiy-u.js} +1 -1
  102. package/dist/assets/{tiptap-document-editor-CDIJTTa_.js → tiptap-document-editor-DPkcv0pe.js} +1 -1
  103. package/dist/assets/{tool-detail-panel-CmbBw4_n.js → tool-detail-panel-84bl2nI3.js} +1 -1
  104. package/dist/assets/{upgrade-cancel-page-DfjtkvP9.js → upgrade-cancel-page-DNteIqqS.js} +1 -1
  105. package/dist/assets/{upgrade-success-page-BDWg5oK4.js → upgrade-success-page-CAeO4QtE.js} +1 -1
  106. package/dist/assets/{use-assistant-identity-details-BAgi4MHa.js → use-assistant-identity-details-DqiKjphK.js} +1 -1
  107. package/dist/assets/{use-attachment-preview-CB3GsEns.js → use-attachment-preview-B4PALbqs.js} +1 -1
  108. package/dist/assets/{use-attachment-squares-DPuVHGRC.js → use-attachment-squares-C-9Rz-8O.js} +1 -1
  109. package/dist/assets/{use-bookmarks-C6IlHWIK.js → use-bookmarks-BWGVUg59.js} +1 -1
  110. package/dist/assets/{use-checkout-dismiss-refresh-CDwSKr1-.js → use-checkout-dismiss-refresh-BGeYbYii.js} +1 -1
  111. package/dist/assets/{use-command-palette-sections-DXzS2Tio.js → use-command-palette-sections-D3aj-BzX.js} +1 -1
  112. package/dist/assets/{use-edge-swipe-back-ZgANxgKE.js → use-edge-swipe-back-BGq52vVr.js} +2 -2
  113. package/dist/assets/{use-edit-app-BHUYCv4X.js → use-edit-app-u-kyfEFX.js} +1 -1
  114. package/dist/assets/{use-invite-link-dialog-CdY5FNQa.js → use-invite-link-dialog-Ccf_XNV3.js} +1 -1
  115. package/dist/assets/{use-is-org-ready-BmOdacs1.js → use-is-org-ready-CQntk0MX.js} +1 -1
  116. package/dist/assets/{use-onboarding-login-BUaNGE_u.js → use-onboarding-login-Cw_9Ydsv.js} +1 -1
  117. package/dist/assets/{use-platform-assistant-id-CEMyKEvV.js → use-platform-assistant-id-DMP9urFb.js} +1 -1
  118. package/dist/assets/{use-platform-gate-CdwOyQ8A.js → use-platform-gate-2lhRAyKS.js} +1 -1
  119. package/dist/assets/{use-return-to-short-circuit-CTYRB2Ne.js → use-return-to-short-circuit-Dm5PWev2.js} +1 -1
  120. package/dist/assets/{use-skill-actions-GbdM3IIw.js → use-skill-actions-BopRxJ9x.js} +1 -1
  121. package/dist/assets/{use-sticky-profiles-LVe9u5gh.js → use-sticky-profiles-5cPu_MUo.js} +1 -1
  122. package/dist/assets/{use-subagent-card-data-CFKl88ab.js → use-subagent-card-data-VnA5x24X.js} +1 -1
  123. package/dist/assets/use-transcript-message-by-id-DCOlEJjY.js +1 -0
  124. package/dist/assets/{use-transcript-messages-vw2Hogaj.js → use-transcript-messages-BEpY7uG4.js} +1 -1
  125. package/dist/assets/{use-voice-sample-preview-BjIqIVEG.js → use-voice-sample-preview-CzqJYPiZ.js} +1 -1
  126. package/dist/assets/{viewer-store-DhrkeZmJ.js → viewer-store-CayI6XWh.js} +1 -1
  127. package/dist/assets/{voice-list-DnqRx15F.js → voice-list-BS2BNjKN.js} +1 -1
  128. package/dist/assets/{voice-page-CrrYAE9k.js → voice-page-B7t0g-1X.js} +1 -1
  129. package/dist/assets/{voice-providers-note-ValSs0nz.js → voice-providers-note-Cv7vCsDI.js} +1 -1
  130. package/dist/assets/{welcome-screen-CiBqE53u.js → welcome-screen-eqR0DNzE.js} +1 -1
  131. package/dist/assets/{workflow-detail-panel-crM7HRfK.js → workflow-detail-panel-Dlj8i7AM.js} +1 -1
  132. package/dist/assets/{workspace-page-iAsgehav.js → workspace-page-CAbshSeb.js} +1 -1
  133. package/dist/index.html +46 -46
  134. package/package.json +1 -1
  135. package/dist/assets/billing-page-n2hU_EAj.js +0 -3
  136. package/dist/assets/chat-markdown-message-WfT4JUja.js +0 -1
  137. package/dist/assets/file-markdown-CZPyyZhu.js +0 -2
  138. package/dist/assets/home-tool-permission-card-Bytpm6bE.js +0 -1
  139. package/dist/assets/index-_S2T-6in.css +0 -2
  140. package/dist/assets/routes-ZeXUrnzY.js +0 -23
  141. package/dist/assets/superpowers-page-gPiU1fsq.js +0 -1
  142. package/dist/assets/use-transcript-message-by-id-cDbEJMB-.js +0 -1
@@ -1 +1 @@
1
- import{n as e}from"./auth-store-DkOiOQNx.js";import{t}from"./assistant-feature-flag-store-qYfAdlBG.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
+ import{n as e}from"./auth-store-BJdkkmzu.js";import{t}from"./assistant-feature-flag-store-qYfAdlBG.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-BUqIilZr.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{a as i,n as a,s as o}from"./auth-store-DkOiOQNx.js";import{E as s}from"./platform-detection-C_TK32Dw.js";import{d as c}from"./routes-iipg2wkc.js";import{t as l}from"./hard-navigate-BrsAH6PB.js";import{n as u,t as d}from"./login-flow-B8CUFAeg.js";import{r as f,t as p}from"./account-shell-DmVQwtZ0.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-BUqIilZr.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{a as i,n as a,s as o}from"./auth-store-BJdkkmzu.js";import{E as s}from"./platform-detection-C_TK32Dw.js";import{d as c}from"./routes-iipg2wkc.js";import{t as l}from"./hard-navigate-BrsAH6PB.js";import{n as u,t as d}from"./login-flow-CN5J4YsY.js";import{r as f,t as p}from"./account-shell-DuR-x14B.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"./src-hNk11eS3.js";import{t}from"./notice-C0ifrvvJ.js";var n=e(),r=(0,n.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,n.jsx)(`path`,{d:`M7.5 15L12.5 10L7.5 5`,stroke:`currentColor`,strokeWidth:`1.67`,strokeLinecap:`round`,strokeLinejoin:`round`})});function i({onSubmit:e,error:i,children:a,submitLabel:o,submittingLabel:s,isSubmitting:c,footer:l}){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`form`,{onSubmit:e,className:`flex flex-col gap-4`,children:[i&&(0,n.jsx)(t,{tone:`error`,children:i}),(0,n.jsx)(`div`,{className:`flex flex-col gap-3`,children:a}),(0,n.jsxs)(`button`,{type:`submit`,disabled:c,className:`mt-2 inline-flex w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)] disabled:cursor-wait disabled:opacity-50`,children:[c?s:o,r]})]}),l&&(0,n.jsx)(`div`,{className:`mt-8 text-center`,children:l})]})}function a(e){return(0,n.jsx)(`input`,{...e,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] px-4 py-3 text-sm text-[var(--content-default)] outline-none placeholder:text-[var(--content-tertiary)] focus:border-[var(--primary-base)]/50`})}function o({title:e,subtitle:t}){return(0,n.jsxs)(`div`,{className:`mb-8 text-center`,children:[(0,n.jsx)(`h1`,{className:`mb-2 font-serif text-[2rem] font-bold italic text-[var(--content-default)]`,children:e}),t&&(0,n.jsx)(`p`,{className:`text-sm text-[var(--content-secondary)]`,children:t})]})}function s({children:e}){return(0,n.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[var(--surface-base)]`,children:(0,n.jsx)(`div`,{className:`w-full max-w-[480px] px-6`,children:(0,n.jsx)(`div`,{className:`flex flex-col items-center gap-10`,children:(0,n.jsx)(`div`,{className:`w-full`,children:e})})})})}export{a as i,i as n,o as r,s as t};
1
+ import{t as e}from"./jsx-runtime-D3ZM-ToX.js";import"./src-DyqTPMO2.js";import{t}from"./notice-C0ifrvvJ.js";var n=e(),r=(0,n.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,n.jsx)(`path`,{d:`M7.5 15L12.5 10L7.5 5`,stroke:`currentColor`,strokeWidth:`1.67`,strokeLinecap:`round`,strokeLinejoin:`round`})});function i({onSubmit:e,error:i,children:a,submitLabel:o,submittingLabel:s,isSubmitting:c,footer:l}){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`form`,{onSubmit:e,className:`flex flex-col gap-4`,children:[i&&(0,n.jsx)(t,{tone:`error`,children:i}),(0,n.jsx)(`div`,{className:`flex flex-col gap-3`,children:a}),(0,n.jsxs)(`button`,{type:`submit`,disabled:c,className:`mt-2 inline-flex w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)] disabled:cursor-wait disabled:opacity-50`,children:[c?s:o,r]})]}),l&&(0,n.jsx)(`div`,{className:`mt-8 text-center`,children:l})]})}function a(e){return(0,n.jsx)(`input`,{...e,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] px-4 py-3 text-sm text-[var(--content-default)] outline-none placeholder:text-[var(--content-tertiary)] focus:border-[var(--primary-base)]/50`})}function o({title:e,subtitle:t}){return(0,n.jsxs)(`div`,{className:`mb-8 text-center`,children:[(0,n.jsx)(`h1`,{className:`mb-2 font-serif text-[2rem] font-bold italic text-[var(--content-default)]`,children:e}),t&&(0,n.jsx)(`p`,{className:`text-sm text-[var(--content-secondary)]`,children:t})]})}function s({children:e}){return(0,n.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[var(--surface-base)]`,children:(0,n.jsx)(`div`,{className:`w-full max-w-[480px] px-6`,children:(0,n.jsx)(`div`,{className:`flex flex-col items-center gap-10`,children:(0,n.jsx)(`div`,{className:`w-full`,children:e})})})})}export{a as i,i as n,o as r,s as t};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-Cw5vs0Ef.js";import{t as n}from"./react-BFJW0bSv.js";import{t as r}from"./button-BENY-yx_.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./typography-BeUa5Fd-.js";import{t as o}from"./createLucideIcon-C1mdGPB9.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./acp-run-actions-BtRROeN9.js";import{t as p}from"./arrow-left-BikDV6F2.js";import{t as m}from"./brain-ZiC0HCCF.js";import{t as h}from"./chevron-down-CrFV6lfm.js";import{t as g}from"./chevron-right-DBGgpEiZ.js";import{t as _}from"./circle-check-q8BVdbgw.js";import{t as v}from"./circle-minus-Y3lFnfyL.js";import{w as y}from"./menu-DKE_-iVc.js";import{t as b}from"./code-DwZ6Mhdw.js";import"./src-hNk11eS3.js";import{t as x}from"./file-text-DDbRSMUn.js";import{t as S}from"./globe-COk-NH9x.js";import{t as C}from"./chat-markdown-message-WfT4JUja.js";import{t as ee}from"./repeat-BvvxRT2U.js";import{t as te}from"./search-D2xMZu1P.js";import{t as ne}from"./send-BlX2px_R.js";import{t as w}from"./square-CE8V_WXJ.js";import{t as T}from"./terminal-CkQ9DSF2.js";import{t as re}from"./trash-2-BKXSi5Tj.js";import{t as ie}from"./triangle-alert-CB4pJgCL.js";import{t as ae}from"./x-338EsJDP.js";import{t as oe}from"./tag-DeMzQvCo.js";import{a as E,i as se,n as D,r as O}from"./acp-run-store-DAOLku4B.js";import{t as k}from"./three-dot-indicator-BQxSg8G2.js";import{t as ce}from"./status-badge-pill---iRVZ8q.js";var le=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`}]]),A=e(n(),1),j=``;function M(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 ue(e){return(e.messageId?.startsWith(`local-marker-`)??!1)||(e.content?.startsWith(`↻ Steering: `)??!1)}function N(e){let t=e??``;return t.startsWith(`↻ Steering: `)?t.slice(D.length):t}function P(e){let t=e[e.length-1];t&&(t.kind===`agent`||t.kind===`thinking`)&&!t.isComplete&&(e[e.length-1]={...t,isComplete:!0})}function F(e,t){if(t.updateType===`agent_message_chunk`&&ue(t)){P(e),e.push({kind:`user`,id:t.messageId??`steer-${e.length}`,content:N(t.content)});return}switch(t.updateType){case`user_message_chunk`:{let n=t.messageId??j,r=N(t.content),i=e[e.length-1];i&&i.kind===`user`&&i.id===n?e[e.length-1]={...i,content:i.content+r}:(P(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??j,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!==j&&r&&r.kind===`agent`&&r.messageId===j&&!r.isComplete&&r.content===(t.content??``)){e[e.length-1]={...r,messageId:n};return}P(e),e.push({kind:`agent`,messageId:n,content:t.content??``,isComplete:!1});return}case`agent_thought_chunk`:{let n=t.messageId??j,r=e[e.length-1];if(r&&r.kind===`thinking`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}P(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;P(e),e.push({kind:`tool`,toolCallId:n,title:t.toolTitle??``,toolKind:t.toolKind,status:M(t.toolStatus,`running`),content:t.content,locations:I(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=I(t);e[r]={...i,title:t.toolTitle??i.title,toolKind:t.toolKind??i.toolKind,status:M(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=de(t.content);if(n===null)return;let r=e.findIndex(e=>e.kind===`plan`),i={kind:`plan`,entries:n};r===-1?(P(e),e.push(i)):e[r]=i;return}}}function I(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 de(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 fe(e){let t=[];for(let n of e)F(t,n);return t}function pe(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 me(){let e=null,t=[];function n(n){return t=fe(n),e=n,t}function r(r){let i=pe(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++)F(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,A.useRef)(null);return t.current??=me(),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-Cw5vs0Ef.js";import{t as n}from"./react-BFJW0bSv.js";import{t as r}from"./button-BENY-yx_.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./typography-BeUa5Fd-.js";import{t as o}from"./createLucideIcon-C1mdGPB9.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./acp-run-actions-BtRROeN9.js";import{t as p}from"./arrow-left-BikDV6F2.js";import{t as m}from"./brain-ZiC0HCCF.js";import{t as h}from"./chevron-down-CrFV6lfm.js";import{t as g}from"./chevron-right-DBGgpEiZ.js";import{t as _}from"./circle-check-q8BVdbgw.js";import{t as v}from"./circle-minus-Y3lFnfyL.js";import{w as y}from"./menu-DKE_-iVc.js";import{t as b}from"./code-DwZ6Mhdw.js";import"./src-DyqTPMO2.js";import{t as x}from"./file-text-DDbRSMUn.js";import{t as S}from"./globe-COk-NH9x.js";import{t as C}from"./chat-markdown-message-C6oOqDdl.js";import{t as ee}from"./repeat-BvvxRT2U.js";import{t as te}from"./search-D2xMZu1P.js";import{t as ne}from"./send-BlX2px_R.js";import{t as w}from"./square-CE8V_WXJ.js";import{t as T}from"./terminal-CkQ9DSF2.js";import{t as re}from"./trash-2-BKXSi5Tj.js";import{t as ie}from"./triangle-alert-CB4pJgCL.js";import{t as ae}from"./x-338EsJDP.js";import{t as oe}from"./tag-DeMzQvCo.js";import{a as E,i as se,n as D,r as O}from"./acp-run-store-DAOLku4B.js";import{t as k}from"./three-dot-indicator-BQxSg8G2.js";import{t as ce}from"./status-badge-pill---iRVZ8q.js";var le=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`}]]),A=e(n(),1),j=``;function M(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 ue(e){return(e.messageId?.startsWith(`local-marker-`)??!1)||(e.content?.startsWith(`↻ Steering: `)??!1)}function N(e){let t=e??``;return t.startsWith(`↻ Steering: `)?t.slice(D.length):t}function P(e){let t=e[e.length-1];t&&(t.kind===`agent`||t.kind===`thinking`)&&!t.isComplete&&(e[e.length-1]={...t,isComplete:!0})}function F(e,t){if(t.updateType===`agent_message_chunk`&&ue(t)){P(e),e.push({kind:`user`,id:t.messageId??`steer-${e.length}`,content:N(t.content)});return}switch(t.updateType){case`user_message_chunk`:{let n=t.messageId??j,r=N(t.content),i=e[e.length-1];i&&i.kind===`user`&&i.id===n?e[e.length-1]={...i,content:i.content+r}:(P(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??j,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!==j&&r&&r.kind===`agent`&&r.messageId===j&&!r.isComplete&&r.content===(t.content??``)){e[e.length-1]={...r,messageId:n};return}P(e),e.push({kind:`agent`,messageId:n,content:t.content??``,isComplete:!1});return}case`agent_thought_chunk`:{let n=t.messageId??j,r=e[e.length-1];if(r&&r.kind===`thinking`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}P(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;P(e),e.push({kind:`tool`,toolCallId:n,title:t.toolTitle??``,toolKind:t.toolKind,status:M(t.toolStatus,`running`),content:t.content,locations:I(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=I(t);e[r]={...i,title:t.toolTitle??i.title,toolKind:t.toolKind??i.toolKind,status:M(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=de(t.content);if(n===null)return;let r=e.findIndex(e=>e.kind===`plan`),i={kind:`plan`,entries:n};r===-1?(P(e),e.push(i)):e[r]=i;return}}}function I(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 de(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 fe(e){let t=[];for(let n of e)F(t,n);return t}function pe(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 me(){let e=null,t=[];function n(n){return t=fe(n),e=n,t}function r(r){let i=pe(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++)F(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,A.useRef)(null);return t.current??=me(),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,assistantId:n}){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)(C,{content:e,assistantId:n}),!t&&(0,W.jsx)(k,{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(E(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)(ie,{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,assistantId:n}){let[r,i]=(0,A.useState)(null),a=r??!t,o=e.trim().length>0,s=t?`Thought process`:`Thinking`,c=t?(0,W.jsx)(m,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,W.jsx)(k,{dotSize:5,className:`shrink-0`,"data-testid":`acp-chat-thinking-streaming`});return o?(0,W.jsxs)(`div`,{"data-testid":`acp-chat-thinking-block`,className:`w-full`,children:[(0,W.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>i(!a),"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:[a?(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`}),c,(0,W.jsx)(`span`,{children:s})]}),a&&(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)(C,{content:e,assistantId:n})})]}):(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:[c,(0,W.jsx)(`span`,{children:s})]})})}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:le,delete:re,move:s,search:te,execute:T,think:m,fetch:S,switch_mode:ee},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,A.useState)(!1),s=(0,A.useMemo)(()=>R(e.content),[e.content]),c=(0,A.useMemo)(()=>V(e.content),[e.content]),l=(0,A.useMemo)(()=>c.split(`
3
3
  `).map(e=>e.trim()).find(e=>e.length>0&&!e.startsWith("```"))||`View output`,[c]),u=(0,A.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)(oe,{tone:we[d],"data-testid":`acp-chat-tool-status`,children:Te[d]}),f&&(0,W.jsx)(k,{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)(T,{"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,assistantId:t}){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)(C,{content:V(e),hardLineBreaks:!0,assistantId:t})})}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-BENY-yx_.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{t as i}from"./typography-BeUa5Fd-.js";import{m as a,n as o,t as s}from"./message-content-Beh5mR15.js";import{a as c,d as l,f as u,i as d,n as f,r as p,u as m,x as h}from"./multi-activity-group-Chyfm08f.js";import{t as g}from"./chevron-left-D-pnIQax.js";import"./src-hNk11eS3.js";import{t as _}from"./chat-markdown-message-WfT4JUja.js";import{t as v}from"./workflow-store-D0DBQy44.js";import{t as y}from"./background-task-store-B1MUU_bh.js";import{r as b}from"./acp-run-store-DAOLku4B.js";import{a as x,g as S,i as C,n as w,r as T,s as E,w as D,x as O}from"./site-favicon-B3DMFtr3.js";import{t as k}from"./detail-shell-g6Pw4jiP.js";import{t as A}from"./use-transcript-message-by-id-cDbEJMB-.js";import{ToolDetailBody as j,t as M}from"./tool-detail-panel-CmbBw4_n.js";var N=e(t(),1);function P(e,t,n){let r=l(t,n.workflow),i=e=>{let t=h(e,n.workflow.byToolUseId);if(t!==null&&r.has(t))return!0;let i=m(e,n.acpByToolUseId);if(i!==null&&n.acpById[i]!==void 0)return!0;let a=u(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=A(e),r=v.use.byId(),i=v.use.byToolUseId(),a=v.use.notFoundRunIds(),c=v.use.hydrationFailedRunIds(),l=b.use.byId(),u=b.use.byToolUseId(),d=y.use.byId();return(0,N.useMemo)(()=>{if(!n||t==null)return null;let e=o(n.contentBlocks??[],{splitInlineThinking:n.role!==`user`})[t];if(!e||e.type!==`activity`)return null;let{cardItems:f,toolCalls:p}=s(e.items);return P(f,p,{workflow:{byId:r,byToolUseId:i,notFoundRunIds:a,hydrationFailedRunIds:c},acpById:l,acpByToolUseId:u,backgroundTaskById:d})},[n,t,r,i,a,c,l,u,d])}var I=r(),L=60;function R({payload:e,onClose:t,assistantId:r}){let[a,o]=(0,N.useState)(null),s=F(e.messageId,e.groupIndex),l=s?.items??e.items,u=s?.toolCalls??e.toolCalls,m=c(l),h=p(m.steps),_=d(m.state,m.steps),v=_===`loading`,y=f(_,m.totalDurationLabel??``,h.failed),b=v&&m.currentStepTitle||y,x=new Map(u.map(e=>[e.id,e])),C=a?a.kind===`thinking`?`Thinking`:a.activity||a.title:``;return(0,I.jsx)(k,{titleNode:a?(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)(g,{}),"aria-label":`Back to all steps`,tooltip:`All steps`,onClick:()=>o(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:C})]}):(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:v?(0,I.jsx)(S,{children:b}):b}),m.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:m.stepCount})]}):null]}),closeLabel:`Close steps`,onClose:t,children:a?(0,I.jsx)(B,{detail:a,assistantId:r}):(0,I.jsx)(E,{steps:m.steps,timeline:!0,renderStep:t=>(0,I.jsx)(z,{step:t,activeDetail:a,onOpenDetail:o,lookupToolCall:e=>x.get(e),messageId:e.messageId,groupIndex:e.groupIndex})})})}function z({step:e,activeDetail:t,onOpenDetail:n,lookupToolCall:r,messageId:i,groupIndex:o}){if(e.kind===`thinking`){let t=i!=null&&e.thinkingItemIndex!=null?{messageId:i,thinkingGroupIndex:o,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,I.jsx)(C,{iconName:`brain`,label:a(D(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)(T,{step:e});if(e.kind===`web_search_error`)return(0,I.jsx)(w,{step:e});if(e.kind!==`tool`)return(0,I.jsx)(x,{step:e});let s=r(e.toolCallId);return(0,I.jsx)(C,{iconName:e.iconName,label:e.activity||e.info||e.title,active:t?.toolCallId===e.toolCallId,onClick:()=>{s&&n(O(s))}})}function B({detail:e,assistantId:t}){let n=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)(_,{content:n??e.thinkingText??``,hardLineBreaks:!0,assistantId:t}):(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-BENY-yx_.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{t as i}from"./typography-BeUa5Fd-.js";import{m as a,n as o,t as s}from"./message-content-Beh5mR15.js";import{a as c,d as l,f as u,i as d,n as f,r as p,u as m,x as h}from"./multi-activity-group-D_OVaru-.js";import{t as g}from"./chevron-left-D-pnIQax.js";import"./src-DyqTPMO2.js";import{t as _}from"./chat-markdown-message-C6oOqDdl.js";import{t as v}from"./workflow-store-D0DBQy44.js";import{t as y}from"./background-task-store-B1MUU_bh.js";import{r as b}from"./acp-run-store-DAOLku4B.js";import{a as x,g as S,i as C,n as w,r as T,s as E,w as D,x as O}from"./site-favicon-DfuXzZcN.js";import{t as k}from"./detail-shell-PCaxY4Tf.js";import{t as A}from"./use-transcript-message-by-id-DCOlEJjY.js";import{ToolDetailBody as j,t as M}from"./tool-detail-panel-84bl2nI3.js";var N=e(t(),1);function P(e,t,n){let r=l(t,n.workflow),i=e=>{let t=h(e,n.workflow.byToolUseId);if(t!==null&&r.has(t))return!0;let i=m(e,n.acpByToolUseId);if(i!==null&&n.acpById[i]!==void 0)return!0;let a=u(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=A(e),r=v.use.byId(),i=v.use.byToolUseId(),a=v.use.notFoundRunIds(),c=v.use.hydrationFailedRunIds(),l=b.use.byId(),u=b.use.byToolUseId(),d=y.use.byId();return(0,N.useMemo)(()=>{if(!n||t==null)return null;let e=o(n.contentBlocks??[],{splitInlineThinking:n.role!==`user`})[t];if(!e||e.type!==`activity`)return null;let{cardItems:f,toolCalls:p}=s(e.items);return P(f,p,{workflow:{byId:r,byToolUseId:i,notFoundRunIds:a,hydrationFailedRunIds:c},acpById:l,acpByToolUseId:u,backgroundTaskById:d})},[n,t,r,i,a,c,l,u,d])}var I=r(),L=60;function R({payload:e,onClose:t,assistantId:r}){let[a,o]=(0,N.useState)(null),s=F(e.messageId,e.groupIndex),l=s?.items??e.items,u=s?.toolCalls??e.toolCalls,m=c(l),h=p(m.steps),_=d(m.state,m.steps),v=_===`loading`,y=f(_,m.totalDurationLabel??``,h.failed),b=v&&m.currentStepTitle||y,x=new Map(u.map(e=>[e.id,e])),C=a?a.kind===`thinking`?`Thinking`:a.activity||a.title:``;return(0,I.jsx)(k,{titleNode:a?(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)(g,{}),"aria-label":`Back to all steps`,tooltip:`All steps`,onClick:()=>o(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:C})]}):(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:v?(0,I.jsx)(S,{children:b}):b}),m.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:m.stepCount})]}):null]}),closeLabel:`Close steps`,onClose:t,children:a?(0,I.jsx)(B,{detail:a,assistantId:r}):(0,I.jsx)(E,{steps:m.steps,timeline:!0,renderStep:t=>(0,I.jsx)(z,{step:t,activeDetail:a,onOpenDetail:o,lookupToolCall:e=>x.get(e),messageId:e.messageId,groupIndex:e.groupIndex})})})}function z({step:e,activeDetail:t,onOpenDetail:n,lookupToolCall:r,messageId:i,groupIndex:o}){if(e.kind===`thinking`){let t=i!=null&&e.thinkingItemIndex!=null?{messageId:i,thinkingGroupIndex:o,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,I.jsx)(C,{iconName:`brain`,label:a(D(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)(T,{step:e});if(e.kind===`web_search_error`)return(0,I.jsx)(w,{step:e});if(e.kind!==`tool`)return(0,I.jsx)(x,{step:e});let s=r(e.toolCallId);return(0,I.jsx)(C,{iconName:e.iconName,label:e.activity||e.info||e.title,active:t?.toolCallId===e.toolCallId,onClick:()=>{s&&n(O(s))}})}function B({detail:e,assistantId:t}){let n=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)(_,{content:n??e.thinkingText??``,hardLineBreaks:!0,assistantId:t}):(0,I.jsx)(j,{detail:e})})}export{R as ActivityStepsPanel};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,l as n,o as r}from"./local-settings-Bx7FsNo5.js";import{r as i,t as a}from"./capture-error-Cw5vs0Ef.js";import{t as o}from"./react-BFJW0bSv.js";import{n as s,t as c}from"./button-BENY-yx_.js";import{d as l,h as u}from"./chunk-5KNZJZUH-BUqIilZr.js";import{n as d}from"./QueryClientProvider-CMu7CkQU.js";import{t as f}from"./useQuery-Bz-fbQ-m.js";import{t as p}from"./useMutation-CXGTrp4W.js";import{t as m}from"./jsx-runtime-D3ZM-ToX.js";import{t as h}from"./typography-BeUa5Fd-.js";import{t as g}from"./check-DSgjgwlo.js";import{t as _}from"./circle-alert-De9q5FVd.js";import{t as v}from"./circle-check-q8BVdbgw.js";import{t as y}from"./menu-DKE_-iVc.js";import{t as b}from"./clock-B8umTTHk.js";import{r as x,z as S}from"./src-hNk11eS3.js";import{t as C}from"./ellipsis-vertical-eVgdKn9z.js";import{t as w}from"./external-link-vwewPjbo.js";import{t as T}from"./info-CXkwGlN_.js";import{t as E}from"./list-O_53kvwx.js";import{t as D}from"./loader-circle-DOtGXcds.js";import{t as O}from"./mail-CYjppw70.js";import{t as k}from"./checkbox-C4x4HEp4.js";import{t as A}from"./plus-DnH9Pjq4.js";import{t as j}from"./search-D2xMZu1P.js";import{t as M}from"./trash-2-BKXSi5Tj.js";import{t as N}from"./triangle-alert-CB4pJgCL.js";import{t as P}from"./notice-C0ifrvvJ.js";import{t as F}from"./tag-DeMzQvCo.js";import{t as I}from"./popover-CAbJ9178.js";import{t as L}from"./input-DmHXRXaB.js";import{t as R}from"./toggle-C-v4x7_A.js";import{t as z}from"./modal-DI63s9MQ.js";import{n as B}from"./toast-BpuLSxyt.js";import{t as V}from"./confirm-dialog-zx8L9sUi.js";import{t as H}from"./select-B8-i-CZ4.js";import{t as U}from"./skeleton-CJJwPIil.js";import{A as W,C as G,I as K,N as ee,P as q,S as J,T as te,_ as Y,a as ne,b as re,c as X,f as ie,g as ae,h as oe,i as se,j as Z,l as ce,m as le,n as ue,o as de,p as fe,r as pe,s as me,t as he,v as ge,x as _e,y as ve}from"./profile-pickers-ChG4_Gpc.js";import{A as ye,B as be,C as xe,F as Se,G as Ce,H as we,I as Te,L as Ee,M as De,N as Oe,P as ke,R as Ae,S as je,U as Me,V as Ne,W as Pe,_ as Fe,a as Ie,b as Le,c as Re,d as ze,f as Be,g as Ve,h as He,i as Ue,j as We,k as Ge,l as Ke,m as qe,n as Je,o as Ye,p as Xe,r as Ze,s as Qe,t as $e,u as et,x as tt,y as nt,z as rt}from"./use-sticky-profiles-LVe9u5gh.js";import{t as it}from"./assistant-identity-store-nE-e8KQw.js";import{i as at,n as ot,o as st,r as ct}from"./utils-CVoSWh7U.js";import{i as lt,r as ut}from"./api-errors-BQX1Pzcm.js";import{Jt as dt,On as ft,dr as pt,j as mt,pt as ht,qt as gt,ut as _t}from"./sdk.gen-CBPZ2IdN.js";import{f as vt}from"./platform-detection-C_TK32Dw.js";import{d as yt}from"./routes-iipg2wkc.js";import{i as bt}from"./use-platform-gate-CdwOyQ8A.js";import{r as xt}from"./use-is-org-ready-BmOdacs1.js";import{G as St,J as Ct,K as wt,St as Tt,Wt as Et,Yt as Dt,_ as Ot,d as kt,f as At,g as jt,h as Mt,m as Nt,on as Pt,p as Ft,q as It,u as Lt,wt as Rt,xt as zt}from"./react-query.gen-DxjuNs-5.js";import{n as Bt}from"./use-is-mobile-BP8UePsY.js";import{c as Vt,d as Ht,f as Ut,g as Wt,h as Gt,l as Kt,m as qt,o as Jt,p as Yt,s as Xt,u as Zt,ut as Qt,v as $t,y as en}from"./react-query.gen-DKb3mEwJ.js";import{t as tn}from"./platform-login-notice-CIpebDVw.js";import{t as nn}from"./android-consumption-only-BkXIkXls.js";import{a as rn,c as an,i as on,n as sn,o as cn}from"./voice-list-DnqRx15F.js";import{n as ln}from"./use-voice-sample-preview-BjIqIVEG.js";import{t as un}from"./use-active-assistant-id-BvHP5Ojg.js";import{t as dn}from"./detail-shell-g6Pw4jiP.js";import{a as fn}from"./schedules-kVuR00ra.js";import{t as pn}from"./detail-card-Dsnf52vg.js";import{n as mn,t as hn}from"./detail-drawer-AKY7keIJ.js";import{t as gn}from"./use-platform-assistant-id-CEMyKEvV.js";import{t as _n}from"./environment-store-CFfbiF-5.js";import{t as vn}from"./stt-language-picker-modal-B5MO-3gk.js";var Q=e(o(),1),$=m();function yn({mode:e,onChange:t}){return(0,$.jsx)(`div`,{className:`max-w-[280px]`,children:(0,$.jsx)(S,{ariaLabel:`Service mode`,value:e,onChange:t,items:[{value:`managed`,label:`Managed`},{value:`your-own`,label:`Your Own`}]})})}function bn({id:e,title:t,subtitle:n,mode:r,onModeChange:i,children:a}){return(0,$.jsxs)(pn,{id:e,title:t,subtitle:n,accessory:(0,$.jsx)(yn,{mode:r,onChange:i}),children:[(0,$.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,$.jsx)(`div`,{className:`mt-4`,children:a})]})}function xn({id:e,title:t,subtitle:n,children:r}){return(0,$.jsxs)(pn,{id:e,title:t,subtitle:n,children:[(0,$.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,$.jsx)(`div`,{className:`mt-4`,children:r})]})}function Sn(){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-4 py-2.5`,children:[(0,$.jsx)(T,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,$.jsxs)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:[`Managed services are metered and deducted from your Vellum account balance.`,` `,(0,$.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,$.jsx)(w,{className:`h-3.5 w-3.5`})]})]})]})}function Cn({status:e,message:t,isLoading:n}){return n?(0,$.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,$.jsx)(D,{className:`h-3 w-3 animate-spin`}),`Checking domain…`]}):e?e===`verified`?(0,$.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,$.jsx)(g,{className:`h-3 w-3`}),`Domain verified`]}):e===`pending`||e===`not_started`?(0,$.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,$.jsx)(b,{className:`h-3 w-3`}),`Verifying domain…`]}):(0,$.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,$.jsx)(_,{className:`h-3 w-3`}),`Verification failed`]}):(0,$.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 wn({onClick:e,disabled:t}){return(0,$.jsx)(c,{onClick:e,disabled:t,children:`Save`})}function Tn({onClick:e,filled:t=!1}){return(0,$.jsx)(c,{variant:t?`danger`:`dangerGhost`,onClick:e,children:`Reset`})}function En({guide:e}){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(T,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{children:e.description}),(0,$.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,$.jsx)(w,{className:`h-3 w-3`})]})]})]})}function Dn({subdomain:e,onSubdomainChange:t,domainSuffix:n,subdomainPlaceholder:r=`my-assistant`,disabled:i,autoFocus:a,prefix:o,error:s,locked:c,lockedMessage:l}){return(0,$.jsxs)(`div`,{children:[(0,$.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,$.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,$.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`.`,n]})]}),s&&(0,$.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--system-negative-strong)]`,children:s}),c&&l&&(0,$.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--content-tertiary)]`,children:l})]})}function On({assistantId:e,assistantHandle:t,emailRootDomain:n}){let r=d(),i=l(),o=vt(),[s,m]=u(),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,N]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{_||!t||h||(g(t),v(!0))},[t,_,h]);let F=f({...Qt(),enabled:!0}),I=F.data,L=I?.entitlements,R=L?.managed_email===!0,z=!!L&&!R,H=!I&&F.isError&&!F.isFetching,U=f({...Vt({path:{assistant_id:e}}),enabled:!z}),W=f({...Yt({path:{assistant_id:e}}),enabled:!z}),G=U.data?.results?.[0],K=W.data?.results?.[0],ee=G?`${G.subdomain}.${n}`:null,q=f({...Gt({path:{assistant_id:e,id:K?.id??``}}),enabled:!!K?.id,refetchOnWindowFocus:!1}),J=f({...Zt({path:{assistant_id:e,id:G?.id??``}}),enabled:!!G?.id,refetchInterval:e=>{let t=e.state.data?.status;return t===`verified`||t===`failed`?!1:1e4},refetchOnWindowFocus:!0});(0,Q.useEffect)(()=>{s.get(`release`)!==`1`||!G||K||(A(!0),m(e=>{let t=new URLSearchParams(e);return t.delete(`release`),t},{replace:!0}))},[K,G,s,m]);let te=p(Jt()),Y=p(Xt()),ne=p(Ht()),re=p(Ut()),X=(0,Q.useCallback)(()=>{let t={assistant_id:e};r.invalidateQueries({queryKey:Kt({path:t})}),r.invalidateQueries({queryKey:qt({path:t})}),K?.id&&r.invalidateQueries({queryKey:Wt({path:{...t,id:K.id}})}),r.invalidateQueries({queryKey:en()})},[K?.id,e,r]),ie=(0,Q.useCallback)(async()=>{let t=h.trim().toLowerCase();if(!t){b(`Enter a subdomain.`);return}E(!1);try{await te.mutateAsync({path:{assistant_id:e},body:{subdomain:t}}),g(``),b(null),X(),B.success(`Domain ${t}.${n} registered.`)}catch(e){b(lt(e,void 0,`Failed to register domain.`))}},[e,n,X,te,h]),ae=(0,Q.useCallback)(async()=>{let t=x.trim().toLowerCase();if(!t){w(`Enter an email username.`);return}try{await ne.mutateAsync({path:{assistant_id:e},body:{username:t}}),S(``),w(null),X(),B.success(`Email address created.`)}catch(e){w(lt(e,void 0,`Failed to create email address.`))}},[e,X,ne,x]),oe=(0,Q.useCallback)(async()=>{if(K?.id){N(!1);try{await re.mutateAsync({path:{assistant_id:e,id:K.id}}),X(),B.success(`Email address removed.`)}catch(e){a(e,{context:`email_address_delete`}),B.error(`Failed to remove email address.`)}}},[K?.id,e,re,X]),se=(0,Q.useCallback)(async()=>{if(!G?.id)return;if(K){B.error(`Remove the email address first.`);return}A(!1);let t=G.subdomain;try{await Y.mutateAsync({path:{assistant_id:e,id:G.id}}),g(t),X(),B.success(`Domain released.`)}catch(e){a(e,{context:`email_domain_release`}),B.error(`Failed to release domain.`)}},[K,e,Y,G?.id,G?.subdomain,X]);if(F.isLoading)return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Checking subscription…`]});if(z)return(0,$.jsx)(P,{tone:`info`,icon:(0,$.jsx)(O,{className:`h-4 w-4`,"aria-hidden":!0}),title:`Give your assistant its own email address`,actions:o?void 0:(0,$.jsx)(c,{size:`compact`,onClick:()=>i(yt.plans),children:`Upgrade`}),children:o?nn:(0,$.jsx)($.Fragment,{children:`Upgrade to a plan that includes an email address for your assistant. No provider setup required.`})});let Z=H?(0,$.jsx)(P,{tone:`warning`,title:`Couldn't verify subscription status`,actions:(0,$.jsx)(c,{size:`compact`,variant:`outlined`,onClick:()=>F.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 G?K?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[Z,(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Address`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:K.address}),(0,$.jsx)(Cn,{status:J.data?.status,message:J.data?.message,isLoading:J.isLoading}),(0,$.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,$.jsx)(M,{}),onClick:()=>N(!0),disabled:re.isPending,"aria-label":`Remove email address`})]}),(0,$.jsx)(V,{open:j,title:`Remove Email Address`,message:(0,$.jsxs)($.Fragment,{children:[`Are you sure you want to remove`,` `,(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:K.address}),`? Your assistant will no longer be able to send or receive email at this address.`]}),confirmLabel:`Remove`,destructive:!0,onConfirm:oe,onCancel:()=>N(!1)})]}),q.data?.usage&&(0,$.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[q.data.usage.sent_today,` /`,` `,q.data.usage.daily_limit,` sent today ·`,` `,q.data.usage.received_today,` received`]})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[Z,(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Domain`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:[G.subdomain,`.`,n]}),(0,$.jsx)(Cn,{status:J.data?.status,message:J.data?.message,isLoading:J.isLoading}),(0,$.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,$.jsx)(M,{}),onClick:()=>A(!0),disabled:Y.isPending,"aria-label":`Release domain`})]}),(0,$.jsx)(V,{open:k,title:`Release Domain`,message:(0,$.jsxs)($.Fragment,{children:[`Are you sure you want to release`,` `,(0,$.jsxs)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:[G.subdomain,`.`,n]}),`? The subdomain will become available for others to claim.`]}),confirmLabel:`Release`,destructive:!0,onConfirm:se,onCancel:()=>A(!1)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Email address`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.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 ${C?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[(0,$.jsx)(`input`,{value:x,onChange:e=>{S(e.target.value.toLowerCase()),C&&w(null)},placeholder:`hi`,"aria-label":`Email username`,"aria-invalid":!!C,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,$.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`@`,ee]})]}),(0,$.jsx)(c,{onClick:ae,disabled:ne.isPending||!x.trim(),children:ne.isPending?`Creating…`:`Create`})]}),C&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:C})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[Z,(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Subdomain`}),(0,$.jsx)(Dn,{subdomain:h,onSubdomainChange:e=>{g(e),y&&b(null)},domainSuffix:n,subdomainPlaceholder:`my-assistant`,error:y}),(0,$.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,$.jsx)(c,{onClick:()=>E(!0),disabled:te.isPending||!h.trim(),children:te.isPending?`Registering…`:`Register`}),(0,$.jsx)(V,{open:T,title:`Set Subdomain`,message:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:h.trim().toLowerCase()||`subdomain`}),` `,`will also become your assistant's public handle. You won't be able to change it once set.`]}),confirmLabel:`Confirm`,onConfirm:ie,onCancel:()=>E(!1)})]})}function kn(){let e=un(),r=xt(),{data:o}=f({...$t(),enabled:r}),s=o?.results?.[0]?.handle,c=_n.use.emailRootDomain(),l=bt(),[u,d]=(0,Q.useState)(()=>l===`gated`?`your-own`:le(t(Ue,`managed`),`managed`)),[p,m]=(0,Q.useState)(()=>{let e=t(Ze,`resend`);return e===`mailgun`||e===`resend`?e:`resend`}),{platformAssistantId:h,error:g}=gn(e,l===`full`&&u===`managed`),_=h??(g?e:null),y=f({queryKey:[`byoEmailCredential`,e,p],queryFn:async()=>{let{data:t}=await _t({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,Q.useEffect)(()=>{y.error&&a(y.error,{context:`byo_email_credential_check`,bestEffort:!0})},[y.error]);let b=y.data?.hasSecret===!0,x=(0,Q.useCallback)(e=>{d(e),n(Ue,e)},[]),S=(0,Q.useCallback)(()=>{n(Ze,p),B.success(`Email settings saved.`)},[p]),C=(0,Q.useMemo)(()=>qe.find(e=>e.id===p)??qe[0],[p]),E=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(T,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`span`,{children:[`Configure `,C.displayName,` via the assistant CLI: ask the assistant to run the`,` `,(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:C.setupSkill}),` `,`skill. It walks you through storing the API key, detecting the domain, and (optionally) wiring up an inbound webhook.`]}),(0,$.jsxs)(`a`,{href:C.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,C.displayName,(0,$.jsx)(w,{className:`h-3 w-3`})]})]})]}),O=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:p,onChange:e=>{(e===`mailgun`||e===`resend`)&&m(e)},options:qe.map(e=>({value:e.id,label:e.displayName}))})]}),b?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.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,$.jsx)(v,{className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,$.jsxs)(`span`,{children:[C.displayName,` API key configured. To reconfigure, run the`,` `,(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:C.setupSkill}),` `,`skill.`]})]}),(0,$.jsxs)(`a`,{href:C.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 `,C.displayName,(0,$.jsx)(w,{className:`h-3 w-3`})]})]}):E,(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(wn,{onClick:S,disabled:!1})})]});return l===`gated`?(0,$.jsx)(xn,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,children:O}):(0,$.jsx)(bn,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,mode:u,onModeChange:x,children:u===`managed`?(0,$.jsx)(`div`,{className:`space-y-4`,children:l===`disabled`?(0,$.jsx)(tn,{children:`Log in to the Vellum platform to manage email settings.`}):_===null?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Connecting to the Vellum platform…`]}):(0,$.jsx)(On,{assistantId:_,assistantHandle:s,emailRootDomain:c})}):O})}function An(){let e=un();return(0,Q.useCallback)(async(t,n)=>{try{let{data:r}=await pt({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});X(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?B.error(`Assistant not ready. Please try again.`):B.error(`Failed to save ${t} API key. Please try again.`),a(e,{context:`provision_provider_key`}),e}},[e])}function jn(e){let[t,n]=(0,Q.useState)(void 0);return(0,Q.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Q.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}var Mn=`0.11.0`;function Nn(){return ot(Mn)}var Pn=`gemini-3.1-flash-image-preview`;function Fn(){let e=un(),r=d(),i=xt(),{data:o}=f({...Lt({path:{assistant_id:e}}),enabled:i,staleTime:3e4}),s=Dt({onSuccess:t=>{At(r,{path:{assistant_id:e}},t)}}),c=An(),[l,u]=jn((0,Q.useMemo)(()=>{if(!o)return t(Ye,`gemini`);let e=o.services?.[`image-generation`];return e?.mode===`managed`?`vellum`:e?.provider||t(`vellum:ai:imageGenProvider`,`gemini`)},[o])),[p,m]=(0,Q.useState)(()=>t(Ie,Pn)),h=tt(l),g=h.includes(p)?p:h[0]??Pn,[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),x=Ve.map(e=>({value:e,label:Fe[e]??e})),S=(0,Q.useMemo)(()=>tt(l).map(e=>({value:e,label:He[e]??e})),[l]),C=l===`gemini`||l===`openai`,{hasStoredCredential:w}=be({assistantId:e,credentialKind:`api_key`,credentialName:l,enabled:C}),T=u,E=(0,Q.useCallback)(async()=>{b(!0);let t=_.trim(),i=C&&t.length>0;try{i&&await c(je(g),t),await st();let n=l===`vellum`&&!Nn()?{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 B.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e});try{await ft({path:{assistant_id:e},body:{modelId:g},throwOnError:!0})}catch(e){throw B.error(`Failed to update image generation model. Please try again.`),a(e,{context:`set_image_gen_model`}),e}finally{r.invalidateQueries({queryKey:kt({path:{assistant_id:e}})})}}catch{b(!1);return}b(!1);try{if(n(Ye,l),n(Ie,g),i){let t=rt(e,`api_key`,l);r.setQueryData(t,!0),r.invalidateQueries({queryKey:t}),v(``)}B.success(`Image generation settings saved.`)}catch(e){a(e,{context:`settings-ai-image-gen-persist-local`}),B.error(`Saved, but local preferences could not be written.`)}},[_,l,C,g,e,s,c,r]),O=(0,Q.useCallback)(()=>{v(``),m(Pn),n(Ie,Pn)},[]);return(0,$.jsx)(xn,{title:`Image Generation`,subtitle:`Configure which model your assistant uses to generate images`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{"aria-label":`Image generation provider`,value:l,onChange:T,options:x})]}),l===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Image generation runs through your Vellum account.`}),C&&(0,$.jsx)(L,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:ke(l===`openai`?`Enter your OpenAI API key`:`Enter your Gemini API key`,w),fullWidth:!0}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,$.jsx)(H,{"aria-label":`Image generation model`,value:g,onChange:m,options:S})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(wn,{onClick:E,disabled:y}),y&&(0,$.jsx)(D,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),C&&(0,$.jsx)(Tn,{onClick:O})]})]})})}function In({title:e,count:t,action:n,children:r}){return(0,$.jsxs)(`section`,{className:`rounded-xl border border-[var(--border-hover)] bg-[var(--surface-overlay)] px-3 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(h,{variant:`body-large-default`,as:`h3`,className:`text-[var(--content-secondary)]`,children:e}),t==null?null:(0,$.jsxs)(h,{variant:`body-large-default`,as:`span`,"aria-label":`${t} ${e.toLowerCase()}`,className:`text-[var(--content-disabled)]`,children:[`·`,` `,t]})]}),n]}),r==null?null:(0,$.jsx)(`div`,{className:`mt-4 border-t border-[var(--border-base)]`,children:r})]})}function Ln(e){return e.scheduleNames.length>0||e.deferredReminderCount>0||e.scheduleLookupFailed}var Rn=5;function zn(e,t){return`${e} ${t}${e===1?``:`s`}`}function Bn(e){return e.length===1?e[0]:e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function Vn(e){let t=e.label||e.name,n=[];e.isActive&&n.push(`is your default profile`),e.callSiteIds.length>0&&n.push(`is used by ${zn(e.callSiteIds.length,`action override`)}`);let r=[];return e.scheduleNames.length>0&&r.push(zn(e.scheduleNames.length,`schedule`)),e.deferredReminderCount>0&&r.push(zn(e.deferredReminderCount,`reminder`)),r.length>0&&n.push(`runs ${Bn(r)}`),n.length===0?`Choose a replacement profile for "${t}". Anything still pointing at it moves there before it is deleted.`:`"${t}" ${Bn(n)}. Pick a replacement below and those references move to it, then "${t}" is deleted.`}function Hn({title:e,items:t,mono:n}){return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--content-tertiary)`,children:e}),(0,$.jsx)(`ul`,{className:`space-y-1 pl-1`,children:t.map(e=>(0,$.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,n?(0,$.jsx)(`code`,{children:e}):e]},e))})]})}function Un({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:s}){let l=e?.scheduleNames??[],u=l.slice(0,Rn),d=l.length-u.length,f=e!=null&&Ln(e);return(0,$.jsx)(z.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(z.Content,{size:`sm`,children:[(0,$.jsx)(z.Header,{children:(0,$.jsx)(z.Title,{children:`Choose a Replacement Profile`})}),(0,$.jsxs)(z.Body,{className:`space-y-4`,children:[e&&(0,$.jsx)(h,{variant:`body-medium-default`,as:`p`,children:Vn(e)}),e&&e.callSiteIds.length>0&&(0,$.jsx)(Hn,{title:`Action overrides`,items:e.callSiteIds,mono:!0}),u.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(Hn,{title:`Schedules`,items:u}),d>0&&(0,$.jsxs)(h,{variant:`body-small-default`,as:`p`,className:`pl-1 text-(--content-tertiary)`,children:[`and `,d,` more`]})]}),e?.scheduleLookupFailed&&(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-mid-strong)`,children:`We could not check which schedules use this profile. Any schedule pinned to it moves to the replacement as well.`}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-(--content-tertiary)`,children:`Replacement profile`}),(0,$.jsx)(H,{"aria-label":`Replacement profile`,value:n,onChange:r,placeholder:`Select a replacement…`,options:t.map(e=>{let t=f&&e.status===`disabled`;return{value:e.name,label:pe(e),disabled:t,tooltip:t?`Enable this profile to move schedules onto it.`:void 0}})})]}),i&&(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,$.jsxs)(z.Footer,{children:[(0,$.jsx)(c,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,$.jsx)(c,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:s,children:a?`Saving…`:`Reassign and Delete`})]})]})})}function Wn({profile:e,isActiveProfile:t,selected:n,connections:r,deletePending:i=!1,onOpen:a,onMakeActive:o,onSetStatus:l,onDelete:u}){let d=e.source===`managed`,f=e.status===`disabled`,p=e.label??e.name,m=[];e.model&&m.push(ye(e.provider??void 0,e.model,r)),d&&m.push(`Managed by Vellum`);let h=e.availability,g=h?.status===`incomplete`,v=h!=null&&h.status!==`ok`?`${h.message??`This profile's provider is not available.`}${g?` Click to fix.`:``}`:null;return(0,$.jsx)(x,{title:(0,$.jsx)(`span`,{className:f?`opacity-55`:void 0,children:p}),subtitle:m.length>0?m.join(` • `):void 0,onClick:a,showChevron:!1,selected:n,disabled:i,contentAriaLabel:`Open profile ${p}`,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[v==null?null:(0,$.jsx)(s,{content:v,children:g?(0,$.jsx)(`button`,{type:`button`,onClick:a,"aria-label":v,className:`inline-flex cursor-pointer rounded-sm p-0.5 keyboard-focus:ring-2 keyboard-focus:ring-[var(--ring)]`,children:(0,$.jsx)(_,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-hidden":`true`})}):(0,$.jsx)(`span`,{className:`inline-flex p-0.5`,tabIndex:0,children:(0,$.jsx)(_,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-label":v,role:`img`})})}),f?(0,$.jsx)(F,{tone:`neutral`,children:`Disabled`}):null,t?(0,$.jsx)(F,{tone:`positive`,children:`Default`}):null,(0,$.jsxs)(y.Root,{children:[(0,$.jsx)(y.Trigger,{asChild:!0,children:(0,$.jsx)(c,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(C,{}),"aria-label":`Actions for ${p}`,disabled:i})}),(0,$.jsxs)(y.Content,{align:`end`,sideOffset:4,children:[(0,$.jsx)(y.Item,{onSelect:a,children:d?`View`:`Edit`}),!t&&!f?(0,$.jsx)(y.Item,{onSelect:o,children:`Make Default`}):null,f?(0,$.jsx)(y.Item,{onSelect:()=>l(!0),children:`Enable`}):d?null:(0,$.jsx)(y.Item,{onSelect:()=>l(!1),children:`Disable`}),d?null:(0,$.jsx)(y.Item,{onSelect:u,className:`text-[var(--system-negative-strong)] data-[highlighted]:text-[var(--system-negative-strong)]`,children:`Delete`})]})]})]})})}var Gn=`0.11.0`;function Kn(){return at(Gn)}function qn(e,t){let n=Kn(),{data:r}=f({...St({path:{assistant_id:e}}),enabled:n,staleTime:3e4}),{profiles:i,profileOrder:a}=$e(t?.llm,e);return(0,Q.useMemo)(()=>r==null?{entries:ce(i,a).map(e=>({name:e.name,label:e.label??null,provider:e.provider??null,model:e.model??null,status:e.status===`disabled`?`disabled`:`active`,source:e.source===`managed`?`managed`:`user`,provider_connection:e.provider_connection,availability:null})),isEffectiveCatalog:!1}:{entries:r.profiles,isEffectiveCatalog:!0},[r,i,a])}function Jn(e){let t=d();return Dt({onSuccess:n=>{At(t,{path:{assistant_id:e}},n),t.invalidateQueries({queryKey:wt({path:{assistant_id:e}})}),t.invalidateQueries({queryKey:Nt({path:{assistant_id:e}})})}})}var Yn=`0.10.8`;function Xn(e){return ct(Yn,e)}var Zn=`settings-ai-profile-make-active`,Qn=`Failed to set the active profile. Please try again.`;function $n(e){let t=Jn(e),n=d(),r=Xn(e),i=Pt({onSuccess:()=>{n.invalidateQueries({queryKey:kt({path:{assistant_id:e}})}),n.invalidateQueries({queryKey:wt({path:{assistant_id:e}})})}});async function o(n,r,i){try{await t.mutateAsync({path:{assistant_id:e},body:{llm:n}})}catch(e){throw a(e,{context:r}),B.error(i),e}}async function s(t){if(!r){await o({activeProfile:t},Zn,Qn);return}try{await i.mutateAsync({path:{assistant_id:e},body:{name:t}})}catch(e){let t=ut(e);throw B.error(t??Qn),t||a(e,{context:Zn}),e}}return{makeActive:s,setStatus:(e,t)=>o({profiles:{[e]:{status:t?`active`:`disabled`}}},`settings-ai-profile-toggle`,`Failed to update the profile. Please try again.`),deleteProfile:(e,t,n)=>o({profiles:{[e]:null},profileOrder:t.filter(t=>t!==e),...n?.isAdvisor?{advisorProfile:null}:{}},`settings-ai-profile-delete`,`Failed to delete the profile. Please try again.`),patchLlm:o,isPending:t.isPending||i.isPending}}var er=`The profile was not deleted.`,tr=`Failed to move the schedules. ${er}`;function nr(e){let t=ut(e);return t?`${/[.!?]$/.test(t)?t:`${t}.`} ${er}`:tr}function rr(e,t,n){let r=$n(e),i=d(),o=me(),s=t?.llm?.activeProfile??null,c=t?.llm?.advisorProfile??null,l=t?.llm?.callSites??{},u=(0,Q.useMemo)(()=>t?.llm?.profiles??{},[t?.llm?.profiles]),f=(0,Q.useMemo)(()=>t?.llm?.profileOrder??[],[t?.llm?.profileOrder]),p=(0,Q.useMemo)(()=>ce(u,f),[u,f]),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),w=(0,Q.useRef)(!1);function T(e){return p.filter(t=>t.name===e?!1:t.status===`disabled`?!0:he(t,p,{requireOwnProviderAndModel:o}))}function E(e,t){let n=T(e).filter(e=>!t||e.status!==`disabled`),r=n.find(e=>e.name===s),i=n.find(e=>e.source!==`managed`);return(r??i??n[0])?.name??``}async function D(e){try{await r.deleteProfile(e,f,{isAdvisor:e===c}),n?.onDeleted?.(e)}catch{}}async function O(t){let n=u[t]?.label??t,r=t===s,o=Object.entries(l).filter(([e,n])=>e!==`mainAgent`&&n?.profile===t).map(([e])=>e),c=[],d=0,f=!1;try{let n=(await i.fetchQuery({...zt({path:{assistant_id:e},query:{inference_profile:t,include_all:`true`}}),retry:!1,staleTime:0})).schedules??[];c=n.filter(e=>!e.isDeferred).map(e=>e.name),d=n.filter(e=>e.isDeferred).length}catch(e){a(e,{context:`settings-ai-profile-delete-schedule-scan`}),f=!0}if(!(r||o.length>0||c.length>0||d>0)&&!f){await D(t);return}let p={name:t,label:n,isActive:r,callSiteIds:o,scheduleNames:c,deferredReminderCount:d,scheduleLookupFailed:f};h(p),y(E(t,Ln(p))),_(null)}function k(e){t==null||w.current||(w.current=!0,C(e),O(e).finally(()=>{w.current=!1,C(null)}))}async function A(){if(!m||!v)return;if(x(!0),_(null),Ln(m))try{await fn(e,m.name,v),await i.invalidateQueries({queryKey:Tt({path:{assistant_id:e}})})}catch(e){a(e,{context:`settings-ai-profile-reassign-schedules`}),_(nr(e)),x(!1);return}let t={};if(m.isActive&&(t.activeProfile=v),m.callSiteIds.length>0){let e={};for(let t of m.callSiteIds)e[t]={profile:v};t.callSites=e}if(Object.keys(t).length>0)try{await r.patchLlm(t,`settings-ai-profile-reassign-delete`,`Failed to reassign references. Please try again.`)}catch{_(`Failed to reassign references. Please try again.`),x(!1);return}let n=m.name;h(null),x(!1),D(n)}return{requestDelete:k,pendingDeleteName:S,blockedDeleteModalProps:{blocked:m,availableReplacements:T(m?.name??null),replacement:v,onReplacementChange:y,error:g,saving:b,onClose:()=>{h(null),_(null)},onConfirm:()=>void A()}}}function ir(){}function ar({assistantId:e,config:t,connections:n,selectedProfileName:r,onOpenProfile:i,onCreateProfile:a,onProfileDeleted:o}){let{entries:s}=qn(e,t),l=$n(e),u=rr(e,t,{onDeleted:o}),d=t?.llm?.activeProfile??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(In,{title:`Profiles`,action:(0,$.jsx)(c,{variant:`primary`,onClick:a,leftIcon:(0,$.jsx)(A,{}),disabled:t==null,children:`Create Profile`}),children:t==null?(0,$.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`Loading profiles…`}):s.length===0?(0,$.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.`}):s.map(e=>(0,$.jsx)(Wn,{profile:e,isActiveProfile:e.name===d,selected:e.name===r,connections:n,deletePending:u.pendingDeleteName===e.name,onOpen:()=>i(e.name),onMakeActive:()=>void l.makeActive(e.name).catch(ir),onSetStatus:t=>void l.setStatus(e.name,t).catch(ir),onDelete:()=>u.requestDelete(e.name)},e.name))}),(0,$.jsx)(Un,{...u.blockedDeleteModalProps})]})}var or={anthropic:!0,openai:!0,gemini:!0,fireworks:!0,openrouter:!0,vellum:!0,together:!0,"vercel-ai-gateway":!0,minimax:!0,atlascloud:!0,baseten:!0,poolside:!0};function sr(e){return e in or}function cr(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 lr(e){switch(e.auth.type){case`api_key`:return`Own API key`;case`oauth_subscription`:return`ChatGPT subscription`;case`none`:return`No API key needed`;default:return null}}function ur(e){if(e.provider===`vellum`)return`Included with your plan`;if(e.provider===`openai-compatible`)return cr(e);let t=[],n=e.models?.length??K(e.provider).length;n>0&&t.push(`${n} ${n===1?`model`:`models`}`);let r=lr(e);return r&&t.push(r),t.join(` • `)}function dr({connection:e,isDefault:t,supportsDefaultProvider:n,selected:r,isSettingDefault:i,onOpen:a,onSetDefault:o,onDelete:s}){let l=e.isManaged??!1,u=Pe(e),d=sr(e.provider),f=ur(e),p=n&&!t&&d,m=!l&&a!=null,h=!l&&!t,g=p||m||h;return(0,$.jsx)(x,{title:u,subtitle:f.length>0?f:void 0,onClick:a,showChevron:!1,selected:r,contentAriaLabel:a?`Open provider ${u}`:void 0,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[l?(0,$.jsx)(F,{tone:`neutral`,title:`Runs on Vellum's managed credentials.`,children:`Managed`}):null,t?(0,$.jsx)(F,{tone:`info`,title:`Built-in profiles (Balanced, Quality, Cost, Speed) use this provider.`,children:`Default`}):null,e.provider===`ollama`?(0,$.jsx)(F,{tone:`neutral`,title:`Runs models on this machine.`,children:`Local`}):null,e.provider===`openai-compatible`?(0,$.jsx)(F,{tone:`neutral`,title:`A provider you created, served by an OpenAI-compatible endpoint.`,children:`Custom`}):null,g?(0,$.jsxs)(y.Root,{children:[(0,$.jsx)(y.Trigger,{asChild:!0,children:(0,$.jsx)(c,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(C,{}),"aria-label":`Actions for ${u}`})}),(0,$.jsxs)(y.Content,{align:`end`,sideOffset:4,children:[m?(0,$.jsx)(y.Item,{onSelect:a,children:`Edit`}):null,p?(0,$.jsx)(y.Item,{disabled:i,onSelect:o,children:`Set as default`}):null,h?(0,$.jsx)(y.Item,{onSelect:s,className:`text-[var(--system-negative-strong)] data-[highlighted]:text-[var(--system-negative-strong)]`,children:`Delete`}):null]})]}):(0,$.jsx)(`span`,{className:`inline-block w-8`,"aria-hidden":!0})]})})}function fr(e,t){let n=d(),r={path:{assistant_id:e}},i=p({...Ot(),onSuccess:()=>{n.invalidateQueries({queryKey:jt(r)}),n.invalidateQueries({queryKey:kt(r)}),n.invalidateQueries({queryKey:wt(r)})},onError:e=>{a(e,{context:`settings-ai-set-default-provider`}),B.error(`Failed to set the default provider. Please try again.`)}});function o(t){sr(t.provider)&&i.mutate({path:{assistant_id:e},body:{provider:t.provider,connectionName:t.name}})}function s(e){return i.isPending&&i.variables?.body?.connectionName===e}async function c(i){try{let{response:a}=await gt({path:{assistant_id:e,name:i}});a?.ok||a?.status===404?(n.invalidateQueries({queryKey:Ct(r)}),t?.onDeleted?.(i)):a?.status===409?B.error(`This provider is in use by a profile or as the default provider. Update those settings before deleting it.`):B.error(`Failed to delete the provider. Please try again.`)}catch(e){a(e,{context:`settings-ai-provider-delete`}),B.error(`Failed to delete the provider. Please try again.`)}}return{setDefault:o,isSettingDefault:s,deleteConnection:c}}var pr=`0.10.8`;function mr(){return at(pr)}function hr({assistantId:e,selectedConnectionName:t,onOpenConnection:n,onAddProvider:r,onConnectionDeleted:i}){let{data:a,isLoading:o,isError:s}=f(It({path:{assistant_id:e}})),l=mr(),{data:u}=f({...Mt({path:{assistant_id:e}}),enabled:l}),d=l?u?.resolvedConnectionName??null:null,p=fr(e,{onDeleted:i}),m=(0,Q.useMemo)(()=>{let e=a?.connections??[];return[...e.filter(e=>e.provider===W),...e.filter(e=>e.provider!==W)]},[a]);return(0,$.jsx)(In,{title:`Providers`,action:(0,$.jsx)(c,{variant:`outlined`,onClick:r,leftIcon:(0,$.jsx)(A,{}),children:`Add Provider`}),children:o?(0,$.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,$.jsx)(U,{className:`h-10 rounded-lg`},e))}):s?(0,$.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.`}):m.length===0?(0,$.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.`}):m.map(e=>(0,$.jsx)(dr,{connection:e,isDefault:e.name===d,supportsDefaultProvider:l,selected:e.name===t,isSettingDefault:p.isSettingDefault(e.name),onOpen:e.isManaged??!1?void 0:()=>n(e.name),onSetDefault:()=>p.setDefault(e),onDelete:()=>void p.deleteConnection(e.name)},e.name))})}function gr({panel:e,onOpenPanel:t,onClosePanel:n}){let r=un(),{data:i}=f({...Lt({path:{assistant_id:r}}),staleTime:3e4}),a=mr(),{data:o}=f({...Mt({path:{assistant_id:r}}),enabled:a}),s=o?.availability,{data:l}=f({...It({path:{assistant_id:r}})}),u=l?.connections,d=i?.llm?.callSites??{},p=Object.entries(d).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length;return(0,$.jsx)(xn,{title:`Language Model`,subtitle:`Profiles choose which model answers. Providers supply access to it`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[s&&s.status!==`ok`&&(0,$.jsx)(P,{tone:s.status===`unknown`?`warning`:`error`,children:s.message??`Your default provider is not available.`}),r&&(0,$.jsx)(ar,{assistantId:r,config:i,connections:u,selectedProfileName:e?.kind===`profile`?e.name:null,onOpenProfile:e=>t({kind:`profile`,name:e}),onCreateProfile:()=>t({kind:`create-profile`}),onProfileDeleted:t=>{e?.kind===`profile`&&e.name===t&&n()}}),r&&(0,$.jsx)(hr,{assistantId:r,selectedConnectionName:e?.kind===`provider`?e.name:null,onOpenConnection:e=>t({kind:`provider`,name:e}),onAddProvider:()=>t({kind:`add-provider`}),onConnectionDeleted:t=>{e?.kind===`provider`&&e.name===t&&n()}}),(0,$.jsx)(In,{title:`Overrides`,count:p,action:(0,$.jsx)(c,{variant:`outlined`,onClick:()=>t({kind:`overrides`}),children:`Manage`})})]})})}function _r(e,{onSaved:t}={}){let n=Jn(e),{data:r}=f({...Lt({path:{assistant_id:e}}),staleTime:3e4}),i=(0,Q.useMemo)(()=>r?.llm?.profiles??{},[r?.llm?.profiles]),o=r?.llm?.profileOrder??[];async function s(r,s,c){let l=c?.mode??`replace`,u=!(r in i);if(l===`merge`&&!u){await n.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[r]:s}}}}),t?.();return}let d={profiles:{[r]:s}};if(u&&(d.profileOrder=o.includes(r)?o:[...o,r]),u)await n.mutateAsync({path:{assistant_id:e},body:{llm:d}});else{let t=i[r];await n.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[r]:null}}}});try{await n.mutateAsync({path:{assistant_id:e},body:{llm:d}})}catch(i){throw a(i,{context:`settings-ai-profile-edit-recreate`}),t!=null&&await n.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[r]:t}}}}).catch(()=>{}),i}}u&&B.success(`Profile "${s.label??r}" created`),t?.()}return{saveProfile:s,isPending:n.isPending}}function vr({assistantId:e,profileName:t,onClose:n}){let{data:r}=f({...Lt({path:{assistant_id:e}}),staleTime:3e4}),{data:i}=f({...It({path:{assistant_id:e}})}),a=i?.connections,o=(0,Q.useMemo)(()=>r?.llm?.profiles??{},[r?.llm?.profiles]),s=Object.keys(o),l=(0,Q.useMemo)(()=>{if(t==null)return;let e=o[t];return e?{name:t,...e}:void 0},[t,o]),u=t==null?`create`:l?.source===`managed`||l?.invariant===!0?`view`:`edit`,{saveProfile:d,isPending:p}=_r(e,{onSaved:n}),m=Ge({mode:u,profileName:t??void 0,initialValues:l,existingNames:s,connections:a,assistantId:e,onSave:d}),h=rr(e,r,{onDeleted:()=>n()}),g=t!=null&&h.pendingDeleteName===t,_=t!=null&&r!=null&&!(t in o);(0,Q.useEffect)(()=>{_&&!m.saving&&!p&&n()},[_,m.saving,p,n]);let v=u===`view`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dn,{title:m.effectiveMode===`create`?`New Profile`:l?.label??t??`Profile`,closeVariant:`outlined`,onClose:n,headerTrailing:v&&m.effectiveMode!==`create`?(0,$.jsx)(F,{tone:`neutral`,children:`Managed by Vellum`}):null,headerActions:m.effectiveMode!==`create`&&!m.isReadOnly?(0,$.jsx)(c,{variant:`outlined`,size:`compact`,leftIcon:(0,$.jsx)(M,{}),tintColor:`var(--system-negative-strong)`,onClick:()=>{t!=null&&h.requestDelete(t)},disabled:m.saving||g,children:g?`Deleting…`:`Delete`}):null,footer:m.isReadOnly?(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(c,{variant:`outlined`,onClick:m.switchToSaveAsNew,disabled:m.saving,children:`Save As New`}),m.hasViewModeChanges?(0,$.jsx)(c,{variant:`primary`,onClick:()=>void m.handleSave(),disabled:m.saving,children:m.saving?`Saving…`:`Save`}):null]}):(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(c,{variant:`primary`,onClick:()=>void m.handleSave(),disabled:m.isInvalid||m.saving,children:m.saving?`Saving…`:m.effectiveMode===`create`?`Create Profile`:`Save Changes`})}),children:(0,$.jsx)(We,{editor:m,assistantId:e,connections:a,variant:`panel`})}),(0,$.jsx)(Un,{...h.blockedDeleteModalProps})]})}function yr({value:e,profileOptions:t,disabled:n,onChange:r}){return(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:`Advisor`}),(0,$.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`The profile your assistant consults for a second opinion when it wants to check a plan or review its own work.`})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,$.jsx)(H,{value:e,onChange:r,options:t,placeholder:`Choose profile…`,className:`w-44`,menuMinWidth:280,menuAlign:`end`,disabled:n})})]})})}var br=`__custom__`;function xr(e){return e?!!(e.profile||e.provider||e.model):!1}function Sr(e,t){if(t?.provider||t?.model)return null;let n=e.defaultProfile??e.shippedDefaultProfile;return n?{profile:n,via:t?.profile===n?`override`:`default`}:null}function Cr(e,t){let n=xr(e);return n===xr(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function wr(e){return`${e} ${e===1?`action`:`actions`}`}function Tr({assistantId:e,callSites:t,domains:n,persistedOverrides:r,orderedProfiles:i,onClose:o,onApplied:s}){let l=Jn(e),u=me(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u}),[u]),f=(0,Q.useMemo)(()=>{let e=new Map;for(let n of t){let t=Sr(n,r[n.id]);t&&e.set(n.id,t)}return e},[t,r]),p=(0,Q.useMemo)(()=>{let e=new Set(Array.from(f.values(),e=>e.profile));return i.filter(t=>e.has(t.name))},[i,f]),[m,g]=(0,Q.useState)(()=>p[0]?.name??``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(new Set),[x,S]=(0,Q.useState)(!1),C=(0,Q.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e.displayName]));return t=>e.get(t)??t},[n]),w=(0,Q.useMemo)(()=>t.filter(e=>f.get(e.id)?.profile===m),[t,f,m]),T=(0,Q.useMemo)(()=>w.map(e=>e.id).filter(e=>!y.has(e)),[w,y]),E=(0,Q.useMemo)(()=>p.map(e=>({value:e.name,label:pe(e)})),[p]),O=(0,Q.useMemo)(()=>de(i,[],d).filter(e=>e.name!==m).map(e=>({value:e.name,label:pe(e)})),[i,m,d]),A=oe(i,m),j=oe(i,_),M=y.size===0;function N(e){g(e),b(new Set),e===_&&v(``)}function F(e,t){b(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})}async function I(){if(!(!m||!_||T.length===0)){S(!0);try{let t={};for(let e of T)t[e]={profile:_};await l.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),B.success(`Updated ${wr(T.length)} to "${j}".`),s(),o()}catch(e){let t=ut(e);B.error(t??`Failed to update overrides. Please try again.`),t||a(e,{context:`settings-ai-bulk-override-swap`})}finally{S(!1)}}}return(0,$.jsx)(z.Root,{open:!0,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(z.Content,{size:`md`,children:[(0,$.jsx)(z.Header,{children:(0,$.jsx)(z.Title,{children:`Change Action Overrides`})}),(0,$.jsxs)(z.Body,{className:`space-y-4`,children:[(0,$.jsx)(h,{variant:`body-medium-default`,as:`p`,children:`Update the actions that currently use one profile. The result is saved as individual overrides.`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsx)(H,{id:`bulk-swap-source`,label:`Currently using`,value:m,onChange:N,options:E}),(0,$.jsx)(H,{id:`bulk-swap-target`,label:`Change to`,value:_,onChange:v,options:O,placeholder:`Select a profile…`})]}),(0,$.jsxs)(P,{tone:`info`,title:`This happens once.`,children:[`It changes the selected actions that use `,A,` today. It does not create an ongoing rule between profiles.`]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(h,{variant:`body-medium-default`,as:`p`,children:[wr(w.length),` currently`,` `,w.length===1?`uses`:`use`,` `,A]}),(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-[color:var(--content-secondary)]`,children:`Choose which actions to update.`})]}),(0,$.jsx)(c,{variant:`ghost`,onClick:()=>b(M?new Set(w.map(e=>e.id)):new Set),children:M?`Clear all`:`Select all`})]}),(0,$.jsx)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto`,children:w.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-[var(--border-base)] px-3 py-2`,children:[(0,$.jsx)(k,{checked:!y.has(e.id),onCheckedChange:t=>F(e.id,t===!0),disabled:x,label:e.displayName,helperText:C(e.domain)}),(0,$.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:f.get(e.id)?.via===`override`?`Override`:`Default`})]},e.id))})]})]}),(0,$.jsxs)(z.Footer,{children:[(0,$.jsxs)(h,{variant:`body-small-default`,as:`p`,className:`mr-auto self-center text-[color:var(--content-secondary)]`,children:[wr(T.length),` will change`]}),(0,$.jsx)(c,{variant:`ghost`,onClick:o,disabled:x,children:`Cancel`}),(0,$.jsx)(c,{variant:`primary`,disabled:!m||!_||T.length===0||x,onClick:()=>void I(),children:x?(0,$.jsx)(D,{className:`h-4 w-4 animate-spin`}):`Apply to ${wr(T.length)}`})]})]})})}function Er({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,onDraftChange:o,onToggle:s}){let c=xr(i),l=!i||!c?``:i.provider||i.model?br:i.profile??``,u=l===br,d=Ne(),f=d[0]??te[0],p=Z(i?.provider)?i.provider:void 0,m=p!==void 0&&d.some(e=>e===p),h=p??f,g=K(h).map(e=>({value:e.id,label:e.displayName})),_=!!i?.provider&&!i?.model;function v(t){t===`__custom__`?o(e,{profile:null,provider:f,model:q(f)??``}):t===``?o(e,null):o(e,{profile:t,provider:null,model:null})}function y(t){let n=q(t)??``;o(e,{...i??{},profile:null,provider:t,model:n})}function b(t){o(e,{...i??{},model:t})}return(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,$.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,$.jsxs)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:[`· Default: `,r]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c&&(0,$.jsx)(H,{value:l,onChange:v,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,$.jsx)(R,{checked:c,onChange:t=>s(e,t),"aria-label":`Override ${t}`})]})]}),c&&u&&(0,$.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:h??``,onChange:y,options:[...d.map(e=>({value:e,label:ee[e]??e})),...p&&!m?[{value:p,label:`${ee[p]??p} (unavailable)`}]:[]]})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,$.jsx)(H,{value:i?.model??``,onChange:b,options:g})]})]}),_&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:`Pick a model`})]})]})}function Dr({groups:e,drafts:t,buildProfileOptionsForRow:n,profileLabelFor:r,advisorMatchesSearch:i,onDraftChange:a,onToggle:o}){return(0,$.jsx)(`div`,{className:`space-y-4`,children:e.length===0?i?null:(0,$.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No actions match your search.`}):e.map(({domain:e,sites:i})=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,$.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>{let i=(()=>{let n=t[e.id]??null;return!n||!xr(n)?``:n.provider||n.model?br:n.profile??``})(),s=e.shippedDefaultProfile??e.defaultProfile,c=s?r(s):null;return(0,$.jsx)(Er,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:c,draft:t[e.id]??null,profileOptions:n(i===``||i===`__custom__`?null:i),onDraftChange:a,onToggle:o},e.id)})})]},e.id))})}function Or(e,t){let n={};for(let r of Object.keys(e)){let i=e[r]??null;xr(i)?n[r]={profile:i?.profile??null,provider:i?.provider??null,model:i?.model??null}:r in t&&t[r]===null&&(n[r]=null)}return n}function kr(e){let t={};for(let n of Object.keys(e))t[n]=null;return t}function Ar({catalogCallSiteIds:e,persistedOverrides:t,persistedAdvisor:n,isSeeded:r}){let[i,a]=(0,Q.useState)({}),[o,s]=(0,Q.useState)(void 0),c=(0,Q.useMemo)(()=>{if(!r)return{};let n={};for(let r of e)if(r in i)n[r]=i[r];else{let e=t[r];n[r]=e?{...e}:{}}return n},[r,e,t,i]),l=o??n,u=l!==n,d=(0,Q.useMemo)(()=>{if(!r)return!1;for(let e of Object.keys(c))if(!Cr(c[e],t[e]))return!0;return!1},[r,c,t]);return{drafts:c,advisorProfile:l,advisorDirty:u,callSiteDraftsDirty:d,hasUnsavedDrafts:u||d,hasValidationError:(0,Q.useMemo)(()=>Object.values(c).some(e=>xr(e)&&!!e?.provider&&!e?.model),[c]),setDraft:(0,Q.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[]),setAdvisor:(0,Q.useCallback)(e=>{s(e)},[]),clearEdits:(0,Q.useCallback)(()=>{a({}),s(void 0)},[]),buildSavePatch:(0,Q.useCallback)(()=>Or(c,i),[c,i]),buildResetPatch:(0,Q.useCallback)(()=>kr(c),[c])}}function jr({assistantId:e,onClose:t}){let{data:n}=f({...Lt({path:{assistant_id:e}}),staleTime:3e4}),r=(0,Q.useMemo)(()=>n?.llm?.profiles??{},[n?.llm?.profiles]),i=(0,Q.useMemo)(()=>n?.llm?.profileOrder??[],[n?.llm?.profileOrder]),o=(0,Q.useMemo)(()=>n?.llm?.callSites??{},[n?.llm?.callSites]),s=(0,Q.useMemo)(()=>ce(r,i),[r,i]),l=Ne(),u=me(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u}),[u]),p=Jn(e),[m,h]=(0,Q.useState)(``),[g,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),{data:C,isLoading:w,isError:T,refetch:E}=f({...Ft({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),O=(0,Q.useMemo)(()=>(C?.callSites??[]).filter(e=>e.id!==`mainAgent`),[C]),k=!w&&!T&&!!C,A=!!n,M=k&&A,N=(0,Q.useMemo)(()=>O.map(e=>e.id),[O]),P=n?.llm?.advisorProfile??``,{drafts:F,advisorProfile:I,advisorDirty:R,callSiteDraftsDirty:z,hasUnsavedDrafts:H,hasValidationError:U,setDraft:W,setAdvisor:G,clearEdits:K,buildSavePatch:ee,buildResetPatch:J}=Ar({catalogCallSiteIds:N,persistedOverrides:o,persistedAdvisor:P,isSeeded:M}),Y=(0,Q.useMemo)(()=>new Set(N),[N]),re=(0,Q.useCallback)(e=>oe(s,e),[s]),X=(0,Q.useCallback)(e=>({value:e.name,label:pe(e),...ue(e,s,d)===`undispatchable`?{icon:(0,$.jsx)(_,{className:`h-3.5 w-3.5 text-[var(--system-mid-strong)]`}),tooltip:ne(e)}:{}}),[s,d]),ie=(0,Q.useMemo)(()=>de(s,[P],d).map(X),[s,P,X,d]),ae=(0,Q.useMemo)(()=>{let e=m.trim().toLowerCase();return e===``||`advisor`.includes(e)||`second opinion`.includes(e)},[m]),Z=(0,Q.useMemo)(()=>O.some(e=>Sr(e,o[e.id])!==null),[O,o]),le=(0,Q.useMemo)(()=>Object.entries(o).some(([e,t])=>Y.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[o,Y]),fe=(0,Q.useCallback)(e=>[...de(s,[e],d).map(X),{value:br,label:`Custom`}],[s,X,d]),he=(0,Q.useMemo)(()=>{if(!m.trim())return O;let e=m.toLowerCase();return O.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[O,m]),ge=(0,Q.useMemo)(()=>{if(!C)return[];let e=C.domains.map(e=>e.id),t=new Map(C.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=he.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let r=new Set(e),i=he.filter(e=>!r.has(e.domain));return i.length>0&&n.push({domain:{id:`other`,displayName:`Other`},sites:i}),n},[C,he]),_e=(0,Q.useCallback)((e,t)=>{if(!t){W(e,null);return}let n=se(s,O.find(t=>t.id===e)?.defaultProfile,d);if(n)W(e,{profile:n});else{let t=l[0]??te[0];W(e,{provider:t,model:q(t)??``})}},[O,s,l,W,d]),ve=(0,Q.useCallback)(async()=>{v(!0);try{let n=ee();await p.mutateAsync({path:{assistant_id:e},body:{llm:{...z?{callSites:n}:{},...R?{advisorProfile:I}:{}}}}),t(),B.success(`Overrides saved.`)}catch(e){B.error(`Failed to save overrides. Please try again.`),a(e,{context:`call_site_overrides_save`})}finally{v(!1)}},[ee,z,R,I,t,p,e]),ye=(0,Q.useCallback)(async()=>{v(!0);try{let n=J();await p.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),B.success(`Overrides reset.`)}catch(e){B.error(`Failed to reset overrides. Please try again.`),a(e,{context:`call_site_overrides_reset`})}finally{v(!1)}},[J,t,p,e]);return(0,$.jsxs)(dn,{title:`Action Overrides`,closeVariant:`outlined`,onClose:t,footer:(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[le&&(0,$.jsx)(c,{variant:`outlined`,onClick:()=>b(!0),disabled:g||!M,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:`Reset to Defaults`}),(0,$.jsx)(c,{variant:`primary`,onClick:()=>void ve(),disabled:!H||U||g,children:g?(0,$.jsx)(D,{className:`h-4 w-4 animate-spin`}):`Save`})]}),children:[(0,$.jsx)(`p`,{className:`mb-4 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Customize which model profile specific actions should use. Uses your default profile if no override is set.`}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(L,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:`Search actions…`,leftIcon:(0,$.jsx)(j,{className:`h-4 w-4`}),fullWidth:!0})}),(0,$.jsx)(c,{variant:`outlined`,onClick:()=>S(!0),disabled:!M||g||H||!Z,title:H?`Save or reset your changes first`:Z?void 0:`No actions currently use a profile`,children:`Bulk change`})]}),A&&ae&&(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:`Advisor`}),(0,$.jsx)(yr,{value:I,profileOptions:ie,disabled:g,onChange:G})]}),w&&(0,$.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,$.jsx)(D,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),T&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Couldn't load actions`}),(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Make sure your assistant is running`}),(0,$.jsx)(c,{variant:`outlined`,onClick:()=>void E(),children:`Retry`})]}),!w&&!T&&C&&(0,$.jsx)(Dr,{groups:ge,drafts:F,buildProfileOptionsForRow:fe,profileLabelFor:re,advisorMatchesSearch:ae,onDraftChange:W,onToggle:_e})]}),x&&C&&(0,$.jsx)(Tr,{assistantId:e,callSites:O,domains:C.domains,persistedOverrides:o,orderedProfiles:s,onClose:()=>S(!1),onApplied:K}),(0,$.jsx)(V,{open:y,title:`Reset to Defaults`,message:`Every action override will be reset and will follow its default. This cannot be undone.`,confirmLabel:`Reset to Defaults`,destructive:!0,onConfirm:()=>{b(!1),ye()},onCancel:()=>b(!1)})]})}function Mr({mode:e,connection:t,assistantId:n,existingNames:r,connections:i,variant:a=`modal`,onSave:o,onCancel:s}){let[l,u]=(0,Q.useState)(t?.label??``),f=t?.name??``,p=t?.provider??`anthropic`,m=t?.auth.type??`api_key`,[g,_]=(0,Q.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[v,y]=(0,Q.useState)(t?.baseUrl??``),[b,x]=(0,Q.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),E=p===`openai-compatible`,[D,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(!1),j=d(),M=(0,Q.useMemo)(()=>Me(g),[g]),N=m===`api_key`&&M!==null,{hasStoredCredential:P,isLoading:F}=be({assistantId:n,credentialKind:`credential`,credentialName:M?`${M.service}:${M.field}`:``,enabled:N}),{credentials:I}=Oe({assistantId:n,enabled:m===`api_key`});(0,Q.useEffect)(()=>{let e=t?.provider??`anthropic`;u(t?.label??``),t?.auth.type===`api_key`?_(t.auth.credential):_(t?``:`credential/${e}/api_key`),T(null),y(t?.baseUrl??``),x(t?.models?t.models.map(e=>e.id).join(`, `):``),O(``),A(!1)},[t]);let R=l.trim()!==(t?.label??``).trim(),B=E&&R?Ee(l,i,t?.name):null,V=f.trim().length>0&&B===null;async function H(){if(V){C(!0),T(null);try{let e;if(m===`api_key`){let t=g.trim()||`credential/${p}/api_key`,r=D.trim();if(r){A(!0);try{let e=Me(t);await pt({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:p,value:r},throwOnError:!0});let i=rt(n,`credential`,e?`${e.service}:${e.field}`:``);j.setQueryData(i,!0),j.invalidateQueries({queryKey:Rt({path:{assistant_id:n}})})}catch{T(`Failed to save API key. Please try again.`);return}finally{A(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{T(`Nothing to edit. Close and try again.`);return}let r=l.trim()||null,i={auth:e,label:r,...E&&{base_url:v.trim()||null,models:b.trim()?b.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:a,error:s,response:c}=await dt({path:{assistant_id:n,name:t?.name??f.trim()},body:i});if(!c?.ok){T(Ce(c?.status,s)??we(c?.status));return}if(!a){T(`Server returned an empty response. Please try again.`);return}o(a)}catch{T(`Failed to save provider. Please try again.`)}finally{C(!1)}}}let U=I.filter(e=>e.service===p),W=e!==`create`&&t?.auth.type===`api_key`,G=U.length>0||W,K=ke(`Enter your API key`,P);if(e===`create`)return(0,$.jsx)(De,{variant:a===`panel`?`inline`:`modal`,assistantId:n,existingNames:r,connections:i,defaultProviderType:p,onCreated:o,onCancel:s});let ee=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[`Display Name`,` `,(0,$.jsx)(`span`,{className:`text-[var(--content-disabled)]`,children:`(optional)`})]}),(0,$.jsx)(L,{value:l,onChange:e=>u(e.target.value),placeholder:`e.g. My Anthropic Key`,fullWidth:!0}),B?(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:Te[B]}):null]}),E&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,$.jsx)(L,{value:v,onChange:e=>y(e.target.value),placeholder:`https://api.example.com/v1`,fullWidth:!0})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,$.jsx)(L,{value:b,onChange:e=>x(e.target.value),placeholder:`model-1, model-2`,fullWidth:!0}),(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),m===`api_key`&&(0,$.jsx)(Se,{apiKeyValue:D,onApiKeyChange:O,credential:g,onCredentialChange:_,isLoadingCredential:F,apiKeyPlaceholder:K,provider:p,providerCredentials:U,showAdvancedSection:G,onError:T}),m===`oauth_subscription`&&(0,$.jsx)(Ae,{assistantId:n,onConnected:o}),w&&(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:w})]}),q=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(c,{variant:`ghost`,size:`compact`,onClick:s,children:`Cancel`}),(0,$.jsx)(c,{variant:`primary`,size:`compact`,disabled:!V||S||k,onClick:()=>void H(),children:S?`Saving…`:`Save Changes`})]});return a===`panel`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[ee,(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:q})]}):(0,$.jsxs)(z.Content,{size:`md`,children:[(0,$.jsxs)(z.Header,{children:[(0,$.jsx)(z.Title,{children:`Edit Provider`}),(0,$.jsx)(z.Description,{children:t?`Editing ${Pe(t)}.`:`Edit provider settings.`})]}),(0,$.jsx)(z.Body,{children:ee}),(0,$.jsx)(z.Footer,{children:q})]})}function Nr({assistantId:e,connectionName:t,onClose:n}){let r=d(),{data:i}=f(It({path:{assistant_id:e}})),a=(0,Q.useMemo)(()=>i?.connections??[],[i]),o=(0,Q.useMemo)(()=>t==null?void 0:a.find(e=>e.name===t),[t,a]),s=t!=null&&i!=null&&o==null;(0,Q.useEffect)(()=>{s&&n()},[s,n]);function c(){r.invalidateQueries({queryKey:Ct({path:{assistant_id:e}})}),r.invalidateQueries({queryKey:jt({path:{assistant_id:e}})}),n()}return(0,$.jsx)(dn,{title:o?Pe(o):`Add Provider`,closeVariant:`outlined`,onClose:n,children:t==null||o!=null?(0,$.jsx)(Mr,{mode:o?`edit`:`create`,connection:o,variant:`panel`,assistantId:e,existingNames:a.map(e=>e.name),connections:a,onSave:c,onCancel:n}):null})}var Pr={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},Fr={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},Ir=`deepgram`;function Lr({assistantId:e,hideSaveButton:r=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=un(),s=e??o,c=xt(),l=d(),[u]=(0,Q.useState)(()=>nt.filter(e=>!e.requiresNativeDictation||xe())),p=Ir,{data:m}=f({...Lt({path:{assistant_id:s}}),enabled:c,staleTime:3e4}),h=m?.services?.stt,g=h?.mode===`managed`?`vellum`:h?.provider,_=(0,Q.useMemo)(()=>{let e=g?Fr[g]:void 0;if(e&&u.some(t=>t.id===e))return e;let n=t(Re,p);return u.some(e=>e.id===n)?n:p},[g,u,p]),v=!!g,[y,b]=jn(_),{available:x,currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T}=rn(s),[E,D]=(0,Q.useState)(!1),O=x&&y===_&&(Pr[y]?.provider===C||!!g&&!Fr[g]),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=t(Re,p);e===`macos-native`&&!u.some(t=>t.id===e)&&n(Re,p)},[u,p]);let I=(0,Q.useMemo)(()=>u.find(e=>e.id===y)??u[0],[u,y]),R=I.apiKeyPlaceholder!==void 0;(0,Q.useEffect)(()=>{M(t(Qe+y,``).length>0),A(``)},[y]);let z=(0,Q.useMemo)(()=>{let e=y!==_,t=k.trim().length>0;return e||t},[y,_,k]),V=(0,Q.useCallback)(async()=>{let e=k.trim();n(Re,y),e.length>0&&n(Qe+y,e);let r=Pr[y];F(!0);try{if(r?.credentialService){let n=e.length>0?e:t(Qe+y,``);if(n.length>0){let{response:e}=await ht({path:{assistant_id:s},body:{service:r.credentialService,field:`api_key`,value:n,label:`${I.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(r&&(y!==_||!v)||g===`vellum`&&y!==`vellum`){let e=r?.provider??Ir,{response:t}=await mt({path:{assistant_id:s},body:{services:{stt:{provider:e,mode:e===`vellum`?`managed`:`your-own`}}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return e.length>0&&M(!0),A(``),l.invalidateQueries({queryKey:kt({path:{assistant_id:s}})}),B.success(`Speech-to-text settings saved`),!0}catch(e){return B.error(e instanceof Error?e.message:`Failed to save speech-to-text settings`),!1}finally{F(!1)}},[s,y,k,I,_,v,g,l]);(0,Q.useEffect)(()=>{a?.({hasChanges:z,saving:P,save:V})},[a,z,P,V]);let U=(0,Q.useCallback)(()=>{n(Qe+y,``),M(!1),A(``)},[y]),W=j?`•••••••• (Enter a new key to replace)`:I.apiKeyPlaceholder;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:y,onChange:b,options:u.map(e=>({value:e.id,label:e.displayName})),"aria-label":`STT provider`})]}),O&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Spoken language`}),(0,$.jsx)(Je,{"aria-label":`Spoken language`,"aria-haspopup":`dialog`,onClick:()=>D(!0),value:an(S,C)}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Applies from your next spoken turn.`}),(0,$.jsx)(vn,{open:E,onOpenChange:D,title:`Spoken language`,currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T})]}),R&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,$.jsx)(L,{type:`password`,value:k,onChange:e=>A(e.target.value),placeholder:W,fullWidth:!0})]}),I.setupWarning&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(N,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,$.jsx)(`span`,{children:I.setupWarning})]}),!i&&I.credentialsGuide&&(0,$.jsx)(En,{guide:I.credentialsGuide}),y===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Transcription runs through your Vellum account.`}),(!r||j)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[!r&&(0,$.jsx)(wn,{onClick:V,disabled:!z||P}),j&&(0,$.jsx)(Tn,{onClick:U})]})]})}function Rr(){return(0,$.jsx)(xn,{title:`Speech-to-Text`,subtitle:`Configure how your assistant transcribes speech`,children:(0,$.jsx)(Lr,{})})}async function zr(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 Br(n,r,i):t===`deepgram`?await Vr(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 Br(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 Hr(i,`ElevenLabs rejected the request.`)}}async function Vr(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 Hr(n,`Deepgram rejected the request.`)}}async function Hr(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 Ur({assistantId:e,value:t,onChange:n,className:r}){let[i,a]=(0,Q.useState)(!1),{voices:o}=cn(e);if(o.length===0)return null;let s=o.find(e=>e.model===t)??o[0];return(0,$.jsxs)(I.Root,{open:i,onOpenChange:a,children:[(0,$.jsx)(I.Trigger,{asChild:!0,children:(0,$.jsx)(Je,{"aria-label":`Voice`,value:s?on(s.description):`Select a voice`,className:r})}),(0,$.jsx)(I.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,$.jsx)(sn,{assistantId:e,value:t,onChange:n,onSelect:()=>a(!1),showSource:!0})})]})}var Wr={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function Gr({assistantId:e,hideSaveButton:r=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=un(),s=e??o,l=it.use.name()??`your assistant`,u=xt(),p=d(),{data:m}=f({...Et({path:{assistant_id:s}}),enabled:u,staleTime:1/0}),h=(0,Q.useMemo)(()=>{let e=m?.providers;if(!e)return Le;if(e.some(e=>e.id===`vellum`))return e;let t=Le.find(e=>e.id===`vellum`);return t?[t,...e]:e},[m]),{data:g}=f({...Lt({path:{assistant_id:s}}),enabled:u,staleTime:3e4}),_=g?.services?.tts,v=_?.mode===`managed`?`vellum`:_?.provider,y=`elevenlabs`,b=(0,Q.useMemo)(()=>v??t(`vellum:voice:ttsProvider`,y),[v,y]),x=!!v,[S,C]=jn(b),[w,T]=(0,Q.useState)(``),[D,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),{voices:R,defaultModel:z,fetched:V}=ln(s,{enabled:S===`vellum`}),U=_?.providers?.vellum?.model??z??``,[W,G]=jn(U),K=R.find(e=>e.model===W)??R[0],[ee,q]=(0,Q.useState)(null),J=R.some(e=>e.model===U),te=ee??(V&&U!==``&&!J),Y=(0,Q.useMemo)(()=>h.find(e=>e.id===S)??h[0],[S,h]),ne=S===`vellum`&&Y.supportsVoiceSelection&&W.trim()!==``&&W.trim()!==U,re=(0,Q.useCallback)(e=>{let n=t(Ke+e,``),r=t(ze+e,``);M(n.length>0),O(r),A(r),T(``)},[]);(0,Q.useEffect)(()=>{re(S)},[S,re]);let X=(0,Q.useMemo)(()=>{let e=S!==b,t=w.trim().length>0,n=D.trim()!==k;return e||t||n||ne},[S,b,w,D,k,ne]),ie=(0,Q.useCallback)(async()=>{let e=w.trim(),r=D.trim(),i=Y.id;n(et,i),e.length>0&&n(Ke+i,e),n(ze+i,r);let a=e.length>0?e:t(Ke+i,``),o=Wr[i];I(!0);try{if(a.length>0){let{response:e}=await ht({path:{assistant_id:s},body:{service:i,field:`api_key`,value:a,label:`${Y.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]:r}}}:{},...ne?{providers:{vellum:{model:W.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await mt({path:{assistant_id:s},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return M(a.length>0),A(r),T(``),p.invalidateQueries({queryKey:kt({path:{assistant_id:s}})}),B.success(`Text-to-speech settings saved`),!0}catch(e){return B.error(e instanceof Error?e.message:`Failed to save text-to-speech settings`),!1}finally{I(!1)}},[s,S,W,ne,w,D,Y,b,x,p]);(0,Q.useEffect)(()=>{a?.({hasChanges:X,saving:F,save:ie})},[a,X,F,ie]);let ae=(0,Q.useCallback)(()=>{n(Ke+S,``),M(!1),T(``)},[S]),oe=(0,Q.useCallback)(async()=>{P(!0);try{let e=t(Ke+S,``),n=w.trim(),r=n.length>0?n:e;if(r.length===0){B.error(`Save an API key for this provider before testing.`);return}let i=t(ze+S,``),a=D.trim(),o=await zr({provider:S,apiKey:r,voiceId:a.length>0?a:i,text:`Hey! It's ${l}. How does this sound?`});if(o.kind!==`audio`){B.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{P(!1)}},[l,w,S,D]),se=j?`•••••••• (Enter a new key to replace)`:Y.apiKeyPlaceholder,Z=S===`vellum`,ce=Z&&Y.supportsVoiceSelection,le=(0,$.jsxs)(c,{variant:`link`,size:`compact`,className:`inline-flex h-auto items-center gap-1 px-0 underline [--vbtn-fg:var(--content-tertiary)]`,onClick:()=>{q(!1),R.some(e=>e.model===W)||G(z||R[0]?.model||``)},children:[(0,$.jsx)(E,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Choose from catalog`]}),ue=ce&&te&&R.length>0?le:null;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:S,onChange:C,options:h.map(e=>({value:e.id,label:e.displayName})),"aria-label":`TTS provider`})]}),!Z&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,$.jsx)(L,{type:`password`,value:w,onChange:e=>T(e.target.value),placeholder:se,fullWidth:!0})]}),ce&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice`}),te?(0,$.jsx)(L,{type:`text`,value:W,onChange:e=>G(e.target.value),placeholder:`Enter a voice ID`,"aria-label":`Custom voice ID`,fullWidth:!0}):K?(0,$.jsx)(Ur,{assistantId:s,value:W,onChange:G}):V&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`No managed voices are currently available.`})]}),Y.supportsVoiceSelection&&!Z&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice ID`}),(0,$.jsx)(L,{type:`text`,value:D,onChange:e=>O(e.target.value),placeholder:`Enter a voice ID`,fullWidth:!0})]}),!i&&!Z&&(0,$.jsx)(En,{guide:Y.credentialsGuide}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!Z&&(0,$.jsx)(c,{variant:`outlined`,onClick:oe,disabled:N,children:N?`Testing…`:`Test`}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[ue,!r&&(0,$.jsx)(wn,{onClick:ie,disabled:!X||F}),j&&!Z&&(0,$.jsx)(Tn,{onClick:ae})]})]})]})}function Kr(){return(0,$.jsx)(xn,{id:`text-to-speech`,title:`Text-to-Speech`,subtitle:`Configure how your assistant speaks`,children:(0,$.jsx)(Gr,{})})}var qr=`default`;function Jr(){let e=un(),i=d(),{data:o}=f({...Lt({path:{assistant_id:e}}),staleTime:3e4}),s=Dt({onSuccess:t=>{At(i,{path:{assistant_id:e}},t)}}),c=An(),l=(0,Q.useMemo)(()=>o?o.services?.[`web-fetch`]?.provider||t(`vellum:ai:webFetchProvider`,qr):t(Be,qr),[o]),[u,p]=(0,Q.useState)(!1),[m,h]=jn(l),[g,_]=(0,Q.useState)(``),v=re.has(m),{hasStoredCredential:y}=be({assistantId:e,credentialKind:`api_key`,credentialName:m,enabled:v}),b=g.trim().length>0,x=u||v&&!y&&!b||m===l&&!b,S=ke(G[m]??`Enter your API key`,y),C=(0,Q.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 B.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(Be,m),r){let r=ie(m);r&&n(r,t);let a=rt(e,`api_key`,m);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),_(``)}B.success(`Web fetch settings saved.`)}catch(e){a(e,{context:`settings-ai-web-fetch-persist-local`}),B.error(`Saved, but local preferences could not be written.`)}},[v,s,c,i,e,g,m]),w=(0,Q.useCallback)(()=>{let e=ie(m);e&&r(e),_(``),h(qr),n(Be,qr)},[m,h]);return(0,$.jsx)(xn,{id:`web-fetch`,title:`Web Fetch`,subtitle:`Configure how your assistant reads individual web pages`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:m,onChange:h,options:J.map(e=>({value:e,label:_e[e]??e}))})]}),v&&(0,$.jsx)(L,{label:`API Key`,type:`password`,value:g,onChange:e=>_(e.target.value),placeholder:S,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(wn,{onClick:C,disabled:x}),u&&(0,$.jsx)(D,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),v&&(0,$.jsx)(Tn,{onClick:w,filled:!0})]})]})})}var Yr=`0.10.12`;function Xr(){return ot(Yr)}function Zr(){let e=un(),i=d(),o=xt(),{data:s}=f({...Lt({path:{assistant_id:e}}),enabled:o,staleTime:3e4}),c=Dt({onSuccess:t=>{At(i,{path:{assistant_id:e}},t)}}),l=An(),u=(0,Q.useMemo)(()=>{if(!s)return t(Xe,`inference-provider-native`);let e=s.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||t(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[s]),[p,m]=(0,Q.useState)(!1),[h,g]=jn(u),[_,v]=(0,Q.useState)(``),y=ae.has(h),{hasStoredCredential:b}=be({assistantId:e,credentialKind:`api_key`,credentialName:h,enabled:y}),x=_.trim().length>0,S=p||y&&!b&&!x||h===u&&!x,C=ke(ve[h]??`Enter your API key`,b),w=(0,Q.useCallback)(async()=>{m(!0);let t=_.trim(),r=fe(h),o=y&&t.length>0;try{o&&await l(h,t),await st();let n=h===`vellum`?Xr()?{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 B.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=rt(e,`api_key`,h);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),v(``)}B.success(`Web search settings saved.`)}catch(e){a(e,{context:`settings-ai-web-search-persist-local`}),B.error(`Saved, but local preferences could not be written.`)}},[y,c,l,i,e,_,h]),T=(0,Q.useCallback)(()=>{let e=fe(h);e&&r(e),v(``),g(`inference-provider-native`),n(Xe,`inference-provider-native`)},[h,g]);return(0,$.jsx)(xn,{title:`Web Search`,subtitle:`Configure how your assistant should search the web`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{"aria-label":`Web search provider`,value:h,onChange:g,options:ge.map(e=>({value:e,label:Y[e]??e}))})]}),h===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Search runs through your Vellum account.`}),y&&(0,$.jsx)(L,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:C,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(wn,{onClick:w,disabled:S}),p&&(0,$.jsx)(D,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),y&&(0,$.jsx)(Tn,{onClick:T,filled:!0})]})]})})}function Qr(){let e=un(),t=Bt(),[n,r]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]);let i=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto`,children:[(0,$.jsx)(Sn,{}),(0,$.jsx)(gr,{panel:n,onOpenPanel:r,onClosePanel:()=>r(null)}),(0,$.jsx)(Zr,{}),(0,$.jsx)(Jr,{}),(0,$.jsx)(kn,{}),(0,$.jsx)(Fn,{}),(0,$.jsx)(Kr,{}),(0,$.jsx)(Rr,{})]}),a=`${e??`none`}:${n?.kind===`profile`?`profile:${n.name}`:n?.kind===`provider`?`provider:${n.name}`:n?.kind??`closed`}`,o=n?.kind===`provider`||n?.kind===`add-provider`,s=n!=null&&e?n.kind===`overrides`?(0,$.jsx)(jr,{assistantId:e,onClose:()=>r(null)},a):o?(0,$.jsx)(Nr,{assistantId:e,connectionName:n.kind===`provider`?n.name:null,onClose:()=>r(null)},a):(0,$.jsx)(vr,{assistantId:e,profileName:n.kind===`profile`?n.name:null,onClose:()=>r(null)},a):null;return s&&t?(0,$.jsx)(mn,{children:s}):s?(0,$.jsx)(hn,{storageKey:`aiSettingsDetailDrawerWidth`,detailKey:a,section:i,detail:s}):i}export{Qr as AiPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,l as n,o as r}from"./local-settings-Bx7FsNo5.js";import{r as i,t as a}from"./capture-error-Cw5vs0Ef.js";import{t as o}from"./react-BFJW0bSv.js";import{n as s,t as c}from"./button-BENY-yx_.js";import{d as l,h as u}from"./chunk-5KNZJZUH-BUqIilZr.js";import{n as d}from"./QueryClientProvider-CMu7CkQU.js";import{t as f}from"./useQuery-Bz-fbQ-m.js";import{t as p}from"./useMutation-CXGTrp4W.js";import{t as m}from"./jsx-runtime-D3ZM-ToX.js";import{t as h}from"./typography-BeUa5Fd-.js";import{t as g}from"./check-DSgjgwlo.js";import{t as _}from"./circle-alert-De9q5FVd.js";import{t as v}from"./circle-check-q8BVdbgw.js";import{t as y}from"./menu-DKE_-iVc.js";import{t as b}from"./clock-B8umTTHk.js";import{B as x,i as S}from"./src-DyqTPMO2.js";import{t as C}from"./ellipsis-vertical-eVgdKn9z.js";import{t as w}from"./external-link-vwewPjbo.js";import{t as T}from"./info-CXkwGlN_.js";import{t as E}from"./list-O_53kvwx.js";import{t as D}from"./loader-circle-DOtGXcds.js";import{t as O}from"./mail-CYjppw70.js";import{t as k}from"./checkbox-C4x4HEp4.js";import{t as A}from"./plus-DnH9Pjq4.js";import{t as j}from"./search-D2xMZu1P.js";import{t as M}from"./trash-2-BKXSi5Tj.js";import{t as N}from"./triangle-alert-CB4pJgCL.js";import{t as P}from"./notice-C0ifrvvJ.js";import{t as F}from"./tag-DeMzQvCo.js";import{t as I}from"./popover-CAbJ9178.js";import{t as L}from"./input-DmHXRXaB.js";import{t as R}from"./toggle-C-v4x7_A.js";import{t as z}from"./modal-DI63s9MQ.js";import{n as B}from"./toast-BpuLSxyt.js";import{t as V}from"./confirm-dialog-zx8L9sUi.js";import{t as H}from"./select-B8-i-CZ4.js";import{t as U}from"./skeleton-CJJwPIil.js";import{A as W,C as G,I as K,N as ee,P as q,S as J,T as te,_ as Y,a as ne,b as re,c as X,f as ie,g as ae,h as oe,i as se,j as Z,l as ce,m as le,n as ue,o as de,p as fe,r as pe,s as me,t as he,v as ge,x as _e,y as ve}from"./profile-pickers-ChG4_Gpc.js";import{A as ye,B as be,C as xe,F as Se,G as Ce,H as we,I as Te,L as Ee,M as De,N as Oe,P as ke,R as Ae,S as je,U as Me,V as Ne,W as Pe,_ as Fe,a as Ie,b as Le,c as Re,d as ze,f as Be,g as Ve,h as He,i as Ue,j as We,k as Ge,l as Ke,m as qe,n as Je,o as Ye,p as Xe,r as Ze,s as Qe,t as $e,u as et,x as tt,y as nt,z as rt}from"./use-sticky-profiles-5cPu_MUo.js";import{t as it}from"./assistant-identity-store-nE-e8KQw.js";import{i as at,n as ot,o as st,r as ct}from"./utils-CVoSWh7U.js";import{i as lt,r as ut}from"./api-errors-BQX1Pzcm.js";import{Jt as dt,On as ft,dr as pt,j as mt,pt as ht,qt as gt,ut as _t}from"./sdk.gen-CBPZ2IdN.js";import{f as vt}from"./platform-detection-C_TK32Dw.js";import{d as yt}from"./routes-iipg2wkc.js";import{i as bt}from"./use-platform-gate-2lhRAyKS.js";import{r as xt}from"./use-is-org-ready-CQntk0MX.js";import{G as St,J as Ct,K as wt,St as Tt,Wt as Et,Yt as Dt,_ as Ot,d as kt,f as At,g as jt,h as Mt,m as Nt,on as Pt,p as Ft,q as It,u as Lt,wt as Rt,xt as zt}from"./react-query.gen-DxjuNs-5.js";import{n as Bt}from"./use-is-mobile-BP8UePsY.js";import{c as Vt,d as Ht,f as Ut,g as Wt,h as Gt,l as Kt,m as qt,o as Jt,p as Yt,s as Xt,u as Zt,ut as Qt,v as $t,y as en}from"./react-query.gen-DKb3mEwJ.js";import{t as tn}from"./platform-login-notice-BEDBlins.js";import{t as nn}from"./android-consumption-only-BkXIkXls.js";import{a as rn,c as an,i as on,n as sn,o as cn}from"./voice-list-BS2BNjKN.js";import{n as ln}from"./use-voice-sample-preview-CzqJYPiZ.js";import{t as un}from"./use-active-assistant-id-BvHP5Ojg.js";import{t as dn}from"./detail-shell-PCaxY4Tf.js";import{a as fn}from"./schedules-kVuR00ra.js";import{t as pn}from"./detail-card-hWrhardR.js";import{n as mn,t as hn}from"./detail-drawer-s-zfqqMy.js";import{t as gn}from"./use-platform-assistant-id-DMP9urFb.js";import{t as _n}from"./environment-store-CFfbiF-5.js";import{t as vn}from"./stt-language-picker-modal-BiWHaqFq.js";var Q=e(o(),1),$=m();function yn({mode:e,onChange:t}){return(0,$.jsx)(`div`,{className:`max-w-[280px]`,children:(0,$.jsx)(x,{ariaLabel:`Service mode`,value:e,onChange:t,items:[{value:`managed`,label:`Managed`},{value:`your-own`,label:`Your Own`}]})})}function bn({id:e,title:t,subtitle:n,mode:r,onModeChange:i,children:a}){return(0,$.jsxs)(pn,{id:e,title:t,subtitle:n,accessory:(0,$.jsx)(yn,{mode:r,onChange:i}),children:[(0,$.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,$.jsx)(`div`,{className:`mt-4`,children:a})]})}function xn({id:e,title:t,subtitle:n,children:r}){return(0,$.jsxs)(pn,{id:e,title:t,subtitle:n,children:[(0,$.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,$.jsx)(`div`,{className:`mt-4`,children:r})]})}function Sn(){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-4 py-2.5`,children:[(0,$.jsx)(T,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,$.jsxs)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:[`Managed services are metered and deducted from your Vellum account balance.`,` `,(0,$.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,$.jsx)(w,{className:`h-3.5 w-3.5`})]})]})]})}function Cn({status:e,message:t,isLoading:n}){return n?(0,$.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,$.jsx)(D,{className:`h-3 w-3 animate-spin`}),`Checking domain…`]}):e?e===`verified`?(0,$.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,$.jsx)(g,{className:`h-3 w-3`}),`Domain verified`]}):e===`pending`||e===`not_started`?(0,$.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,$.jsx)(b,{className:`h-3 w-3`}),`Verifying domain…`]}):(0,$.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,$.jsx)(_,{className:`h-3 w-3`}),`Verification failed`]}):(0,$.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 wn({onClick:e,disabled:t}){return(0,$.jsx)(c,{onClick:e,disabled:t,children:`Save`})}function Tn({onClick:e,filled:t=!1}){return(0,$.jsx)(c,{variant:t?`danger`:`dangerGhost`,onClick:e,children:`Reset`})}function En({guide:e}){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(T,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{children:e.description}),(0,$.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,$.jsx)(w,{className:`h-3 w-3`})]})]})]})}function Dn({subdomain:e,onSubdomainChange:t,domainSuffix:n,subdomainPlaceholder:r=`my-assistant`,disabled:i,autoFocus:a,prefix:o,error:s,locked:c,lockedMessage:l}){return(0,$.jsxs)(`div`,{children:[(0,$.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,$.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,$.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`.`,n]})]}),s&&(0,$.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--system-negative-strong)]`,children:s}),c&&l&&(0,$.jsx)(`p`,{className:`mt-1.5 text-body-small-default text-[var(--content-tertiary)]`,children:l})]})}function On({assistantId:e,assistantHandle:t,emailRootDomain:n}){let r=d(),i=l(),o=vt(),[s,m]=u(),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,N]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{_||!t||h||(g(t),v(!0))},[t,_,h]);let F=f({...Qt(),enabled:!0}),I=F.data,L=I?.entitlements,R=L?.managed_email===!0,z=!!L&&!R,H=!I&&F.isError&&!F.isFetching,U=f({...Vt({path:{assistant_id:e}}),enabled:!z}),W=f({...Yt({path:{assistant_id:e}}),enabled:!z}),G=U.data?.results?.[0],K=W.data?.results?.[0],ee=G?`${G.subdomain}.${n}`:null,q=f({...Gt({path:{assistant_id:e,id:K?.id??``}}),enabled:!!K?.id,refetchOnWindowFocus:!1}),J=f({...Zt({path:{assistant_id:e,id:G?.id??``}}),enabled:!!G?.id,refetchInterval:e=>{let t=e.state.data?.status;return t===`verified`||t===`failed`?!1:1e4},refetchOnWindowFocus:!0});(0,Q.useEffect)(()=>{s.get(`release`)!==`1`||!G||K||(A(!0),m(e=>{let t=new URLSearchParams(e);return t.delete(`release`),t},{replace:!0}))},[K,G,s,m]);let te=p(Jt()),Y=p(Xt()),ne=p(Ht()),re=p(Ut()),X=(0,Q.useCallback)(()=>{let t={assistant_id:e};r.invalidateQueries({queryKey:Kt({path:t})}),r.invalidateQueries({queryKey:qt({path:t})}),K?.id&&r.invalidateQueries({queryKey:Wt({path:{...t,id:K.id}})}),r.invalidateQueries({queryKey:en()})},[K?.id,e,r]),ie=(0,Q.useCallback)(async()=>{let t=h.trim().toLowerCase();if(!t){b(`Enter a subdomain.`);return}E(!1);try{await te.mutateAsync({path:{assistant_id:e},body:{subdomain:t}}),g(``),b(null),X(),B.success(`Domain ${t}.${n} registered.`)}catch(e){b(lt(e,void 0,`Failed to register domain.`))}},[e,n,X,te,h]),ae=(0,Q.useCallback)(async()=>{let t=x.trim().toLowerCase();if(!t){w(`Enter an email username.`);return}try{await ne.mutateAsync({path:{assistant_id:e},body:{username:t}}),S(``),w(null),X(),B.success(`Email address created.`)}catch(e){w(lt(e,void 0,`Failed to create email address.`))}},[e,X,ne,x]),oe=(0,Q.useCallback)(async()=>{if(K?.id){N(!1);try{await re.mutateAsync({path:{assistant_id:e,id:K.id}}),X(),B.success(`Email address removed.`)}catch(e){a(e,{context:`email_address_delete`}),B.error(`Failed to remove email address.`)}}},[K?.id,e,re,X]),se=(0,Q.useCallback)(async()=>{if(!G?.id)return;if(K){B.error(`Remove the email address first.`);return}A(!1);let t=G.subdomain;try{await Y.mutateAsync({path:{assistant_id:e,id:G.id}}),g(t),X(),B.success(`Domain released.`)}catch(e){a(e,{context:`email_domain_release`}),B.error(`Failed to release domain.`)}},[K,e,Y,G?.id,G?.subdomain,X]);if(F.isLoading)return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Checking subscription…`]});if(z)return(0,$.jsx)(P,{tone:`info`,icon:(0,$.jsx)(O,{className:`h-4 w-4`,"aria-hidden":!0}),title:`Give your assistant its own email address`,actions:o?void 0:(0,$.jsx)(c,{size:`compact`,onClick:()=>i(yt.plans),children:`Upgrade`}),children:o?nn:(0,$.jsx)($.Fragment,{children:`Upgrade to a plan that includes an email address for your assistant. No provider setup required.`})});let Z=H?(0,$.jsx)(P,{tone:`warning`,title:`Couldn't verify subscription status`,actions:(0,$.jsx)(c,{size:`compact`,variant:`outlined`,onClick:()=>F.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 G?K?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[Z,(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Address`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:K.address}),(0,$.jsx)(Cn,{status:J.data?.status,message:J.data?.message,isLoading:J.isLoading}),(0,$.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,$.jsx)(M,{}),onClick:()=>N(!0),disabled:re.isPending,"aria-label":`Remove email address`})]}),(0,$.jsx)(V,{open:j,title:`Remove Email Address`,message:(0,$.jsxs)($.Fragment,{children:[`Are you sure you want to remove`,` `,(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:K.address}),`? Your assistant will no longer be able to send or receive email at this address.`]}),confirmLabel:`Remove`,destructive:!0,onConfirm:oe,onCancel:()=>N(!1)})]}),q.data?.usage&&(0,$.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[q.data.usage.sent_today,` /`,` `,q.data.usage.daily_limit,` sent today ·`,` `,q.data.usage.received_today,` received`]})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[Z,(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Domain`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:[G.subdomain,`.`,n]}),(0,$.jsx)(Cn,{status:J.data?.status,message:J.data?.message,isLoading:J.isLoading}),(0,$.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,$.jsx)(M,{}),onClick:()=>A(!0),disabled:Y.isPending,"aria-label":`Release domain`})]}),(0,$.jsx)(V,{open:k,title:`Release Domain`,message:(0,$.jsxs)($.Fragment,{children:[`Are you sure you want to release`,` `,(0,$.jsxs)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:[G.subdomain,`.`,n]}),`? The subdomain will become available for others to claim.`]}),confirmLabel:`Release`,destructive:!0,onConfirm:se,onCancel:()=>A(!1)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Email address`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.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 ${C?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[(0,$.jsx)(`input`,{value:x,onChange:e=>{S(e.target.value.toLowerCase()),C&&w(null)},placeholder:`hi`,"aria-label":`Email username`,"aria-invalid":!!C,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,$.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`@`,ee]})]}),(0,$.jsx)(c,{onClick:ae,disabled:ne.isPending||!x.trim(),children:ne.isPending?`Creating…`:`Create`})]}),C&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:C})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[Z,(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Subdomain`}),(0,$.jsx)(Dn,{subdomain:h,onSubdomainChange:e=>{g(e),y&&b(null)},domainSuffix:n,subdomainPlaceholder:`my-assistant`,error:y}),(0,$.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,$.jsx)(c,{onClick:()=>E(!0),disabled:te.isPending||!h.trim(),children:te.isPending?`Registering…`:`Register`}),(0,$.jsx)(V,{open:T,title:`Set Subdomain`,message:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:h.trim().toLowerCase()||`subdomain`}),` `,`will also become your assistant's public handle. You won't be able to change it once set.`]}),confirmLabel:`Confirm`,onConfirm:ie,onCancel:()=>E(!1)})]})}function kn(){let e=un(),r=xt(),{data:o}=f({...$t(),enabled:r}),s=o?.results?.[0]?.handle,c=_n.use.emailRootDomain(),l=bt(),[u,d]=(0,Q.useState)(()=>l===`gated`?`your-own`:le(t(Ue,`managed`),`managed`)),[p,m]=(0,Q.useState)(()=>{let e=t(Ze,`resend`);return e===`mailgun`||e===`resend`?e:`resend`}),{platformAssistantId:h,error:g}=gn(e,l===`full`&&u===`managed`),_=h??(g?e:null),y=f({queryKey:[`byoEmailCredential`,e,p],queryFn:async()=>{let{data:t}=await _t({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,Q.useEffect)(()=>{y.error&&a(y.error,{context:`byo_email_credential_check`,bestEffort:!0})},[y.error]);let b=y.data?.hasSecret===!0,x=(0,Q.useCallback)(e=>{d(e),n(Ue,e)},[]),S=(0,Q.useCallback)(()=>{n(Ze,p),B.success(`Email settings saved.`)},[p]),C=(0,Q.useMemo)(()=>qe.find(e=>e.id===p)??qe[0],[p]),E=(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(T,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`span`,{children:[`Configure `,C.displayName,` via the assistant CLI: ask the assistant to run the`,` `,(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:C.setupSkill}),` `,`skill. It walks you through storing the API key, detecting the domain, and (optionally) wiring up an inbound webhook.`]}),(0,$.jsxs)(`a`,{href:C.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,C.displayName,(0,$.jsx)(w,{className:`h-3 w-3`})]})]})]}),O=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:p,onChange:e=>{(e===`mailgun`||e===`resend`)&&m(e)},options:qe.map(e=>({value:e.id,label:e.displayName}))})]}),b?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.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,$.jsx)(v,{className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,$.jsxs)(`span`,{children:[C.displayName,` API key configured. To reconfigure, run the`,` `,(0,$.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:C.setupSkill}),` `,`skill.`]})]}),(0,$.jsxs)(`a`,{href:C.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 `,C.displayName,(0,$.jsx)(w,{className:`h-3 w-3`})]})]}):E,(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(wn,{onClick:S,disabled:!1})})]});return l===`gated`?(0,$.jsx)(xn,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,children:O}):(0,$.jsx)(bn,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,mode:u,onModeChange:x,children:u===`managed`?(0,$.jsx)(`div`,{className:`space-y-4`,children:l===`disabled`?(0,$.jsx)(tn,{children:`Log in to the Vellum platform to manage email settings.`}):_===null?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Connecting to the Vellum platform…`]}):(0,$.jsx)(On,{assistantId:_,assistantHandle:s,emailRootDomain:c})}):O})}function An(){let e=un();return(0,Q.useCallback)(async(t,n)=>{try{let{data:r}=await pt({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});X(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?B.error(`Assistant not ready. Please try again.`):B.error(`Failed to save ${t} API key. Please try again.`),a(e,{context:`provision_provider_key`}),e}},[e])}function jn(e){let[t,n]=(0,Q.useState)(void 0);return(0,Q.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Q.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}var Mn=`0.11.0`;function Nn(){return ot(Mn)}var Pn=`gemini-3.1-flash-image-preview`;function Fn(){let e=un(),r=d(),i=xt(),{data:o}=f({...Lt({path:{assistant_id:e}}),enabled:i,staleTime:3e4}),s=Dt({onSuccess:t=>{At(r,{path:{assistant_id:e}},t)}}),c=An(),[l,u]=jn((0,Q.useMemo)(()=>{if(!o)return t(Ye,`gemini`);let e=o.services?.[`image-generation`];return e?.mode===`managed`?`vellum`:e?.provider||t(`vellum:ai:imageGenProvider`,`gemini`)},[o])),[p,m]=(0,Q.useState)(()=>t(Ie,Pn)),h=tt(l),g=h.includes(p)?p:h[0]??Pn,[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),x=Ve.map(e=>({value:e,label:Fe[e]??e})),S=(0,Q.useMemo)(()=>tt(l).map(e=>({value:e,label:He[e]??e})),[l]),C=l===`gemini`||l===`openai`,{hasStoredCredential:w}=be({assistantId:e,credentialKind:`api_key`,credentialName:l,enabled:C}),T=u,E=(0,Q.useCallback)(async()=>{b(!0);let t=_.trim(),i=C&&t.length>0;try{i&&await c(je(g),t),await st();let n=l===`vellum`&&!Nn()?{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 B.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e});try{await ft({path:{assistant_id:e},body:{modelId:g},throwOnError:!0})}catch(e){throw B.error(`Failed to update image generation model. Please try again.`),a(e,{context:`set_image_gen_model`}),e}finally{r.invalidateQueries({queryKey:kt({path:{assistant_id:e}})})}}catch{b(!1);return}b(!1);try{if(n(Ye,l),n(Ie,g),i){let t=rt(e,`api_key`,l);r.setQueryData(t,!0),r.invalidateQueries({queryKey:t}),v(``)}B.success(`Image generation settings saved.`)}catch(e){a(e,{context:`settings-ai-image-gen-persist-local`}),B.error(`Saved, but local preferences could not be written.`)}},[_,l,C,g,e,s,c,r]),O=(0,Q.useCallback)(()=>{v(``),m(Pn),n(Ie,Pn)},[]);return(0,$.jsx)(xn,{title:`Image Generation`,subtitle:`Configure which model your assistant uses to generate images`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{"aria-label":`Image generation provider`,value:l,onChange:T,options:x})]}),l===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Image generation runs through your Vellum account.`}),C&&(0,$.jsx)(L,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:ke(l===`openai`?`Enter your OpenAI API key`:`Enter your Gemini API key`,w),fullWidth:!0}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,$.jsx)(H,{"aria-label":`Image generation model`,value:g,onChange:m,options:S})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(wn,{onClick:E,disabled:y}),y&&(0,$.jsx)(D,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),C&&(0,$.jsx)(Tn,{onClick:O})]})]})})}function In({title:e,count:t,action:n,children:r}){return(0,$.jsxs)(`section`,{className:`rounded-xl border border-[var(--border-hover)] bg-[var(--surface-overlay)] px-3 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(h,{variant:`body-large-default`,as:`h3`,className:`text-[var(--content-secondary)]`,children:e}),t==null?null:(0,$.jsxs)(h,{variant:`body-large-default`,as:`span`,"aria-label":`${t} ${e.toLowerCase()}`,className:`text-[var(--content-disabled)]`,children:[`·`,` `,t]})]}),n]}),r==null?null:(0,$.jsx)(`div`,{className:`mt-4 border-t border-[var(--border-base)]`,children:r})]})}function Ln(e){return e.scheduleNames.length>0||e.deferredReminderCount>0||e.scheduleLookupFailed}var Rn=5;function zn(e,t){return`${e} ${t}${e===1?``:`s`}`}function Bn(e){return e.length===1?e[0]:e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function Vn(e){let t=e.label||e.name,n=[];e.isActive&&n.push(`is your default profile`),e.callSiteIds.length>0&&n.push(`is used by ${zn(e.callSiteIds.length,`action override`)}`);let r=[];return e.scheduleNames.length>0&&r.push(zn(e.scheduleNames.length,`schedule`)),e.deferredReminderCount>0&&r.push(zn(e.deferredReminderCount,`reminder`)),r.length>0&&n.push(`runs ${Bn(r)}`),n.length===0?`Choose a replacement profile for "${t}". Anything still pointing at it moves there before it is deleted.`:`"${t}" ${Bn(n)}. Pick a replacement below and those references move to it, then "${t}" is deleted.`}function Hn({title:e,items:t,mono:n}){return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--content-tertiary)`,children:e}),(0,$.jsx)(`ul`,{className:`space-y-1 pl-1`,children:t.map(e=>(0,$.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,n?(0,$.jsx)(`code`,{children:e}):e]},e))})]})}function Un({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:s}){let l=e?.scheduleNames??[],u=l.slice(0,Rn),d=l.length-u.length,f=e!=null&&Ln(e);return(0,$.jsx)(z.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(z.Content,{size:`sm`,children:[(0,$.jsx)(z.Header,{children:(0,$.jsx)(z.Title,{children:`Choose a Replacement Profile`})}),(0,$.jsxs)(z.Body,{className:`space-y-4`,children:[e&&(0,$.jsx)(h,{variant:`body-medium-default`,as:`p`,children:Vn(e)}),e&&e.callSiteIds.length>0&&(0,$.jsx)(Hn,{title:`Action overrides`,items:e.callSiteIds,mono:!0}),u.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(Hn,{title:`Schedules`,items:u}),d>0&&(0,$.jsxs)(h,{variant:`body-small-default`,as:`p`,className:`pl-1 text-(--content-tertiary)`,children:[`and `,d,` more`]})]}),e?.scheduleLookupFailed&&(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-mid-strong)`,children:`We could not check which schedules use this profile. Any schedule pinned to it moves to the replacement as well.`}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-(--content-tertiary)`,children:`Replacement profile`}),(0,$.jsx)(H,{"aria-label":`Replacement profile`,value:n,onChange:r,placeholder:`Select a replacement…`,options:t.map(e=>{let t=f&&e.status===`disabled`;return{value:e.name,label:pe(e),disabled:t,tooltip:t?`Enable this profile to move schedules onto it.`:void 0}})})]}),i&&(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,$.jsxs)(z.Footer,{children:[(0,$.jsx)(c,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,$.jsx)(c,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:s,children:a?`Saving…`:`Reassign and Delete`})]})]})})}function Wn({profile:e,isActiveProfile:t,selected:n,connections:r,deletePending:i=!1,onOpen:a,onMakeActive:o,onSetStatus:l,onDelete:u}){let d=e.source===`managed`,f=e.status===`disabled`,p=e.label??e.name,m=[];e.model&&m.push(ye(e.provider??void 0,e.model,r)),d&&m.push(`Managed by Vellum`);let h=e.availability,g=h?.status===`incomplete`,v=h!=null&&h.status!==`ok`?`${h.message??`This profile's provider is not available.`}${g?` Click to fix.`:``}`:null;return(0,$.jsx)(S,{title:(0,$.jsx)(`span`,{className:f?`opacity-55`:void 0,children:p}),subtitle:m.length>0?m.join(` • `):void 0,onClick:a,showChevron:!1,selected:n,disabled:i,contentAriaLabel:`Open profile ${p}`,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[v==null?null:(0,$.jsx)(s,{content:v,children:g?(0,$.jsx)(`button`,{type:`button`,onClick:a,"aria-label":v,className:`inline-flex cursor-pointer rounded-sm p-0.5 keyboard-focus:ring-2 keyboard-focus:ring-[var(--ring)]`,children:(0,$.jsx)(_,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-hidden":`true`})}):(0,$.jsx)(`span`,{className:`inline-flex p-0.5`,tabIndex:0,children:(0,$.jsx)(_,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-label":v,role:`img`})})}),f?(0,$.jsx)(F,{tone:`neutral`,children:`Disabled`}):null,t?(0,$.jsx)(F,{tone:`positive`,children:`Default`}):null,(0,$.jsxs)(y.Root,{children:[(0,$.jsx)(y.Trigger,{asChild:!0,children:(0,$.jsx)(c,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(C,{}),"aria-label":`Actions for ${p}`,disabled:i})}),(0,$.jsxs)(y.Content,{align:`end`,sideOffset:4,children:[(0,$.jsx)(y.Item,{onSelect:a,children:d?`View`:`Edit`}),!t&&!f?(0,$.jsx)(y.Item,{onSelect:o,children:`Make Default`}):null,f?(0,$.jsx)(y.Item,{onSelect:()=>l(!0),children:`Enable`}):d?null:(0,$.jsx)(y.Item,{onSelect:()=>l(!1),children:`Disable`}),d?null:(0,$.jsx)(y.Item,{onSelect:u,className:`text-[var(--system-negative-strong)] data-[highlighted]:text-[var(--system-negative-strong)]`,children:`Delete`})]})]})]})})}var Gn=`0.11.0`;function Kn(){return at(Gn)}function qn(e,t){let n=Kn(),{data:r}=f({...St({path:{assistant_id:e}}),enabled:n,staleTime:3e4}),{profiles:i,profileOrder:a}=$e(t?.llm,e);return(0,Q.useMemo)(()=>r==null?{entries:ce(i,a).map(e=>({name:e.name,label:e.label??null,provider:e.provider??null,model:e.model??null,status:e.status===`disabled`?`disabled`:`active`,source:e.source===`managed`?`managed`:`user`,provider_connection:e.provider_connection,availability:null})),isEffectiveCatalog:!1}:{entries:r.profiles,isEffectiveCatalog:!0},[r,i,a])}function Jn(e){let t=d();return Dt({onSuccess:n=>{At(t,{path:{assistant_id:e}},n),t.invalidateQueries({queryKey:wt({path:{assistant_id:e}})}),t.invalidateQueries({queryKey:Nt({path:{assistant_id:e}})})}})}var Yn=`0.10.8`;function Xn(e){return ct(Yn,e)}var Zn=`settings-ai-profile-make-active`,Qn=`Failed to set the active profile. Please try again.`;function $n(e){let t=Jn(e),n=d(),r=Xn(e),i=Pt({onSuccess:()=>{n.invalidateQueries({queryKey:kt({path:{assistant_id:e}})}),n.invalidateQueries({queryKey:wt({path:{assistant_id:e}})})}});async function o(n,r,i){try{await t.mutateAsync({path:{assistant_id:e},body:{llm:n}})}catch(e){throw a(e,{context:r}),B.error(i),e}}async function s(t){if(!r){await o({activeProfile:t},Zn,Qn);return}try{await i.mutateAsync({path:{assistant_id:e},body:{name:t}})}catch(e){let t=ut(e);throw B.error(t??Qn),t||a(e,{context:Zn}),e}}return{makeActive:s,setStatus:(e,t)=>o({profiles:{[e]:{status:t?`active`:`disabled`}}},`settings-ai-profile-toggle`,`Failed to update the profile. Please try again.`),deleteProfile:(e,t,n)=>o({profiles:{[e]:null},profileOrder:t.filter(t=>t!==e),...n?.isAdvisor?{advisorProfile:null}:{}},`settings-ai-profile-delete`,`Failed to delete the profile. Please try again.`),patchLlm:o,isPending:t.isPending||i.isPending}}var er=`The profile was not deleted.`,tr=`Failed to move the schedules. ${er}`;function nr(e){let t=ut(e);return t?`${/[.!?]$/.test(t)?t:`${t}.`} ${er}`:tr}function rr(e,t,n){let r=$n(e),i=d(),o=me(),s=t?.llm?.activeProfile??null,c=t?.llm?.advisorProfile??null,l=t?.llm?.callSites??{},u=(0,Q.useMemo)(()=>t?.llm?.profiles??{},[t?.llm?.profiles]),f=(0,Q.useMemo)(()=>t?.llm?.profileOrder??[],[t?.llm?.profileOrder]),p=(0,Q.useMemo)(()=>ce(u,f),[u,f]),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),w=(0,Q.useRef)(!1);function T(e){return p.filter(t=>t.name===e?!1:t.status===`disabled`?!0:he(t,p,{requireOwnProviderAndModel:o}))}function E(e,t){let n=T(e).filter(e=>!t||e.status!==`disabled`),r=n.find(e=>e.name===s),i=n.find(e=>e.source!==`managed`);return(r??i??n[0])?.name??``}async function D(e){try{await r.deleteProfile(e,f,{isAdvisor:e===c}),n?.onDeleted?.(e)}catch{}}async function O(t){let n=u[t]?.label??t,r=t===s,o=Object.entries(l).filter(([e,n])=>e!==`mainAgent`&&n?.profile===t).map(([e])=>e),c=[],d=0,f=!1;try{let n=(await i.fetchQuery({...zt({path:{assistant_id:e},query:{inference_profile:t,include_all:`true`}}),retry:!1,staleTime:0})).schedules??[];c=n.filter(e=>!e.isDeferred).map(e=>e.name),d=n.filter(e=>e.isDeferred).length}catch(e){a(e,{context:`settings-ai-profile-delete-schedule-scan`}),f=!0}if(!(r||o.length>0||c.length>0||d>0)&&!f){await D(t);return}let p={name:t,label:n,isActive:r,callSiteIds:o,scheduleNames:c,deferredReminderCount:d,scheduleLookupFailed:f};h(p),y(E(t,Ln(p))),_(null)}function k(e){t==null||w.current||(w.current=!0,C(e),O(e).finally(()=>{w.current=!1,C(null)}))}async function A(){if(!m||!v)return;if(x(!0),_(null),Ln(m))try{await fn(e,m.name,v),await i.invalidateQueries({queryKey:Tt({path:{assistant_id:e}})})}catch(e){a(e,{context:`settings-ai-profile-reassign-schedules`}),_(nr(e)),x(!1);return}let t={};if(m.isActive&&(t.activeProfile=v),m.callSiteIds.length>0){let e={};for(let t of m.callSiteIds)e[t]={profile:v};t.callSites=e}if(Object.keys(t).length>0)try{await r.patchLlm(t,`settings-ai-profile-reassign-delete`,`Failed to reassign references. Please try again.`)}catch{_(`Failed to reassign references. Please try again.`),x(!1);return}let n=m.name;h(null),x(!1),D(n)}return{requestDelete:k,pendingDeleteName:S,blockedDeleteModalProps:{blocked:m,availableReplacements:T(m?.name??null),replacement:v,onReplacementChange:y,error:g,saving:b,onClose:()=>{h(null),_(null)},onConfirm:()=>void A()}}}function ir(){}function ar({assistantId:e,config:t,connections:n,selectedProfileName:r,onOpenProfile:i,onCreateProfile:a,onProfileDeleted:o}){let{entries:s}=qn(e,t),l=$n(e),u=rr(e,t,{onDeleted:o}),d=t?.llm?.activeProfile??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(In,{title:`Profiles`,action:(0,$.jsx)(c,{variant:`primary`,onClick:a,leftIcon:(0,$.jsx)(A,{}),disabled:t==null,children:`Create Profile`}),children:t==null?(0,$.jsx)(h,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`Loading profiles…`}):s.length===0?(0,$.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.`}):s.map(e=>(0,$.jsx)(Wn,{profile:e,isActiveProfile:e.name===d,selected:e.name===r,connections:n,deletePending:u.pendingDeleteName===e.name,onOpen:()=>i(e.name),onMakeActive:()=>void l.makeActive(e.name).catch(ir),onSetStatus:t=>void l.setStatus(e.name,t).catch(ir),onDelete:()=>u.requestDelete(e.name)},e.name))}),(0,$.jsx)(Un,{...u.blockedDeleteModalProps})]})}var or={anthropic:!0,openai:!0,gemini:!0,fireworks:!0,openrouter:!0,vellum:!0,together:!0,"vercel-ai-gateway":!0,minimax:!0,atlascloud:!0,baseten:!0,poolside:!0};function sr(e){return e in or}function cr(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 lr(e){switch(e.auth.type){case`api_key`:return`Own API key`;case`oauth_subscription`:return`ChatGPT subscription`;case`none`:return`No API key needed`;default:return null}}function ur(e){if(e.provider===`vellum`)return`Included with your plan`;if(e.provider===`openai-compatible`)return cr(e);let t=[],n=e.models?.length??K(e.provider).length;n>0&&t.push(`${n} ${n===1?`model`:`models`}`);let r=lr(e);return r&&t.push(r),t.join(` • `)}function dr({connection:e,isDefault:t,supportsDefaultProvider:n,selected:r,isSettingDefault:i,onOpen:a,onSetDefault:o,onDelete:s}){let l=e.isManaged??!1,u=Pe(e),d=sr(e.provider),f=ur(e),p=n&&!t&&d,m=!l&&a!=null,h=!l&&!t,g=p||m||h;return(0,$.jsx)(S,{title:u,subtitle:f.length>0?f:void 0,onClick:a,showChevron:!1,selected:r,contentAriaLabel:a?`Open provider ${u}`:void 0,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[l?(0,$.jsx)(F,{tone:`neutral`,title:`Runs on Vellum's managed credentials.`,children:`Managed`}):null,t?(0,$.jsx)(F,{tone:`info`,title:`Built-in profiles (Balanced, Quality, Cost, Speed) use this provider.`,children:`Default`}):null,e.provider===`ollama`?(0,$.jsx)(F,{tone:`neutral`,title:`Runs models on this machine.`,children:`Local`}):null,e.provider===`openai-compatible`?(0,$.jsx)(F,{tone:`neutral`,title:`A provider you created, served by an OpenAI-compatible endpoint.`,children:`Custom`}):null,g?(0,$.jsxs)(y.Root,{children:[(0,$.jsx)(y.Trigger,{asChild:!0,children:(0,$.jsx)(c,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(C,{}),"aria-label":`Actions for ${u}`})}),(0,$.jsxs)(y.Content,{align:`end`,sideOffset:4,children:[m?(0,$.jsx)(y.Item,{onSelect:a,children:`Edit`}):null,p?(0,$.jsx)(y.Item,{disabled:i,onSelect:o,children:`Set as default`}):null,h?(0,$.jsx)(y.Item,{onSelect:s,className:`text-[var(--system-negative-strong)] data-[highlighted]:text-[var(--system-negative-strong)]`,children:`Delete`}):null]})]}):(0,$.jsx)(`span`,{className:`inline-block w-8`,"aria-hidden":!0})]})})}function fr(e,t){let n=d(),r={path:{assistant_id:e}},i=p({...Ot(),onSuccess:()=>{n.invalidateQueries({queryKey:jt(r)}),n.invalidateQueries({queryKey:kt(r)}),n.invalidateQueries({queryKey:wt(r)})},onError:e=>{a(e,{context:`settings-ai-set-default-provider`}),B.error(`Failed to set the default provider. Please try again.`)}});function o(t){sr(t.provider)&&i.mutate({path:{assistant_id:e},body:{provider:t.provider,connectionName:t.name}})}function s(e){return i.isPending&&i.variables?.body?.connectionName===e}async function c(i){try{let{response:a}=await gt({path:{assistant_id:e,name:i}});a?.ok||a?.status===404?(n.invalidateQueries({queryKey:Ct(r)}),t?.onDeleted?.(i)):a?.status===409?B.error(`This provider is in use by a profile or as the default provider. Update those settings before deleting it.`):B.error(`Failed to delete the provider. Please try again.`)}catch(e){a(e,{context:`settings-ai-provider-delete`}),B.error(`Failed to delete the provider. Please try again.`)}}return{setDefault:o,isSettingDefault:s,deleteConnection:c}}var pr=`0.10.8`;function mr(){return at(pr)}function hr({assistantId:e,selectedConnectionName:t,onOpenConnection:n,onAddProvider:r,onConnectionDeleted:i}){let{data:a,isLoading:o,isError:s}=f(It({path:{assistant_id:e}})),l=mr(),{data:u}=f({...Mt({path:{assistant_id:e}}),enabled:l}),d=l?u?.resolvedConnectionName??null:null,p=fr(e,{onDeleted:i}),m=(0,Q.useMemo)(()=>{let e=a?.connections??[];return[...e.filter(e=>e.provider===W),...e.filter(e=>e.provider!==W)]},[a]);return(0,$.jsx)(In,{title:`Providers`,action:(0,$.jsx)(c,{variant:`outlined`,onClick:r,leftIcon:(0,$.jsx)(A,{}),children:`Add Provider`}),children:o?(0,$.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,$.jsx)(U,{className:`h-10 rounded-lg`},e))}):s?(0,$.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.`}):m.length===0?(0,$.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.`}):m.map(e=>(0,$.jsx)(dr,{connection:e,isDefault:e.name===d,supportsDefaultProvider:l,selected:e.name===t,isSettingDefault:p.isSettingDefault(e.name),onOpen:e.isManaged??!1?void 0:()=>n(e.name),onSetDefault:()=>p.setDefault(e),onDelete:()=>void p.deleteConnection(e.name)},e.name))})}function gr({panel:e,onOpenPanel:t,onClosePanel:n}){let r=un(),{data:i}=f({...Lt({path:{assistant_id:r}}),staleTime:3e4}),a=mr(),{data:o}=f({...Mt({path:{assistant_id:r}}),enabled:a}),s=o?.availability,{data:l}=f({...It({path:{assistant_id:r}})}),u=l?.connections,d=i?.llm?.callSites??{},p=Object.entries(d).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length;return(0,$.jsx)(xn,{title:`Language Model`,subtitle:`Profiles choose which model answers. Providers supply access to it`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[s&&s.status!==`ok`&&(0,$.jsx)(P,{tone:s.status===`unknown`?`warning`:`error`,children:s.message??`Your default provider is not available.`}),r&&(0,$.jsx)(ar,{assistantId:r,config:i,connections:u,selectedProfileName:e?.kind===`profile`?e.name:null,onOpenProfile:e=>t({kind:`profile`,name:e}),onCreateProfile:()=>t({kind:`create-profile`}),onProfileDeleted:t=>{e?.kind===`profile`&&e.name===t&&n()}}),r&&(0,$.jsx)(hr,{assistantId:r,selectedConnectionName:e?.kind===`provider`?e.name:null,onOpenConnection:e=>t({kind:`provider`,name:e}),onAddProvider:()=>t({kind:`add-provider`}),onConnectionDeleted:t=>{e?.kind===`provider`&&e.name===t&&n()}}),(0,$.jsx)(In,{title:`Overrides`,count:p,action:(0,$.jsx)(c,{variant:`outlined`,onClick:()=>t({kind:`overrides`}),children:`Manage`})})]})})}function _r(e,{onSaved:t}={}){let n=Jn(e),{data:r}=f({...Lt({path:{assistant_id:e}}),staleTime:3e4}),i=(0,Q.useMemo)(()=>r?.llm?.profiles??{},[r?.llm?.profiles]),o=r?.llm?.profileOrder??[];async function s(r,s,c){let l=c?.mode??`replace`,u=!(r in i);if(l===`merge`&&!u){await n.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[r]:s}}}}),t?.();return}let d={profiles:{[r]:s}};if(u&&(d.profileOrder=o.includes(r)?o:[...o,r]),u)await n.mutateAsync({path:{assistant_id:e},body:{llm:d}});else{let t=i[r];await n.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[r]:null}}}});try{await n.mutateAsync({path:{assistant_id:e},body:{llm:d}})}catch(i){throw a(i,{context:`settings-ai-profile-edit-recreate`}),t!=null&&await n.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[r]:t}}}}).catch(()=>{}),i}}u&&B.success(`Profile "${s.label??r}" created`),t?.()}return{saveProfile:s,isPending:n.isPending}}function vr({assistantId:e,profileName:t,onClose:n}){let{data:r}=f({...Lt({path:{assistant_id:e}}),staleTime:3e4}),{data:i}=f({...It({path:{assistant_id:e}})}),a=i?.connections,o=(0,Q.useMemo)(()=>r?.llm?.profiles??{},[r?.llm?.profiles]),s=Object.keys(o),l=(0,Q.useMemo)(()=>{if(t==null)return;let e=o[t];return e?{name:t,...e}:void 0},[t,o]),u=t==null?`create`:l?.source===`managed`||l?.invariant===!0?`view`:`edit`,{saveProfile:d,isPending:p}=_r(e,{onSaved:n}),m=Ge({mode:u,profileName:t??void 0,initialValues:l,existingNames:s,connections:a,assistantId:e,onSave:d}),h=rr(e,r,{onDeleted:()=>n()}),g=t!=null&&h.pendingDeleteName===t,_=t!=null&&r!=null&&!(t in o);(0,Q.useEffect)(()=>{_&&!m.saving&&!p&&n()},[_,m.saving,p,n]);let v=u===`view`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dn,{title:m.effectiveMode===`create`?`New Profile`:l?.label??t??`Profile`,closeVariant:`outlined`,onClose:n,headerTrailing:v&&m.effectiveMode!==`create`?(0,$.jsx)(F,{tone:`neutral`,children:`Managed by Vellum`}):null,headerActions:m.effectiveMode!==`create`&&!m.isReadOnly?(0,$.jsx)(c,{variant:`outlined`,size:`compact`,leftIcon:(0,$.jsx)(M,{}),tintColor:`var(--system-negative-strong)`,onClick:()=>{t!=null&&h.requestDelete(t)},disabled:m.saving||g,children:g?`Deleting…`:`Delete`}):null,footer:m.isReadOnly?(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(c,{variant:`outlined`,onClick:m.switchToSaveAsNew,disabled:m.saving,children:`Save As New`}),m.hasViewModeChanges?(0,$.jsx)(c,{variant:`primary`,onClick:()=>void m.handleSave(),disabled:m.saving,children:m.saving?`Saving…`:`Save`}):null]}):(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(c,{variant:`primary`,onClick:()=>void m.handleSave(),disabled:m.isInvalid||m.saving,children:m.saving?`Saving…`:m.effectiveMode===`create`?`Create Profile`:`Save Changes`})}),children:(0,$.jsx)(We,{editor:m,assistantId:e,connections:a,variant:`panel`})}),(0,$.jsx)(Un,{...h.blockedDeleteModalProps})]})}function yr({value:e,profileOptions:t,disabled:n,onChange:r}){return(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:`Advisor`}),(0,$.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`The profile your assistant consults for a second opinion when it wants to check a plan or review its own work.`})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,$.jsx)(H,{value:e,onChange:r,options:t,placeholder:`Choose profile…`,className:`w-44`,menuMinWidth:280,menuAlign:`end`,disabled:n})})]})})}var br=`__custom__`;function xr(e){return e?!!(e.profile||e.provider||e.model):!1}function Sr(e,t){if(t?.provider||t?.model)return null;let n=e.defaultProfile??e.shippedDefaultProfile;return n?{profile:n,via:t?.profile===n?`override`:`default`}:null}function Cr(e,t){let n=xr(e);return n===xr(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function wr(e){return`${e} ${e===1?`action`:`actions`}`}function Tr({assistantId:e,callSites:t,domains:n,persistedOverrides:r,orderedProfiles:i,onClose:o,onApplied:s}){let l=Jn(e),u=me(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u}),[u]),f=(0,Q.useMemo)(()=>{let e=new Map;for(let n of t){let t=Sr(n,r[n.id]);t&&e.set(n.id,t)}return e},[t,r]),p=(0,Q.useMemo)(()=>{let e=new Set(Array.from(f.values(),e=>e.profile));return i.filter(t=>e.has(t.name))},[i,f]),[m,g]=(0,Q.useState)(()=>p[0]?.name??``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(new Set),[x,S]=(0,Q.useState)(!1),C=(0,Q.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e.displayName]));return t=>e.get(t)??t},[n]),w=(0,Q.useMemo)(()=>t.filter(e=>f.get(e.id)?.profile===m),[t,f,m]),T=(0,Q.useMemo)(()=>w.map(e=>e.id).filter(e=>!y.has(e)),[w,y]),E=(0,Q.useMemo)(()=>p.map(e=>({value:e.name,label:pe(e)})),[p]),O=(0,Q.useMemo)(()=>de(i,[],d).filter(e=>e.name!==m).map(e=>({value:e.name,label:pe(e)})),[i,m,d]),A=oe(i,m),j=oe(i,_),M=y.size===0;function N(e){g(e),b(new Set),e===_&&v(``)}function F(e,t){b(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})}async function I(){if(!(!m||!_||T.length===0)){S(!0);try{let t={};for(let e of T)t[e]={profile:_};await l.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),B.success(`Updated ${wr(T.length)} to "${j}".`),s(),o()}catch(e){let t=ut(e);B.error(t??`Failed to update overrides. Please try again.`),t||a(e,{context:`settings-ai-bulk-override-swap`})}finally{S(!1)}}}return(0,$.jsx)(z.Root,{open:!0,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(z.Content,{size:`md`,children:[(0,$.jsx)(z.Header,{children:(0,$.jsx)(z.Title,{children:`Change Action Overrides`})}),(0,$.jsxs)(z.Body,{className:`space-y-4`,children:[(0,$.jsx)(h,{variant:`body-medium-default`,as:`p`,children:`Update the actions that currently use one profile. The result is saved as individual overrides.`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsx)(H,{id:`bulk-swap-source`,label:`Currently using`,value:m,onChange:N,options:E}),(0,$.jsx)(H,{id:`bulk-swap-target`,label:`Change to`,value:_,onChange:v,options:O,placeholder:`Select a profile…`})]}),(0,$.jsxs)(P,{tone:`info`,title:`This happens once.`,children:[`It changes the selected actions that use `,A,` today. It does not create an ongoing rule between profiles.`]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(h,{variant:`body-medium-default`,as:`p`,children:[wr(w.length),` currently`,` `,w.length===1?`uses`:`use`,` `,A]}),(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-[color:var(--content-secondary)]`,children:`Choose which actions to update.`})]}),(0,$.jsx)(c,{variant:`ghost`,onClick:()=>b(M?new Set(w.map(e=>e.id)):new Set),children:M?`Clear all`:`Select all`})]}),(0,$.jsx)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto`,children:w.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-[var(--border-base)] px-3 py-2`,children:[(0,$.jsx)(k,{checked:!y.has(e.id),onCheckedChange:t=>F(e.id,t===!0),disabled:x,label:e.displayName,helperText:C(e.domain)}),(0,$.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:f.get(e.id)?.via===`override`?`Override`:`Default`})]},e.id))})]})]}),(0,$.jsxs)(z.Footer,{children:[(0,$.jsxs)(h,{variant:`body-small-default`,as:`p`,className:`mr-auto self-center text-[color:var(--content-secondary)]`,children:[wr(T.length),` will change`]}),(0,$.jsx)(c,{variant:`ghost`,onClick:o,disabled:x,children:`Cancel`}),(0,$.jsx)(c,{variant:`primary`,disabled:!m||!_||T.length===0||x,onClick:()=>void I(),children:x?(0,$.jsx)(D,{className:`h-4 w-4 animate-spin`}):`Apply to ${wr(T.length)}`})]})]})})}function Er({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,onDraftChange:o,onToggle:s}){let c=xr(i),l=!i||!c?``:i.provider||i.model?br:i.profile??``,u=l===br,d=Ne(),f=d[0]??te[0],p=Z(i?.provider)?i.provider:void 0,m=p!==void 0&&d.some(e=>e===p),h=p??f,g=K(h).map(e=>({value:e.id,label:e.displayName})),_=!!i?.provider&&!i?.model;function v(t){t===`__custom__`?o(e,{profile:null,provider:f,model:q(f)??``}):t===``?o(e,null):o(e,{profile:t,provider:null,model:null})}function y(t){let n=q(t)??``;o(e,{...i??{},profile:null,provider:t,model:n})}function b(t){o(e,{...i??{},model:t})}return(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,$.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,$.jsxs)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:[`· Default: `,r]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c&&(0,$.jsx)(H,{value:l,onChange:v,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,$.jsx)(R,{checked:c,onChange:t=>s(e,t),"aria-label":`Override ${t}`})]})]}),c&&u&&(0,$.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:h??``,onChange:y,options:[...d.map(e=>({value:e,label:ee[e]??e})),...p&&!m?[{value:p,label:`${ee[p]??p} (unavailable)`}]:[]]})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,$.jsx)(H,{value:i?.model??``,onChange:b,options:g})]})]}),_&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:`Pick a model`})]})]})}function Dr({groups:e,drafts:t,buildProfileOptionsForRow:n,profileLabelFor:r,advisorMatchesSearch:i,onDraftChange:a,onToggle:o}){return(0,$.jsx)(`div`,{className:`space-y-4`,children:e.length===0?i?null:(0,$.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No actions match your search.`}):e.map(({domain:e,sites:i})=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,$.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>{let i=(()=>{let n=t[e.id]??null;return!n||!xr(n)?``:n.provider||n.model?br:n.profile??``})(),s=e.shippedDefaultProfile??e.defaultProfile,c=s?r(s):null;return(0,$.jsx)(Er,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:c,draft:t[e.id]??null,profileOptions:n(i===``||i===`__custom__`?null:i),onDraftChange:a,onToggle:o},e.id)})})]},e.id))})}function Or(e,t){let n={};for(let r of Object.keys(e)){let i=e[r]??null;xr(i)?n[r]={profile:i?.profile??null,provider:i?.provider??null,model:i?.model??null}:r in t&&t[r]===null&&(n[r]=null)}return n}function kr(e){let t={};for(let n of Object.keys(e))t[n]=null;return t}function Ar({catalogCallSiteIds:e,persistedOverrides:t,persistedAdvisor:n,isSeeded:r}){let[i,a]=(0,Q.useState)({}),[o,s]=(0,Q.useState)(void 0),c=(0,Q.useMemo)(()=>{if(!r)return{};let n={};for(let r of e)if(r in i)n[r]=i[r];else{let e=t[r];n[r]=e?{...e}:{}}return n},[r,e,t,i]),l=o??n,u=l!==n,d=(0,Q.useMemo)(()=>{if(!r)return!1;for(let e of Object.keys(c))if(!Cr(c[e],t[e]))return!0;return!1},[r,c,t]);return{drafts:c,advisorProfile:l,advisorDirty:u,callSiteDraftsDirty:d,hasUnsavedDrafts:u||d,hasValidationError:(0,Q.useMemo)(()=>Object.values(c).some(e=>xr(e)&&!!e?.provider&&!e?.model),[c]),setDraft:(0,Q.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[]),setAdvisor:(0,Q.useCallback)(e=>{s(e)},[]),clearEdits:(0,Q.useCallback)(()=>{a({}),s(void 0)},[]),buildSavePatch:(0,Q.useCallback)(()=>Or(c,i),[c,i]),buildResetPatch:(0,Q.useCallback)(()=>kr(c),[c])}}function jr({assistantId:e,onClose:t}){let{data:n}=f({...Lt({path:{assistant_id:e}}),staleTime:3e4}),r=(0,Q.useMemo)(()=>n?.llm?.profiles??{},[n?.llm?.profiles]),i=(0,Q.useMemo)(()=>n?.llm?.profileOrder??[],[n?.llm?.profileOrder]),o=(0,Q.useMemo)(()=>n?.llm?.callSites??{},[n?.llm?.callSites]),s=(0,Q.useMemo)(()=>ce(r,i),[r,i]),l=Ne(),u=me(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u}),[u]),p=Jn(e),[m,h]=(0,Q.useState)(``),[g,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),{data:C,isLoading:w,isError:T,refetch:E}=f({...Ft({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),O=(0,Q.useMemo)(()=>(C?.callSites??[]).filter(e=>e.id!==`mainAgent`),[C]),k=!w&&!T&&!!C,A=!!n,M=k&&A,N=(0,Q.useMemo)(()=>O.map(e=>e.id),[O]),P=n?.llm?.advisorProfile??``,{drafts:F,advisorProfile:I,advisorDirty:R,callSiteDraftsDirty:z,hasUnsavedDrafts:H,hasValidationError:U,setDraft:W,setAdvisor:G,clearEdits:K,buildSavePatch:ee,buildResetPatch:J}=Ar({catalogCallSiteIds:N,persistedOverrides:o,persistedAdvisor:P,isSeeded:M}),Y=(0,Q.useMemo)(()=>new Set(N),[N]),re=(0,Q.useCallback)(e=>oe(s,e),[s]),X=(0,Q.useCallback)(e=>({value:e.name,label:pe(e),...ue(e,s,d)===`undispatchable`?{icon:(0,$.jsx)(_,{className:`h-3.5 w-3.5 text-[var(--system-mid-strong)]`}),tooltip:ne(e)}:{}}),[s,d]),ie=(0,Q.useMemo)(()=>de(s,[P],d).map(X),[s,P,X,d]),ae=(0,Q.useMemo)(()=>{let e=m.trim().toLowerCase();return e===``||`advisor`.includes(e)||`second opinion`.includes(e)},[m]),Z=(0,Q.useMemo)(()=>O.some(e=>Sr(e,o[e.id])!==null),[O,o]),le=(0,Q.useMemo)(()=>Object.entries(o).some(([e,t])=>Y.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[o,Y]),fe=(0,Q.useCallback)(e=>[...de(s,[e],d).map(X),{value:br,label:`Custom`}],[s,X,d]),he=(0,Q.useMemo)(()=>{if(!m.trim())return O;let e=m.toLowerCase();return O.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[O,m]),ge=(0,Q.useMemo)(()=>{if(!C)return[];let e=C.domains.map(e=>e.id),t=new Map(C.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=he.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let r=new Set(e),i=he.filter(e=>!r.has(e.domain));return i.length>0&&n.push({domain:{id:`other`,displayName:`Other`},sites:i}),n},[C,he]),_e=(0,Q.useCallback)((e,t)=>{if(!t){W(e,null);return}let n=se(s,O.find(t=>t.id===e)?.defaultProfile,d);if(n)W(e,{profile:n});else{let t=l[0]??te[0];W(e,{provider:t,model:q(t)??``})}},[O,s,l,W,d]),ve=(0,Q.useCallback)(async()=>{v(!0);try{let n=ee();await p.mutateAsync({path:{assistant_id:e},body:{llm:{...z?{callSites:n}:{},...R?{advisorProfile:I}:{}}}}),t(),B.success(`Overrides saved.`)}catch(e){B.error(`Failed to save overrides. Please try again.`),a(e,{context:`call_site_overrides_save`})}finally{v(!1)}},[ee,z,R,I,t,p,e]),ye=(0,Q.useCallback)(async()=>{v(!0);try{let n=J();await p.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),B.success(`Overrides reset.`)}catch(e){B.error(`Failed to reset overrides. Please try again.`),a(e,{context:`call_site_overrides_reset`})}finally{v(!1)}},[J,t,p,e]);return(0,$.jsxs)(dn,{title:`Action Overrides`,closeVariant:`outlined`,onClose:t,footer:(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[le&&(0,$.jsx)(c,{variant:`outlined`,onClick:()=>b(!0),disabled:g||!M,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:`Reset to Defaults`}),(0,$.jsx)(c,{variant:`primary`,onClick:()=>void ve(),disabled:!H||U||g,children:g?(0,$.jsx)(D,{className:`h-4 w-4 animate-spin`}):`Save`})]}),children:[(0,$.jsx)(`p`,{className:`mb-4 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Customize which model profile specific actions should use. Uses your default profile if no override is set.`}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(L,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:`Search actions…`,leftIcon:(0,$.jsx)(j,{className:`h-4 w-4`}),fullWidth:!0})}),(0,$.jsx)(c,{variant:`outlined`,onClick:()=>S(!0),disabled:!M||g||H||!Z,title:H?`Save or reset your changes first`:Z?void 0:`No actions currently use a profile`,children:`Bulk change`})]}),A&&ae&&(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:`Advisor`}),(0,$.jsx)(yr,{value:I,profileOptions:ie,disabled:g,onChange:G})]}),w&&(0,$.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,$.jsx)(D,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),T&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Couldn't load actions`}),(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Make sure your assistant is running`}),(0,$.jsx)(c,{variant:`outlined`,onClick:()=>void E(),children:`Retry`})]}),!w&&!T&&C&&(0,$.jsx)(Dr,{groups:ge,drafts:F,buildProfileOptionsForRow:fe,profileLabelFor:re,advisorMatchesSearch:ae,onDraftChange:W,onToggle:_e})]}),x&&C&&(0,$.jsx)(Tr,{assistantId:e,callSites:O,domains:C.domains,persistedOverrides:o,orderedProfiles:s,onClose:()=>S(!1),onApplied:K}),(0,$.jsx)(V,{open:y,title:`Reset to Defaults`,message:`Every action override will be reset and will follow its default. This cannot be undone.`,confirmLabel:`Reset to Defaults`,destructive:!0,onConfirm:()=>{b(!1),ye()},onCancel:()=>b(!1)})]})}function Mr({mode:e,connection:t,assistantId:n,existingNames:r,connections:i,variant:a=`modal`,onSave:o,onCancel:s}){let[l,u]=(0,Q.useState)(t?.label??``),f=t?.name??``,p=t?.provider??`anthropic`,m=t?.auth.type??`api_key`,[g,_]=(0,Q.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[v,y]=(0,Q.useState)(t?.baseUrl??``),[b,x]=(0,Q.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),E=p===`openai-compatible`,[D,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(!1),j=d(),M=(0,Q.useMemo)(()=>Me(g),[g]),N=m===`api_key`&&M!==null,{hasStoredCredential:P,isLoading:F}=be({assistantId:n,credentialKind:`credential`,credentialName:M?`${M.service}:${M.field}`:``,enabled:N}),{credentials:I}=Oe({assistantId:n,enabled:m===`api_key`});(0,Q.useEffect)(()=>{let e=t?.provider??`anthropic`;u(t?.label??``),t?.auth.type===`api_key`?_(t.auth.credential):_(t?``:`credential/${e}/api_key`),T(null),y(t?.baseUrl??``),x(t?.models?t.models.map(e=>e.id).join(`, `):``),O(``),A(!1)},[t]);let R=l.trim()!==(t?.label??``).trim(),B=E&&R?Ee(l,i,t?.name):null,V=f.trim().length>0&&B===null;async function H(){if(V){C(!0),T(null);try{let e;if(m===`api_key`){let t=g.trim()||`credential/${p}/api_key`,r=D.trim();if(r){A(!0);try{let e=Me(t);await pt({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:p,value:r},throwOnError:!0});let i=rt(n,`credential`,e?`${e.service}:${e.field}`:``);j.setQueryData(i,!0),j.invalidateQueries({queryKey:Rt({path:{assistant_id:n}})})}catch{T(`Failed to save API key. Please try again.`);return}finally{A(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{T(`Nothing to edit. Close and try again.`);return}let r=l.trim()||null,i={auth:e,label:r,...E&&{base_url:v.trim()||null,models:b.trim()?b.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:a,error:s,response:c}=await dt({path:{assistant_id:n,name:t?.name??f.trim()},body:i});if(!c?.ok){T(Ce(c?.status,s)??we(c?.status));return}if(!a){T(`Server returned an empty response. Please try again.`);return}o(a)}catch{T(`Failed to save provider. Please try again.`)}finally{C(!1)}}}let U=I.filter(e=>e.service===p),W=e!==`create`&&t?.auth.type===`api_key`,G=U.length>0||W,K=ke(`Enter your API key`,P);if(e===`create`)return(0,$.jsx)(De,{variant:a===`panel`?`inline`:`modal`,assistantId:n,existingNames:r,connections:i,defaultProviderType:p,onCreated:o,onCancel:s});let ee=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[`Display Name`,` `,(0,$.jsx)(`span`,{className:`text-[var(--content-disabled)]`,children:`(optional)`})]}),(0,$.jsx)(L,{value:l,onChange:e=>u(e.target.value),placeholder:`e.g. My Anthropic Key`,fullWidth:!0}),B?(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:Te[B]}):null]}),E&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,$.jsx)(L,{value:v,onChange:e=>y(e.target.value),placeholder:`https://api.example.com/v1`,fullWidth:!0})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,$.jsx)(L,{value:b,onChange:e=>x(e.target.value),placeholder:`model-1, model-2`,fullWidth:!0}),(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),m===`api_key`&&(0,$.jsx)(Se,{apiKeyValue:D,onApiKeyChange:O,credential:g,onCredentialChange:_,isLoadingCredential:F,apiKeyPlaceholder:K,provider:p,providerCredentials:U,showAdvancedSection:G,onError:T}),m===`oauth_subscription`&&(0,$.jsx)(Ae,{assistantId:n,onConnected:o}),w&&(0,$.jsx)(h,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:w})]}),q=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(c,{variant:`ghost`,size:`compact`,onClick:s,children:`Cancel`}),(0,$.jsx)(c,{variant:`primary`,size:`compact`,disabled:!V||S||k,onClick:()=>void H(),children:S?`Saving…`:`Save Changes`})]});return a===`panel`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[ee,(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:q})]}):(0,$.jsxs)(z.Content,{size:`md`,children:[(0,$.jsxs)(z.Header,{children:[(0,$.jsx)(z.Title,{children:`Edit Provider`}),(0,$.jsx)(z.Description,{children:t?`Editing ${Pe(t)}.`:`Edit provider settings.`})]}),(0,$.jsx)(z.Body,{children:ee}),(0,$.jsx)(z.Footer,{children:q})]})}function Nr({assistantId:e,connectionName:t,onClose:n}){let r=d(),{data:i}=f(It({path:{assistant_id:e}})),a=(0,Q.useMemo)(()=>i?.connections??[],[i]),o=(0,Q.useMemo)(()=>t==null?void 0:a.find(e=>e.name===t),[t,a]),s=t!=null&&i!=null&&o==null;(0,Q.useEffect)(()=>{s&&n()},[s,n]);function c(){r.invalidateQueries({queryKey:Ct({path:{assistant_id:e}})}),r.invalidateQueries({queryKey:jt({path:{assistant_id:e}})}),n()}return(0,$.jsx)(dn,{title:o?Pe(o):`Add Provider`,closeVariant:`outlined`,onClose:n,children:t==null||o!=null?(0,$.jsx)(Mr,{mode:o?`edit`:`create`,connection:o,variant:`panel`,assistantId:e,existingNames:a.map(e=>e.name),connections:a,onSave:c,onCancel:n}):null})}var Pr={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},Fr={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},Ir=`deepgram`;function Lr({assistantId:e,hideSaveButton:r=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=un(),s=e??o,c=xt(),l=d(),[u]=(0,Q.useState)(()=>nt.filter(e=>!e.requiresNativeDictation||xe())),p=Ir,{data:m}=f({...Lt({path:{assistant_id:s}}),enabled:c,staleTime:3e4}),h=m?.services?.stt,g=h?.mode===`managed`?`vellum`:h?.provider,_=(0,Q.useMemo)(()=>{let e=g?Fr[g]:void 0;if(e&&u.some(t=>t.id===e))return e;let n=t(Re,p);return u.some(e=>e.id===n)?n:p},[g,u,p]),v=!!g,[y,b]=jn(_),{available:x,currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T}=rn(s),[E,D]=(0,Q.useState)(!1),O=x&&y===_&&(Pr[y]?.provider===C||!!g&&!Fr[g]),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=t(Re,p);e===`macos-native`&&!u.some(t=>t.id===e)&&n(Re,p)},[u,p]);let I=(0,Q.useMemo)(()=>u.find(e=>e.id===y)??u[0],[u,y]),R=I.apiKeyPlaceholder!==void 0;(0,Q.useEffect)(()=>{M(t(Qe+y,``).length>0),A(``)},[y]);let z=(0,Q.useMemo)(()=>{let e=y!==_,t=k.trim().length>0;return e||t},[y,_,k]),V=(0,Q.useCallback)(async()=>{let e=k.trim();n(Re,y),e.length>0&&n(Qe+y,e);let r=Pr[y];F(!0);try{if(r?.credentialService){let n=e.length>0?e:t(Qe+y,``);if(n.length>0){let{response:e}=await ht({path:{assistant_id:s},body:{service:r.credentialService,field:`api_key`,value:n,label:`${I.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(r&&(y!==_||!v)||g===`vellum`&&y!==`vellum`){let e=r?.provider??Ir,{response:t}=await mt({path:{assistant_id:s},body:{services:{stt:{provider:e,mode:e===`vellum`?`managed`:`your-own`}}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return e.length>0&&M(!0),A(``),l.invalidateQueries({queryKey:kt({path:{assistant_id:s}})}),B.success(`Speech-to-text settings saved`),!0}catch(e){return B.error(e instanceof Error?e.message:`Failed to save speech-to-text settings`),!1}finally{F(!1)}},[s,y,k,I,_,v,g,l]);(0,Q.useEffect)(()=>{a?.({hasChanges:z,saving:P,save:V})},[a,z,P,V]);let U=(0,Q.useCallback)(()=>{n(Qe+y,``),M(!1),A(``)},[y]),W=j?`•••••••• (Enter a new key to replace)`:I.apiKeyPlaceholder;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:y,onChange:b,options:u.map(e=>({value:e.id,label:e.displayName})),"aria-label":`STT provider`})]}),O&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Spoken language`}),(0,$.jsx)(Je,{"aria-label":`Spoken language`,"aria-haspopup":`dialog`,onClick:()=>D(!0),value:an(S,C)}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Applies from your next spoken turn.`}),(0,$.jsx)(vn,{open:E,onOpenChange:D,title:`Spoken language`,currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T})]}),R&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,$.jsx)(L,{type:`password`,value:k,onChange:e=>A(e.target.value),placeholder:W,fullWidth:!0})]}),I.setupWarning&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)(N,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,$.jsx)(`span`,{children:I.setupWarning})]}),!i&&I.credentialsGuide&&(0,$.jsx)(En,{guide:I.credentialsGuide}),y===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Transcription runs through your Vellum account.`}),(!r||j)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[!r&&(0,$.jsx)(wn,{onClick:V,disabled:!z||P}),j&&(0,$.jsx)(Tn,{onClick:U})]})]})}function Rr(){return(0,$.jsx)(xn,{title:`Speech-to-Text`,subtitle:`Configure how your assistant transcribes speech`,children:(0,$.jsx)(Lr,{})})}async function zr(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 Br(n,r,i):t===`deepgram`?await Vr(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 Br(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 Hr(i,`ElevenLabs rejected the request.`)}}async function Vr(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 Hr(n,`Deepgram rejected the request.`)}}async function Hr(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 Ur({assistantId:e,value:t,onChange:n,className:r}){let[i,a]=(0,Q.useState)(!1),{voices:o}=cn(e);if(o.length===0)return null;let s=o.find(e=>e.model===t)??o[0];return(0,$.jsxs)(I.Root,{open:i,onOpenChange:a,children:[(0,$.jsx)(I.Trigger,{asChild:!0,children:(0,$.jsx)(Je,{"aria-label":`Voice`,value:s?on(s.description):`Select a voice`,className:r})}),(0,$.jsx)(I.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,$.jsx)(sn,{assistantId:e,value:t,onChange:n,onSelect:()=>a(!1),showSource:!0})})]})}var Wr={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function Gr({assistantId:e,hideSaveButton:r=!1,hideCredentialsGuide:i=!1,onSaveStateChange:a}={}){let o=un(),s=e??o,l=it.use.name()??`your assistant`,u=xt(),p=d(),{data:m}=f({...Et({path:{assistant_id:s}}),enabled:u,staleTime:1/0}),h=(0,Q.useMemo)(()=>{let e=m?.providers;if(!e)return Le;if(e.some(e=>e.id===`vellum`))return e;let t=Le.find(e=>e.id===`vellum`);return t?[t,...e]:e},[m]),{data:g}=f({...Lt({path:{assistant_id:s}}),enabled:u,staleTime:3e4}),_=g?.services?.tts,v=_?.mode===`managed`?`vellum`:_?.provider,y=`elevenlabs`,b=(0,Q.useMemo)(()=>v??t(`vellum:voice:ttsProvider`,y),[v,y]),x=!!v,[S,C]=jn(b),[w,T]=(0,Q.useState)(``),[D,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),{voices:R,defaultModel:z,fetched:V}=ln(s,{enabled:S===`vellum`}),U=_?.providers?.vellum?.model??z??``,[W,G]=jn(U),K=R.find(e=>e.model===W)??R[0],[ee,q]=(0,Q.useState)(null),J=R.some(e=>e.model===U),te=ee??(V&&U!==``&&!J),Y=(0,Q.useMemo)(()=>h.find(e=>e.id===S)??h[0],[S,h]),ne=S===`vellum`&&Y.supportsVoiceSelection&&W.trim()!==``&&W.trim()!==U,re=(0,Q.useCallback)(e=>{let n=t(Ke+e,``),r=t(ze+e,``);M(n.length>0),O(r),A(r),T(``)},[]);(0,Q.useEffect)(()=>{re(S)},[S,re]);let X=(0,Q.useMemo)(()=>{let e=S!==b,t=w.trim().length>0,n=D.trim()!==k;return e||t||n||ne},[S,b,w,D,k,ne]),ie=(0,Q.useCallback)(async()=>{let e=w.trim(),r=D.trim(),i=Y.id;n(et,i),e.length>0&&n(Ke+i,e),n(ze+i,r);let a=e.length>0?e:t(Ke+i,``),o=Wr[i];I(!0);try{if(a.length>0){let{response:e}=await ht({path:{assistant_id:s},body:{service:i,field:`api_key`,value:a,label:`${Y.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]:r}}}:{},...ne?{providers:{vellum:{model:W.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await mt({path:{assistant_id:s},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return M(a.length>0),A(r),T(``),p.invalidateQueries({queryKey:kt({path:{assistant_id:s}})}),B.success(`Text-to-speech settings saved`),!0}catch(e){return B.error(e instanceof Error?e.message:`Failed to save text-to-speech settings`),!1}finally{I(!1)}},[s,S,W,ne,w,D,Y,b,x,p]);(0,Q.useEffect)(()=>{a?.({hasChanges:X,saving:F,save:ie})},[a,X,F,ie]);let ae=(0,Q.useCallback)(()=>{n(Ke+S,``),M(!1),T(``)},[S]),oe=(0,Q.useCallback)(async()=>{P(!0);try{let e=t(Ke+S,``),n=w.trim(),r=n.length>0?n:e;if(r.length===0){B.error(`Save an API key for this provider before testing.`);return}let i=t(ze+S,``),a=D.trim(),o=await zr({provider:S,apiKey:r,voiceId:a.length>0?a:i,text:`Hey! It's ${l}. How does this sound?`});if(o.kind!==`audio`){B.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{P(!1)}},[l,w,S,D]),se=j?`•••••••• (Enter a new key to replace)`:Y.apiKeyPlaceholder,Z=S===`vellum`,ce=Z&&Y.supportsVoiceSelection,le=(0,$.jsxs)(c,{variant:`link`,size:`compact`,className:`inline-flex h-auto items-center gap-1 px-0 underline [--vbtn-fg:var(--content-tertiary)]`,onClick:()=>{q(!1),R.some(e=>e.model===W)||G(z||R[0]?.model||``)},children:[(0,$.jsx)(E,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Choose from catalog`]}),ue=ce&&te&&R.length>0?le:null;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:S,onChange:C,options:h.map(e=>({value:e.id,label:e.displayName})),"aria-label":`TTS provider`})]}),!Z&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,$.jsx)(L,{type:`password`,value:w,onChange:e=>T(e.target.value),placeholder:se,fullWidth:!0})]}),ce&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice`}),te?(0,$.jsx)(L,{type:`text`,value:W,onChange:e=>G(e.target.value),placeholder:`Enter a voice ID`,"aria-label":`Custom voice ID`,fullWidth:!0}):K?(0,$.jsx)(Ur,{assistantId:s,value:W,onChange:G}):V&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`No managed voices are currently available.`})]}),Y.supportsVoiceSelection&&!Z&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice ID`}),(0,$.jsx)(L,{type:`text`,value:D,onChange:e=>O(e.target.value),placeholder:`Enter a voice ID`,fullWidth:!0})]}),!i&&!Z&&(0,$.jsx)(En,{guide:Y.credentialsGuide}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!Z&&(0,$.jsx)(c,{variant:`outlined`,onClick:oe,disabled:N,children:N?`Testing…`:`Test`}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[ue,!r&&(0,$.jsx)(wn,{onClick:ie,disabled:!X||F}),j&&!Z&&(0,$.jsx)(Tn,{onClick:ae})]})]})]})}function Kr(){return(0,$.jsx)(xn,{id:`text-to-speech`,title:`Text-to-Speech`,subtitle:`Configure how your assistant speaks`,children:(0,$.jsx)(Gr,{})})}var qr=`default`;function Jr(){let e=un(),i=d(),{data:o}=f({...Lt({path:{assistant_id:e}}),staleTime:3e4}),s=Dt({onSuccess:t=>{At(i,{path:{assistant_id:e}},t)}}),c=An(),l=(0,Q.useMemo)(()=>o?o.services?.[`web-fetch`]?.provider||t(`vellum:ai:webFetchProvider`,qr):t(Be,qr),[o]),[u,p]=(0,Q.useState)(!1),[m,h]=jn(l),[g,_]=(0,Q.useState)(``),v=re.has(m),{hasStoredCredential:y}=be({assistantId:e,credentialKind:`api_key`,credentialName:m,enabled:v}),b=g.trim().length>0,x=u||v&&!y&&!b||m===l&&!b,S=ke(G[m]??`Enter your API key`,y),C=(0,Q.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 B.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(Be,m),r){let r=ie(m);r&&n(r,t);let a=rt(e,`api_key`,m);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),_(``)}B.success(`Web fetch settings saved.`)}catch(e){a(e,{context:`settings-ai-web-fetch-persist-local`}),B.error(`Saved, but local preferences could not be written.`)}},[v,s,c,i,e,g,m]),w=(0,Q.useCallback)(()=>{let e=ie(m);e&&r(e),_(``),h(qr),n(Be,qr)},[m,h]);return(0,$.jsx)(xn,{id:`web-fetch`,title:`Web Fetch`,subtitle:`Configure how your assistant reads individual web pages`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{value:m,onChange:h,options:J.map(e=>({value:e,label:_e[e]??e}))})]}),v&&(0,$.jsx)(L,{label:`API Key`,type:`password`,value:g,onChange:e=>_(e.target.value),placeholder:S,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(wn,{onClick:C,disabled:x}),u&&(0,$.jsx)(D,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),v&&(0,$.jsx)(Tn,{onClick:w,filled:!0})]})]})})}var Yr=`0.10.12`;function Xr(){return ot(Yr)}function Zr(){let e=un(),i=d(),o=xt(),{data:s}=f({...Lt({path:{assistant_id:e}}),enabled:o,staleTime:3e4}),c=Dt({onSuccess:t=>{At(i,{path:{assistant_id:e}},t)}}),l=An(),u=(0,Q.useMemo)(()=>{if(!s)return t(Xe,`inference-provider-native`);let e=s.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||t(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[s]),[p,m]=(0,Q.useState)(!1),[h,g]=jn(u),[_,v]=(0,Q.useState)(``),y=ae.has(h),{hasStoredCredential:b}=be({assistantId:e,credentialKind:`api_key`,credentialName:h,enabled:y}),x=_.trim().length>0,S=p||y&&!b&&!x||h===u&&!x,C=ke(ve[h]??`Enter your API key`,b),w=(0,Q.useCallback)(async()=>{m(!0);let t=_.trim(),r=fe(h),o=y&&t.length>0;try{o&&await l(h,t),await st();let n=h===`vellum`?Xr()?{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 B.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=rt(e,`api_key`,h);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),v(``)}B.success(`Web search settings saved.`)}catch(e){a(e,{context:`settings-ai-web-search-persist-local`}),B.error(`Saved, but local preferences could not be written.`)}},[y,c,l,i,e,_,h]),T=(0,Q.useCallback)(()=>{let e=fe(h);e&&r(e),v(``),g(`inference-provider-native`),n(Xe,`inference-provider-native`)},[h,g]);return(0,$.jsx)(xn,{title:`Web Search`,subtitle:`Configure how your assistant should search the web`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,$.jsx)(H,{"aria-label":`Web search provider`,value:h,onChange:g,options:ge.map(e=>({value:e,label:Y[e]??e}))})]}),h===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Search runs through your Vellum account.`}),y&&(0,$.jsx)(L,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:C,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(wn,{onClick:w,disabled:S}),p&&(0,$.jsx)(D,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),y&&(0,$.jsx)(Tn,{onClick:T,filled:!0})]})]})})}function Qr(){let e=un(),t=Bt(),[n,r]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]);let i=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto`,children:[(0,$.jsx)(Sn,{}),(0,$.jsx)(gr,{panel:n,onOpenPanel:r,onClosePanel:()=>r(null)}),(0,$.jsx)(Zr,{}),(0,$.jsx)(Jr,{}),(0,$.jsx)(kn,{}),(0,$.jsx)(Fn,{}),(0,$.jsx)(Kr,{}),(0,$.jsx)(Rr,{})]}),a=`${e??`none`}:${n?.kind===`profile`?`profile:${n.name}`:n?.kind===`provider`?`provider:${n.name}`:n?.kind??`closed`}`,o=n?.kind===`provider`||n?.kind===`add-provider`,s=n!=null&&e?n.kind===`overrides`?(0,$.jsx)(jr,{assistantId:e,onClose:()=>r(null)},a):o?(0,$.jsx)(Nr,{assistantId:e,connectionName:n.kind===`provider`?n.name:null,onClose:()=>r(null)},a):(0,$.jsx)(vr,{assistantId:e,profileName:n.kind===`profile`?n.name:null,onClose:()=>r(null)},a):null;return s&&t?(0,$.jsx)(mn,{children:s}):s?(0,$.jsx)(hn,{storageKey:`aiSettingsDetailDrawerWidth`,detailKey:a,section:i,detail:s}):i}export{Qr as AiPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-BENY-yx_.js";import{n as r}from"./QueryClientProvider-CMu7CkQU.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./cn-DFWryB3N.js";import{t as o}from"./createLucideIcon-C1mdGPB9.js";import"./src-hNk11eS3.js";import{t as s}from"./external-link-vwewPjbo.js";import{t as c}from"./puzzle-CIWAeBs0.js";import{n as l}from"./toast-BpuLSxyt.js";import{t as u}from"./confirm-dialog-zx8L9sUi.js";import{n as d,t as f}from"./create-selectors-DBgi9gD3.js";import{t as p}from"./sdk.gen-CBPZ2IdN.js";import{i as m}from"./typed-storage-lk6_tW16.js";import{i as h}from"./react-query.gen-DxjuNs-5.js";import{s as g}from"./viewer-store-DhrkeZmJ.js";import{t as _}from"./haptics-Mqend0Ru.js";import{t as v}from"./pointer-CmipOtDe.js";import{t as y}from"./misc-Z0jXGGeY.js";import{t as b}from"./edge-swipe-arbiter-store-aOM60mqn.js";import{i as x}from"./sandbox-bridge-BlniBIsp.js";var S=o(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),C=o(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),w=e(t(),1),T=36,E=.8,D=8,O=.35;function k({enabled:e,leadingActions:t,trailingActions:n}){let r=(t?.length??0)*72,i=(n?.length??0)*72,[a,o]=(0,w.useState)(0),[s,c]=(0,w.useState)(!1),[l,u]=(0,w.useState)(`none`),d=b.use.registerOpenRow(),f=b.use.unregisterOpenRow();(0,w.useEffect)(()=>{if(l!==`none`)return d(),f},[l,d,f]);let p=(0,w.useRef)(null),m=(0,w.useCallback)(()=>{p.current=null,c(!1),o(0)},[]),h=(0,w.useCallback)(()=>{o(0),u(`none`)},[]);return{offset:a,isDragging:s,revealedSide:l,leadingWidth:r,trailingWidth:i,onTouchStart:(0,w.useCallback)(r=>{if(!e||!t&&!n)return;if(r.touches.length!==1){m();return}let i=r.touches[0];p.current={touchId:i.identifier,startX:i.clientX,startY:i.clientY,axis:`undecided`,lastDx:0,startOffset:a}},[e,t,n,a,m]),onTouchMove:(0,w.useCallback)(e=>{let t=p.current;if(!t)return;if(e.touches.length!==1){m();return}let n=e.touches[0];if(n.identifier!==t.touchId)return;let a=n.clientX-t.startX,s=n.clientY-t.startY;if(t.lastDx=a,t.axis===`undecided`){if(Math.abs(a)<D&&Math.abs(s)<D)return;if(Math.abs(s)>Math.abs(a)*E){p.current=null;return}t.axis=`horizontal`,c(!0)}if(t.axis!==`horizontal`)return;if(Math.abs(a)<T&&Math.abs(s)>Math.abs(a)*E){m(),o(t.startOffset);return}let l=t.startOffset+a,u=r,d=-i;l>u?l=u+(l-u)*O:l<d&&(l=d+(l-d)*O),(t.startOffset>0&&l<0&&i===0||t.startOffset<0&&l>0&&r===0)&&(l*=O),o(l)},[r,i,m]),onTouchEnd:(0,w.useCallback)(e=>{let t=p.current;if(!t){m();return}if(t.axis===`undecided`){p.current=null,c(!1);return}if(t.axis!==`horizontal`){m();return}if(e.touches.length>0){m();return}let n=Array.from(e.changedTouches).find(e=>e.identifier===t.touchId),a=n?n.clientX-t.startX:t.lastDx,s=t.startOffset+a;s<=-T&&i>0?(_.light(),o(-i),u(`trailing`)):s>=T&&r>0?(_.light(),o(r),u(`leading`)):(o(0),u(`none`)),p.current=null,c(!1)},[r,i,m]),onTouchCancel:(0,w.useCallback)(()=>{h(),m()},[h,m]),close:h}}var A=i();function j({action:e,onAfterSelect:t,hidden:n=!1}){let r=(0,w.useCallback)(()=>{e.onSelect(),t()},[e,t]),i=e.icon;return(0,A.jsxs)(`button`,{type:`button`,"aria-label":e.label,"aria-hidden":n,tabIndex:n?-1:0,onClick:r,className:a(`flex shrink-0 flex-col items-center justify-center gap-1`,`touch-mobile:transition-none`),style:{width:72,color:e.variant===`destructive`?`var(--aux-white)`:`var(--content-inset)`,background:e.variant===`destructive`?`var(--system-negative-strong)`:`var(--primary-base)`},children:[(0,A.jsx)(i,{size:18}),(0,A.jsx)(`span`,{className:`text-[10px] font-medium leading-none`,children:e.label})]})}var M=(0,w.forwardRef)(function({children:e,leadingActions:t,trailingActions:n,enabled:r=v(),className:i,style:o,...s},c){let l=r&&((t?.length??0)>0||(n?.length??0)>0),{offset:u,isDragging:d,onTouchStart:f,onTouchMove:p,onTouchEnd:m,onTouchCancel:h,close:g}=k({enabled:l,leadingActions:t,trailingActions:n});return l?(0,A.jsxs)(`div`,{ref:c,className:a(`relative overflow-hidden`,i),...s,style:{...o,touchAction:`pan-y`},onTouchStart:f,onTouchMove:p,onTouchEnd:m,onTouchCancel:h,children:[n&&n.length>0?(0,A.jsx)(`div`,{className:`absolute inset-y-0 right-0 flex`,"aria-hidden":u>=0,style:u>=0?{pointerEvents:`none`}:void 0,children:n.map(e=>(0,A.jsx)(j,{action:e,onAfterSelect:g,hidden:u>=0},e.id))}):null,t&&t.length>0?(0,A.jsx)(`div`,{className:`absolute inset-y-0 left-0 flex`,"aria-hidden":u<=0,style:u<=0?{pointerEvents:`none`}:void 0,children:t.map(e=>(0,A.jsx)(j,{action:e,onAfterSelect:g,hidden:u<=0},e.id))}):null,(0,A.jsx)(`div`,{className:a(`relative bg-[var(--surface-overlay)] transition-transform`,d&&`transition-none`),style:{transform:`translateX(${u}px)`,zIndex:1},children:e})]}):(0,A.jsx)(`div`,{ref:c,className:i,style:o,...s,children:e})});function N(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.appId==`string`&&typeof t.pinnedOrder==`number`&&Number.isFinite(t.pinnedOrder)&&typeof t.name==`string`&&(t.icon===void 0||typeof t.icon==`string`)&&(t.color===void 0||typeof t.color==`string`)}function P(e){let t=JSON.parse(e);return Array.isArray(t)?t.filter(N):null}var F=m({key:`vellum:pinnedApps`,scope:`user`,parse:P,serialize:JSON.stringify,fallback:[]}),I=F.load;F.save;var L=F.subscribe;function R(e){let t=F.load();if(t.some(t=>t.appId===e.id))return;let n=t.reduce((e,t)=>Math.max(e,t.pinnedOrder),0);F.save([...t,{appId:e.id,pinnedOrder:n+1,name:e.name,icon:e.icon}])}function z(e){let t=F.load().filter(t=>t.appId!==e);t=t.sort((e,t)=>e.pinnedOrder-t.pinnedOrder).map((e,t)=>({...e,pinnedOrder:t+1})),F.save(t)}function B(e,t){let n=F.load();n.some(t=>t.appId===e)&&F.save(n.map(n=>{if(n.appId!==e)return n;let{color:r,...i}=n;return t===null?i:{...i,color:t}}))}var V=new Set;function H(e){return{pinnedApps:e,pinnedAppIds:new Set(e.map(e=>e.appId))}}function U(){let e=W.getState(),t=I();if(t===e.pinnedApps)return;let n=H(t);W.setState(n);for(let t of e.pinnedAppIds)if(!n.pinnedAppIds.has(t))for(let e of V)e(t)}var W=d()((e,t)=>({...H(I()),togglePin:e=>{t().pinnedAppIds.has(e.id)?t().unpin(e.id):(R(e),U())},unpin:e=>{t().pinnedAppIds.has(e)&&(z(e),U())},setColor:(e,n)=>{t().pinnedAppIds.has(e)&&(B(e,n),U())},isPinned:e=>t().pinnedAppIds.has(e),onUnpin:e=>(V.add(e),()=>{V.delete(e)})}));L(U);var G=f(W);function K({app:e,isDeleting:t,onConfirm:n,onCancel:r}){return(0,A.jsx)(u,{open:e!==null,title:`Delete app`,message:e?`"${e.name}" will be permanently removed.`:``,confirmLabel:t?`Deleting…`:`Delete`,destructive:!0,onConfirm:n,onCancel:r})}function q(e){let t=r(),n=G.use.togglePin(),i=G.use.pinnedAppIds(),[a,o]=(0,w.useState)(null),[s,c]=(0,w.useState)(!1);return{pendingDelete:a,isDeleting:s,requestDelete:o,confirmDelete:(0,w.useCallback)(async()=>{if(!(!a||s)){c(!0);try{await p({path:{assistant_id:e,id:a.id},throwOnError:!0}),g(e,a.id),t.invalidateQueries({queryKey:h({path:{assistant_id:e}})}),i.has(a.id)&&n(a),o(null)}catch(e){l.error(e instanceof Error?e.message:`Failed to delete app`)}finally{c(!1)}}},[a,s,e,i,n,t]),cancelDelete:(0,w.useCallback)(()=>{s||o(null)},[s])}}function J({name:e,description:t,icon:r,loadHtml:i,isPinned:a=!1,isLoading:o=!1,isOpenDisabled:c=!1,isPreviewPending:l=!1,onOpen:u,onPin:d}){return(0,A.jsxs)(`div`,{className:y(`flex flex-col gap-2 rounded-xl border border-[var(--border-base)]`,`bg-[var(--surface-lift)] p-3`),children:[(0,A.jsx)(Y,{name:e,icon:r,loadHtml:l?void 0:i,isLoading:o,isPreviewPending:l}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-0.5`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-2 truncate text-body-large-default text-[color:var(--content-emphasised)]`,children:[r?(0,A.jsx)(`span`,{"aria-hidden":!0,className:`leading-none`,children:r}):null,(0,A.jsx)(`span`,{className:`truncate`,children:e})]}),t?(0,A.jsx)(`span`,{className:`truncate text-body-medium-default text-[color:var(--content-secondary)]`,children:t}):null]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 px-0.5`,children:[(0,A.jsx)(n,{variant:`primary`,leftIcon:(0,A.jsx)(s,{}),onClick:u,disabled:c||u==null,children:`Open App`}),(0,A.jsx)(n,{variant:`outlined`,leftIcon:a?(0,A.jsx)(S,{}):(0,A.jsx)(C,{}),onClick:d,disabled:d==null,children:a?`Unpin`:`Pin`})]})]})}function Y({name:e,icon:t,loadHtml:n,isLoading:r=!1,isPreviewPending:i=!1,className:a}){let o=(0,w.useRef)(null),[s,l]=(0,w.useState)(null),[u,d]=(0,w.useState)(!1);return(0,w.useEffect)(()=>{if(n==null)return;let e=o.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(([e])=>{e?.isIntersecting&&(d(!0),t.disconnect())},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[n]),(0,w.useEffect)(()=>{if(!u||n==null)return;let e=!1;return n().then(t=>{e||l(t)}).catch(()=>{}),()=>{e=!0}},[u,n]),(0,A.jsxs)(`div`,{ref:o,className:y(`relative aspect-[16/10] w-full overflow-hidden rounded-lg`,`border border-[var(--border-base)] bg-[var(--surface-base)]`,a),children:[(0,A.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:i?null:t?(0,A.jsx)(`span`,{className:`text-4xl`,children:t}):(0,A.jsx)(c,{size:32,className:`text-[var(--content-tertiary)]`})}),s!=null&&(0,A.jsx)(`iframe`,{srcDoc:x(s),sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,title:`${e} preview`,"aria-hidden":`true`,tabIndex:-1,loading:`lazy`,scrolling:`no`,className:`absolute left-0 top-0 border-none bg-[var(--surface-base)]`,style:{width:`200%`,height:`200%`,transform:`scale(0.5)`,transformOrigin:`top left`,pointerEvents:`none`}}),r&&(0,A.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-[var(--surface-base)]/60 backdrop-blur-sm`,children:(0,A.jsx)(`div`,{className:`h-5 w-5 animate-spin rounded-full border-2 border-[var(--border-base)] border-t-[var(--primary-base)]`})})]})}export{G as a,S as c,K as i,Y as n,M as o,q as r,C as s,J as t};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-BENY-yx_.js";import{n as r}from"./QueryClientProvider-CMu7CkQU.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./cn-DFWryB3N.js";import{t as o}from"./createLucideIcon-C1mdGPB9.js";import"./src-DyqTPMO2.js";import{t as s}from"./external-link-vwewPjbo.js";import{t as c}from"./puzzle-CIWAeBs0.js";import{n as l}from"./toast-BpuLSxyt.js";import{t as u}from"./confirm-dialog-zx8L9sUi.js";import{n as d,t as f}from"./create-selectors-DBgi9gD3.js";import{t as p}from"./sdk.gen-CBPZ2IdN.js";import{i as m}from"./typed-storage-lk6_tW16.js";import{i as h}from"./react-query.gen-DxjuNs-5.js";import{s as g}from"./viewer-store-CayI6XWh.js";import{t as _}from"./haptics-Mqend0Ru.js";import{t as v}from"./pointer-CmipOtDe.js";import{t as y}from"./misc-Z0jXGGeY.js";import{t as b}from"./edge-swipe-arbiter-store-aOM60mqn.js";import{i as x}from"./sandbox-bridge-WZhWtkZd.js";var S=o(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),C=o(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),w=e(t(),1),T=36,E=.8,D=8,O=.35;function k({enabled:e,leadingActions:t,trailingActions:n}){let r=(t?.length??0)*72,i=(n?.length??0)*72,[a,o]=(0,w.useState)(0),[s,c]=(0,w.useState)(!1),[l,u]=(0,w.useState)(`none`),d=b.use.registerOpenRow(),f=b.use.unregisterOpenRow();(0,w.useEffect)(()=>{if(l!==`none`)return d(),f},[l,d,f]);let p=(0,w.useRef)(null),m=(0,w.useCallback)(()=>{p.current=null,c(!1),o(0)},[]),h=(0,w.useCallback)(()=>{o(0),u(`none`)},[]);return{offset:a,isDragging:s,revealedSide:l,leadingWidth:r,trailingWidth:i,onTouchStart:(0,w.useCallback)(r=>{if(!e||!t&&!n)return;if(r.touches.length!==1){m();return}let i=r.touches[0];p.current={touchId:i.identifier,startX:i.clientX,startY:i.clientY,axis:`undecided`,lastDx:0,startOffset:a}},[e,t,n,a,m]),onTouchMove:(0,w.useCallback)(e=>{let t=p.current;if(!t)return;if(e.touches.length!==1){m();return}let n=e.touches[0];if(n.identifier!==t.touchId)return;let a=n.clientX-t.startX,s=n.clientY-t.startY;if(t.lastDx=a,t.axis===`undecided`){if(Math.abs(a)<D&&Math.abs(s)<D)return;if(Math.abs(s)>Math.abs(a)*E){p.current=null;return}t.axis=`horizontal`,c(!0)}if(t.axis!==`horizontal`)return;if(Math.abs(a)<T&&Math.abs(s)>Math.abs(a)*E){m(),o(t.startOffset);return}let l=t.startOffset+a,u=r,d=-i;l>u?l=u+(l-u)*O:l<d&&(l=d+(l-d)*O),(t.startOffset>0&&l<0&&i===0||t.startOffset<0&&l>0&&r===0)&&(l*=O),o(l)},[r,i,m]),onTouchEnd:(0,w.useCallback)(e=>{let t=p.current;if(!t){m();return}if(t.axis===`undecided`){p.current=null,c(!1);return}if(t.axis!==`horizontal`){m();return}if(e.touches.length>0){m();return}let n=Array.from(e.changedTouches).find(e=>e.identifier===t.touchId),a=n?n.clientX-t.startX:t.lastDx,s=t.startOffset+a;s<=-T&&i>0?(_.light(),o(-i),u(`trailing`)):s>=T&&r>0?(_.light(),o(r),u(`leading`)):(o(0),u(`none`)),p.current=null,c(!1)},[r,i,m]),onTouchCancel:(0,w.useCallback)(()=>{h(),m()},[h,m]),close:h}}var A=i();function j({action:e,onAfterSelect:t,hidden:n=!1}){let r=(0,w.useCallback)(()=>{e.onSelect(),t()},[e,t]),i=e.icon;return(0,A.jsxs)(`button`,{type:`button`,"aria-label":e.label,"aria-hidden":n,tabIndex:n?-1:0,onClick:r,className:a(`flex shrink-0 flex-col items-center justify-center gap-1`,`touch-mobile:transition-none`),style:{width:72,color:e.variant===`destructive`?`var(--aux-white)`:`var(--content-inset)`,background:e.variant===`destructive`?`var(--system-negative-strong)`:`var(--primary-base)`},children:[(0,A.jsx)(i,{size:18}),(0,A.jsx)(`span`,{className:`text-[10px] font-medium leading-none`,children:e.label})]})}var M=(0,w.forwardRef)(function({children:e,leadingActions:t,trailingActions:n,enabled:r=v(),className:i,style:o,...s},c){let l=r&&((t?.length??0)>0||(n?.length??0)>0),{offset:u,isDragging:d,onTouchStart:f,onTouchMove:p,onTouchEnd:m,onTouchCancel:h,close:g}=k({enabled:l,leadingActions:t,trailingActions:n});return l?(0,A.jsxs)(`div`,{ref:c,className:a(`relative overflow-hidden`,i),...s,style:{...o,touchAction:`pan-y`},onTouchStart:f,onTouchMove:p,onTouchEnd:m,onTouchCancel:h,children:[n&&n.length>0?(0,A.jsx)(`div`,{className:`absolute inset-y-0 right-0 flex`,"aria-hidden":u>=0,style:u>=0?{pointerEvents:`none`}:void 0,children:n.map(e=>(0,A.jsx)(j,{action:e,onAfterSelect:g,hidden:u>=0},e.id))}):null,t&&t.length>0?(0,A.jsx)(`div`,{className:`absolute inset-y-0 left-0 flex`,"aria-hidden":u<=0,style:u<=0?{pointerEvents:`none`}:void 0,children:t.map(e=>(0,A.jsx)(j,{action:e,onAfterSelect:g,hidden:u<=0},e.id))}):null,(0,A.jsx)(`div`,{className:a(`relative bg-[var(--surface-overlay)] transition-transform`,d&&`transition-none`),style:{transform:`translateX(${u}px)`,zIndex:1},children:e})]}):(0,A.jsx)(`div`,{ref:c,className:i,style:o,...s,children:e})});function N(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.appId==`string`&&typeof t.pinnedOrder==`number`&&Number.isFinite(t.pinnedOrder)&&typeof t.name==`string`&&(t.icon===void 0||typeof t.icon==`string`)&&(t.color===void 0||typeof t.color==`string`)}function P(e){let t=JSON.parse(e);return Array.isArray(t)?t.filter(N):null}var F=m({key:`vellum:pinnedApps`,scope:`user`,parse:P,serialize:JSON.stringify,fallback:[]}),I=F.load;F.save;var L=F.subscribe;function R(e){let t=F.load();if(t.some(t=>t.appId===e.id))return;let n=t.reduce((e,t)=>Math.max(e,t.pinnedOrder),0);F.save([...t,{appId:e.id,pinnedOrder:n+1,name:e.name,icon:e.icon}])}function z(e){let t=F.load().filter(t=>t.appId!==e);t=t.sort((e,t)=>e.pinnedOrder-t.pinnedOrder).map((e,t)=>({...e,pinnedOrder:t+1})),F.save(t)}function B(e,t){let n=F.load();n.some(t=>t.appId===e)&&F.save(n.map(n=>{if(n.appId!==e)return n;let{color:r,...i}=n;return t===null?i:{...i,color:t}}))}var V=new Set;function H(e){return{pinnedApps:e,pinnedAppIds:new Set(e.map(e=>e.appId))}}function U(){let e=W.getState(),t=I();if(t===e.pinnedApps)return;let n=H(t);W.setState(n);for(let t of e.pinnedAppIds)if(!n.pinnedAppIds.has(t))for(let e of V)e(t)}var W=d()((e,t)=>({...H(I()),togglePin:e=>{t().pinnedAppIds.has(e.id)?t().unpin(e.id):(R(e),U())},unpin:e=>{t().pinnedAppIds.has(e)&&(z(e),U())},setColor:(e,n)=>{t().pinnedAppIds.has(e)&&(B(e,n),U())},isPinned:e=>t().pinnedAppIds.has(e),onUnpin:e=>(V.add(e),()=>{V.delete(e)})}));L(U);var G=f(W);function K({app:e,isDeleting:t,onConfirm:n,onCancel:r}){return(0,A.jsx)(u,{open:e!==null,title:`Delete app`,message:e?`"${e.name}" will be permanently removed.`:``,confirmLabel:t?`Deleting…`:`Delete`,destructive:!0,onConfirm:n,onCancel:r})}function q(e){let t=r(),n=G.use.togglePin(),i=G.use.pinnedAppIds(),[a,o]=(0,w.useState)(null),[s,c]=(0,w.useState)(!1);return{pendingDelete:a,isDeleting:s,requestDelete:o,confirmDelete:(0,w.useCallback)(async()=>{if(!(!a||s)){c(!0);try{await p({path:{assistant_id:e,id:a.id},throwOnError:!0}),g(e,a.id),t.invalidateQueries({queryKey:h({path:{assistant_id:e}})}),i.has(a.id)&&n(a),o(null)}catch(e){l.error(e instanceof Error?e.message:`Failed to delete app`)}finally{c(!1)}}},[a,s,e,i,n,t]),cancelDelete:(0,w.useCallback)(()=>{s||o(null)},[s])}}function J({name:e,description:t,icon:r,loadHtml:i,isPinned:a=!1,isLoading:o=!1,isOpenDisabled:c=!1,isPreviewPending:l=!1,onOpen:u,onPin:d}){return(0,A.jsxs)(`div`,{className:y(`flex flex-col gap-2 rounded-xl border border-[var(--border-base)]`,`bg-[var(--surface-lift)] p-3`),children:[(0,A.jsx)(Y,{name:e,icon:r,loadHtml:l?void 0:i,isLoading:o,isPreviewPending:l}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-0.5 px-0.5`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-2 truncate text-body-large-default text-[color:var(--content-emphasised)]`,children:[r?(0,A.jsx)(`span`,{"aria-hidden":!0,className:`leading-none`,children:r}):null,(0,A.jsx)(`span`,{className:`truncate`,children:e})]}),t?(0,A.jsx)(`span`,{className:`truncate text-body-medium-default text-[color:var(--content-secondary)]`,children:t}):null]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 px-0.5`,children:[(0,A.jsx)(n,{variant:`primary`,leftIcon:(0,A.jsx)(s,{}),onClick:u,disabled:c||u==null,children:`Open App`}),(0,A.jsx)(n,{variant:`outlined`,leftIcon:a?(0,A.jsx)(S,{}):(0,A.jsx)(C,{}),onClick:d,disabled:d==null,children:a?`Unpin`:`Pin`})]})]})}function Y({name:e,icon:t,loadHtml:n,isLoading:r=!1,isPreviewPending:i=!1,className:a}){let o=(0,w.useRef)(null),[s,l]=(0,w.useState)(null),[u,d]=(0,w.useState)(!1);return(0,w.useEffect)(()=>{if(n==null)return;let e=o.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(([e])=>{e?.isIntersecting&&(d(!0),t.disconnect())},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[n]),(0,w.useEffect)(()=>{if(!u||n==null)return;let e=!1;return n().then(t=>{e||l(t)}).catch(()=>{}),()=>{e=!0}},[u,n]),(0,A.jsxs)(`div`,{ref:o,className:y(`relative aspect-[16/10] w-full overflow-hidden rounded-lg`,`border border-[var(--border-base)] bg-[var(--surface-base)]`,a),children:[(0,A.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:i?null:t?(0,A.jsx)(`span`,{className:`text-4xl`,children:t}):(0,A.jsx)(c,{size:32,className:`text-[var(--content-tertiary)]`})}),s!=null&&(0,A.jsx)(`iframe`,{srcDoc:x(s),sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,title:`${e} preview`,"aria-hidden":`true`,tabIndex:-1,loading:`lazy`,scrolling:`no`,className:`absolute left-0 top-0 border-none bg-[var(--surface-base)]`,style:{width:`200%`,height:`200%`,transform:`scale(0.5)`,transformOrigin:`top left`,pointerEvents:`none`}}),r&&(0,A.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-[var(--surface-base)]/60 backdrop-blur-sm`,children:(0,A.jsx)(`div`,{className:`h-5 w-5 animate-spin rounded-full border-2 border-[var(--border-base)] border-t-[var(--primary-base)]`})})]})}export{G as a,S as c,K as i,Y as n,M as o,q as r,C as s,J as t};