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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/assets/{account-page-B8Z6QZKe.js → account-page-Cn_Ux2k8.js} +1 -1
  2. package/dist/assets/{acp-run-detail-panel-DvbBzgps.js → acp-run-detail-panel-hdemc9Ns.js} +4 -4
  3. package/dist/assets/{activity-steps-panel-Cc6sOJ7O.js → activity-steps-panel-CJDoPVUC.js} +1 -1
  4. package/dist/assets/ai-page-DX1CAGiX.js +1 -0
  5. package/dist/assets/{api-key-screen-D7u7SPiq.js → api-key-screen-C0F9Kodk.js} +1 -1
  6. package/dist/assets/{background-task-detail-panel-BNb7N4q2.js → background-task-detail-panel-B3sQQ2WB.js} +1 -1
  7. package/dist/assets/{billing-page-QcfuHjR9.js → billing-page-DbgQl5CS.js} +2 -2
  8. package/dist/assets/{bookmarks-page-CRZqWo3d.js → bookmarks-page-Bg1kpqdy.js} +1 -1
  9. package/dist/assets/{channels-page-route-C_YBqGsE.js → channels-page-route-Cm7KQpHs.js} +2 -2
  10. package/dist/assets/{command-palette-y6-mfSgF.js → command-palette-B23DDF8y.js} +1 -1
  11. package/dist/assets/{command-palette-window-page-DUPyaVxH.js → command-palette-window-page-2gnvF4NV.js} +1 -1
  12. package/dist/assets/community-page-De9KLKyn.js +1 -0
  13. package/dist/assets/contacts-page-route-CZwZ6baw.js +1 -0
  14. package/dist/assets/{credentials-page-CvW82Tlz.js → credentials-page-st-zOas5.js} +1 -1
  15. package/dist/assets/{debug-page-CmPi5tnZ.js → debug-page-BhcVrLKj.js} +2 -2
  16. package/dist/assets/{deploy-dialogs-DaPjl9bW.js → deploy-dialogs-BJRrRbSc.js} +1 -1
  17. package/dist/assets/{detail-panel-stop-button-DpEnEgJn.js → detail-panel-stop-button-c0oweWwM.js} +1 -1
  18. package/dist/assets/{developer-page-CV-CsA3N.js → developer-page-DRakR84C.js} +1 -1
  19. package/dist/assets/{dictation-overlay-page-g9BvDir_.js → dictation-overlay-page-jXIAQQGI.js} +1 -1
  20. package/dist/assets/{document-viewer-page-C5v8akIG.js → document-viewer-page-B6lpLvJw.js} +1 -1
  21. package/dist/assets/{emails-page-CtFCYDq9.js → emails-page-ChYRO5ST.js} +1 -1
  22. package/dist/assets/general-page-0F5njKZW.js +1 -0
  23. package/dist/assets/{hatching-screen-HNiZriOH.js → hatching-screen-CW3BRgRH.js} +1 -1
  24. package/dist/assets/home-page-route-D_8JCZ_Q.js +1 -0
  25. package/dist/assets/{hosting-screen-CkRQ1ibr.js → hosting-screen-DHETBcAy.js} +1 -1
  26. package/dist/assets/identity-page-route-B1o8eOMl.js +7 -0
  27. package/dist/assets/{index-CZVGv7Cn.js → index-CmaRQR9x.js} +28 -28
  28. package/dist/assets/index-yF00bLYk.css +2 -0
  29. package/dist/assets/{inspect-page-JQwJQ_Sl.js → inspect-page-Cj0WVion.js} +2 -2
  30. package/dist/assets/{integrations-page-FCrRTt2X.js → integrations-page-CH-pFd_e.js} +1 -1
  31. package/dist/assets/{intelligence-layout-AsbvHVqu.js → intelligence-layout-BHGZqgWE.js} +1 -1
  32. package/dist/assets/latest-assistant-text-DqYv-19M.js +24 -0
  33. package/dist/assets/{library-detail-page-Bcnsh9CI.js → library-detail-page-D1SaX446.js} +1 -1
  34. package/dist/assets/{library-page-DZduD_bA.js → library-page-CY_UIQ7K.js} +1 -1
  35. package/dist/assets/{logout-page-Buv0U8Wq.js → logout-page-BsVCSXLH.js} +1 -1
  36. package/dist/assets/{logs-layout-CaZNYn0T.js → logs-layout-D_7jq15m.js} +1 -1
  37. package/dist/assets/memory-page-route-BGWq_aq8.js +1 -0
  38. package/dist/assets/{memory-router-playground-page-CGIGEOgT.js → memory-router-playground-page-DThWyhXE.js} +1 -1
  39. package/dist/assets/{mobile-sidebar-drawer-kwgBD2Oe.js → mobile-sidebar-drawer-XsUj_ej1.js} +1 -1
  40. package/dist/assets/{notifications-page-BhLbSbpe.js → notifications-page-4H3d3TVi.js} +1 -1
  41. package/dist/assets/{oauth-complete-page-Y9TaL3bP.js → oauth-complete-page-IYjT22S6.js} +1 -1
  42. package/dist/assets/{oauth-popup-complete-page-D9YtNVV9.js → oauth-popup-complete-page-B2tgdOeo.js} +1 -1
  43. package/dist/assets/{pairing-page-CYBL5nXH.js → pairing-page-BsGxP4RT.js} +1 -1
  44. package/dist/assets/personality-page-DWuNCYhT.js +1 -0
  45. package/dist/assets/{plugins-page-DtB-KvF9.js → plugins-page-O4J9g6Y8.js} +1 -1
  46. package/dist/assets/prechat-route-CoHHHLoD.js +1 -0
  47. package/dist/assets/privacy-page-DXHDyrXM.js +1 -0
  48. package/dist/assets/{privacy-screen-C4Y8Fzqr.js → privacy-screen-N6-nGjeG.js} +1 -1
  49. package/dist/assets/{provider-callback-page-DkUH2bax.js → provider-callback-page-B6zqXdPZ.js} +1 -1
  50. package/dist/assets/{quick-input-page--AKggGR2.js → quick-input-page-UeFQo32q.js} +1 -1
  51. package/dist/assets/{research-mock-page-DNVvgUNF.js → research-mock-page-DL9B4Lli.js} +1 -1
  52. package/dist/assets/research-onboarding-route-CEPszqjJ.js +42 -0
  53. package/dist/assets/{review-terms-screen-3Mt29KCp.js → review-terms-screen-CchSUndG.js} +1 -1
  54. package/dist/assets/schedules-page-Bj5HEJa-.js +1 -0
  55. package/dist/assets/{select-assistant-screen-DKEkfrzB.js → select-assistant-screen-BQLQKCB5.js} +1 -1
  56. package/dist/assets/{settings-layout-D5GIvMSd.js → settings-layout-Dr3LiWJ0.js} +1 -1
  57. package/dist/assets/{share-feedback-modal-Bns-AdW9.js → share-feedback-modal-DvC-1HRQ.js} +1 -1
  58. package/dist/assets/{sidebar-tree-DRAO8jjA.js → sidebar-tree-r9N8LP3u.js} +1 -1
  59. package/dist/assets/{signup-page-_JnnV0FO.js → signup-page-B7lZHfHL.js} +1 -1
  60. package/dist/assets/{skill-detail-page-DiV9u6T7.js → skill-detail-page-onU_WAHM.js} +1 -1
  61. package/dist/assets/{skill-detail-panel-Bevi3Lss.js → skill-detail-panel-r5S_O0rZ.js} +1 -1
  62. package/dist/assets/skills-page-Cf86q643.js +1 -0
  63. package/dist/assets/{start-screen-DfMdkCZZ.js → start-screen-kBX69v2m.js} +1 -1
  64. package/dist/assets/{subagent-detail-panel-B8XiU0Z-.js → subagent-detail-panel-D6oy2K_C.js} +2 -2
  65. package/dist/assets/{system-events-page-Bd7g4y5T.js → system-events-page-CXkh6imt.js} +1 -1
  66. package/dist/assets/{theme-stage-page-B72tB13w.js → theme-stage-page-B1KCcRzM.js} +1 -1
  67. package/dist/assets/{tiptap-document-editor-jTc6PPwp.js → tiptap-document-editor-BVFwGbyO.js} +1 -1
  68. package/dist/assets/{tool-detail-panel-DyCqe5Yq.js → tool-detail-panel-CI8Z5mU5.js} +1 -1
  69. package/dist/assets/{upgrade-cancel-page-CUl1Cass.js → upgrade-cancel-page-78mnz39g.js} +1 -1
  70. package/dist/assets/{upgrade-success-page-DKvgbJHK.js → upgrade-success-page-Dnqc4oxD.js} +1 -1
  71. package/dist/assets/use-assistant-identity-details-D0dDGwFZ.js +1 -0
  72. package/dist/assets/{use-edge-swipe-back-CaTk2Wz5.js → use-edge-swipe-back-CzIG6Agy.js} +1 -1
  73. package/dist/assets/{use-invite-link-dialog-B6r6wWD7.js → use-invite-link-dialog-BLqplXYp.js} +1 -1
  74. package/dist/assets/{use-skill-actions-B443tGAI.js → use-skill-actions-B58D56j9.js} +1 -1
  75. package/dist/assets/{use-skill-categories-DsLNc-NO.js → use-skill-categories-BewT8dcB.js} +1 -1
  76. package/dist/assets/{use-skill-detail-files-BjQHazRM.js → use-skill-detail-files-S961Kf-o.js} +1 -1
  77. package/dist/assets/{voice-page-BiO7sMlu.js → voice-page-IaJC48fm.js} +1 -1
  78. package/dist/assets/{weather-forecast-display-CZLINMqN.js → weather-forecast-display-Cd2sZBmz.js} +1 -1
  79. package/dist/assets/{welcome-screen-CkOAvi7q.js → welcome-screen-CUTRt2OQ.js} +1 -1
  80. package/dist/assets/{workflow-detail-panel-PevRtp_O.js → workflow-detail-panel-BRYRq60N.js} +1 -1
  81. package/dist/assets/{workspace-page-D_ZIEJYY.js → workspace-page-DgDej6f2.js} +1 -1
  82. package/dist/index.html +3 -3
  83. package/package.json +1 -1
  84. package/dist/assets/ai-page-TYCxSdRA.js +0 -1
  85. package/dist/assets/community-page-JggT8MFi.js +0 -1
  86. package/dist/assets/contacts-page-route-q6JfNlkd.js +0 -1
  87. package/dist/assets/general-page-CBJ13Yzs.js +0 -1
  88. package/dist/assets/home-page-route-B5t1I9Kc.js +0 -1
  89. package/dist/assets/identity-page-route-BvdzgZ7m.js +0 -7
  90. package/dist/assets/index-BoLhUIgw.css +0 -2
  91. package/dist/assets/latest-assistant-text-BCjy0Q0O.js +0 -24
  92. package/dist/assets/memory-page-route-VwqOIgOs.js +0 -1
  93. package/dist/assets/personality-page-BuIF9LmP.js +0 -1
  94. package/dist/assets/prechat-route-Cn9TbGYd.js +0 -1
  95. package/dist/assets/privacy-page-wr_tX0w2.js +0 -1
  96. package/dist/assets/research-onboarding-route-CsLjEqSj.js +0 -42
  97. package/dist/assets/schedules-page-DWZ-lJ7j.js +0 -1
  98. package/dist/assets/skills-page-ano_t4YY.js +0 -1
  99. package/dist/assets/use-assistant-identity-details-CmAZ1Y2o.js +0 -1
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{a as t,c as n,i as r}from"./local-settings-C-dW2vkq.js";import{r as i,t as a}from"./capture-error-BGD3-GQf.js";import{t as o}from"./react-DJZBPgpf.js";import{t as s}from"./button-BQVYX8n_.js";import{m as c,u as l}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as u}from"./QueryClientProvider-DKhXIxGb.js";import{t as d}from"./useQuery-B45lW1Kk.js";import{t as f}from"./useMutation-Lj4VunQV.js";import{t as p}from"./jsx-runtime-CVSDxk6A.js";import{t as m}from"./typography-Cqi8q9o7.js";import{t as h}from"./createLucideIcon-Bjb-Kuq7.js";import{t as g}from"./check-wF3S-AV4.js";import{t as _}from"./circle-alert-CTnM6GCb.js";import{t as v}from"./circle-check-DqvTjWle.js";import{t as y}from"./clock-LiCGqvyn.js";import{n as b,t as x}from"./domain-field-Bj9ReZlJ.js";import{t as S}from"./external-link-5a-JuPGf.js";import{t as C}from"./info-DPHR_AMJ.js";import{t as w}from"./loader-circle-D57RZgLH.js";import{t as T}from"./triangle-alert-DXEpFOj_.js";import{t as E}from"./notice-BylgS5W_.js";import{j as D}from"./src-CDdn26Yb.js";import{t as O}from"./tag-B6WeUtBW.js";import{t as k}from"./input-ZpyYt_a0.js";import{t as A}from"./toggle-QSEiPr3k.js";import{t as j}from"./modal-BtcwNEBj.js";import{n as M}from"./toast-ZoZVyeDI.js";import{t as N}from"./confirm-dialog-CCrDkChx.js";import{t as P}from"./dropdown-BMNSccmo.js";import{Ht as F,Ut as I,bn as L,ct as R,dt as ee,j as z,tr as B}from"./sdk.gen-D_Qurj4O.js";import{H as V,Pt as te,V as H,_t as U,c as W,d as ne,f as G,l as K,m as re,p as ie,u as q,zt as J}from"./react-query.gen-BQH0QRfT.js";import{t as ae}from"./assistant-identity-store-bwxIa6fM.js";import{r as oe}from"./utils-ilzygKkt.js";import{r as se}from"./api-errors-CDe82ZvY.js";import{c as ce}from"./routes-XPLb07Av.js";import{t as le}from"./use-is-org-ready-ChwxZgjQ.js";import{c as ue,d as de,f as fe,g as pe,h as me,it as he,l as ge,m as _e,o as ve,p as ye,s as be,u as xe,v as Se,y as Ce}from"./react-query.gen-BXPoln4i.js";import{$i as we,$r as Te,Ai as Ee,B as De,Ci as Oe,Di as ke,Ei as Ae,H as je,Hi as Me,Oi as Ne,Qr as Pe,Si as Fe,Ti as Ie,U as Le,V as Re,_i as ze,ai as Be,bi as Ve,ci as He,ei as Ue,gi as We,gr as Ge,hi as Ke,ii as qe,ji as Je,ki as Ye,li as Xe,mi as Ze,ni as Qe,oi as $e,pi as et,ri as tt,si as nt,ti as rt,ui as it,vi as at,wi as ot,xi as st,yi as ct,z as lt}from"./index-CZVGv7Cn.js";import{t as Y}from"./use-active-assistant-id-9rGx8kT9.js";import{t as ut}from"./detail-card-CA8lPa5K.js";import{t as dt}from"./environment-store-D_Bc9wnl.js";var ft=h(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),X=e(o(),1),Z=p();function pt({mode:e,onChange:t}){return(0,Z.jsx)(`div`,{className:`max-w-[280px]`,children:(0,Z.jsx)(D,{ariaLabel:`Service mode`,value:e,onChange:t,items:[{value:`managed`,label:`Managed`},{value:`your-own`,label:`Your Own`}]})})}function mt({id:e,title:t,subtitle:n,mode:r,onModeChange:i,children:a}){return(0,Z.jsxs)(ut,{id:e,title:t,subtitle:n,accessory:(0,Z.jsx)(pt,{mode:r,onChange:i}),children:[(0,Z.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Z.jsx)(`div`,{className:`mt-4`,children:a})]})}function Q({onClick:e,disabled:t}){return(0,Z.jsx)(s,{onClick:e,disabled:t,children:`Save`})}function ht({onClick:e,filled:t=!1}){return(0,Z.jsx)(s,{variant:t?`danger`:`dangerGhost`,onClick:e,children:`Reset`})}function gt({id:e,title:t,subtitle:n,children:r}){return(0,Z.jsxs)(ut,{id:e,title:t,subtitle:n,children:[(0,Z.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Z.jsx)(`div`,{className:`mt-4`,children:r})]})}function _t({guide:e}){return(0,Z.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,Z.jsx)(C,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{children:e.description}),(0,Z.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,Z.jsx)(S,{className:`h-3 w-3`})]})]})]})}function vt({status:e,message:t,isLoading:n}){return n?(0,Z.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,Z.jsx)(w,{className:`h-3 w-3 animate-spin`}),`Checking domain…`]}):e?e===`verified`?(0,Z.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,Z.jsx)(g,{className:`h-3 w-3`}),`Domain verified`]}):e===`pending`||e===`not_started`?(0,Z.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,Z.jsx)(y,{className:`h-3 w-3`}),`Verifying domain…`]}):(0,Z.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,Z.jsx)(_,{className:`h-3 w-3`}),`Verification failed`]}):(0,Z.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`})}var yt=`__custom__`;function bt(e){return e?!!(e.profile||e.provider||e.model):!1}function xt(e,t){let n=bt(e);return n===bt(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function St({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,onDraftChange:o,onToggle:s}){let c=bt(i),l=!i||!c?``:i.provider||i.model?yt:i.profile??``,u=l===yt,d=$e(),f=d[0]??ke[0],p=d.find(e=>e===i?.provider)??f,m=Je(p).map(e=>({value:e.id,label:e.displayName})),h=!!i?.provider&&!i?.model;function g(t){t===`__custom__`?o(e,{profile:null,provider:f,model:Ee(f)??``}):t===``?o(e,null):o(e,{profile:t,provider:null,model:null})}function _(t){let n=Ee(t)??``;o(e,{...i??{},profile:null,provider:t,model:n})}function v(t){o(e,{...i??{},model:t})}return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,Z.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,Z.jsxs)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:[`· Default: `,r]})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c&&(0,Z.jsx)(P,{value:l,onChange:g,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,Z.jsx)(A,{checked:c,onChange:t=>s(e,t),"aria-label":`Override ${t}`})]})]}),c&&u&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex-1`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Z.jsx)(P,{value:p??``,onChange:_,options:d.map(e=>({value:e,label:Ye[e]??e}))})]}),(0,Z.jsxs)(`div`,{className:`flex-1`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,Z.jsx)(P,{value:i?.model??``,onChange:v,options:m})]})]}),h&&(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:`Pick a model`})]})]})}function Ct({isOpen:e,onClose:t,assistantId:n}){let r=(0,X.useRef)(!1);return(0,Z.jsx)(j.Root,{open:e,onOpenChange:e=>{!e&&!r.current&&t()},children:e?(0,Z.jsx)(wt,{assistantId:n,onClose:t,onSavingChange:e=>{r.current=e}}):null})}function wt({assistantId:e,onClose:t,onSavingChange:n}){let r=u(),{data:i}=d({...W({path:{assistant_id:e}}),staleTime:3e4}),o=(0,X.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),c=(0,X.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),l=(0,X.useMemo)(()=>i?.llm?.callSites??{},[i?.llm?.callSites]),f=(0,X.useMemo)(()=>Ke(o,c),[o,c]),p=$e(),m=J({onSuccess:t=>{q(r,{path:{assistant_id:e}},t)}}),[h,g]=(0,X.useState)(``),[_,v]=(0,X.useState)({}),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(!1),{data:C,isLoading:T,isError:E,refetch:D}=d({...ne({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),O=(0,X.useMemo)(()=>(C?.callSites??[]).filter(e=>e.id!==`mainAgent`),[C]),A=!T&&!E&&!!C&&!!i,P=(0,X.useMemo)(()=>O.map(e=>e.id),[O]),F=(0,X.useMemo)(()=>{if(!A)return{};let e={};for(let t of P)if(t in _)e[t]=_[t];else{let n=l[t];e[t]=n?{...n}:{}}return e},[A,P,l,_]),I=(0,X.useMemo)(()=>new Set(P),[P]),L=(0,X.useMemo)(()=>Object.entries(l).some(([e,t])=>I.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[l,I]),R=(0,X.useMemo)(()=>{if(!A)return!1;for(let e of Object.keys(F))if(!xt(F[e],l[e]))return!0;return!1},[A,F,l]),ee=(0,X.useMemo)(()=>Object.values(F).some(e=>bt(e)&&!!e?.provider&&!e?.model),[F]),z=(0,X.useCallback)(e=>[...je(f,[e]).map(e=>({value:e.name,label:De(e)})),{value:yt,label:`Custom`}],[f]),B=(0,X.useMemo)(()=>{if(!h.trim())return O;let e=h.toLowerCase();return O.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[O,h]),V=(0,X.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=B.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let r=new Set(e),i=B.filter(e=>!r.has(e.domain));return i.length>0&&n.push({domain:{id:`other`,displayName:`Other`},sites:i}),n},[C,B]),te=(0,X.useCallback)((e,t)=>{v(n=>({...n,[e]:t}))},[]),H=(0,X.useCallback)((e,t)=>{if(!t){v(t=>({...t,[e]:null}));return}let n=Re(f,O.find(t=>t.id===e)?.defaultProfile);if(n)v(t=>({...t,[e]:{profile:n}}));else{let t=p[0]??ke[0],n=Ee(t)??``;v(r=>({...r,[e]:{provider:t,model:n}}))}},[O,f,p]),U=(0,X.useCallback)(async()=>{b(!0),n?.(!0);try{let n={};for(let e of Object.keys(F)){let t=F[e]??null;n[e]=bt(t)?{profile:t?.profile??null,provider:t?.provider??null,model:t?.model??null}:null}await m.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),M.success(`Overrides saved.`)}catch(e){M.error(`Failed to save overrides. Please try again.`),a(e,{context:`call_site_overrides_save`})}finally{b(!1),n?.(!1)}},[F,t,m,n,e]),G=(0,X.useCallback)(async()=>{b(!0),n?.(!0);try{let n={};for(let e of Object.keys(F))n[e]=null;await m.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),M.success(`Overrides reset.`)}catch(e){M.error(`Failed to reset overrides. Please try again.`),a(e,{context:`call_site_overrides_reset`})}finally{b(!1),n?.(!1)}},[F,t,m,n,e]);return(0,Z.jsxs)(j.Content,{size:`lg`,hideCloseButton:!0,children:[(0,Z.jsxs)(j.Header,{children:[(0,Z.jsx)(j.Title,{children:`Action Overrides`}),(0,Z.jsx)(j.Description,{children:`Customize which model profile specific actions should use. Uses your default profile if no override is set.`})]}),(0,Z.jsxs)(j.Body,{children:[(0,Z.jsx)(`div`,{className:`mb-4`,children:(0,Z.jsx)(k,{type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:`Search actions…`,leftIcon:(0,Z.jsx)(we,{className:`h-4 w-4`}),fullWidth:!0})}),T&&(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Z.jsx)(w,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),E&&(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Couldn't load actions`}),(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Make sure your assistant is running`}),(0,Z.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>void D(),children:`Retry`})]}),!T&&!E&&C&&(0,Z.jsx)(`div`,{className:`space-y-4`,children:V.length===0?(0,Z.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No actions match your search.`}):V.map(({domain:e,sites:t})=>(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,Z.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>{let t=(()=>{let t=F[e.id]??null;return!t||!bt(t)?``:t.provider||t.model?`__custom__`:t.profile??``})(),n=e.defaultProfile?f.find(t=>t.name===e.defaultProfile)?.label??e.defaultProfile:null;return(0,Z.jsx)(St,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:n,draft:F[e.id]??null,profileOptions:z(t===``||t===`__custom__`?null:t),onDraftChange:te,onToggle:H},e.id)})})]},e.id))})]}),(0,Z.jsxs)(j.Footer,{children:[L&&(0,Z.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>S(!0),disabled:y||!A,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:`Reset to Defaults`}),(0,Z.jsx)(s,{variant:`outlined`,size:`compact`,onClick:t,disabled:y,children:`Cancel`}),(0,Z.jsx)(s,{variant:`primary`,size:`compact`,onClick:()=>void U(),disabled:!R||ee||y,children:y?(0,Z.jsx)(w,{className:`h-4 w-4 animate-spin`}):`Save`})]}),(0,Z.jsx)(N,{open:x,title:`Reset to Defaults`,message:`Every task override will be reset and will follow your active profile. This cannot be undone.`,confirmLabel:`Reset to Defaults`,destructive:!0,onConfirm:()=>{S(!1),G()},onCancel:()=>S(!1)})]})}function Tt({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:c}){let l=``;if(e){let t=e.label||e.name;l=e.isActive&&e.callSiteIds.length>0?`"${t}" is the active profile and is used by ${e.callSiteIds.length} call site(s). Pick a replacement profile.`:e.isActive?`"${t}" is the active profile. Pick a different active profile before deleting, or select a replacement below.`:`"${t}" is used by ${e.callSiteIds.length} call site(s). Select a replacement profile to reassign them before deleting.`}return(0,Z.jsx)(j.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,Z.jsxs)(j.Content,{size:`sm`,children:[(0,Z.jsx)(j.Header,{children:(0,Z.jsx)(j.Title,{children:`Can't Delete Profile`})}),(0,Z.jsxs)(j.Body,{className:`space-y-4`,children:[(0,Z.jsx)(m,{variant:`body-medium-default`,as:`p`,children:l}),e&&e.callSiteIds.length>0&&(0,Z.jsx)(`ul`,{className:`space-y-1 pl-1`,children:e.callSiteIds.map(e=>(0,Z.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,(0,Z.jsx)(`code`,{children:e})]},e))}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Replacement profile`}),(0,Z.jsx)(P,{"aria-label":`Replacement profile`,value:n,onChange:r,options:[{value:``,label:`Select a replacement…`},...t.map(e=>({value:e.name,label:e.label??e.name}))]})]}),i&&(0,Z.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,Z.jsxs)(j.Footer,{children:[(0,Z.jsx)(s,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,Z.jsx)(s,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:c,children:a?`Saving…`:`Reassign and Delete`})]})]})})}function Et(e,t){if(e){let n=Je(e).find(e=>e.id===t);if(n)return n.displayName}let n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t}function Dt(e,t){let n=[];e.description&&n.push(e.description);let r=e.provider_connection===`vellum`&&t?`vellum`:e.provider,i=[];if(e.model&&i.push(Et(r,e.model)),r){let e=Ye[r]??r;i.push(`hosted by ${e}`)}return i.length>0&&n.push(i.join(` `)),n.join(` – `)}function Ot({profile:e,vellumIsManaged:t,isDragging:n,dropTarget:r,isDeleting:i,deleteError:a,isToggling:o,onDragStart:c,onDragEnd:l,onDragOver:u,onDragLeave:d,onDrop:f,onEditClick:p,onDeleteClick:h,onStatusToggle:g}){let _=e.source===`managed`,v=e.invariant===!0,y=e.status!==`disabled`;return(0,Z.jsxs)(`div`,{className:`relative`,children:[r?.name===e.name&&!r.after&&(0,Z.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg pr-2 py-2${n?` opacity-50`:``}`,draggable:!_,onDragStart:c,onDragEnd:l,onDragOver:u,onDragLeave:d,onDrop:f,children:[(0,Z.jsx)(ft,{className:`h-4 w-4 shrink-0 ${_?`invisible`:`cursor-grab text-[var(--content-tertiary)]`}`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1${y?``:` opacity-55`}`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(m,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:e.label??e.name}),_&&(0,Z.jsx)(O,{tone:`positive`,title:`Managed by Platform — this profile cannot be disabled, deleted, or renamed.`,children:`Platform`})]}),e.description||e.model||e.provider?(0,Z.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:Dt(e,t)}):null]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(!v||!y)&&(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center`,title:y?`Active — toggle to hide from pickers`:`Disabled — toggle to show in pickers`,children:(0,Z.jsx)(A,{checked:y,onChange:e=>g(e),disabled:o,"aria-label":`${y?`Disable`:`Enable`} ${e.label??e.name}`})}),(0,Z.jsxs)(`div`,{className:`flex w-[92px] items-center justify-end gap-2`,children:[(0,Z.jsx)(s,{variant:`ghost`,size:`compact`,onClick:p,children:_||v?`View`:`Edit`}),(0,Z.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(Me,{}),"aria-label":`Delete ${e.label??e.name}`,disabled:_||v||i,title:_||v?`Managed profiles cannot be deleted`:void 0,onClick:h,tintColor:`var(--system-negative-strong)`})]})]})]}),r?.name===e.name&&r.after&&(0,Z.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),a?(0,Z.jsx)(m,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:a}):null]})}function kt({isOpen:e,assistantId:t,onClose:n}){let r=u(),{data:i}=d({...W({path:{assistant_id:t}}),staleTime:3e4}),o=(0,X.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),s=(0,X.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),c=i?.llm?.activeProfile??null,l=i?.llm?.callSites??{},f=(0,X.useMemo)(()=>Ke(o,s),[o,s]),p=J({onSuccess:e=>{q(r,{path:{assistant_id:t}},e)}}),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(null),{data:v}=d({...H({path:{assistant_id:t}}),enabled:e}),y=v?.connections,b=y?.some(e=>e.name===`vellum`&&e.provider===`vellum`)??!1,x=Object.keys(o);async function S(e,n,r){let i=r?.mode??`replace`,c=!(e in o);if(i===`merge`&&!c){await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:n}}}}),h(!1),_(null);return}let l={profiles:{[e]:n}};if(c&&(l.profileOrder=s.includes(e)?s:[...s,e]),c)await p.mutateAsync({path:{assistant_id:t},body:{llm:l}});else{let n=o[e];await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:null}}}});try{await p.mutateAsync({path:{assistant_id:t},body:{llm:l}})}catch(r){throw a(r,{context:`settings-ai-profile-edit-recreate`}),n!=null&&await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:n}}}}).catch(()=>{}),r}}c&&M.success(`Profile "${n.label??e}" created`),h(!1),_(null)}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(j.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,Z.jsx)(At,{assistantId:t,vellumIsManaged:b,profiles:o,profileOrder:s,orderedProfiles:f,activeProfile:c,callSiteOverrides:l,onClose:n,onEditClick:e=>{_(e),h(!0)},onNewClick:()=>{_(null),h(!0)}}):null}),(0,Z.jsx)(Pe,{isOpen:m,mode:g?g.source===`managed`||g.invariant===!0?`view`:`edit`:`create`,profileName:g?.name,initialValues:g??void 0,existingNames:x,connections:y,assistantId:t,onSave:S,onCancel:()=>{h(!1),_(null)}})]})}function At({assistantId:e,vellumIsManaged:t,profiles:n,profileOrder:r,orderedProfiles:i,activeProfile:o,callSiteOverrides:c,onClose:l,onEditClick:d,onNewClick:f}){let p=u(),h=J({onSuccess:t=>{q(p,{path:{assistant_id:e}},t)}}),[g,_]=(0,X.useState)({}),[v,y]=(0,X.useState)({}),[b,x]=(0,X.useState)(new Set),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(null),[E,D]=(0,X.useState)(null),[O,k]=(0,X.useState)(null),A=(0,X.useRef)(null),M=(0,X.useRef)(null),[N,P]=(0,X.useState)(null),[F,I]=(0,X.useState)(null),[L,R]=(0,X.useState)(``),[ee,z]=(0,X.useState)(!1),B=(0,X.useMemo)(()=>i,[i]);async function V(t,r){if(b.has(t.name))return!1;x(e=>new Set(e).add(t.name)),C(null);let i=r?`active`:`disabled`;if(!n[t.name])return x(e=>{let n=new Set(e);return n.delete(t.name),n}),!1;try{return await h.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[t.name]:{status:i}}}}}),!0}catch(e){return a(e,{context:`settings-ai-profile-toggle`}),C(`Couldn't update "${t.label??t.name}". Please try again.`),!1}finally{x(e=>{let n=new Set(e);return n.delete(t.name),n})}}async function te(t){y(e=>({...e,[t]:!0})),_(e=>{let n={...e};return delete n[t],n});try{let n=r.filter(e=>e!==t);await h.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[t]:null},profileOrder:n}}})}catch(e){a(e,{context:`settings-ai-profile-delete`}),_(e=>({...e,[t]:`Failed to delete profile. Please try again.`}))}finally{y(e=>{let n={...e};return delete n[t],n})}}function H(e){let t=B.find(t=>t.name===e)?.label??e,n=e===o,r=Object.entries(c).filter(([t,n])=>t!==`mainAgent`&&n?.profile===e).map(([e])=>e);if(n||r.length>0){P({name:e,label:t,isActive:n,callSiteIds:r}),R(``),I(null);return}te(e)}async function U(){if(!N||!L)return;z(!0),I(null);let t={};if(N.isActive&&(t.activeProfile=L),N.callSiteIds.length>0){let e={};for(let t of N.callSiteIds)e[t]={profile:L};t.callSites=e}if(Object.keys(t).length>0)try{await h.mutateAsync({path:{assistant_id:e},body:{llm:t}})}catch(e){a(e,{context:`settings-ai-profile-reassign-delete`}),I(`Failed to reassign references. Please try again.`),z(!1);return}let n=N.name;P(null),z(!1),te(n)}async function W(t,n){if(t===n.name)return;k(null);let i=r.filter(e=>e!==t),o=i.indexOf(n.name);if(o===-1)return;n.after&&(o+=1);let s=[...i.slice(0,o),t,...i.slice(o)];try{await h.mutateAsync({path:{assistant_id:e},body:{llm:{profileOrder:s}}})}catch(e){a(e,{context:`settings-ai-profile-reorder`}),k(`Failed to reorder profiles. Please try again.`)}}let ne=B.filter(e=>e.name!==N?.name&&e.source!==`managed`),G=ne.length>0?ne:B.filter(e=>e.name!==N?.name);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(j.Content,{size:`md`,children:[(0,Z.jsxs)(j.Header,{children:[(0,Z.jsx)(j.Title,{children:`Model Profiles`}),(0,Z.jsx)(j.Description,{children:`Bundle a provider and model into a named profile. Assign profiles to specific actions or swap between them when chatting.`})]}),(0,Z.jsxs)(j.Body,{children:[B.length===0?(0,Z.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No profiles yet. Create one to get started.`}):(0,Z.jsx)(`div`,{className:`space-y-1`,children:B.map(e=>(0,Z.jsx)(Ot,{profile:e,vellumIsManaged:t,isDragging:w===e.name,dropTarget:E,isDeleting:v[e.name]??!1,deleteError:g[e.name],isToggling:b.has(e.name),onDragStart:t=>{A.current=e.name,T(e.name),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{A.current=null,M.current=null,T(null),D(null)},onDragOver:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>n.top+n.height/2,i={name:e.name,after:r};M.current=i,D(i)},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||(M.current=null,D(t=>t?.name===e.name?null:t))},onDrop:e=>{e.preventDefault();let t=A.current,n=M.current;A.current=null,M.current=null,T(null),D(null),t&&n&&W(t,n)},onEditClick:()=>d(e),onDeleteClick:()=>H(e.name),onStatusToggle:t=>void V(e,t)},e.name))}),O&&(0,Z.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:O}),S&&(0,Z.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:S})]}),(0,Z.jsxs)(j.Footer,{className:`justify-between`,children:[(0,Z.jsx)(s,{variant:`outlined`,size:`compact`,onClick:f,children:`+ New Profile`}),(0,Z.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Done`})]})]}),(0,Z.jsx)(Tt,{blocked:N,availableReplacements:G,replacement:L,onReplacementChange:R,error:F,saving:ee,onClose:()=>{P(null),I(null)},onConfirm:()=>void U()})]})}var jt=`0.10.8`;function Mt(){return oe(jt)}function Nt({mode:e,connection:t,assistantId:n,existingNames:r,onSave:i,onCancel:a}){let[o,c]=(0,X.useState)(t?.label??``),l=t?.name??``,d=t?.provider??`anthropic`,f=t?.auth.type??`api_key`,[p,h]=(0,X.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[g,_]=(0,X.useState)(t?.baseUrl??``),[v,y]=(0,X.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(null),w=d===`openai-compatible`,[T,E]=(0,X.useState)(``),[D,O]=(0,X.useState)(!1),A=u(),M=(0,X.useMemo)(()=>He(p),[p]),N=f===`api_key`&&M!==null,{hasStoredCredential:P,isLoading:F}=Be({assistantId:n,credentialKind:`credential`,credentialName:M?`${M.service}:${M.field}`:``,enabled:N}),{credentials:L}=Ue({assistantId:n,enabled:f===`api_key`});(0,X.useEffect)(()=>{let e=t?.provider??`anthropic`;c(t?.label??``),t?.auth.type===`api_key`?h(t.auth.credential):h(t?``:`credential/${e}/api_key`),C(null),_(t?.baseUrl??``),y(t?.models?t.models.map(e=>e.id).join(`, `):``),E(``),O(!1)},[t]);let R=l.trim().length>0;async function ee(){if(R){x(!0),C(null);try{let e;if(f===`api_key`){let t=p.trim()||`credential/${d}/api_key`,r=T.trim();if(r){O(!0);try{let e=He(t);await B({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:d,value:r},throwOnError:!0});let i=qe(n,`credential`,e?`${e.service}:${e.field}`:``);A.setQueryData(i,!0),A.invalidateQueries({queryKey:U({path:{assistant_id:n}})})}catch{C(`Failed to save API key. Please try again.`);return}finally{O(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{C(`Nothing to edit. Close and try again.`);return}let r=o.trim()||null,a={auth:e,label:r,...w&&{base_url:g.trim()||null,models:v.trim()?v.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:s,error:c,response:u}=await I({path:{assistant_id:n,name:t?.name??l.trim()},body:a});if(!u?.ok){C(it(u?.status,c)??nt(u?.status));return}if(!s){C(`Server returned an empty response. Please try again.`);return}i(s)}catch{C(`Failed to save provider. Please try again.`)}finally{x(!1)}}}let z=L.filter(e=>e.service===d),V=e!==`create`&&t?.auth.type===`api_key`,te=z.length>0||V,H=rt(`Enter your API key`,P);return e===`create`?(0,Z.jsx)(Te,{variant:`modal`,assistantId:n,existingNames:r,defaultProviderType:d,onCreated:i,onCancel:a}):(0,Z.jsxs)(j.Content,{size:`md`,children:[(0,Z.jsxs)(j.Header,{children:[(0,Z.jsx)(j.Title,{children:`Edit Provider`}),(0,Z.jsx)(j.Description,{children:t?`Editing ${Xe(t)}.`:`Edit provider settings.`})]}),(0,Z.jsxs)(j.Body,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[`Display Name`,` `,(0,Z.jsx)(`span`,{className:`text-[var(--content-disabled)]`,children:`(optional)`})]}),(0,Z.jsx)(k,{value:o,onChange:e=>c(e.target.value),placeholder:`e.g. My Anthropic Key`,fullWidth:!0})]}),w&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,Z.jsx)(k,{value:g,onChange:e=>_(e.target.value),placeholder:`https://api.example.com/v1`,fullWidth:!0})]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,Z.jsx)(k,{value:v,onChange:e=>y(e.target.value),placeholder:`model-1, model-2`,fullWidth:!0}),(0,Z.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),f===`api_key`&&(0,Z.jsx)(Qe,{apiKeyValue:T,onApiKeyChange:E,credential:p,onCredentialChange:h,isLoadingCredential:F,apiKeyPlaceholder:H,provider:d,providerCredentials:z,showAdvancedSection:te,onError:C}),f===`oauth_subscription`&&(0,Z.jsx)(tt,{assistantId:n,onConnected:i}),S&&(0,Z.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:S})]}),(0,Z.jsxs)(j.Footer,{children:[(0,Z.jsx)(s,{variant:`ghost`,size:`compact`,onClick:a,children:`Cancel`}),(0,Z.jsx)(s,{variant:`primary`,size:`compact`,disabled:!R||b||D,onClick:()=>void ee(),children:b?`Saving…`:`Save`})]})]})}var Pt={anthropic:!0,openai:!0,gemini:!0,fireworks:!0,openrouter:!0,vellum:!0};function Ft(e){return e in Pt}function It({isOpen:e,assistantId:t,onClose:n}){let[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(null),s=u(),{data:c,isLoading:l,isError:f}=d({...H({path:{assistant_id:t}}),enabled:e}),p=Mt(),{data:m}=d({...G({path:{assistant_id:t}}),enabled:e&&p}),h=(0,X.useMemo)(()=>{let e=c?.connections??[];return[...e.filter(e=>e.provider===Ne),...e.filter(e=>e.provider!==Ne)]},[c]);function g(){s.invalidateQueries({queryKey:ie({path:{assistant_id:t}})}),s.invalidateQueries({queryKey:K({path:{assistant_id:t}})})}function _(e){s.invalidateQueries({queryKey:V({path:{assistant_id:t}})}),i(!1),o(null)}let v=h.map(e=>e.name),y=()=>{i(!1),o(null)};return(0,Z.jsx)(j.Root,{open:e,onOpenChange:e=>{e||(r?y():n())},children:e?r?(0,Z.jsx)(Nt,{mode:a?`edit`:`create`,connection:a??void 0,assistantId:t,existingNames:v,onSave:_,onCancel:y}):(0,Z.jsx)(Lt,{connections:h,loading:l,isError:f,assistantId:t,supportsDefaultProvider:p,defaultConnectionName:p?m?.resolvedConnectionName??null:null,onDefaultChanged:g,onClose:n,onEditClick:e=>{o(e),i(!0)},onNewClick:()=>{o(null),i(!0)},onConnectionDeleted:()=>{s.invalidateQueries({queryKey:V({path:{assistant_id:t}})})}}):null})}function Lt({connections:e,loading:t,isError:n,assistantId:r,supportsDefaultProvider:i,defaultConnectionName:o,onDefaultChanged:c,onClose:l,onEditClick:u,onNewClick:d,onConnectionDeleted:p}){let[h,g]=(0,X.useState)({}),[_,v]=(0,X.useState)({}),y=f({...re(),onMutate:e=>{let t=e.body?.connectionName;t&&g(e=>{let n={...e};return delete n[t],n})},onSuccess:c,onError:(e,t)=>{a(e,{context:`settings-ai-set-default-provider`});let n=t.body?.connectionName;n&&g(e=>({...e,[n]:`Failed to set default provider. Please try again.`}))}});function b(e){Ft(e.provider)&&y.mutate({path:{assistant_id:r},body:{provider:e.provider,connectionName:e.name}})}async function x(e){v(t=>({...t,[e]:!0})),g(t=>{let n={...t};return delete n[e],n});try{let{response:t}=await F({path:{assistant_id:r,name:e}});t?.ok||t?.status===404?p(e):t?.status===409?g(t=>({...t,[e]:`This provider is in use by a profile or as the default provider. Update those settings before deleting it.`})):g(t=>({...t,[e]:`Failed to delete provider. Please try again.`}))}catch{g(t=>({...t,[e]:`Failed to delete provider. Please try again.`}))}finally{v(t=>{let n={...t};return delete n[e],n})}}return(0,Z.jsxs)(j.Content,{size:`md`,children:[(0,Z.jsxs)(j.Header,{children:[(0,Z.jsx)(j.Title,{children:`Providers`}),(0,Z.jsx)(j.Description,{children:`Manage the model providers your assistant can use.`})]}),(0,Z.jsx)(j.Body,{children:t?(0,Z.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,Z.jsx)(`div`,{className:`h-10 animate-pulse rounded-lg bg-[var(--surface-active)]`},e))}):n?(0,Z.jsx)(m,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:`Failed to load providers. Please try again.`}):e.length===0?(0,Z.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No providers yet. Add one to get started.`}):(0,Z.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>{let t=_[e.name]??!1,n=h[e.name],r=e.isManaged??!1,a=e.name===o,c=Ft(e.provider),l=y.isPending&&y.variables?.body?.connectionName===e.name;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg px-2 py-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(m,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:Xe(e)}),r&&(0,Z.jsx)(O,{tone:`positive`,title:`Managed by Platform — you can rename this provider, but not edit it.`,children:`Platform`}),a&&(0,Z.jsx)(O,{tone:`info`,title:`Built-in profiles (Balanced, Quality, Speed) use this provider.`,children:`Default`})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[i&&!a&&(0,Z.jsx)(s,{variant:`ghost`,size:`compact`,disabled:!c||l,title:c?`Use this provider for the built-in profiles.`:`Built-in profiles can't run on this provider.`,onClick:()=>b(e),children:`Set as default`}),!r&&(0,Z.jsx)(s,{variant:`ghost`,size:`compact`,onClick:()=>u(e),children:`Edit`}),(0,Z.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(Me,{}),"aria-label":`Delete ${Xe(e)}`,disabled:r||a||t,title:r?`The Vellum provider cannot be removed`:a?`This is your default provider. Set another provider as default first.`:void 0,onClick:()=>void x(e.name),tintColor:`var(--system-negative-strong)`})]})]}),n?(0,Z.jsx)(m,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:n}):null]},e.name)})})}),(0,Z.jsxs)(j.Footer,{className:`justify-between`,children:[(0,Z.jsx)(s,{variant:`outlined`,size:`compact`,onClick:d,children:`+ Add Provider`}),(0,Z.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Done`})]})]})}function $(e){let[t,n]=(0,X.useState)(void 0);return(0,X.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,X.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}function Rt(){let e=Y(),t=u(),{data:n}=d({...W({path:{assistant_id:e}}),staleTime:3e4}),r=Mt(),{data:i,refetch:o}=d({...G({path:{assistant_id:e}}),enabled:r}),c=i?.availability,l=n?.llm?.activeProfile??null,f=n?.llm?.advisorProfile??null,p=n?.llm?.callSites??{},{profiles:h,profileOrder:g}=lt(n?.llm,e),_=(0,X.useMemo)(()=>Ke(h,g),[h,g]),v=J({onSuccess:n=>{q(t,{path:{assistant_id:e}},n)}}),[y,b]=$(l),[x,S]=$(f),[C,T]=(0,X.useState)(!1),[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(!1),j=(0,X.useMemo)(()=>je(_,[y]),[_,y]),N=(0,X.useMemo)(()=>je(_,[x]),[_,x]),F=Object.entries(p).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length,I=F===1?`1 Override`:F>0?`${F} Overrides`:`Overrides`,L=y!==l,R=x!==f,ee=(0,X.useCallback)(async()=>{try{let t={};L&&(t.activeProfile=y),R&&(t.advisorProfile=x),await v.mutateAsync({path:{assistant_id:e},body:{llm:t}}),M.success(`Saved.`)}catch(e){M.error(`Failed to save. Please try again.`),a(e,{context:`settings-ai-language-model-save`})}},[L,R,y,x,v,e]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(gt,{title:`Language Model`,subtitle:`Configure the LLMs that power your assistant`,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[c&&c.status!==`ok`&&(0,Z.jsx)(E,{tone:c.status===`unknown`?`warning`:`error`,children:c.message??`Your default provider is not available.`}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Default Profile`}),(0,Z.jsx)(P,{value:y??``,onChange:e=>{b(e===``?null:e)},placeholder:`Select a default profile…`,options:j.map(e=>({value:e.name,label:De(e)}))}),j.length===0?(0,Z.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`No profiles yet. Click Profiles below to create one.`}):null]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Advisor Profile`}),(0,Z.jsx)(P,{value:x??``,onChange:e=>{S(e===``?null:e)},placeholder:`Select an advisor profile…`,options:N.map(e=>({value:e.name,label:De(e)}))}),(0,Z.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`Which model your assistant consults for a second opinion`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>A(!0),children:`Providers`}),(0,Z.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>T(!0),children:`Profiles`}),(0,Z.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>O(!0),children:I})]}),(L||R)&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Q,{onClick:ee,disabled:v.isPending}),v.isPending&&(0,Z.jsx)(w,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]})}),e&&(0,Z.jsx)(kt,{isOpen:C,assistantId:e,onClose:()=>T(!1)}),e&&(0,Z.jsx)(Ct,{isOpen:D,onClose:()=>O(!1),assistantId:e}),e&&(0,Z.jsx)(It,{isOpen:k,assistantId:e,onClose:()=>{A(!1),r&&o()}})]})}var zt=`vellum:ai:imageGenMode`,Bt=`vellum:ai:imageGenModel`,Vt=`vellum:ai:webSearchMode`,Ht=`vellum:ai:webSearchProvider`,Ut=`vellum:ai:webFetchProvider`,Wt=`vellum:ai:emailMode`,Gt=`vellum:ai:emailByoProvider`,Kt=`vellum:voice:ttsMode`,qt=`vellum:voice:ttsProvider`,Jt=`vellum:voice:ttsApiKey:`,Yt=`vellum:voice:ttsVoiceId:`,Xt=`vellum:voice:sttMode`,Zt=`vellum:voice:sttProvider`,Qt=`vellum:voice:sttApiKey:`;function $t(){let e=Y();return(0,X.useCallback)(async(t,n)=>{try{let{data:r}=await B({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});Ze(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?M.error(`Assistant not ready. Please try again.`):M.error(`Failed to save ${t} API key. Please try again.`),a(e,{context:`provision_provider_key`}),e}},[e])}function en(){let e=Y(),i=u(),{data:o}=d({...W({path:{assistant_id:e}}),staleTime:3e4}),s=J({onSuccess:t=>{q(i,{path:{assistant_id:e}},t)}}),c=$t(),{serverWebSearchMode:l,serverWebSearchProvider:f}=(0,X.useMemo)(()=>{if(!o)return{serverWebSearchMode:at(r(Vt,`your-own`),`your-own`),serverWebSearchProvider:r(Ht,`inference-provider-native`)};let e=o.services?.[`web-search`];return{serverWebSearchMode:at(e?.mode??r(`vellum:ai:webSearchMode`,`your-own`),`your-own`),serverWebSearchProvider:e?.provider||r(`vellum:ai:webSearchProvider`,`inference-provider-native`)}},[o]),[p,m]=(0,X.useState)(!1),[h,g]=$(l),[_,v]=$(f),[y,b]=(0,X.useState)(``),x=ct.has(_),{hasStoredCredential:S}=Be({assistantId:e,credentialKind:`api_key`,credentialName:_,enabled:x}),C=y.trim().length>0,T=p||h===`your-own`&&x&&!S&&!C||!(h!==l||(h===`managed`?`inference-provider-native`:_)!==f)&&!C,E=rt(Fe[_]??`Enter your API key`,S),D=(0,X.useCallback)(async()=>{m(!0);let t=y.trim(),r=h===`managed`?`inference-provider-native`:_,o=ze(r),l=h===`your-own`&&x&&t.length>0;try{l&&await c(r,t),await s.mutateAsync({path:{assistant_id:e},body:{services:{"web-search":{mode:h,provider:r}}}}).catch(e=>{throw M.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(Vt,h),n(Ht,r),l){o&&n(o,t);let r=qe(e,`api_key`,_);i.setQueryData(r,!0),i.invalidateQueries({queryKey:r}),b(``)}M.success(`Web search settings saved.`)}catch(e){a(e,{context:`settings-ai-web-search-persist-local`}),M.error(`Saved, but local preferences could not be written.`)}},[x,s,c,i,e,y,h,_]),O=(0,X.useCallback)(()=>{let e=ze(_);e&&t(e),b(``),v(`inference-provider-native`),n(Ht,`inference-provider-native`)},[_,v]);return(0,Z.jsx)(mt,{title:`Web Search`,subtitle:`Configure how your assistant should search the web`,mode:h,onModeChange:e=>g(e),children:h===`managed`?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Web search is included with managed inference.`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Q,{onClick:D,disabled:T}),p&&(0,Z.jsx)(w,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]}):(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Z.jsx)(P,{value:_,onChange:v,options:st.map(e=>({value:e,label:Ve[e]??e}))})]}),x&&(0,Z.jsx)(k,{label:`API Key`,type:`password`,value:y,onChange:e=>b(e.target.value),placeholder:E,fullWidth:!0}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Q,{onClick:D,disabled:T}),p&&(0,Z.jsx)(w,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),x&&(0,Z.jsx)(ht,{onClick:O,filled:!0})]})]})})}var tn=`default`;function nn(){let e=Y(),i=u(),{data:o}=d({...W({path:{assistant_id:e}}),staleTime:3e4}),s=J({onSuccess:t=>{q(i,{path:{assistant_id:e}},t)}}),c=$t(),l=(0,X.useMemo)(()=>o?o.services?.[`web-fetch`]?.provider||r(`vellum:ai:webFetchProvider`,tn):r(Ut,tn),[o]),[f,p]=(0,X.useState)(!1),[m,h]=$(l),[g,_]=(0,X.useState)(``),v=Oe.has(m),{hasStoredCredential:y}=Be({assistantId:e,credentialKind:`api_key`,credentialName:m,enabled:v}),b=g.trim().length>0,x=f||v&&!y&&!b||m===l&&!b,S=rt(Ae[m]??`Enter your API key`,y),C=(0,X.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 M.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(Ut,m),r){let r=We(m);r&&n(r,t);let a=qe(e,`api_key`,m);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),_(``)}M.success(`Web fetch settings saved.`)}catch(e){a(e,{context:`settings-ai-web-fetch-persist-local`}),M.error(`Saved, but local preferences could not be written.`)}},[v,s,c,i,e,g,m]),T=(0,X.useCallback)(()=>{let e=We(m);e&&t(e),_(``),h(tn),n(Ut,tn)},[m,h]);return(0,Z.jsx)(gt,{id:`web-fetch`,title:`Web Fetch`,subtitle:`Configure how your assistant reads individual web pages`,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Z.jsx)(P,{value:m,onChange:h,options:Ie.map(e=>({value:e,label:ot[e]??e}))})]}),v&&(0,Z.jsx)(k,{label:`API Key`,type:`password`,value:g,onChange:e=>_(e.target.value),placeholder:S,fullWidth:!0}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Q,{onClick:C,disabled:x}),f&&(0,Z.jsx)(w,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),v&&(0,Z.jsx)(ht,{onClick:T,filled:!0})]})]})})}var rn=[{id:`elevenlabs`,displayName:`ElevenLabs`,subtitle:`High-quality voice synthesis for conversations and read-aloud. Requires an ElevenLabs API key.`,supportsVoiceSelection:!0,apiKeyPlaceholder:`sk_…`,credentialsGuide:{description:`Sign in to ElevenLabs, go to your Profile, and copy your API key.`,url:`https://elevenlabs.io/app/settings/api-keys`,linkLabel:`Open ElevenLabs API Keys`}},{id:`fish-audio`,displayName:`Fish Audio`,subtitle:`Natural-sounding voice synthesis with custom voice cloning. Requires a Fish Audio API key and voice reference ID.`,supportsVoiceSelection:!0,apiKeyPlaceholder:`Enter your Fish Audio API key`,credentialsGuide:{description:`Sign in to Fish Audio, navigate to API Keys in your dashboard, and create a new key.`,url:`https://fish.audio/app/api-keys/`,linkLabel:`Open Fish Audio API Keys`}},{id:`deepgram`,displayName:`Deepgram`,subtitle:`Fast, accurate text-to-speech synthesis. Uses the same API key as Deepgram speech-to-text.`,supportsVoiceSelection:!1,apiKeyPlaceholder:`Enter your Deepgram API key`,credentialsGuide:{description:`Sign in to Deepgram, navigate to your API Keys page, and create or copy an existing key. This is the same key used for speech-to-text.`,url:`https://console.deepgram.com/`,linkLabel:`Open Deepgram Console`}},{id:`xai`,displayName:`xAI`,subtitle:`Text-to-speech from xAI with expressive voices (eve, ara, rex, sal, leo). Requires an xAI API key.`,supportsVoiceSelection:!1,apiKeyPlaceholder:`Enter your xAI API key`,credentialsGuide:{description:`Sign in to the xAI console, navigate to API Keys, and create a new key.`,url:`https://console.x.ai/`,linkLabel:`Open xAI Console`}}],an=[{id:`deepgram`,displayName:`Deepgram`,subtitle:`Fast, accurate speech-to-text transcription. Uses the same API key as Deepgram text-to-speech.`,apiKeyPlaceholder:`Enter your Deepgram API key`,credentialsGuide:{description:`Sign in to Deepgram, navigate to your API Keys page, and create or copy an existing key. This is the same key used for text-to-speech.`,url:`https://console.deepgram.com/`,linkLabel:`Open Deepgram Console`}},{id:`openai`,displayName:`OpenAI`,subtitle:`OpenAI Whisper transcription. Requires an OpenAI API key.`,apiKeyPlaceholder:`sk-…`,credentialsGuide:{description:`Sign in to the OpenAI platform, navigate to API Keys, and create a new secret key.`,url:`https://platform.openai.com/api-keys`,linkLabel:`Open OpenAI API Keys`}},{id:`macos-native`,displayName:`macOS Native Dictation`,subtitle:`Apple's on-device speech recognition, running locally through the macOS helper. Works offline and needs no API key.`,requiresNativeDictation:!0,setupWarning:`Requires macOS Dictation to be turned on: open System Settings → Keyboard, then enable Dictation. macOS downloads the on-device speech model the first time Dictation is enabled — without it, voice input produces no transcript.`}],on=[{id:`mailgun`,displayName:`Mailgun`,setupSkill:`mailgun-setup`,docsUrl:`https://www.mailgun.com/`},{id:`resend`,displayName:`Resend`,setupSkill:`resend-setup`,docsUrl:`https://resend.com/`}],sn=[`gemini-3.1-flash-image-preview`,`gemini-3-pro-image-preview`,`gpt-image-2`],cn={"gemini-3.1-flash-image-preview":`Nano Banana 2`,"gemini-3-pro-image-preview":`Nano Banana Pro`,"gpt-image-2":`GPT Image 2`};function ln(e){return e.startsWith(`gpt-`)||e.startsWith(`dall-e-`)?`openai`:(e.startsWith(`gemini-`),`gemini`)}function un({assistantId:e,assistantHandle:t,emailRootDomain:n}){let r=u(),i=l(),[o,p]=c(),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(null),[S,C]=(0,X.useState)(``),[T,D]=(0,X.useState)(null),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(!1),[P,F]=(0,X.useState)(!1);(0,X.useEffect)(()=>{g||!t||m||(h(t),_(!0))},[t,g,m]);let I=d({...he(),enabled:!0}),L=I.data,R=L?.entitlements,ee=R?.managed_email===!0,z=!!R&&!ee,B=!L&&I.isError&&!I.isFetching,V=d({...ue({path:{assistant_id:e}}),enabled:!z}),te=d({...ye({path:{assistant_id:e}}),enabled:!z}),H=V.data?.results?.[0],U=te.data?.results?.[0],W=H?`${H.subdomain}.${n}`:null,ne=d({...me({path:{assistant_id:e,id:U?.id??``}}),enabled:!!U?.id,refetchOnWindowFocus:!1}),G=d({...xe({path:{assistant_id:e,id:H?.id??``}}),enabled:!!H?.id,refetchInterval:e=>{let t=e.state.data?.status;return t===`verified`||t===`failed`?!1:1e4},refetchOnWindowFocus:!0});(0,X.useEffect)(()=>{o.get(`release`)!==`1`||!H||U||(j(!0),p(e=>{let t=new URLSearchParams(e);return t.delete(`release`),t},{replace:!0}))},[U,H,o,p]);let K=f(ve()),re=f(be()),ie=f(de()),q=f(fe()),J=(0,X.useCallback)(()=>{let t={assistant_id:e};r.invalidateQueries({queryKey:ge({path:t})}),r.invalidateQueries({queryKey:_e({path:t})}),U?.id&&r.invalidateQueries({queryKey:pe({path:{...t,id:U.id}})}),r.invalidateQueries({queryKey:Ce()})},[U?.id,e,r]),ae=(0,X.useCallback)(async()=>{let t=m.trim().toLowerCase();if(!t){y(`Enter a subdomain.`);return}k(!1);try{await K.mutateAsync({path:{assistant_id:e},body:{subdomain:t}}),h(``),y(null),J(),M.success(`Domain ${t}.${n} registered.`)}catch(e){y(se(e,void 0,`Failed to register domain.`))}},[e,n,J,K,m]),oe=(0,X.useCallback)(async()=>{let t=S.trim().toLowerCase();if(!t){D(`Enter an email username.`);return}try{await ie.mutateAsync({path:{assistant_id:e},body:{username:t}}),C(``),D(null),J(),M.success(`Email address created.`)}catch(e){D(se(e,void 0,`Failed to create email address.`))}},[e,J,ie,S]),le=(0,X.useCallback)(async()=>{if(U?.id){F(!1);try{await q.mutateAsync({path:{assistant_id:e,id:U.id}}),J(),M.success(`Email address removed.`)}catch(e){a(e,{context:`email_address_delete`}),M.error(`Failed to remove email address.`)}}},[U?.id,e,q,J]),Se=(0,X.useCallback)(async()=>{if(!H?.id)return;if(U){M.error(`Remove the email address first.`);return}j(!1);let t=H.subdomain;try{await re.mutateAsync({path:{assistant_id:e,id:H.id}}),h(t),J(),M.success(`Domain released.`)}catch(e){a(e,{context:`email_domain_release`}),M.error(`Failed to release domain.`)}},[U,e,re,H?.id,H?.subdomain,J]);if(I.isLoading)return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(w,{className:`h-4 w-4 animate-spin`}),`Checking subscription…`]});if(z)return(0,Z.jsxs)(E,{tone:`info`,icon:(0,Z.jsx)(b,{className:`h-4 w-4`,"aria-hidden":!0}),title:`Get a dedicated email address for your assistant`,actions:(0,Z.jsx)(s,{size:`compact`,onClick:()=>i(`${ce.settings.billing}?adjust_plan`),children:`Upgrade to Pro`}),children:[`Pro plans include a managed`,` `,`<your-subdomain>.${n}`,` inbox — no provider setup required. Or switch to `,(0,Z.jsx)(`strong`,{children:`Your Own`}),` to bring an existing provider.`]});let we=B?(0,Z.jsx)(E,{tone:`warning`,title:`Couldn't verify subscription status`,actions:(0,Z.jsx)(s,{size:`compact`,variant:`outlined`,onClick:()=>I.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 H?U?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[we,(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Address`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:U.address}),(0,Z.jsx)(vt,{status:G.data?.status,message:G.data?.message,isLoading:G.isLoading}),(0,Z.jsx)(s,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Z.jsx)(Me,{}),onClick:()=>F(!0),disabled:q.isPending,"aria-label":`Remove email address`})]}),(0,Z.jsx)(N,{open:P,title:`Remove Email Address`,message:(0,Z.jsxs)(Z.Fragment,{children:[`Are you sure you want to remove `,(0,Z.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:U.address}),`? Your assistant will no longer be able to send or receive email at this address.`]}),confirmLabel:`Remove`,destructive:!0,onConfirm:le,onCancel:()=>F(!1)})]}),ne.data?.usage&&(0,Z.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[ne.data.usage.sent_today,` /`,` `,ne.data.usage.daily_limit,` sent today ·`,` `,ne.data.usage.received_today,` received`]})]}):(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[we,(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Domain`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:[H.subdomain,`.`,n]}),(0,Z.jsx)(vt,{status:G.data?.status,message:G.data?.message,isLoading:G.isLoading}),(0,Z.jsx)(s,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Z.jsx)(Me,{}),onClick:()=>j(!0),disabled:re.isPending,"aria-label":`Release domain`})]}),(0,Z.jsx)(N,{open:A,title:`Release Domain`,message:(0,Z.jsxs)(Z.Fragment,{children:[`Are you sure you want to release `,(0,Z.jsxs)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:[H.subdomain,`.`,n]}),`? The subdomain will become available for others to claim.`]}),confirmLabel:`Release`,destructive:!0,onConfirm:Se,onCancel:()=>j(!1)})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Email address`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.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 ${T?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[(0,Z.jsx)(`input`,{value:S,onChange:e=>{C(e.target.value.toLowerCase()),T&&D(null)},placeholder:`hi`,"aria-label":`Email username`,"aria-invalid":!!T,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,Z.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`@`,W]})]}),(0,Z.jsx)(s,{onClick:oe,disabled:ie.isPending||!S.trim(),children:ie.isPending?`Creating…`:`Create`})]}),T&&(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:T})]})]}):(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[we,(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Subdomain`}),(0,Z.jsx)(x,{subdomain:m,onSubdomainChange:e=>{h(e),v&&y(null)},domainSuffix:n,subdomainPlaceholder:`my-assistant`,error:v}),(0,Z.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,Z.jsx)(s,{onClick:()=>k(!0),disabled:K.isPending||!m.trim(),children:K.isPending?`Registering…`:`Register`}),(0,Z.jsx)(N,{open:O,title:`Set Subdomain`,message:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:m.trim().toLowerCase()||`subdomain`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),confirmLabel:`Confirm`,onConfirm:ae,onCancel:()=>k(!1)})]})}function dn(){let e=Y(),t=le(),{data:o}=d({...Se(),enabled:t}),s=o?.results?.[0]?.handle,c=dt.use.emailRootDomain(),l=et(),[u,f]=(0,X.useState)(()=>l===`gated`?`your-own`:at(r(Wt,`managed`),`managed`)),[p,m]=(0,X.useState)(()=>{let e=r(Gt,`resend`);return e===`mailgun`||e===`resend`?e:`resend`}),h=d({queryKey:[`byoEmailCredential`,e,p],queryFn:async()=>{let{data:t}=await R({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,X.useEffect)(()=>{h.error&&a(h.error,{context:`byo_email_credential_check`,bestEffort:!0})},[h.error]);let g=h.data?.hasSecret===!0,_=(0,X.useCallback)(e=>{f(e),n(Wt,e)},[]),y=(0,X.useCallback)(()=>{n(Gt,p),M.success(`Email settings saved.`)},[p]),b=(0,X.useMemo)(()=>on.find(e=>e.id===p)??on[0],[p]),x=(0,Z.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,Z.jsx)(C,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`span`,{children:[`Configure `,b.displayName,` via the assistant CLI: ask the assistant to run the`,` `,(0,Z.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:b.setupSkill}),` `,`skill. It walks you through storing the API key, detecting the domain, and (optionally) wiring up an inbound webhook.`]}),(0,Z.jsxs)(`a`,{href:b.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,b.displayName,(0,Z.jsx)(S,{className:`h-3 w-3`})]})]})]}),w=(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Z.jsx)(P,{value:p,onChange:e=>{(e===`mailgun`||e===`resend`)&&m(e)},options:on.map(e=>({value:e.id,label:e.displayName}))})]}),g?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.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,Z.jsx)(v,{className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,Z.jsxs)(`span`,{children:[b.displayName,` API key configured. To reconfigure, run the`,` `,(0,Z.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:b.setupSkill}),` `,`skill.`]})]}),(0,Z.jsxs)(`a`,{href:b.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 `,b.displayName,(0,Z.jsx)(S,{className:`h-3 w-3`})]})]}):x,(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(Q,{onClick:y,disabled:!1})})]});return l===`gated`?(0,Z.jsx)(gt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,children:w}):(0,Z.jsx)(mt,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,mode:u,onModeChange:_,children:u===`managed`?(0,Z.jsx)(`div`,{className:`space-y-4`,children:l===`disabled`?(0,Z.jsx)(Le,{children:`Log in to the Vellum platform to manage email settings.`}):(0,Z.jsx)(un,{assistantId:e,assistantHandle:s,emailRootDomain:c})}):w})}function fn(){let e=Y(),t=u(),{data:i}=d({...W({path:{assistant_id:e}}),staleTime:3e4}),o=J({onSuccess:n=>{q(t,{path:{assistant_id:e}},n)}}),s=$t(),[c,l]=$((0,X.useMemo)(()=>at(i?i.services?.[`image-generation`]?.mode??r(`vellum:ai:imageGenMode`,`your-own`):r(zt,`your-own`),`your-own`),[i])),[f,p]=(0,X.useState)(()=>r(Bt,`gemini-3.1-flash-image-preview`)),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(!1),v=(0,X.useCallback)(async()=>{_(!0);let r=m.trim(),i=c===`your-own`&&r.length>0;try{i&&await s(ln(f),r),await o.mutateAsync({path:{assistant_id:e},body:{services:{"image-generation":{mode:c}}}}).catch(e=>{throw M.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e});try{await L({path:{assistant_id:e},body:{modelId:f},throwOnError:!0})}catch(e){throw M.error(`Failed to update image generation model. Please try again.`),a(e,{context:`set_image_gen_model`}),e}finally{t.invalidateQueries({queryKey:K({path:{assistant_id:e}})})}}catch{_(!1);return}_(!1);try{n(zt,c),n(Bt,f),i&&h(``),M.success(`Image generation settings saved.`)}catch(e){a(e,{context:`settings-ai-image-gen-persist-local`}),M.error(`Saved, but local preferences could not be written.`)}},[m,c,f,e,o,s,t]),y=(0,X.useCallback)(()=>{h(``),p(`gemini-3.1-flash-image-preview`),n(Bt,`gemini-3.1-flash-image-preview`)},[]);return(0,Z.jsx)(mt,{title:`Image Generation`,subtitle:`Configure which model your assistant uses to generate images`,mode:c,onModeChange:e=>l(e),children:c===`managed`?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Z.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,Z.jsx)(P,{className:`flex-1`,value:f,onChange:p,options:sn.map(e=>({value:e,label:cn[e]??e}))}),(0,Z.jsx)(Q,{onClick:v,disabled:g}),g&&(0,Z.jsx)(w,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]}):(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(k,{label:`API Key`,type:`password`,value:m,onChange:e=>h(e.target.value),placeholder:ln(f)===`openai`?`Enter your OpenAI API key`:`Enter your Gemini API key`,fullWidth:!0}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Z.jsx)(P,{value:f,onChange:p,options:sn.map(e=>({value:e,label:cn[e]??e}))})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Q,{onClick:v,disabled:g}),g&&(0,Z.jsx)(w,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),(0,Z.jsx)(ht,{onClick:y})]})]})})}async function pn(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 mn(n,r,i):t===`deepgram`?await hn(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 mn(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 gn(i,`ElevenLabs rejected the request.`)}}async function hn(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 gn(n,`Deepgram rejected the request.`)}}async function gn(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})`}}var _n={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function vn(){let e=Y(),t=ae.use.name()??`your assistant`,i=le(),a=u(),{data:o}=d({...te({path:{assistant_id:e}}),enabled:i,staleTime:1/0}),c=o?.providers??rn,{data:l}=d({...W({path:{assistant_id:e}}),enabled:i,staleTime:3e4}),f=l?.services?.tts,p=f?.provider,m=f?.mode===`managed`,h=(0,X.useMemo)(()=>at(f?.mode??r(`vellum:voice:ttsMode`,`your-own`),`your-own`),[f?.mode]),[g,_]=$(h),v=c[0]?.id??`elevenlabs`,y=(0,X.useMemo)(()=>p??r(`vellum:voice:ttsProvider`,v),[p,v]),b=!!p,[x,S]=$(y),[C,w]=(0,X.useState)(``),[T,E]=(0,X.useState)(``),[D,O]=(0,X.useState)(``),[A,j]=(0,X.useState)(!1),[N,F]=(0,X.useState)(!1),[I,L]=(0,X.useState)(!1),R=(0,X.useMemo)(()=>c.find(e=>e.id===x)??c[0],[x,c]),B=(0,X.useCallback)(e=>{let t=r(Jt+e,``),n=r(Yt+e,``);j(t.length>0),E(n),O(n),w(``)},[]);(0,X.useEffect)(()=>{B(x)},[x,B]);let V=(0,X.useMemo)(()=>{let e=x!==y,t=C.trim().length>0,n=T.trim()!==D;return e||t||n||g!==h},[x,y,C,T,D,g,h]),H=(0,X.useCallback)(async()=>{let t=C.trim(),i=T.trim(),o=R.id;n(Kt,`your-own`),n(qt,o),t.length>0&&n(Jt+o,t),n(Yt+o,i);let s=t.length>0?t:r(Jt+o,``),c=_n[o];L(!0);try{if(s.length>0){let{response:t}=await ee({path:{assistant_id:e},body:{service:o,field:`api_key`,value:s,label:`${R.displayName} API Key`},throwOnError:!1});if(!t?.ok)throw Error(`Failed to store API key (HTTP ${t?.status??`?`})`)}let t=m,n={...x!==y||!b||t?{provider:o}:{},...t?{mode:`your-own`}:{},...c?{providers:{[o]:{[c]:i}}}:{}};if(Object.keys(n).length>0){let{response:t}=await z({path:{assistant_id:e},body:{services:{tts:n}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}j(s.length>0),O(i),w(``),a.invalidateQueries({queryKey:K({path:{assistant_id:e}})}),M.success(`Text-to-speech settings saved`)}catch(e){M.error(e instanceof Error?e.message:`Failed to save text-to-speech settings`)}finally{L(!1)}},[e,x,C,T,R,y,b,m,a]),U=(0,X.useCallback)(async()=>{L(!0);try{let{response:t}=await z({path:{assistant_id:e},body:{services:{tts:{mode:`managed`,provider:R.id}}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`);n(Kt,`managed`),a.invalidateQueries({queryKey:K({path:{assistant_id:e}})}),M.success(`Text-to-speech settings saved`)}catch(e){M.error(e instanceof Error?e.message:`Failed to save text-to-speech settings`)}finally{L(!1)}},[e,R,a]),ne=(0,X.useCallback)(()=>{n(Jt+x,``),j(!1),w(``)},[x]),G=(0,X.useCallback)(async()=>{F(!0);try{let e=r(Jt+x,``),n=C.trim(),i=n.length>0?n:e;if(i.length===0){M.error(`Save an API key for this provider before testing.`);return}let a=r(Yt+x,``),o=T.trim(),s=await pn({provider:x,apiKey:i,voiceId:o.length>0?o:a,text:`Hey! It's ${t}. How does this sound?`});if(s.kind!==`audio`){M.error(s.message);return}let c=URL.createObjectURL(s.blob);try{let e=new Audio(c);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(c)}}finally{F(!1)}},[t,C,x,T]),re=A?`•••••••• (Enter a new key to replace)`:R.apiKeyPlaceholder;return(0,Z.jsx)(mt,{title:`Text-to-Speech`,subtitle:`Configure how your assistant speaks`,mode:g,onModeChange:e=>_(e),children:g===`managed`?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Managed speech synthesis is included with your Vellum connection.`}),(0,Z.jsx)(Q,{onClick:U,disabled:I})]}):(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Z.jsx)(P,{value:x,onChange:S,options:c.map(e=>({value:e.id,label:e.displayName})),"aria-label":`TTS provider`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Z.jsx)(k,{type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:re,fullWidth:!0})]}),R.supportsVoiceSelection&&(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice ID`}),(0,Z.jsx)(k,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`Enter a voice ID`,fullWidth:!0})]}),(0,Z.jsx)(_t,{guide:R.credentialsGuide}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(s,{variant:`outlined`,onClick:G,disabled:N,children:N?`Testing…`:`Test`}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Z.jsx)(Q,{onClick:H,disabled:!V||I}),A&&(0,Z.jsx)(ht,{onClick:ne})]})]})]})})}var yn={deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},bn={deepgram:`deepgram`,"openai-whisper":`openai`};function xn(){let e=Y(),t=le(),i=u(),[a]=(0,X.useState)(()=>an.filter(e=>!e.requiresNativeDictation||Ge())),o=a[0]?.id??`deepgram`,{data:s}=d({...W({path:{assistant_id:e}}),enabled:t,staleTime:3e4}),c=s?.services?.stt,l=c?.provider,f=c?.mode===`managed`,p=(0,X.useMemo)(()=>at(c?.mode??r(`vellum:voice:sttMode`,`your-own`),`your-own`),[c?.mode]),[m,h]=$(p),g=(0,X.useMemo)(()=>{let e=l?bn[l]:void 0;if(e&&a.some(t=>t.id===e))return e;let t=r(Zt,o);return a.some(e=>e.id===t)?t:o},[l,a,o]),_=!!l,[v,y]=$(g),[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(!1),[w,E]=(0,X.useState)(!1);(0,X.useEffect)(()=>{let e=r(Zt,o);e===`macos-native`&&!a.some(t=>t.id===e)&&n(Zt,o)},[a,o]);let D=(0,X.useMemo)(()=>a.find(e=>e.id===v)??a[0],[a,v]),O=D.apiKeyPlaceholder!==void 0;(0,X.useEffect)(()=>{C(r(Qt+v,``).length>0),x(``)},[v]);let A=(0,X.useMemo)(()=>{let e=v!==g,t=b.trim().length>0;return e||t||m!==p},[v,g,b,m,p]),j=(0,X.useCallback)(async()=>{let t=b.trim();n(Xt,`your-own`),n(Zt,v),t.length>0&&n(Qt+v,t);let a=yn[v];E(!0);try{if(a){let n=t.length>0?t:r(Qt+v,``);if(n.length>0){let{response:t}=await ee({path:{assistant_id:e},body:{service:a.credentialService,field:`api_key`,value:n,label:`${D.displayName} API Key`},throwOnError:!1});if(!t?.ok)throw Error(`Failed to store API key (HTTP ${t?.status??`?`})`)}}let n=f,o=!!a&&(v!==g||!_)||n&&(!l||l===`vellum`);if(o||n){let t=a?.provider??yn[v]?.provider??`deepgram`,{response:r}=await z({path:{assistant_id:e},body:{services:{stt:{...o?{provider:t}:{},...n?{mode:`your-own`}:{}}}},throwOnError:!1});if(!r?.ok)throw Error(`Failed to save configuration (HTTP ${r?.status??`?`})`)}t.length>0&&C(!0),x(``),i.invalidateQueries({queryKey:K({path:{assistant_id:e}})}),M.success(`Speech-to-text settings saved`)}catch(e){M.error(e instanceof Error?e.message:`Failed to save speech-to-text settings`)}finally{E(!1)}},[e,v,b,D,g,_,f,l,i]),N=(0,X.useCallback)(async()=>{E(!0);try{let t=l&&l!==`vellum`?l:yn[v]?.provider??`deepgram`,{response:r}=await z({path:{assistant_id:e},body:{services:{stt:{mode:`managed`,provider:t}}},throwOnError:!1});if(!r?.ok)throw Error(`Failed to save configuration (HTTP ${r?.status??`?`})`);n(Xt,`managed`),v===`macos-native`&&n(Zt,o),i.invalidateQueries({queryKey:K({path:{assistant_id:e}})}),M.success(`Speech-to-text settings saved`)}catch(e){M.error(e instanceof Error?e.message:`Failed to save speech-to-text settings`)}finally{E(!1)}},[e,l,v,o,i]),F=(0,X.useCallback)(()=>{n(Qt+v,``),C(!1),x(``)},[v]),I=S?`•••••••• (Enter a new key to replace)`:D.apiKeyPlaceholder;return(0,Z.jsx)(mt,{title:`Speech-to-Text`,subtitle:`Configure how your assistant transcribes speech`,mode:m,onModeChange:e=>h(e),children:m===`managed`?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Managed transcription is included with your Vellum connection.`}),(0,Z.jsx)(Q,{onClick:N,disabled:w})]}):(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Z.jsx)(P,{value:v,onChange:y,options:a.map(e=>({value:e.id,label:e.displayName})),"aria-label":`STT provider`})]}),O&&(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Z.jsx)(k,{type:`password`,value:b,onChange:e=>x(e.target.value),placeholder:I,fullWidth:!0})]}),D.setupWarning&&(0,Z.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,Z.jsx)(T,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,Z.jsx)(`span`,{children:D.setupWarning})]}),D.credentialsGuide&&(0,Z.jsx)(_t,{guide:D.credentialsGuide}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Z.jsx)(Q,{onClick:j,disabled:!A||w}),S&&(0,Z.jsx)(ht,{onClick:F})]})]})})}function Sn(){return(0,X.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]),(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.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,Z.jsx)(C,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Z.jsxs)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:[`Managed services are metered and deducted from your Vellum account balance.`,` `,(0,Z.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,Z.jsx)(S,{className:`h-3.5 w-3.5`})]})]})]}),(0,Z.jsx)(Rt,{}),(0,Z.jsx)(en,{}),(0,Z.jsx)(nn,{}),(0,Z.jsx)(dn,{}),(0,Z.jsx)(fn,{}),(0,Z.jsx)(vn,{}),(0,Z.jsx)(xn,{})]})}export{Sn as AiPage};
@@ -1 +0,0 @@
1
- import{t as e}from"./button-BQVYX8n_.js";import{t}from"./jsx-runtime-CVSDxk6A.js";import{t as n}from"./card-D8zyWtZh.js";import{t as r}from"./createLucideIcon-Bjb-Kuq7.js";import{r as i}from"./middleware-DL-IveDQ.js";import{t as a}from"./bug-YmXTm_XW.js";import{t as o}from"./external-link-5a-JuPGf.js";import{t as s}from"./globe-Dx8dM0gj.js";import{t as c}from"./sparkles-DDIsk_nZ.js";import{t as l}from"./tag-B6WeUtBW.js";import{A as u,Ct as d,Gi as f,O as p,k as m,ra as h,v as g,wa as _,zi as v}from"./index-CZVGv7Cn.js";var y=r(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),b=t();function x({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`})})}function S({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})})}function C({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814ZM9.545 15.568V8.432L15.818 12l-6.273 3.568Z`})})}function w(){return(0,b.jsx)(n,{padding:`lg`,className:`bg-[var(--surface-lift)]`,children:(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`div`,{className:`pointer-events-none absolute -right-16 -top-16 h-64 w-64 rounded-full opacity-30 blur-3xl`,style:{background:`radial-gradient(circle, var(--system-mid-weak) 0%, transparent 70%)`},"aria-hidden":!0}),(0,b.jsxs)(`div`,{className:`relative flex flex-col items-start gap-3`,children:[(0,b.jsxs)(l,{tone:`neutral`,children:[(0,b.jsx)(h,{className:`h-3.5 w-3.5`}),`Community`]}),(0,b.jsx)(`h1`,{className:`text-[28px] font-semibold leading-tight tracking-tight text-[var(--content-emphasised)]`,children:`Build with us, in the open.`}),(0,b.jsx)(`p`,{className:`max-w-xl text-body-medium-default text-[color:var(--content-tertiary)]`,children:`Vellum is built in the open with a growing community of developers, designers, and tinkerers. Here's how to get involved.`})]})]})})}function T({icon:e,text:t}){return(0,b.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--surface-base)]`,children:(0,b.jsx)(e,{size:14,className:`text-[var(--content-secondary)]`,"aria-hidden":!0})}),(0,b.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]})}function E({accentColor:t,iconColor:r=`var(--aux-white)`,label:a,icon:o,title:s,subtitle:c,benefits:l,primaryAction:u,secondaryAction:d}){return(0,b.jsx)(n,{padding:`lg`,className:`flex-1`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,b.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg`,style:{backgroundColor:t,color:r},children:o}),(0,b.jsx)(`span`,{className:`text-label-medium-default uppercase tracking-wider text-[color:var(--content-tertiary)]`,children:a})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`h2`,{className:`text-title-medium text-[var(--content-emphasised)]`,children:s}),(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:c})]}),(0,b.jsx)(`ul`,{className:`flex flex-col gap-3`,children:l.map(({icon:e,text:t})=>(0,b.jsx)(T,{icon:e,text:t},t))}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(e,{onClick:u.onClick,children:[u.icon,u.label]}),d&&(0,b.jsxs)(e,{variant:`ghost`,onClick:()=>window.open(d.href,`_blank`,`noopener,noreferrer`),children:[d.label,(0,b.jsx)(i,{className:`h-3.5 w-3.5`})]})]})]})})}function D({icon:e,iconBg:t,iconColor:r=`white`,title:i,description:a,href:s}){return(0,b.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,className:`flex flex-1 cursor-pointer`,children:(0,b.jsx)(n,{className:`flex-1 transition-shadow hover:shadow-md`,padding:`lg`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,b.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg`,style:{backgroundColor:t,color:r},children:e}),(0,b.jsx)(o,{size:14,className:`text-[var(--content-tertiary)]`,"aria-hidden":!0})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`span`,{className:`text-title-medium text-[var(--content-emphasised)]`,children:i}),(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:a})]})]})})})}function O(){let{handleStar:e}=u();return(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsx)(w,{}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,b.jsx)(E,{accentColor:`var(--content-emphasised)`,iconColor:`var(--surface-base)`,label:`Open Source`,icon:(0,b.jsx)(x,{size:20}),title:`Vellum is open source`,subtitle:`Read the source, star the repo, and contribute fixes and features on GitHub.`,benefits:[{icon:f,text:`Star the repo to follow updates`},{icon:a,text:`Open issues and report bugs`},{icon:y,text:`Contribute fixes and new features`}],primaryAction:{label:`Star on GitHub`,icon:(0,b.jsx)(f,{size:16}),onClick:e},secondaryAction:{label:`View source`,href:m}}),(0,b.jsx)(E,{accentColor:`#5865F2`,label:`Discord`,icon:(0,b.jsx)(d,{size:20}),title:`Join our community`,subtitle:`Talk to the team, share feedback, request features, and get answers faster.`,benefits:[{icon:_,text:`Talk directly with the team`},{icon:c,text:`Share feedback and request features`},{icon:v,text:`Get answers faster from the community`}],primaryAction:{label:`Join Discord`,icon:(0,b.jsx)(d,{size:16,style:{color:`currentColor`}}),onClick:p}})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsx)(`h2`,{className:`text-label-medium-default uppercase tracking-wider text-[color:var(--content-tertiary)]`,children:`More from Vellum`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,b.jsx)(D,{icon:(0,b.jsx)(s,{size:20}),iconBg:`#22c55e`,title:`Community Hub`,description:`Showcases, guides, and projects shared by the community.`,href:g}),(0,b.jsx)(D,{icon:(0,b.jsx)(S,{size:20}),iconBg:`var(--content-default)`,iconColor:`var(--surface-base)`,title:`Follow on X`,description:`Product updates, releases, and behind-the-scenes.`,href:`https://x.com/vellum_ai`}),(0,b.jsx)(D,{icon:(0,b.jsx)(C,{size:20}),iconBg:`#ef4444`,title:`YouTube channel`,description:`Walkthroughs, tutorials, and product deep-dives.`,href:`https://www.youtube.com/@Vellum_AI`})]})]})]})}export{O as CommunityPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-BQVYX8n_.js";import{m as r,n as i,t as a,u as o}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./useQuery-B45lW1Kk.js";import{t as l}from"./useMutation-Lj4VunQV.js";import{t as u}from"./jsx-runtime-CVSDxk6A.js";import{t as d}from"./typography-Cqi8q9o7.js";import{t as f}from"./card-D8zyWtZh.js";import{t as p}from"./createLucideIcon-Bjb-Kuq7.js";import{t as m}from"./arrow-left-C2re-gYj.js";import{t as h}from"./link-2-BASJHEX6.js";import{t as g}from"./loader-circle-D57RZgLH.js";import{t as _}from"./pencil-DEevs4oD.js";import{t as v}from"./plus-CQiIB1qS.js";import{t as y}from"./user-plus-Jr3b-fDv.js";import{t as b}from"./tag-B6WeUtBW.js";import{t as x}from"./input-ZpyYt_a0.js";import{t as S}from"./modal-BtcwNEBj.js";import{t as C}from"./panel-item-Bvqsr5n9.js";import{n as w}from"./toast-ZoZVyeDI.js";import{t as T}from"./confirm-dialog-CCrDkChx.js";import{C as E}from"./sdk.gen-D_Qurj4O.js";import{Ht as ee,S as D,Vt as te,a as O,b as ne,x as k}from"./react-query.gen-BQH0QRfT.js";import{t as re}from"./assistant-identity-store-bwxIa6fM.js";import{c as ie}from"./routes-XPLb07Av.js";import{t as ae}from"./assistant-feature-flag-store-BpbbAIKZ.js";import{$i as A,Cn as j,Ga as M,Qi as N,Ta as oe,Ua as P,Ut as F,Va as I,la as L,oa as se,pa as R,w as ce,wn as z,xr as B,zr as V}from"./index-CZVGv7Cn.js";import{t as H}from"./use-active-assistant-id-9rGx8kT9.js";import{a as le,d as ue,i as de,n as fe,o as pe,r as me,t as he}from"./use-invite-link-dialog-B6r6wWD7.js";import{t as U}from"./detail-card-CA8lPa5K.js";import{n as ge,t as _e}from"./mobile-sidebar-drawer-kwgBD2Oe.js";import{t as W}from"./mutation-error-CbcKvssD.js";import{a as ve,i as ye,n as G,t as be}from"./contacts-gateway-EIOxMIFC.js";var xe=p(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Se=p(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Ce=p(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),K=e(t(),1),q=new Set([`slack`]);function J(e){return e.status===`verified`||e.status===`active`&&e.verifiedAt!=null}var Y=u();function X({channels:e,pendingChannelKey:t=null,onConnect:n,onDisconnect:r}){let[i,a]=(0,K.useState)(null);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`flex flex-col`,children:e.map((e,i)=>(0,Y.jsxs)(`div`,{children:[i>0?(0,Y.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}):null,(0,Y.jsx)(Z,{channel:e,pending:t===e.key,onConnect:n?()=>n(e.key):void 0,onDisconnect:r?()=>a(e.key):void 0})]},e.key))}),(0,Y.jsx)(T,{open:i!==null,title:`Disconnect ${i?z(i):``}?`,message:`This clears the stored credentials for this channel. You can reconnect later.`,confirmLabel:`Disconnect`,destructive:!0,onConfirm:()=>{i&&r&&r(i),a(null)},onCancel:()=>a(null)})]})}function Z({channel:e,pending:t,onConnect:r,onDisconnect:i}){let a=e.status===`ready`;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,Y.jsx)(j,{channelId:e.key,className:`h-4 w-4 shrink-0 text-[color:var(--content-secondary)]`}),(0,Y.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:z(e.key)}),a&&e.address?(0,Y.jsx)(`span`,{className:`truncate text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:e.address}):null,(0,Y.jsx)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 h-8 px-2.5 rounded-md whitespace-nowrap select-none text-body-small-emphasised leading-none bg-[var(--content-default)] text-[var(--surface-base)]`,children:[(0,Y.jsx)(I,{className:`h-3 w-3`}),`Connected`]}),(0,Y.jsx)(n,{variant:`danger`,onClick:i,disabled:!i||t,children:t?`Disconnecting…`:`Disconnect`})]}):(0,Y.jsx)(n,{variant:`outlined`,onClick:r,disabled:!r||t,children:`Connect`})})]})}function Q({role:e,contactType:t}){let{label:n,tone:r}=we(e,t);return(0,Y.jsx)(b,{tone:r,children:n})}function we(e,t){switch(e){case`guardian`:return{label:`Guardian`,tone:`positive`};case`assistant`:return{label:`Assistant`,tone:`negative`};default:return t===`assistant`?{label:`Assistant`,tone:`negative`}:{label:`Human`,tone:`warning`}}}function Te({assistantName:e,...t}){let n=ue(e);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.jsx)(U,{title:`${n} (Your Assistant)`,accessory:(0,Y.jsx)(Q,{role:`assistant`}),compactAccessory:!0}),(0,Y.jsx)(U,{title:`Channels`,subtitle:`Where ${n} can be reached.`,children:(0,Y.jsx)(X,{...t})})]})}function Ee({provenance:e}){return e.source===`global-default`?(0,Y.jsx)(b,{children:`Global default`}):(0,Y.jsxs)(b,{children:[`Default from`,(0,Y.jsx)(n,{asChild:!0,variant:`link`,size:`compact`,className:`h-auto px-0`,children:(0,Y.jsxs)(a,{to:`${ie.channels}?setup=${e.channel}`,children:[`Channels → `,z(e.channel)]})})]})}var $=new Set([`telegram`,`phone`,`vellum`,`whatsapp`,`slack`,`email`,`platform`,`a2a`]);function De(e){return $.has(e)}function Oe(e,t){return e.id===`a2a`?t&&t.status!==`revoked`?{kind:`connected`}:{kind:`setup`}:t!=null&&J(t)?{kind:`verified`}:t?.status===`blocked`?{kind:`none`}:t&&t.status!==`revoked`?{kind:`unverified`}:{kind:`setup`}}function ke(e,t,n){let r=[],i=new Set;if(e)for(let t of e)t.id===`a2a`&&!n||(r.push(t),i.add(t.id));for(let e of t)e.status===`revoked`||i.has(e.type)||e.type===`a2a`&&!n||De(e.type)&&(r.push({id:e.type,label:e.type.charAt(0).toUpperCase()+e.type.slice(1),subtitle:``,icon:`help-circle`,supportsVerification:!1,setupMessages:{guardian:``,contact:``}}),i.add(e.type));return r}function Ae({name:e,className:t,style:n}){switch(e){case`bot`:return(0,Y.jsx)(P,{className:t,style:n});case`hash`:return(0,Y.jsx)(oe,{className:t,style:n});case`send`:return(0,Y.jsx)(N,{className:t,style:n});case`phone`:return(0,Y.jsx)(se,{className:t,style:n});case`mail`:return(0,Y.jsx)(R,{className:t,style:n});case`message-square`:return(0,Y.jsx)(L,{className:t,style:n});default:return(0,Y.jsx)(xe,{className:t,style:n})}}function je({contactChannels:e,availableChannels:t,a2aEnabled:n,channelProvenance:r,setupLabel:i=`Invite`,verifyLoading:a,verifySubject:o=`self`,onSetupChannel:s,onVerifyChannel:c,onRevokeChannel:l,onLinkAccount:u}){let[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(null),h=new Map;for(let t of e)t.status!==`revoked`&&(h.has(t.type)||h.set(t.type,t));return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`flex flex-col`,children:ke(t,e,n).map((e,t)=>{let n=h.get(e.id);return(0,Y.jsxs)(`div`,{children:[t>0&&(0,Y.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}),(0,Y.jsx)(Me,{info:e,existing:n,provenance:n&&F(e.id)?r?.[e.id]:void 0,setupLabel:i,verifyLoading:a,onSetup:s?()=>s(e.id):void 0,onVerify:c&&e.supportsVerification?()=>f(e):void 0,onRevoke:l&&n?()=>m({channelId:n.id,channel:e}):void 0,onLinkAccount:u&&q.has(e.id)?()=>u(e.id):void 0})]},e.id)})}),d&&(0,Y.jsx)(T,{open:!0,title:`Verify ${d.label}`,message:o===`contact`?`This will mark this contact's ${d.label} channel as verified. Your assistant will recognize them when they reach out from it.`:`This will mark your ${d.label} channel as verified. Your assistant will recognize you when you reach out from it.`,confirmLabel:`Verify`,onConfirm:()=>{d&&(c?.(d.id),f(null))},onCancel:()=>f(null)}),p&&(0,Y.jsx)(T,{open:!0,title:`Revoke ${p.channel.label}`,message:`This will disconnect the verified channel. The contact will need to re-verify to use this channel again.`,confirmLabel:`Revoke`,destructive:!0,onConfirm:()=>{l?.(p.channelId,p.channel.id),m(null)},onCancel:()=>m(null)})]})}function Me({info:e,existing:t,provenance:r,setupLabel:i,verifyLoading:a,onSetup:o,onVerify:s,onRevoke:c,onLinkAccount:l}){let u=Oe(e,t);return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,Y.jsx)(Ae,{name:e.icon,className:`h-4 w-4 shrink-0`,style:{color:`var(--content-secondary)`}}),(0,Y.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e.label}),t?.address?(0,Y.jsx)(`span`,{className:`truncate text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:t.address}):null,(0,Y.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[r?(0,Y.jsx)(Ee,{provenance:r}):null,u.kind===`connected`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 h-8 px-2.5 rounded-md whitespace-nowrap select-none text-body-small-emphasised leading-none bg-[var(--content-default)] text-[var(--surface-base)]`,children:[(0,Y.jsx)(I,{className:`h-3 w-3`}),`Connected`]}),c?(0,Y.jsx)(n,{variant:`danger`,onClick:c,children:`Revoke`}):null]}):u.kind===`verified`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 h-8 px-2.5 rounded-md whitespace-nowrap select-none text-body-small-emphasised leading-none bg-[var(--content-default)] text-[var(--surface-base)]`,children:[(0,Y.jsx)(I,{className:`h-3 w-3`}),`Verified`]}),c?(0,Y.jsx)(n,{variant:`danger`,onClick:c,children:`Revoke`}):null]}):u.kind===`unverified`?(0,Y.jsx)(n,{variant:`outlined`,onClick:s,disabled:!s||a,children:a?`Verifying…`:`Verify`}):u.kind===`setup`?e.id===`a2a`?null:(0,Y.jsxs)(Y.Fragment,{children:[l?(0,Y.jsxs)(n,{onClick:l,children:[(0,Y.jsx)(h,{className:`h-3.5 w-3.5`}),`Link account`]}):null,(0,Y.jsx)(n,{variant:`outlined`,onClick:o,disabled:!o,children:i})]}):null]})]})}function Ne(e){return(0,Y.jsx)(Pe,{...e},e.contact.id)}function Pe({contact:e,savePending:t,deletePending:r,verifyPending:i,mergePending:a=!1,canMerge:o=!1,availableChannels:s,a2aEnabled:c,channelProvenance:l,onSave:u,onDelete:d,onMerge:f,onSetupChannel:p,onVerifyChannel:m,onRevokeChannel:h,onLinkAccount:g}){let _=e.displayName===`New Contact`,[v,y]=(0,K.useState)(_?``:e.displayName),[b,S]=(0,K.useState)(e.notes??``),[C,w]=(0,K.useState)(!1),E=v.trim(),ee=b.trim(),D=_?``:e.displayName,te=e.notes??``,O=E!==D||ee!==te,ne=E.length>0&&O&&!t&&!r,k=_&&e.channels.length===0&&e.interactionCount===0,re=E||e.displayName,ie=`${e.interactionCount} interaction${e.interactionCount===1?``:`s`}`;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.jsx)(U,{title:re,accessory:(0,Y.jsx)(Q,{role:e.role,contactType:e.contactType}),compactAccessory:!0,subtitle:ie,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsx)(x,{label:`Name`,type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:`Give this human a name`,autoFocus:_,disabled:t||r,fullWidth:!0}),(0,Y.jsx)(x,{label:`Notes`,type:`text`,value:b,onChange:e=>S(e.target.value),placeholder:`Optional notes about the human which AI will take into account`,disabled:t||r,fullWidth:!0}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(n,{type:`button`,onClick:()=>u({displayName:E,notes:ee}),disabled:!ne,children:t?`Saving…`:`Save`}),f?(0,Y.jsx)(n,{type:`button`,variant:`outlined`,onClick:f,disabled:!o||k||O||a||t||r,title:o?k?`Save this contact before merging`:O?`Save your changes before merging`:void 0:`No other contacts available to merge`,children:a?`Merging…`:`Merge…`}):null,(0,Y.jsx)(n,{type:`button`,variant:`danger`,onClick:()=>{k?d():w(!0)},disabled:r,children:r?`Deleting…`:`Delete Contact`})]})]})}),(0,Y.jsx)(U,{title:`Linked accounts`,subtitle:`Where the assistant recognizes this contact. Link accounts you know, invite the ones you don't.`,children:(0,Y.jsx)(je,{contactChannels:e.channels,availableChannels:s,a2aEnabled:c,channelProvenance:l,verifyLoading:i,verifySubject:`contact`,onSetupChannel:p,onVerifyChannel:m,onRevokeChannel:h,onLinkAccount:g})}),(0,Y.jsx)(T,{open:C,title:`Delete ${e.displayName}?`,message:`This will permanently delete this contact and all their channels. This action cannot be undone.`,confirmLabel:`Delete`,destructive:!0,onConfirm:()=>{w(!1),d()},onCancel:()=>w(!1)})]})}function Fe(e){return(0,Y.jsx)(Ie,{...e},`${e.survivor.id}:${e.open?`open`:`closed`}`)}function Ie({open:e,survivor:t,candidates:r,pending:i,errorMessage:a,onMerge:o,onClose:s}){let[c,l]=(0,K.useState)(``),[u,f]=(0,K.useState)(null);(0,K.useEffect)(()=>{u&&!r.some(e=>e.id===u)&&f(null)},[r,u]);let p=(0,K.useMemo)(()=>{let e=c.trim().toLowerCase();return e?r.filter(t=>t.displayName.toLowerCase().includes(e)):r},[r,c]),h=u?r.find(e=>e.id===u)??null:null,g=Ve(t);return(0,Y.jsx)(S.Root,{open:e,onOpenChange:e=>{!e&&!i&&s()},children:(0,Y.jsxs)(S.Content,{size:`md`,children:[(0,Y.jsxs)(S.Header,{children:[(0,Y.jsx)(S.Title,{icon:Ce,children:h?`Merge "${h.displayName}" into ${g}?`:`Merge another contact into ${g}`}),(0,Y.jsx)(S.Description,{children:h?`Channels and notes from the merged contact will move over. The merged contact will be deleted.`:`The contact you pick will be deleted. Its channels and notes will be added to this one.`})]}),(0,Y.jsxs)(S.Body,{className:`flex flex-col gap-3`,children:[h?(0,Y.jsx)(ze,{survivor:t,donor:h}):r.length===0?(0,Y.jsx)(Be,{}):(0,Y.jsx)(Le,{search:c,onSearch:l,candidates:p,onPick:f}),a?(0,Y.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-(--system-negative-strong)`,role:`alert`,children:a}):null]}),(0,Y.jsx)(S.Footer,{children:h?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(n,{variant:`outlined`,onClick:()=>f(null),disabled:i,leftIcon:(0,Y.jsx)(m,{"aria-hidden":!0}),children:`Back`}),(0,Y.jsx)(n,{variant:`danger`,onClick:()=>o(h.id),disabled:i,children:i?`Merging…`:`Merge`})]}):(0,Y.jsx)(n,{variant:`outlined`,onClick:s,disabled:i,children:`Cancel`})})]})})}function Le({search:e,onSearch:t,candidates:n,onPick:r}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Search contacts`,leftIcon:(0,Y.jsx)(A,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0}),(0,Y.jsx)(`div`,{className:`flex max-h-[320px] min-h-[120px] flex-col gap-1 overflow-y-auto`,role:`listbox`,"aria-label":`Select a contact to merge`,children:n.length===0?(0,Y.jsx)(d,{as:`p`,variant:`body-small-default`,className:`px-3 py-4 text-center text-(--content-tertiary)`,children:`No matching contacts`}):n.map(e=>(0,Y.jsx)(Re,{contact:e,onPick:()=>r(e.id)},e.id))})]})}function Re({contact:e,onPick:t}){let n=Ge(e).join(` | `)||void 0;return(0,Y.jsx)(C,{asChild:!0,label:``,children:(0,Y.jsx)(`button`,{type:`button`,onClick:t,role:`option`,"aria-selected":`false`,className:`flex h-auto w-full items-center gap-2 rounded-[6px] px-[8px] py-2 text-left`,children:(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-body-medium-default`,children:e.displayName}),n?(0,Y.jsx)(`span`,{className:`truncate text-body-small-default text-(--content-tertiary)`,children:n}):null]})})})}function ze({survivor:e,donor:t}){let n=Ve(e),{moved:r,duplicates:i}=We(e,t);return(0,Y.jsxs)(`ul`,{className:`flex flex-col gap-2 text-body-medium-lighter text-(--content-secondary)`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`span`,{className:`text-(--content-default)`,children:[`“`,t.displayName,`”`]}),` `,`will be deleted.`]}),(0,Y.jsx)(`li`,{children:r.length===0?`No new channels will move to ${n}.`:`${r.length} channel${r.length===1?``:`s`} will move to ${n}: ${r.map(e=>Ue(e.type)).join(`, `)}.`}),i.length>0?(0,Y.jsxs)(`li`,{className:`text-(--content-tertiary)`,children:[i.length,` duplicate channel`,i.length===1?``:`s`,` already on `,n,` `,`(skipped).`]}):null,t.notes?(0,Y.jsx)(`li`,{children:`Notes from the merged contact will be appended.`}):null,(0,Y.jsx)(`li`,{className:`text-(--content-tertiary)`,children:`This cannot be undone.`})]})}function Be(){return(0,Y.jsx)(d,{as:`p`,variant:`body-medium-lighter`,className:`px-3 py-6 text-center text-(--content-tertiary)`,children:`No other contacts available to merge.`})}function Ve(e){return e.role===`guardian`?!e.displayName||e.displayName.startsWith(`vellum-principal-`)?`you`:`${e.displayName} (you)`:e.displayName||`this contact`}var He={slack:`Slack`,telegram:`Telegram`,phone:`Phone`,email:`Email`,whatsapp:`WhatsApp`};function Ue(e){return He[e.toLowerCase()]??e}function We(e,t){let n=[],r=[];for(let i of t.channels)i.status!==`revoked`&&(e.channels.some(e=>e.type===i.type&&e.address.toLowerCase()===i.address.toLowerCase())?r.push(i):n.push(i));return{moved:n,duplicates:r}}function Ge(e){let t=new Set,n=[];for(let r of e.channels){if(r.status===`revoked`)continue;let e=r.type.toLowerCase();t.has(e)||(t.add(e),n.push(He[e]??r.type))}return n}function Ke({loading:e,guardian:t,assistantName:r,regularContacts:i,selection:a,onSelect:o,onAddContact:s,addingContact:c=!1}){let[l,u]=(0,K.useState)(``),d=l.trim()?i.filter(e=>e.displayName.toLowerCase().includes(l.trim().toLowerCase())):i;return(0,Y.jsx)(f.Root,{className:`flex h-full flex-col overflow-hidden`,children:(0,Y.jsxs)(f.Body,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`h2`,{className:`text-title-medium`,style:{color:`var(--content-default)`},children:`Entries`}),(0,Y.jsx)(n,{type:`button`,variant:`ghost`,iconOnly:c?(0,Y.jsx)(g,{className:`animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(v,{"aria-hidden":!0}),onClick:s,disabled:c,"aria-label":`Add contact`,tintColor:`var(--content-secondary)`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t?(0,Y.jsx)(qe,{name:t.displayName?`${t.displayName} (You)`:`You`,role:t.role,channelTypes:t.channelTypes,selected:a?.kind===`contact`&&a.contactId===t.id,onClick:()=>o({kind:`contact`,contactId:t.id}),trailingIcon:`pencil`}):null,(0,Y.jsx)(qe,{name:r?.trim()||`Your Assistant`,role:`assistant`,selected:a?.kind===`assistant`,onClick:()=>o({kind:`assistant`}),trailingIcon:`more`})]}),(0,Y.jsx)(`div`,{className:`border-t`,style:{borderColor:`var(--border-base)`}}),i.length>0?(0,Y.jsx)(x,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`Search Contacts`,leftIcon:(0,Y.jsx)(A,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0}):null,i.length>0?(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto flex flex-col gap-1`,children:[d.map(e=>(0,Y.jsx)(qe,{name:e.displayName,role:e.role,contactType:e.contactType,channelTypes:e.channelTypes,verified:e.verified,selected:a?.kind===`contact`&&a.contactId===e.id,onClick:()=>o({kind:`contact`,contactId:e.id}),trailingIcon:`more`},e.id)),d.length===0?(0,Y.jsx)(`p`,{className:`px-3 py-4 text-center text-body-small-default`,style:{color:`var(--content-tertiary)`},children:`No matching contacts`}):null]}):e?null:(0,Y.jsx)(n,{type:`button`,variant:`ghost`,onClick:s,disabled:c,tintColor:`var(--primary-base)`,leftIcon:c?(0,Y.jsx)(g,{className:`animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(y,{"aria-hidden":!0}),children:`Add Contact`})]})})}function qe({name:e,role:t,contactType:n,channelTypes:r,selected:i,onClick:a,trailingIcon:o,verified:s}){let c=r&&r.length>0?r.join(` | `):void 0;return(0,Y.jsx)(C,{asChild:!0,active:i,label:``,trailingAction:o===`pencil`?(0,Y.jsx)(_,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):o===`more`?(0,Y.jsx)(Se,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):void 0,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:a,className:`flex h-auto w-full items-center gap-2 rounded-[6px] px-[8px] py-2 text-left`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-body-medium-default`,children:e}),c?(0,Y.jsx)(`span`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:c}):null]}),(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[s===void 0?null:(0,Y.jsx)(b,{tone:s?`positive`:`neutral`,children:s?`Verified`:`Unverified`}),(0,Y.jsx)(Q,{role:t,contactType:n})]})]})})}function Je(e){return(0,Y.jsx)(Ye,{...e},e.contact.id)}function Ye({contact:e,savePending:t,verifyPending:r,mergePending:i=!1,canMerge:a=!1,availableChannels:o,a2aEnabled:s,onSave:c,onMerge:l,onSetupChannel:u,onVerifyChannel:d,onRevokeChannel:f,onGenerateInviteLink:p}){let m=e.displayName.startsWith(`vellum-principal-`),h=m?``:e.displayName,[g,_]=(0,K.useState)(h),[v,y]=(0,K.useState)(e.notes??``),b=g.trim(),S=v.trim(),C=b!==h.trim()||S!==(e.notes??``).trim(),w=C&&!t,T=`${e.interactionCount} interaction${e.interactionCount===1?``:`s`}`;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Y.jsx)(U,{title:m?`You`:`${e.displayName} (You)`,accessory:(0,Y.jsx)(Q,{role:`guardian`}),compactAccessory:!0,subtitle:T,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsx)(x,{label:`Name`,type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:`Your name`,disabled:t,fullWidth:!0}),(0,Y.jsx)(x,{label:`Notes`,type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:`Notes about yourself which AI will take into account`,disabled:t,fullWidth:!0}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(n,{variant:`primary`,onClick:()=>c({displayName:b||e.displayName,notes:S}),disabled:!w,children:t?`Saving…`:`Save`}),l?(0,Y.jsx)(n,{variant:`outlined`,onClick:l,disabled:!a||C||i||t,title:a?C?`Save your changes before merging`:void 0:`No other contacts available to merge`,children:i?`Merging…`:`Merge…`}):null]})]})}),(0,Y.jsx)(U,{title:`Channels`,subtitle:`Once verified, your assistant will recognize you when you message from these channels.`,children:(0,Y.jsx)(je,{contactChannels:e.channels,availableChannels:o,a2aEnabled:s,setupLabel:`Verify me`,verifyLoading:r,onSetupChannel:u,onVerifyChannel:d,onRevokeChannel:f})}),p?(0,Y.jsx)(le,{onClick:p}):null]})}function Xe(e,t){let n=t.trim().toLowerCase().replace(/^@/,``);return n===``?e:e.filter(e=>e.displayName.toLowerCase().includes(n)||e.username.toLowerCase().includes(n))}function Ze(e){let t=e.trim().split(/\s+/).filter(Boolean);return`${t[0]?.[0]??`?`}${t.length>1?t[t.length-1]?.[0]??``:``}`.toUpperCase()}function Qe({open:e,channelLabel:t,contactName:r,accounts:i,loading:a,errorMessage:o,pendingAccountId:s,onPick:c,onClose:l,onInviteInstead:u}){let[d,f]=(0,K.useState)(``);(0,K.useEffect)(()=>{e&&f(``)},[e]);let p=(0,K.useMemo)(()=>Xe(i??[],d),[i,d]),m=s!=null;return(0,Y.jsx)(S.Root,{open:e,onOpenChange:e=>!e&&l(),children:(0,Y.jsxs)(S.Content,{size:`sm`,children:[(0,Y.jsxs)(S.Header,{children:[(0,Y.jsxs)(S.Title,{children:[`Link `,t,` account`]}),(0,Y.jsxs)(S.Description,{children:[`Search your `,t,` workspace and pick`,` `,(0,Y.jsx)(`span`,{className:`text-[color:var(--content-default)]`,children:r}),`’s account.`]})]}),(0,Y.jsxs)(S.Body,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(x,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:`Search by name or @handle`,"aria-label":`Search ${t} workspace accounts`,leftIcon:(0,Y.jsx)(A,{className:`h-4 w-4`}),fullWidth:!0}),o?(0,Y.jsx)(`p`,{className:`text-body-small-default text-[color:var(--content-negative)]`,children:o}):null,(0,Y.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:a?(0,Y.jsx)(`p`,{className:`py-4 text-center text-body-small-default text-[color:var(--content-tertiary)]`,children:`Loading workspace members…`}):p.length===0?(0,Y.jsx)(`p`,{className:`py-4 text-center text-body-small-default text-[color:var(--content-tertiary)]`,children:(i?.length??0)===0?`No workspace members found.`:`No members match.`}):(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:p.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c(e),disabled:m,className:`flex w-full cursor-pointer items-center gap-3 rounded-md px-2 py-2 text-left transition-colors hover:bg-[var(--surface-overlay)] disabled:cursor-not-allowed disabled:opacity-60`,children:[e.imageUrl?(0,Y.jsx)(`img`,{src:e.imageUrl,alt:``,className:`h-8 w-8 shrink-0 rounded-full`}):(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[var(--tag-bg-neutral)] text-body-small-emphasised text-[color:var(--content-secondary)]`,children:Ze(e.displayName)}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-body-medium-default text-[color:var(--content-default)]`,children:e.displayName}),(0,Y.jsxs)(`span`,{className:`truncate text-body-small-default text-[color:var(--content-tertiary)]`,children:[`@`,e.username]})]}),s===e.id?(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:`Linking…`}):null]})},e.id))})})]}),(0,Y.jsxs)(S.Footer,{className:`items-center justify-between gap-3 border-t border-[var(--border-base)]`,children:[(0,Y.jsxs)(`p`,{className:`text-body-small-default text-[color:var(--content-tertiary)]`,children:[`Picking marks this account as`,` `,(0,Y.jsx)(`span`,{className:`text-[color:var(--content-secondary)]`,children:`guardian-linked`}),` `,`— you vouch for the identity, no handshake needed.`]}),u?(0,Y.jsxs)(n,{variant:`link`,className:`shrink-0`,onClick:u,disabled:m,children:[`Or send an invite instead`,(0,Y.jsx)(M,{className:`h-3.5 w-3.5`})]}):null]})]})})}function $e(e){let t={};for(let n of e)F(n.channelType)&&(t[n.channelType]=n.policy===`trusted_contacts`?{source:`global-default`}:{source:`channel-default`,channel:n.channelType});return t}function et(e){return $e(de(e))}function tt(e){let t=ae.use.channelTrustFloors(),n=me(),r=t&&n,i=c({...B({path:{assistant_id:e}}),enabled:r,select:et});return r?i.data:void 0}function nt({assistantId:e,channelType:t,contact:n,onLinked:r}){let[i,a]=(0,K.useState)(!1),o=l({mutationFn:n=>G(e,n.contact,{type:t,address:n.account.id}),onSuccess:(e,t)=>{a(!1),w.success(`Linked as @${t.account.username}`),r()}}),s=(0,K.useCallback)(()=>{o.reset(),a(!0)},[o]),c=(0,K.useCallback)(()=>{o.isPending||(o.reset(),a(!1))},[o]),u=(0,K.useCallback)(e=>{!n||o.isPending||o.mutate({contact:n,account:e})},[n,o]);return{channelType:t,dialogOpen:i,open:s,close:c,linkErrorMessage:o.error instanceof Error?o.error.message:o.error?`Failed to link account`:null,pendingAccountId:o.isPending?o.variables.account.id:null,pick:u}}var rt=[{id:`slack`,label:`Slack`,subtitle:`Message your assistant from Slack`,icon:`hash`,supportsVerification:!0,setupMessages:{guardian:`I'd like to verify my identity as your guardian on Slack. Can you help me set that up?`,contact:`I'd like to verify a contact's Slack identity. Can you walk me through it?`}},{id:`telegram`,label:`Telegram`,subtitle:`Message your assistant from Telegram`,icon:`send`,supportsVerification:!0,setupMessages:{guardian:`I'd like to verify my identity as your guardian on Telegram. Can you help me set that up?`,contact:`I'd like to verify a contact's Telegram identity. Can you walk me through it?`}},{id:`phone`,label:`Phone Calling`,subtitle:`Call or text your assistant via phone`,icon:`phone`,supportsVerification:!0,setupMessages:{guardian:`I'd like to verify my identity as your guardian for phone calls. Can you help me set that up?`,contact:`I'd like to verify a contact's phone number. Can you help me set that up?`}}],it=[];function at({assistantId:e,onStartSetupConversation:t}){let n=ae.use.a2aChannel(),a=re.use.name(),o=s(),[u]=r(),d=u.get(`setup`),f=d&&F(d)?d:null,[p,m]=(0,K.useState)({kind:`assistant`}),h=he(e),[g,_]=(0,K.useState)(!1),[v,y]=(0,K.useState)(!1),b=ue(a),x=(0,K.useMemo)(()=>({path:{assistant_id:e}}),[e]),S=k(x),C=c({...ne(x),enabled:!!e,select:e=>e.contacts}),T=fe({assistantId:e,onStartSetupConversation:t}),A=tt(e),j=c({...O({path:{assistant_id:e}}),enabled:!!e,queryFn:async({signal:t})=>{let{data:n,error:r,response:i}=await E({path:{assistant_id:e},signal:t,throwOnError:!1});if(!i||i.status===404)return{channels:rt};if(!i.ok)throw r??Error(`Failed to fetch channel availability`);return n},select:e=>e.channels}).data??it,M=C.data,N=(0,K.useMemo)(()=>M?.find(e=>e.role===`guardian`)??null,[M]),oe=(0,K.useMemo)(()=>M?.filter(e=>e.role!==`guardian`)??[],[M]),P=(0,K.useMemo)(()=>p.kind===`contact`?M?.find(e=>e.id===p.contactId)??null:null,[M,p]),I=(0,K.useMemo)(()=>!M||!P?[]:M.filter(e=>e.id!==P.id&&e.role!==`guardian`),[M,P]),L=I.length>0,se=(0,K.useRef)(!!f);(0,K.useEffect)(()=>{se.current||N&&(se.current=!0,m({kind:`contact`,contactId:N.id}))},[N]);let R=(0,K.useCallback)(()=>o.invalidateQueries({queryKey:S}),[o,S]),z=l({mutationFn:()=>ye(e,{displayName:`New Contact`}),onMutate:async()=>{await o.cancelQueries({queryKey:S})},onSuccess:e=>{D(o,x,t=>t?{...t,contacts:[...t.contacts,e]}:void 0),m({kind:`contact`,contactId:e.id})},onError:W(`Failed to create contact`),onSettled:()=>R()}),B=l({mutationFn:t=>be(e,t),onSuccess:(e,t)=>{D(o,x,e=>e?{...e,contacts:e.contacts.filter(e=>e.id!==t)}:void 0),m({kind:`assistant`})},onError:W(`Failed to delete contact`),onSettled:()=>R()}),V=l({mutationFn:({contactId:t,patch:n})=>ye(e,{id:t,displayName:n.displayName,notes:n.notes}),onSuccess:e=>{D(o,x,t=>t?{...t,contacts:t.contacts.map(t=>t.id===e.id?e:t)}:void 0)},onError:W(`Failed to save contact`),onSettled:()=>R()}),H=ee({onMutate:async()=>{await o.cancelQueries({queryKey:S})},onSuccess:(e,t)=>{let n=e.contact,r=t.body.mergeId;n&&(D(o,x,e=>e?{...e,contacts:e.contacts.filter(e=>e.id!==r).map(e=>e.id===n.id?n:e)}:void 0),m({kind:`contact`,contactId:n.id})),y(!1),w.success(`Contacts merged`)},onSettled:()=>R()}),le=(0,K.useCallback)(e=>{m(e),_(!1),y(!1),H.reset()},[H]),de=(0,K.useCallback)(()=>{H.reset(),y(!0)},[H]),me=(0,K.useCallback)(()=>{H.isPending||(y(!1),H.reset())},[H]),U=te({onSuccess:()=>R()}),G=(0,K.useCallback)((t,n)=>{U.mutate({path:{assistant_id:e,contactChannelId:t},body:{status:`revoked`}})},[U,e]),xe=(0,K.useCallback)(()=>{z.isPending||z.mutate()},[z]),Se=(0,K.useCallback)(e=>{if(!t)return;let n=j.find(t=>t.id===e)?.setupMessages.contact;n&&t(n)},[j,t]),Ce=(0,K.useCallback)(e=>{if(!t)return;let n=j.find(t=>t.id===e)?.setupMessages.guardian;n&&t(n)},[j,t]),q=l({mutationFn:t=>ve(e,t.channelId),onSuccess:()=>R(),onError:W(`Failed to verify channel`)}),J=(0,K.useCallback)(e=>{if(!P)return;let t=P.channels.find(t=>t.type===e&&t.status!==`revoked`);t&&q.mutate({channelId:t.id})},[P,q]),X=nt({assistantId:e,channelType:`slack`,contact:P?{id:P.id,displayName:P.displayName}:null,onLinked:R}),Z=c({...ce(e),enabled:!!e&&X.dialogOpen,select:e=>e.users}),Q=T.channels.some(e=>e.key===`slack`&&e.status===`ready`),we=(0,K.useCallback)(e=>{e===X.channelType&&X.open()},[X]),Ee=B.isPending?B.variables:null,$=(0,K.useMemo)(()=>P?V.isPending&&V.variables?.contactId===P.id?{...P,displayName:V.variables.patch.displayName,notes:V.variables.patch.notes}:P:null,[P,V.isPending,V.variables]);if(f)return(0,Y.jsx)(i,{to:`${ie.channels}?setup=${f}`,replace:!0});let De={loading:C.isLoading,assistantName:b,guardian:N?{id:N.id,displayName:N.displayName.startsWith(`vellum-principal-`)?``:N.displayName,role:N.role,channelTypes:lt(N.channels,n)}:null,regularContacts:oe.filter(e=>e.id!==Ee).map(e=>({id:e.id,displayName:e.displayName,role:e.role,contactType:e.contactType,channelTypes:lt(e.channels,n),verified:ct(e.channels)})),selection:p,onAddContact:xe,addingContact:z.isPending};return(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden sm:flex-row sm:gap-6`,children:[(0,Y.jsx)(`div`,{className:`flex items-center sm:hidden`,children:(0,Y.jsx)(ge,{onClick:()=>_(!0)})}),(0,Y.jsx)(_e,{open:g,onClose:()=>_(!1),title:`Contacts`,children:(0,Y.jsx)(Ke,{...De,onSelect:le})}),(0,Y.jsx)(`aside`,{className:`hidden min-h-0 w-[320px] shrink-0 overflow-y-auto self-stretch sm:block`,children:(0,Y.jsx)(Ke,{...De,onSelect:le})}),(0,Y.jsx)(`section`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto`,children:p.kind===`assistant`||p.kind===`contact`&&p.contactId===Ee?(0,Y.jsx)(Te,{assistantName:b,channels:T.channels,pendingChannelKey:T.pendingChannelKey,onConnect:T.onSetup,onDisconnect:T.onDisconnect}):$?$.role===`guardian`?(0,Y.jsx)(Je,{contact:$,savePending:V.isPending,verifyPending:q.isPending,mergePending:H.isPending,canMerge:L,availableChannels:j,a2aEnabled:n,onSave:e=>{V.mutate({contactId:$.id,patch:e})},onMerge:de,onSetupChannel:t?Ce:void 0,onVerifyChannel:J,onRevokeChannel:G,onGenerateInviteLink:n?h.open:void 0}):(0,Y.jsx)(Ne,{contact:$,savePending:V.isPending,deletePending:B.isPending,verifyPending:q.isPending,mergePending:H.isPending,canMerge:L,availableChannels:j,a2aEnabled:n,channelProvenance:A,onSave:e=>{V.mutate({contactId:$.id,patch:e})},onDelete:()=>{B.mutate($.id)},onMerge:de,onSetupChannel:t?Se:void 0,onVerifyChannel:J,onRevokeChannel:G,onLinkAccount:Q?we:void 0}):(0,Y.jsx)(ot,{})}),P?(0,Y.jsx)(Fe,{open:v,survivor:P,candidates:I,pending:H.isPending,errorMessage:H.error instanceof Error?H.error.message:H.error?`Failed to merge contacts`:null,onMerge:t=>H.mutate({path:{assistant_id:e},body:{keepId:P.id,mergeId:t}}),onClose:me}):null,(0,Y.jsx)(Qe,{open:X.dialogOpen,channelLabel:`Slack`,contactName:P?.displayName??``,accounts:Z.data,loading:Z.isLoading,errorMessage:Z.isError?`Couldn’t load the workspace roster. Check the Slack connection and try again.`:X.linkErrorMessage,pendingAccountId:X.pendingAccountId,onPick:X.pick,onClose:X.close,onInviteInstead:t?()=>{X.close(),Se(X.channelType)}:void 0}),(0,Y.jsx)(pe,{open:h.isOpen,assistantId:e,onClose:h.close})]})}function ot(){return(0,Y.jsx)(`div`,{className:`flex h-full items-center justify-center py-16`,children:(0,Y.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a contact`})})}var st={slack:`Slack`,telegram:`Telegram`,phone:`Phone`,email:`Email`,whatsapp:`WhatsApp`,a2a:`A2A`};function ct(e){return e.some(e=>e.status!==`revoked`&&(e.type===`a2a`||J(e)))}function lt(e,t){let n=new Set,r=[];for(let i of e){if(i.status===`revoked`)continue;let e=i.type.toLowerCase();n.has(e)||e===`a2a`&&!t||(n.add(e),r.push(st[e]??i.type))}return r}function ut(){let e=o(),t=H();return(0,Y.jsx)(at,{assistantId:t,onStartSetupConversation:t=>{V(e,{prompt:t})}},t)}export{ut as ContactsPageRoute};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,r as n,s as r}from"./device-settings-DXp9L4iB.js";import{t as i}from"./capture-error-BGD3-GQf.js";import{t as a}from"./react-DJZBPgpf.js";import{t as o}from"./button-BQVYX8n_.js";import{m as s,t as c,u as l}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as u}from"./QueryClientProvider-DKhXIxGb.js";import{t as d}from"./useQuery-B45lW1Kk.js";import{t as f}from"./useMutation-Lj4VunQV.js";import{t as p}from"./jsx-runtime-CVSDxk6A.js";import{t as m}from"./card-D8zyWtZh.js";import{t as h}from"./createLucideIcon-Bjb-Kuq7.js";import{t as g}from"./bell-BbESwsZk.js";import{t as _}from"./check-wF3S-AV4.js";import{t as v}from"./chevron-down-DpYf9Gwq.js";import{t as y}from"./circle-alert-CTnM6GCb.js";import{t as b}from"./circle-check-DqvTjWle.js";import{o as x}from"./list-row-9xgQystQ.js";import{t as S}from"./hard-drive-BxDRcYId.js";import{t as C}from"./loader-circle-D57RZgLH.js";import{t as w}from"./monitor-DTDBOcSy.js";import{t as T}from"./moon-Ci1LuSVx.js";import{t as E}from"./refresh-cw-CMEIZvPt.js";import{a as D,c as O,o as k,r as A,s as j,t as M}from"./resize-errors-B4T7-3eS.js";import{t as N}from"./sparkles-DDIsk_nZ.js";import{t as P}from"./triangle-alert-DXEpFOj_.js";import{t as F}from"./x-CswtfvgS.js";import{t as I}from"./notice-BylgS5W_.js";import{t as ee}from"./progress-bar-Bqv7D4mZ.js";import{M as L,N as te,i as R,j as ne,n as re}from"./src-CDdn26Yb.js";import{t as ie}from"./tag-B6WeUtBW.js";import{t as z}from"./input-ZpyYt_a0.js";import{t as ae}from"./toggle-QSEiPr3k.js";import{t as B}from"./modal-BtcwNEBj.js";import{n as V}from"./toast-ZoZVyeDI.js";import{t as H}from"./confirm-dialog-CCrDkChx.js";import{t as oe}from"./dropdown-BMNSccmo.js";import{C as U,D as se,S as ce,_ as le,c as ue,f as de,g as fe,i as pe,k as me,l as he,p as ge,r as _e}from"./local-mode-hyYI6_OH.js";import{t as W}from"./is-electron-DBOtwp5h.js";import{n as ve}from"./resolved-assistants-store-DdnJoLGS.js";import{r as ye,t as be}from"./semver-CRR7tMUr.js";import{n as xe,r as Se,t as Ce}from"./api-errors-CDe82ZvY.js";import{E as we,O as Te,_ as Ee,a as De,h as Oe,l as ke,m as Ae,n as je,v as Me,w as Ne,x as Pe,y as Fe}from"./auth-store-B6EXnaee.js";import{t as G}from"./client.gen-DZZugzSk.js";import{C as Ie,H as Le,M as Re,Rt as ze,T as Be,X as Ve,Z as He,j as Ue}from"./sdk.gen-BJsTUGAk.js";import{a as We,o as Ge}from"./api-BBMl4mW3.js";import{c as K}from"./routes-XPLb07Av.js";import{a as Ke,r as qe}from"./platform-detection-1awANa55.js";import{t as q}from"./client-feature-flag-store-DeUwlUsr.js";import{n as Je,r as Ye,t as Xe}from"./theme-preferences-DXNlsaIE.js";import{A as Ze,At as Qe,D as $e,E as et,F as tt,M as nt,Mt as rt,Nt as it,Ot as at,P as ot,T as st,Tt as ct,bt as lt,c as ut,it as dt,j as ft,jt as pt,k as mt,kt as ht,nt as gt,v as _t,w as vt,wt as yt}from"./react-query.gen-BXPoln4i.js";import{t as bt}from"./assistant-feature-flag-store-BpbbAIKZ.js";import{t as xt}from"./pointer-Cdz7NGHe.js";import{t as St}from"./proxy-BzlH_XAe.js";import{t as Ct}from"./AnimatePresence-C8APSgIu.js";import{t as wt}from"./use-reduced-motion-CcGT6CHV.js";import{Fn as Tt,In as Et,Ir as Dt,Ji as Ot,N as kt,Nn as At,P as jt,Pn as Mt,Qt as Nt,U as J,Wi as Pt,Xn as Ft,Yn as It,di as Lt,ea as Rt,fi as zt,j as Bt,pi as Vt,ta as Ht,wa as Ut,wt as Wt}from"./index-CZVGv7Cn.js";import{t as Gt}from"./use-active-assistant-id-9rGx8kT9.js";import{t as Y}from"./detail-card-CA8lPa5K.js";import{t as Kt}from"./app-info-Dwct98Bb.js";import{t as qt}from"./environment-store-D_Bc9wnl.js";import{a as Jt,i as Yt,n as Xt,r as Zt,t as Qt}from"./assistant-status-panel-DDvWvhN1.js";import{t as $t}from"./settings-divider-Dk_uJxp_.js";var en=h(`fingerprint-pattern`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),tn=h(`vibrate`,[[`path`,{d:`m2 8 2 2-2 2 2 2-2 2`,key:`sv1b1`}],[`path`,{d:`m22 8-2 2 2 2-2 2 2 2`,key:`101i4y`}],[`rect`,{width:`8`,height:`14`,x:`8`,y:`5`,rx:`1`,key:`1oyrl4`}]]),X=e(a(),1),nn=Ae,rn=`Please choose a different handle.`;async function an(e,t){let{data:n,error:r,response:i}=await Re({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:Se(r,void 0,`Failed to save handle.`)??`Failed to save handle.`};if(i.ok&&n)return{kind:`ok`,data:n};if(i.status===409){let{message:e}=Fe(r,`handle`,nn.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=Fe(r,`handle`,rn);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:Se(r,i,`Failed to save handle.`)}}async function on(e,t,n){let{data:r,error:i,response:a}=await Ie({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(xe(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new Ce(a.status,a.status===429?`Too many checks — try again in a moment.`:Se(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function sn(e){return/\d{2,}$/.test(e)}var Z=p(),cn=300,ln=1400;function un({initialHandle:e,inputLabel:t,helperText:n,idleHelperText:r,checkAvailable:i,save:a,onSaved:s,saveSuccessToast:c,fieldId:l}){let[u,d]=(0,X.useState)(e),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(!1),[g,v]=(0,X.useState)(`idle`),[b,x]=(0,X.useState)(null),S=wt(),w=(0,X.useRef)(null),T=(0,X.useMemo)(()=>u.trim().toLowerCase(),[u]),E=T===e.toLowerCase();(0,X.useEffect)(()=>{if(E||T.length===0){h(!1),w.current?.abort();return}let e=new AbortController;w.current?.abort(),w.current=e,h(!0);let t=window.setTimeout(async()=>{try{let t=await i(T,e.signal);e.signal.aborted||p(t)}catch(t){e.signal.aborted||x(t instanceof Error?t.message:`Couldn't check availability.`)}finally{e.signal.aborted||h(!1)}},cn);return()=>{window.clearTimeout(t),e.abort()}},[T,E,i]);let D=(()=>{if(b)return b;if(f&&!f.available){let e=f.code;return f.message??(e?nn[e]:`Please choose a different handle.`)}return null})(),O=D?n:E?r??null:m?`Checking availability…`:f?.available?`Available.`:null,k=!E&&!m&&f?.available!==!1&&g!==`saving`,A=(0,X.useCallback)(async()=>{if(!k)return;v(`saving`),x(null);let e=await a(T);if(e.kind===`ok`){v(`saved`),s(e.data),V.success(c),window.setTimeout(()=>v(`idle`),ln);return}if(e.kind===`taken`){v(`idle`),p({available:!1,code:`taken`,message:e.message});return}if(e.kind===`invalid`){v(`idle`),p({available:!1,code:e.code,message:e.message});return}v(`error`),x(e.message),V.error(e.message)},[k,T,s,a,c]),j=(()=>{if(E&&u.length>0||u.length===0)return null;let e=m?`checking`:f?.available?`available`:f?.available===!1?`invalid`:null;return e?(0,Z.jsx)(Ct,{mode:`wait`,initial:!1,children:(0,Z.jsxs)(St.span,{initial:S?!1:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:S?void 0:{opacity:0,scale:.85},transition:{duration:.14,ease:`easeOut`},className:`flex items-center`,"aria-hidden":e!==`available`&&e!==`invalid`,children:[e===`checking`&&(0,Z.jsx)(C,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,Z.jsx)(_,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":`Available`}),e===`invalid`&&(0,Z.jsx)(y,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":`Not available`})]},e)}):null})(),M=(()=>{switch(g){case`saving`:return(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(C,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),`Saving…`]});case`saved`:return(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(_,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Saved`]});default:return`Save`}})();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(z,{label:t,value:u,onChange:e=>{d(e.target.value.replace(/\s+/g,``)),p(null),x(null)},autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,maxLength:30,leftIcon:(0,Z.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),rightIcon:j,errorText:D??void 0,helperText:O??void 0,"aria-invalid":!!D,fullWidth:!0,"data-testid":`${l}-input`}),(!E||g!==`idle`)&&(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(o,{variant:`primary`,size:`compact`,onClick:A,disabled:!k,"aria-live":`polite`,"data-testid":`${l}-save`,children:M})})]})}function dn({initial:e,onSaved:t}){let n=je.use.refreshSession(),r=sn(e.username)?`Your handle was auto-generated at signup — pick one you like.`:void 0,i=(0,X.useCallback)(async e=>await Me({username:e}),[]),a=(0,X.useCallback)((e,t)=>Oe(e,t),[]),o=(0,X.useCallback)(e=>{t(e),n()},[t,n]);return(0,Z.jsx)(un,{initialHandle:e.username,inputLabel:`User handle`,helperText:`Lowercase letters, digits, hyphens, and underscores. 3–30 characters.`,idleHelperText:r,checkAvailable:a,save:i,onSaved:o,saveSuccessToast:`Profile updated.`,fieldId:`user-handle`})}function fn({assistant:e,onSaved:t}){let n=e.handle??``,r=d({...ut({path:{assistant_id:e.id}})}).data?.results?.[0],i=!!r&&r.subdomain.toLowerCase()===n.toLowerCase(),a=n.length===0?`Your assistant doesn't have a handle yet — claim one to make it mentionable.`:void 0,o=(0,X.useCallback)(async t=>await an(e.id,t),[e.id]),s=(0,X.useCallback)((t,n)=>on(e.id,t,n),[e.id]);return i?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(z,{label:`Assistant handle`,value:n,readOnly:!0,disabled:!0,leftIcon:(0,Z.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),fullWidth:!0,"data-testid":`assistant-handle-input`}),(0,Z.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Your assistant's handle is locked because it's used as its email subdomain. To change it,`,` `,(0,Z.jsx)(c,{to:`${K.settings.ai}?release=1#email`,className:`text-[var(--content-link)] underline hover:text-[var(--content-link-hover)]`,children:`release the subdomain`}),` `,`first.`]})]}):(0,Z.jsx)(un,{initialHandle:n,inputLabel:`Assistant handle`,helperText:`Lowercase letters, digits, hyphens, and underscores. 3–30 characters.`,idleHelperText:a,checkAvailable:s,save:o,onSaved:t,saveSuccessToast:`Assistant handle updated.`,fieldId:`assistant-handle`})}function pn(){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":!0,"aria-live":`polite`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-3 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Z.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Z.jsx)(`div`,{className:`h-3 w-72 animate-pulse rounded bg-[var(--surface-muted)]`})]}),(0,Z.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`h-3 w-60 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Z.jsx)(`div`,{className:`h-7 w-16 animate-pulse rounded-md bg-[var(--surface-muted)]`})]}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Loading your profile…`})]})}function mn(){return(0,Z.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`})}function hn({assistant:e,showHandles:t=!0,children:n}={}){let r=je.use.user?.()?.email??null;return(0,Z.jsx)(Y,{title:`Profile`,subtitle:`Manage your account details and preferences.`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[r&&(0,Z.jsx)(`div`,{className:`max-w-[420px]`,children:(0,Z.jsx)(z,{label:`Email`,value:r,disabled:!0,readOnly:!0})}),t&&(0,Z.jsxs)(Z.Fragment,{children:[r&&(0,Z.jsx)(mn,{}),(0,Z.jsx)(gn,{assistant:e})]}),n!=null&&(0,Z.jsxs)(Z.Fragment,{children:[(r||t)&&(0,Z.jsx)(mn,{}),n]})]})})}function gn({assistant:e}){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(null),a=wt(),[o,s]=(0,X.useState)(e??null);return(0,X.useEffect)(()=>{s(e??null)},[e]),(0,X.useEffect)(()=>{let e=!1;return Ee().then(t=>{e||n(t)}).catch(t=>{e||i(t instanceof Error?t.message:`Failed to load profile.`)}),()=>{e=!0}},[]),r?(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:r}):t?(0,Z.jsxs)(St.div,{initial:a?!1:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.22,ease:`easeOut`},className:`flex flex-col gap-6`,children:[(0,Z.jsx)(dn,{initial:t,onSaved:n}),o&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Z.jsx)(fn,{assistant:o,onSaved:s})]})]}):(0,Z.jsx)(pn,{})}var _n=_t({query:{hosting:`platform`}});function vn(){let e=Gt(),t=d(_n),n=t.data?.results??[];return t.isPending||n.length<2?null:(0,Z.jsx)(Y,{title:`Switch Assistant`,subtitle:`Choose which assistant is active for this account.`,children:(0,Z.jsx)(`div`,{className:`space-y-2`,children:n.map(t=>{let n=t.id===e;return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-lg border px-4 py-3 ${n?`border-[var(--border-focus)] bg-[var(--surface-lift)]`:`border-[var(--border-base)] bg-[var(--surface-default)]`}`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(w,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:t.name||`Unnamed`}),t.status!==`active`&&(0,Z.jsx)(ie,{tone:`warning`,children:t.status})]})})]}),(0,Z.jsx)(`div`,{className:`shrink-0`,children:n?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-body-small-default text-[var(--system-positive-default)]`,children:[(0,Z.jsx)(_,{className:`h-4 w-4`}),`Active`]}):(0,Z.jsx)(o,{variant:`outlined`,size:`compact`,disabled:t.status!==`active`,onClick:()=>{Te(t.id),V.success(`Switched active assistant.`)},children:`Switch`})})]},t.id)})})})}var yn=[{label:`Never`,seconds:0},{label:`5 min`,seconds:300,devOnly:!0},{label:`10 min`,seconds:600,devOnly:!0},{label:`1 hour`,seconds:3600},{label:`3 hours`,seconds:10800},{label:`1 day`,seconds:86400},{label:`3 days`,seconds:259200},{label:`7 days`,seconds:604800},{label:`14 days`,seconds:1209600},{label:`30 days`,seconds:2592e3}];function bn(e){if(e===0)return`Never (sleep disabled)`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600);if(t>0&&n>0)return`${t}d ${n}h`;if(t>0)return`${t} day${t===1?``:`s`}`;if(n>0)return`${n} hour${n===1?``:`s`}`;let r=Math.floor(e/60);return r>0?`${r} minute${r===1?``:`s`}`:`${e}s`}function xn({assistantId:e}){let t=u(),n=qt.use.isNonProduction(),r=(0,X.useMemo)(()=>yn.filter(e=>!e.devOnly||n),[n]),{data:i,isLoading:a,isError:s}=d(ft({path:{id:e}})),c=(0,X.useMemo)(()=>i?.idle_timeout_seconds??259200,[i]),[l,f]=(0,X.useState)(null),p=l??c,m=l!==null,h=ct({onSuccess:()=>{V.success(`Sleep policy saved.`),f(null),t.invalidateQueries({queryKey:nt({path:{id:e}})})},onError:()=>{V.error(`Failed to save sleep policy. Please try again.`)}});return a?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(C,{className:`h-4 w-4 animate-spin`}),`Loading sleep settings...`]}):s?(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:`Failed to load sleep policy. Refresh the page to try again.`}):(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:`Idle timeout`}),(0,Z.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`How long the assistant can be idle before it is put to sleep. "Never" disables idle sleep entirely.`}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:r.map(e=>(0,Z.jsx)(o,{variant:`outlined`,active:p===e.seconds,onClick:()=>f(e.seconds),children:e.label},e.seconds))}),(0,Z.jsxs)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:[`Current: `,bn(p)]})]}),m&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(o,{variant:`primary`,leftIcon:h.isPending?(0,Z.jsx)(C,{className:`animate-spin`}):void 0,onClick:()=>h.mutate({path:{id:e},body:{idle_timeout_seconds:p}}),disabled:h.isPending,children:`Save`}),(0,Z.jsx)(o,{variant:`outlined`,onClick:()=>f(null),disabled:h.isPending,children:`Cancel`})]})]})}function Sn(e,t,n){let r=[e.version];return e.version===n&&r.push(`(latest)`),t&&e.version===t&&r.push(`(current)`),r.join(` `)}var Cn=3e3;function wn({version:e,assistantId:t}){let{onTap:n,message:r}=Yt(t);return(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`block min-w-0 break-all text-left text-body-medium-lighter text-[var(--content-default)]`,onClick:n,children:e??`—`}),r&&(0,Z.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-accent)]`,children:r})]})}function Tn({assistantId:e,currentVersion:t,releaseChannel:n,onUpgradeComplete:r}){let i=bt.use.rollbackEnabled(),a=q.use.previewChannel(),s=u(),c=Mt(n,a),l=c===`preview`,[p,m]=(0,X.useState)(!1),h=(0,X.useRef)(null),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[S,w]=(0,X.useState)(null),T=e=>e&&h.current&&e===h.current?(queueMicrotask(()=>{w(b?`Successfully rolled back to version ${h.current}.`:`Successfully updated to version ${h.current}.`),m(!1),h.current=null,_(null),V.success(b?`Rollback complete — assistant is healthy.`:`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),r?.()}),!1):Cn;d({...mt({path:{id:e}}),refetchInterval:p?e=>T(e.state.data?.current_release_version):!1});let{data:D,isLoading:O}=d(lt({query:{channel:c}})),k=D?.find(e=>e.is_stable!==!1)??D?.[0],A=g??k?.version??null,j=(0,X.useMemo)(()=>{if(!i||!A||!t)return!1;let e=ye(A),n=ye(t);return!e||!n?!1:be(e,n)<0},[i,A,t]),M=(0,X.useMemo)(()=>{if(!A)return!1;if(!t)return!0;let e=ye(A),n=ye(t);if(!e||!n)return A!==t;let r=be(e,n);return i?r!==0:r>0},[i,A,t]),N=f({mutationFn:async t=>{let{data:n}=await Ve({path:{id:e},body:t,throwOnError:!0});return n}}),P=f({mutationFn:async t=>{let{data:n}=await Le({path:{id:e},body:t,throwOnError:!0});return n}});return(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 md:grid md:grid-cols-[auto_minmax(0,1fr)] md:items-center md:gap-x-8 md:gap-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Z.jsx)(wn,{version:t,assistantId:e})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:l?`Preview release`:M?j?`Rollback to`:`Update to`:`Selected`}),(0,Z.jsx)(`span`,{className:`block min-w-0`,children:O?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(C,{className:`h-3 w-3 animate-spin`}),`Loading...`]}):D&&D.length>0?i?(0,Z.jsx)(oe,{value:A??``,onChange:e=>_(e===k?.version?null:e),disabled:p||N.isPending||P.isPending,options:D.map(e=>({value:e.version,label:Sn(e,t,k?.version)}))}):(0,Z.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:k?Sn(k,t,k.version):`—`}):`No releases available`})]})]}),(0,Z.jsx)(o,{variant:j?`outlined`:`primary`,className:`min-w-[160px]`,leftIcon:N.isPending||P.isPending||p?(0,Z.jsx)(C,{className:`animate-spin`}):(0,Z.jsx)(E,{}),onClick:()=>y(!0),disabled:!M||N.isPending||P.isPending||p||O||!D?.length,children:p?b?`Rolling back...`:`Updating...`:j?`Rollback`:l?`Update preview`:`Update`}),l&&(0,Z.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Using Preview releases.`,` `,(0,Z.jsx)(`a`,{href:`#preview-release-channel`,className:`text-[var(--primary-base)] underline-offset-2 hover:underline`,children:`Switch back to Stable`})]}),!M&&t&&A&&!O&&(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:S??`You are already on this version.`}),(0,Z.jsx)(H,{open:v,title:j?`Rollback assistant`:l?`Update preview release`:`Update assistant`,message:j?`Rollback to version ${A??`unknown`}? The assistant will be briefly unavailable.`:l?`Update to preview version ${A??`latest`}? The assistant will be briefly unavailable during the update.`:`Update to version ${A??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:j?`Rollback`:l?`Update preview`:`Update`,onConfirm:async()=>{y(!1),w(null);let t=g??void 0;try{if(j){let e=await P.mutateAsync({version:t});h.current=e.version??t??null,V.success(e.detail||`Rollback to ${t} initiated.`)}else{let e=await N.mutateAsync({version:t});if(e.detail?.includes(`Already on the latest`)){V.warning(e.detail);return}h.current=e.version??t??null,V.success(e.detail||`Update to ${e.version??t??`latest`} initiated.`)}x(j),m(!0),s.invalidateQueries({queryKey:Ze({path:{id:e}})})}catch{V.error(j?`Failed to trigger rollback. Please try again.`:`Failed to trigger update. Please try again.`)}},onCancel:()=>y(!1)})]})}function En({assistantId:e,currentVersion:t,onUpgradeComplete:n}){let[r,i]=(0,X.useState)(!1),[a,s]=(0,X.useState)(null),{data:c,isLoading:l}=d(lt({query:{stable:!0,limit:100}})),u=(0,X.useMemo)(()=>At(c),[c]),f=u?.version,p=t?Tt(t,f):!!f,m=Et({assistantId:e,targetVersion:f});return(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 md:grid md:grid-cols-[auto_minmax(0,1fr)] md:items-center md:gap-x-8 md:gap-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Z.jsx)(wn,{version:t,assistantId:e})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Update to`}),(0,Z.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:l?`Loading...`:f&&u?Sn(u,t,f):`No releases available`})]})]}),(0,Z.jsx)(o,{variant:`primary`,className:`min-w-[160px]`,leftIcon:m.isPending?(0,Z.jsx)(C,{className:`animate-spin`}):(0,Z.jsx)(E,{}),onClick:()=>i(!0),disabled:m.isPending||l||!f||!p,children:m.isPending?`Updating...`:f?`Update to ${f}`:`Update`}),a&&(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:a}),!a&&!p&&f&&!l&&(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:`You are already on this version.`}),(0,Z.jsx)(H,{open:r,title:`Update assistant`,message:`Update to version ${f??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:`Update`,onConfirm:async()=>{i(!1),s(null);try{let e=await m.upgrade();s(e.version?`Successfully updated to version ${e.version}.`:`Successfully updated to version ${f??`latest`}.`),V.success(`Update complete — assistant is healthy.`,{id:`runtime-upgrade-complete`,tone:`strong`}),n?.()}catch(e){V.error(e instanceof Error?e.message:`Failed to trigger update. Please try again.`)}},onCancel:()=>i(!1)})]})}function Dn(){let e=Vt({platformHostedOnly:!0}),t=zt(),n=je.use.user()?.id??null,r=je.use.logout(),[i,a]=(0,X.useState)(!1),s=at({onSuccess:async()=>{V.success(`Account deletion requested. You will be logged out shortly.`),ke(n),await r(),Dt(K.account.login)},onError:()=>{V.error(`Failed to request account deletion. Please try again.`)}}),c=e===`full`&&t;return(0,X.useEffect)(()=>{c&&i&&a(!1)},[c,i]),e===`gated`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Delete Account`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently delete your account and all associated data.`}),(0,Z.jsx)(`div`,{className:`mt-1`,children:e===`disabled`?(0,Z.jsx)(J,{children:`Log in to the Vellum platform to delete your account.`}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(o,{variant:`dangerOutline`,onClick:()=>a(!0),disabled:s.isPending||c,className:`self-start`,children:`Delete My Account`}),c&&(0,Z.jsx)(C,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})})]}),(0,Z.jsx)(H,{open:i,title:`Delete Account`,message:`This will permanently delete your account and all associated data. This action cannot be undone.`,confirmLabel:`Delete Account`,destructive:!0,onConfirm:()=>{if(c){a(!1);return}a(!1),s.mutate({})},onCancel:()=>a(!1)})]})}function On({title:e,subtitle:t,benefits:n,ctaLabel:r,ctaLeftIcon:i,onAction:a}){return(0,Z.jsx)(Y,{title:e,subtitle:t,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsx)(`ul`,{className:`space-y-3`,children:n.map(({icon:e,text:t})=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`},children:(0,Z.jsx)(e,{size:14,style:{color:`var(--content-secondary)`},"aria-hidden":!0})}),(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]},t))}),(0,Z.jsx)(o,{variant:`primary`,size:`regular`,leftIcon:i,onClick:a,className:`self-start`,children:r})]})})}function kn(){return Ke()?(0,Z.jsx)(On,{title:`Get the iOS App`,subtitle:`The Vellum iOS app gives you a native experience.`,benefits:[{icon:g,text:`Push notifications`},{icon:en,text:`Biometric login`},{icon:tn,text:`Native haptics`},{icon:Ot,text:`Home screen access`}],ctaLabel:`Download`,ctaLeftIcon:(0,Z.jsx)(Ot,{size:16}),onAction:()=>{kt(),Bt()}}):null}async function An(){if(!W())return[];let e=window.vellum;return e?.hotkeys?e.hotkeys.get():[]}async function jn(e,t){if(!W())return;let n=window.vellum;n?.hotkeys&&await n.hotkeys.set(e,t)}function Mn(e){if(!W())return()=>{};let t=window.vellum;return t?.hotkeys?t.hotkeys.onChange(e):()=>{}}var Nn={ArrowUp:`Up`,ArrowDown:`Down`,ArrowLeft:`Left`,ArrowRight:`Right`,Enter:`Return`,NumpadEnter:`Return`,Space:`Space`,Tab:`Tab`,Escape:`Escape`,Backspace:`Backspace`,Delete:`Delete`,Insert:`Insert`,Home:`Home`,End:`End`,PageUp:`PageUp`,PageDown:`PageDown`,Minus:`-`,Equal:`=`,BracketLeft:`[`,BracketRight:`]`,Backslash:`\\`,Semicolon:`;`,Quote:`'`,Backquote:"`",Comma:`,`,Period:`.`,Slash:`/`},Pn=new Set([`MetaLeft`,`MetaRight`,`ControlLeft`,`ControlRight`,`AltLeft`,`AltRight`,`ShiftLeft`,`ShiftRight`]),Fn=e=>{let t=e.code;return Pn.has(t)?null:/^Key[A-Z]$/.test(t)?t.slice(3):/^Digit[0-9]$/.test(t)?t.slice(5):/^Numpad[0-9]$/.test(t)?`num${t.slice(6)}`:/^F[0-9]{1,2}$/.test(t)?t:Nn[t]??null},In=e=>{let t=Fn(e);if(t===null)return null;let n=[];return e.metaKey&&n.push(`CmdOrCtrl`),e.ctrlKey&&n.push(`Control`),e.altKey&&n.push(`Alt`),e.shiftKey&&n.push(`Shift`),[...n,t].join(`+`)},Ln=(e,t,n)=>n===``?null:e.find(e=>e.key!==t&&e.accelerator===n)??null,Rn=[{scope:`global`,title:`Global shortcuts`,description:`Work anywhere, even when Vellum is in the background.`},{scope:`menu`,title:`App shortcuts`,description:`Work while a Vellum window is focused.`}];function zn({hotkey:e,recording:t,conflictLabel:n,onStartRecording:r,onCancelRecording:i,onReset:a,onRemove:s}){let c=e.accelerator===``,l=e.override!==null;return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-body-medium-lighter text-[var(--content-default)]`,children:e.label}),n!==null&&(0,Z.jsxs)(`div`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:[`Already used by `,n]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,Z.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Recording… press a shortcut, or Esc to cancel`}):c?(0,Z.jsx)(`span`,{className:`text-body-small-default italic text-[var(--content-disabled)]`,children:`Disabled`}):(0,Z.jsx)(re,{accelerator:e.accelerator}),t?(0,Z.jsx)(o,{variant:`ghost`,size:`compact`,onClick:i,children:`Cancel`}):(0,Z.jsx)(o,{variant:`outlined`,size:`compact`,onClick:r,"aria-label":`Record shortcut for ${e.label}`,children:`Record`}),(0,Z.jsx)(o,{variant:`ghost`,size:`compact`,disabled:!l,leftIcon:(0,Z.jsx)(Rt,{className:`h-3.5 w-3.5`}),onClick:a,"aria-label":`Reset ${e.label} to default`}),(0,Z.jsx)(o,{variant:`ghost`,size:`compact`,disabled:c,leftIcon:(0,Z.jsx)(F,{className:`h-3.5 w-3.5`}),onClick:s,"aria-label":`Remove ${e.label} binding`})]})]})}function Bn(){let[e,t]=(0,X.useState)([]),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(null),o=(0,X.useCallback)(()=>{An().then(t)},[]);(0,X.useEffect)(()=>(o(),Mn(t)),[o]);let s=(0,X.useCallback)(()=>{r(null),a(null)},[]);(0,X.useEffect)(()=>{if(n===null)return;let t=t=>{if(t.preventDefault(),t.stopPropagation(),t.code===`Escape`){s();return}let r=In(t);if(r===null)return;let i=Ln(e,n,r);if(i!==null){a({key:n,label:i.label});return}jn(n,r).then(o),s()};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[n,e,o,s]);let c=(0,X.useCallback)(e=>{a(null),r(e)},[]),l=(0,X.useCallback)(t=>{let n=Ln(e,t,e.find(e=>e.key===t)?.defaultAccelerator??``);if(n!==null){r(null),a({key:t,label:n.label});return}s(),jn(t,null).then(o)},[e,o,s]),u=(0,X.useCallback)(e=>{s(),jn(e,``).then(o)},[o,s]),d=(0,X.useMemo)(()=>Rn.map(t=>({...t,commands:e.filter(e=>e.rebindable&&e.scope===t.scope)})).filter(e=>e.commands.length>0),[e]);return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[i!==null&&(0,Z.jsxs)(I,{tone:`warning`,children:[`That shortcut is already used by `,i.label,`.`,` `,n===null?`Remove or change that binding before resetting.`:`Pick a different combination, or press Esc to cancel.`]}),d.map(e=>(0,Z.jsxs)(m,{bordered:!0,children:[(0,Z.jsxs)(`div`,{className:`mb-2`,children:[(0,Z.jsx)(`div`,{className:`text-body-medium-emphasised text-[var(--content-default)]`,children:e.title}),(0,Z.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:e.description})]}),(0,Z.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.commands.map(e=>(0,Z.jsx)(zn,{hotkey:e,recording:n===e.key,conflictLabel:i!==null&&i.key===e.key?i.label:null,onStartRecording:()=>c(e.key),onCancelRecording:s,onReset:()=>l(e.key),onRemove:()=>u(e.key)},e.key))})]},e.scope))]})}async function Vn(){if(!W())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function Hn(e){if(!W())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function Un(){let e=q.use.velvet(),[t,n]=(0,X.useState)(()=>Je({velvetEnabled:e}));(0,X.useEffect)(()=>{n(Je({velvetEnabled:e}))},[e]),(0,X.useEffect)(()=>r(`theme`,()=>{n(Je({velvetEnabled:e}))}),[e]),(0,X.useEffect)(()=>{Xe(t)},[t]);let i=e=>{n(e),Ye(e),Xe(e)},a=[{value:`system`,label:`System`,icon:(0,Z.jsx)(w,{className:`h-4 w-4`})},{value:`light`,label:`Light`,icon:(0,Z.jsx)(Pt,{className:`h-4 w-4`})},{value:`dark`,label:`Dark`,icon:(0,Z.jsx)(T,{className:`h-4 w-4`})},...e?[{value:`velvet`,label:`Velvet`,icon:(0,Z.jsx)(Ut,{className:`h-4 w-4`})}]:[]];return(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Appearance`}),(0,Z.jsx)(`div`,{className:`mt-2 max-w-[360px]`,children:(0,Z.jsx)(ne,{ariaLabel:`Theme`,value:t,onChange:i,items:a})})]})}function Wn(){let e=jt.useValue();if(xt())return null;let t=qe()?`Cmd`:`Ctrl`;return(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Composer`}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(ae,{checked:e,onChange:jt.save,label:`Send with ${t}+Enter`,helperText:`When enabled, Enter inserts a new line and ${t}+Enter sends.`})})]})}function Gn(){let[e,t]=(0,X.useState)(!1);(0,X.useEffect)(()=>{Vn().then(t)},[]);let n=async e=>{t(e);try{await Hn(e)}catch{t(!e)}};return(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Launch at Login`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Automatically start Vellum when you log in to your Mac.`}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(ae,{checked:e,onChange:e=>void n(e),"aria-label":`Launch at Login`})})]})}function Kn({open:e,onClose:t}){return(0,Z.jsx)(B.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,Z.jsxs)(B.Content,{size:`lg`,children:[(0,Z.jsxs)(B.Header,{children:[(0,Z.jsx)(B.Title,{children:`Preferences`}),(0,Z.jsx)(B.Description,{children:`Customize shortcuts and how Vellum behaves on this device.`})]}),(0,Z.jsx)(B.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsx)(Un,{}),W()&&(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Keyboard Shortcuts`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Customize the shortcuts for Vellum's commands.`}),(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(Bn,{})})]}),(0,Z.jsx)(Wn,{}),W()&&(0,Z.jsx)(Gn,{})]})})]})})}function qn(e){return e===`preview`?`preview`:`stable`}function Jn(e){if(!e)return`Unknown`;let t=new Date(e);return Number.isNaN(t.getTime())?`Unknown`:t.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function Yn(e){return e.source_release_version?`Stable ${e.source_release_version}`:e.snapshot_name}function Xn(e){return e.filter(e=>e.ready_to_use)}function Zn(e){return e?.feature_enabled===!1}function Qn({assistantId:e,onComplete:t}){let n=q.use.previewChannel(),r=u(),[i,a]=(0,X.useState)(),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[p,m]=(0,X.useState)(`restore_backup`),[h,g]=(0,X.useState)(``),_=et({path:{assistant_id:e}}),y=$e({path:{assistant_id:e}}),b=Ze({path:{id:e}}),{data:x,isLoading:S,isError:w}=d({..._,enabled:n,retry:!1}),T=x?.preview_backups??[],E=(0,X.useMemo)(()=>Xn(T),[T]),D=E[0],O=E.find(e=>e.snapshot_name===h)??D,k=()=>{r.invalidateQueries({queryKey:y}),r.invalidateQueries({queryKey:b}),t?.()},A=f(vt()),j=f(st()),M=qn(x?.current_channel),N=A.isPending||j.isPending,P=N||Zn(x)||!x?.latest_preview_release,F=p===`restore_backup`&&!O;if((0,X.useEffect)(()=>{a(M===`preview`?`release-channel`:void 0)},[M]),!n)return null;let ee=x?.standard_upgrade_available??!1;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(R.Root,{type:`single`,collapsible:!0,value:i,onValueChange:e=>a(e||void 0),className:`mt-5 border-t border-[var(--border-base)] pt-5`,children:(0,Z.jsxs)(R.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,Z.jsxs)(R.Trigger,{className:`group justify-between gap-3`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`Release Channel`}),x&&(0,Z.jsx)(ie,{tone:M===`preview`?`warning`:`neutral`,children:M===`preview`?`Preview`:`Stable`})]}),(0,Z.jsx)(v,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Z.jsx)(R.Content,{children:(0,Z.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[S&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(C,{className:`h-4 w-4 animate-spin`}),`Loading release channel...`]}),w&&(0,Z.jsx)(I,{tone:`error`,title:`Could not load release channel status`,children:`Refresh this page before changing release channels.`}),x&&(0,Z.jsxs)(Z.Fragment,{children:[Zn(x)&&(0,Z.jsx)(I,{tone:`neutral`,title:`Preview channel is unavailable`,children:`The Preview channel is not enabled for this assistant.`}),M===`stable`?(0,Z.jsx)($n,{status:x,isChangingChannel:N,optInDisabled:P,onOptIn:()=>s(!0)}):(0,Z.jsx)(er,{status:x,isChangingChannel:N,onOptOut:()=>{let e=D;g(e?.snapshot_name??``),m(e?`restore_backup`:ee?`standard_upgrade`:`restore_backup`),l(!0)}})]})]})})]})}),(0,Z.jsx)(nr,{open:o,isPending:A.isPending,previewVersion:x?.latest_preview_release?.version,onConfirm:async()=>{try{let t=await A.mutateAsync({path:{assistant_id:e}});V.success(t.detail||`Preview channel enabled.`),s(!1),k()}catch(e){V.error(Se(e,void 0,`Could not enable Preview channel.`))}},onCancel:()=>s(!1)}),(0,Z.jsx)(rr,{open:c,backups:E,mode:p,selectedSnapshotName:O?.snapshot_name??``,isPending:j.isPending,restoreModeDisabled:F,standardUpgradeAvailable:ee,onModeChange:m,onSnapshotChange:g,onConfirm:async()=>{if(!F)try{let t=await j.mutateAsync({path:{assistant_id:e},body:p===`restore_backup`?{mode:`restore_backup`,snapshot_name:O?.snapshot_name}:{mode:`standard_upgrade`}});V.success(t.detail||`Stable channel enabled.`),l(!1),k()}catch(e){V.error(Se(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>l(!1)})]})}function $n({status:e,isChangingChannel:t,optInDisabled:n,onOptIn:r}){return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(tr,{status:e}),!e.latest_preview_release&&(0,Z.jsx)(I,{tone:`neutral`,title:`No Preview release is available`,children:`Stable remains the only available release channel.`}),(0,Z.jsx)(o,{variant:`outlined`,leftIcon:t?(0,Z.jsx)(C,{className:`animate-spin`}):(0,Z.jsx)(Ht,{}),disabled:n,onClick:r,children:`Opt in to Preview`})]})}function er({status:e,isChangingChannel:t,onOptOut:n}){return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(tr,{status:e}),(0,Z.jsx)(o,{variant:`outlined`,leftIcon:t?(0,Z.jsx)(C,{className:`animate-spin`}):(0,Z.jsx)(Rt,{}),disabled:t,onClick:n,children:`Switch back to Stable`})]})}function tr({status:e}){return(0,Z.jsxs)(`dl`,{className:`grid gap-3 text-body-medium-lighter sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Stable`}),(0,Z.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_stable_release?.version??`None`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Preview`}),(0,Z.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_preview_release?.version??`None`})]})]})}function nr({open:e,isPending:t,previewVersion:n,onConfirm:r,onCancel:i}){return(0,Z.jsx)(B.Root,{open:e,onOpenChange:e=>!e&&i(),children:(0,Z.jsxs)(B.Content,{size:`md`,hideCloseButton:t,children:[(0,Z.jsxs)(B.Header,{children:[(0,Z.jsx)(B.Title,{icon:P,children:`Opt in to Preview`}),(0,Z.jsx)(B.Description,{children:`Preview releases may be unstable. A 90-day safety backup is taken before the image changes.`})]}),(0,Z.jsx)(B.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(I,{tone:`warning`,title:`Data loss may occur when returning to Stable`,children:`Preview data may not be compatible with the Stable channel. The safety backup lets you restore the Stable-channel data that existed before opt-in.`}),(0,Z.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,Z.jsx)(`li`,{children:`Create and verify a Preview safety backup.`}),(0,Z.jsxs)(`li`,{children:[`Switch to Preview image `,n??`latest`,`.`]}),(0,Z.jsx)(`li`,{children:`Run the normal upgrade path and wait for health.`})]})]})}),(0,Z.jsxs)(B.Footer,{children:[(0,Z.jsx)(o,{variant:`outlined`,disabled:t,onClick:i,children:`Cancel`}),(0,Z.jsx)(o,{variant:`primary`,disabled:t,leftIcon:t?(0,Z.jsx)(C,{className:`animate-spin`}):(0,Z.jsx)(Ht,{}),onClick:r,children:t?`Switching...`:`Take Backup and Switch`})]})]})})}function rr({open:e,backups:t,mode:n,selectedSnapshotName:r,isPending:i,restoreModeDisabled:a,standardUpgradeAvailable:s,onModeChange:c,onSnapshotChange:l,onConfirm:u,onCancel:d}){return(0,Z.jsx)(B.Root,{open:e,onOpenChange:e=>!e&&d(),children:(0,Z.jsxs)(B.Content,{size:`md`,hideCloseButton:i,children:[(0,Z.jsxs)(B.Header,{children:[(0,Z.jsx)(B.Title,{icon:P,children:`Switch back to Stable`}),(0,Z.jsx)(B.Description,{children:`Choose how this assistant should leave the Preview channel.`})]}),(0,Z.jsx)(B.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(te,{value:n,onValueChange:c,disabled:i,"aria-label":`Stable channel return method`,children:[(0,Z.jsx)(L,{value:`restore_backup`,disabled:t.length===0,label:`Restore safety backup`,helperText:`Return to the Stable-channel data captured before Preview opt-in.`}),(0,Z.jsx)(L,{value:`standard_upgrade`,disabled:!s,label:`Switch to Stable without restoring backup`,helperText:s?`Keep the current data and directly switch to the Stable image.`:`Unavailable because the latest Stable release is older than this assistant's Preview release.`})]}),n===`restore_backup`&&t.length>0&&(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[`Safety backup`,(0,Z.jsx)(oe,{value:r,onChange:l,disabled:i,options:t.map(e=>({value:e.snapshot_name,label:`${Yn(e)} - ${Jn(e.created_at)}`}))})]}),n===`restore_backup`&&t.length===0&&!s&&(0,Z.jsx)(I,{tone:`error`,title:`Stable requires a safety backup`,children:`This Preview release is newer than the latest Stable release, so switching directly is blocked. Wait for a newer Stable release, or run Vellum Doctor if the safety backup is missing.`}),n===`standard_upgrade`&&(0,Z.jsx)(I,{tone:`error`,title:`Preview data may not survive this`,children:`Switching directly to the Stable image without restoring the safety backup may cause data loss or leave the assistant unusable if Preview data is incompatible with Stable.`})]})}),(0,Z.jsxs)(B.Footer,{children:[(0,Z.jsx)(o,{variant:`outlined`,disabled:i,onClick:d,children:`Cancel`}),(0,Z.jsx)(o,{variant:n===`standard_upgrade`?`danger`:`primary`,disabled:i||a||n===`standard_upgrade`&&!s,leftIcon:i?(0,Z.jsx)(C,{className:`animate-spin`}):(0,Z.jsx)(E,{}),onClick:u,children:i?`Switching...`:`Switch to Stable`})]})]})})}function ir({assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:a}){let s=l(),u=d(dt()),f=u.data,p=!e.is_local,m=f?.plan_id===`pro`,h=d({...gt(),enabled:m}),g=e.machine_size||`small`,_=D(h.data?.max_machine_tier??null),v=(0,X.useMemo)(()=>k(_,g,(0,Z.jsx)(ie,{tone:`positive`,children:`Current`})),[_,g]),y=h.data?.selected_storage_gib??null,[b,x]=(0,X.useState)(!1),w=_.length>0?_[_.length-1]:null,[T,P]=(0,X.useState)(null),F=T??w??g,[ee,L]=(0,X.useState)(null),[te,R]=(0,X.useState)(null),ne=yt({onSuccess:(e,n)=>{V.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),R(null),P(null),x(!1),n.body?.machine_size==null?i():a(t)},onError:e=>{R(M(e,`Failed to resize assistant. Please try again.`))}});if(u.isError&&f==null)return(0,Z.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Z.jsx)(I,{tone:`error`,children:`Could not load your subscription. Please try again.`})});let re=m&&_.includes(F)&&F!==g?F:null,z=m&&y!=null&&!0,ae=m&&_.length>0&&j(g)<j(_[_.length-1]),H=ne.isPending||r,U=y==null?t?.disk?.totalMb??null:y*1024,se=t?.disk&&U!=null?{value:t.disk.usedMb,max:U,caption:`${Qt(t.disk.usedMb)} of ${Qt(U)}`}:null,ce=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,le=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:`${Qt(t.memory.currentMb)} of ${Qt(t.memory.maxMb)}`}:null,ue=p?m?z?(0,Z.jsxs)(`button`,{type:`button`,disabled:H,onClick:()=>x(!0),className:`flex items-center gap-1.5 rounded-lg border border-amber-500/30 bg-amber-500/15 px-3 py-1.5 text-body-small-default font-medium text-amber-400 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,children:[(0,Z.jsx)(N,{className:`h-3.5 w-3.5`}),`Increase Storage`]}):(0,Z.jsx)(o,{variant:`ghost`,size:`compact`,disabled:H,onClick:()=>x(!0),children:`Resize`}):(0,Z.jsx)(o,{variant:`ghost`,size:`compact`,onClick:()=>L(`storage`),children:`Resize`}):null,de=p?m?ae?(0,Z.jsxs)(`button`,{type:`button`,disabled:H,onClick:()=>x(!0),className:`flex items-center gap-1.5 rounded-lg border border-amber-500/30 bg-amber-500/15 px-3 py-1.5 text-body-small-default font-medium text-amber-400 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,children:[(0,Z.jsx)(N,{className:`h-3.5 w-3.5`}),`Increase Size`]}):(0,Z.jsx)(o,{variant:`ghost`,size:`compact`,disabled:H,onClick:()=>x(!0),children:`Resize`}):(0,Z.jsx)(o,{variant:`ghost`,size:`compact`,onClick:()=>L(`machine`),children:`Resize`}):null;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,compactAccessory:!0,accessory:(0,Z.jsx)(o,{variant:`ghost`,size:`compact`,iconOnly:n||r?(0,Z.jsx)(C,{className:`animate-spin`}):(0,Z.jsx)(E,{}),tooltip:r?`Applying resize…`:`Refresh resource metrics`,"aria-label":`Refresh resource metrics`,disabled:n||r,onClick:()=>void i()}),children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_2fr]`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Z.jsx)(S,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Disk`})]}),ue]}),(0,Z.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1 pt-3`,children:[(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Storage`}),se?(0,Z.jsx)(Jt,{value:se.value,max:se.max,caption:se.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(C,{className:`h-3 w-3 animate-spin`})}):(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Unavailable`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Z.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Machine`}),(0,Z.jsx)(ie,{tone:`neutral`,children:A[g]})]}),de]}),(0,Z.jsxs)(`div`,{className:`mt-auto grid grid-cols-2 gap-3 pt-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`CPU`}),ce?(0,Z.jsx)(Jt,{value:ce.value,max:ce.max,caption:ce.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(C,{className:`h-3 w-3 animate-spin`})}):(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Memory`}),le?(0,Z.jsx)(Jt,{value:le.value,max:le.max,caption:le.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(C,{className:`h-3 w-3 animate-spin`})}):(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,Z.jsx)(B.Root,{open:ee!=null,onOpenChange:e=>{e||L(null)},children:(0,Z.jsxs)(B.Content,{size:`sm`,children:[(0,Z.jsxs)(B.Header,{children:[(0,Z.jsx)(B.Title,{children:`Upgrade to Pro`}),(0,Z.jsx)(B.Description,{children:ee===`storage`?`Upgrade to the Pro plan to increase your storage allocation and get more space for your assistant.`:`Upgrade to the Pro plan to unlock larger machine sizes with more CPU and memory for your assistant.`})]}),(0,Z.jsxs)(B.Footer,{children:[(0,Z.jsx)(o,{variant:`ghost`,onClick:()=>L(null),children:`Cancel`}),(0,Z.jsx)(o,{onClick:()=>{L(null),s(`${K.settings.billing}?adjust_plan=1`)},children:`Upgrade`})]})]})}),(0,Z.jsx)(B.Root,{open:b,onOpenChange:e=>{e||(x(!1),P(null),R(null))},children:(0,Z.jsxs)(B.Content,{size:`sm`,children:[(0,Z.jsxs)(B.Header,{children:[(0,Z.jsx)(B.Title,{icon:O,children:`Resize Assistant`}),(0,Z.jsx)(B.Description,{children:`Resize your assistant's compute and storage. Your assistant will briefly restart.`})]}),(0,Z.jsx)(B.Body,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[_.length===0?(0,Z.jsx)(I,{tone:`warning`,children:`No machine tier configured. Visit the community for help.`}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:`Machine Size`}),(0,Z.jsx)(oe,{options:v,value:F,onChange:P,"aria-label":`Compute machine size`,"data-testid":`resize-machine-size`})]}),z?(0,Z.jsx)(I,{tone:`info`,children:`Storage will be expanded to ${y} GiB.`}):(0,Z.jsx)(I,{tone:`neutral`,children:`Storage will not change.`}),te&&(0,Z.jsx)(I,{tone:`error`,children:te})]})}),(0,Z.jsxs)(B.Footer,{className:`items-center justify-between`,children:[(0,Z.jsxs)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:[`Need more?`,` `,(0,Z.jsx)(c,{to:`${K.settings.billing}?adjust_plan=1`,className:`text-[var(--content-secondary)] underline decoration-[var(--border-element)] underline-offset-2 transition-colors hover:text-[var(--content-default)]`,onClick:()=>x(!1),children:`Upgrade plan`})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(o,{variant:`ghost`,onClick:()=>{x(!1),P(null),R(null)},children:`Cancel`}),(0,Z.jsx)(o,{disabled:re==null&&!z||H,leftIcon:H?(0,Z.jsx)(C,{className:`animate-spin`}):void 0,onClick:()=>{R(null);let t={};re!=null&&(t.machine_size=re),z&&y!=null&&(t.storage_gib=y),ne.mutate({path:{id:e.id},body:t})},children:te?`Retry`:`Apply`})]})]})]})})]})}function ar({assistantId:e}){let t=l(),[n,r]=(0,X.useState)(!1),[i,a]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{variant:`dangerOutline`,onClick:()=>r(!0),className:`shrink-0`,children:`Retire Assistant`}),(0,Z.jsx)(It,{open:n,isPending:i,onConfirm:async()=>{a(!0);let n=await Ft(e);if(n.ok){r(!1),t(n.nextRoute,{replace:!0});return}V.error(n.error),a(!1),r(!1)},onCancel:()=>r(!1)})]})}var or=`UTC.Africa/Cairo.Africa/Johannesburg.Africa/Lagos.Africa/Nairobi.America/Anchorage.America/Argentina/Buenos_Aires.America/Bogota.America/Chicago.America/Denver.America/Halifax.America/Lima.America/Los_Angeles.America/Mexico_City.America/New_York.America/Phoenix.America/Santiago.America/Sao_Paulo.America/Toronto.America/Vancouver.Asia/Bangkok.Asia/Dubai.Asia/Hong_Kong.Asia/Jakarta.Asia/Jerusalem.Asia/Karachi.Asia/Kolkata.Asia/Kuala_Lumpur.Asia/Manila.Asia/Seoul.Asia/Shanghai.Asia/Singapore.Asia/Taipei.Asia/Tokyo.Australia/Melbourne.Australia/Perth.Australia/Sydney.Europe/Amsterdam.Europe/Athens.Europe/Berlin.Europe/Brussels.Europe/Dublin.Europe/Istanbul.Europe/Lisbon.Europe/London.Europe/Madrid.Europe/Moscow.Europe/Paris.Europe/Rome.Europe/Stockholm.Europe/Vienna.Europe/Warsaw.Europe/Zurich.Pacific/Auckland.Pacific/Honolulu`.split(`.`);function sr(){let e=Intl;if(typeof e.supportedValuesOf==`function`)try{let t=e.supportedValuesOf(`timeZone`);if(t.length>0)return[...t].sort()}catch{}return[...or].sort()}function cr(e){let t=e.split(`/`),n=(t[t.length-1]??e).replace(/_/g,` `),r=t.length>1?(t[0]??``).replace(/_/g,` `):``,i=0,a=``;try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??`GMT`;a=t.startsWith(`GMT`)||t.startsWith(`UTC`)?t:`GMT ${t}`;let n=t.match(/([+-])(\d{1,2})(?::(\d{2}))?/);if(n){let e=n[1]===`-`?-1:1,t=parseInt(n[2]??`0`,10),r=parseInt(n[3]??`0`,10);i=e*(t*60+r)}}catch{return null}return{identifier:e,city:n,region:r,offsetLabel:a,offsetMinutes:i}}function lr(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour:`numeric`,minute:`2-digit`,hour12:!0}).format(new Date)}catch{return``}}function ur(e){if(!e)return`Not set`;try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`long`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value;if(t)return t}catch{}return e.replace(/_/g,` `)}function dr({value:e,onChange:t}){let[n,r]=(0,X.useState)(``),[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(null),l=(0,X.useRef)(null),u=(0,X.useMemo)(()=>sr().map(e=>cr(e)).filter(e=>e!==null),[]);(0,X.useEffect)(()=>{let e=window.setTimeout(()=>{a(n.trim().toLowerCase())},200);return()=>window.clearTimeout(e)},[n]),(0,X.useEffect)(()=>{if(!o)return;let e=e=>{c.current&&!c.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);let d=(0,X.useMemo)(()=>i?u.filter(e=>e.city.toLowerCase().includes(i)||e.region.toLowerCase().includes(i)||e.offsetLabel.toLowerCase().includes(i)||e.identifier.toLowerCase().includes(i)):u,[u,i]),f=(0,X.useMemo)(()=>{if(!e)return``;let t=e.split(`/`);return(t[t.length-1]??e).replace(/_/g,` `)},[e]),p=e=>{t(e),r(``),s(!1),l.current?.blur()};return(0,Z.jsxs)(`div`,{ref:c,className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 md:flex-row md:items-center md:justify-between md:gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Closest city`}),(0,Z.jsxs)(`div`,{className:`relative w-full md:max-w-[280px]`,children:[(0,Z.jsx)(z,{ref:l,type:`text`,value:n,placeholder:f||`Search city or country...`,onChange:e=>{r(e.target.value),s(!0)},onFocus:()=>s(!0),onKeyDown:e=>{e.key===`Escape`&&(r(``),s(!1),l.current?.blur())},fullWidth:!0}),o&&d.length>0&&(0,Z.jsx)(`div`,{className:`absolute left-0 right-0 top-full z-20 mt-1 max-h-[240px] overflow-y-auto rounded-md border border-[var(--border-base)] bg-[var(--surface-lift)] shadow-lg`,children:d.slice(0,200).map(t=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>p(t.identifier),className:`flex w-full cursor-pointer items-center justify-between gap-3 px-3 py-2 text-left text-body-medium-lighter transition-colors ${t.identifier===e?`bg-[var(--surface-active)] text-[var(--content-default)]`:`text-[var(--content-default)] hover:bg-[var(--surface-active)]`}`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-body-medium-default`,children:t.city}),t.region&&(0,Z.jsx)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:t.region})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(`span`,{children:lr(t.identifier)}),(0,Z.jsx)(`span`,{children:t.offsetLabel})]})]},t.identifier))})]})]}),(0,Z.jsx)($t,{}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Time zone`}),(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:ur(e)})]})]})}function fr(){let e=ve.use.activeAssistantId(),[r,a]=(0,X.useState)(()=>n(`timezone`,``)),o=(0,X.useRef)(e);(0,X.useEffect)(()=>{o.current=e},[e]);let s=(0,X.useRef)(!1),c=(0,X.useRef)(null),l=(0,X.useRef)(()=>{}),u=e=>{if(s.current){c.current=e;return}let t=o.current;if(!t){c.current=null;return}s.current=!0,c.current=null,G.patch({url:`/v1/assistants/{assistant_id}/config`,path:{assistant_id:t},body:{ui:{userTimezone:e}},throwOnError:!0}).catch(e=>{i(e,{context:`settings-timezone-override`})}).finally(()=>{s.current=!1;let e=c.current;c.current=null,e!==null&&l.current(e)})};return(0,X.useEffect)(()=>{l.current=u}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Timezone`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Used when displaying times and scheduling reminders.`}),(0,Z.jsx)(`div`,{className:`mt-1`,children:(0,Z.jsx)(dr,{value:r,onChange:e=>{a(e),t(`timezone`,e),u(e)}})})]})}var pr=[[`Mon`,0],[`Tue`,1],[`Wed`,2],[`Thu`,3],[`Fri`,4],[`Sat`,5],[`Sun`,6]];function mr(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),t,n));return`${i.getHours().toString().padStart(2,`0`)}:${i.getMinutes().toString().padStart(2,`0`)}`}function hr(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),t,n);return`${i.getUTCHours().toString().padStart(2,`0`)}:${i.getUTCMinutes().toString().padStart(2,`0`)}`}function gr(){return Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}function _r(e){let t=e?.schedule?.window.start??`06:00`,n=e?.schedule?.window.end??`08:00`;return{enabled:e?.enabled??!0,timezone:`UTC`,frequency:e?.schedule?.frequency??`weekly`,daysOfWeek:e?.schedule?.days_of_week??[0],daysOfMonth:e?.schedule?.days_of_month??[],windowStart:mr(t),windowEnd:mr(n)}}function vr({assistantId:e}){let t=u(),{data:n,isLoading:r,isError:i}=d(ot({path:{id:e}})),a=(0,X.useMemo)(()=>_r(n),[n]),[s,c]=(0,X.useState)(null),l=s??a,p=s!==null,m=(0,X.useMemo)(()=>gr(),[]),[h,g]=(0,X.useState)(null),_=h??l.daysOfMonth.join(`, `),v=f({mutationFn:async t=>{let{data:n}=await He({path:{id:e},body:t,throwOnError:!0});return n}}),y=e=>{c(t=>({...t??a,...e}))},b=e=>{y({daysOfWeek:l.daysOfWeek.includes(e)?l.daysOfWeek.filter(t=>t!==e):[...l.daysOfWeek,e].sort((e,t)=>e-t)})},x=e=>e.split(`,`).map(e=>parseInt(e.trim(),10)).filter(e=>!isNaN(e)&&e>=1&&e<=31);return r?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(C,{className:`h-4 w-4 animate-spin`}),`Loading update window settings...`]}):i?(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:`Failed to load update window policy. Refresh the page to try again.`}):(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsx)(ae,{checked:l.enabled,onChange:e=>y({enabled:e}),label:`Automatic updates`,helperText:`Update automatically during a configured time window`}),l.enabled&&(0,Z.jsxs)(`div`,{className:`space-y-5`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Frequency`}),(0,Z.jsx)(`div`,{className:`max-w-[400px]`,children:(0,Z.jsx)(ne,{ariaLabel:`Frequency`,value:l.frequency,onChange:e=>{e!==`monthly`&&g(null),y({frequency:e})},items:[{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}]})})]}),l.frequency===`weekly`&&(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Day(s) of week`}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:pr.map(([e,t])=>(0,Z.jsx)(o,{variant:`outlined`,size:`compact`,active:l.daysOfWeek.includes(t),onClick:()=>b(t),children:e},t))})]}),l.frequency===`monthly`&&(0,Z.jsx)(z,{label:`Day(s) of month`,type:`text`,value:_,onChange:e=>g(e.target.value),onBlur:e=>{let t=x(e.target.value);y({daysOfMonth:t}),g(t.join(`, `))},placeholder:`e.g. 1, 15`,helperText:`Comma-separated day numbers (1–31)`,className:`w-48`}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:[`Update window`,m?` (${m})`:``]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(z,{type:`time`,value:l.windowStart,onChange:e=>y({windowStart:e.target.value})}),(0,Z.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`to`}),(0,Z.jsx)(z,{type:`time`,value:l.windowEnd,onChange:e=>y({windowEnd:e.target.value})})]})]})]}),(0,Z.jsx)(o,{variant:`primary`,leftIcon:v.isPending?(0,Z.jsx)(C,{className:`animate-spin`}):void 0,onClick:async()=>{let n=l.frequency===`monthly`&&h!==null?x(h):l.daysOfMonth;try{await v.mutateAsync({enabled:l.enabled,timezone:`UTC`,schedule:{frequency:l.frequency,days_of_week:l.frequency===`weekly`?l.daysOfWeek:[],days_of_month:l.frequency===`monthly`?n:[],window:{start:hr(l.windowStart),end:hr(l.windowEnd)}}}),V.success(`Auto-update policy saved.`),c(null),g(null),t.invalidateQueries({queryKey:tt({path:{id:e}})})}catch{V.error(`Failed to save policy. Please try again.`)}},disabled:v.isPending||!p,children:`Save policy`})]})}function yr({assistantId:e,open:t,onClose:n}){return(0,Z.jsx)(B.Root,{open:t,onOpenChange:e=>{e||n()},children:(0,Z.jsxs)(B.Content,{size:`md`,children:[(0,Z.jsxs)(B.Header,{children:[(0,Z.jsx)(B.Title,{children:`Update Window`}),(0,Z.jsx)(B.Description,{children:`Configure when automatic updates are applied.`})]}),(0,Z.jsx)(B.Body,{children:(0,Z.jsx)(vr,{assistantId:e})})]})})}function br(e){if(typeof e==`object`&&e&&`code`in e){let t=e.code;if(typeof t==`string`)return t}}function xr({open:e,onOpenChange:t}){let n=u(),[r,i]=(0,X.useState)(null),[a,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(null),d=(0,X.useRef)(!1),f=(0,X.useRef)(e),p=()=>n.invalidateQueries({queryKey:it()}),m=e=>{ze({path:{id:e}}).catch(()=>void 0).finally(()=>void p())},h=ht({onSuccess:e=>{if(!f.current){m(e.factor_id);return}i(e)},onError:e=>{let n=br(e);n===`no_workos_account`?V.error(`Two-factor authentication is only available for Vellum platform accounts.`):n===`throttled`||n===`workos_rate_limited`?V.error(`Too many attempts. Try again in a minute.`):n===`factor_limit_reached`?V.error(`An authenticator app is already set up. Remove it before adding another.`):V.error(`Failed to start setup. Please try again.`),t(!1)}}),g=pt({onSuccess:e=>{e.valid?(d.current=!0,V.success(`Two-factor authentication is on.`),p(),t(!1)):l(`That code didn't match. Check your authenticator app and try again.`)},onError:e=>{let n=br(e);if(n===`challenge_already_verified`){d.current=!0,V.success(`Two-factor authentication is on.`),p(),t(!1);return}if(n===`challenge_expired`||n===`challenge_not_found`){r&&m(r.factor_id),i(null),s(``),l(`This setup session expired. Scan the new QR code and try again.`),h.mutate({});return}if(n===`throttled`||n===`workos_rate_limited`){l(`Too many attempts. Wait a minute and try again.`);return}l(`Couldn't verify the code. Wait a moment and try again.`)}});(0,X.useEffect)(()=>{f.current=e,e&&(d.current=!1,i(null),s(``),l(null),h.mutate({}))},[e]);let _=e=>{!e&&g.isPending||(!e&&r&&!d.current&&m(r.factor_id),t(e))},v=()=>{r&&navigator.clipboard.writeText(r.secret).then(()=>V.success(`Setup key copied.`)).catch(()=>V.error(`Couldn't copy the setup key.`))},y=()=>{!r||a.length!==6||g.isPending||(l(null),g.mutate({body:{challenge_id:r.challenge_id,code:a}}))};return(0,Z.jsx)(B.Root,{open:e,onOpenChange:_,children:(0,Z.jsxs)(B.Content,{size:`sm`,children:[(0,Z.jsxs)(B.Header,{children:[(0,Z.jsx)(B.Title,{children:`Set up authenticator app`}),(0,Z.jsx)(B.Description,{children:`Scan the QR code with an authenticator app such as Google Authenticator or 1Password, then enter the 6-digit code it shows.`})]}),(0,Z.jsx)(B.Body,{children:r===null?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,Z.jsx)(C,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):(0,Z.jsxs)(`form`,{className:`flex flex-col items-center gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,Z.jsx)(`img`,{src:r.qr_code,alt:`QR code for your authenticator app`,className:`h-44 w-44 rounded-lg bg-white p-2`}),(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Can't scan it? Enter this setup key manually:`}),(0,Z.jsxs)(`button`,{type:`button`,onClick:v,className:`flex cursor-pointer items-center gap-2 self-start font-mono text-body-small-default text-[var(--content-default)] hover:text-[var(--content-emphasised)]`,children:[(0,Z.jsx)(`span`,{className:`break-all text-left`,children:r.secret}),(0,Z.jsx)(x,{className:`h-3.5 w-3.5 shrink-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:`totp-code`,className:`text-body-small-default text-[var(--content-tertiary)]`,children:`6-digit code`}),(0,Z.jsx)(z,{id:`totp-code`,inputMode:`numeric`,autoComplete:`one-time-code`,maxLength:6,placeholder:`123456`,value:a,onChange:e=>s(e.target.value.replace(/\D/g,``).slice(0,6))}),c&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-body-small-default text-[var(--system-negative-strong)]`,children:c})]})]})}),(0,Z.jsxs)(B.Footer,{children:[(0,Z.jsx)(o,{variant:`outlined`,onClick:()=>_(!1),disabled:g.isPending,children:`Cancel`}),(0,Z.jsx)(o,{onClick:y,disabled:r===null||a.length!==6||g.isPending,children:g.isPending?`Verifying…`:`Verify`})]})]})})}function Sr(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function Cr(){let e=u(),[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(null),a=d({...rt()}),s=a.data??[],c=()=>e.invalidateQueries({queryKey:it()}),l=Qe({onSuccess:()=>{V.success(`Authenticator app removed.`),c()},onError:e=>{if(br(e)===`factor_not_found`){c();return}V.error(`Failed to remove the authenticator app. Please try again.`)}});return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[a.isPending?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(C,{className:`h-4 w-4 animate-spin`}),(0,Z.jsx)(`span`,{className:`text-body-medium-default`,children:`Loading authenticator apps…`})]}):a.isError?(0,Z.jsxs)(I,{tone:`error`,children:[`Couldn't load your authenticator apps.`,` `,(0,Z.jsx)(`button`,{type:`button`,className:`cursor-pointer underline`,onClick:()=>void a.refetch(),children:`Try again`})]}):s.length===0?(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`No authenticator app is set up. Add one to require a one-time code at sign-in.`}):(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:s.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsx)(Ot,{className:`h-5 w-5 shrink-0 text-[var(--content-tertiary)]`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Authenticator app`}),(0,Z.jsxs)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:[e.user,e.created_at?` · Added ${Sr(e.created_at)}`:``]})]})]}),(0,Z.jsx)(o,{variant:`dangerOutline`,onClick:()=>i(e),disabled:l.isPending,children:`Remove`})]},e.id))}),!a.isPending&&!a.isError&&s.length===0&&(0,Z.jsx)(o,{onClick:()=>n(!0),className:`self-start`,children:`Add authenticator app`}),(0,Z.jsx)(xr,{open:t,onOpenChange:n}),(0,Z.jsx)(H,{open:r!==null,title:`Remove authenticator app`,message:`Signing in will no longer ask for a code from this app. You can set up a new authenticator app at any time.`,confirmLabel:`Remove`,destructive:!0,onConfirm:()=>{r&&l.mutate({path:{id:r.id}}),i(null)},onCancel:()=>i(null)})]})}var Q=class extends Error{code;constructor(e,t){super(t),this.name=`TeleportError`,this.code=e}},wr=`local`,Tr=`docker`,Er=`vellum`;function Dr(e){switch((e??``).toLowerCase()){case wr:return`local`;case Tr:return`docker`;case Er:return`managed`;default:return`other`}}function Or(e){let t=Dr(e);return t===`managed`?`local`:t===`local`?`platform`:null}function kr(e){switch(e){case`docker`:return`Move to Docker`;case`platform`:return`Move to Cloud (Platform)`;case`local`:return`Move to Local`}}function Ar(e){switch(e){case`docker`:return`Run your assistant in a Docker container on this Mac.`;case`platform`:return`Run your assistant in the cloud, managed by the Vellum platform.`;case`local`:return`Run your assistant locally on this Mac.`}}function jr(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.reason!==`version_mismatch`)return null;let n=t.bundle_compat,r=t.target_runtime_version;if(!n||typeof n!=`object`||typeof r!=`string`)return null;let i=n,a=i.min_runtime_version;if(typeof a!=`string`)return null;let o=typeof i.max_runtime_version==`string`?i.max_runtime_version:null;return`Cannot import: bundle requires runtime ${o?`${a}–${o}`:`${a}+`}, but this local runtime is ${r}. Update your local runtime before importing.`}async function Mr(e,t){let n=Number(e.headers.get(`Content-Length`)??0);if(!e.body||!t||n<=0){let n=await e.arrayBuffer();return t?.(1),n}let r=e.body.getReader(),i=[],a=0;for(;;){let{done:e,value:o}=await r.read();if(e)break;i.push(o),a+=o.length,t(a/n)}let o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return t(1),o.buffer}function Nr(e){let t=pe(e);if(!t)throw new Q(`local_assistant_not_found`,`Assistant ${e.assistantId} has no resolved local gateway.`);return`${window.location.origin}${t}`}async function Pr(e,t){let n=await se(e.assistantId),r=await fetch(`${t}/auth/token`,{method:`POST`,headers:{Authorization:`Bearer ${n}`}});if(!r.ok)throw new Q(`not_signed_in`,`Gateway token request failed (HTTP ${r.status}).`);let{token:i}=await r.json();return i}async function Fr(e,t){let n=Nr(e),r=await Pr(e,n),i=await fetch(`${n}/v1/migrations/export`,{method:`POST`,headers:{Authorization:`Bearer ${r}`}});if(!i.ok)throw new Q(`export_failed`,`Export failed (HTTP ${i.status}).`);return Mr(i,t)}async function Ir(e,t){let n=Nr(e),r=await Pr(e,n),i=await fetch(`${n}/v1/migrations/import`,{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:new Blob([t],{type:`application/octet-stream`})});if(!i.ok)throw new Q(`import_failed`,`Import failed (HTTP ${i.status}).`);let a=await zr(i);if(a&&a.success===!1)throw new Q(`import_failed`,a.error??`Import reported failure`)}async function Lr(e,t){let{data:n,response:r}=await G.post({url:`/v1/assistants/{assistant_id}/migrations/export-to-gcs/`,path:{assistant_id:e},body:{upload_url:t},throwOnError:!1}),i=r?.status??0;if(!(r?.ok??!1)&&i!==202)throw new Q(`export_failed`,`Export failed (HTTP ${i}).`);let a=n?.job_id;if(!a)throw new Q(`export_failed`,`Export accepted but no job ID was returned.`);return a}async function Rr(e,t){let{data:n,response:r}=await G.get({url:`/v1/assistants/{assistant_id}/migrations/jobs/{job_id}`,path:{assistant_id:e,job_id:t},throwOnError:!1}),i=r?.status??0;if(i>=500)return`processing`;if(!(r?.ok??!1))throw new Q(`export_job_failed`,`Job status check failed (HTTP ${i})`);let a=n;if(a?.status===`failed`)throw new Q(`export_job_failed`,a.error??`Export job failed`);return a?.status??`processing`}async function zr(e){try{return await e.json()}catch{return null}}var Br=new Set([500,502,503,504]),$=3,Vr=e=>new Promise(t=>setTimeout(t,e));async function Hr(e,t=new Set){for(let n=0;n<=$;n++){let{response:r,data:i,error:a}=await e(),o=r?.status??0;if(n<$&&Br.has(o)&&!t.has(o)){await Vr(2**n*1e3);continue}return{status:o,data:i,error:a}}throw new Q(`unknown`,`Unexpected retry loop exit`)}async function Ur(e,t){let n={operation:`upload`};e&&(n.min_runtime_version=e,n.max_runtime_version=null),t&&(n.consumer=t);let{status:r,data:i}=await Hr(()=>G.post({url:`/v1/migrations/signed-url/`,body:n,throwOnError:!1}),new Set([404,503]));if(r===503||r===404)throw new Q(`export_failed`,`Signed URL uploads are not available — the platform may not support this feature yet.`);if(r!==201)throw new Q(`export_failed`,`Migration request failed (HTTP ${r}).`);let a=i;return{url:a.url,bundleKey:a.bundle_key,expiresAt:a.expires_at}}async function Wr(e,t){let{status:n,data:r,error:i}=await Hr(()=>G.post({url:`/v1/migrations/signed-url/`,body:{operation:`download`,bundle_key:e,target_runtime_version:t},throwOnError:!1}),new Set([422]));if(n===422){let e=jr(i);if(e)throw new Q(`version_mismatch`,e)}if(n!==200&&n!==201)throw new Q(`import_failed`,`Migration request failed (HTTP ${n}).`);return r.url}async function Gr(e,t,n){for(let r=0;r<=$;r++){let i=await Kr(e,t,n);if(r<$&&Br.has(i)){await Vr(2**r*1e3),n?.(0);continue}if(i<200||i>=300)throw new Q(`export_failed`,`Bundle upload failed (HTTP ${i}).`);return}}function Kr(e,t,n){return new Promise((r,i)=>{let a=new XMLHttpRequest;a.open(`PUT`,e),a.setRequestHeader(`Content-Type`,`application/octet-stream`),a.timeout=36e5,n&&(a.upload.onprogress=e=>{e.lengthComputable&&n(e.loaded/e.total)}),a.onload=()=>{n?.(1),r(a.status)},a.onerror=()=>i(new Q(`export_failed`,`Bundle upload failed.`)),a.ontimeout=()=>i(new Q(`export_timed_out`,`Bundle upload timed out.`)),a.send(t)})}async function qr(e,t){for(let n=0;n<=$;n++){let r=await fetch(e,{method:`GET`});if(n<$&&Br.has(r.status)){await Vr(2**n*1e3),t?.(0);continue}if(!r.ok)throw new Q(`import_failed`,`Bundle download failed (HTTP ${r.status}).`);return Mr(r,t)}throw new Q(`import_failed`,`Unexpected retry loop exit`)}async function Jr(e){let{status:t,data:n,error:r}=await Hr(()=>G.post({url:`/v1/migrations/import-from-gcs/`,body:{bundle_key:e},throwOnError:!1}));return{status:t,body:n??r??null}}async function Yr(e){let{status:t,data:n}=await Hr(()=>G.get({url:`/v1/migrations/jobs/{job_id}/`,path:{job_id:e},throwOnError:!1}));if(t!==200)throw new Q(`import_failed`,`Job status check failed (HTTP ${t})`);let r=n??{};return{status:typeof r.status==`string`?r.status:`unknown`,jobId:typeof r.job_id==`string`?r.job_id:null,error:typeof r.error==`string`?r.error:null}}var Xr=5e3,Zr=36e5,Qr=5*6e4,$r=30,ei=e=>new Promise(t=>setTimeout(t,e));function ti(){let e=l(),t=he(),n=Or(t?.cloud),[r,a]=(0,X.useState)({kind:`idle`}),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(null),u=(0,X.useRef)(null),d=(0,X.useCallback)(e=>{a({kind:`transferring`,step:e,progress:null})},[]),f=(0,X.useCallback)(e=>{a(t=>t.kind===`transferring`?{...t,progress:e}:t)},[]),p=(0,X.useCallback)(async()=>{if(!(!t||!n)){u.current={id:t.assistantId,kind:Dr(t.cloud)===`managed`?`managed`:`local`,createdFresh:!1};try{if(n===`platform`)await ni(t,d,f,c);else if(n===`local`)await ri(t,d,f,c);else throw new Q(`unknown`,`Unsupported teleport destination.`);a({kind:`verifying`})}catch(e){a({kind:`failed`,error:`Teleport failed: ${e instanceof Q||e instanceof Error?e.message:`Teleport failed.`}`}),i(e,{context:`teleport-execute`}),await ai(c.current,u.current,`teleport-execute-cleanup`),c.current=null}}},[t,n,d,f]),m=(0,X.useCallback)(()=>s(!0),[]),h=(0,X.useCallback)(()=>s(!1),[]),g=(0,X.useCallback)(()=>{s(!1),p()},[p]),_=(0,X.useCallback)(()=>{c.current=null,u.current=null,a({kind:`idle`})},[]);return{destination:n,phase:r,confirmOpen:o,requestTeleport:m,cancelConfirm:h,confirm:g,confirmAndSwitch:(0,X.useCallback)(()=>{let t=c.current,n=u.current;t&&(async()=>{try{let e=je.getState();t.kind===`managed`?await e.connectPlatformAssistant(t.id):(await e.connectLocalAssistant(t.id),Pe(t.id,{onError:e=>i(e,{context:`teleport-inject-platform-identity`})}))}catch(e){a({kind:`failed`,error:`Switch failed: ${e instanceof Error?e.message:`Failed to switch assistant.`}`}),i(e,{context:`teleport-confirm-switch`});return}n&&Ft(n.id).then(e=>{e.ok||i(Error(e.error),{context:`teleport-retire-source`})}),_(),e(K.assistant,{replace:!0})})()},[e,_]),cancelTeleport:(0,X.useCallback)(()=>{let e=c.current,t=u.current;c.current=null,u.current=null,a({kind:`idle`}),ai(e,t,`teleport-cancel-retire-target`)},[]),reset:_}}async function ni(e,t,n,r){t(`Exporting assistant data...`);let i=await Fr(e,n);t(`Resolving organization...`);let a=await si();t(`Checking for existing assistant...`);let o=(await Be({query:{hosting:`platform`},throwOnError:!1})).data?.results?.[0];if(o)throw new Q(`existing_platform_assistant`,`You already have a platform assistant '${o.id}'. Retire it first, then retry the teleport.`);t(`Uploading data to cloud...`);let s=await Ur(e.resources?.runtimeVersion);await Gr(s.url,i,n),t(`Setting up cloud assistant...`);let c=await Ge(void 0,`create`);if(!c.ok)throw new Q(`import_failed`,`Failed to set up the cloud assistant.`);if(c.status===200)throw new Q(`existing_platform_assistant`,`You already have a platform assistant '${c.data.id}'. Retire it first, then retry the teleport.`);let l=c.data.id;await ce({assistantId:l,name:c.data.name,cloud:`vellum`,runtimeUrl:ue(),hatchedAt:c.data.created??new Date().toISOString(),organizationId:a}),await U(e.assistantId),r.current={id:l,kind:`managed`,createdFresh:!0},t(`Finalizing cloud assistant...`),await ci(l),t(`Importing data to cloud...`);let u=await Jr(s.bundleKey);if(u.status<200||u.status>=300){let e=u.body;throw new Q(`import_failed`,e?.error??`Import failed (HTTP ${u.status}).`)}if(u.status===202){let e=u.body?.job_id;if(!e)throw new Q(`import_failed`,`Import accepted but no job ID returned.`);await li(e)}else{let e=u.body;if(e&&e.success===!1)throw new Q(`import_failed`,e.error??`Import reported failure.`)}}async function ri(e,t,n,r){t(`Preparing export...`);let i=await Ur(await oi(e.assistantId),`runtime`);t(`Exporting cloud data...`);let a=await Lr(e.assistantId,i.url);await ui(e.assistantId,a),t(`Preparing local assistant...`);let{assistant:o,createdFresh:s}=await di();r.current={id:o.assistantId,kind:`local`,createdFresh:s};let c=await ii(o,s);if(!c)throw new Q(`local_assistant_not_found`,`Could not determine the local assistant's runtime version. Restart or upgrade the local assistant, then retry the teleport.`);t(`Preparing import...`);let l=await Wr(i.bundleKey,c);t(`Downloading data...`);let u=await qr(l,n);t(`Importing data...`),await pi(o,u),await U(e.assistantId)}async function ii(e,t){if(e.resources?.runtimeVersion)return e.resources.runtimeVersion;if(t)return(await Kt())?.version??void 0}async function ai(e,t,n){if(e?.createdFresh){let t=await Ft(e.id);t.ok||i(Error(t.error),{context:n})}t&&await U(t.id)}async function oi(e){let t=await We(e);return t.ok?t.data.version??void 0:void 0}async function si(){let e=we.getState();e.organizations.length===0&&await e.fetchOrganizations();let t=we.getState().organizations,n=Ne();if(n&&t.some(e=>e.id===n))return n;if(t.length===0)throw new Q(`no_organizations`,`No organizations found for this account.`);if(t.length>1)throw new Q(`multiple_organizations`,`Multiple organizations found — please select one in account settings first.`);let r=t[0].id;return we.getState().setCurrentOrganizationId(r),r}async function ci(e){let t=Date.now();for(;Date.now()-t<Qr;){let{data:t,response:n}=await Ue({path:{id:e},throwOnError:!1});if(n?.ok&&t?.state===`active`)return;await ei(Xr)}}async function li(e){let t=Date.now();for(;Date.now()-t<Zr;){await ei(Xr);let t=await Yr(e);if(t.status===`complete`)return;if(t.status===`failed`)throw new Q(`import_failed`,t.error??`Import job failed`)}throw new Q(`import_failed`,`Import timed out after 60 minutes.`)}async function ui(e,t){let n=Date.now();for(;Date.now()-n<Zr;)if(await ei(Xr),await Rr(e,t)===`complete`)return;throw new Q(`export_timed_out`,`Export timed out.`)}async function di(){let e=await me(void 0,void 0);if(!e.ok)throw new Q(`local_assistant_not_found`,e.error??`Could not create a local assistant.`);await le();let t=e.assistantId?_e().find(t=>t.assistantId===e.assistantId):fi();if(!t)throw new Q(`local_assistant_not_found`,`Could not find or create a local assistant.`);return{assistant:t,createdFresh:!0}}function fi(){return _e().slice().sort((e,t)=>(t.hatchedAt??``).localeCompare(e.hatchedAt??``))[0]}async function pi(e,t){let n;for(let r=0;r<$r;r++)try{await Ir(e,t);return}catch(e){n=e,await ei(1e3)}throw n instanceof Error?n:new Q(`import_failed`,`Import failed.`)}function mi(){let e=ti(),{destination:t,phase:n}=e;return t?(0,Z.jsxs)(Y,{title:`Teleport`,subtitle:`Move your assistant to a different hosting environment.`,children:[n.kind===`idle`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:Ar(t)}),(0,Z.jsx)(o,{variant:`outlined`,className:`self-start`,onClick:e.requestTeleport,children:kr(t)})]}),n.kind===`transferring`&&(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.progress==null&&(0,Z.jsx)(C,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:n.step})]}),n.progress!=null&&(0,Z.jsx)(ee,{value:n.progress,"aria-label":`Teleport progress`,className:`max-w-[240px]`})]}),n.kind===`verifying`&&(0,Z.jsx)(I,{tone:`success`,icon:(0,Z.jsx)(b,{className:`h-4 w-4`}),title:`Transfer complete — verify your new assistant is working.`,actions:(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(o,{variant:`primary`,onClick:e.confirmAndSwitch,children:`Confirm & Switch`}),(0,Z.jsx)(o,{variant:`outlined`,onClick:e.cancelTeleport,children:`Cancel`})]})}),n.kind===`failed`&&(0,Z.jsx)(I,{tone:`error`,title:n.error,actions:(0,Z.jsx)(o,{variant:`outlined`,onClick:e.reset,children:`Try Again`})}),(0,Z.jsx)(H,{open:e.confirmOpen,title:kr(t),message:`Your data will be copied to the new environment. The current assistant will remain available until you confirm the new one works.`,confirmLabel:`Teleport`,onConfirm:e.confirm,onCancel:e.cancelConfirm})]}):null}function hi(){let{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:a}=Xt(),c=q.use.multiPlatformAssistant(),u=q.use.teleport(),d=q.use.accountMfa(),f=bt.use.settingsSleepPolicy(),p=De(),m=l(),h=Vt(),g=Vt({platformHostedOnly:!0}),_=Lt(),v=Nt({assistantId:e?.id??null,enabled:g===`full`&&_}),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(!1),[C,w]=s();(0,X.useEffect)(()=>{if(C.get(`preferences`)!==`open`)return;let e=new URLSearchParams(C);e.delete(`preferences`),w(e,{replace:!0}),S(!0)},[C,w]);let T=e?.is_local&&!ge()?null:e,E=he(),D=ge()&&!!e&&!!E&&de(E),O=D,k=D&&!fe(),A=g===`full`&&!!T||k&&!!e;(0,X.useEffect)(()=>{!e||window.location.hash!==`#storage-resources`||requestAnimationFrame(()=>{document.getElementById(`storage-resources`)?.scrollIntoView({block:`start`})})},[e]);let j=t?.version??e?.current_release_version??null,M=(h===`full`||O)&&!!T||h===`disabled`&&!O,N=g!==`gated`;return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[v.status&&v.mode!==`inactive`&&(0,Z.jsx)(Wt,{status:v.status,mode:v.mode,isAcknowledging:v.isAcknowledging,acknowledgeError:v.acknowledgeError?.message??null,onAcknowledge:()=>void v.acknowledge(),onReviewWorkspaceData:()=>void m(`${K.workspace}?sort=size`),onUpgradeStorage:g===`full`?()=>void m(`${K.settings.billing}?adjust_plan=1`):null}),(0,Z.jsxs)(hn,{assistant:_?T:null,showHandles:p&&h===`full`,children:[(0,Z.jsx)(fr,{}),d&&h!==`gated`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Two-Factor Authentication`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Require a code from an authenticator app when you sign in.`}),(0,Z.jsx)(`div`,{className:`mt-1`,children:h===`disabled`?(0,Z.jsx)(J,{children:`Log in to the Vellum platform to manage two-factor authentication.`}):(0,Z.jsx)(Cr,{})})]})]})]}),(0,Z.jsx)(Y,{title:`Version`,subtitle:`Manage your assistant's software version and updates.`,accessory:g===`full`&&T?(0,Z.jsx)(o,{variant:`outlined`,onClick:()=>b(!0),children:`Update Window`}):void 0,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g===`full`&&T&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Tn,{assistantId:T.id,currentVersion:j,releaseChannel:T.release_channel,onUpgradeComplete:()=>{i()}}),(0,Z.jsx)(Qn,{assistantId:T.id,onComplete:()=>{i()}})]}),k&&e&&(0,Z.jsx)(En,{assistantId:e.id,currentVersion:j,onUpgradeComplete:()=>{i()}}),!A&&e&&(0,Z.jsxs)(`div`,{className:`grid grid-cols-[140px_minmax(0,1fr)] gap-y-3`,children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Z.jsx)(Zt,{version:j,loading:n&&!e.current_release_version,assistantId:e.id??null})]}),g===`disabled`&&!k&&(0,Z.jsx)(J,{children:`Log in to the Vellum platform to manage software updates.`})]})}),g===`full`&&T&&(0,Z.jsx)(yr,{assistantId:T.id,open:y,onClose:()=>b(!1)}),g===`full`&&e&&(0,Z.jsx)(ir,{assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:a}),g===`disabled`&&(0,Z.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Z.jsx)(J,{children:`Log in to the Vellum platform to manage compute resources.`})}),(0,Z.jsx)(Y,{title:`Preferences`,subtitle:`Customize appearance, shortcuts, and how Vellum behaves on this device.`,accessory:(0,Z.jsx)(o,{variant:`outlined`,onClick:()=>S(!0),children:`Customize`})}),(0,Z.jsx)(Kn,{open:x,onClose:()=>S(!1)}),u&&W()&&(0,Z.jsx)(mi,{}),(0,Z.jsx)(kn,{}),g===`full`&&T&&f&&(0,Z.jsx)(Y,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Z.jsx)(xn,{assistantId:T.id})}),g===`disabled`&&f&&(0,Z.jsx)(Y,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Z.jsx)(J,{children:`Log in to the Vellum platform to manage sleep policy.`})}),c&&(0,Z.jsx)(vn,{}),(M||N)&&(0,Z.jsx)(Y,{variant:`danger`,title:`Danger Zone`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[M&&(0,Z.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-title-small text-[var(--content-emphasised)]`,children:`Retire Assistant`}),(0,Z.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Permanently retire this assistant and delete all associated data.`}),(0,Z.jsx)(`div`,{className:`mt-1`,children:(h===`full`||O)&&T?(0,Z.jsx)(ar,{assistantId:T.id}):(0,Z.jsx)(J,{children:`Log in to the Vellum platform to retire this assistant.`})})]}),M&&N&&(0,Z.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Z.jsx)(Dn,{})]})})]})}export{hi as GeneralPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{P as n,t as r}from"./button-BQVYX8n_.js";import{l as i,u as a}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as o}from"./QueryClientProvider-DKhXIxGb.js";import{t as s}from"./useQuery-B45lW1Kk.js";import{t as c}from"./jsx-runtime-CVSDxk6A.js";import{t as l}from"./typography-Cqi8q9o7.js";import{t as u}from"./arrow-left-C2re-gYj.js";import{t as d}from"./bell-BbESwsZk.js";import{t as f}from"./calendar-D0labpMU.js";import{t as p}from"./chevron-right-jRymmL7S.js";import{t as m}from"./x-CswtfvgS.js";import{d as h,h as g,i as _}from"./src-CDdn26Yb.js";import{t as v}from"./tag-B6WeUtBW.js";import{R as y,z as b}from"./react-query.gen-BQH0QRfT.js";import{c as x}from"./routes-XPLb07Av.js";import{Er as S,Hi as C,Hn as w,Jn as T,Nt as E,Rr as D,Un as O,Wn as k,_ as ee,a as A,c as te,d as j,ea as M,f as N,g as P,h as F,i as I,l as L,ma as R,n as ne,o as re,p as z,pa as ie,r as B,s as V,u as H}from"./index-CZVGv7Cn.js";import{t as U}from"./use-active-assistant-id-9rGx8kT9.js";import{t as W}from"./page-shell-DeTaZ_s4.js";import{l as G,s as K,t as q,u as J}from"./page-empty-state-DbCk3v6f.js";var Y=e(t(),1),X=c(),ae={p:({children:e})=>(0,X.jsx)(`p`,{className:`mb-2 text-body-medium-default last:mb-0`,style:{color:`var(--content-secondary)`},children:e}),strong:({children:e})=>(0,X.jsx)(`strong`,{style:{color:`var(--content-default)`},children:e}),em:({children:e})=>(0,X.jsx)(`em`,{style:{color:`var(--content-default)`},children:e}),a:({href:e,children:t})=>(0,X.jsx)(`a`,{href:e,className:`underline`,style:{color:`var(--content-link)`},target:`_blank`,rel:`noopener noreferrer`,onClick:t=>E(t,e),children:t}),ul:({children:e})=>(0,X.jsx)(`ul`,{className:`mb-2 list-disc pl-5 text-body-medium-default`,style:{color:`var(--content-secondary)`},children:e}),ol:({children:e})=>(0,X.jsx)(`ol`,{className:`mb-2 list-decimal pl-5 text-body-medium-default`,style:{color:`var(--content-secondary)`},children:e}),li:({children:e})=>(0,X.jsx)(`li`,{className:`mb-0.5`,children:e}),code:({children:e})=>(0,X.jsx)(`code`,{className:`rounded px-1 py-0.5 font-mono text-[0.85em]`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 8%, transparent)`,color:`var(--content-default)`},children:e}),pre:({children:e})=>(0,X.jsx)(`pre`,{className:`mb-2 overflow-x-auto rounded p-3 font-mono text-[0.85em]`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 6%, transparent)`,color:`var(--content-default)`},children:e}),h1:({children:e})=>(0,X.jsx)(`h1`,{className:`mb-2 text-title-medium first:mt-0`,style:{color:`var(--content-default)`},children:e}),h2:({children:e})=>(0,X.jsx)(`h2`,{className:`mb-2 text-title-small first:mt-0`,style:{color:`var(--content-default)`},children:e}),h3:({children:e})=>(0,X.jsx)(`h3`,{className:`mb-1 text-body-medium-default first:mt-0`,style:{color:`var(--content-default)`},children:e}),blockquote:({children:e})=>(0,X.jsx)(`blockquote`,{className:`mb-2 border-l-2 pl-3 text-body-medium-default`,style:{borderColor:`var(--border-base)`,color:`var(--content-tertiary)`},children:e}),table:({children:e})=>(0,X.jsx)(`div`,{className:`mb-2 overflow-x-auto`,children:(0,X.jsx)(`table`,{className:`w-full border-collapse text-body-small-default`,style:{color:`var(--content-secondary)`},children:e})}),thead:({children:e})=>(0,X.jsx)(`thead`,{style:{backgroundColor:`var(--surface-lift)`},children:e}),tbody:({children:e})=>(0,X.jsx)(`tbody`,{children:e}),tr:({children:e})=>(0,X.jsx)(`tr`,{style:{borderBottom:`1px solid var(--border-base)`},children:e}),th:({children:e})=>(0,X.jsx)(`th`,{className:`px-2 py-1.5 text-left font-semibold`,style:{color:`var(--content-default)`},children:e}),td:({children:e})=>(0,X.jsx)(`td`,{className:`px-2 py-1.5 align-top`,children:e})};function oe({content:e,className:t}){return(0,X.jsx)(`div`,{className:n(`text-body-medium-default`,t),children:(0,X.jsx)(g,{remarkPlugins:[h],components:ae,children:e})})}function Z({item:e}){return(0,X.jsx)(oe,{content:e.summary})}function se(e){switch(e){case`revoked`:case`expired`:return`var(--system-negative-strong)`;case`missing_scopes`:case`missing_token`:case`ping_failed`:return`var(--system-mid-strong)`;default:return`var(--content-disabled)`}}function ce(e){return e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Q({item:e}){let t=e.metadata,n=t?.provider;if(!n)return(0,X.jsx)(l,{variant:`body-medium-default`,className:`text-[var(--content-secondary)]`,children:e.title??e.summary});let r=t?.accountInfo??null,i=t?.status??`unreachable`,a=t?.details??``,o=Array.isArray(t?.missingScopes)?t.missingScopes:[];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-[var(--app-spacing-md)]`,children:[(0,X.jsx)(l,{variant:`title-small`,as:`h3`,children:n}),r?(0,X.jsx)(l,{variant:`body-medium-lighter`,className:`text-[var(--content-secondary)]`,children:r}):null,(0,X.jsxs)(`div`,{className:`flex items-center gap-[var(--app-spacing-sm)]`,children:[(0,X.jsx)(`span`,{className:`inline-block shrink-0 rounded-full`,style:{width:8,height:8,backgroundColor:se(i)},"aria-hidden":`true`}),(0,X.jsx)(l,{variant:`body-medium-default`,className:`text-[var(--content-default)]`,children:ce(i)})]}),a?(0,X.jsx)(l,{variant:`body-medium-lighter`,className:`text-[var(--content-secondary)]`,children:a}):null,o.length>0?(0,X.jsxs)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)]`,children:[(0,X.jsx)(l,{variant:`body-small-emphasised`,className:`text-[var(--content-secondary)]`,children:`Missing scopes`}),(0,X.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-[var(--app-spacing-xxs)] pl-[var(--app-spacing-lg)]`,children:o.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(l,{variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:e})},e))})]}):null]})}function le(e){return e&&N[e]?N[e]:N.system}function ue(e){return e.title?e.title:e.category?e.category.charAt(0).toUpperCase()+e.category.slice(1):`Notification`}function de({item:e,isMobile:t,validConversationIds:n,onClose:i,onGoToThread:a,onUpdateStatus:o,onDismiss:s,onViewSchedule:c}){if(!e)return null;let d=e.detailPanel?.kind,p=ue(e),h=le(e.category),g=h.icon,_=e.status===`new`,y=e.status===`dismissed`,b=!!e.conversationId&&n.has(e.conversationId);return t?(0,X.jsxs)(`div`,{className:`flex h-full flex-col bg-[var(--surface-overlay)]`,children:[(0,X.jsxs)(`div`,{className:`relative flex shrink-0 items-center px-3 py-2`,children:[(0,X.jsx)(r,{variant:`ghost`,iconOnly:(0,X.jsx)(u,{}),onClick:i,"aria-label":`Back`,tooltip:`Back`}),(0,X.jsx)(l,{variant:`body-medium-default`,className:`pointer-events-none absolute inset-x-0 text-center text-[var(--content-secondary)]`,children:`Details`}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,X.jsx)(r,{variant:`ghost`,iconOnly:_?(0,X.jsx)(R,{}):(0,X.jsx)(ie,{}),onClick:()=>o(e.id,_?`seen`:`new`),"aria-label":_?`Mark as read`:`Mark as unread`,tooltip:_?`Mark as read`:`Mark as unread`}),y?(0,X.jsx)(r,{variant:`ghost`,iconOnly:(0,X.jsx)(M,{}),onClick:()=>o(e.id,`seen`),"aria-label":`Restore`,tooltip:`Restore`}):(0,X.jsx)(r,{variant:`ghost`,iconOnly:(0,X.jsx)(C,{}),onClick:()=>s(e.id),"aria-label":`Dismiss`,tooltip:`Dismiss`})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,X.jsx)(`span`,{className:`flex shrink-0 items-center justify-center rounded-full`,style:{width:40,height:40,backgroundColor:h.weak},"aria-hidden":`true`,children:(0,X.jsx)(g,{width:18,height:18,style:{color:h.strong}})}),(0,X.jsx)(l,{variant:`title-small`,className:`min-w-0 text-[var(--content-default)]`,children:p}),(0,X.jsx)(v,{tone:`neutral`,className:`shrink-0`,title:F(e.timestamp),children:P(e.timestamp)})]}),(0,X.jsx)(`div`,{className:`mx-4 border-b border-[var(--border-disabled)]`}),(0,X.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:d===`toolPermission`?(0,X.jsx)(Q,{item:e}):(0,X.jsx)(Z,{item:e})}),b||c?(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 px-4 pb-4 pt-2`,children:[c?(0,X.jsx)(r,{variant:`outlined`,fullWidth:!0,leftIcon:(0,X.jsx)(f,{className:`size-4`}),onClick:c,children:`View schedule`}):null,b?(0,X.jsx)(r,{variant:`primary`,fullWidth:!0,onClick:()=>a(e.conversationId),children:`Go to Conversation`}):null]}):null]}):(0,X.jsxs)(`div`,{className:`flex h-full flex-col rounded-[var(--radius-xl)] border border-[var(--border-base)] bg-[var(--surface-overlay)]`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-[var(--app-spacing-sm)] border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,X.jsx)(`span`,{className:`flex shrink-0 items-center justify-center rounded-full`,style:{width:28,height:28,backgroundColor:h.weak},"aria-hidden":`true`,children:(0,X.jsx)(g,{width:14,height:14,style:{color:h.strong}})}),(0,X.jsx)(l,{variant:`title-small`,className:`min-w-0 flex-1 truncate text-[var(--content-default)]`,children:p}),b?(0,X.jsx)(r,{variant:`outlined`,onClick:()=>a(e.conversationId),children:`Go to Convo`}):null,(0,X.jsx)(r,{variant:`outlined`,iconOnly:(0,X.jsx)(m,{}),onClick:i,"aria-label":`Close detail panel`,tooltip:`Close`})]}),(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-[var(--app-spacing-lg)]`,children:[d===`toolPermission`?(0,X.jsx)(Q,{item:e}):(0,X.jsx)(Z,{item:e}),(0,X.jsx)(`div`,{className:`mt-[var(--app-spacing-md)]`,children:(0,X.jsx)(v,{tone:`neutral`,title:F(e.timestamp),children:P(e.timestamp)})})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-[var(--app-spacing-sm)] border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,X.jsx)(`div`,{children:c?(0,X.jsx)(r,{variant:`outlined`,leftIcon:(0,X.jsx)(f,{className:`size-4`}),onClick:c,children:`View schedule`}):null}),(0,X.jsx)(`div`,{className:`flex items-center gap-[var(--app-spacing-sm)]`,children:y?(0,X.jsx)(r,{variant:`primary`,onClick:()=>o(e.id,`seen`),children:`Restore`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{variant:`outlined`,onClick:()=>o(e.id,_?`seen`:`new`),children:_?`Mark as read`:`Mark as unread`}),(0,X.jsx)(r,{variant:`primary`,onClick:()=>s(e.id),children:`Dismiss`})]})})]})]})}var fe={today:`Today`,yesterday:`Yesterday`,older:`Older`},pe=10080*60*1e3;function $(e,t){return e.status===`new`||e.status===`dismissed`?!1:t-new Date(e.createdAt).getTime()>pe}function me({items:e,selectedItemId:t,validConversationIds:n,onSelectItem:r,onDismissItem:i,onRestoreItem:a,onToggleRead:o,onGoToThread:s,archivedOpen:c,onArchivedOpenChange:u,dismissedOpen:f,onDismissedOpenChange:m}){let[h,g]=(0,Y.useState)(null),[v]=(0,Y.useState)(()=>Date.now()),y=B(e.filter(e=>e.status!==`dismissed`)),b=y.filter(e=>!$(e,v)),x=L(y.filter(e=>$(e,v))),S=A(b),C=h&&S.includes(h)?h:null;h!==C&&g(C);let w=V(L(I(b,C))),T=e.filter(e=>e.status===`dismissed`).sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());return(0,X.jsxs)(`div`,{className:`flex flex-col gap-[var(--app-spacing-lg)]`,children:[(0,X.jsx)(z,{categories:S,activeFilter:C,onFilterChange:g}),w.size===0?C?(0,X.jsx)(l,{variant:`body-medium-lighter`,className:`py-[var(--app-spacing-xl)] text-center text-[var(--content-disabled)]`,children:`No items match the selected filter.`}):(0,X.jsx)(q,{icon:d,title:`No notifications yet`,description:`Updates and activity from your assistant will appear here.`}):[...w.entries()].map(([e,a])=>(0,X.jsxs)(`section`,{className:`flex flex-col gap-[var(--app-spacing-md)]`,children:[(0,X.jsx)(l,{variant:`body-small-default`,as:`h3`,className:`text-[var(--content-tertiary)]`,children:fe[e]}),(0,X.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)]`,children:a.map(e=>(0,X.jsx)(j,{item:e,isActive:e.id===t,validConversationIds:n,onSelect:r,onDismiss:i,onToggleRead:o,onGoToThread:s},e.id))})]},e)),x.length>0&&(0,X.jsx)(_.Root,{type:`single`,collapsible:!0,value:c?`archived-read`:``,onValueChange:e=>u?.(e===`archived-read`),children:(0,X.jsxs)(_.Item,{value:`archived-read`,children:[(0,X.jsxs)(_.Trigger,{className:`group gap-[var(--app-spacing-xs)] text-body-small-default text-[var(--content-tertiary)]`,children:[(0,X.jsx)(p,{size:14,"aria-hidden":!0,className:`shrink-0 transition-transform group-data-[state=open]:rotate-90`}),(0,X.jsxs)(`span`,{children:[`Earlier (`,x.length,`)`]})]}),(0,X.jsx)(_.Content,{children:(0,X.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)] pt-[var(--app-spacing-sm)]`,children:x.map(e=>(0,X.jsx)(j,{item:e,isActive:e.id===t,validConversationIds:n,onSelect:r,onDismiss:i,onToggleRead:o,onGoToThread:s},e.id))})})]})}),T.length>0&&(0,X.jsx)(_.Root,{type:`single`,collapsible:!0,value:f?`dismissed`:``,onValueChange:e=>m?.(e===`dismissed`),children:(0,X.jsxs)(_.Item,{value:`dismissed`,children:[(0,X.jsxs)(_.Trigger,{className:`group gap-[var(--app-spacing-xs)] text-body-small-default text-[var(--content-tertiary)]`,children:[(0,X.jsx)(p,{size:14,"aria-hidden":!0,className:`shrink-0 transition-transform group-data-[state=open]:rotate-90`}),(0,X.jsxs)(`span`,{children:[`Dismissed (`,T.length,`)`]})]}),(0,X.jsx)(_.Content,{children:(0,X.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xs)] pt-[var(--app-spacing-sm)]`,children:T.map(e=>(0,X.jsx)(j,{item:e,onSelect:r,onDismiss:a,trailingAction:`restore`},e.id))})})]})})]})}function he(){return(0,X.jsx)(`h1`,{className:`shrink-0 text-title-large text-[var(--content-default)]`,children:`Activity`})}function ge(e){let t=o(),n=(0,Y.useMemo)(()=>b({path:{assistant_id:e??``}}),[e]),r=s({...y({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4}),i=(0,Y.useCallback)(()=>{e&&t.invalidateQueries({queryKey:n})},[e,t,n]);return{...r,invalidate:i}}function _e(){return(0,X.jsxs)(`div`,{className:`flex flex-col gap-[var(--app-spacing-xl)]`,children:[(0,X.jsx)(`div`,{className:`h-7 w-64 animate-pulse rounded-md bg-[var(--surface-lift)]`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-[var(--app-spacing-sm)]`,children:Array.from({length:4},(e,t)=>(0,X.jsx)(`div`,{className:`h-16 animate-pulse rounded-md bg-[var(--surface-lift)]`},t))})]})}function ve(e){let t=e?.metadata?.scheduleId;return typeof t==`string`&&t.length>0?t:null}function ye({assistantId:e,validConversationIds:t,onOpenConversation:n,onViewSchedule:i,initialFeedItemId:a,navigationKey:o,onInitialFeedItemConsumed:c}){let l=D(),u=H(e);ge(e);let{data:d}=s(K(e)),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(!1),v=(0,Y.useCallback)(e=>{e.status===`new`?(p({...e,status:`seen`}),u.updateStatus.mutate({itemId:e.id,status:`seen`})):p(e)},[u.updateStatus]),y=(0,Y.useCallback)(()=>{p(null)},[]),b=(0,Y.useCallback)(e=>{u.updateStatus.mutate({itemId:e,status:`dismissed`}),f?.id===e&&p(null)},[u.updateStatus,f?.id]),x=(0,Y.useCallback)(e=>{u.updateStatus.mutate({itemId:e,status:`seen`}),p(t=>t?.id===e?{...t,status:`seen`}:t)},[u.updateStatus]),S=(0,Y.useCallback)((e,t)=>{u.updateStatus.mutate({itemId:e,status:t}),p(n=>n?.id===e?{...n,status:t}:n)},[u.updateStatus]),C=(0,Y.useCallback)(e=>{p(null),n(e)},[n]),w=u.data?.items??[],[T,E]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!a||o===T||u.isLoading)return;E(o??null);let e=w.find(e=>e.id===a);e&&e.status!==`dismissed`&&v(e),c?.()},[a,o,T,u.isLoading,w,v,c]);let O=re(w),k=O.filter(e=>e.status===`new`).length,A=O.length,j=ee(),M=(0,Y.useCallback)(()=>{u.markAll.mutate(te(O))},[u.markAll,O]),N=(0,Y.useCallback)(()=>{u.markAll.mutate(ne(O)),p(null)},[u.markAll,O]),P=ve(f),F=P!=null&&(d??[]).some(e=>e.id===P),I=f?(0,X.jsx)(de,{item:f,isMobile:l,validConversationIds:t,onClose:y,onGoToThread:C,onUpdateStatus:S,onDismiss:b,onViewSchedule:F?()=>i(P):void 0}):null,L=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-[var(--app-spacing-lg)] overflow-y-auto`,children:[u.isError?(0,X.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-[var(--system-negative-weak)] bg-[var(--system-negative-weak)] px-[var(--app-spacing-lg)] py-[var(--app-spacing-md)] text-[var(--system-negative-strong)]`,children:[`Couldn't load home feed`,u.error instanceof Error?`: ${u.error.message}`:`.`]}):null,j&&(k>0||A>0)&&(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-[var(--app-spacing-sm)]`,children:[k>0&&(0,X.jsx)(r,{variant:`ghost`,size:`compact`,onClick:M,disabled:u.markAll.isPending,children:`Mark all as read`}),A>0&&(0,X.jsx)(r,{variant:`ghost`,size:`compact`,onClick:N,disabled:u.markAll.isPending,children:`Clear all`})]}),(0,X.jsx)(me,{items:w,selectedItemId:f?.id,validConversationIds:t,onSelectItem:v,onDismissItem:b,onRestoreItem:x,onToggleRead:S,onGoToThread:C,archivedOpen:m,onArchivedOpenChange:h,dismissedOpen:g,onDismissedOpenChange:_})]}),R=I&&!l?(0,X.jsx)(G,{storageKey:`homeDetailDrawerWidth`,detailKey:f?.id,section:L,detail:I}):L,z=u.isLoading?(0,X.jsx)(_e,{}):(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-[var(--app-spacing-xl)]`,children:[l?null:(0,X.jsx)(he,{}),R]});return I&&l?(0,X.jsx)(J,{children:I}):(0,X.jsx)(W,{children:z})}function be(){let e=a(),t=i(),n=U(),r=t.state?.feedItemId??null,o=(0,Y.useCallback)(()=>{e(t.pathname+t.search,{replace:!0})},[e,t.pathname,t.search]),s=T.use.setTopBarCenter(),c=D(),{conversations:u}=O(n),{conversations:d}=w(n,!0),{conversations:f}=k(n,!0),p=(0,Y.useMemo)(()=>new Set(S(u,d,f).map(e=>e.conversationId)),[u,d,f]);return(0,Y.useEffect)(()=>(s(c?(0,X.jsx)(l,{variant:`body-medium-default`,className:`text-[var(--content-secondary)]`,children:`Activity`}):null),()=>{s(null)}),[c,s]),(0,X.jsx)(ye,{assistantId:n,validConversationIds:p,initialFeedItemId:r,navigationKey:t.key,onInitialFeedItemConsumed:o,onOpenConversation:t=>e(x.conversation(t)),onViewSchedule:t=>e(x.schedules.detail(t))})}export{be as HomePageRoute};