@vellumai/web 0.10.5-staging.2 → 0.10.5-staging.3

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 (78) hide show
  1. package/dist/assets/{account-page-D7N_WAt8.js → account-page-B4_qrJXM.js} +1 -1
  2. package/dist/assets/{acp-run-detail-panel-DGXWy1zV.js → acp-run-detail-panel-ZJb9mPFf.js} +1 -1
  3. package/dist/assets/{advanced-page-CA-Fynld.js → advanced-page-BsF8JW-4.js} +1 -1
  4. package/dist/assets/{ai-page-zZGFrEzO.js → ai-page-BNaD9M7D.js} +1 -1
  5. package/dist/assets/{api-key-screen-CUEhMjCI.js → api-key-screen-DiW5rDSM.js} +1 -1
  6. package/dist/assets/{archive-page-hU8w9ytm.js → archive-page-DZ_8uaQt.js} +1 -1
  7. package/dist/assets/{background-task-detail-panel-BbCZGqHm.js → background-task-detail-panel-DRBcuGts.js} +1 -1
  8. package/dist/assets/{billing-page-DvW9-kBw.js → billing-page-Rw3ECU55.js} +1 -1
  9. package/dist/assets/{bookmarks-page-DnqyJXnk.js → bookmarks-page-DmPcHyC_.js} +1 -1
  10. package/dist/assets/{command-palette-B0pI8wFe.js → command-palette-DkJaPl6x.js} +1 -1
  11. package/dist/assets/{command-palette-window-page-BgQhfKX5.js → command-palette-window-page-v-j032zP.js} +1 -1
  12. package/dist/assets/{community-page-D85Cmkcv.js → community-page-BZ9IruGQ.js} +1 -1
  13. package/dist/assets/{contacts-page-route-BZz1O1XL.js → contacts-page-route-iggE95MQ.js} +1 -1
  14. package/dist/assets/{debug-page-BA2gOVPd.js → debug-page-DhYoaQMd.js} +1 -1
  15. package/dist/assets/{deploy-dialogs-wNJRqYiu.js → deploy-dialogs-Cbti_xsn.js} +1 -1
  16. package/dist/assets/{detail-panel-stop-button-Dc3MB_3r.js → detail-panel-stop-button-BHEQd627.js} +1 -1
  17. package/dist/assets/detail-shell-CPp3KhI8.js +4 -0
  18. package/dist/assets/{developer-page-B9c_NOq0.js → developer-page-D0Ttwt5o.js} +1 -1
  19. package/dist/assets/{devices-page-C_MPiuEN.js → devices-page-CkA_1aNA.js} +1 -1
  20. package/dist/assets/{dictation-overlay-page-dlmrZeaQ.js → dictation-overlay-page-BHrUGwJK.js} +1 -1
  21. package/dist/assets/{document-viewer-page-CVJKsLcz.js → document-viewer-page-CnFgbOqH.js} +1 -1
  22. package/dist/assets/{earn-credits-modal-gdB0QAos.js → earn-credits-modal-DOIDaArW.js} +1 -1
  23. package/dist/assets/{emails-page-wOQsKKch.js → emails-page-B0bc-Gj2.js} +1 -1
  24. package/dist/assets/{file-editor-sKfnpW-D.js → file-editor-Bm5LJXwA.js} +1 -1
  25. package/dist/assets/{general-page-C0EgypjR.js → general-page-Df1AoP_V.js} +1 -1
  26. package/dist/assets/{hatching-screen-B4dscGGq.js → hatching-screen-CENPVFoZ.js} +1 -1
  27. package/dist/assets/{home-page-route-BYUiByXT.js → home-page-route-mQBcsrfW.js} +1 -1
  28. package/dist/assets/{hosting-screen-oFxveMgT.js → hosting-screen-I6v4dE5d.js} +1 -1
  29. package/dist/assets/{identity-page-route-jU_Rzwhx.js → identity-page-route-DlM3U1hC.js} +1 -1
  30. package/dist/assets/index-B-S-gNKm.js +131 -0
  31. package/dist/assets/{inspect-page-BKOxlmBF.js → inspect-page-BIEfENnw.js} +1 -1
  32. package/dist/assets/{install-C22EWSPL.js → install-lYdVLxh2.js} +1 -1
  33. package/dist/assets/{integrations-page-BBcBVFLT.js → integrations-page-BBZ2VFVI.js} +1 -1
  34. package/dist/assets/{intelligence-layout-BqECxena.js → intelligence-layout-zqIx7Q-I.js} +1 -1
  35. package/dist/assets/{keyboard-shortcuts-page-BZTs62Wj.js → keyboard-shortcuts-page-H4mn2-og.js} +1 -1
  36. package/dist/assets/{library-detail-page-Ck65_rdB.js → library-detail-page-DTbtqnJW.js} +1 -1
  37. package/dist/assets/{library-page-BPrjQGL6.js → library-page-CtniKYuA.js} +1 -1
  38. package/dist/assets/{logout-page-8AH_ZU_7.js → logout-page-BbQCJKwL.js} +1 -1
  39. package/dist/assets/{logs-layout-DD-9gYta.js → logs-layout-xXeY2t6B.js} +1 -1
  40. package/dist/assets/{memory-router-playground-page-BRe1h0Mv.js → memory-router-playground-page-BhFJ0lwa.js} +1 -1
  41. package/dist/assets/{mobile-sidebar-drawer-CzcwUqpn.js → mobile-sidebar-drawer-BA9ERuJ7.js} +1 -1
  42. package/dist/assets/{notifications-page-CNz_ce_3.js → notifications-page-BSwHh8Mx.js} +1 -1
  43. package/dist/assets/{oauth-complete-page-BY4IUzM3.js → oauth-complete-page-KFGDIl3q.js} +1 -1
  44. package/dist/assets/{oauth-popup-complete-page-DFSwc7gE.js → oauth-popup-complete-page-C9FKG9VY.js} +1 -1
  45. package/dist/assets/{pairing-page-rN8Xn7wW.js → pairing-page-CT45DoH8.js} +1 -1
  46. package/dist/assets/{plugins-page-BQcsJgVb.js → plugins-page-H6DAm3HM.js} +1 -1
  47. package/dist/assets/{prechat-route-6ome-g7N.js → prechat-route-BfQPMYu8.js} +1 -1
  48. package/dist/assets/{privacy-page-DtQMDaEM.js → privacy-page-CLJnEPBh.js} +1 -1
  49. package/dist/assets/{privacy-screen-DdeTm5d2.js → privacy-screen-DWLF6KuW.js} +1 -1
  50. package/dist/assets/{provider-callback-page-CwplW9PX.js → provider-callback-page-UAlBgfqn.js} +1 -1
  51. package/dist/assets/{research-mock-page-DMXNiiqw.js → research-mock-page-5ewHxOuJ.js} +1 -1
  52. package/dist/assets/{research-onboarding-route-BYbFY_h9.js → research-onboarding-route-RxDDgsKx.js} +1 -1
  53. package/dist/assets/{review-terms-screen-73sQOI_T.js → review-terms-screen-BqGwop2y.js} +1 -1
  54. package/dist/assets/{select-assistant-screen-Y_lcjNSt.js → select-assistant-screen-BfhDJw-S.js} +1 -1
  55. package/dist/assets/{settings-layout-B99yx7iZ.js → settings-layout-D_5HXQhT.js} +1 -1
  56. package/dist/assets/{share-feedback-modal-BqFpqbwt.js → share-feedback-modal-B3axmWXR.js} +1 -1
  57. package/dist/assets/{sidebar-tree-nlZD0iQq.js → sidebar-tree-DM30_BN8.js} +1 -1
  58. package/dist/assets/{signup-page-BBz6b3Nv.js → signup-page-DlqG9kP3.js} +1 -1
  59. package/dist/assets/{skills-page-CyNFwtMm.js → skills-page-C303uEzv.js} +1 -1
  60. package/dist/assets/{sounds-page-DTwqrvjQ.js → sounds-page-DC_yF186.js} +1 -1
  61. package/dist/assets/{subagent-detail-panel-B7-EOosT.js → subagent-detail-panel-B69kOmY_.js} +2 -2
  62. package/dist/assets/{system-events-page-kz2QZXlf.js → system-events-page-CMXtS3Lt.js} +1 -1
  63. package/dist/assets/{tiptap-document-editor-BkhvVzHq.js → tiptap-document-editor-BILtD2S2.js} +1 -1
  64. package/dist/assets/{tool-detail-panel-Djpgj3--.js → tool-detail-panel-CG9Wp2NK.js} +2 -2
  65. package/dist/assets/{trace-page-BEyQxpBX.js → trace-page-k0cYj2Bt.js} +1 -1
  66. package/dist/assets/{upgrade-cancel-page-BMj8YpAx.js → upgrade-cancel-page-KGY9H9Mg.js} +1 -1
  67. package/dist/assets/{upgrade-success-page-BZjQzQQB.js → upgrade-success-page-9MHgGZFb.js} +1 -1
  68. package/dist/assets/{usage-page-YnMiaGbU.js → usage-page-CVI5PvbA.js} +1 -1
  69. package/dist/assets/{use-skill-categories-6bE1o8xC.js → use-skill-categories-nKUbiuQn.js} +1 -1
  70. package/dist/assets/{voice-page-CjOnnW4C.js → voice-page-ChYDqNwz.js} +1 -1
  71. package/dist/assets/{weather-forecast-display-Aqhg0YWH.js → weather-forecast-display-DaU-H5wf.js} +1 -1
  72. package/dist/assets/{welcome-screen-BYiDdI6u.js → welcome-screen-1tj61zH7.js} +1 -1
  73. package/dist/assets/{workflow-detail-panel-CEiMuzvs.js → workflow-detail-panel-Di63Av9t.js} +1 -1
  74. package/dist/assets/{workspace-page-CeCbEfiQ.js → workspace-page-C5nupXN6.js} +1 -1
  75. package/dist/index.html +2 -2
  76. package/package.json +1 -1
  77. package/dist/assets/detail-shell-CyXDiAEa.js +0 -4
  78. package/dist/assets/index-CZ2UBc_U.js +0 -130
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{d as n,p as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-BscuIPxA.js";import"./src-SCpl1O1B.js";import{n as o}from"./resolved-assistants-store-Dqf0LJrA.js";import{t as s}from"./loader-circle-BFRVtR3K.js";import{ht as c,mt as l,pt as u}from"./sdk.gen-zA5ns5LT.js";import{a as d}from"./routes-C6gxiCrz.js";import{t as f}from"./use-bus-subscription-BNaztnO7.js";import{n as p}from"./viewer-store-BR99G-Ii.js";import{r as m,t as h}from"./edit-chat-session-DcCgw5Qy.js";import{Dt as g}from"./index-CZ2UBc_U.js";var _=e(t(),1);function v({surfaceId:e,enabled:t,onCommentsChanged:n}){let r=(0,_.useRef)(n);return(0,_.useLayoutEffect)(()=>{r.current=n},[n]),(0,_.useCallback)(n=>{if(!t)return;let i=n.message;switch(i.type){case`document_comment_created`:case`document_comment_resolved`:case`document_comment_reopened`:case`document_comment_deleted`:i.surfaceId===e&&r.current();break;default:break}},[e,t])}var y=i();function b(){let{surfaceId:e}=r(),t=n(),i=o.use.activeAssistantId(),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!0),[w,T]=(0,_.useState)(null),E=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(!e){T(`No document ID provided.`),C(!1);return}if(!i)return;let t=!1;return(async()=>{try{let{data:n}=await l({path:{assistant_id:i,id:e},throwOnError:!0});if(t)return;x(n)}catch{t||T(`Failed to load document.`)}finally{t||C(!1)}})(),()=>{t=!0}},[e,i]);let D=(0,_.useCallback)(()=>{E.current?.refreshComments()},[]);f(`sse.event`,v({surfaceId:e??``,enabled:!!e,onCommentsChanged:D}));let O=(0,_.useCallback)(()=>{t(-1)},[t]),k=(0,_.useCallback)(async()=>{if(!b||!i||!e)return;let n=b.conversationId||h(i,e)||(typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`);if(m(i,e,n),n!==b.conversationId)try{await u({path:{assistant_id:i,id:e},body:{conversationId:n},throwOnError:!0})}catch{}p.getState().openDocument(),p.getState().setLoadedDocument({surfaceId:b.surfaceId,conversationId:n,documentName:b.title,content:b.content});let r=`Please review and address my comments on "${b.title}".`;t(`${d.conversation(n)}?prompt=${encodeURIComponent(r)}`)},[b,i,e,t]),A=(0,_.useCallback)(async()=>{if(!b||!i)return;let{data:e,response:t}=await c({path:{assistant_id:i,id:b.surfaceId},throwOnError:!1,parseAs:`blob`});if(!t?.ok||!e)return;let n=URL.createObjectURL(e);Object.assign(document.createElement(`a`),{href:n,download:`${b.title||`document`}.pdf`}).click(),URL.revokeObjectURL(n)},[b,i]);return S?(0,y.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,y.jsx)(s,{size:24,className:`animate-spin`,style:{color:`var(--content-tertiary)`}})}):w||!b||!i?(0,y.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,y.jsx)(a,{variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:w??`Document not found.`})}):(0,y.jsx)(g,{surfaceId:b.surfaceId,assistantId:i,conversationId:b.conversationId,documentName:b.title,content:b.content,onClose:O,onExport:A,onSubmitFeedback:k,handleRef:E})}export{b as DocumentViewerPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{d as n,p as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-BscuIPxA.js";import"./src-SCpl1O1B.js";import{n as o}from"./resolved-assistants-store-Dqf0LJrA.js";import{t as s}from"./loader-circle-BFRVtR3K.js";import{ht as c,mt as l,pt as u}from"./sdk.gen-zA5ns5LT.js";import{a as d}from"./routes-C6gxiCrz.js";import{t as f}from"./use-bus-subscription-BNaztnO7.js";import{n as p}from"./viewer-store-BR99G-Ii.js";import{r as m,t as h}from"./edit-chat-session-DcCgw5Qy.js";import{Dt as g}from"./index-B-S-gNKm.js";var _=e(t(),1);function v({surfaceId:e,enabled:t,onCommentsChanged:n}){let r=(0,_.useRef)(n);return(0,_.useLayoutEffect)(()=>{r.current=n},[n]),(0,_.useCallback)(n=>{if(!t)return;let i=n.message;switch(i.type){case`document_comment_created`:case`document_comment_resolved`:case`document_comment_reopened`:case`document_comment_deleted`:i.surfaceId===e&&r.current();break;default:break}},[e,t])}var y=i();function b(){let{surfaceId:e}=r(),t=n(),i=o.use.activeAssistantId(),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!0),[w,T]=(0,_.useState)(null),E=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(!e){T(`No document ID provided.`),C(!1);return}if(!i)return;let t=!1;return(async()=>{try{let{data:n}=await l({path:{assistant_id:i,id:e},throwOnError:!0});if(t)return;x(n)}catch{t||T(`Failed to load document.`)}finally{t||C(!1)}})(),()=>{t=!0}},[e,i]);let D=(0,_.useCallback)(()=>{E.current?.refreshComments()},[]);f(`sse.event`,v({surfaceId:e??``,enabled:!!e,onCommentsChanged:D}));let O=(0,_.useCallback)(()=>{t(-1)},[t]),k=(0,_.useCallback)(async()=>{if(!b||!i||!e)return;let n=b.conversationId||h(i,e)||(typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`);if(m(i,e,n),n!==b.conversationId)try{await u({path:{assistant_id:i,id:e},body:{conversationId:n},throwOnError:!0})}catch{}p.getState().openDocument(),p.getState().setLoadedDocument({surfaceId:b.surfaceId,conversationId:n,documentName:b.title,content:b.content});let r=`Please review and address my comments on "${b.title}".`;t(`${d.conversation(n)}?prompt=${encodeURIComponent(r)}`)},[b,i,e,t]),A=(0,_.useCallback)(async()=>{if(!b||!i)return;let{data:e,response:t}=await c({path:{assistant_id:i,id:b.surfaceId},throwOnError:!1,parseAs:`blob`});if(!t?.ok||!e)return;let n=URL.createObjectURL(e);Object.assign(document.createElement(`a`),{href:n,download:`${b.title||`document`}.pdf`}).click(),URL.revokeObjectURL(n)},[b,i]);return S?(0,y.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,y.jsx)(s,{size:24,className:`animate-spin`,style:{color:`var(--content-tertiary)`}})}):w||!b||!i?(0,y.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,y.jsx)(a,{variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:w??`Document not found.`})}):(0,y.jsx)(g,{surfaceId:b.surfaceId,assistantId:i,conversationId:b.conversationId,documentName:b.title,content:b.content,onClose:O,onExport:A,onSubmitFeedback:k,handleRef:E})}export{b as DocumentViewerPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D-AX8Voo.js";import{t as r}from"./useQuery-B45lW1Kk.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import"./src-SCpl1O1B.js";import{t as a}from"./notice-CqRgVmeL.js";import{t as o}from"./input-D4W4p0pZ.js";import{t as s}from"./modal-BNAVT2FK.js";import{t as c}from"./createLucideIcon-BlMXrA59.js";import{t as l}from"./arrow-left-CP-EhDNF.js";import{t as u}from"./check-D6WkI0gF.js";import{t as d}from"./credit-card-BKRB1ZIi.js";import{t as f}from"./loader-circle-BFRVtR3K.js";import{ht as p}from"./react-query.gen-gQ1_8EHv.js";import{da as m,si as h,ta as g}from"./index-CZ2UBc_U.js";var _=c(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),v=e(t(),1),y=i();function b(e){return e.replace(/\.00$/,``)}function x(e,t,n){let r=b(n),i=b(e),a=b(t);return i===a?`Share Vellum with friends — you'll each earn ${i} credits when they sign up, up to ${r} total.`:`Share Vellum with friends — you'll earn ${i} credits and they'll get ${a} when they sign up, up to ${r} total.`}function S({open:e,onClose:t}){return(0,y.jsx)(s.Root,{open:e,onOpenChange:e=>{e||t()},children:e?(0,y.jsx)(C,{}):null})}function C(){let[e,t]=(0,v.useState)(!1),[i,c]=(0,v.useState)(!1),{data:S,isLoading:C,isError:D,refetch:O,isFetching:k}=r(p()),A=(0,v.useCallback)(e=>{navigator.clipboard.writeText(e).then(()=>{t(!0),setTimeout(()=>t(!1),2e3)})},[]),j=S?.is_eligible_for_credits===!1,M=S?j?`Invite friends to Vellum. You'll start earning referral credits once you've purchased credits or upgraded to Pro.`:x(S.referrer_credit_amount,S.credit_amount,S.earning_cap):`Refer friends to earn free credits.`,N=S?b(S.earning_cap):``,P=i?`Referral Program Terms`:`Earn free credits`;return(0,y.jsxs)(s.Content,{size:`sm`,children:[(0,y.jsx)(s.Header,{children:(0,y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[i&&(0,y.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:(0,y.jsx)(l,{}),onClick:()=>c(!1),"aria-label":`Back`,className:`mt-0.5`,tintColor:`var(--content-secondary)`}),(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(s.Title,{children:P}),!i&&(0,y.jsx)(s.Description,{children:M})]})]})}),(0,y.jsx)(s.Body,{children:i&&S?(0,y.jsx)(E,{cap:N}):C?(0,y.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[(0,y.jsx)(f,{className:`h-4 w-4 animate-spin`}),`Loading referral information…`]}):D||!S?(0,y.jsxs)(`div`,{className:`space-y-3`,children:[(0,y.jsx)(`p`,{className:`!m-0 text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:`Failed to load referral information.`}),(0,y.jsx)(n,{variant:`outlined`,onClick:()=>void O(),disabled:k,children:k?`Retrying…`:`Try Again`})]}):(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(w,{icon:(0,y.jsx)(_,{className:`h-4 w-4`}),label:`Share your invite link`}),(0,y.jsx)(w,{icon:(0,y.jsx)(h,{className:`h-4 w-4`}),label:`They sign up`}),(0,y.jsx)(w,{icon:(0,y.jsx)(g,{className:`h-4 w-4`}),label:j?`You earn credits — once you've purchased credits or upgraded to Pro`:`You earn credits`})]}),(0,y.jsx)(`div`,{style:{borderTop:`1px solid var(--border-base)`}}),j&&(0,y.jsx)(a,{tone:`info`,children:`You're not currently earning referral credits. Buy credits or upgrade to Pro to start earning — your invite link still works in the meantime.`}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(o,{type:`text`,readOnly:!0,value:S.referral_url,fullWidth:!0,wrapperClassName:`flex-1`,className:`font-mono`,onFocus:e=>e.currentTarget.select()}),(0,y.jsx)(n,{variant:`outlined`,iconOnly:e?(0,y.jsx)(u,{}):(0,y.jsx)(m,{}),onClick:()=>A(S.referral_url),"aria-label":`Copy referral link`,className:`h-9 w-9`})]}),(0,y.jsx)(`div`,{style:{borderTop:`1px solid var(--border-base)`}}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,y.jsx)(T,{icon:(0,y.jsx)(h,{className:`h-3.5 w-3.5`}),value:String(S.referred_count),label:`Friends Referred`}),(0,y.jsx)(T,{icon:(0,y.jsx)(d,{className:`h-3.5 w-3.5`}),value:b(S.total_earned),label:`Credits Earned`})]}),(0,y.jsx)(`div`,{style:{borderTop:`1px solid var(--border-base)`}}),(0,y.jsx)(n,{variant:`ghost`,size:`compact`,onClick:()=>c(!0),fullWidth:!0,className:`text-body-small-default`,tintColor:`var(--content-tertiary)`,children:`View Terms and Conditions`})]})})]})}function w({icon:e,label:t}){return(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`,color:`var(--content-secondary)`},children:e}),(0,y.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:t})]})}function T({icon:e,value:t,label:n}){return(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-body-medium-lighter`,children:[(0,y.jsx)(`span`,{style:{color:`var(--content-tertiary)`},children:e}),(0,y.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:t}),(0,y.jsx)(`span`,{style:{color:`var(--content-tertiary)`},children:n})]})}function E({cap:e}){return(0,y.jsx)(`ul`,{className:`!m-0 !list-none space-y-2 !p-0`,children:[`This promotion is available to new users who sign up through your referral link only.`,`Rewards are earned once your invitee completes the creation of their Vellum account.`,`You may earn up to ${e} free credits through the Referral Program. We may change this limit at any time.`,`We do not grant credits for disposable or high-risk email accounts.`,`Each new user can generate only one (1) reward. No stacking or loophole hunting.`,`Please avoid spamming or misusing your referral link. Our systems actively monitor referral engagement.`,`If we detect suspicious or non-compliant activity, we reserve the right to withhold rewards or deactivate your referral link.`,`We may update, pause, or discontinue this program at any time.`].map(e=>(0,y.jsxs)(`li`,{className:`flex items-start gap-2 text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:[(0,y.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5`,children:`•`}),(0,y.jsx)(`span`,{children:e})]},e))})}export{S as EarnCreditsModal};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D-AX8Voo.js";import{t as r}from"./useQuery-B45lW1Kk.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import"./src-SCpl1O1B.js";import{t as a}from"./notice-CqRgVmeL.js";import{t as o}from"./input-D4W4p0pZ.js";import{t as s}from"./modal-BNAVT2FK.js";import{t as c}from"./createLucideIcon-BlMXrA59.js";import{t as l}from"./arrow-left-CP-EhDNF.js";import{t as u}from"./check-D6WkI0gF.js";import{t as d}from"./credit-card-BKRB1ZIi.js";import{t as f}from"./loader-circle-BFRVtR3K.js";import{ht as p}from"./react-query.gen-gQ1_8EHv.js";import{da as m,si as h,ta as g}from"./index-B-S-gNKm.js";var _=c(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),v=e(t(),1),y=i();function b(e){return e.replace(/\.00$/,``)}function x(e,t,n){let r=b(n),i=b(e),a=b(t);return i===a?`Share Vellum with friends — you'll each earn ${i} credits when they sign up, up to ${r} total.`:`Share Vellum with friends — you'll earn ${i} credits and they'll get ${a} when they sign up, up to ${r} total.`}function S({open:e,onClose:t}){return(0,y.jsx)(s.Root,{open:e,onOpenChange:e=>{e||t()},children:e?(0,y.jsx)(C,{}):null})}function C(){let[e,t]=(0,v.useState)(!1),[i,c]=(0,v.useState)(!1),{data:S,isLoading:C,isError:D,refetch:O,isFetching:k}=r(p()),A=(0,v.useCallback)(e=>{navigator.clipboard.writeText(e).then(()=>{t(!0),setTimeout(()=>t(!1),2e3)})},[]),j=S?.is_eligible_for_credits===!1,M=S?j?`Invite friends to Vellum. You'll start earning referral credits once you've purchased credits or upgraded to Pro.`:x(S.referrer_credit_amount,S.credit_amount,S.earning_cap):`Refer friends to earn free credits.`,N=S?b(S.earning_cap):``,P=i?`Referral Program Terms`:`Earn free credits`;return(0,y.jsxs)(s.Content,{size:`sm`,children:[(0,y.jsx)(s.Header,{children:(0,y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[i&&(0,y.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:(0,y.jsx)(l,{}),onClick:()=>c(!1),"aria-label":`Back`,className:`mt-0.5`,tintColor:`var(--content-secondary)`}),(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(s.Title,{children:P}),!i&&(0,y.jsx)(s.Description,{children:M})]})]})}),(0,y.jsx)(s.Body,{children:i&&S?(0,y.jsx)(E,{cap:N}):C?(0,y.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[(0,y.jsx)(f,{className:`h-4 w-4 animate-spin`}),`Loading referral information…`]}):D||!S?(0,y.jsxs)(`div`,{className:`space-y-3`,children:[(0,y.jsx)(`p`,{className:`!m-0 text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:`Failed to load referral information.`}),(0,y.jsx)(n,{variant:`outlined`,onClick:()=>void O(),disabled:k,children:k?`Retrying…`:`Try Again`})]}):(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(w,{icon:(0,y.jsx)(_,{className:`h-4 w-4`}),label:`Share your invite link`}),(0,y.jsx)(w,{icon:(0,y.jsx)(h,{className:`h-4 w-4`}),label:`They sign up`}),(0,y.jsx)(w,{icon:(0,y.jsx)(g,{className:`h-4 w-4`}),label:j?`You earn credits — once you've purchased credits or upgraded to Pro`:`You earn credits`})]}),(0,y.jsx)(`div`,{style:{borderTop:`1px solid var(--border-base)`}}),j&&(0,y.jsx)(a,{tone:`info`,children:`You're not currently earning referral credits. Buy credits or upgrade to Pro to start earning — your invite link still works in the meantime.`}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(o,{type:`text`,readOnly:!0,value:S.referral_url,fullWidth:!0,wrapperClassName:`flex-1`,className:`font-mono`,onFocus:e=>e.currentTarget.select()}),(0,y.jsx)(n,{variant:`outlined`,iconOnly:e?(0,y.jsx)(u,{}):(0,y.jsx)(m,{}),onClick:()=>A(S.referral_url),"aria-label":`Copy referral link`,className:`h-9 w-9`})]}),(0,y.jsx)(`div`,{style:{borderTop:`1px solid var(--border-base)`}}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,y.jsx)(T,{icon:(0,y.jsx)(h,{className:`h-3.5 w-3.5`}),value:String(S.referred_count),label:`Friends Referred`}),(0,y.jsx)(T,{icon:(0,y.jsx)(d,{className:`h-3.5 w-3.5`}),value:b(S.total_earned),label:`Credits Earned`})]}),(0,y.jsx)(`div`,{style:{borderTop:`1px solid var(--border-base)`}}),(0,y.jsx)(n,{variant:`ghost`,size:`compact`,onClick:()=>c(!0),fullWidth:!0,className:`text-body-small-default`,tintColor:`var(--content-tertiary)`,children:`View Terms and Conditions`})]})})]})}function w({icon:e,label:t}){return(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`,color:`var(--content-secondary)`},children:e}),(0,y.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:t})]})}function T({icon:e,value:t,label:n}){return(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-body-medium-lighter`,children:[(0,y.jsx)(`span`,{style:{color:`var(--content-tertiary)`},children:e}),(0,y.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:t}),(0,y.jsx)(`span`,{style:{color:`var(--content-tertiary)`},children:n})]})}function E({cap:e}){return(0,y.jsx)(`ul`,{className:`!m-0 !list-none space-y-2 !p-0`,children:[`This promotion is available to new users who sign up through your referral link only.`,`Rewards are earned once your invitee completes the creation of their Vellum account.`,`You may earn up to ${e} free credits through the Referral Program. We may change this limit at any time.`,`We do not grant credits for disposable or high-risk email accounts.`,`Each new user can generate only one (1) reward. No stacking or loophole hunting.`,`Please avoid spamming or misusing your referral link. Our systems actively monitor referral engagement.`,`If we detect suspicious or non-compliant activity, we reserve the right to withhold rewards or deactivate your referral link.`,`We may update, pause, or discontinue this program at any time.`].map(e=>(0,y.jsxs)(`li`,{className:`flex items-start gap-2 text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:[(0,y.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5`,children:`•`}),(0,y.jsx)(`span`,{children:e})]},e))})}export{S as EarnCreditsModal};
@@ -1 +1 @@
1
- import{r as e,t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./useQuery-B45lW1Kk.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import"./src-SCpl1O1B.js";import{t as i}from"./tag-CW6WC4fE.js";import{t as a}from"./loader-circle-BFRVtR3K.js";import{t as o}from"./triangle-alert-C3aHZq1F.js";import{a as s}from"./routes-C6gxiCrz.js";import{_ as c,h as l,p as u}from"./react-query.gen-gQ1_8EHv.js";import{Fr as d,Zi as f,x as p,xi as m,ya as h}from"./index-CZ2UBc_U.js";import{t as g}from"./use-active-assistant-id-BVzVN4_g.js";var _=r();function v(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function y({title:e,children:t}){return(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:e}),t]})}function b({tone:e=`info`,children:t}){let n=e===`error`;return(0,_.jsx)(`div`,{className:`rounded-md border px-4 py-3 text-body-medium-lighter`,style:{background:n?`var(--surface-negative-subtle, var(--surface-lift))`:`var(--surface-lift)`,borderColor:n?`var(--border-negative, var(--border-base))`:`var(--border-base)`,color:n?`var(--content-negative, var(--content-default))`:`var(--content-default)`},children:(0,_.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n&&(0,_.jsx)(o,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,_.jsx)(`div`,{className:`flex-1`,children:t})]})})}function x({message:e,onRetry:t,retrying:n}){return(0,_.jsx)(b,{tone:`error`,children:(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,_.jsx)(`span`,{children:e}),(0,_.jsx)(`button`,{type:`button`,onClick:t,disabled:n,className:`text-body-small-default underline disabled:opacity-50`,style:{color:`var(--content-default)`},children:n?`Retrying…`:`Retry`})]})})}function S({label:e,value:t,sub:n}){return(0,_.jsxs)(`div`,{className:`rounded-xl border p-3`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:[(0,_.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e}),(0,_.jsx)(`p`,{className:`mt-1 text-title-large tabular-nums`,style:{color:`var(--content-default)`},children:t??`—`}),n&&(0,_.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-disabled)`},children:n})]})}function C({email:e}){let t=e.direction===`inbound`;return(0,_.jsx)(`div`,{className:`rounded-xl border p-4`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,_.jsx)(i,{tone:t?`positive`:`neutral`,leftIcon:t?(0,_.jsx)(f,{}):(0,_.jsx)(m,{}),children:t?`Inbound`:`Outbound`}),(0,_.jsx)(`span`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e.from_address})]}),(0,_.jsx)(`p`,{className:`truncate text-body-medium-default`,style:{color:`var(--content-default)`},children:e.subject||`(no subject)`})]}),(0,_.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[(0,_.jsx)(h,{className:`h-3 w-3`}),(0,_.jsx)(`span`,{children:v(e.created_at)})]})]})})}function w({assistantId:e,platformGate:r}){let i=r===`full`,o=n({...u({path:{assistant_id:e}}),enabled:i}),d=o.data?.results?.[0],f=n({...l({path:{assistant_id:e,id:d?.id??``}}),enabled:i&&!!d?.id}),p=n({...c({path:{assistant_id:e},query:{limit:10}}),enabled:i}),m=f.data?.usage,h=p.data?.results??[];return o.isLoading?(0,_.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,_.jsx)(a,{className:`h-8 w-8 animate-spin`,style:{color:`var(--content-tertiary)`}})}):o.isError?(0,_.jsx)(x,{message:`Couldn't load email addresses.`,onRetry:()=>{o.refetch()},retrying:o.isFetching}):d?(0,_.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,_.jsx)(y,{title:`Totals`,children:(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,_.jsx)(S,{label:`Sent today`,value:m?.sent_today,sub:m?`of ${m.daily_limit} daily limit`:void 0}),(0,_.jsx)(S,{label:`Received today`,value:m?.received_today}),(0,_.jsx)(S,{label:`Sent this month`,value:m?.sent_this_month}),(0,_.jsx)(S,{label:`Received this month`,value:m?.received_this_month})]})}),(0,_.jsx)(y,{title:`Recent Emails`,children:p.isLoading?(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[(0,_.jsx)(a,{className:`h-4 w-4 animate-spin`}),`Loading…`]}):p.isError?(0,_.jsx)(x,{message:`Couldn't load recent emails.`,onRetry:()=>{p.refetch()},retrying:p.isFetching}):h.length===0?(0,_.jsx)(b,{children:`No emails yet.`}):(0,_.jsx)(`div`,{className:`space-y-2`,children:h.map(e=>(0,_.jsx)(C,{email:e},e.id))})})]}):(0,_.jsxs)(b,{children:[`No email address registered yet.`,` `,(0,_.jsx)(t,{to:s.settings.ai,className:`underline`,style:{color:`var(--content-tertiary)`},children:`Set one up in AI Settings → Email.`})]})}function T(){let t=d(),n=g();return t===`gated`?(0,_.jsx)(e,{replace:!0,to:s.logs.root}):t===`disabled`?(0,_.jsx)(p,{children:`Log in to the Vellum platform to view emails.`}):(0,_.jsx)(w,{assistantId:n,platformGate:t})}export{T as EmailsPage};
1
+ import{r as e,t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./useQuery-B45lW1Kk.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import"./src-SCpl1O1B.js";import{t as i}from"./tag-CW6WC4fE.js";import{t as a}from"./loader-circle-BFRVtR3K.js";import{t as o}from"./triangle-alert-C3aHZq1F.js";import{a as s}from"./routes-C6gxiCrz.js";import{_ as c,h as l,p as u}from"./react-query.gen-gQ1_8EHv.js";import{Fr as d,Zi as f,x as p,xi as m,ya as h}from"./index-B-S-gNKm.js";import{t as g}from"./use-active-assistant-id-BVzVN4_g.js";var _=r();function v(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function y({title:e,children:t}){return(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:e}),t]})}function b({tone:e=`info`,children:t}){let n=e===`error`;return(0,_.jsx)(`div`,{className:`rounded-md border px-4 py-3 text-body-medium-lighter`,style:{background:n?`var(--surface-negative-subtle, var(--surface-lift))`:`var(--surface-lift)`,borderColor:n?`var(--border-negative, var(--border-base))`:`var(--border-base)`,color:n?`var(--content-negative, var(--content-default))`:`var(--content-default)`},children:(0,_.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n&&(0,_.jsx)(o,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,_.jsx)(`div`,{className:`flex-1`,children:t})]})})}function x({message:e,onRetry:t,retrying:n}){return(0,_.jsx)(b,{tone:`error`,children:(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,_.jsx)(`span`,{children:e}),(0,_.jsx)(`button`,{type:`button`,onClick:t,disabled:n,className:`text-body-small-default underline disabled:opacity-50`,style:{color:`var(--content-default)`},children:n?`Retrying…`:`Retry`})]})})}function S({label:e,value:t,sub:n}){return(0,_.jsxs)(`div`,{className:`rounded-xl border p-3`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:[(0,_.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e}),(0,_.jsx)(`p`,{className:`mt-1 text-title-large tabular-nums`,style:{color:`var(--content-default)`},children:t??`—`}),n&&(0,_.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-disabled)`},children:n})]})}function C({email:e}){let t=e.direction===`inbound`;return(0,_.jsx)(`div`,{className:`rounded-xl border p-4`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,_.jsx)(i,{tone:t?`positive`:`neutral`,leftIcon:t?(0,_.jsx)(f,{}):(0,_.jsx)(m,{}),children:t?`Inbound`:`Outbound`}),(0,_.jsx)(`span`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e.from_address})]}),(0,_.jsx)(`p`,{className:`truncate text-body-medium-default`,style:{color:`var(--content-default)`},children:e.subject||`(no subject)`})]}),(0,_.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[(0,_.jsx)(h,{className:`h-3 w-3`}),(0,_.jsx)(`span`,{children:v(e.created_at)})]})]})})}function w({assistantId:e,platformGate:r}){let i=r===`full`,o=n({...u({path:{assistant_id:e}}),enabled:i}),d=o.data?.results?.[0],f=n({...l({path:{assistant_id:e,id:d?.id??``}}),enabled:i&&!!d?.id}),p=n({...c({path:{assistant_id:e},query:{limit:10}}),enabled:i}),m=f.data?.usage,h=p.data?.results??[];return o.isLoading?(0,_.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,_.jsx)(a,{className:`h-8 w-8 animate-spin`,style:{color:`var(--content-tertiary)`}})}):o.isError?(0,_.jsx)(x,{message:`Couldn't load email addresses.`,onRetry:()=>{o.refetch()},retrying:o.isFetching}):d?(0,_.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,_.jsx)(y,{title:`Totals`,children:(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,_.jsx)(S,{label:`Sent today`,value:m?.sent_today,sub:m?`of ${m.daily_limit} daily limit`:void 0}),(0,_.jsx)(S,{label:`Received today`,value:m?.received_today}),(0,_.jsx)(S,{label:`Sent this month`,value:m?.sent_this_month}),(0,_.jsx)(S,{label:`Received this month`,value:m?.received_this_month})]})}),(0,_.jsx)(y,{title:`Recent Emails`,children:p.isLoading?(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[(0,_.jsx)(a,{className:`h-4 w-4 animate-spin`}),`Loading…`]}):p.isError?(0,_.jsx)(x,{message:`Couldn't load recent emails.`,onRetry:()=>{p.refetch()},retrying:p.isFetching}):h.length===0?(0,_.jsx)(b,{children:`No emails yet.`}):(0,_.jsx)(`div`,{className:`space-y-2`,children:h.map(e=>(0,_.jsx)(C,{email:e},e.id))})})]}):(0,_.jsxs)(b,{children:[`No email address registered yet.`,` `,(0,_.jsx)(t,{to:s.settings.ai,className:`underline`,style:{color:`var(--content-tertiary)`},children:`Set one up in AI Settings → Email.`})]})}function T(){let t=d(),n=g();return t===`gated`?(0,_.jsx)(e,{replace:!0,to:s.logs.root}):t===`disabled`?(0,_.jsx)(p,{children:`Log in to the Vellum platform to view emails.`}):(0,_.jsx)(w,{assistantId:n,platformGate:t})}export{T as EmailsPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D-AX8Voo.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./check-D6WkI0gF.js";import{t as a}from"./pencil-B90pDI55.js";import{da as o,ua as s}from"./index-CZ2UBc_U.js";var c=e(t(),1),l=r(),u=`ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace`;function d({content:e,downloadContent:t,fileName:r,mimeType:u=`text/plain`,showEdit:d,isEditing:f,onToggleEdit:p,extraActions:m}){let[h,g]=(0,c.useState)(!1),_=(0,c.useRef)(null),v=(0,c.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{g(!0),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>g(!1),1500)})},[e]),y=t??e,b=(0,c.useCallback)(()=>{let e=new Blob([y],{type:u}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=r,n.click(),URL.revokeObjectURL(t)},[y,r,u]);return(0,c.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]),f?null:(0,l.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex items-center gap-1 rounded-md bg-[var(--surface-primary)] shadow-sm`,children:[d&&p&&(0,l.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:(0,l.jsx)(a,{"aria-hidden":!0}),onClick:p,"aria-label":`Edit file`,className:`hover:bg-[var(--surface-base)]`}),m,(0,l.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:h?(0,l.jsx)(i,{"aria-hidden":!0}):(0,l.jsx)(o,{"aria-hidden":!0}),onClick:v,"aria-label":h?`Copied`:`Copy file contents`,className:`hover:bg-[var(--surface-base)]`}),(0,l.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:(0,l.jsx)(s,{"aria-hidden":!0}),onClick:b,"aria-label":`Download file`,className:`hover:bg-[var(--surface-base)]`})]})}function f({value:e,onChange:t,onSave:n}){return(0,l.jsx)(`textarea`,{className:`m-0 h-full w-full resize-none overflow-auto border-none bg-transparent p-4 text-body-medium-lighter leading-relaxed outline-none`,style:{color:`var(--content-default)`,fontFamily:u},value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),n())},spellCheck:!1})}function p({isDirty:e,isSaving:t,error:r,onSave:i,onDiscard:a}){return(0,l.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t px-3 py-2`,style:{borderColor:`var(--border-element)`},children:[r&&(0,l.jsx)(`span`,{className:`mr-auto text-body-small-default`,style:{color:`var(--system-error)`},children:r}),(0,l.jsx)(n,{variant:`ghost`,size:`compact`,disabled:t,onClick:a,children:`Discard`}),(0,l.jsx)(n,{variant:`primary`,size:`compact`,disabled:!e||t,onClick:i,children:t?`Saving…`:`Save`})]})}function m({content:e,readOnly:t,whiteSpace:n=`pre-wrap`,onStartEdit:r}){return(0,l.jsx)(`pre`,{className:`m-0 h-full overflow-auto p-4 text-body-medium-lighter leading-relaxed${t?``:` cursor-text`}`,style:{color:`var(--content-default)`,fontFamily:u,whiteSpace:n},onClick:t?void 0:r,children:e})}export{m as i,p as n,f as r,d as t};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D-AX8Voo.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./check-D6WkI0gF.js";import{t as a}from"./pencil-B90pDI55.js";import{da as o,ua as s}from"./index-B-S-gNKm.js";var c=e(t(),1),l=r(),u=`ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace`;function d({content:e,downloadContent:t,fileName:r,mimeType:u=`text/plain`,showEdit:d,isEditing:f,onToggleEdit:p,extraActions:m}){let[h,g]=(0,c.useState)(!1),_=(0,c.useRef)(null),v=(0,c.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{g(!0),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>g(!1),1500)})},[e]),y=t??e,b=(0,c.useCallback)(()=>{let e=new Blob([y],{type:u}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=r,n.click(),URL.revokeObjectURL(t)},[y,r,u]);return(0,c.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]),f?null:(0,l.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex items-center gap-1 rounded-md bg-[var(--surface-primary)] shadow-sm`,children:[d&&p&&(0,l.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:(0,l.jsx)(a,{"aria-hidden":!0}),onClick:p,"aria-label":`Edit file`,className:`hover:bg-[var(--surface-base)]`}),m,(0,l.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:h?(0,l.jsx)(i,{"aria-hidden":!0}):(0,l.jsx)(o,{"aria-hidden":!0}),onClick:v,"aria-label":h?`Copied`:`Copy file contents`,className:`hover:bg-[var(--surface-base)]`}),(0,l.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:(0,l.jsx)(s,{"aria-hidden":!0}),onClick:b,"aria-label":`Download file`,className:`hover:bg-[var(--surface-base)]`})]})}function f({value:e,onChange:t,onSave:n}){return(0,l.jsx)(`textarea`,{className:`m-0 h-full w-full resize-none overflow-auto border-none bg-transparent p-4 text-body-medium-lighter leading-relaxed outline-none`,style:{color:`var(--content-default)`,fontFamily:u},value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),n())},spellCheck:!1})}function p({isDirty:e,isSaving:t,error:r,onSave:i,onDiscard:a}){return(0,l.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t px-3 py-2`,style:{borderColor:`var(--border-element)`},children:[r&&(0,l.jsx)(`span`,{className:`mr-auto text-body-small-default`,style:{color:`var(--system-error)`},children:r}),(0,l.jsx)(n,{variant:`ghost`,size:`compact`,disabled:t,onClick:a,children:`Discard`}),(0,l.jsx)(n,{variant:`primary`,size:`compact`,disabled:!e||t,onClick:i,children:t?`Saving…`:`Save`})]})}function m({content:e,readOnly:t,whiteSpace:n=`pre-wrap`,onStartEdit:r}){return(0,l.jsx)(`pre`,{className:`m-0 h-full overflow-auto p-4 text-body-medium-lighter leading-relaxed${t?``:` cursor-text`}`,style:{color:`var(--content-default)`,fontFamily:u,whiteSpace:n},onClick:t?void 0:r,children:e})}export{m as i,p as n,f as r,d as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{a as t,n,o as r,r as i,s as a}from"./device-settings-BBwtGKJb.js";import{t as o}from"./capture-error-BG-GkiMq.js";import{t as s}from"./react-DJZBPgpf.js";import{t as c}from"./button-D-AX8Voo.js";import{d as l,t as u}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as d}from"./QueryClientProvider-DKhXIxGb.js";import{t as f}from"./useQuery-B45lW1Kk.js";import{t as p}from"./useMutation-Lj4VunQV.js";import{t as m}from"./jsx-runtime-CVSDxk6A.js";import{t as h}from"./cn-DvW5mxZR.js";import{t as g}from"./dropdown-ChWAdhLG.js";import{c as _,l as v,n as y}from"./src-SCpl1O1B.js";import{t as b}from"./confirm-dialog-bfBx6UYv.js";import{t as x}from"./notice-CqRgVmeL.js";import{t as S}from"./progress-bar-DIFlWPPg.js";import{t as C}from"./tag-CW6WC4fE.js";import{t as w}from"./input-D4W4p0pZ.js";import{t as T}from"./toggle-X_kQW5my.js";import{n as E}from"./stat-square-8mff1dLC.js";import{t as D}from"./modal-BNAVT2FK.js";import{n as O}from"./toast-sdJJ6aTV.js";import{D as k,T as A,b as j,c as M,d as N,f as P,g as F,h as I,i as L,r as ee,s as R,x as z}from"./local-mode-CgrENuVf.js";import{t as B}from"./is-electron-C_ZTVhv8.js";import{n as V}from"./resolved-assistants-store-Dqf0LJrA.js";import{t as H}from"./createLucideIcon-BlMXrA59.js";import{t as te}from"./bell-DB1SrBre.js";import{t as ne}from"./check-D6WkI0gF.js";import{t as re}from"./chevron-right-B6vEpVY0.js";import{t as ie}from"./circle-alert-DvNg50UK.js";import{t as ae}from"./circle-check-DzlJxj_M.js";import{t as oe}from"./hard-drive-CZEg1Cqc.js";import{t as U}from"./loader-circle-BFRVtR3K.js";import{t as se}from"./monitor-CXU19mVX.js";import{t as ce}from"./moon-CKINz50a.js";import{t as le}from"./refresh-cw-Dui3Ymsb.js";import{a as ue,c as de,o as fe,r as pe,s as me,t as he}from"./resize-errors-D1myE8D_.js";import{t as ge}from"./sparkles-Bla177ar.js";import{t as _e}from"./triangle-alert-C3aHZq1F.js";import{n as ve,r as W,t as ye}from"./api-errors-DPruG7q9.js";import{D as be,S as xe,T as Se,a as Ce,b as we,g as Te,h as Ee,k as De,l as Oe,n as ke,v as Ae,y as je}from"./auth-store-B1y6dgYQ.js";import{t as G}from"./client.gen-BHupOCJH.js";import{A as Me,S as Ne,V as Pe,Y as Fe,j as Ie,w as Le}from"./sdk.gen-DmWuY0SL.js";import{a as Re,o as ze}from"./api-1X5EQzNF.js";import{a as K}from"./routes-C6gxiCrz.js";import{n as Be,r as Ve}from"./platform-detection-Ceodt3Hu.js";import{t as q}from"./client-feature-flag-store-CHA6YxVq.js";import{r as He,t as Ue}from"./semver-0cyB3qXO.js";import{t as We}from"./assistant-feature-flag-store-Btrsn1VW.js";import{A as Ge,D as Ke,E as qe,M as Je,Q as Ye,T as Xe,bt as Ze,c as Qe,et as $e,gt as et,j as tt,k as nt,v as rt,w as it,wt as at,xt as ot}from"./react-query.gen-gQ1_8EHv.js";import{t as st}from"./proxy-BgtfAoJj.js";import{t as ct}from"./AnimatePresence-uY0BR2n2.js";import{t as lt}from"./use-reduced-motion-BG6r0Z46.js";import{$i as ut,Dn as dt,Ei as ft,Fr as pt,Nr as mt,Oa as ht,On as gt,Pr as _t,Ti as vt,Ut as yt,Wn as bt,_r as xt,d as St,dn as Ct,f as wt,fi as Tt,fn as Et,gi as Dt,gr as Ot,ht as kt,l as At,mn as jt,pn as Mt,ui as Nt,ur as Pt,vr as Ft,x as J}from"./index-CZ2UBc_U.js";import{t as It}from"./app-info-DJQFoVxX.js";import{t as Lt}from"./use-active-assistant-id-BVzVN4_g.js";import{t as Y}from"./detail-card-EsA9SOvZ.js";import{t as Rt}from"./environment-store-CnVyTyZ7.js";import{i as zt,n as Bt,r as Vt,t as Ht}from"./assistant-status-panel-D-XT9dcW.js";var Ut=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`}]]),Wt=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(s(),1),Gt=Ee,Kt=`Please choose a different handle.`;async function qt(e,t){let{data:n,error:r,response:i}=await Ie({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:W(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}=we(r,`handle`,Gt.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=we(r,`handle`,Kt);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:W(r,i,`Failed to save handle.`)}}async function Jt(e,t,n){let{data:r,error:i,response:a}=await Ne({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(ve(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new ye(a.status,a.status===429?`Too many checks — try again in a moment.`:W(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function Yt(e){return/\d{2,}$/.test(e)}var Z=m(),Xt=300,Zt=1400;function Qt({initialHandle:e,inputLabel:t,helperText:n,idleHelperText:r,checkAvailable:i,save:a,onSaved:o,saveSuccessToast:s,fieldId:l}){let[u,d]=(0,X.useState)(e),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(`idle`),[v,y]=(0,X.useState)(null),b=lt(),x=(0,X.useRef)(null),S=(0,X.useMemo)(()=>u.trim().toLowerCase(),[u]),C=S===e.toLowerCase();(0,X.useEffect)(()=>{if(C||S.length===0){h(!1),x.current?.abort();return}let e=new AbortController;x.current?.abort(),x.current=e,h(!0);let t=window.setTimeout(async()=>{try{let t=await i(S,e.signal);e.signal.aborted||p(t)}catch(t){e.signal.aborted||y(t instanceof Error?t.message:`Couldn't check availability.`)}finally{e.signal.aborted||h(!1)}},Xt);return()=>{window.clearTimeout(t),e.abort()}},[S,C,i]);let T=(()=>{if(v)return v;if(f&&!f.available){let e=f.code;return f.message??(e?Gt[e]:`Please choose a different handle.`)}return null})(),E=T?n:C?r??null:m?`Checking availability…`:f?.available?`Available.`:null,D=!C&&!m&&f?.available!==!1&&g!==`saving`,k=(0,X.useCallback)(async()=>{if(!D)return;_(`saving`),y(null);let e=await a(S);if(e.kind===`ok`){_(`saved`),o(e.data),O.success(s),window.setTimeout(()=>_(`idle`),Zt);return}if(e.kind===`taken`){_(`idle`),p({available:!1,code:`taken`,message:e.message});return}if(e.kind===`invalid`){_(`idle`),p({available:!1,code:e.code,message:e.message});return}_(`error`),y(e.message),O.error(e.message)},[D,S,o,a,s]),A=(()=>{if(C&&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:b?!1:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:b?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)(U,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,Z.jsx)(ne,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":`Available`}),e===`invalid`&&(0,Z.jsx)(ie,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":`Not available`})]},e)}):null})(),j=(()=>{switch(g){case`saving`:return(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(U,{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)(ne,{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)(w,{label:t,value:u,onChange:e=>{d(e.target.value.replace(/\s+/g,``)),p(null),y(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:A,errorText:T??void 0,helperText:E??void 0,"aria-invalid":!!T,fullWidth:!0,"data-testid":`${l}-input`}),(!C||g!==`idle`)&&(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(c,{variant:`primary`,size:`compact`,onClick:k,disabled:!D,"aria-live":`polite`,"data-testid":`${l}-save`,children:j})})]})}function $t({initial:e,onSaved:t}){let n=ke.use.refreshSession(),r=Yt(e.username)?`Your handle was auto-generated at signup — pick one you like.`:void 0,i=(0,X.useCallback)(async e=>await je({username:e}),[]),a=(0,X.useCallback)((e,t)=>Te(e,t),[]),o=(0,X.useCallback)(e=>{t(e),n()},[t,n]);return(0,Z.jsx)(Qt,{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 en({assistant:e,onSaved:t}){let n=e.handle??``,r=f({...Qe({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 qt(e.id,t),[e.id]),s=(0,X.useCallback)((t,n)=>Jt(e.id,t,n),[e.id]);return i?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(w,{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)(u,{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)(Qt,{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 tn(){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 nn({assistant:e}={}){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(null),a=lt(),[o,s]=(0,X.useState)(e??null);return(0,X.useEffect)(()=>{s(e??null)},[e]),(0,X.useEffect)(()=>{let e=!1;return Ae().then(t=>{e||n(t)}).catch(t=>{e||i(t instanceof Error?t.message:`Failed to load profile.`)}),()=>{e=!0}},[]),(0,Z.jsx)(Y,{title:`Profile`,subtitle:`Manage your user and assistant public handles.`,children: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)($t,{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)(en,{assistant:o,onSaved:s})]})]}):(0,Z.jsx)(tn,{})})}var rn=rt({query:{hosting:`platform`}});function an(){let e=Lt(),t=f(rn),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)(se,{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)(C,{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)(ne,{className:`h-4 w-4`}),`Active`]}):(0,Z.jsx)(c,{variant:`outlined`,size:`compact`,disabled:t.status!==`active`,onClick:()=>{De(t.id),O.success(`Switched active assistant.`)},children:`Switch`})})]},t.id)})})})}var on=[{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 sn(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 cn({assistantId:e}){let t=d(),n=Rt.use.isNonProduction(),r=(0,X.useMemo)(()=>on.filter(e=>!e.devOnly||n),[n]),{data:i,isLoading:a,isError:o}=f(tt({path:{id:e}})),s=(0,X.useMemo)(()=>i?.idle_timeout_seconds??259200,[i]),[l,u]=(0,X.useState)(null),p=l??s,m=l!==null,h=ot({onSuccess:()=>{O.success(`Sleep policy saved.`),u(null),t.invalidateQueries({queryKey:Je({path:{id:e}})})},onError:()=>{O.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)(U,{className:`h-4 w-4 animate-spin`}),`Loading sleep settings...`]}):o?(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)(c,{variant:`outlined`,active:p===e.seconds,onClick:()=>u(e.seconds),children:e.label},e.seconds))}),(0,Z.jsxs)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:[`Current: `,sn(p)]})]}),m&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(c,{variant:`primary`,leftIcon:h.isPending?(0,Z.jsx)(U,{className:`animate-spin`}):void 0,onClick:()=>h.mutate({path:{id:e},body:{idle_timeout_seconds:p}}),disabled:h.isPending,children:`Save`}),(0,Z.jsx)(c,{variant:`outlined`,onClick:()=>u(null),disabled:h.isPending,children:`Cancel`})]})]})}function ln(e,t,n){let r=[e.version];return e.version===n&&r.push(`(latest)`),t&&e.version===t&&r.push(`(current)`),r.join(` `)}var un=3e3;function dn({assistantId:e,currentVersion:t,releaseChannel:n,onUpgradeComplete:r}){let i=We.use.rollbackEnabled(),a=q.use.previewChannel(),o=d(),s=Et(n,a),l=s===`preview`,[u,m]=(0,X.useState)(!1),h=(0,X.useRef)(null),[_,v]=(0,X.useState)(null),[y,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(null),E=e=>e&&h.current&&e===h.current?(queueMicrotask(()=>{T(S?`Successfully rolled back to version ${h.current}.`:`Successfully updated to version ${h.current}.`),m(!1),h.current=null,v(null),O.success(S?`Rollback complete — assistant is healthy.`:`Update complete — assistant is healthy.`),r?.()}),!1):un;f({...nt({path:{id:e}}),refetchInterval:u?e=>E(e.state.data?.current_release_version):!1});let{data:D,isLoading:k}=f(et({query:{channel:s}})),A=D?.find(e=>e.is_stable!==!1)??D?.[0],j=_??A?.version??null,M=(0,X.useMemo)(()=>{if(!i||!j||!t)return!1;let e=He(j),n=He(t);return!e||!n?!1:Ue(e,n)<0},[i,j,t]),N=(0,X.useMemo)(()=>{if(!j)return!1;if(!t)return!0;let e=He(j),n=He(t);if(!e||!n)return j!==t;let r=Ue(e,n);return i?r!==0:r>0},[i,j,t]),P=p({mutationFn:async t=>{let{data:n}=await Fe({path:{id:e},body:t,throwOnError:!0});return n}}),F=p({mutationFn:async t=>{let{data:n}=await Pe({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)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:t??`—`})]}),(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`:N?M?`Rollback to`:`Update to`:`Selected`}),(0,Z.jsx)(`span`,{className:`block min-w-0`,children:k?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(U,{className:`h-3 w-3 animate-spin`}),`Loading...`]}):D&&D.length>0?i?(0,Z.jsx)(g,{value:j??``,onChange:e=>v(e===A?.version?null:e),disabled:u||P.isPending||F.isPending,options:D.map(e=>({value:e.version,label:ln(e,t,A?.version)}))}):(0,Z.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:A?ln(A,t,A.version):`—`}):`No releases available`})]})]}),(0,Z.jsx)(c,{variant:M?`outlined`:`primary`,className:`min-w-[160px]`,leftIcon:P.isPending||F.isPending||u?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(le,{}),onClick:()=>x(!0),disabled:!N||P.isPending||F.isPending||u||k||!D?.length,children:u?S?`Rolling back...`:`Updating...`:M?`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`})]}),!N&&t&&j&&!k&&(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:w??`You are already on this version.`}),(0,Z.jsx)(b,{open:y,title:M?`Rollback assistant`:l?`Update preview release`:`Update assistant`,message:M?`Rollback to version ${j??`unknown`}? The assistant will be briefly unavailable.`:l?`Update to preview version ${j??`latest`}? The assistant will be briefly unavailable during the update.`:`Update to version ${j??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:M?`Rollback`:l?`Update preview`:`Update`,onConfirm:async()=>{x(!1),T(null);let t=_??void 0;try{if(M){let e=await F.mutateAsync({version:t});h.current=e.version??t??null,O.success(e.detail||`Rollback to ${t} initiated.`)}else{let e=await P.mutateAsync({version:t});if(e.detail?.includes(`Already on the latest`)){O.warning(e.detail);return}h.current=e.version??t??null,O.success(e.detail||`Update to ${e.version??t??`latest`} initiated.`)}C(M),m(!0),o.invalidateQueries({queryKey:Ge({path:{id:e}})})}catch{O.error(M?`Failed to trigger rollback. Please try again.`:`Failed to trigger update. Please try again.`)}},onCancel:()=>x(!1)})]})}function fn({assistantId:e,currentVersion:t,onUpgradeComplete:n}){let[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(null),{data:s,isLoading:l}=f(et({query:{stable:!0,limit:100}})),u=(0,X.useMemo)(()=>Ct(s),[s]),d=u?.version,p=t?Mt(t,d):!!d,m=jt({assistantId:e,targetVersion:d});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)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:t??`—`})]}),(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...`:d&&u?ln(u,t,d):`No releases available`})]})]}),(0,Z.jsx)(c,{variant:`primary`,className:`min-w-[160px]`,leftIcon:m.isPending?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(le,{}),onClick:()=>i(!0),disabled:m.isPending||l||!d||!p,children:m.isPending?`Updating...`:d?`Update to ${d}`:`Update`}),a&&(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:a}),!a&&!p&&d&&!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)(b,{open:r,title:`Update assistant`,message:`Update to version ${d??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:`Update`,onConfirm:async()=>{i(!1),o(null);try{let e=await m.upgrade();o(e.version?`Successfully updated to version ${e.version}.`:`Successfully updated to version ${d??`latest`}.`),O.success(`Update complete — assistant is healthy.`),n?.()}catch(e){O.error(e instanceof Error?e.message:`Failed to trigger update. Please try again.`)}},onCancel:()=>i(!1)})]})}function pn(){let e=wt.useValue();if(bt())return null;let t=Be()?`Cmd`:`Ctrl`;return(0,Z.jsx)(Y,{title:`Composer`,children:(0,Z.jsx)(T,{checked:e,onChange:wt.save,label:`Send with ${t}+Enter`,helperText:`When enabled, Enter inserts a new line and ${t}+Enter sends.`})})}function mn(){let e=pt({platformHostedOnly:!0}),t=_t(),n=ke.use.user()?.id??null,r=ke.use.logout(),[i,a]=(0,X.useState)(!1),o=at({onSuccess:async()=>{O.success(`Account deletion requested. You will be logged out shortly.`),Oe(n),await r(),Pt(K.account.login)},onError:()=>{O.error(`Failed to request account deletion. Please try again.`)}}),s=e===`full`&&t;return(0,X.useEffect)(()=>{s&&i&&a(!1)},[s,i]),e===`gated`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{title:`Delete Account`,subtitle:`Permanently delete your account and all associated data.`,variant:`danger`,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)(c,{variant:`dangerOutline`,onClick:()=>a(!0),disabled:o.isPending||s,className:`self-start`,children:`Delete My Account`}),s&&(0,Z.jsx)(U,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})}),(0,Z.jsx)(b,{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(s){a(!1);return}a(!1),o.mutate({})},onCancel:()=>a(!1)})]})}function hn({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)(c,{variant:`primary`,size:`regular`,leftIcon:i,onClick:a,className:`self-start`,children:r})]})})}function gn(){return Ve()?(0,Z.jsx)(hn,{title:`Get the iOS App`,subtitle:`The Vellum iOS app gives you a native experience.`,benefits:[{icon:te,text:`Push notifications`},{icon:Ut,text:`Biometric login`},{icon:Wt,text:`Native haptics`},{icon:Dt,text:`Home screen access`}],ctaLabel:`Download`,ctaLeftIcon:(0,Z.jsx)(Dt,{size:16}),onAction:()=>{St(),At()}}):null}async function _n(){if(!B())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function vn(e){if(!B())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function yn(){let[e,t]=(0,X.useState)(!1);(0,X.useEffect)(()=>{_n().then(t)},[]);let n=async e=>{t(e);try{await vn(e)}catch{t(!e)}};return(0,Z.jsx)(Y,{title:`Launch at Login`,subtitle:`Automatically start Vellum when you log in to your Mac.`,children:(0,Z.jsx)(T,{checked:e,onChange:e=>void n(e),"aria-label":`Launch at Login`})})}function bn({className:e}){return(0,Z.jsx)(`div`,{role:`presentation`,className:h(`h-px w-full bg-[var(--border-base)]`,e)})}var xn=[`youtube.com`,`youtu.be`,`vimeo.com`,`loom.com`];function Sn(e){try{let t=JSON.parse(e);if(Array.isArray(t))return t.filter(e=>typeof e==`string`)}catch{}return[...xn]}function Cn(){return n(`mediaEmbedsEnabled`,!0)}function wn(){let e=i(`mediaEmbedDomains`,``);return e?Sn(e):[...xn]}function Tn(){let[e,n]=(0,X.useState)(()=>Cn()),[i,a]=(0,X.useState)(()=>wn()),[o,s]=(0,X.useState)(!1),[l,u]=(0,X.useState)(``),d=(0,X.useMemo)(()=>l.trim().toLowerCase(),[l]),f=e=>{n(e),t(`mediaEmbedsEnabled`,e)},p=e=>{a(e),r(`mediaEmbedDomains`,JSON.stringify(e))},m=()=>{if(d){if(i.includes(d)){u(``);return}p([...i,d]),u(``)}},h=e=>{p(i.filter(t=>t!==e))},g=()=>{p([...xn])},_=i.length===xn.length&&i.every((e,t)=>e===xn[t]);return(0,Z.jsxs)(Y,{title:`Media Embeds`,subtitle:`Automatically embed images, videos, and other media shared in chat messages.`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Auto Media Embeds`}),(0,Z.jsx)(T,{checked:e,onChange:f})]}),e&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(bn,{})}),(0,Z.jsxs)(c,{type:`button`,variant:`ghost`,onClick:()=>s(e=>!e),className:`mt-4 w-full justify-between px-3`,"aria-expanded":o,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[o?(0,Z.jsx)(ht,{className:`h-4 w-4`,"aria-hidden":!0}):(0,Z.jsx)(re,{className:`h-4 w-4`,"aria-hidden":!0}),`Video Domain Allowlist`]}),(0,Z.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[i.length,` domain`,i.length===1?``:`s`]})]}),o&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Z.jsx)(w,{label:`Add Domain`,type:`text`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),m())},placeholder:`Add domain (e.g. example.com)`,fullWidth:!0,wrapperClassName:`flex-1`}),(0,Z.jsx)(c,{variant:`primary`,size:`compact`,onClick:m,disabled:!d,children:`Add`})]}),i.length>0&&(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,onClick:g,disabled:_,tintColor:`var(--content-tertiary)`,children:`Reset to Defaults`})}),i.length>0&&(0,Z.jsx)(`ul`,{className:`space-y-2`,children:i.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center justify-between rounded-md border border-[var(--border-base)] px-3 py-2 text-body-medium-lighter`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-[var(--content-default)]`,children:e}),(0,Z.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Z.jsx)(Nt,{}),onClick:()=>h(e),"aria-label":`Remove ${e}`})]},e))})]})]})]})}function En(e){return e===`preview`?`preview`:`stable`}function Dn(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 On(e){return e.source_release_version?`Stable ${e.source_release_version}`:e.snapshot_name}function kn(e){return e.filter(e=>e.ready_to_use)}function An(e){return e?.feature_enabled===!1}function jn({assistantId:e,onComplete:t}){let n=q.use.previewChannel(),r=d(),[i,a]=(0,X.useState)(),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,m]=(0,X.useState)(`restore_backup`),[h,g]=(0,X.useState)(``),_=qe({path:{assistant_id:e}}),v=Ke({path:{assistant_id:e}}),b=Ge({path:{id:e}}),{data:S,isLoading:w,isError:T}=f({..._,enabled:n,retry:!1}),E=S?.preview_backups??[],D=(0,X.useMemo)(()=>kn(E),[E]),k=D[0],A=D.find(e=>e.snapshot_name===h)??k,j=()=>{r.invalidateQueries({queryKey:v}),r.invalidateQueries({queryKey:b}),t?.()},M=p(it()),N=p(Xe()),P=En(S?.current_channel),F=M.isPending||N.isPending,I=F||An(S)||!S?.latest_preview_release,L=u===`restore_backup`&&!A;if((0,X.useEffect)(()=>{a(P===`preview`?`release-channel`:void 0)},[P]),!n)return null;let ee=S?.standard_upgrade_available??!1;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(y.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)(y.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,Z.jsxs)(y.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`}),S&&(0,Z.jsx)(C,{tone:P===`preview`?`warning`:`neutral`,children:P===`preview`?`Preview`:`Stable`})]}),(0,Z.jsx)(ht,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Z.jsx)(y.Content,{children:(0,Z.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[w&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(U,{className:`h-4 w-4 animate-spin`}),`Loading release channel...`]}),T&&(0,Z.jsx)(x,{tone:`error`,title:`Could not load release channel status`,children:`Refresh this page before changing release channels.`}),S&&(0,Z.jsxs)(Z.Fragment,{children:[An(S)&&(0,Z.jsx)(x,{tone:`neutral`,title:`Preview channel is unavailable`,children:`The Preview channel is not enabled for this assistant.`}),P===`stable`?(0,Z.jsx)(Mn,{status:S,isChangingChannel:F,optInDisabled:I,onOptIn:()=>s(!0)}):(0,Z.jsx)(Nn,{status:S,isChangingChannel:F,onOptOut:()=>{let e=k;g(e?.snapshot_name??``),m(e?`restore_backup`:ee?`standard_upgrade`:`restore_backup`),l(!0)}})]})]})})]})}),(0,Z.jsx)(Fn,{open:o,isPending:M.isPending,previewVersion:S?.latest_preview_release?.version,onConfirm:async()=>{try{let t=await M.mutateAsync({path:{assistant_id:e}});O.success(t.detail||`Preview channel enabled.`),s(!1),j()}catch(e){O.error(W(e,void 0,`Could not enable Preview channel.`))}},onCancel:()=>s(!1)}),(0,Z.jsx)(In,{open:c,backups:D,mode:u,selectedSnapshotName:A?.snapshot_name??``,isPending:N.isPending,restoreModeDisabled:L,standardUpgradeAvailable:ee,onModeChange:m,onSnapshotChange:g,onConfirm:async()=>{if(!L)try{let t=await N.mutateAsync({path:{assistant_id:e},body:u===`restore_backup`?{mode:`restore_backup`,snapshot_name:A?.snapshot_name}:{mode:`standard_upgrade`}});O.success(t.detail||`Stable channel enabled.`),l(!1),j()}catch(e){O.error(W(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>l(!1)})]})}function Mn({status:e,isChangingChannel:t,optInDisabled:n,onOptIn:r}){return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Pn,{status:e}),!e.latest_preview_release&&(0,Z.jsx)(x,{tone:`neutral`,title:`No Preview release is available`,children:`Stable remains the only available release channel.`}),(0,Z.jsx)(c,{variant:`outlined`,leftIcon:t?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(ft,{}),disabled:n,onClick:r,children:`Opt in to Preview`})]})}function Nn({status:e,isChangingChannel:t,onOptOut:n}){return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Pn,{status:e}),(0,Z.jsx)(c,{variant:`outlined`,leftIcon:t?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(vt,{}),disabled:t,onClick:n,children:`Switch back to Stable`})]})}function Pn({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 Fn({open:e,isPending:t,previewVersion:n,onConfirm:r,onCancel:i}){return(0,Z.jsx)(D.Root,{open:e,onOpenChange:e=>!e&&i(),children:(0,Z.jsxs)(D.Content,{size:`md`,hideCloseButton:t,children:[(0,Z.jsxs)(D.Header,{children:[(0,Z.jsx)(D.Title,{icon:_e,children:`Opt in to Preview`}),(0,Z.jsx)(D.Description,{children:`Preview releases may be unstable. A 90-day safety backup is taken before the image changes.`})]}),(0,Z.jsx)(D.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(x,{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)(D.Footer,{children:[(0,Z.jsx)(c,{variant:`outlined`,disabled:t,onClick:i,children:`Cancel`}),(0,Z.jsx)(c,{variant:`primary`,disabled:t,leftIcon:t?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(ft,{}),onClick:r,children:t?`Switching...`:`Take Backup and Switch`})]})]})})}function In({open:e,backups:t,mode:n,selectedSnapshotName:r,isPending:i,restoreModeDisabled:a,standardUpgradeAvailable:o,onModeChange:s,onSnapshotChange:l,onConfirm:u,onCancel:d}){return(0,Z.jsx)(D.Root,{open:e,onOpenChange:e=>!e&&d(),children:(0,Z.jsxs)(D.Content,{size:`md`,hideCloseButton:i,children:[(0,Z.jsxs)(D.Header,{children:[(0,Z.jsx)(D.Title,{icon:_e,children:`Switch back to Stable`}),(0,Z.jsx)(D.Description,{children:`Choose how this assistant should leave the Preview channel.`})]}),(0,Z.jsx)(D.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(v,{value:n,onValueChange:s,disabled:i,"aria-label":`Stable channel return method`,children:[(0,Z.jsx)(_,{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)(_,{value:`standard_upgrade`,disabled:!o,label:`Switch to Stable without restoring backup`,helperText:o?`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)(g,{value:r,onChange:l,disabled:i,options:t.map(e=>({value:e.snapshot_name,label:`${On(e)} - ${Dn(e.created_at)}`}))})]}),n===`restore_backup`&&t.length===0&&!o&&(0,Z.jsx)(x,{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)(x,{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)(D.Footer,{children:[(0,Z.jsx)(c,{variant:`outlined`,disabled:i,onClick:d,children:`Cancel`}),(0,Z.jsx)(c,{variant:n===`standard_upgrade`?`danger`:`primary`,disabled:i||a||n===`standard_upgrade`&&!o,leftIcon:i?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(le,{}),onClick:u,children:i?`Switching...`:`Switch to Stable`})]})]})})}function Ln({assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:a}){let o=l(),s=f($e()),d=s.data,p=!e.is_local,m=d?.plan_id===`pro`,h=f({...Ye(),enabled:m}),_=e.machine_size||`small`,v=ue(h.data?.max_machine_tier??null),y=(0,X.useMemo)(()=>fe(v,_,(0,Z.jsx)(C,{tone:`positive`,children:`Current`})),[v,_]),b=h.data?.selected_storage_gib??null,[S,w]=(0,X.useState)(!1),T=v.length>0?v[v.length-1]:null,[E,k]=(0,X.useState)(null),A=E??T??_,[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),F=Ze({onSuccess:(e,n)=>{O.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),P(null),k(null),w(!1),n.body?.machine_size==null?i():a(t)},onError:e=>{P(he(e,`Failed to resize assistant. Please try again.`))}});if(s.isError&&d==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)(x,{tone:`error`,children:`Could not load your subscription. Please try again.`})});let I=m&&v.includes(A)&&A!==_?A:null,L=m&&b!=null&&!0,ee=m&&v.length>0&&me(_)<me(v[v.length-1]),R=F.isPending||r,z=b==null?t?.disk?.totalMb??null:b*1024,B=t?.disk&&z!=null?{value:t.disk.usedMb,max:z,caption:`${Bt(t.disk.usedMb)} of ${Bt(z)}`}:null,V=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,H=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:`${Bt(t.memory.currentMb)} of ${Bt(t.memory.maxMb)}`}:null,te=p?m?L?(0,Z.jsxs)(`button`,{type:`button`,disabled:R,onClick:()=>w(!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)(ge,{className:`h-3.5 w-3.5`}),`Increase Storage`]}):(0,Z.jsx)(c,{variant:`ghost`,size:`compact`,disabled:R,onClick:()=>w(!0),children:`Resize`}):(0,Z.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>M(`storage`),children:`Resize`}):null,ne=p?m?ee?(0,Z.jsxs)(`button`,{type:`button`,disabled:R,onClick:()=>w(!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)(ge,{className:`h-3.5 w-3.5`}),`Increase Size`]}):(0,Z.jsx)(c,{variant:`ghost`,size:`compact`,disabled:R,onClick:()=>w(!0),children:`Resize`}):(0,Z.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>M(`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)(c,{variant:`ghost`,size:`compact`,iconOnly:n||r?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(le,{}),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)(oe,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Disk`})]}),te]}),(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`}),B?(0,Z.jsx)(zt,{value:B.value,max:B.max,caption:B.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(U,{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)(de,{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)(C,{tone:`neutral`,children:pe[_]})]}),ne]}),(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`}),V?(0,Z.jsx)(zt,{value:V.value,max:V.max,caption:V.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(U,{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`}),H?(0,Z.jsx)(zt,{value:H.value,max:H.max,caption:H.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(U,{className:`h-3 w-3 animate-spin`})}):(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,Z.jsx)(D.Root,{open:j!=null,onOpenChange:e=>{e||M(null)},children:(0,Z.jsxs)(D.Content,{size:`sm`,children:[(0,Z.jsxs)(D.Header,{children:[(0,Z.jsx)(D.Title,{children:`Upgrade to Pro`}),(0,Z.jsx)(D.Description,{children:j===`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)(D.Footer,{children:[(0,Z.jsx)(c,{variant:`ghost`,onClick:()=>M(null),children:`Cancel`}),(0,Z.jsx)(c,{onClick:()=>{M(null),o(`${K.settings.billing}?adjust_plan=1`)},children:`Upgrade`})]})]})}),(0,Z.jsx)(D.Root,{open:S,onOpenChange:e=>{e||(w(!1),k(null),P(null))},children:(0,Z.jsxs)(D.Content,{size:`sm`,children:[(0,Z.jsxs)(D.Header,{children:[(0,Z.jsx)(D.Title,{icon:de,children:`Resize Assistant`}),(0,Z.jsx)(D.Description,{children:`Resize your assistant's compute and storage. Your assistant will briefly restart.`})]}),(0,Z.jsx)(D.Body,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[v.length===0?(0,Z.jsx)(x,{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)(g,{options:y,value:A,onChange:k,"aria-label":`Compute machine size`,"data-testid":`resize-machine-size`})]}),L?(0,Z.jsx)(x,{tone:`info`,children:`Storage will be expanded to ${b} GiB.`}):(0,Z.jsx)(x,{tone:`neutral`,children:`Storage will not change.`}),N&&(0,Z.jsx)(x,{tone:`error`,children:N})]})}),(0,Z.jsxs)(D.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)(u,{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:()=>w(!1),children:`Upgrade plan`})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(c,{variant:`ghost`,onClick:()=>{w(!1),k(null),P(null)},children:`Cancel`}),(0,Z.jsx)(c,{disabled:I==null&&!L||R,leftIcon:R?(0,Z.jsx)(U,{className:`animate-spin`}):void 0,onClick:()=>{P(null);let t={};I!=null&&(t.machine_size=I),L&&b!=null&&(t.storage_gib=b),F.mutate({path:{id:e.id},body:t})},children:N?`Retry`:`Apply`})]})]})]})})]})}function Rn({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)(c,{variant:`dangerOutline`,onClick:()=>r(!0),className:`shrink-0`,children:`Retire Assistant`}),(0,Z.jsx)(dt,{open:n,isPending:i,onConfirm:async()=>{a(!0);let n=await gt(e);if(n.ok){r(!1),t(n.nextRoute,{replace:!0});return}O.error(n.error),a(!1),r(!1)},onCancel:()=>r(!1)})]})}var zn=`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 Bn(){let e=Intl;if(typeof e.supportedValuesOf==`function`)try{let t=e.supportedValuesOf(`timeZone`);if(t.length>0)return[...t].sort()}catch{}return[...zn].sort()}function Vn(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 Hn(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour:`numeric`,minute:`2-digit`,hour12:!0}).format(new Date)}catch{return``}}function Un(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 Wn({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)(()=>Bn().map(e=>Vn(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)(w,{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:Hn(t.identifier)}),(0,Z.jsx)(`span`,{children:t.offsetLabel})]})]},t.identifier))})]})]}),(0,Z.jsx)(bn,{}),(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:Un(e)})]})]})}var Q=class extends Error{code;constructor(e,t){super(t),this.name=`TeleportError`,this.code=e}},Gn=`local`,Kn=`docker`,qn=`vellum`;function Jn(e){switch((e??``).toLowerCase()){case Gn:return`local`;case Kn:return`docker`;case qn:return`managed`;default:return`other`}}function Yn(e){let t=Jn(e);return t===`managed`?`local`:t===`local`?`platform`:null}function Xn(e){switch(e){case`docker`:return`Move to Docker`;case`platform`:return`Move to Cloud (Platform)`;case`local`:return`Move to Local`}}function Zn(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 Qn(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 $n(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 er(e){let t=L(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 tr(e,t){let n=await A(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 nr(e,t){let n=er(e),r=await tr(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 $n(i,t)}async function rr(e,t){let n=er(e),r=await tr(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 or(i);if(a&&a.success===!1)throw new Q(`import_failed`,a.error??`Import reported failure`)}async function ir(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 ar(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 or(e){try{return await e.json()}catch{return null}}var sr=new Set([500,502,503,504]),$=3,cr=e=>new Promise(t=>setTimeout(t,e));async function lr(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<$&&sr.has(o)&&!t.has(o)){await cr(2**n*1e3);continue}return{status:o,data:i,error:a}}throw new Q(`unknown`,`Unexpected retry loop exit`)}async function ur(e){let t={operation:`upload`};e&&(t.min_runtime_version=e,t.max_runtime_version=null);let{status:n,data:r}=await lr(()=>G.post({url:`/v1/migrations/signed-url/`,body:t,throwOnError:!1}),new Set([404,503]));if(n===503||n===404)throw new Q(`export_failed`,`Signed URL uploads are not available — the platform may not support this feature yet.`);if(n!==201)throw new Q(`export_failed`,`Migration request failed (HTTP ${n}).`);let i=r;return{url:i.url,bundleKey:i.bundle_key,expiresAt:i.expires_at}}async function dr(e,t){let{status:n,data:r,error:i}=await lr(()=>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=Qn(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 fr(e,t,n){for(let r=0;r<=$;r++){let i=await pr(e,t,n);if(r<$&&sr.has(i)){await cr(2**r*1e3),n?.(0);continue}if(i<200||i>=300)throw new Q(`export_failed`,`Bundle upload failed (HTTP ${i}).`);return}}function pr(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 mr(e,t){for(let n=0;n<=$;n++){let r=await fetch(e,{method:`GET`});if(n<$&&sr.has(r.status)){await cr(2**n*1e3),t?.(0);continue}if(!r.ok)throw new Q(`import_failed`,`Bundle download failed (HTTP ${r.status}).`);return $n(r,t)}throw new Q(`import_failed`,`Unexpected retry loop exit`)}async function hr(e){let{status:t,data:n,error:r}=await lr(()=>G.post({url:`/v1/migrations/import-from-gcs/`,body:{bundle_key:e},throwOnError:!1}));return{status:t,body:n??r??null}}async function gr(e){let{status:t,data:n}=await lr(()=>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 _r=5e3,vr=36e5,yr=5*6e4,br=30,xr=e=>new Promise(t=>setTimeout(t,e));function Sr(){let e=l(),t=M(),n=Yn(t?.cloud),[r,i]=(0,X.useState)({kind:`idle`}),[a,s]=(0,X.useState)(!1),c=(0,X.useRef)(null),u=(0,X.useRef)(null),d=(0,X.useCallback)(e=>{i({kind:`transferring`,step:e,progress:null})},[]),f=(0,X.useCallback)(e=>{i(t=>t.kind===`transferring`?{...t,progress:e}:t)},[]),p=(0,X.useCallback)(async()=>{if(!(!t||!n)){u.current={id:t.assistantId,kind:Jn(t.cloud)===`managed`?`managed`:`local`,createdFresh:!1};try{if(n===`platform`)await Cr(t,d,f,c);else if(n===`local`)await wr(t,d,f,c);else throw new Q(`unknown`,`Unsupported teleport destination.`);i({kind:`verifying`})}catch(e){i({kind:`failed`,error:`Teleport failed: ${e instanceof Q||e instanceof Error?e.message:`Teleport failed.`}`}),o(e,{context:`teleport-execute`}),await Er(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,i({kind:`idle`})},[]);return{destination:n,phase:r,confirmOpen:a,requestTeleport:m,cancelConfirm:h,confirm:g,confirmAndSwitch:(0,X.useCallback)(()=>{let t=c.current,n=u.current;t&&(async()=>{try{let e=ke.getState();t.kind===`managed`?await e.connectPlatformAssistant(t.id):(await e.connectLocalAssistant(t.id),xe(t.id,{onError:e=>o(e,{context:`teleport-inject-platform-identity`})}))}catch(e){i({kind:`failed`,error:`Switch failed: ${e instanceof Error?e.message:`Failed to switch assistant.`}`}),o(e,{context:`teleport-confirm-switch`});return}n&&gt(n.id).then(e=>{e.ok||o(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,i({kind:`idle`}),Er(e,t,`teleport-cancel-retire-target`)},[]),reset:_}}async function Cr(e,t,n,r){t(`Exporting assistant data...`);let i=await nr(e,n);t(`Resolving organization...`);let a=await Or();t(`Checking for existing assistant...`);let o=(await Le({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 fr(s.url,i,n),t(`Setting up cloud assistant...`);let c=await ze(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 j({assistantId:l,name:c.data.name,cloud:`vellum`,runtimeUrl:R(),hatchedAt:c.data.created??new Date().toISOString(),organizationId:a}),await z(e.assistantId),r.current={id:l,kind:`managed`,createdFresh:!0},t(`Finalizing cloud assistant...`),await kr(l),t(`Importing data to cloud...`);let u=await hr(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 Ar(e)}else{let e=u.body;if(e&&e.success===!1)throw new Q(`import_failed`,e.error??`Import reported failure.`)}}async function wr(e,t,n,r){t(`Preparing export...`);let i=await ur(await Dr(e.assistantId));t(`Exporting cloud data...`);let a=await ir(e.assistantId,i.url);await jr(e.assistantId,a),t(`Preparing local assistant...`);let{assistant:o,createdFresh:s}=await Mr();r.current={id:o.assistantId,kind:`local`,createdFresh:s};let c=await Tr(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 dr(i.bundleKey,c);t(`Downloading data...`);let u=await mr(l,n);t(`Importing data...`),await Pr(o,u),await z(e.assistantId)}async function Tr(e,t){if(e.resources?.runtimeVersion)return e.resources.runtimeVersion;if(t)return(await It())?.version??void 0}async function Er(e,t,n){if(e?.createdFresh){let t=await gt(e.id);t.ok||o(Error(t.error),{context:n})}t&&await z(t.id)}async function Dr(e){let t=await Re(e);return t.ok?t.data.version??void 0:void 0}async function Or(){let e=be.getState();e.organizations.length===0&&await e.fetchOrganizations();let t=be.getState().organizations,n=Se();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 be.getState().setCurrentOrganizationId(r),r}async function kr(e){let t=Date.now();for(;Date.now()-t<yr;){let{data:t,response:n}=await Me({path:{id:e},throwOnError:!1});if(n?.ok&&t?.state===`active`)return;await xr(_r)}}async function Ar(e){let t=Date.now();for(;Date.now()-t<vr;){await xr(_r);let t=await gr(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 jr(e,t){let n=Date.now();for(;Date.now()-n<vr;)if(await xr(_r),await ar(e,t)===`complete`)return;throw new Q(`export_timed_out`,`Export timed out.`)}async function Mr(){let e=await k(void 0,void 0);if(!e.ok)throw new Q(`local_assistant_not_found`,e.error??`Could not create a local assistant.`);await F();let t=e.assistantId?ee().find(t=>t.assistantId===e.assistantId):Nr();if(!t)throw new Q(`local_assistant_not_found`,`Could not find or create a local assistant.`);return{assistant:t,createdFresh:!0}}function Nr(){return ee().slice().sort((e,t)=>(t.hatchedAt??``).localeCompare(e.hatchedAt??``))[0]}async function Pr(e,t){let n;for(let r=0;r<br;r++)try{await rr(e,t);return}catch(e){n=e,await xr(1e3)}throw n instanceof Error?n:new Q(`import_failed`,`Import failed.`)}function Fr(){let e=Sr(),{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:Zn(t)}),(0,Z.jsx)(c,{variant:`outlined`,className:`self-start`,onClick:e.requestTeleport,children:Xn(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)(U,{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)(S,{value:n.progress,"aria-label":`Teleport progress`,className:`max-w-[240px]`})]}),n.kind===`verifying`&&(0,Z.jsx)(x,{tone:`success`,icon:(0,Z.jsx)(ae,{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)(c,{variant:`primary`,onClick:e.confirmAndSwitch,children:`Confirm & Switch`}),(0,Z.jsx)(c,{variant:`outlined`,onClick:e.cancelTeleport,children:`Cancel`})]})}),n.kind===`failed`&&(0,Z.jsx)(x,{tone:`error`,title:n.error,actions:(0,Z.jsx)(c,{variant:`outlined`,onClick:e.reset,children:`Try Again`})}),(0,Z.jsx)(b,{open:e.confirmOpen,title:Xn(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 Ir(){let e=q.use.velvet(),[t,n]=(0,X.useState)(()=>xt({velvetEnabled:e}));return(0,X.useEffect)(()=>{n(xt({velvetEnabled:e}))},[e]),(0,X.useEffect)(()=>a(`theme`,()=>{n(xt({velvetEnabled:e}))}),[e]),(0,X.useEffect)(()=>{Ot(t)},[t]),(0,Z.jsx)(Y,{title:`Theme`,children:(0,Z.jsx)(`div`,{className:`max-w-[360px]`,children:(0,Z.jsx)(E,{ariaLabel:`Theme`,value:t,onChange:e=>{n(e),Ft(e),Ot(e)},items:[{value:`system`,label:`System`,icon:(0,Z.jsx)(se,{className:`h-4 w-4`})},{value:`light`,label:`Light`,icon:(0,Z.jsx)(Tt,{className:`h-4 w-4`})},{value:`dark`,label:`Dark`,icon:(0,Z.jsx)(ce,{className:`h-4 w-4`})},...e?[{value:`velvet`,label:`Velvet`,icon:(0,Z.jsx)(ut,{className:`h-4 w-4`})}]:[]]})})})}function Lr(){let e=V.use.activeAssistantId(),[t,n]=(0,X.useState)(()=>i(`timezone`,``)),a=(0,X.useRef)(e);(0,X.useEffect)(()=>{a.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=a.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=>{o(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.jsx)(Y,{title:`Timezone`,subtitle:`Used when displaying times and scheduling reminders.`,children:(0,Z.jsx)(Wn,{value:t,onChange:e=>{n(e),r(`timezone`,e),u(e)}})})}function Rr(){let{assistant:e,assistantLoading:t,healthz:n,healthzLoading:r,healthzPolling:i,refetch:a,refetchUntilResized:o}=Vt(),s=q.use.multiPlatformAssistant(),c=q.use.teleport(),u=We.use.settingsSleepPolicy(),d=Ce(),f=l(),p=pt(),m=pt({platformHostedOnly:!0}),h=mt(),g=yt({assistantId:e?.id??null,enabled:m===`full`&&h}),_=e?.is_local&&!P()?null:e,v=M(),y=P()&&!!e&&!!v&&N(v),b=y,x=y&&!I();return(0,X.useEffect)(()=>{!e||window.location.hash!==`#storage-resources`||requestAnimationFrame(()=>{document.getElementById(`storage-resources`)?.scrollIntoView({block:`start`})})},[e]),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[g.status&&g.mode!==`inactive`&&(0,Z.jsx)(kt,{status:g.status,mode:g.mode,isAcknowledging:g.isAcknowledging,acknowledgeError:g.acknowledgeError?.message??null,onAcknowledge:()=>void g.acknowledge(),onReviewWorkspaceData:()=>void f(`${K.workspace}?sort=size`),onUpgradeStorage:m===`full`?()=>void f(`${K.settings.billing}?adjust_plan=1`):null}),(0,Z.jsx)(Y,{title:`General`,children:(0,Z.jsx)(Ht,{assistant:_,assistantLoading:t,healthz:n,healthzLoading:r})}),d&&p===`full`&&(0,Z.jsx)(nn,{assistant:h?_:null}),m===`full`&&e&&(0,Z.jsx)(Ln,{assistant:e,healthz:n,healthzLoading:r,healthzPolling:i,refetch:a,refetchUntilResized:o}),m===`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)(Ir,{}),(0,Z.jsx)(pn,{}),B()&&(0,Z.jsx)(yn,{}),c&&B()&&(0,Z.jsx)(Fr,{}),m===`full`&&_&&(0,Z.jsxs)(Y,{title:`Software Updates`,children:[(0,Z.jsx)(dn,{assistantId:_.id,currentVersion:n?.version??_.current_release_version??null,releaseChannel:_.release_channel,onUpgradeComplete:()=>{a()}}),(0,Z.jsx)(jn,{assistantId:_.id,onComplete:()=>{a()}})]}),x&&e&&(0,Z.jsx)(Y,{title:`Software Updates`,children:(0,Z.jsx)(fn,{assistantId:e.id,currentVersion:n?.version??e.current_release_version??null,onUpgradeComplete:()=>{a()}})}),m===`disabled`&&!x&&(0,Z.jsx)(Y,{title:`Software Updates`,children:(0,Z.jsx)(J,{children:`Log in to the Vellum platform to manage software updates.`})}),(0,Z.jsx)(gn,{}),m===`full`&&_&&u&&(0,Z.jsx)(Y,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Z.jsx)(cn,{assistantId:_.id})}),m===`disabled`&&u&&(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.`})}),(0,Z.jsx)(Lr,{}),(0,Z.jsx)(Tn,{}),s&&(0,Z.jsx)(an,{}),(p===`full`||b)&&_&&(0,Z.jsx)(Y,{variant:`danger`,title:`Retire Assistant`,subtitle:`Permanently retire this assistant and delete all associated data.`,children:(0,Z.jsx)(Rn,{assistantId:_.id})}),p===`disabled`&&!b&&(0,Z.jsx)(Y,{variant:`danger`,title:`Retire Assistant`,subtitle:`Permanently retire this assistant and delete all associated data.`,children:(0,Z.jsx)(J,{children:`Log in to the Vellum platform to retire this assistant.`})}),(0,Z.jsx)(mn,{})]})}export{Rr as GeneralPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{a as t,n,o as r,r as i,s as a}from"./device-settings-BBwtGKJb.js";import{t as o}from"./capture-error-BG-GkiMq.js";import{t as s}from"./react-DJZBPgpf.js";import{t as c}from"./button-D-AX8Voo.js";import{d as l,t as u}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as d}from"./QueryClientProvider-DKhXIxGb.js";import{t as f}from"./useQuery-B45lW1Kk.js";import{t as p}from"./useMutation-Lj4VunQV.js";import{t as m}from"./jsx-runtime-CVSDxk6A.js";import{t as h}from"./cn-DvW5mxZR.js";import{t as g}from"./dropdown-ChWAdhLG.js";import{c as _,l as v,n as y}from"./src-SCpl1O1B.js";import{t as b}from"./confirm-dialog-bfBx6UYv.js";import{t as x}from"./notice-CqRgVmeL.js";import{t as S}from"./progress-bar-DIFlWPPg.js";import{t as C}from"./tag-CW6WC4fE.js";import{t as w}from"./input-D4W4p0pZ.js";import{t as T}from"./toggle-X_kQW5my.js";import{n as E}from"./stat-square-8mff1dLC.js";import{t as D}from"./modal-BNAVT2FK.js";import{n as O}from"./toast-sdJJ6aTV.js";import{D as k,T as A,b as j,c as M,d as N,f as P,g as F,h as I,i as L,r as ee,s as R,x as z}from"./local-mode-CgrENuVf.js";import{t as B}from"./is-electron-C_ZTVhv8.js";import{n as V}from"./resolved-assistants-store-Dqf0LJrA.js";import{t as H}from"./createLucideIcon-BlMXrA59.js";import{t as te}from"./bell-DB1SrBre.js";import{t as ne}from"./check-D6WkI0gF.js";import{t as re}from"./chevron-right-B6vEpVY0.js";import{t as ie}from"./circle-alert-DvNg50UK.js";import{t as ae}from"./circle-check-DzlJxj_M.js";import{t as oe}from"./hard-drive-CZEg1Cqc.js";import{t as U}from"./loader-circle-BFRVtR3K.js";import{t as se}from"./monitor-CXU19mVX.js";import{t as ce}from"./moon-CKINz50a.js";import{t as le}from"./refresh-cw-Dui3Ymsb.js";import{a as ue,c as de,o as fe,r as pe,s as me,t as he}from"./resize-errors-D1myE8D_.js";import{t as ge}from"./sparkles-Bla177ar.js";import{t as _e}from"./triangle-alert-C3aHZq1F.js";import{n as ve,r as W,t as ye}from"./api-errors-DPruG7q9.js";import{D as be,S as xe,T as Se,a as Ce,b as we,g as Te,h as Ee,k as De,l as Oe,n as ke,v as Ae,y as je}from"./auth-store-B1y6dgYQ.js";import{t as G}from"./client.gen-BHupOCJH.js";import{A as Me,S as Ne,V as Pe,Y as Fe,j as Ie,w as Le}from"./sdk.gen-DmWuY0SL.js";import{a as Re,o as ze}from"./api-1X5EQzNF.js";import{a as K}from"./routes-C6gxiCrz.js";import{n as Be,r as Ve}from"./platform-detection-Ceodt3Hu.js";import{t as q}from"./client-feature-flag-store-CHA6YxVq.js";import{r as He,t as Ue}from"./semver-0cyB3qXO.js";import{t as We}from"./assistant-feature-flag-store-Btrsn1VW.js";import{A as Ge,D as Ke,E as qe,M as Je,Q as Ye,T as Xe,bt as Ze,c as Qe,et as $e,gt as et,j as tt,k as nt,v as rt,w as it,wt as at,xt as ot}from"./react-query.gen-gQ1_8EHv.js";import{t as st}from"./proxy-BgtfAoJj.js";import{t as ct}from"./AnimatePresence-uY0BR2n2.js";import{t as lt}from"./use-reduced-motion-BG6r0Z46.js";import{$i as ut,Dn as dt,Ei as ft,Fr as pt,Nr as mt,Oa as ht,On as gt,Pr as _t,Ti as vt,Ut as yt,Wn as bt,_r as xt,d as St,dn as Ct,f as wt,fi as Tt,fn as Et,gi as Dt,gr as Ot,ht as kt,l as At,mn as jt,pn as Mt,ui as Nt,ur as Pt,vr as Ft,x as J}from"./index-B-S-gNKm.js";import{t as It}from"./app-info-DJQFoVxX.js";import{t as Lt}from"./use-active-assistant-id-BVzVN4_g.js";import{t as Y}from"./detail-card-EsA9SOvZ.js";import{t as Rt}from"./environment-store-CnVyTyZ7.js";import{i as zt,n as Bt,r as Vt,t as Ht}from"./assistant-status-panel-D-XT9dcW.js";var Ut=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`}]]),Wt=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(s(),1),Gt=Ee,Kt=`Please choose a different handle.`;async function qt(e,t){let{data:n,error:r,response:i}=await Ie({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:W(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}=we(r,`handle`,Gt.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=we(r,`handle`,Kt);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:W(r,i,`Failed to save handle.`)}}async function Jt(e,t,n){let{data:r,error:i,response:a}=await Ne({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(ve(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new ye(a.status,a.status===429?`Too many checks — try again in a moment.`:W(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function Yt(e){return/\d{2,}$/.test(e)}var Z=m(),Xt=300,Zt=1400;function Qt({initialHandle:e,inputLabel:t,helperText:n,idleHelperText:r,checkAvailable:i,save:a,onSaved:o,saveSuccessToast:s,fieldId:l}){let[u,d]=(0,X.useState)(e),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(`idle`),[v,y]=(0,X.useState)(null),b=lt(),x=(0,X.useRef)(null),S=(0,X.useMemo)(()=>u.trim().toLowerCase(),[u]),C=S===e.toLowerCase();(0,X.useEffect)(()=>{if(C||S.length===0){h(!1),x.current?.abort();return}let e=new AbortController;x.current?.abort(),x.current=e,h(!0);let t=window.setTimeout(async()=>{try{let t=await i(S,e.signal);e.signal.aborted||p(t)}catch(t){e.signal.aborted||y(t instanceof Error?t.message:`Couldn't check availability.`)}finally{e.signal.aborted||h(!1)}},Xt);return()=>{window.clearTimeout(t),e.abort()}},[S,C,i]);let T=(()=>{if(v)return v;if(f&&!f.available){let e=f.code;return f.message??(e?Gt[e]:`Please choose a different handle.`)}return null})(),E=T?n:C?r??null:m?`Checking availability…`:f?.available?`Available.`:null,D=!C&&!m&&f?.available!==!1&&g!==`saving`,k=(0,X.useCallback)(async()=>{if(!D)return;_(`saving`),y(null);let e=await a(S);if(e.kind===`ok`){_(`saved`),o(e.data),O.success(s),window.setTimeout(()=>_(`idle`),Zt);return}if(e.kind===`taken`){_(`idle`),p({available:!1,code:`taken`,message:e.message});return}if(e.kind===`invalid`){_(`idle`),p({available:!1,code:e.code,message:e.message});return}_(`error`),y(e.message),O.error(e.message)},[D,S,o,a,s]),A=(()=>{if(C&&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:b?!1:{opacity:0,scale:.85},animate:{opacity:1,scale:1},exit:b?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)(U,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,Z.jsx)(ne,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":`Available`}),e===`invalid`&&(0,Z.jsx)(ie,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":`Not available`})]},e)}):null})(),j=(()=>{switch(g){case`saving`:return(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(U,{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)(ne,{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)(w,{label:t,value:u,onChange:e=>{d(e.target.value.replace(/\s+/g,``)),p(null),y(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:A,errorText:T??void 0,helperText:E??void 0,"aria-invalid":!!T,fullWidth:!0,"data-testid":`${l}-input`}),(!C||g!==`idle`)&&(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(c,{variant:`primary`,size:`compact`,onClick:k,disabled:!D,"aria-live":`polite`,"data-testid":`${l}-save`,children:j})})]})}function $t({initial:e,onSaved:t}){let n=ke.use.refreshSession(),r=Yt(e.username)?`Your handle was auto-generated at signup — pick one you like.`:void 0,i=(0,X.useCallback)(async e=>await je({username:e}),[]),a=(0,X.useCallback)((e,t)=>Te(e,t),[]),o=(0,X.useCallback)(e=>{t(e),n()},[t,n]);return(0,Z.jsx)(Qt,{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 en({assistant:e,onSaved:t}){let n=e.handle??``,r=f({...Qe({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 qt(e.id,t),[e.id]),s=(0,X.useCallback)((t,n)=>Jt(e.id,t,n),[e.id]);return i?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(w,{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)(u,{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)(Qt,{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 tn(){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 nn({assistant:e}={}){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(null),a=lt(),[o,s]=(0,X.useState)(e??null);return(0,X.useEffect)(()=>{s(e??null)},[e]),(0,X.useEffect)(()=>{let e=!1;return Ae().then(t=>{e||n(t)}).catch(t=>{e||i(t instanceof Error?t.message:`Failed to load profile.`)}),()=>{e=!0}},[]),(0,Z.jsx)(Y,{title:`Profile`,subtitle:`Manage your user and assistant public handles.`,children: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)($t,{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)(en,{assistant:o,onSaved:s})]})]}):(0,Z.jsx)(tn,{})})}var rn=rt({query:{hosting:`platform`}});function an(){let e=Lt(),t=f(rn),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)(se,{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)(C,{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)(ne,{className:`h-4 w-4`}),`Active`]}):(0,Z.jsx)(c,{variant:`outlined`,size:`compact`,disabled:t.status!==`active`,onClick:()=>{De(t.id),O.success(`Switched active assistant.`)},children:`Switch`})})]},t.id)})})})}var on=[{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 sn(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 cn({assistantId:e}){let t=d(),n=Rt.use.isNonProduction(),r=(0,X.useMemo)(()=>on.filter(e=>!e.devOnly||n),[n]),{data:i,isLoading:a,isError:o}=f(tt({path:{id:e}})),s=(0,X.useMemo)(()=>i?.idle_timeout_seconds??259200,[i]),[l,u]=(0,X.useState)(null),p=l??s,m=l!==null,h=ot({onSuccess:()=>{O.success(`Sleep policy saved.`),u(null),t.invalidateQueries({queryKey:Je({path:{id:e}})})},onError:()=>{O.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)(U,{className:`h-4 w-4 animate-spin`}),`Loading sleep settings...`]}):o?(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)(c,{variant:`outlined`,active:p===e.seconds,onClick:()=>u(e.seconds),children:e.label},e.seconds))}),(0,Z.jsxs)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:[`Current: `,sn(p)]})]}),m&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(c,{variant:`primary`,leftIcon:h.isPending?(0,Z.jsx)(U,{className:`animate-spin`}):void 0,onClick:()=>h.mutate({path:{id:e},body:{idle_timeout_seconds:p}}),disabled:h.isPending,children:`Save`}),(0,Z.jsx)(c,{variant:`outlined`,onClick:()=>u(null),disabled:h.isPending,children:`Cancel`})]})]})}function ln(e,t,n){let r=[e.version];return e.version===n&&r.push(`(latest)`),t&&e.version===t&&r.push(`(current)`),r.join(` `)}var un=3e3;function dn({assistantId:e,currentVersion:t,releaseChannel:n,onUpgradeComplete:r}){let i=We.use.rollbackEnabled(),a=q.use.previewChannel(),o=d(),s=Et(n,a),l=s===`preview`,[u,m]=(0,X.useState)(!1),h=(0,X.useRef)(null),[_,v]=(0,X.useState)(null),[y,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(null),E=e=>e&&h.current&&e===h.current?(queueMicrotask(()=>{T(S?`Successfully rolled back to version ${h.current}.`:`Successfully updated to version ${h.current}.`),m(!1),h.current=null,v(null),O.success(S?`Rollback complete — assistant is healthy.`:`Update complete — assistant is healthy.`),r?.()}),!1):un;f({...nt({path:{id:e}}),refetchInterval:u?e=>E(e.state.data?.current_release_version):!1});let{data:D,isLoading:k}=f(et({query:{channel:s}})),A=D?.find(e=>e.is_stable!==!1)??D?.[0],j=_??A?.version??null,M=(0,X.useMemo)(()=>{if(!i||!j||!t)return!1;let e=He(j),n=He(t);return!e||!n?!1:Ue(e,n)<0},[i,j,t]),N=(0,X.useMemo)(()=>{if(!j)return!1;if(!t)return!0;let e=He(j),n=He(t);if(!e||!n)return j!==t;let r=Ue(e,n);return i?r!==0:r>0},[i,j,t]),P=p({mutationFn:async t=>{let{data:n}=await Fe({path:{id:e},body:t,throwOnError:!0});return n}}),F=p({mutationFn:async t=>{let{data:n}=await Pe({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)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:t??`—`})]}),(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`:N?M?`Rollback to`:`Update to`:`Selected`}),(0,Z.jsx)(`span`,{className:`block min-w-0`,children:k?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(U,{className:`h-3 w-3 animate-spin`}),`Loading...`]}):D&&D.length>0?i?(0,Z.jsx)(g,{value:j??``,onChange:e=>v(e===A?.version?null:e),disabled:u||P.isPending||F.isPending,options:D.map(e=>({value:e.version,label:ln(e,t,A?.version)}))}):(0,Z.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:A?ln(A,t,A.version):`—`}):`No releases available`})]})]}),(0,Z.jsx)(c,{variant:M?`outlined`:`primary`,className:`min-w-[160px]`,leftIcon:P.isPending||F.isPending||u?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(le,{}),onClick:()=>x(!0),disabled:!N||P.isPending||F.isPending||u||k||!D?.length,children:u?S?`Rolling back...`:`Updating...`:M?`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`})]}),!N&&t&&j&&!k&&(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:w??`You are already on this version.`}),(0,Z.jsx)(b,{open:y,title:M?`Rollback assistant`:l?`Update preview release`:`Update assistant`,message:M?`Rollback to version ${j??`unknown`}? The assistant will be briefly unavailable.`:l?`Update to preview version ${j??`latest`}? The assistant will be briefly unavailable during the update.`:`Update to version ${j??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:M?`Rollback`:l?`Update preview`:`Update`,onConfirm:async()=>{x(!1),T(null);let t=_??void 0;try{if(M){let e=await F.mutateAsync({version:t});h.current=e.version??t??null,O.success(e.detail||`Rollback to ${t} initiated.`)}else{let e=await P.mutateAsync({version:t});if(e.detail?.includes(`Already on the latest`)){O.warning(e.detail);return}h.current=e.version??t??null,O.success(e.detail||`Update to ${e.version??t??`latest`} initiated.`)}C(M),m(!0),o.invalidateQueries({queryKey:Ge({path:{id:e}})})}catch{O.error(M?`Failed to trigger rollback. Please try again.`:`Failed to trigger update. Please try again.`)}},onCancel:()=>x(!1)})]})}function fn({assistantId:e,currentVersion:t,onUpgradeComplete:n}){let[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(null),{data:s,isLoading:l}=f(et({query:{stable:!0,limit:100}})),u=(0,X.useMemo)(()=>Ct(s),[s]),d=u?.version,p=t?Mt(t,d):!!d,m=jt({assistantId:e,targetVersion:d});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)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:t??`—`})]}),(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...`:d&&u?ln(u,t,d):`No releases available`})]})]}),(0,Z.jsx)(c,{variant:`primary`,className:`min-w-[160px]`,leftIcon:m.isPending?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(le,{}),onClick:()=>i(!0),disabled:m.isPending||l||!d||!p,children:m.isPending?`Updating...`:d?`Update to ${d}`:`Update`}),a&&(0,Z.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:a}),!a&&!p&&d&&!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)(b,{open:r,title:`Update assistant`,message:`Update to version ${d??`latest`}? The assistant will be briefly unavailable during the update.`,confirmLabel:`Update`,onConfirm:async()=>{i(!1),o(null);try{let e=await m.upgrade();o(e.version?`Successfully updated to version ${e.version}.`:`Successfully updated to version ${d??`latest`}.`),O.success(`Update complete — assistant is healthy.`),n?.()}catch(e){O.error(e instanceof Error?e.message:`Failed to trigger update. Please try again.`)}},onCancel:()=>i(!1)})]})}function pn(){let e=wt.useValue();if(bt())return null;let t=Be()?`Cmd`:`Ctrl`;return(0,Z.jsx)(Y,{title:`Composer`,children:(0,Z.jsx)(T,{checked:e,onChange:wt.save,label:`Send with ${t}+Enter`,helperText:`When enabled, Enter inserts a new line and ${t}+Enter sends.`})})}function mn(){let e=pt({platformHostedOnly:!0}),t=_t(),n=ke.use.user()?.id??null,r=ke.use.logout(),[i,a]=(0,X.useState)(!1),o=at({onSuccess:async()=>{O.success(`Account deletion requested. You will be logged out shortly.`),Oe(n),await r(),Pt(K.account.login)},onError:()=>{O.error(`Failed to request account deletion. Please try again.`)}}),s=e===`full`&&t;return(0,X.useEffect)(()=>{s&&i&&a(!1)},[s,i]),e===`gated`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{title:`Delete Account`,subtitle:`Permanently delete your account and all associated data.`,variant:`danger`,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)(c,{variant:`dangerOutline`,onClick:()=>a(!0),disabled:o.isPending||s,className:`self-start`,children:`Delete My Account`}),s&&(0,Z.jsx)(U,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})}),(0,Z.jsx)(b,{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(s){a(!1);return}a(!1),o.mutate({})},onCancel:()=>a(!1)})]})}function hn({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)(c,{variant:`primary`,size:`regular`,leftIcon:i,onClick:a,className:`self-start`,children:r})]})})}function gn(){return Ve()?(0,Z.jsx)(hn,{title:`Get the iOS App`,subtitle:`The Vellum iOS app gives you a native experience.`,benefits:[{icon:te,text:`Push notifications`},{icon:Ut,text:`Biometric login`},{icon:Wt,text:`Native haptics`},{icon:Dt,text:`Home screen access`}],ctaLabel:`Download`,ctaLeftIcon:(0,Z.jsx)(Dt,{size:16}),onAction:()=>{St(),At()}}):null}async function _n(){if(!B())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function vn(e){if(!B())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function yn(){let[e,t]=(0,X.useState)(!1);(0,X.useEffect)(()=>{_n().then(t)},[]);let n=async e=>{t(e);try{await vn(e)}catch{t(!e)}};return(0,Z.jsx)(Y,{title:`Launch at Login`,subtitle:`Automatically start Vellum when you log in to your Mac.`,children:(0,Z.jsx)(T,{checked:e,onChange:e=>void n(e),"aria-label":`Launch at Login`})})}function bn({className:e}){return(0,Z.jsx)(`div`,{role:`presentation`,className:h(`h-px w-full bg-[var(--border-base)]`,e)})}var xn=[`youtube.com`,`youtu.be`,`vimeo.com`,`loom.com`];function Sn(e){try{let t=JSON.parse(e);if(Array.isArray(t))return t.filter(e=>typeof e==`string`)}catch{}return[...xn]}function Cn(){return n(`mediaEmbedsEnabled`,!0)}function wn(){let e=i(`mediaEmbedDomains`,``);return e?Sn(e):[...xn]}function Tn(){let[e,n]=(0,X.useState)(()=>Cn()),[i,a]=(0,X.useState)(()=>wn()),[o,s]=(0,X.useState)(!1),[l,u]=(0,X.useState)(``),d=(0,X.useMemo)(()=>l.trim().toLowerCase(),[l]),f=e=>{n(e),t(`mediaEmbedsEnabled`,e)},p=e=>{a(e),r(`mediaEmbedDomains`,JSON.stringify(e))},m=()=>{if(d){if(i.includes(d)){u(``);return}p([...i,d]),u(``)}},h=e=>{p(i.filter(t=>t!==e))},g=()=>{p([...xn])},_=i.length===xn.length&&i.every((e,t)=>e===xn[t]);return(0,Z.jsxs)(Y,{title:`Media Embeds`,subtitle:`Automatically embed images, videos, and other media shared in chat messages.`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Auto Media Embeds`}),(0,Z.jsx)(T,{checked:e,onChange:f})]}),e&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(bn,{})}),(0,Z.jsxs)(c,{type:`button`,variant:`ghost`,onClick:()=>s(e=>!e),className:`mt-4 w-full justify-between px-3`,"aria-expanded":o,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[o?(0,Z.jsx)(ht,{className:`h-4 w-4`,"aria-hidden":!0}):(0,Z.jsx)(re,{className:`h-4 w-4`,"aria-hidden":!0}),`Video Domain Allowlist`]}),(0,Z.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[i.length,` domain`,i.length===1?``:`s`]})]}),o&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Z.jsx)(w,{label:`Add Domain`,type:`text`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),m())},placeholder:`Add domain (e.g. example.com)`,fullWidth:!0,wrapperClassName:`flex-1`}),(0,Z.jsx)(c,{variant:`primary`,size:`compact`,onClick:m,disabled:!d,children:`Add`})]}),i.length>0&&(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,onClick:g,disabled:_,tintColor:`var(--content-tertiary)`,children:`Reset to Defaults`})}),i.length>0&&(0,Z.jsx)(`ul`,{className:`space-y-2`,children:i.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center justify-between rounded-md border border-[var(--border-base)] px-3 py-2 text-body-medium-lighter`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-[var(--content-default)]`,children:e}),(0,Z.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Z.jsx)(Nt,{}),onClick:()=>h(e),"aria-label":`Remove ${e}`})]},e))})]})]})]})}function En(e){return e===`preview`?`preview`:`stable`}function Dn(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 On(e){return e.source_release_version?`Stable ${e.source_release_version}`:e.snapshot_name}function kn(e){return e.filter(e=>e.ready_to_use)}function An(e){return e?.feature_enabled===!1}function jn({assistantId:e,onComplete:t}){let n=q.use.previewChannel(),r=d(),[i,a]=(0,X.useState)(),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,m]=(0,X.useState)(`restore_backup`),[h,g]=(0,X.useState)(``),_=qe({path:{assistant_id:e}}),v=Ke({path:{assistant_id:e}}),b=Ge({path:{id:e}}),{data:S,isLoading:w,isError:T}=f({..._,enabled:n,retry:!1}),E=S?.preview_backups??[],D=(0,X.useMemo)(()=>kn(E),[E]),k=D[0],A=D.find(e=>e.snapshot_name===h)??k,j=()=>{r.invalidateQueries({queryKey:v}),r.invalidateQueries({queryKey:b}),t?.()},M=p(it()),N=p(Xe()),P=En(S?.current_channel),F=M.isPending||N.isPending,I=F||An(S)||!S?.latest_preview_release,L=u===`restore_backup`&&!A;if((0,X.useEffect)(()=>{a(P===`preview`?`release-channel`:void 0)},[P]),!n)return null;let ee=S?.standard_upgrade_available??!1;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(y.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)(y.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,Z.jsxs)(y.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`}),S&&(0,Z.jsx)(C,{tone:P===`preview`?`warning`:`neutral`,children:P===`preview`?`Preview`:`Stable`})]}),(0,Z.jsx)(ht,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Z.jsx)(y.Content,{children:(0,Z.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[w&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Z.jsx)(U,{className:`h-4 w-4 animate-spin`}),`Loading release channel...`]}),T&&(0,Z.jsx)(x,{tone:`error`,title:`Could not load release channel status`,children:`Refresh this page before changing release channels.`}),S&&(0,Z.jsxs)(Z.Fragment,{children:[An(S)&&(0,Z.jsx)(x,{tone:`neutral`,title:`Preview channel is unavailable`,children:`The Preview channel is not enabled for this assistant.`}),P===`stable`?(0,Z.jsx)(Mn,{status:S,isChangingChannel:F,optInDisabled:I,onOptIn:()=>s(!0)}):(0,Z.jsx)(Nn,{status:S,isChangingChannel:F,onOptOut:()=>{let e=k;g(e?.snapshot_name??``),m(e?`restore_backup`:ee?`standard_upgrade`:`restore_backup`),l(!0)}})]})]})})]})}),(0,Z.jsx)(Fn,{open:o,isPending:M.isPending,previewVersion:S?.latest_preview_release?.version,onConfirm:async()=>{try{let t=await M.mutateAsync({path:{assistant_id:e}});O.success(t.detail||`Preview channel enabled.`),s(!1),j()}catch(e){O.error(W(e,void 0,`Could not enable Preview channel.`))}},onCancel:()=>s(!1)}),(0,Z.jsx)(In,{open:c,backups:D,mode:u,selectedSnapshotName:A?.snapshot_name??``,isPending:N.isPending,restoreModeDisabled:L,standardUpgradeAvailable:ee,onModeChange:m,onSnapshotChange:g,onConfirm:async()=>{if(!L)try{let t=await N.mutateAsync({path:{assistant_id:e},body:u===`restore_backup`?{mode:`restore_backup`,snapshot_name:A?.snapshot_name}:{mode:`standard_upgrade`}});O.success(t.detail||`Stable channel enabled.`),l(!1),j()}catch(e){O.error(W(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>l(!1)})]})}function Mn({status:e,isChangingChannel:t,optInDisabled:n,onOptIn:r}){return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Pn,{status:e}),!e.latest_preview_release&&(0,Z.jsx)(x,{tone:`neutral`,title:`No Preview release is available`,children:`Stable remains the only available release channel.`}),(0,Z.jsx)(c,{variant:`outlined`,leftIcon:t?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(ft,{}),disabled:n,onClick:r,children:`Opt in to Preview`})]})}function Nn({status:e,isChangingChannel:t,onOptOut:n}){return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Pn,{status:e}),(0,Z.jsx)(c,{variant:`outlined`,leftIcon:t?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(vt,{}),disabled:t,onClick:n,children:`Switch back to Stable`})]})}function Pn({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 Fn({open:e,isPending:t,previewVersion:n,onConfirm:r,onCancel:i}){return(0,Z.jsx)(D.Root,{open:e,onOpenChange:e=>!e&&i(),children:(0,Z.jsxs)(D.Content,{size:`md`,hideCloseButton:t,children:[(0,Z.jsxs)(D.Header,{children:[(0,Z.jsx)(D.Title,{icon:_e,children:`Opt in to Preview`}),(0,Z.jsx)(D.Description,{children:`Preview releases may be unstable. A 90-day safety backup is taken before the image changes.`})]}),(0,Z.jsx)(D.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(x,{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)(D.Footer,{children:[(0,Z.jsx)(c,{variant:`outlined`,disabled:t,onClick:i,children:`Cancel`}),(0,Z.jsx)(c,{variant:`primary`,disabled:t,leftIcon:t?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(ft,{}),onClick:r,children:t?`Switching...`:`Take Backup and Switch`})]})]})})}function In({open:e,backups:t,mode:n,selectedSnapshotName:r,isPending:i,restoreModeDisabled:a,standardUpgradeAvailable:o,onModeChange:s,onSnapshotChange:l,onConfirm:u,onCancel:d}){return(0,Z.jsx)(D.Root,{open:e,onOpenChange:e=>!e&&d(),children:(0,Z.jsxs)(D.Content,{size:`md`,hideCloseButton:i,children:[(0,Z.jsxs)(D.Header,{children:[(0,Z.jsx)(D.Title,{icon:_e,children:`Switch back to Stable`}),(0,Z.jsx)(D.Description,{children:`Choose how this assistant should leave the Preview channel.`})]}),(0,Z.jsx)(D.Body,{children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(v,{value:n,onValueChange:s,disabled:i,"aria-label":`Stable channel return method`,children:[(0,Z.jsx)(_,{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)(_,{value:`standard_upgrade`,disabled:!o,label:`Switch to Stable without restoring backup`,helperText:o?`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)(g,{value:r,onChange:l,disabled:i,options:t.map(e=>({value:e.snapshot_name,label:`${On(e)} - ${Dn(e.created_at)}`}))})]}),n===`restore_backup`&&t.length===0&&!o&&(0,Z.jsx)(x,{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)(x,{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)(D.Footer,{children:[(0,Z.jsx)(c,{variant:`outlined`,disabled:i,onClick:d,children:`Cancel`}),(0,Z.jsx)(c,{variant:n===`standard_upgrade`?`danger`:`primary`,disabled:i||a||n===`standard_upgrade`&&!o,leftIcon:i?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(le,{}),onClick:u,children:i?`Switching...`:`Switch to Stable`})]})]})})}function Ln({assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:a}){let o=l(),s=f($e()),d=s.data,p=!e.is_local,m=d?.plan_id===`pro`,h=f({...Ye(),enabled:m}),_=e.machine_size||`small`,v=ue(h.data?.max_machine_tier??null),y=(0,X.useMemo)(()=>fe(v,_,(0,Z.jsx)(C,{tone:`positive`,children:`Current`})),[v,_]),b=h.data?.selected_storage_gib??null,[S,w]=(0,X.useState)(!1),T=v.length>0?v[v.length-1]:null,[E,k]=(0,X.useState)(null),A=E??T??_,[j,M]=(0,X.useState)(null),[N,P]=(0,X.useState)(null),F=Ze({onSuccess:(e,n)=>{O.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),P(null),k(null),w(!1),n.body?.machine_size==null?i():a(t)},onError:e=>{P(he(e,`Failed to resize assistant. Please try again.`))}});if(s.isError&&d==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)(x,{tone:`error`,children:`Could not load your subscription. Please try again.`})});let I=m&&v.includes(A)&&A!==_?A:null,L=m&&b!=null&&!0,ee=m&&v.length>0&&me(_)<me(v[v.length-1]),R=F.isPending||r,z=b==null?t?.disk?.totalMb??null:b*1024,B=t?.disk&&z!=null?{value:t.disk.usedMb,max:z,caption:`${Bt(t.disk.usedMb)} of ${Bt(z)}`}:null,V=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,H=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:`${Bt(t.memory.currentMb)} of ${Bt(t.memory.maxMb)}`}:null,te=p?m?L?(0,Z.jsxs)(`button`,{type:`button`,disabled:R,onClick:()=>w(!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)(ge,{className:`h-3.5 w-3.5`}),`Increase Storage`]}):(0,Z.jsx)(c,{variant:`ghost`,size:`compact`,disabled:R,onClick:()=>w(!0),children:`Resize`}):(0,Z.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>M(`storage`),children:`Resize`}):null,ne=p?m?ee?(0,Z.jsxs)(`button`,{type:`button`,disabled:R,onClick:()=>w(!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)(ge,{className:`h-3.5 w-3.5`}),`Increase Size`]}):(0,Z.jsx)(c,{variant:`ghost`,size:`compact`,disabled:R,onClick:()=>w(!0),children:`Resize`}):(0,Z.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>M(`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)(c,{variant:`ghost`,size:`compact`,iconOnly:n||r?(0,Z.jsx)(U,{className:`animate-spin`}):(0,Z.jsx)(le,{}),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)(oe,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Disk`})]}),te]}),(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`}),B?(0,Z.jsx)(zt,{value:B.value,max:B.max,caption:B.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(U,{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)(de,{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)(C,{tone:`neutral`,children:pe[_]})]}),ne]}),(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`}),V?(0,Z.jsx)(zt,{value:V.value,max:V.max,caption:V.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(U,{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`}),H?(0,Z.jsx)(zt,{value:H.value,max:H.max,caption:H.caption}):n?(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Z.jsx)(U,{className:`h-3 w-3 animate-spin`})}):(0,Z.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,Z.jsx)(D.Root,{open:j!=null,onOpenChange:e=>{e||M(null)},children:(0,Z.jsxs)(D.Content,{size:`sm`,children:[(0,Z.jsxs)(D.Header,{children:[(0,Z.jsx)(D.Title,{children:`Upgrade to Pro`}),(0,Z.jsx)(D.Description,{children:j===`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)(D.Footer,{children:[(0,Z.jsx)(c,{variant:`ghost`,onClick:()=>M(null),children:`Cancel`}),(0,Z.jsx)(c,{onClick:()=>{M(null),o(`${K.settings.billing}?adjust_plan=1`)},children:`Upgrade`})]})]})}),(0,Z.jsx)(D.Root,{open:S,onOpenChange:e=>{e||(w(!1),k(null),P(null))},children:(0,Z.jsxs)(D.Content,{size:`sm`,children:[(0,Z.jsxs)(D.Header,{children:[(0,Z.jsx)(D.Title,{icon:de,children:`Resize Assistant`}),(0,Z.jsx)(D.Description,{children:`Resize your assistant's compute and storage. Your assistant will briefly restart.`})]}),(0,Z.jsx)(D.Body,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[v.length===0?(0,Z.jsx)(x,{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)(g,{options:y,value:A,onChange:k,"aria-label":`Compute machine size`,"data-testid":`resize-machine-size`})]}),L?(0,Z.jsx)(x,{tone:`info`,children:`Storage will be expanded to ${b} GiB.`}):(0,Z.jsx)(x,{tone:`neutral`,children:`Storage will not change.`}),N&&(0,Z.jsx)(x,{tone:`error`,children:N})]})}),(0,Z.jsxs)(D.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)(u,{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:()=>w(!1),children:`Upgrade plan`})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(c,{variant:`ghost`,onClick:()=>{w(!1),k(null),P(null)},children:`Cancel`}),(0,Z.jsx)(c,{disabled:I==null&&!L||R,leftIcon:R?(0,Z.jsx)(U,{className:`animate-spin`}):void 0,onClick:()=>{P(null);let t={};I!=null&&(t.machine_size=I),L&&b!=null&&(t.storage_gib=b),F.mutate({path:{id:e.id},body:t})},children:N?`Retry`:`Apply`})]})]})]})})]})}function Rn({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)(c,{variant:`dangerOutline`,onClick:()=>r(!0),className:`shrink-0`,children:`Retire Assistant`}),(0,Z.jsx)(dt,{open:n,isPending:i,onConfirm:async()=>{a(!0);let n=await gt(e);if(n.ok){r(!1),t(n.nextRoute,{replace:!0});return}O.error(n.error),a(!1),r(!1)},onCancel:()=>r(!1)})]})}var zn=`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 Bn(){let e=Intl;if(typeof e.supportedValuesOf==`function`)try{let t=e.supportedValuesOf(`timeZone`);if(t.length>0)return[...t].sort()}catch{}return[...zn].sort()}function Vn(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 Hn(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour:`numeric`,minute:`2-digit`,hour12:!0}).format(new Date)}catch{return``}}function Un(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 Wn({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)(()=>Bn().map(e=>Vn(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)(w,{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:Hn(t.identifier)}),(0,Z.jsx)(`span`,{children:t.offsetLabel})]})]},t.identifier))})]})]}),(0,Z.jsx)(bn,{}),(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:Un(e)})]})]})}var Q=class extends Error{code;constructor(e,t){super(t),this.name=`TeleportError`,this.code=e}},Gn=`local`,Kn=`docker`,qn=`vellum`;function Jn(e){switch((e??``).toLowerCase()){case Gn:return`local`;case Kn:return`docker`;case qn:return`managed`;default:return`other`}}function Yn(e){let t=Jn(e);return t===`managed`?`local`:t===`local`?`platform`:null}function Xn(e){switch(e){case`docker`:return`Move to Docker`;case`platform`:return`Move to Cloud (Platform)`;case`local`:return`Move to Local`}}function Zn(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 Qn(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 $n(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 er(e){let t=L(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 tr(e,t){let n=await A(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 nr(e,t){let n=er(e),r=await tr(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 $n(i,t)}async function rr(e,t){let n=er(e),r=await tr(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 or(i);if(a&&a.success===!1)throw new Q(`import_failed`,a.error??`Import reported failure`)}async function ir(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 ar(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 or(e){try{return await e.json()}catch{return null}}var sr=new Set([500,502,503,504]),$=3,cr=e=>new Promise(t=>setTimeout(t,e));async function lr(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<$&&sr.has(o)&&!t.has(o)){await cr(2**n*1e3);continue}return{status:o,data:i,error:a}}throw new Q(`unknown`,`Unexpected retry loop exit`)}async function ur(e){let t={operation:`upload`};e&&(t.min_runtime_version=e,t.max_runtime_version=null);let{status:n,data:r}=await lr(()=>G.post({url:`/v1/migrations/signed-url/`,body:t,throwOnError:!1}),new Set([404,503]));if(n===503||n===404)throw new Q(`export_failed`,`Signed URL uploads are not available — the platform may not support this feature yet.`);if(n!==201)throw new Q(`export_failed`,`Migration request failed (HTTP ${n}).`);let i=r;return{url:i.url,bundleKey:i.bundle_key,expiresAt:i.expires_at}}async function dr(e,t){let{status:n,data:r,error:i}=await lr(()=>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=Qn(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 fr(e,t,n){for(let r=0;r<=$;r++){let i=await pr(e,t,n);if(r<$&&sr.has(i)){await cr(2**r*1e3),n?.(0);continue}if(i<200||i>=300)throw new Q(`export_failed`,`Bundle upload failed (HTTP ${i}).`);return}}function pr(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 mr(e,t){for(let n=0;n<=$;n++){let r=await fetch(e,{method:`GET`});if(n<$&&sr.has(r.status)){await cr(2**n*1e3),t?.(0);continue}if(!r.ok)throw new Q(`import_failed`,`Bundle download failed (HTTP ${r.status}).`);return $n(r,t)}throw new Q(`import_failed`,`Unexpected retry loop exit`)}async function hr(e){let{status:t,data:n,error:r}=await lr(()=>G.post({url:`/v1/migrations/import-from-gcs/`,body:{bundle_key:e},throwOnError:!1}));return{status:t,body:n??r??null}}async function gr(e){let{status:t,data:n}=await lr(()=>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 _r=5e3,vr=36e5,yr=5*6e4,br=30,xr=e=>new Promise(t=>setTimeout(t,e));function Sr(){let e=l(),t=M(),n=Yn(t?.cloud),[r,i]=(0,X.useState)({kind:`idle`}),[a,s]=(0,X.useState)(!1),c=(0,X.useRef)(null),u=(0,X.useRef)(null),d=(0,X.useCallback)(e=>{i({kind:`transferring`,step:e,progress:null})},[]),f=(0,X.useCallback)(e=>{i(t=>t.kind===`transferring`?{...t,progress:e}:t)},[]),p=(0,X.useCallback)(async()=>{if(!(!t||!n)){u.current={id:t.assistantId,kind:Jn(t.cloud)===`managed`?`managed`:`local`,createdFresh:!1};try{if(n===`platform`)await Cr(t,d,f,c);else if(n===`local`)await wr(t,d,f,c);else throw new Q(`unknown`,`Unsupported teleport destination.`);i({kind:`verifying`})}catch(e){i({kind:`failed`,error:`Teleport failed: ${e instanceof Q||e instanceof Error?e.message:`Teleport failed.`}`}),o(e,{context:`teleport-execute`}),await Er(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,i({kind:`idle`})},[]);return{destination:n,phase:r,confirmOpen:a,requestTeleport:m,cancelConfirm:h,confirm:g,confirmAndSwitch:(0,X.useCallback)(()=>{let t=c.current,n=u.current;t&&(async()=>{try{let e=ke.getState();t.kind===`managed`?await e.connectPlatformAssistant(t.id):(await e.connectLocalAssistant(t.id),xe(t.id,{onError:e=>o(e,{context:`teleport-inject-platform-identity`})}))}catch(e){i({kind:`failed`,error:`Switch failed: ${e instanceof Error?e.message:`Failed to switch assistant.`}`}),o(e,{context:`teleport-confirm-switch`});return}n&&gt(n.id).then(e=>{e.ok||o(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,i({kind:`idle`}),Er(e,t,`teleport-cancel-retire-target`)},[]),reset:_}}async function Cr(e,t,n,r){t(`Exporting assistant data...`);let i=await nr(e,n);t(`Resolving organization...`);let a=await Or();t(`Checking for existing assistant...`);let o=(await Le({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 fr(s.url,i,n),t(`Setting up cloud assistant...`);let c=await ze(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 j({assistantId:l,name:c.data.name,cloud:`vellum`,runtimeUrl:R(),hatchedAt:c.data.created??new Date().toISOString(),organizationId:a}),await z(e.assistantId),r.current={id:l,kind:`managed`,createdFresh:!0},t(`Finalizing cloud assistant...`),await kr(l),t(`Importing data to cloud...`);let u=await hr(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 Ar(e)}else{let e=u.body;if(e&&e.success===!1)throw new Q(`import_failed`,e.error??`Import reported failure.`)}}async function wr(e,t,n,r){t(`Preparing export...`);let i=await ur(await Dr(e.assistantId));t(`Exporting cloud data...`);let a=await ir(e.assistantId,i.url);await jr(e.assistantId,a),t(`Preparing local assistant...`);let{assistant:o,createdFresh:s}=await Mr();r.current={id:o.assistantId,kind:`local`,createdFresh:s};let c=await Tr(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 dr(i.bundleKey,c);t(`Downloading data...`);let u=await mr(l,n);t(`Importing data...`),await Pr(o,u),await z(e.assistantId)}async function Tr(e,t){if(e.resources?.runtimeVersion)return e.resources.runtimeVersion;if(t)return(await It())?.version??void 0}async function Er(e,t,n){if(e?.createdFresh){let t=await gt(e.id);t.ok||o(Error(t.error),{context:n})}t&&await z(t.id)}async function Dr(e){let t=await Re(e);return t.ok?t.data.version??void 0:void 0}async function Or(){let e=be.getState();e.organizations.length===0&&await e.fetchOrganizations();let t=be.getState().organizations,n=Se();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 be.getState().setCurrentOrganizationId(r),r}async function kr(e){let t=Date.now();for(;Date.now()-t<yr;){let{data:t,response:n}=await Me({path:{id:e},throwOnError:!1});if(n?.ok&&t?.state===`active`)return;await xr(_r)}}async function Ar(e){let t=Date.now();for(;Date.now()-t<vr;){await xr(_r);let t=await gr(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 jr(e,t){let n=Date.now();for(;Date.now()-n<vr;)if(await xr(_r),await ar(e,t)===`complete`)return;throw new Q(`export_timed_out`,`Export timed out.`)}async function Mr(){let e=await k(void 0,void 0);if(!e.ok)throw new Q(`local_assistant_not_found`,e.error??`Could not create a local assistant.`);await F();let t=e.assistantId?ee().find(t=>t.assistantId===e.assistantId):Nr();if(!t)throw new Q(`local_assistant_not_found`,`Could not find or create a local assistant.`);return{assistant:t,createdFresh:!0}}function Nr(){return ee().slice().sort((e,t)=>(t.hatchedAt??``).localeCompare(e.hatchedAt??``))[0]}async function Pr(e,t){let n;for(let r=0;r<br;r++)try{await rr(e,t);return}catch(e){n=e,await xr(1e3)}throw n instanceof Error?n:new Q(`import_failed`,`Import failed.`)}function Fr(){let e=Sr(),{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:Zn(t)}),(0,Z.jsx)(c,{variant:`outlined`,className:`self-start`,onClick:e.requestTeleport,children:Xn(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)(U,{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)(S,{value:n.progress,"aria-label":`Teleport progress`,className:`max-w-[240px]`})]}),n.kind===`verifying`&&(0,Z.jsx)(x,{tone:`success`,icon:(0,Z.jsx)(ae,{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)(c,{variant:`primary`,onClick:e.confirmAndSwitch,children:`Confirm & Switch`}),(0,Z.jsx)(c,{variant:`outlined`,onClick:e.cancelTeleport,children:`Cancel`})]})}),n.kind===`failed`&&(0,Z.jsx)(x,{tone:`error`,title:n.error,actions:(0,Z.jsx)(c,{variant:`outlined`,onClick:e.reset,children:`Try Again`})}),(0,Z.jsx)(b,{open:e.confirmOpen,title:Xn(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 Ir(){let e=q.use.velvet(),[t,n]=(0,X.useState)(()=>xt({velvetEnabled:e}));return(0,X.useEffect)(()=>{n(xt({velvetEnabled:e}))},[e]),(0,X.useEffect)(()=>a(`theme`,()=>{n(xt({velvetEnabled:e}))}),[e]),(0,X.useEffect)(()=>{Ot(t)},[t]),(0,Z.jsx)(Y,{title:`Theme`,children:(0,Z.jsx)(`div`,{className:`max-w-[360px]`,children:(0,Z.jsx)(E,{ariaLabel:`Theme`,value:t,onChange:e=>{n(e),Ft(e),Ot(e)},items:[{value:`system`,label:`System`,icon:(0,Z.jsx)(se,{className:`h-4 w-4`})},{value:`light`,label:`Light`,icon:(0,Z.jsx)(Tt,{className:`h-4 w-4`})},{value:`dark`,label:`Dark`,icon:(0,Z.jsx)(ce,{className:`h-4 w-4`})},...e?[{value:`velvet`,label:`Velvet`,icon:(0,Z.jsx)(ut,{className:`h-4 w-4`})}]:[]]})})})}function Lr(){let e=V.use.activeAssistantId(),[t,n]=(0,X.useState)(()=>i(`timezone`,``)),a=(0,X.useRef)(e);(0,X.useEffect)(()=>{a.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=a.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=>{o(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.jsx)(Y,{title:`Timezone`,subtitle:`Used when displaying times and scheduling reminders.`,children:(0,Z.jsx)(Wn,{value:t,onChange:e=>{n(e),r(`timezone`,e),u(e)}})})}function Rr(){let{assistant:e,assistantLoading:t,healthz:n,healthzLoading:r,healthzPolling:i,refetch:a,refetchUntilResized:o}=Vt(),s=q.use.multiPlatformAssistant(),c=q.use.teleport(),u=We.use.settingsSleepPolicy(),d=Ce(),f=l(),p=pt(),m=pt({platformHostedOnly:!0}),h=mt(),g=yt({assistantId:e?.id??null,enabled:m===`full`&&h}),_=e?.is_local&&!P()?null:e,v=M(),y=P()&&!!e&&!!v&&N(v),b=y,x=y&&!I();return(0,X.useEffect)(()=>{!e||window.location.hash!==`#storage-resources`||requestAnimationFrame(()=>{document.getElementById(`storage-resources`)?.scrollIntoView({block:`start`})})},[e]),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[g.status&&g.mode!==`inactive`&&(0,Z.jsx)(kt,{status:g.status,mode:g.mode,isAcknowledging:g.isAcknowledging,acknowledgeError:g.acknowledgeError?.message??null,onAcknowledge:()=>void g.acknowledge(),onReviewWorkspaceData:()=>void f(`${K.workspace}?sort=size`),onUpgradeStorage:m===`full`?()=>void f(`${K.settings.billing}?adjust_plan=1`):null}),(0,Z.jsx)(Y,{title:`General`,children:(0,Z.jsx)(Ht,{assistant:_,assistantLoading:t,healthz:n,healthzLoading:r})}),d&&p===`full`&&(0,Z.jsx)(nn,{assistant:h?_:null}),m===`full`&&e&&(0,Z.jsx)(Ln,{assistant:e,healthz:n,healthzLoading:r,healthzPolling:i,refetch:a,refetchUntilResized:o}),m===`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)(Ir,{}),(0,Z.jsx)(pn,{}),B()&&(0,Z.jsx)(yn,{}),c&&B()&&(0,Z.jsx)(Fr,{}),m===`full`&&_&&(0,Z.jsxs)(Y,{title:`Software Updates`,children:[(0,Z.jsx)(dn,{assistantId:_.id,currentVersion:n?.version??_.current_release_version??null,releaseChannel:_.release_channel,onUpgradeComplete:()=>{a()}}),(0,Z.jsx)(jn,{assistantId:_.id,onComplete:()=>{a()}})]}),x&&e&&(0,Z.jsx)(Y,{title:`Software Updates`,children:(0,Z.jsx)(fn,{assistantId:e.id,currentVersion:n?.version??e.current_release_version??null,onUpgradeComplete:()=>{a()}})}),m===`disabled`&&!x&&(0,Z.jsx)(Y,{title:`Software Updates`,children:(0,Z.jsx)(J,{children:`Log in to the Vellum platform to manage software updates.`})}),(0,Z.jsx)(gn,{}),m===`full`&&_&&u&&(0,Z.jsx)(Y,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Z.jsx)(cn,{assistantId:_.id})}),m===`disabled`&&u&&(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.`})}),(0,Z.jsx)(Lr,{}),(0,Z.jsx)(Tn,{}),s&&(0,Z.jsx)(an,{}),(p===`full`||b)&&_&&(0,Z.jsx)(Y,{variant:`danger`,title:`Retire Assistant`,subtitle:`Permanently retire this assistant and delete all associated data.`,children:(0,Z.jsx)(Rn,{assistantId:_.id})}),p===`disabled`&&!b&&(0,Z.jsx)(Y,{variant:`danger`,title:`Retire Assistant`,subtitle:`Permanently retire this assistant and delete all associated data.`,children:(0,Z.jsx)(J,{children:`Log in to the Vellum platform to retire this assistant.`})}),(0,Z.jsx)(mn,{})]})}export{Rr as GeneralPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,t as n}from"./capture-error-BG-GkiMq.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-D-AX8Voo.js";import{d as a,h as o}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./jsx-runtime-CVSDxk6A.js";import{t as l}from"./progress-bar-DIFlWPPg.js";import{D as ee,_ as te,b as u,f as d,g as ne,i as re,s as f,tt as ie}from"./local-mode-CgrENuVf.js";import{t as p}from"./is-electron-C_ZTVhv8.js";import{n as m}from"./resolved-assistants-store-Dqf0LJrA.js";import{r as ae}from"./api-errors-DPruG7q9.js";import{A as h,B as oe,D as g,L as se,P as _,R as ce,k as v,n as y,z as b}from"./auth-store-B1y6dgYQ.js";import{a as le,o as ue,r as x}from"./api-1X5EQzNF.js";import{u as de}from"./native-biometric-BK6_QtW5.js";import{a as S}from"./routes-C6gxiCrz.js";import{r as C,t as w}from"./build-state-B-RL-LxH.js";import{i as fe,p as pe}from"./prefs-Ds__U7Hi.js";import{t as T}from"./avatar-svg-compositor-CNy1XmWD.js";import{ar as E,ir as D,rn as O,tr as k}from"./index-CZ2UBc_U.js";import{t as me}from"./provider-key-Ba5Bw5MO.js";import{BUNDLED_COMPONENTS as A}from"./avatar-bundled-components-w37NPF4o.js";var j=e(r(),1);async function he(e,t,r){try{await D(e)||await E(e,t),r.invalidateQueries({queryKey:k(e)})}catch(e){n(e,{context:`onboarding_avatar_sync`})}}function ge(e){let t=e=>e[Math.floor(Math.random()*e.length)];return{bodyShape:t(e.bodyShapes).id,eyeStyle:t(e.eyeStyles).id,color:t(e.colors).id}}var M=c(),N=3e3,_e=800,P=3e5,F=null,I=null,L=null;function R(){F=null,I=null,L=null}var ve={initializing:0,provisioning:.33,connecting:.66,ready:1},z=1500,ye={initializing:`Getting things ready…`,provisioning:`Setting up your assistant…`,connecting:`Connecting to your assistant…`,ready:`Ready`};function be(e,t,n){if(e>=t)return t;let r=1-(1-Math.min(1,n/z))**3;return e+(t-e)*r}function xe(){let e=C(w(),{kind:`hatch-gate`});return e.action===`redirect`?{kind:`redirect`,to:e.to}:e.action===`wait`?{kind:`wait`}:{kind:`proceed`}}function B(){let e=a(),r=s(),[c]=o(),C=c.get(`hosting`),w=c.get(`fail`),E=p(),D=d()&&C!==null&&C!==`vellum-cloud`,k=y.use.sessionStatus(),z=D?_(k):k,[B]=(0,j.useState)(()=>L??=ge(A)),V=(0,j.useMemo)(()=>{let e=T(A,B.bodyShape,B.eyeStyle,B.color,320);return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`},[B]),[H,U]=(0,j.useState)(`initializing`),[W,G]=(0,j.useState)(null),[Se,K]=(0,j.useState)(!1),[Ce,we]=(0,j.useState)(0),[Te,q]=(0,j.useState)(0),[Ee,J]=(0,j.useState)(0),Y=(0,j.useRef)(H),X=(0,j.useRef)(0),Z=(0,j.useRef)(0),Q=(0,j.useRef)(0),$=(0,j.useCallback)(e=>{X.current=Q.current,Z.current=Date.now(),Y.current=e,U(e),J(e=>e+1)},[]);return(0,j.useEffect)(()=>{if(w!==null){G(`Simulated hatch failure (developer menu → Replay Hatch Failure).`);return}let i=xe();if(i.kind===`redirect`){e(i.to,{replace:!0});return}if(i.kind===`wait`)return;K(!1);let a=!1,o=null,s=null,c=null,l=Date.now(),p,_=!1,T=!1,E=fe(),O=()=>{try{pe(``)}catch(e){n(e,{context:`onboarding_mark_completed`})}q(1),Q.current=1,X.current=1,U(`ready`),Y.current=`ready`,s=setTimeout(()=>{a||(R(),(async()=>{if(await h.checkAssistant(),!a){if(de()){h.markExpectingFirstMessage(),e(`${S.assistant}?onboarding=1`,{replace:!0});return}e(S.onboarding.prechat,{replace:!0})}})())},_e)},k=e=>he(e,B,r),A=async()=>{if($(`provisioning`),!D){try{let e=await x(),t=b(e);if(!a&&e.ok&&t.kind===`active`){d()&&u({assistantId:e.data.id,name:e.data.name,cloud:`vellum`,runtimeUrl:f(),hatchedAt:new Date().toISOString(),organizationId:g.getState().currentOrganizationId??void 0}),O();return}t.kind===`auto_hatch`&&(T=!0)}catch{}if(a)return}if(D){try{F||=ee(void 0,C===`docker`?`docker`:void 0);let e=await F;if(a)return;if(!e.ok){R(),G(e.error??`Failed to hatch local assistant.`);return}await ne(),e.assistantId&&v(e.assistantId),$(`connecting`);let t=!1;for(;!a&&!t;){let e=re();if(e)try{let n=await fetch(`${e}/readyz`);if(n.ok){let e=await n.json();if(e&&typeof e==`object`&&`status`in e&&e.status===`ok`){ie(),await te(),t=!0;break}}}catch{}if(Date.now()-l>=P){R(),G(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{c=setTimeout(e,N)}),c=null}if(a)return;if(e.assistantId)try{await me(e.assistantId)}catch(e){n(e,{context:`onboarding_apply_provider_key`})}e.assistantId&&await y.getState().connectLocalAssistant(e.assistantId),e.assistantId&&(m.getState().upsertFromApi({id:e.assistantId,name:e.assistantId,status:`active`,is_local:!0,created:new Date().toISOString()}),v(e.assistantId),k(e.assistantId)),O()}catch{if(R(),a)return;G(`Failed to hatch local assistant. Check CLI logs for details.`)}return}try{I||=ue(E?{version:E}:void 0);let e=await I;if(I=null,a)return;if(e.ok&&(p=e.data.id),_=e.ok&&e.status===201,!e.ok){if(t(`Onboarding hatch request failed`,{level:`warning`,extra:{status:e.status,error:e.error}}),ce(e.status,e.error)){G(se),K(!0);return}if(!oe(e.status)){G(ae(e.error,void 0,`Failed to start your assistant. Please try again.`));return}}}catch(e){if(I=null,n(e,{context:`onboarding_hatch_assistant`}),a)return}j(0)},j=e=>{a||(o=setTimeout(ge,e))},ge=async()=>{if(!a){if(Date.now()-l>=P){t(`Onboarding hatch wait exceeded timeout`,{level:`warning`,extra:{maxWaitMs:P}}),G(`Your assistant is taking longer than expected. Please try again.`);return}try{let e=await x(p);if(a||p&&!e.ok&&e.status===404&&(p=void 0,e=await x(),a))return;let t=b(e);if(t.kind===`active`){if(e.ok){let t=e.data.id;for(m.getState().upsertFromApi(e.data),v(t),(_||T)&&k(t),d()&&u({assistantId:t,name:e.data.name,cloud:`vellum`,runtimeUrl:f(),hatchedAt:new Date().toISOString(),organizationId:g.getState().currentOrganizationId??void 0}),$(`connecting`);!a;){try{if((await le(t)).ok)break}catch{}if(Date.now()-l>=P){G(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{o=setTimeout(e,N)}),o=null}if(a)return}O();return}if(t.kind===`error`){G(t.message);return}t.kind!==`auto_hatch`&&Y.current===`provisioning`&&$(`connecting`),j(N)}catch(e){if(n(e,{context:`onboarding_poll_assistant`}),a)return;j(N)}}};return A(),()=>{a=!0,o&&clearTimeout(o),s&&clearTimeout(s),c&&clearTimeout(c)}},[Ce,w,B,z,e,r,$,D]),(0,j.useEffect)(()=>{Z.current===0&&(Z.current=Date.now());let e,t=()=>{let n=Date.now()-Z.current,r=ve[Y.current],i=be(X.current,r,n);Q.current=i,q(i),r-i>1e-6&&(e=requestAnimationFrame(t))};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[Ee]),W?(0,M.jsx)(O,{children:(0,M.jsxs)(`div`,{role:`alert`,className:`mx-auto flex w-full max-w-xl flex-col items-center ${E?`min-h-full px-8 pt-21 pb-28 electron-prechat-type`:`min-h-screen justify-center px-6 pb-40`} text-center text-[var(--content-default)]`,children:[(0,M.jsx)(`h1`,{className:E?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:`Something went wrong`}),(0,M.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${E?`mt-3.5`:`mt-4`}`,children:W}),Se&&(0,M.jsxs)(`div`,{className:`mt-6 flex w-full max-w-sm flex-col items-center gap-3`,children:[(0,M.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Get started today with a local assistant`}),(0,M.jsx)(i,{asChild:!0,variant:`primary`,size:`regular`,fullWidth:!0,className:E?void 0:`h-11 text-base`,children:(0,M.jsx)(`a`,{href:`${window.location.origin}/download`,children:`Download the macOS app`})})]}),(0,M.jsx)(`img`,{src:V,alt:``,width:160,height:160,className:`${E?`my-auto py-8`:`my-16`} onboarding-avatar-failed`}),(0,M.jsxs)(`div`,{className:`flex w-full flex-col ${E?`gap-2.5 max-w-[280px]`:`gap-2 max-w-sm`}`,children:[(0,M.jsx)(i,{variant:`primary`,size:`regular`,fullWidth:!0,className:E?void 0:`h-11 text-base`,onClick:()=>{X.current=0,Z.current=Date.now(),Y.current=`initializing`,Q.current=0,U(`initializing`),q(0),J(e=>e+1),G(null),K(!1),we(e=>e+1)},children:`Try again`}),(0,M.jsx)(i,{variant:`outlined`,size:`regular`,fullWidth:!0,className:E?void 0:`h-11 text-base`,onClick:()=>void e(D?S.onboarding.hosting:S.onboarding.privacy,{replace:!0}),children:`Back`})]})]})}):(0,M.jsx)(O,{children:(0,M.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${E?`min-h-full px-8 pt-21 pb-28 electron-prechat-type`:`min-h-screen justify-center px-6 pb-40`} text-center text-[var(--content-default)]`,children:[(0,M.jsx)(`h1`,{className:E?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:H===`ready`?`Your assistant is ready!`:`Waking up…`}),H!==`ready`&&(0,M.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${E?`mt-3.5`:`mt-4`}`,children:`Hang tight — your assistant will have a few questions for you once it's up.`}),(0,M.jsx)(`img`,{src:V,alt:``,width:160,height:160,className:`${E?`my-auto py-8`:`my-16`} ${H===`ready`?`onboarding-avatar-awake`:`onboarding-avatar-pulse`}`}),(0,M.jsx)(l,{value:Te,height:6,className:`w-full ${E?`max-w-[200px]`:`max-w-sm`}`,"aria-label":`Assistant startup progress`}),(0,M.jsx)(`p`,{className:`text-[var(--content-tertiary)] ${E?`mt-4 text-label-small-default`:`mt-3 text-body-small-default`}`,children:ye[H]})]})})}export{B as HatchingScreen};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,t as n}from"./capture-error-BG-GkiMq.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-D-AX8Voo.js";import{d as a,h as o}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./jsx-runtime-CVSDxk6A.js";import{t as l}from"./progress-bar-DIFlWPPg.js";import{D as ee,_ as te,b as u,f as d,g as ne,i as re,s as f,tt as ie}from"./local-mode-CgrENuVf.js";import{t as p}from"./is-electron-C_ZTVhv8.js";import{n as m}from"./resolved-assistants-store-Dqf0LJrA.js";import{r as ae}from"./api-errors-DPruG7q9.js";import{A as h,B as oe,D as g,L as se,P as _,R as ce,k as v,n as y,z as b}from"./auth-store-B1y6dgYQ.js";import{a as le,o as ue,r as x}from"./api-1X5EQzNF.js";import{u as de}from"./native-biometric-BK6_QtW5.js";import{a as S}from"./routes-C6gxiCrz.js";import{r as C,t as w}from"./build-state-B-RL-LxH.js";import{i as fe,p as pe}from"./prefs-Ds__U7Hi.js";import{t as T}from"./avatar-svg-compositor-CNy1XmWD.js";import{ar as E,ir as D,rn as O,tr as k}from"./index-B-S-gNKm.js";import{t as me}from"./provider-key-Ba5Bw5MO.js";import{BUNDLED_COMPONENTS as A}from"./avatar-bundled-components-w37NPF4o.js";var j=e(r(),1);async function he(e,t,r){try{await D(e)||await E(e,t),r.invalidateQueries({queryKey:k(e)})}catch(e){n(e,{context:`onboarding_avatar_sync`})}}function ge(e){let t=e=>e[Math.floor(Math.random()*e.length)];return{bodyShape:t(e.bodyShapes).id,eyeStyle:t(e.eyeStyles).id,color:t(e.colors).id}}var M=c(),N=3e3,_e=800,P=3e5,F=null,I=null,L=null;function R(){F=null,I=null,L=null}var ve={initializing:0,provisioning:.33,connecting:.66,ready:1},z=1500,ye={initializing:`Getting things ready…`,provisioning:`Setting up your assistant…`,connecting:`Connecting to your assistant…`,ready:`Ready`};function be(e,t,n){if(e>=t)return t;let r=1-(1-Math.min(1,n/z))**3;return e+(t-e)*r}function xe(){let e=C(w(),{kind:`hatch-gate`});return e.action===`redirect`?{kind:`redirect`,to:e.to}:e.action===`wait`?{kind:`wait`}:{kind:`proceed`}}function B(){let e=a(),r=s(),[c]=o(),C=c.get(`hosting`),w=c.get(`fail`),E=p(),D=d()&&C!==null&&C!==`vellum-cloud`,k=y.use.sessionStatus(),z=D?_(k):k,[B]=(0,j.useState)(()=>L??=ge(A)),V=(0,j.useMemo)(()=>{let e=T(A,B.bodyShape,B.eyeStyle,B.color,320);return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`},[B]),[H,U]=(0,j.useState)(`initializing`),[W,G]=(0,j.useState)(null),[Se,K]=(0,j.useState)(!1),[Ce,we]=(0,j.useState)(0),[Te,q]=(0,j.useState)(0),[Ee,J]=(0,j.useState)(0),Y=(0,j.useRef)(H),X=(0,j.useRef)(0),Z=(0,j.useRef)(0),Q=(0,j.useRef)(0),$=(0,j.useCallback)(e=>{X.current=Q.current,Z.current=Date.now(),Y.current=e,U(e),J(e=>e+1)},[]);return(0,j.useEffect)(()=>{if(w!==null){G(`Simulated hatch failure (developer menu → Replay Hatch Failure).`);return}let i=xe();if(i.kind===`redirect`){e(i.to,{replace:!0});return}if(i.kind===`wait`)return;K(!1);let a=!1,o=null,s=null,c=null,l=Date.now(),p,_=!1,T=!1,E=fe(),O=()=>{try{pe(``)}catch(e){n(e,{context:`onboarding_mark_completed`})}q(1),Q.current=1,X.current=1,U(`ready`),Y.current=`ready`,s=setTimeout(()=>{a||(R(),(async()=>{if(await h.checkAssistant(),!a){if(de()){h.markExpectingFirstMessage(),e(`${S.assistant}?onboarding=1`,{replace:!0});return}e(S.onboarding.prechat,{replace:!0})}})())},_e)},k=e=>he(e,B,r),A=async()=>{if($(`provisioning`),!D){try{let e=await x(),t=b(e);if(!a&&e.ok&&t.kind===`active`){d()&&u({assistantId:e.data.id,name:e.data.name,cloud:`vellum`,runtimeUrl:f(),hatchedAt:new Date().toISOString(),organizationId:g.getState().currentOrganizationId??void 0}),O();return}t.kind===`auto_hatch`&&(T=!0)}catch{}if(a)return}if(D){try{F||=ee(void 0,C===`docker`?`docker`:void 0);let e=await F;if(a)return;if(!e.ok){R(),G(e.error??`Failed to hatch local assistant.`);return}await ne(),e.assistantId&&v(e.assistantId),$(`connecting`);let t=!1;for(;!a&&!t;){let e=re();if(e)try{let n=await fetch(`${e}/readyz`);if(n.ok){let e=await n.json();if(e&&typeof e==`object`&&`status`in e&&e.status===`ok`){ie(),await te(),t=!0;break}}}catch{}if(Date.now()-l>=P){R(),G(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{c=setTimeout(e,N)}),c=null}if(a)return;if(e.assistantId)try{await me(e.assistantId)}catch(e){n(e,{context:`onboarding_apply_provider_key`})}e.assistantId&&await y.getState().connectLocalAssistant(e.assistantId),e.assistantId&&(m.getState().upsertFromApi({id:e.assistantId,name:e.assistantId,status:`active`,is_local:!0,created:new Date().toISOString()}),v(e.assistantId),k(e.assistantId)),O()}catch{if(R(),a)return;G(`Failed to hatch local assistant. Check CLI logs for details.`)}return}try{I||=ue(E?{version:E}:void 0);let e=await I;if(I=null,a)return;if(e.ok&&(p=e.data.id),_=e.ok&&e.status===201,!e.ok){if(t(`Onboarding hatch request failed`,{level:`warning`,extra:{status:e.status,error:e.error}}),ce(e.status,e.error)){G(se),K(!0);return}if(!oe(e.status)){G(ae(e.error,void 0,`Failed to start your assistant. Please try again.`));return}}}catch(e){if(I=null,n(e,{context:`onboarding_hatch_assistant`}),a)return}j(0)},j=e=>{a||(o=setTimeout(ge,e))},ge=async()=>{if(!a){if(Date.now()-l>=P){t(`Onboarding hatch wait exceeded timeout`,{level:`warning`,extra:{maxWaitMs:P}}),G(`Your assistant is taking longer than expected. Please try again.`);return}try{let e=await x(p);if(a||p&&!e.ok&&e.status===404&&(p=void 0,e=await x(),a))return;let t=b(e);if(t.kind===`active`){if(e.ok){let t=e.data.id;for(m.getState().upsertFromApi(e.data),v(t),(_||T)&&k(t),d()&&u({assistantId:t,name:e.data.name,cloud:`vellum`,runtimeUrl:f(),hatchedAt:new Date().toISOString(),organizationId:g.getState().currentOrganizationId??void 0}),$(`connecting`);!a;){try{if((await le(t)).ok)break}catch{}if(Date.now()-l>=P){G(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{o=setTimeout(e,N)}),o=null}if(a)return}O();return}if(t.kind===`error`){G(t.message);return}t.kind!==`auto_hatch`&&Y.current===`provisioning`&&$(`connecting`),j(N)}catch(e){if(n(e,{context:`onboarding_poll_assistant`}),a)return;j(N)}}};return A(),()=>{a=!0,o&&clearTimeout(o),s&&clearTimeout(s),c&&clearTimeout(c)}},[Ce,w,B,z,e,r,$,D]),(0,j.useEffect)(()=>{Z.current===0&&(Z.current=Date.now());let e,t=()=>{let n=Date.now()-Z.current,r=ve[Y.current],i=be(X.current,r,n);Q.current=i,q(i),r-i>1e-6&&(e=requestAnimationFrame(t))};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[Ee]),W?(0,M.jsx)(O,{children:(0,M.jsxs)(`div`,{role:`alert`,className:`mx-auto flex w-full max-w-xl flex-col items-center ${E?`min-h-full px-8 pt-21 pb-28 electron-prechat-type`:`min-h-screen justify-center px-6 pb-40`} text-center text-[var(--content-default)]`,children:[(0,M.jsx)(`h1`,{className:E?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:`Something went wrong`}),(0,M.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${E?`mt-3.5`:`mt-4`}`,children:W}),Se&&(0,M.jsxs)(`div`,{className:`mt-6 flex w-full max-w-sm flex-col items-center gap-3`,children:[(0,M.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Get started today with a local assistant`}),(0,M.jsx)(i,{asChild:!0,variant:`primary`,size:`regular`,fullWidth:!0,className:E?void 0:`h-11 text-base`,children:(0,M.jsx)(`a`,{href:`${window.location.origin}/download`,children:`Download the macOS app`})})]}),(0,M.jsx)(`img`,{src:V,alt:``,width:160,height:160,className:`${E?`my-auto py-8`:`my-16`} onboarding-avatar-failed`}),(0,M.jsxs)(`div`,{className:`flex w-full flex-col ${E?`gap-2.5 max-w-[280px]`:`gap-2 max-w-sm`}`,children:[(0,M.jsx)(i,{variant:`primary`,size:`regular`,fullWidth:!0,className:E?void 0:`h-11 text-base`,onClick:()=>{X.current=0,Z.current=Date.now(),Y.current=`initializing`,Q.current=0,U(`initializing`),q(0),J(e=>e+1),G(null),K(!1),we(e=>e+1)},children:`Try again`}),(0,M.jsx)(i,{variant:`outlined`,size:`regular`,fullWidth:!0,className:E?void 0:`h-11 text-base`,onClick:()=>void e(D?S.onboarding.hosting:S.onboarding.privacy,{replace:!0}),children:`Back`})]})]})}):(0,M.jsx)(O,{children:(0,M.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${E?`min-h-full px-8 pt-21 pb-28 electron-prechat-type`:`min-h-screen justify-center px-6 pb-40`} text-center text-[var(--content-default)]`,children:[(0,M.jsx)(`h1`,{className:E?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:H===`ready`?`Your assistant is ready!`:`Waking up…`}),H!==`ready`&&(0,M.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${E?`mt-3.5`:`mt-4`}`,children:`Hang tight — your assistant will have a few questions for you once it's up.`}),(0,M.jsx)(`img`,{src:V,alt:``,width:160,height:160,className:`${E?`my-auto py-8`:`my-16`} ${H===`ready`?`onboarding-avatar-awake`:`onboarding-avatar-pulse`}`}),(0,M.jsx)(l,{value:Te,height:6,className:`w-full ${E?`max-w-[200px]`:`max-w-sm`}`,"aria-label":`Assistant startup progress`}),(0,M.jsx)(`p`,{className:`text-[var(--content-tertiary)] ${E?`mt-4 text-label-small-default`:`mt-3 text-body-small-default`}`,children:ye[H]})]})})}export{B as HatchingScreen};