@vellumai/web 0.10.3-staging.1 → 0.10.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.
- package/dist/assets/{account-page-BB5Phl5s.js → account-page-CCYCSy2-.js} +1 -1
- package/dist/assets/{advanced-page-CMAf1fno.js → advanced-page-CVnT0zH-.js} +1 -1
- package/dist/assets/{ai-page-DcOYf6ki.js → ai-page-kEbHR7cH.js} +1 -1
- package/dist/assets/{api-key-screen-A7FySG-O.js → api-key-screen-DGVn66y4.js} +1 -1
- package/dist/assets/{archive-page-m3yQFOvD.js → archive-page-Dl6HLIJt.js} +1 -1
- package/dist/assets/{billing-page-C-JoA25u.js → billing-page-Cq_yLwUC.js} +1 -1
- package/dist/assets/{bookmarks-page-Cl2O0te-.js → bookmarks-page-CANlE7hP.js} +1 -1
- package/dist/assets/{command-palette-AdQxXi8M.js → command-palette-GZu_zgQg.js} +1 -1
- package/dist/assets/{command-palette-window-page-9TqGuzVu.js → command-palette-window-page-CzWu42Ee.js} +1 -1
- package/dist/assets/{community-page-DPCIsZX3.js → community-page-Dhgypa-h.js} +1 -1
- package/dist/assets/{contacts-page-route-BvCp-gAp.js → contacts-page-route-C3QiOxjO.js} +1 -1
- package/dist/assets/{debug-page-CTD3JrfL.js → debug-page-CBozmAQQ.js} +1 -1
- package/dist/assets/{deploy-dialogs-C0aZYWkv.js → deploy-dialogs-jf5VL1UP.js} +1 -1
- package/dist/assets/{developer-page-Dx6SbGPL.js → developer-page-iEL4eJ8x.js} +1 -1
- package/dist/assets/{devices-page-DtqksGFR.js → devices-page-RMaPGcXe.js} +1 -1
- package/dist/assets/{dictation-overlay-page-B9zcq9IK.js → dictation-overlay-page-BxQCzLMY.js} +1 -1
- package/dist/assets/{document-viewer-page-oeRhq2Yx.js → document-viewer-page-57OuXxYw.js} +1 -1
- package/dist/assets/{earn-credits-modal-3vmD9Fug.js → earn-credits-modal-Nm1VymMp.js} +1 -1
- package/dist/assets/{emails-page-C_RKF4jL.js → emails-page-0gRZqa6y.js} +1 -1
- package/dist/assets/{file-editor-wIYQnMM_.js → file-editor-BNkJJbUv.js} +1 -1
- package/dist/assets/{general-page-Bjr3EfG_.js → general-page-aZxTpnpI.js} +1 -1
- package/dist/assets/{hatching-screen-OMSxOyvX.js → hatching-screen-KPinlCES.js} +1 -1
- package/dist/assets/{home-page-route-BDyODWxN.js → home-page-route-CudtBGg1.js} +1 -1
- package/dist/assets/{hosting-screen-dwUA84uS.js → hosting-screen-C14KAJ6m.js} +1 -1
- package/dist/assets/{identity-page-route-Ds4SXg6o.js → identity-page-route-C0BFcTAF.js} +1 -1
- package/dist/assets/{index-BIDC22lX.js → index-PRnvH2Y1.js} +7 -7
- package/dist/assets/{inspect-page-CpIdOQCU.js → inspect-page-CWasyuSO.js} +1 -1
- package/dist/assets/{install-b0ONV1om.js → install-C3xe8ARr.js} +1 -1
- package/dist/assets/{integrations-page-Dw3rJqPE.js → integrations-page-WhBpTYP2.js} +1 -1
- package/dist/assets/{intelligence-layout-DovsSaK4.js → intelligence-layout-CvTumtjv.js} +1 -1
- package/dist/assets/{keyboard-shortcuts-page-B2rDCmXw.js → keyboard-shortcuts-page-kiOEZKzE.js} +1 -1
- package/dist/assets/{library-detail-page-BfwLhTzc.js → library-detail-page-rPvN9G1a.js} +1 -1
- package/dist/assets/{library-page-CKwzimBZ.js → library-page-BHejhapZ.js} +1 -1
- package/dist/assets/{login-page-aWGeNMsB.js → login-page-BGLVK82t.js} +1 -1
- package/dist/assets/{logout-page-BgczaAe_.js → logout-page-Bl6AD21S.js} +1 -1
- package/dist/assets/{logs-layout-Bb4h3S2N.js → logs-layout-C9eUE1Pt.js} +1 -1
- package/dist/assets/{memory-router-playground-page-gcwT23uj.js → memory-router-playground-page-Dhi3uqxr.js} +1 -1
- package/dist/assets/{mobile-sidebar-drawer-wA5GnkLS.js → mobile-sidebar-drawer-DqXFL0Ke.js} +1 -1
- package/dist/assets/{notifications-page-BilxDebz.js → notifications-page-pHiDPA0p.js} +1 -1
- package/dist/assets/{oauth-complete-page-CzAcy6Qj.js → oauth-complete-page-DiGMWbOb.js} +1 -1
- package/dist/assets/{oauth-popup-complete-page-CvE_74ec.js → oauth-popup-complete-page-CwoZnzdc.js} +1 -1
- package/dist/assets/{pairing-page-ddUW7kSm.js → pairing-page-clFaUgzL.js} +1 -1
- package/dist/assets/{plugin-detail-page-B-d90SJ8.js → plugin-detail-page-IRPeI4lP.js} +1 -1
- package/dist/assets/{plugins-page-tUsEY9_b.js → plugins-page-BaYp2QOe.js} +1 -1
- package/dist/assets/{prechat-route-in5c2S6S.js → prechat-route-BaMWiiaf.js} +1 -1
- package/dist/assets/{privacy-page-CpYx1RMr.js → privacy-page-BUhxrIRn.js} +1 -1
- package/dist/assets/{privacy-screen-Cd4yErpJ.js → privacy-screen-BaHYtKEt.js} +1 -1
- package/dist/assets/{provider-callback-page-BCXiAoax.js → provider-callback-page-CxFC4PH1.js} +1 -1
- package/dist/assets/{research-mock-page-DfC4Xf4z.js → research-mock-page-ttrrPwo3.js} +1 -1
- package/dist/assets/{research-onboarding-route-QentSADF.js → research-onboarding-route-Cxai0fux.js} +1 -1
- package/dist/assets/{review-terms-screen-kUBWOFsV.js → review-terms-screen-DEiifDmK.js} +1 -1
- package/dist/assets/{select-assistant-screen-DDdKrCaI.js → select-assistant-screen-UoixBMN2.js} +1 -1
- package/dist/assets/{settings-layout-CIAca9J9.js → settings-layout-CQ3Z9Raj.js} +1 -1
- package/dist/assets/{share-feedback-modal-sqz1cvkl.js → share-feedback-modal-CTwByE7B.js} +1 -1
- package/dist/assets/{sidebar-tree-BNLVikyu.js → sidebar-tree-BJkXpCut.js} +1 -1
- package/dist/assets/{signup-page-DOYf5rnz.js → signup-page-CKDYl9Wb.js} +1 -1
- package/dist/assets/{skills-page-pXRiOYxp.js → skills-page-DVjqqfMw.js} +1 -1
- package/dist/assets/{sounds-page-DZjipsnL.js → sounds-page-mens6EAJ.js} +1 -1
- package/dist/assets/{step-indicator-dots-D1EQV6VE.js → step-indicator-dots-CEVbsP8r.js} +1 -1
- package/dist/assets/{subagent-detail-panel-BhMGv4KW.js → subagent-detail-panel-DVQAkMjF.js} +1 -1
- package/dist/assets/{system-events-page-8chSE8WO.js → system-events-page-Dro8iNrx.js} +1 -1
- package/dist/assets/{tiptap-document-editor-BIYDH0gu.js → tiptap-document-editor-D2t4qYzv.js} +1 -1
- package/dist/assets/{tool-detail-panel-CltEAL4k.js → tool-detail-panel-DRD2DIMF.js} +1 -1
- package/dist/assets/{trace-page-Ceqkb39z.js → trace-page-DRWPaAuQ.js} +1 -1
- package/dist/assets/{upgrade-cancel-page-BLYBOQhL.js → upgrade-cancel-page-Cwv5eMh9.js} +1 -1
- package/dist/assets/{upgrade-success-page-Besx7BnU.js → upgrade-success-page-DnJ8Kyyj.js} +1 -1
- package/dist/assets/{usage-page-UvJrF1jZ.js → usage-page-DJHRS0lZ.js} +1 -1
- package/dist/assets/{voice-page-B6ocZCAN.js → voice-page-kQZ2ya5j.js} +1 -1
- package/dist/assets/{weather-forecast-display-JXZ2NoLx.js → weather-forecast-display-Cu3W6OZF.js} +1 -1
- package/dist/assets/{welcome-screen-4_W-iOJc.js → welcome-screen-Bd7PCfAf.js} +1 -1
- package/dist/assets/{workflow-detail-panel-BYvRNK8S.js → workflow-detail-panel-CMmPPsuL.js} +1 -1
- package/dist/assets/{workspace-page-D6Ak7heg.js → workspace-page-BR4pOxs5.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -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-Hr1Yo2kx.js";import{t as s}from"./react-DJZBPgpf.js";import{t as c}from"./button-D7s2Q_uG.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-CL8VmqrY.js";import{c as _,n as v,s as y}from"./src-CK6bncSg.js";import{t as b}from"./confirm-dialog-CfOXCE1N.js";import{t as x}from"./notice-CqRgVmeL.js";import{t as S}from"./progress-bar-DIFlWPPg.js";import{t as C}from"./tag-B_-QAvJF.js";import{t as w}from"./input-C8kfrq9r.js";import{t as T}from"./toggle-X_kQW5my.js";import{n as E}from"./stat-square-B0S3fO7O.js";import{t as D}from"./modal-D0Q3UWD0.js";import{n as O}from"./toast-2TW5tj1Y.js";import{E as k,b as A,c as j,d as M,f as N,g as P,h as F,i as I,r as L,s as ee,w as R,x as z}from"./local-mode-CvrNMtPF.js";import{t as B}from"./is-electron-C_ZTVhv8.js";import{n as te}from"./resolved-assistants-store-Cp4J43BK.js";import{t as V}from"./createLucideIcon-BlMXrA59.js";import{t as ne}from"./bell-DB1SrBre.js";import{t as re}from"./check-D6WkI0gF.js";import{t as ie}from"./chevron-right-B6vEpVY0.js";import{t as ae}from"./circle-alert-DvNg50UK.js";import{t as oe}from"./circle-check-DzlJxj_M.js";import{t as se}from"./hard-drive-D7_5VMhi.js";import{t as H}from"./loader-circle-IIzBGiwm.js";import{t as ce}from"./monitor-D2okHi8o.js";import{t as le}from"./moon-CK8MXzOo.js";import{t as ue}from"./refresh-cw-Bf6LV0kG.js";import{a as de,c as fe,o as pe,r as me,s as he,t as ge}from"./resize-errors-DnJEbHn4.js";import{t as _e}from"./sparkles-BICoewVE.js";import{t as ve}from"./triangle-alert-DKOyShqD.js";import{n as ye,r as U,t as be}from"./api-errors-CveHbhgb.js";import{I as xe,V as Se,Z as Ce,a as we,b as Te,g as Ee,h as De,l as Oe,n as ke,v as Ae,y as je,z as Me}from"./auth-store-Kfxhs2oI.js";import{t as W}from"./client.gen-Cs6pCK0s.js";import{A as Ne,S as Pe,V as Fe,Y as Ie,j as Le,w as Re}from"./sdk.gen-D-_js_oC.js";import{a as ze,o as Be}from"./api-2kc3MHRz.js";import{a as G}from"./routes-DVqkwUEe.js";import{t as K}from"./client-feature-flag-store-C1kdd1EO.js";import{r as Ve,t as He}from"./semver-yC_Iq9co.js";import{t as Ue}from"./assistant-feature-flag-store-Dl92XRsM.js";import{A as We,D as Ge,E as Ke,M as qe,Q as Je,T as Ye,bt as Xe,c as Ze,et as Qe,gt as $e,j as et,k as tt,v as nt,w as rt,wt as it,xt as at}from"./react-query.gen-rp6Krcco.js";import{t as ot}from"./proxy-DmIh4F51.js";import{t as st}from"./AnimatePresence-CgXwEO42.js";import{t as ct}from"./use-reduced-motion-ChB7nOGe.js";import{$i as lt,Bt as ut,Hr as dt,Ir as ft,Jn as pt,Kn as mt,Lt as ht,Qr as gt,Rn as _t,Rr as vt,Rt as yt,Zr as bt,an as xt,bn as St,d as Ct,en as wt,f as Tt,ht as Et,in as Dt,l as Ot,qn as kt,rn as At,s as jt,st as Mt,tn as Nt,u as Pt,wi as Ft,x as q,zt as It}from"./index-BIDC22lX.js";import{t as Lt}from"./app-info-BZYaLxCg.js";import{t as Rt}from"./use-active-assistant-id-C-RHQ9f6.js";import{t as J}from"./detail-card-BIwpXT5F.js";import{t as zt}from"./environment-store-CvH3J6fT.js";import{i as Bt,n as Vt,r as Ht,t as Ut}from"./assistant-status-panel-BkIkvMYw.js";var Wt=V(`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`}]]),Gt=V(`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`}]]),Y=e(s(),1),Kt=De,qt=`Please choose a different handle.`;async function Jt(e,t){let{data:n,error:r,response:i}=await Le({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:U(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}=Te(r,`handle`,Kt.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=Te(r,`handle`,qt);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:U(r,i,`Failed to save handle.`)}}async function Yt(e,t,n){let{data:r,error:i,response:a}=await Pe({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(ye(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new be(a.status,a.status===429?`Too many checks — try again in a moment.`:U(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function Xt(e){return/\d{2,}$/.test(e)}var X=m(),Zt=300,Qt=1400;function $t({initialHandle:e,inputLabel:t,helperText:n,idleHelperText:r,checkAvailable:i,save:a,onSaved:o,saveSuccessToast:s,fieldId:l}){let[u,d]=(0,Y.useState)(e),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(`idle`),[v,y]=(0,Y.useState)(null),b=ct(),x=(0,Y.useRef)(null),S=(0,Y.useMemo)(()=>u.trim().toLowerCase(),[u]),C=S===e.toLowerCase();(0,Y.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)}},Zt);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?Kt[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,Y.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`),Qt);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,X.jsx)(st,{mode:`wait`,initial:!1,children:(0,X.jsxs)(ot.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,X.jsx)(H,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,X.jsx)(re,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":`Available`}),e===`invalid`&&(0,X.jsx)(ae,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":`Not available`})]},e)}):null})(),j=(()=>{switch(g){case`saving`:return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(H,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),`Saving…`]});case`saved`:return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(re,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Saved`]});default:return`Save`}})();return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.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,X.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,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(c,{variant:`primary`,size:`compact`,onClick:k,disabled:!D,"aria-live":`polite`,"data-testid":`${l}-save`,children:j})})]})}function en({initial:e,onSaved:t}){let n=ke.use.refreshSession(),r=Xt(e.username)?`Your handle was auto-generated at signup — pick one you like.`:void 0,i=(0,Y.useCallback)(async e=>await je({username:e}),[]),a=(0,Y.useCallback)((e,t)=>Ee(e,t),[]),o=(0,Y.useCallback)(e=>{t(e),n()},[t,n]);return(0,X.jsx)($t,{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 tn({assistant:e,onSaved:t}){let n=e.handle??``,r=f({...Ze({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,Y.useCallback)(async t=>await Jt(e.id,t),[e.id]),s=(0,Y.useCallback)((t,n)=>Yt(e.id,t,n),[e.id]);return i?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(w,{label:`Assistant handle`,value:n,readOnly:!0,disabled:!0,leftIcon:(0,X.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),fullWidth:!0,"data-testid":`assistant-handle-input`}),(0,X.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,X.jsx)(u,{to:`${G.settings.ai}?release=1#email`,className:`text-[var(--content-link)] underline hover:text-[var(--content-link-hover)]`,children:`release the subdomain`}),` `,`first.`]})]}):(0,X.jsx)($t,{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 nn(){return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":!0,"aria-live":`polite`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`div`,{className:`h-3 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,X.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,X.jsx)(`div`,{className:`h-3 w-72 animate-pulse rounded bg-[var(--surface-muted)]`})]}),(0,X.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`h-3 w-60 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,X.jsx)(`div`,{className:`h-7 w-16 animate-pulse rounded-md bg-[var(--surface-muted)]`})]}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Loading your profile…`})]})}function rn({assistant:e}={}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),a=ct(),[o,s]=(0,Y.useState)(e??null);return(0,Y.useEffect)(()=>{s(e??null)},[e]),(0,Y.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,X.jsx)(J,{title:`Profile`,subtitle:`Manage your user and assistant public handles.`,children:r?(0,X.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:r}):t?(0,X.jsxs)(ot.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,X.jsx)(en,{initial:t,onSaved:n}),o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,X.jsx)(tn,{assistant:o,onSaved:s})]})]}):(0,X.jsx)(nn,{})})}var an=nt({query:{hosting:`platform`}});function on(){let e=Rt(),t=f(an),n=t.data?.results??[];return t.isPending||n.length<2?null:(0,X.jsx)(J,{title:`Switch Assistant`,subtitle:`Choose which assistant is active for this account.`,children:(0,X.jsx)(`div`,{className:`space-y-2`,children:n.map(t=>{let n=t.id===e;return(0,X.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,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(ce,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:t.name||`Unnamed`}),t.status!==`active`&&(0,X.jsx)(C,{tone:`warning`,children:t.status})]})})]}),(0,X.jsx)(`div`,{className:`shrink-0`,children:n?(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5 text-body-small-default text-[var(--system-positive-default)]`,children:[(0,X.jsx)(re,{className:`h-4 w-4`}),`Active`]}):(0,X.jsx)(c,{variant:`outlined`,size:`compact`,disabled:t.status!==`active`,onClick:()=>{Ce(t.id),O.success(`Switched active assistant.`)},children:`Switch`})})]},t.id)})})})}var sn=[{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 cn(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 ln({assistantId:e}){let t=d(),n=zt.use.isNonProduction(),r=(0,Y.useMemo)(()=>sn.filter(e=>!e.devOnly||n),[n]),{data:i,isLoading:a,isError:o}=f(et({path:{id:e}})),s=(0,Y.useMemo)(()=>i?.idle_timeout_seconds??259200,[i]),[l,u]=(0,Y.useState)(null),p=l??s,m=l!==null,h=at({onSuccess:()=>{O.success(`Sleep policy saved.`),u(null),t.invalidateQueries({queryKey:qe({path:{id:e}})})},onError:()=>{O.error(`Failed to save sleep policy. Please try again.`)}});return a?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(H,{className:`h-4 w-4 animate-spin`}),`Loading sleep settings...`]}):o?(0,X.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,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:`Idle timeout`}),(0,X.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,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:r.map(e=>(0,X.jsx)(c,{variant:`outlined`,active:p===e.seconds,onClick:()=>u(e.seconds),children:e.label},e.seconds))}),(0,X.jsxs)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:[`Current: `,cn(p)]})]}),m&&(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(c,{variant:`primary`,leftIcon:h.isPending?(0,X.jsx)(H,{className:`animate-spin`}):void 0,onClick:()=>h.mutate({path:{id:e},body:{idle_timeout_seconds:p}}),disabled:h.isPending,children:`Save`}),(0,X.jsx)(c,{variant:`outlined`,onClick:()=>u(null),disabled:h.isPending,children:`Cancel`})]})]})}function un(e,t,n){let r=[e.version];return e.version===n&&r.push(`(latest)`),t&&e.version===t&&r.push(`(current)`),r.join(` `)}var dn=3e3;function fn({assistantId:e,currentVersion:t,releaseChannel:n,onUpgradeComplete:r}){let i=Ue.use.rollbackEnabled(),a=K.use.previewChannel(),o=d(),s=yt(n,a),l=s===`preview`,[u,m]=(0,Y.useState)(!1),h=(0,Y.useRef)(null),[_,v]=(0,Y.useState)(null),[y,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.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):dn;f({...tt({path:{id:e}}),refetchInterval:u?e=>E(e.state.data?.current_release_version):!1});let{data:D,isLoading:k}=f($e({query:{channel:s}})),A=D?.find(e=>e.is_stable!==!1)??D?.[0],j=_??A?.version??null,M=(0,Y.useMemo)(()=>{if(!i||!j||!t)return!1;let e=Ve(j),n=Ve(t);return!e||!n?!1:He(e,n)<0},[i,j,t]),N=(0,Y.useMemo)(()=>{if(!j)return!1;if(!t)return!0;let e=Ve(j),n=Ve(t);if(!e||!n)return j!==t;let r=He(e,n);return i?r!==0:r>0},[i,j,t]),P=p({mutationFn:async t=>{let{data:n}=await Ie({path:{id:e},body:t,throwOnError:!0});return n}}),F=p({mutationFn:async t=>{let{data:n}=await Fe({path:{id:e},body:t,throwOnError:!0});return n}});return(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,X.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:t??`—`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:l?`Preview release`:N?M?`Rollback to`:`Update to`:`Selected`}),(0,X.jsx)(`span`,{className:`block min-w-0`,children:k?(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(H,{className:`h-3 w-3 animate-spin`}),`Loading...`]}):D&&D.length>0?i?(0,X.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:un(e,t,A?.version)}))}):(0,X.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:A?un(A,t,A.version):`—`}):`No releases available`})]})]}),(0,X.jsx)(c,{variant:M?`outlined`:`primary`,className:`min-w-[160px]`,leftIcon:P.isPending||F.isPending||u?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(ue,{}),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,X.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Using Preview releases.`,` `,(0,X.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,X.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:w??`You are already on this version.`}),(0,X.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:We({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 pn({assistantId:e,currentVersion:t,onUpgradeComplete:n}){let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(null),{data:s,isLoading:l}=f($e({query:{stable:!0,limit:100}})),u=(0,Y.useMemo)(()=>ht(s),[s]),d=u?.version,p=t?It(t,d):!!d,m=ut({assistantId:e,targetVersion:d});return(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,X.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:t??`—`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Update to`}),(0,X.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:l?`Loading...`:d&&u?un(u,t,d):`No releases available`})]})]}),(0,X.jsx)(c,{variant:`primary`,className:`min-w-[160px]`,leftIcon:m.isPending?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(ue,{}),onClick:()=>i(!0),disabled:m.isPending||l||!d||!p,children:m.isPending?`Updating...`:d?`Update to ${d}`:`Update`}),a&&(0,X.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:a}),!a&&!p&&d&&!l&&(0,X.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:`You are already on this version.`}),(0,X.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 mn(){let e=Tt.useValue();if(St())return null;let t=Pt()?`Cmd`:`Ctrl`;return(0,X.jsx)(J,{title:`Composer`,children:(0,X.jsx)(T,{checked:e,onChange:Tt.save,label:`Send with ${t}+Enter`,helperText:`When enabled, Enter inserts a new line and ${t}+Enter sends.`})})}function hn(){let e=xt({platformHostedOnly:!0}),t=Dt(),n=ke.use.user()?.id??null,r=ke.use.logout(),[i,a]=(0,Y.useState)(!1),o=it({onSuccess:async()=>{O.success(`Account deletion requested. You will be logged out shortly.`),Oe(n),await r(),_t(G.account.login)},onError:()=>{O.error(`Failed to request account deletion. Please try again.`)}}),s=e===`full`&&t;return(0,Y.useEffect)(()=>{s&&i&&a(!1)},[s,i]),e===`gated`?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(J,{title:`Delete Account`,subtitle:`Permanently delete your account and all associated data.`,variant:`danger`,children:e===`disabled`?(0,X.jsx)(q,{children:`Log in to the Vellum platform to delete your account.`}):(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(c,{variant:`dangerOutline`,onClick:()=>a(!0),disabled:o.isPending||s,className:`self-start`,children:`Delete My Account`}),s&&(0,X.jsx)(H,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})}),(0,X.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 gn({title:e,subtitle:t,benefits:n,ctaLabel:r,ctaLeftIcon:i,onAction:a}){return(0,X.jsx)(J,{title:e,subtitle:t,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(`ul`,{className:`space-y-3`,children:n.map(({icon:e,text:t})=>(0,X.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`},children:(0,X.jsx)(e,{size:14,style:{color:`var(--content-secondary)`},"aria-hidden":!0})}),(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]},t))}),(0,X.jsx)(c,{variant:`primary`,size:`regular`,leftIcon:i,onClick:a,className:`self-start`,children:r})]})})}function _n(){return Ct()?(0,X.jsx)(gn,{title:`Get the iOS App`,subtitle:`The Vellum iOS app gives you a native experience.`,benefits:[{icon:ne,text:`Push notifications`},{icon:Wt,text:`Biometric login`},{icon:Gt,text:`Native haptics`},{icon:dt,text:`Home screen access`}],ctaLabel:`Download`,ctaLeftIcon:(0,X.jsx)(dt,{size:16}),onAction:()=>{Ot(),jt()}}):null}async function vn(){if(!B())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function yn(e){if(!B())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function bn(){let[e,t]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{vn().then(t)},[]);let n=async e=>{t(e);try{await yn(e)}catch{t(!e)}};return(0,X.jsx)(J,{title:`Launch at Login`,subtitle:`Automatically start Vellum when you log in to your Mac.`,children:(0,X.jsx)(T,{checked:e,onChange:e=>void n(e),"aria-label":`Launch at Login`})})}function xn({className:e}){return(0,X.jsx)(`div`,{role:`presentation`,className:h(`h-px w-full bg-[var(--border-base)]`,e)})}var Z=[`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[...Z]}function Cn(){return n(`mediaEmbedsEnabled`,!0)}function wn(){let e=i(`mediaEmbedDomains`,``);return e?Sn(e):[...Z]}function Tn(){let[e,n]=(0,Y.useState)(()=>Cn()),[i,a]=(0,Y.useState)(()=>wn()),[o,s]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(``),d=(0,Y.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([...Z])},_=i.length===Z.length&&i.every((e,t)=>e===Z[t]);return(0,X.jsxs)(J,{title:`Media Embeds`,subtitle:`Automatically embed images, videos, and other media shared in chat messages.`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Auto Media Embeds`}),(0,X.jsx)(T,{checked:e,onChange:f})]}),e&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(xn,{})}),(0,X.jsxs)(c,{type:`button`,variant:`ghost`,onClick:()=>s(e=>!e),className:`mt-4 w-full justify-between px-3`,"aria-expanded":o,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[o?(0,X.jsx)(lt,{className:`h-4 w-4`,"aria-hidden":!0}):(0,X.jsx)(ie,{className:`h-4 w-4`,"aria-hidden":!0}),`Video Domain Allowlist`]}),(0,X.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[i.length,` domain`,i.length===1?``:`s`]})]}),o&&(0,X.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,X.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,X.jsx)(c,{variant:`primary`,size:`compact`,onClick:m,disabled:!d,children:`Add`})]}),i.length>0&&(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,onClick:g,disabled:_,tintColor:`var(--content-tertiary)`,children:`Reset to Defaults`})}),i.length>0&&(0,X.jsx)(`ul`,{className:`space-y-2`,children:i.map(e=>(0,X.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,X.jsx)(`span`,{className:`font-mono text-[var(--content-default)]`,children:e}),(0,X.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,X.jsx)(ft,{}),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=K.use.previewChannel(),r=d(),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,m]=(0,Y.useState)(`restore_backup`),[h,g]=(0,Y.useState)(``),_=Ke({path:{assistant_id:e}}),y=Ge({path:{assistant_id:e}}),b=We({path:{id:e}}),{data:S,isLoading:w,isError:T}=f({..._,enabled:n,retry:!1}),E=S?.preview_backups??[],D=(0,Y.useMemo)(()=>kn(E),[E]),k=D[0],A=D.find(e=>e.snapshot_name===h)??k,j=()=>{r.invalidateQueries({queryKey:y}),r.invalidateQueries({queryKey:b}),t?.()},M=p(rt()),N=p(Ye()),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,Y.useEffect)(()=>{a(P===`preview`?`release-channel`:void 0)},[P]),!n)return null;let ee=S?.standard_upgrade_available??!1;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(v.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,X.jsxs)(v.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,X.jsxs)(v.Trigger,{className:`group justify-between gap-3`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`Release Channel`}),S&&(0,X.jsx)(C,{tone:P===`preview`?`warning`:`neutral`,children:P===`preview`?`Preview`:`Stable`})]}),(0,X.jsx)(lt,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,X.jsx)(v.Content,{children:(0,X.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[w&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(H,{className:`h-4 w-4 animate-spin`}),`Loading release channel...`]}),T&&(0,X.jsx)(x,{tone:`error`,title:`Could not load release channel status`,children:`Refresh this page before changing release channels.`}),S&&(0,X.jsxs)(X.Fragment,{children:[An(S)&&(0,X.jsx)(x,{tone:`neutral`,title:`Preview channel is unavailable`,children:`The Preview channel is not enabled for this assistant.`}),P===`stable`?(0,X.jsx)(Mn,{status:S,isChangingChannel:F,optInDisabled:I,onOptIn:()=>s(!0)}):(0,X.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,X.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(U(e,void 0,`Could not enable Preview channel.`))}},onCancel:()=>s(!1)}),(0,X.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(U(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>l(!1)})]})}function Mn({status:e,isChangingChannel:t,optInDisabled:n,onOptIn:r}){return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(Pn,{status:e}),!e.latest_preview_release&&(0,X.jsx)(x,{tone:`neutral`,title:`No Preview release is available`,children:`Stable remains the only available release channel.`}),(0,X.jsx)(c,{variant:`outlined`,leftIcon:t?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(gt,{}),disabled:n,onClick:r,children:`Opt in to Preview`})]})}function Nn({status:e,isChangingChannel:t,onOptOut:n}){return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(Pn,{status:e}),(0,X.jsx)(c,{variant:`outlined`,leftIcon:t?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(bt,{}),disabled:t,onClick:n,children:`Switch back to Stable`})]})}function Pn({status:e}){return(0,X.jsxs)(`dl`,{className:`grid gap-3 text-body-medium-lighter sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Stable`}),(0,X.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_stable_release?.version??`None`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Preview`}),(0,X.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,X.jsx)(D.Root,{open:e,onOpenChange:e=>!e&&i(),children:(0,X.jsxs)(D.Content,{size:`md`,hideCloseButton:t,children:[(0,X.jsxs)(D.Header,{children:[(0,X.jsx)(D.Title,{icon:ve,children:`Opt in to Preview`}),(0,X.jsx)(D.Description,{children:`Preview releases may be unstable. A 90-day safety backup is taken before the image changes.`})]}),(0,X.jsx)(D.Body,{children:(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.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,X.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,X.jsx)(`li`,{children:`Create and verify a Preview safety backup.`}),(0,X.jsxs)(`li`,{children:[`Switch to Preview image `,n??`latest`,`.`]}),(0,X.jsx)(`li`,{children:`Run the normal upgrade path and wait for health.`})]})]})}),(0,X.jsxs)(D.Footer,{children:[(0,X.jsx)(c,{variant:`outlined`,disabled:t,onClick:i,children:`Cancel`}),(0,X.jsx)(c,{variant:`primary`,disabled:t,leftIcon:t?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(gt,{}),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,X.jsx)(D.Root,{open:e,onOpenChange:e=>!e&&d(),children:(0,X.jsxs)(D.Content,{size:`md`,hideCloseButton:i,children:[(0,X.jsxs)(D.Header,{children:[(0,X.jsx)(D.Title,{icon:ve,children:`Switch back to Stable`}),(0,X.jsx)(D.Description,{children:`Choose how this assistant should leave the Preview channel.`})]}),(0,X.jsx)(D.Body,{children:(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(_,{value:n,onValueChange:s,disabled:i,"aria-label":`Stable channel return method`,children:[(0,X.jsx)(y,{value:`restore_backup`,disabled:t.length===0,label:`Restore safety backup`,helperText:`Return to the Stable-channel data captured before Preview opt-in.`}),(0,X.jsx)(y,{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,X.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[`Safety backup`,(0,X.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,X.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,X.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,X.jsxs)(D.Footer,{children:[(0,X.jsx)(c,{variant:`outlined`,disabled:i,onClick:d,children:`Cancel`}),(0,X.jsx)(c,{variant:n===`standard_upgrade`?`danger`:`primary`,disabled:i||a||n===`standard_upgrade`&&!o,leftIcon:i?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(ue,{}),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(Qe()),d=s.data,p=!e.is_local,m=d?.plan_id===`pro`,h=f({...Je(),enabled:m}),_=e.machine_size||`small`,v=de(h.data?.max_machine_tier??null),y=(0,Y.useMemo)(()=>pe(v,_,(0,X.jsx)(C,{tone:`positive`,children:`Current`})),[v,_]),b=h.data?.selected_storage_gib??null,[S,w]=(0,Y.useState)(!1),T=v.length>0?v[v.length-1]:null,[E,k]=(0,Y.useState)(null),A=E??T??_,[j,M]=(0,Y.useState)(null),[N,P]=(0,Y.useState)(null),F=Xe({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(ge(e,`Failed to resize assistant. Please try again.`))}});if(s.isError&&d==null)return(0,X.jsx)(J,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,X.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&&he(_)<he(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:`${Vt(t.disk.usedMb)} of ${Vt(z)}`}:null,te=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,V=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:`${Vt(t.memory.currentMb)} of ${Vt(t.memory.maxMb)}`}:null,ne=p?m?L?(0,X.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,X.jsx)(_e,{className:`h-3.5 w-3.5`}),`Increase Storage`]}):(0,X.jsx)(c,{variant:`ghost`,size:`compact`,disabled:R,onClick:()=>w(!0),children:`Resize`}):(0,X.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>M(`storage`),children:`Resize`}):null,re=p?m?ee?(0,X.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,X.jsx)(_e,{className:`h-3.5 w-3.5`}),`Increase Size`]}):(0,X.jsx)(c,{variant:`ghost`,size:`compact`,disabled:R,onClick:()=>w(!0),children:`Resize`}):(0,X.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>M(`machine`),children:`Resize`}):null;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(J,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,compactAccessory:!0,accessory:(0,X.jsx)(c,{variant:`ghost`,size:`compact`,iconOnly:n||r?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(ue,{}),tooltip:r?`Applying resize…`:`Refresh resource metrics`,"aria-label":`Refresh resource metrics`,disabled:n||r,onClick:()=>void i()}),children:(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_2fr]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,X.jsx)(se,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Disk`})]}),ne]}),(0,X.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1 pt-3`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Storage`}),B?(0,X.jsx)(Bt,{value:B.value,max:B.max,caption:B.caption}):n?(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,X.jsx)(H,{className:`h-3 w-3 animate-spin`})}):(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Unavailable`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,X.jsx)(fe,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Machine`}),(0,X.jsx)(C,{tone:`neutral`,children:me[_]})]}),re]}),(0,X.jsxs)(`div`,{className:`mt-auto grid grid-cols-2 gap-3 pt-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`CPU`}),te?(0,X.jsx)(Bt,{value:te.value,max:te.max,caption:te.caption}):n?(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,X.jsx)(H,{className:`h-3 w-3 animate-spin`})}):(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Memory`}),V?(0,X.jsx)(Bt,{value:V.value,max:V.max,caption:V.caption}):n?(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,X.jsx)(H,{className:`h-3 w-3 animate-spin`})}):(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,X.jsx)(D.Root,{open:j!=null,onOpenChange:e=>{e||M(null)},children:(0,X.jsxs)(D.Content,{size:`sm`,children:[(0,X.jsxs)(D.Header,{children:[(0,X.jsx)(D.Title,{children:`Upgrade to Pro`}),(0,X.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,X.jsxs)(D.Footer,{children:[(0,X.jsx)(c,{variant:`ghost`,onClick:()=>M(null),children:`Cancel`}),(0,X.jsx)(c,{onClick:()=>{M(null),o(`${G.settings.billing}?adjust_plan=1`)},children:`Upgrade`})]})]})}),(0,X.jsx)(D.Root,{open:S,onOpenChange:e=>{e||(w(!1),k(null),P(null))},children:(0,X.jsxs)(D.Content,{size:`sm`,children:[(0,X.jsxs)(D.Header,{children:[(0,X.jsx)(D.Title,{icon:fe,children:`Resize Assistant`}),(0,X.jsx)(D.Description,{children:`Resize your assistant's compute and storage. Your assistant will briefly restart.`})]}),(0,X.jsx)(D.Body,{children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[v.length===0?(0,X.jsx)(x,{tone:`warning`,children:`No machine tier configured. Visit the community for help.`}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:`Machine Size`}),(0,X.jsx)(g,{options:y,value:A,onChange:k,"aria-label":`Compute machine size`,"data-testid":`resize-machine-size`})]}),L?(0,X.jsx)(x,{tone:`info`,children:`Storage will be expanded to ${b} GiB.`}):(0,X.jsx)(x,{tone:`neutral`,children:`Storage will not change.`}),N&&(0,X.jsx)(x,{tone:`error`,children:N})]})}),(0,X.jsxs)(D.Footer,{className:`items-center justify-between`,children:[(0,X.jsxs)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:[`Need more?`,` `,(0,X.jsx)(u,{to:`${G.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,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(c,{variant:`ghost`,onClick:()=>{w(!1),k(null),P(null)},children:`Cancel`}),(0,X.jsx)(c,{disabled:I==null&&!L||R,leftIcon:R?(0,X.jsx)(H,{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,Y.useState)(!1),[i,a]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(c,{variant:`dangerOutline`,onClick:()=>r(!0),className:`shrink-0`,children:`Retire Assistant`}),(0,X.jsx)(wt,{open:n,isPending:i,onConfirm:async()=>{a(!0);let n=await Nt(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,Y.useState)(``),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=(0,Y.useMemo)(()=>Bn().map(e=>Vn(e)).filter(e=>e!==null),[]);(0,Y.useEffect)(()=>{let e=window.setTimeout(()=>{a(n.trim().toLowerCase())},200);return()=>window.clearTimeout(e)},[n]),(0,Y.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,Y.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,Y.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,X.jsxs)(`div`,{ref:c,className:`space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 md:flex-row md:items-center md:justify-between md:gap-4`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Closest city`}),(0,X.jsxs)(`div`,{className:`relative w-full md:max-w-[280px]`,children:[(0,X.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,X.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,X.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,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-body-medium-default`,children:t.city}),t.region&&(0,X.jsx)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:t.region})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,X.jsx)(`span`,{children:Hn(t.identifier)}),(0,X.jsx)(`span`,{children:t.offsetLabel})]})]},t.identifier))})]})]}),(0,X.jsx)(xn,{}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Time zone`}),(0,X.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=I(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 R(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 W.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 W.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(()=>W.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(()=>W.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(()=>W.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(()=>W.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=j(),n=Yn(t?.cloud),[r,i]=(0,Y.useState)({kind:`idle`}),[a,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useCallback)(e=>{i({kind:`transferring`,step:e,progress:null})},[]),f=(0,Y.useCallback)(e=>{i(t=>t.kind===`transferring`?{...t,progress:e}:t)},[]),p=(0,Y.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,Y.useCallback)(()=>s(!0),[]),h=(0,Y.useCallback)(()=>s(!1),[]),g=(0,Y.useCallback)(()=>{s(!1),p()},[p]),_=(0,Y.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,Y.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&&Nt(n.id).then(e=>{e.ok||o(Error(e.error),{context:`teleport-retire-source`})}),_(),e(G.assistant,{replace:!0})})()},[e,_]),cancelTeleport:(0,Y.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 Re({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 Be(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 A({assistantId:l,name:c.data.name,cloud:`vellum`,runtimeUrl:ee(),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 Lt())?.version??void 0}async function Er(e,t,n){if(e?.createdFresh){let t=await Nt(e.id);t.ok||o(Error(t.error),{context:n})}t&&await z(t.id)}async function Dr(e){let t=await ze(e);return t.ok?t.data.version??void 0:void 0}async function Or(){let e=Se.getState();e.organizations.length===0&&await e.fetchOrganizations();let t=Se.getState().organizations,n=Me();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 Se.getState().setCurrentOrganizationId(r),r}async function kr(e){let t=Date.now();for(;Date.now()-t<yr;){let{data:t,response:n}=await Ne({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 P();let t=e.assistantId?L().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 L().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,X.jsxs)(J,{title:`Teleport`,subtitle:`Move your assistant to a different hosting environment.`,children:[n.kind===`idle`&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:Zn(t)}),(0,X.jsx)(c,{variant:`outlined`,className:`self-start`,onClick:e.requestTeleport,children:Xn(t)})]}),n.kind===`transferring`&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.progress==null&&(0,X.jsx)(H,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:n.step})]}),n.progress!=null&&(0,X.jsx)(S,{value:n.progress,"aria-label":`Teleport progress`,className:`max-w-[240px]`})]}),n.kind===`verifying`&&(0,X.jsx)(x,{tone:`success`,icon:(0,X.jsx)(oe,{className:`h-4 w-4`}),title:`Transfer complete — verify your new assistant is working.`,actions:(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(c,{variant:`primary`,onClick:e.confirmAndSwitch,children:`Confirm & Switch`}),(0,X.jsx)(c,{variant:`outlined`,onClick:e.cancelTeleport,children:`Cancel`})]})}),n.kind===`failed`&&(0,X.jsx)(x,{tone:`error`,title:n.error,actions:(0,X.jsx)(c,{variant:`outlined`,onClick:e.reset,children:`Try Again`})}),(0,X.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=K.use.velvet(),[t,n]=(0,Y.useState)(()=>kt({velvetEnabled:e}));return(0,Y.useEffect)(()=>{n(kt({velvetEnabled:e}))},[e]),(0,Y.useEffect)(()=>a(`theme`,()=>{n(kt({velvetEnabled:e}))}),[e]),(0,Y.useEffect)(()=>{mt(t)},[t]),(0,X.jsx)(J,{title:`Theme`,children:(0,X.jsx)(`div`,{className:`max-w-[360px]`,children:(0,X.jsx)(E,{ariaLabel:`Theme`,value:t,onChange:e=>{n(e),pt(e),mt(e)},items:[{value:`system`,label:`System`,icon:(0,X.jsx)(ce,{className:`h-4 w-4`})},{value:`light`,label:`Light`,icon:(0,X.jsx)(vt,{className:`h-4 w-4`})},{value:`dark`,label:`Dark`,icon:(0,X.jsx)(le,{className:`h-4 w-4`})},...e?[{value:`velvet`,label:`Velvet`,icon:(0,X.jsx)(Ft,{className:`h-4 w-4`})}]:[]]})})})}function Lr(){let e=te.use.activeAssistantId(),[t,n]=(0,Y.useState)(()=>i(`timezone`,``)),a=(0,Y.useRef)(e);(0,Y.useEffect)(()=>{a.current=e},[e]);let s=(0,Y.useRef)(!1),c=(0,Y.useRef)(null),l=(0,Y.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,W.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,Y.useEffect)(()=>{l.current=u}),(0,X.jsx)(J,{title:`Timezone`,subtitle:`Used when displaying times and scheduling reminders.`,children:(0,X.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}=Ht(),s=K.use.multiPlatformAssistant(),c=K.use.teleport(),u=Ue.use.settingsSleepPolicy(),d=we(),f=l(),p=xt(),m=xt({platformHostedOnly:!0}),h=At(),g=Et({assistantId:e?.id??null,enabled:m===`full`&&h}),_=e?.is_local&&!N()?null:e,v=j(),y=N()&&!!e&&!!v&&M(v),b=y,x=y&&!F();return(0,Y.useEffect)(()=>{!e||window.location.hash!==`#storage-resources`||requestAnimationFrame(()=>{document.getElementById(`storage-resources`)?.scrollIntoView({block:`start`})})},[e]),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[g.status&&g.mode!==`inactive`&&(0,X.jsx)(Mt,{status:g.status,mode:g.mode,isAcknowledging:g.isAcknowledging,acknowledgeError:g.acknowledgeError?.message??null,onAcknowledge:()=>void g.acknowledge(),onReviewWorkspaceData:()=>void f(`${G.workspace}?sort=size`),onUpgradeStorage:m===`full`?()=>void f(`${G.settings.billing}?adjust_plan=1`):null}),(0,X.jsx)(J,{title:`General`,children:(0,X.jsx)(Ut,{assistant:_,assistantLoading:t,healthz:n,healthzLoading:r})}),d&&p===`full`&&(0,X.jsx)(rn,{assistant:h?_:null}),m===`full`&&e&&(0,X.jsx)(Ln,{assistant:e,healthz:n,healthzLoading:r,healthzPolling:i,refetch:a,refetchUntilResized:o}),m===`disabled`&&(0,X.jsx)(J,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage compute resources.`})}),(0,X.jsx)(Ir,{}),(0,X.jsx)(mn,{}),B()&&(0,X.jsx)(bn,{}),c&&B()&&(0,X.jsx)(Fr,{}),m===`full`&&_&&(0,X.jsxs)(J,{title:`Software Updates`,children:[(0,X.jsx)(fn,{assistantId:_.id,currentVersion:n?.version??_.current_release_version??null,releaseChannel:_.release_channel,onUpgradeComplete:()=>{a()}}),(0,X.jsx)(jn,{assistantId:_.id,onComplete:()=>{a()}})]}),x&&e&&(0,X.jsx)(J,{title:`Software Updates`,children:(0,X.jsx)(pn,{assistantId:e.id,currentVersion:n?.version??e.current_release_version??null,onUpgradeComplete:()=>{a()}})}),m===`disabled`&&!x&&(0,X.jsx)(J,{title:`Software Updates`,children:(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage software updates.`})}),(0,X.jsx)(_n,{}),m===`full`&&_&&u&&(0,X.jsx)(J,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,X.jsx)(ln,{assistantId:_.id})}),m===`disabled`&&u&&(0,X.jsx)(J,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage sleep policy.`})}),(0,X.jsx)(Lr,{}),(0,X.jsx)(Tn,{}),s&&(0,X.jsx)(on,{}),(p===`full`||b)&&_&&(0,X.jsx)(J,{variant:`danger`,title:`Retire Assistant`,subtitle:`Permanently retire this assistant and delete all associated data.`,children:(0,X.jsx)(Rn,{assistantId:_.id})}),p===`disabled`&&!b&&(0,X.jsx)(J,{variant:`danger`,title:`Retire Assistant`,subtitle:`Permanently retire this assistant and delete all associated data.`,children:(0,X.jsx)(q,{children:`Log in to the Vellum platform to retire this assistant.`})}),(0,X.jsx)(hn,{})]})}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-Hr1Yo2kx.js";import{t as s}from"./react-DJZBPgpf.js";import{t as c}from"./button-D7s2Q_uG.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-CL8VmqrY.js";import{c as _,n as v,s as y}from"./src-CK6bncSg.js";import{t as b}from"./confirm-dialog-CfOXCE1N.js";import{t as x}from"./notice-CqRgVmeL.js";import{t as S}from"./progress-bar-DIFlWPPg.js";import{t as C}from"./tag-B_-QAvJF.js";import{t as w}from"./input-C8kfrq9r.js";import{t as T}from"./toggle-X_kQW5my.js";import{n as E}from"./stat-square-B0S3fO7O.js";import{t as D}from"./modal-D0Q3UWD0.js";import{n as O}from"./toast-2TW5tj1Y.js";import{E as k,b as A,c as j,d as M,f as N,g as P,h as F,i as I,r as L,s as ee,w as R,x as z}from"./local-mode-CvrNMtPF.js";import{t as B}from"./is-electron-C_ZTVhv8.js";import{n as te}from"./resolved-assistants-store-Cp4J43BK.js";import{t as V}from"./createLucideIcon-BlMXrA59.js";import{t as ne}from"./bell-DB1SrBre.js";import{t as re}from"./check-D6WkI0gF.js";import{t as ie}from"./chevron-right-B6vEpVY0.js";import{t as ae}from"./circle-alert-DvNg50UK.js";import{t as oe}from"./circle-check-DzlJxj_M.js";import{t as se}from"./hard-drive-D7_5VMhi.js";import{t as H}from"./loader-circle-IIzBGiwm.js";import{t as ce}from"./monitor-D2okHi8o.js";import{t as le}from"./moon-CK8MXzOo.js";import{t as ue}from"./refresh-cw-Bf6LV0kG.js";import{a as de,c as fe,o as pe,r as me,s as he,t as ge}from"./resize-errors-DnJEbHn4.js";import{t as _e}from"./sparkles-BICoewVE.js";import{t as ve}from"./triangle-alert-DKOyShqD.js";import{n as ye,r as U,t as be}from"./api-errors-CveHbhgb.js";import{I as xe,V as Se,Z as Ce,a as we,b as Te,g as Ee,h as De,l as Oe,n as ke,v as Ae,y as je,z as Me}from"./auth-store-Kfxhs2oI.js";import{t as W}from"./client.gen-Cs6pCK0s.js";import{A as Ne,S as Pe,V as Fe,Y as Ie,j as Le,w as Re}from"./sdk.gen-D-_js_oC.js";import{a as ze,o as Be}from"./api-2kc3MHRz.js";import{a as G}from"./routes-DVqkwUEe.js";import{t as K}from"./client-feature-flag-store-C1kdd1EO.js";import{r as Ve,t as He}from"./semver-yC_Iq9co.js";import{t as Ue}from"./assistant-feature-flag-store-Dl92XRsM.js";import{A as We,D as Ge,E as Ke,M as qe,Q as Je,T as Ye,bt as Xe,c as Ze,et as Qe,gt as $e,j as et,k as tt,v as nt,w as rt,wt as it,xt as at}from"./react-query.gen-rp6Krcco.js";import{t as ot}from"./proxy-DmIh4F51.js";import{t as st}from"./AnimatePresence-CgXwEO42.js";import{t as ct}from"./use-reduced-motion-ChB7nOGe.js";import{$i as lt,Bt as ut,Hr as dt,Ir as ft,Jn as pt,Kn as mt,Lt as ht,Qr as gt,Rn as _t,Rr as vt,Rt as yt,Zr as bt,an as xt,bn as St,d as Ct,en as wt,f as Tt,ht as Et,in as Dt,l as Ot,qn as kt,rn as At,s as jt,st as Mt,tn as Nt,u as Pt,wi as Ft,x as q,zt as It}from"./index-PRnvH2Y1.js";import{t as Lt}from"./app-info-BZYaLxCg.js";import{t as Rt}from"./use-active-assistant-id-C-RHQ9f6.js";import{t as J}from"./detail-card-BIwpXT5F.js";import{t as zt}from"./environment-store-CvH3J6fT.js";import{i as Bt,n as Vt,r as Ht,t as Ut}from"./assistant-status-panel-BkIkvMYw.js";var Wt=V(`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`}]]),Gt=V(`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`}]]),Y=e(s(),1),Kt=De,qt=`Please choose a different handle.`;async function Jt(e,t){let{data:n,error:r,response:i}=await Le({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:U(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}=Te(r,`handle`,Kt.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=Te(r,`handle`,qt);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:U(r,i,`Failed to save handle.`)}}async function Yt(e,t,n){let{data:r,error:i,response:a}=await Pe({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(ye(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new be(a.status,a.status===429?`Too many checks — try again in a moment.`:U(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function Xt(e){return/\d{2,}$/.test(e)}var X=m(),Zt=300,Qt=1400;function $t({initialHandle:e,inputLabel:t,helperText:n,idleHelperText:r,checkAvailable:i,save:a,onSaved:o,saveSuccessToast:s,fieldId:l}){let[u,d]=(0,Y.useState)(e),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(`idle`),[v,y]=(0,Y.useState)(null),b=ct(),x=(0,Y.useRef)(null),S=(0,Y.useMemo)(()=>u.trim().toLowerCase(),[u]),C=S===e.toLowerCase();(0,Y.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)}},Zt);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?Kt[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,Y.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`),Qt);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,X.jsx)(st,{mode:`wait`,initial:!1,children:(0,X.jsxs)(ot.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,X.jsx)(H,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,X.jsx)(re,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":`Available`}),e===`invalid`&&(0,X.jsx)(ae,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":`Not available`})]},e)}):null})(),j=(()=>{switch(g){case`saving`:return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(H,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),`Saving…`]});case`saved`:return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(re,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Saved`]});default:return`Save`}})();return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.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,X.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,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(c,{variant:`primary`,size:`compact`,onClick:k,disabled:!D,"aria-live":`polite`,"data-testid":`${l}-save`,children:j})})]})}function en({initial:e,onSaved:t}){let n=ke.use.refreshSession(),r=Xt(e.username)?`Your handle was auto-generated at signup — pick one you like.`:void 0,i=(0,Y.useCallback)(async e=>await je({username:e}),[]),a=(0,Y.useCallback)((e,t)=>Ee(e,t),[]),o=(0,Y.useCallback)(e=>{t(e),n()},[t,n]);return(0,X.jsx)($t,{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 tn({assistant:e,onSaved:t}){let n=e.handle??``,r=f({...Ze({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,Y.useCallback)(async t=>await Jt(e.id,t),[e.id]),s=(0,Y.useCallback)((t,n)=>Yt(e.id,t,n),[e.id]);return i?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(w,{label:`Assistant handle`,value:n,readOnly:!0,disabled:!0,leftIcon:(0,X.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),fullWidth:!0,"data-testid":`assistant-handle-input`}),(0,X.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,X.jsx)(u,{to:`${G.settings.ai}?release=1#email`,className:`text-[var(--content-link)] underline hover:text-[var(--content-link-hover)]`,children:`release the subdomain`}),` `,`first.`]})]}):(0,X.jsx)($t,{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 nn(){return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":!0,"aria-live":`polite`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`div`,{className:`h-3 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,X.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,X.jsx)(`div`,{className:`h-3 w-72 animate-pulse rounded bg-[var(--surface-muted)]`})]}),(0,X.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`h-3 w-60 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,X.jsx)(`div`,{className:`h-7 w-16 animate-pulse rounded-md bg-[var(--surface-muted)]`})]}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Loading your profile…`})]})}function rn({assistant:e}={}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),a=ct(),[o,s]=(0,Y.useState)(e??null);return(0,Y.useEffect)(()=>{s(e??null)},[e]),(0,Y.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,X.jsx)(J,{title:`Profile`,subtitle:`Manage your user and assistant public handles.`,children:r?(0,X.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:r}):t?(0,X.jsxs)(ot.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,X.jsx)(en,{initial:t,onSaved:n}),o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,X.jsx)(tn,{assistant:o,onSaved:s})]})]}):(0,X.jsx)(nn,{})})}var an=nt({query:{hosting:`platform`}});function on(){let e=Rt(),t=f(an),n=t.data?.results??[];return t.isPending||n.length<2?null:(0,X.jsx)(J,{title:`Switch Assistant`,subtitle:`Choose which assistant is active for this account.`,children:(0,X.jsx)(`div`,{className:`space-y-2`,children:n.map(t=>{let n=t.id===e;return(0,X.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,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(ce,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:t.name||`Unnamed`}),t.status!==`active`&&(0,X.jsx)(C,{tone:`warning`,children:t.status})]})})]}),(0,X.jsx)(`div`,{className:`shrink-0`,children:n?(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5 text-body-small-default text-[var(--system-positive-default)]`,children:[(0,X.jsx)(re,{className:`h-4 w-4`}),`Active`]}):(0,X.jsx)(c,{variant:`outlined`,size:`compact`,disabled:t.status!==`active`,onClick:()=>{Ce(t.id),O.success(`Switched active assistant.`)},children:`Switch`})})]},t.id)})})})}var sn=[{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 cn(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 ln({assistantId:e}){let t=d(),n=zt.use.isNonProduction(),r=(0,Y.useMemo)(()=>sn.filter(e=>!e.devOnly||n),[n]),{data:i,isLoading:a,isError:o}=f(et({path:{id:e}})),s=(0,Y.useMemo)(()=>i?.idle_timeout_seconds??259200,[i]),[l,u]=(0,Y.useState)(null),p=l??s,m=l!==null,h=at({onSuccess:()=>{O.success(`Sleep policy saved.`),u(null),t.invalidateQueries({queryKey:qe({path:{id:e}})})},onError:()=>{O.error(`Failed to save sleep policy. Please try again.`)}});return a?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(H,{className:`h-4 w-4 animate-spin`}),`Loading sleep settings...`]}):o?(0,X.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,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:`Idle timeout`}),(0,X.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,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:r.map(e=>(0,X.jsx)(c,{variant:`outlined`,active:p===e.seconds,onClick:()=>u(e.seconds),children:e.label},e.seconds))}),(0,X.jsxs)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:[`Current: `,cn(p)]})]}),m&&(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(c,{variant:`primary`,leftIcon:h.isPending?(0,X.jsx)(H,{className:`animate-spin`}):void 0,onClick:()=>h.mutate({path:{id:e},body:{idle_timeout_seconds:p}}),disabled:h.isPending,children:`Save`}),(0,X.jsx)(c,{variant:`outlined`,onClick:()=>u(null),disabled:h.isPending,children:`Cancel`})]})]})}function un(e,t,n){let r=[e.version];return e.version===n&&r.push(`(latest)`),t&&e.version===t&&r.push(`(current)`),r.join(` `)}var dn=3e3;function fn({assistantId:e,currentVersion:t,releaseChannel:n,onUpgradeComplete:r}){let i=Ue.use.rollbackEnabled(),a=K.use.previewChannel(),o=d(),s=yt(n,a),l=s===`preview`,[u,m]=(0,Y.useState)(!1),h=(0,Y.useRef)(null),[_,v]=(0,Y.useState)(null),[y,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.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):dn;f({...tt({path:{id:e}}),refetchInterval:u?e=>E(e.state.data?.current_release_version):!1});let{data:D,isLoading:k}=f($e({query:{channel:s}})),A=D?.find(e=>e.is_stable!==!1)??D?.[0],j=_??A?.version??null,M=(0,Y.useMemo)(()=>{if(!i||!j||!t)return!1;let e=Ve(j),n=Ve(t);return!e||!n?!1:He(e,n)<0},[i,j,t]),N=(0,Y.useMemo)(()=>{if(!j)return!1;if(!t)return!0;let e=Ve(j),n=Ve(t);if(!e||!n)return j!==t;let r=He(e,n);return i?r!==0:r>0},[i,j,t]),P=p({mutationFn:async t=>{let{data:n}=await Ie({path:{id:e},body:t,throwOnError:!0});return n}}),F=p({mutationFn:async t=>{let{data:n}=await Fe({path:{id:e},body:t,throwOnError:!0});return n}});return(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,X.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:t??`—`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:l?`Preview release`:N?M?`Rollback to`:`Update to`:`Selected`}),(0,X.jsx)(`span`,{className:`block min-w-0`,children:k?(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(H,{className:`h-3 w-3 animate-spin`}),`Loading...`]}):D&&D.length>0?i?(0,X.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:un(e,t,A?.version)}))}):(0,X.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:A?un(A,t,A.version):`—`}):`No releases available`})]})]}),(0,X.jsx)(c,{variant:M?`outlined`:`primary`,className:`min-w-[160px]`,leftIcon:P.isPending||F.isPending||u?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(ue,{}),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,X.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Using Preview releases.`,` `,(0,X.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,X.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:w??`You are already on this version.`}),(0,X.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:We({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 pn({assistantId:e,currentVersion:t,onUpgradeComplete:n}){let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(null),{data:s,isLoading:l}=f($e({query:{stable:!0,limit:100}})),u=(0,Y.useMemo)(()=>ht(s),[s]),d=u?.version,p=t?It(t,d):!!d,m=ut({assistantId:e,targetVersion:d});return(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,X.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:t??`—`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Update to`}),(0,X.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:l?`Loading...`:d&&u?un(u,t,d):`No releases available`})]})]}),(0,X.jsx)(c,{variant:`primary`,className:`min-w-[160px]`,leftIcon:m.isPending?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(ue,{}),onClick:()=>i(!0),disabled:m.isPending||l||!d||!p,children:m.isPending?`Updating...`:d?`Update to ${d}`:`Update`}),a&&(0,X.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:a}),!a&&!p&&d&&!l&&(0,X.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:`You are already on this version.`}),(0,X.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 mn(){let e=Tt.useValue();if(St())return null;let t=Pt()?`Cmd`:`Ctrl`;return(0,X.jsx)(J,{title:`Composer`,children:(0,X.jsx)(T,{checked:e,onChange:Tt.save,label:`Send with ${t}+Enter`,helperText:`When enabled, Enter inserts a new line and ${t}+Enter sends.`})})}function hn(){let e=xt({platformHostedOnly:!0}),t=Dt(),n=ke.use.user()?.id??null,r=ke.use.logout(),[i,a]=(0,Y.useState)(!1),o=it({onSuccess:async()=>{O.success(`Account deletion requested. You will be logged out shortly.`),Oe(n),await r(),_t(G.account.login)},onError:()=>{O.error(`Failed to request account deletion. Please try again.`)}}),s=e===`full`&&t;return(0,Y.useEffect)(()=>{s&&i&&a(!1)},[s,i]),e===`gated`?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(J,{title:`Delete Account`,subtitle:`Permanently delete your account and all associated data.`,variant:`danger`,children:e===`disabled`?(0,X.jsx)(q,{children:`Log in to the Vellum platform to delete your account.`}):(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(c,{variant:`dangerOutline`,onClick:()=>a(!0),disabled:o.isPending||s,className:`self-start`,children:`Delete My Account`}),s&&(0,X.jsx)(H,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})}),(0,X.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 gn({title:e,subtitle:t,benefits:n,ctaLabel:r,ctaLeftIcon:i,onAction:a}){return(0,X.jsx)(J,{title:e,subtitle:t,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(`ul`,{className:`space-y-3`,children:n.map(({icon:e,text:t})=>(0,X.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`},children:(0,X.jsx)(e,{size:14,style:{color:`var(--content-secondary)`},"aria-hidden":!0})}),(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]},t))}),(0,X.jsx)(c,{variant:`primary`,size:`regular`,leftIcon:i,onClick:a,className:`self-start`,children:r})]})})}function _n(){return Ct()?(0,X.jsx)(gn,{title:`Get the iOS App`,subtitle:`The Vellum iOS app gives you a native experience.`,benefits:[{icon:ne,text:`Push notifications`},{icon:Wt,text:`Biometric login`},{icon:Gt,text:`Native haptics`},{icon:dt,text:`Home screen access`}],ctaLabel:`Download`,ctaLeftIcon:(0,X.jsx)(dt,{size:16}),onAction:()=>{Ot(),jt()}}):null}async function vn(){if(!B())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function yn(e){if(!B())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function bn(){let[e,t]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{vn().then(t)},[]);let n=async e=>{t(e);try{await yn(e)}catch{t(!e)}};return(0,X.jsx)(J,{title:`Launch at Login`,subtitle:`Automatically start Vellum when you log in to your Mac.`,children:(0,X.jsx)(T,{checked:e,onChange:e=>void n(e),"aria-label":`Launch at Login`})})}function xn({className:e}){return(0,X.jsx)(`div`,{role:`presentation`,className:h(`h-px w-full bg-[var(--border-base)]`,e)})}var Z=[`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[...Z]}function Cn(){return n(`mediaEmbedsEnabled`,!0)}function wn(){let e=i(`mediaEmbedDomains`,``);return e?Sn(e):[...Z]}function Tn(){let[e,n]=(0,Y.useState)(()=>Cn()),[i,a]=(0,Y.useState)(()=>wn()),[o,s]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(``),d=(0,Y.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([...Z])},_=i.length===Z.length&&i.every((e,t)=>e===Z[t]);return(0,X.jsxs)(J,{title:`Media Embeds`,subtitle:`Automatically embed images, videos, and other media shared in chat messages.`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Auto Media Embeds`}),(0,X.jsx)(T,{checked:e,onChange:f})]}),e&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(xn,{})}),(0,X.jsxs)(c,{type:`button`,variant:`ghost`,onClick:()=>s(e=>!e),className:`mt-4 w-full justify-between px-3`,"aria-expanded":o,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[o?(0,X.jsx)(lt,{className:`h-4 w-4`,"aria-hidden":!0}):(0,X.jsx)(ie,{className:`h-4 w-4`,"aria-hidden":!0}),`Video Domain Allowlist`]}),(0,X.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[i.length,` domain`,i.length===1?``:`s`]})]}),o&&(0,X.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,X.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,X.jsx)(c,{variant:`primary`,size:`compact`,onClick:m,disabled:!d,children:`Add`})]}),i.length>0&&(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,onClick:g,disabled:_,tintColor:`var(--content-tertiary)`,children:`Reset to Defaults`})}),i.length>0&&(0,X.jsx)(`ul`,{className:`space-y-2`,children:i.map(e=>(0,X.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,X.jsx)(`span`,{className:`font-mono text-[var(--content-default)]`,children:e}),(0,X.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,X.jsx)(ft,{}),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=K.use.previewChannel(),r=d(),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,m]=(0,Y.useState)(`restore_backup`),[h,g]=(0,Y.useState)(``),_=Ke({path:{assistant_id:e}}),y=Ge({path:{assistant_id:e}}),b=We({path:{id:e}}),{data:S,isLoading:w,isError:T}=f({..._,enabled:n,retry:!1}),E=S?.preview_backups??[],D=(0,Y.useMemo)(()=>kn(E),[E]),k=D[0],A=D.find(e=>e.snapshot_name===h)??k,j=()=>{r.invalidateQueries({queryKey:y}),r.invalidateQueries({queryKey:b}),t?.()},M=p(rt()),N=p(Ye()),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,Y.useEffect)(()=>{a(P===`preview`?`release-channel`:void 0)},[P]),!n)return null;let ee=S?.standard_upgrade_available??!1;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(v.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,X.jsxs)(v.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,X.jsxs)(v.Trigger,{className:`group justify-between gap-3`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`Release Channel`}),S&&(0,X.jsx)(C,{tone:P===`preview`?`warning`:`neutral`,children:P===`preview`?`Preview`:`Stable`})]}),(0,X.jsx)(lt,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,X.jsx)(v.Content,{children:(0,X.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[w&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,X.jsx)(H,{className:`h-4 w-4 animate-spin`}),`Loading release channel...`]}),T&&(0,X.jsx)(x,{tone:`error`,title:`Could not load release channel status`,children:`Refresh this page before changing release channels.`}),S&&(0,X.jsxs)(X.Fragment,{children:[An(S)&&(0,X.jsx)(x,{tone:`neutral`,title:`Preview channel is unavailable`,children:`The Preview channel is not enabled for this assistant.`}),P===`stable`?(0,X.jsx)(Mn,{status:S,isChangingChannel:F,optInDisabled:I,onOptIn:()=>s(!0)}):(0,X.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,X.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(U(e,void 0,`Could not enable Preview channel.`))}},onCancel:()=>s(!1)}),(0,X.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(U(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>l(!1)})]})}function Mn({status:e,isChangingChannel:t,optInDisabled:n,onOptIn:r}){return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(Pn,{status:e}),!e.latest_preview_release&&(0,X.jsx)(x,{tone:`neutral`,title:`No Preview release is available`,children:`Stable remains the only available release channel.`}),(0,X.jsx)(c,{variant:`outlined`,leftIcon:t?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(gt,{}),disabled:n,onClick:r,children:`Opt in to Preview`})]})}function Nn({status:e,isChangingChannel:t,onOptOut:n}){return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(Pn,{status:e}),(0,X.jsx)(c,{variant:`outlined`,leftIcon:t?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(bt,{}),disabled:t,onClick:n,children:`Switch back to Stable`})]})}function Pn({status:e}){return(0,X.jsxs)(`dl`,{className:`grid gap-3 text-body-medium-lighter sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Stable`}),(0,X.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_stable_release?.version??`None`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Preview`}),(0,X.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,X.jsx)(D.Root,{open:e,onOpenChange:e=>!e&&i(),children:(0,X.jsxs)(D.Content,{size:`md`,hideCloseButton:t,children:[(0,X.jsxs)(D.Header,{children:[(0,X.jsx)(D.Title,{icon:ve,children:`Opt in to Preview`}),(0,X.jsx)(D.Description,{children:`Preview releases may be unstable. A 90-day safety backup is taken before the image changes.`})]}),(0,X.jsx)(D.Body,{children:(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.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,X.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,X.jsx)(`li`,{children:`Create and verify a Preview safety backup.`}),(0,X.jsxs)(`li`,{children:[`Switch to Preview image `,n??`latest`,`.`]}),(0,X.jsx)(`li`,{children:`Run the normal upgrade path and wait for health.`})]})]})}),(0,X.jsxs)(D.Footer,{children:[(0,X.jsx)(c,{variant:`outlined`,disabled:t,onClick:i,children:`Cancel`}),(0,X.jsx)(c,{variant:`primary`,disabled:t,leftIcon:t?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(gt,{}),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,X.jsx)(D.Root,{open:e,onOpenChange:e=>!e&&d(),children:(0,X.jsxs)(D.Content,{size:`md`,hideCloseButton:i,children:[(0,X.jsxs)(D.Header,{children:[(0,X.jsx)(D.Title,{icon:ve,children:`Switch back to Stable`}),(0,X.jsx)(D.Description,{children:`Choose how this assistant should leave the Preview channel.`})]}),(0,X.jsx)(D.Body,{children:(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(_,{value:n,onValueChange:s,disabled:i,"aria-label":`Stable channel return method`,children:[(0,X.jsx)(y,{value:`restore_backup`,disabled:t.length===0,label:`Restore safety backup`,helperText:`Return to the Stable-channel data captured before Preview opt-in.`}),(0,X.jsx)(y,{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,X.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[`Safety backup`,(0,X.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,X.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,X.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,X.jsxs)(D.Footer,{children:[(0,X.jsx)(c,{variant:`outlined`,disabled:i,onClick:d,children:`Cancel`}),(0,X.jsx)(c,{variant:n===`standard_upgrade`?`danger`:`primary`,disabled:i||a||n===`standard_upgrade`&&!o,leftIcon:i?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(ue,{}),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(Qe()),d=s.data,p=!e.is_local,m=d?.plan_id===`pro`,h=f({...Je(),enabled:m}),_=e.machine_size||`small`,v=de(h.data?.max_machine_tier??null),y=(0,Y.useMemo)(()=>pe(v,_,(0,X.jsx)(C,{tone:`positive`,children:`Current`})),[v,_]),b=h.data?.selected_storage_gib??null,[S,w]=(0,Y.useState)(!1),T=v.length>0?v[v.length-1]:null,[E,k]=(0,Y.useState)(null),A=E??T??_,[j,M]=(0,Y.useState)(null),[N,P]=(0,Y.useState)(null),F=Xe({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(ge(e,`Failed to resize assistant. Please try again.`))}});if(s.isError&&d==null)return(0,X.jsx)(J,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,X.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&&he(_)<he(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:`${Vt(t.disk.usedMb)} of ${Vt(z)}`}:null,te=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,V=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:`${Vt(t.memory.currentMb)} of ${Vt(t.memory.maxMb)}`}:null,ne=p?m?L?(0,X.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,X.jsx)(_e,{className:`h-3.5 w-3.5`}),`Increase Storage`]}):(0,X.jsx)(c,{variant:`ghost`,size:`compact`,disabled:R,onClick:()=>w(!0),children:`Resize`}):(0,X.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>M(`storage`),children:`Resize`}):null,re=p?m?ee?(0,X.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,X.jsx)(_e,{className:`h-3.5 w-3.5`}),`Increase Size`]}):(0,X.jsx)(c,{variant:`ghost`,size:`compact`,disabled:R,onClick:()=>w(!0),children:`Resize`}):(0,X.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>M(`machine`),children:`Resize`}):null;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(J,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,compactAccessory:!0,accessory:(0,X.jsx)(c,{variant:`ghost`,size:`compact`,iconOnly:n||r?(0,X.jsx)(H,{className:`animate-spin`}):(0,X.jsx)(ue,{}),tooltip:r?`Applying resize…`:`Refresh resource metrics`,"aria-label":`Refresh resource metrics`,disabled:n||r,onClick:()=>void i()}),children:(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_2fr]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,X.jsx)(se,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Disk`})]}),ne]}),(0,X.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1 pt-3`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Storage`}),B?(0,X.jsx)(Bt,{value:B.value,max:B.max,caption:B.caption}):n?(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,X.jsx)(H,{className:`h-3 w-3 animate-spin`})}):(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Unavailable`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,X.jsx)(fe,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Machine`}),(0,X.jsx)(C,{tone:`neutral`,children:me[_]})]}),re]}),(0,X.jsxs)(`div`,{className:`mt-auto grid grid-cols-2 gap-3 pt-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`CPU`}),te?(0,X.jsx)(Bt,{value:te.value,max:te.max,caption:te.caption}):n?(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,X.jsx)(H,{className:`h-3 w-3 animate-spin`})}):(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Memory`}),V?(0,X.jsx)(Bt,{value:V.value,max:V.max,caption:V.caption}):n?(0,X.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,X.jsx)(H,{className:`h-3 w-3 animate-spin`})}):(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,X.jsx)(D.Root,{open:j!=null,onOpenChange:e=>{e||M(null)},children:(0,X.jsxs)(D.Content,{size:`sm`,children:[(0,X.jsxs)(D.Header,{children:[(0,X.jsx)(D.Title,{children:`Upgrade to Pro`}),(0,X.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,X.jsxs)(D.Footer,{children:[(0,X.jsx)(c,{variant:`ghost`,onClick:()=>M(null),children:`Cancel`}),(0,X.jsx)(c,{onClick:()=>{M(null),o(`${G.settings.billing}?adjust_plan=1`)},children:`Upgrade`})]})]})}),(0,X.jsx)(D.Root,{open:S,onOpenChange:e=>{e||(w(!1),k(null),P(null))},children:(0,X.jsxs)(D.Content,{size:`sm`,children:[(0,X.jsxs)(D.Header,{children:[(0,X.jsx)(D.Title,{icon:fe,children:`Resize Assistant`}),(0,X.jsx)(D.Description,{children:`Resize your assistant's compute and storage. Your assistant will briefly restart.`})]}),(0,X.jsx)(D.Body,{children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[v.length===0?(0,X.jsx)(x,{tone:`warning`,children:`No machine tier configured. Visit the community for help.`}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:`Machine Size`}),(0,X.jsx)(g,{options:y,value:A,onChange:k,"aria-label":`Compute machine size`,"data-testid":`resize-machine-size`})]}),L?(0,X.jsx)(x,{tone:`info`,children:`Storage will be expanded to ${b} GiB.`}):(0,X.jsx)(x,{tone:`neutral`,children:`Storage will not change.`}),N&&(0,X.jsx)(x,{tone:`error`,children:N})]})}),(0,X.jsxs)(D.Footer,{className:`items-center justify-between`,children:[(0,X.jsxs)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:[`Need more?`,` `,(0,X.jsx)(u,{to:`${G.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,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(c,{variant:`ghost`,onClick:()=>{w(!1),k(null),P(null)},children:`Cancel`}),(0,X.jsx)(c,{disabled:I==null&&!L||R,leftIcon:R?(0,X.jsx)(H,{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,Y.useState)(!1),[i,a]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(c,{variant:`dangerOutline`,onClick:()=>r(!0),className:`shrink-0`,children:`Retire Assistant`}),(0,X.jsx)(wt,{open:n,isPending:i,onConfirm:async()=>{a(!0);let n=await Nt(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,Y.useState)(``),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=(0,Y.useMemo)(()=>Bn().map(e=>Vn(e)).filter(e=>e!==null),[]);(0,Y.useEffect)(()=>{let e=window.setTimeout(()=>{a(n.trim().toLowerCase())},200);return()=>window.clearTimeout(e)},[n]),(0,Y.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,Y.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,Y.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,X.jsxs)(`div`,{ref:c,className:`space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 md:flex-row md:items-center md:justify-between md:gap-4`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Closest city`}),(0,X.jsxs)(`div`,{className:`relative w-full md:max-w-[280px]`,children:[(0,X.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,X.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,X.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,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-body-medium-default`,children:t.city}),t.region&&(0,X.jsx)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:t.region})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,X.jsx)(`span`,{children:Hn(t.identifier)}),(0,X.jsx)(`span`,{children:t.offsetLabel})]})]},t.identifier))})]})]}),(0,X.jsx)(xn,{}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,X.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Time zone`}),(0,X.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=I(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 R(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 W.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 W.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(()=>W.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(()=>W.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(()=>W.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(()=>W.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=j(),n=Yn(t?.cloud),[r,i]=(0,Y.useState)({kind:`idle`}),[a,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useCallback)(e=>{i({kind:`transferring`,step:e,progress:null})},[]),f=(0,Y.useCallback)(e=>{i(t=>t.kind===`transferring`?{...t,progress:e}:t)},[]),p=(0,Y.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,Y.useCallback)(()=>s(!0),[]),h=(0,Y.useCallback)(()=>s(!1),[]),g=(0,Y.useCallback)(()=>{s(!1),p()},[p]),_=(0,Y.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,Y.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&&Nt(n.id).then(e=>{e.ok||o(Error(e.error),{context:`teleport-retire-source`})}),_(),e(G.assistant,{replace:!0})})()},[e,_]),cancelTeleport:(0,Y.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 Re({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 Be(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 A({assistantId:l,name:c.data.name,cloud:`vellum`,runtimeUrl:ee(),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 Lt())?.version??void 0}async function Er(e,t,n){if(e?.createdFresh){let t=await Nt(e.id);t.ok||o(Error(t.error),{context:n})}t&&await z(t.id)}async function Dr(e){let t=await ze(e);return t.ok?t.data.version??void 0:void 0}async function Or(){let e=Se.getState();e.organizations.length===0&&await e.fetchOrganizations();let t=Se.getState().organizations,n=Me();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 Se.getState().setCurrentOrganizationId(r),r}async function kr(e){let t=Date.now();for(;Date.now()-t<yr;){let{data:t,response:n}=await Ne({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 P();let t=e.assistantId?L().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 L().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,X.jsxs)(J,{title:`Teleport`,subtitle:`Move your assistant to a different hosting environment.`,children:[n.kind===`idle`&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:Zn(t)}),(0,X.jsx)(c,{variant:`outlined`,className:`self-start`,onClick:e.requestTeleport,children:Xn(t)})]}),n.kind===`transferring`&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.progress==null&&(0,X.jsx)(H,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),(0,X.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:n.step})]}),n.progress!=null&&(0,X.jsx)(S,{value:n.progress,"aria-label":`Teleport progress`,className:`max-w-[240px]`})]}),n.kind===`verifying`&&(0,X.jsx)(x,{tone:`success`,icon:(0,X.jsx)(oe,{className:`h-4 w-4`}),title:`Transfer complete — verify your new assistant is working.`,actions:(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(c,{variant:`primary`,onClick:e.confirmAndSwitch,children:`Confirm & Switch`}),(0,X.jsx)(c,{variant:`outlined`,onClick:e.cancelTeleport,children:`Cancel`})]})}),n.kind===`failed`&&(0,X.jsx)(x,{tone:`error`,title:n.error,actions:(0,X.jsx)(c,{variant:`outlined`,onClick:e.reset,children:`Try Again`})}),(0,X.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=K.use.velvet(),[t,n]=(0,Y.useState)(()=>kt({velvetEnabled:e}));return(0,Y.useEffect)(()=>{n(kt({velvetEnabled:e}))},[e]),(0,Y.useEffect)(()=>a(`theme`,()=>{n(kt({velvetEnabled:e}))}),[e]),(0,Y.useEffect)(()=>{mt(t)},[t]),(0,X.jsx)(J,{title:`Theme`,children:(0,X.jsx)(`div`,{className:`max-w-[360px]`,children:(0,X.jsx)(E,{ariaLabel:`Theme`,value:t,onChange:e=>{n(e),pt(e),mt(e)},items:[{value:`system`,label:`System`,icon:(0,X.jsx)(ce,{className:`h-4 w-4`})},{value:`light`,label:`Light`,icon:(0,X.jsx)(vt,{className:`h-4 w-4`})},{value:`dark`,label:`Dark`,icon:(0,X.jsx)(le,{className:`h-4 w-4`})},...e?[{value:`velvet`,label:`Velvet`,icon:(0,X.jsx)(Ft,{className:`h-4 w-4`})}]:[]]})})})}function Lr(){let e=te.use.activeAssistantId(),[t,n]=(0,Y.useState)(()=>i(`timezone`,``)),a=(0,Y.useRef)(e);(0,Y.useEffect)(()=>{a.current=e},[e]);let s=(0,Y.useRef)(!1),c=(0,Y.useRef)(null),l=(0,Y.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,W.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,Y.useEffect)(()=>{l.current=u}),(0,X.jsx)(J,{title:`Timezone`,subtitle:`Used when displaying times and scheduling reminders.`,children:(0,X.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}=Ht(),s=K.use.multiPlatformAssistant(),c=K.use.teleport(),u=Ue.use.settingsSleepPolicy(),d=we(),f=l(),p=xt(),m=xt({platformHostedOnly:!0}),h=At(),g=Et({assistantId:e?.id??null,enabled:m===`full`&&h}),_=e?.is_local&&!N()?null:e,v=j(),y=N()&&!!e&&!!v&&M(v),b=y,x=y&&!F();return(0,Y.useEffect)(()=>{!e||window.location.hash!==`#storage-resources`||requestAnimationFrame(()=>{document.getElementById(`storage-resources`)?.scrollIntoView({block:`start`})})},[e]),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[g.status&&g.mode!==`inactive`&&(0,X.jsx)(Mt,{status:g.status,mode:g.mode,isAcknowledging:g.isAcknowledging,acknowledgeError:g.acknowledgeError?.message??null,onAcknowledge:()=>void g.acknowledge(),onReviewWorkspaceData:()=>void f(`${G.workspace}?sort=size`),onUpgradeStorage:m===`full`?()=>void f(`${G.settings.billing}?adjust_plan=1`):null}),(0,X.jsx)(J,{title:`General`,children:(0,X.jsx)(Ut,{assistant:_,assistantLoading:t,healthz:n,healthzLoading:r})}),d&&p===`full`&&(0,X.jsx)(rn,{assistant:h?_:null}),m===`full`&&e&&(0,X.jsx)(Ln,{assistant:e,healthz:n,healthzLoading:r,healthzPolling:i,refetch:a,refetchUntilResized:o}),m===`disabled`&&(0,X.jsx)(J,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage compute resources.`})}),(0,X.jsx)(Ir,{}),(0,X.jsx)(mn,{}),B()&&(0,X.jsx)(bn,{}),c&&B()&&(0,X.jsx)(Fr,{}),m===`full`&&_&&(0,X.jsxs)(J,{title:`Software Updates`,children:[(0,X.jsx)(fn,{assistantId:_.id,currentVersion:n?.version??_.current_release_version??null,releaseChannel:_.release_channel,onUpgradeComplete:()=>{a()}}),(0,X.jsx)(jn,{assistantId:_.id,onComplete:()=>{a()}})]}),x&&e&&(0,X.jsx)(J,{title:`Software Updates`,children:(0,X.jsx)(pn,{assistantId:e.id,currentVersion:n?.version??e.current_release_version??null,onUpgradeComplete:()=>{a()}})}),m===`disabled`&&!x&&(0,X.jsx)(J,{title:`Software Updates`,children:(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage software updates.`})}),(0,X.jsx)(_n,{}),m===`full`&&_&&u&&(0,X.jsx)(J,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,X.jsx)(ln,{assistantId:_.id})}),m===`disabled`&&u&&(0,X.jsx)(J,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,X.jsx)(q,{children:`Log in to the Vellum platform to manage sleep policy.`})}),(0,X.jsx)(Lr,{}),(0,X.jsx)(Tn,{}),s&&(0,X.jsx)(on,{}),(p===`full`||b)&&_&&(0,X.jsx)(J,{variant:`danger`,title:`Retire Assistant`,subtitle:`Permanently retire this assistant and delete all associated data.`,children:(0,X.jsx)(Rn,{assistantId:_.id})}),p===`disabled`&&!b&&(0,X.jsx)(J,{variant:`danger`,title:`Retire Assistant`,subtitle:`Permanently retire this assistant and delete all associated data.`,children:(0,X.jsx)(q,{children:`Log in to the Vellum platform to retire this assistant.`})}),(0,X.jsx)(hn,{})]})}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-Hr1Yo2kx.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-D7s2Q_uG.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{E as ee,_ as te,b as u,et as ne,f as d,g as re,i as ie,s as f}from"./local-mode-CvrNMtPF.js";import{t as p}from"./is-electron-C_ZTVhv8.js";import{n as m}from"./resolved-assistants-store-Cp4J43BK.js";import{r as ae}from"./api-errors-CveHbhgb.js";import{Q as h,V as g,Z as _,at as oe,ct as se,k as ce,n as v,nt as y,ot as le,st as b}from"./auth-store-Kfxhs2oI.js";import{a as ue,o as de,r as x}from"./api-2kc3MHRz.js";import{a as S}from"./routes-DVqkwUEe.js";import{r as C,t as w}from"./build-state-VC4tL7sK.js";import{i as fe,p as pe}from"./prefs-C_oq5G87.js";import{t as T}from"./avatar-svg-compositor-CEmN7KGI.js";import{Fn as E,Pn as D,jn as O,kt as k}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,t as n}from"./capture-error-Hr1Yo2kx.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-D7s2Q_uG.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{E as ee,_ as te,b as u,et as ne,f as d,g as re,i as ie,s as f}from"./local-mode-CvrNMtPF.js";import{t as p}from"./is-electron-C_ZTVhv8.js";import{n as m}from"./resolved-assistants-store-Cp4J43BK.js";import{r as ae}from"./api-errors-CveHbhgb.js";import{Q as h,V as g,Z as _,at as oe,ct as se,k as ce,n as v,nt as y,ot as le,st as b}from"./auth-store-Kfxhs2oI.js";import{a as ue,o as de,r as x}from"./api-2kc3MHRz.js";import{a as S}from"./routes-DVqkwUEe.js";import{r as C,t as w}from"./build-state-VC4tL7sK.js";import{i as fe,p as pe}from"./prefs-C_oq5G87.js";import{t as T}from"./avatar-svg-compositor-CEmN7KGI.js";import{Fn as E,Pn as D,jn as O,kt as k}from"./index-PRnvH2Y1.js";import{t as me}from"./provider-key-nA35OC4Y.js";import{BUNDLED_COMPONENTS as A}from"./avatar-bundled-components-BgAkdy0n.js";var j=e(r(),1);async function he(e,t,r){try{await D(e)||await E(e,t),r.invalidateQueries({queryKey:O(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`,O=v.use.sessionStatus(),z=D?y(O):O,[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,y=!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(ce()){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 re(),e.assistantId&&_(e.assistantId),$(`connecting`);let t=!1;for(;!a&&!t;){let e=ie();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`){ne(),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&&await v.getState().connectLocalAssistant(e.assistantId),e.assistantId){try{await me(e.assistantId)}catch(e){n(e,{context:`onboarding_apply_provider_key`})}m.getState().upsertFromApi({id:e.assistantId,name:e.assistantId,status:`active`,is_local:!0,created:new Date().toISOString()}),_(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||=de(E?{version:E}:void 0);let e=await I;if(I=null,a)return;if(e.ok&&(p=e.data.id),y=e.ok&&e.status===201,!e.ok){if(t(`Onboarding hatch request failed`,{level:`warning`,extra:{status:e.status,error:e.error}}),le(e.status,e.error)){G(oe),K(!0);return}if(!se(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),_(t),(y||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 ue(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)(k,{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)(k,{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};
|