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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/assets/{account-page-D5qDx37o.js → account-page-B5rB7loj.js} +1 -1
  2. package/dist/assets/{add-credits-modal-DpHTkxV2.js → add-credits-modal-BEX4_5jj.js} +1 -1
  3. package/dist/assets/{advanced-page-DWX9qbxa.js → advanced-page-9RUi4YCF.js} +1 -1
  4. package/dist/assets/{ai-page-Cp6X0S2W.js → ai-page-CZj92XF4.js} +1 -1
  5. package/dist/assets/{api-key-screen-DvV4RiY0.js → api-key-screen-CUKjlF2C.js} +1 -1
  6. package/dist/assets/{archive-page-B7i9-bc2.js → archive-page-YsBlmevd.js} +1 -1
  7. package/dist/assets/{billing-page-CMhUfBBf.js → billing-page-DgX2YBSA.js} +1 -1
  8. package/dist/assets/{bookmarks-page-BBlx8L6h.js → bookmarks-page-DRcIBBva.js} +1 -1
  9. package/dist/assets/{command-palette-yIWk_niH.js → command-palette-BXEAR93M.js} +1 -1
  10. package/dist/assets/{command-palette-window-page-CHu_bF8J.js → command-palette-window-page-5SP_Ft4Y.js} +1 -1
  11. package/dist/assets/{community-page-CiartSQX.js → community-page-D5-exeNr.js} +1 -1
  12. package/dist/assets/{contacts-page-route-C9IaBKKe.js → contacts-page-route-C9T-8Sdr.js} +1 -1
  13. package/dist/assets/{debug-page-DGQMqihK.js → debug-page-ClQetFUa.js} +1 -1
  14. package/dist/assets/{deploy-dialogs-DWIqIDdv.js → deploy-dialogs-BtpYB7B8.js} +1 -1
  15. package/dist/assets/{developer-page-ClPMK7n8.js → developer-page-DQs8SZ8K.js} +1 -1
  16. package/dist/assets/{devices-page-N9s-okC5.js → devices-page-VsRsz6XP.js} +1 -1
  17. package/dist/assets/{dictation-overlay-page-D_eJHI6R.js → dictation-overlay-page-C5HFJIsY.js} +1 -1
  18. package/dist/assets/{document-viewer-page-CmSYAtEc.js → document-viewer-page-BLBwWqM4.js} +1 -1
  19. package/dist/assets/{earn-credits-modal-OFm9gF2_.js → earn-credits-modal-Dig03UD-.js} +1 -1
  20. package/dist/assets/{emails-page-psWdsGCD.js → emails-page-D9R72EQW.js} +1 -1
  21. package/dist/assets/{file-editor-CKotrZYQ.js → file-editor-HQXiGdH-.js} +1 -1
  22. package/dist/assets/{general-page-CaAos_hp.js → general-page-CMr5RhNh.js} +1 -1
  23. package/dist/assets/{hatching-screen-CtgkoJwM.js → hatching-screen-BAzE4aGD.js} +1 -1
  24. package/dist/assets/{home-page-route-syOFwCBN.js → home-page-route-JenDSLBl.js} +1 -1
  25. package/dist/assets/{hosting-screen-Duoz3ECF.js → hosting-screen-dPfTLCnv.js} +1 -1
  26. package/dist/assets/{identity-page-route-gCgQUpAC.js → identity-page-route-r9ZgIw8g.js} +1 -1
  27. package/dist/assets/{index-LP2PV_QY.js → index-BiN-6kWM.js} +23 -23
  28. package/dist/assets/{inspect-page-CYszP4kv.js → inspect-page-2cNMjT4e.js} +1 -1
  29. package/dist/assets/{install-BK1MtTfb.js → install-CHMiF_Hw.js} +1 -1
  30. package/dist/assets/{integrations-page-8RrTqdmS.js → integrations-page-BiLM3QyR.js} +1 -1
  31. package/dist/assets/{intelligence-layout-DMxSxRZX.js → intelligence-layout-CjDxFKQO.js} +1 -1
  32. package/dist/assets/{keyboard-shortcuts-page-q_QkRUkC.js → keyboard-shortcuts-page-DIhG1FK_.js} +1 -1
  33. package/dist/assets/{library-detail-page-_lrynJRj.js → library-detail-page-CjeBxuMc.js} +1 -1
  34. package/dist/assets/{library-page-CKh1x82Q.js → library-page-BFIPthR_.js} +1 -1
  35. package/dist/assets/{login-page-CDtyRiaq.js → login-page-KDH0IZ6y.js} +1 -1
  36. package/dist/assets/{logout-page-vdgRWyPg.js → logout-page-DI7i4Hok.js} +1 -1
  37. package/dist/assets/{logs-layout-btcFTD4i.js → logs-layout-BEMQQY7S.js} +1 -1
  38. package/dist/assets/{mcp-page-DdG8hp_Z.js → mcp-page-B7tUTzT0.js} +1 -1
  39. package/dist/assets/{memory-router-playground-page-Bt_KJsxN.js → memory-router-playground-page-JdkTEwPy.js} +1 -1
  40. package/dist/assets/{mobile-sidebar-drawer-Cd68jgRD.js → mobile-sidebar-drawer-DuJUmy0b.js} +1 -1
  41. package/dist/assets/{notifications-page-BilkBeoP.js → notifications-page-CmOvbV59.js} +1 -1
  42. package/dist/assets/{oauth-complete-page-BC7UElNs.js → oauth-complete-page-R_1ODIIi.js} +1 -1
  43. package/dist/assets/{oauth-popup-complete-page-CiTNEvfk.js → oauth-popup-complete-page-YECuZtPs.js} +1 -1
  44. package/dist/assets/{pairing-page-Dc-5wQmY.js → pairing-page-BtaFWq0w.js} +1 -1
  45. package/dist/assets/{plugin-detail-page-CtWtIYBW.js → plugin-detail-page-D6Gve0qx.js} +1 -1
  46. package/dist/assets/{plugins-page-1vkkdBfG.js → plugins-page-DA-JrehF.js} +1 -1
  47. package/dist/assets/{prechat-route-CG8Qo2Tq.js → prechat-route-BhzvRsw3.js} +1 -1
  48. package/dist/assets/{privacy-page-rNHkqHfs.js → privacy-page-Yex5OJjZ.js} +1 -1
  49. package/dist/assets/{privacy-screen-Cck6z5wu.js → privacy-screen-ccjT4S0F.js} +1 -1
  50. package/dist/assets/{provider-callback-page-CrZXFWM7.js → provider-callback-page-BS-DqV_M.js} +1 -1
  51. package/dist/assets/{research-mock-page-D7-VpSBh.js → research-mock-page-D0-sKBpu.js} +1 -1
  52. package/dist/assets/{research-onboarding-route-DAPVTFHs.js → research-onboarding-route-ZTgUGnrN.js} +1 -1
  53. package/dist/assets/{review-terms-screen-C8XTIUYc.js → review-terms-screen-DLWgKysx.js} +1 -1
  54. package/dist/assets/{select-assistant-screen-PZqDGbI2.js → select-assistant-screen-LNX6PpzR.js} +1 -1
  55. package/dist/assets/{settings-layout-ByZKbs5J.js → settings-layout-BA0suokL.js} +1 -1
  56. package/dist/assets/{share-feedback-modal-CuxFlSR6.js → share-feedback-modal-CFgHvfgR.js} +1 -1
  57. package/dist/assets/{sidebar-tree-BZUv9ggX.js → sidebar-tree-DALLHIeG.js} +1 -1
  58. package/dist/assets/{signup-page-BWnAp0Bw.js → signup-page-13TRI3CC.js} +1 -1
  59. package/dist/assets/{skills-page-BAodqgt1.js → skills-page-DiopOlcy.js} +1 -1
  60. package/dist/assets/{sounds-page-hDPPoEEQ.js → sounds-page-DE47aZrz.js} +1 -1
  61. package/dist/assets/{step-indicator-dots-CwbobrxS.js → step-indicator-dots-BOKv1I4C.js} +1 -1
  62. package/dist/assets/{subagent-detail-panel-Db9feY1I.js → subagent-detail-panel-BdPp2LMK.js} +1 -1
  63. package/dist/assets/{system-events-page-DYi0jI1g.js → system-events-page-DcaF2EuX.js} +1 -1
  64. package/dist/assets/{tiptap-document-editor-DD5B0bf0.js → tiptap-document-editor-DjIQ9tCC.js} +1 -1
  65. package/dist/assets/{tool-detail-panel-DZf8WIS6.js → tool-detail-panel-C6uFi3_6.js} +1 -1
  66. package/dist/assets/{trace-page-DSDi-YYp.js → trace-page-4MU66DDM.js} +1 -1
  67. package/dist/assets/{upgrade-cancel-page-DHzkb9An.js → upgrade-cancel-page-D2-xTACq.js} +1 -1
  68. package/dist/assets/{upgrade-success-page-CIooZvxn.js → upgrade-success-page-DLjl6978.js} +1 -1
  69. package/dist/assets/{usage-page-XWL-WFaq.js → usage-page-CCBqWkRU.js} +1 -1
  70. package/dist/assets/{voice-page-BwA-ETwe.js → voice-page-VrJ7AZrg.js} +1 -1
  71. package/dist/assets/{weather-forecast-display-tzc5l6oR.js → weather-forecast-display-DKMPxDv5.js} +1 -1
  72. package/dist/assets/{welcome-screen-BkL_1qYq.js → welcome-screen-DVeLGZKg.js} +1 -1
  73. package/dist/assets/{workflow-detail-panel-DYQvTG3m.js → workflow-detail-panel-BgDWu3_4.js} +1 -1
  74. package/dist/assets/{workspace-page-t_8JOOXv.js → workspace-page-BlVlfXIt.js} +1 -1
  75. package/dist/index.html +1 -1
  76. package/package.json +1 -1
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{a as t,m as n,o as r}from"./capture-error-B0wqOYKY.js";import{t as i}from"./react-DJZBPgpf.js";import{t as a}from"./button-D7s2Q_uG.js";import{d as o,h as s,r as c}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as l}from"./QueryClientProvider-DKhXIxGb.js";import{t as u}from"./useQuery-B45lW1Kk.js";import{t as d}from"./jsx-runtime-CVSDxk6A.js";import{t as f}from"./cn-DvW5mxZR.js";import{t as p}from"./dropdown-yOV5eJnU.js";import"./src-D6Nu2Lol.js";import{t as m}from"./confirm-dialog-DbNUkFt6.js";import{t as h}from"./tag-BadGF3FB.js";import{t as g}from"./toggle-_vZlLDBV.js";import{n as _}from"./toast-DLWkiWW6.js";import{S as ee,f as v}from"./local-mode-9ZkSq1Fr.js";import{t as y}from"./createLucideIcon-DIlBzeWM.js";import{t as b}from"./bug-BIPj7Nbx.js";import{t as x}from"./info-BJtskZc-.js";import{t as S}from"./loader-circle-CTs38Ovl.js";import{t as C}from"./triangle-alert-M_S_Pe8C.js";import{l as w}from"./auth-store-CrTf0uWL.js";import{t as te}from"./client.gen-Cuv6iN0E.js";import{c as ne,o as T}from"./api-BSHLYsxJ.js";import{a as E}from"./routes-BKwsRssF.js";import{t as D}from"./use-is-org-ready-BoWiaeMc.js";import{a as O,l as k,o as A}from"./feature-flag-catalog-DEr38CMM.js";import{t as j}from"./client-feature-flag-store-ivPVcKfH.js";import{t as M}from"./assistant-feature-flag-store-D2CUHsmL.js";import{t as N}from"./misc-Bo3spjOe.js";import{Dn as P,aa as re,fn as F,lo as I}from"./index-LP2PV_QY.js";import{t as L}from"./use-active-assistant-id-512RohBL.js";import{t as R}from"./detail-card-CLwQ17AA.js";import{t as z}from"./environment-store-Ck7wXCrL.js";var B=y(`flame`,[[`path`,{d:`M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4`,key:`1slcih`}]]),V=y(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),H=e(i(),1),U=d();function W(){let e=l(),[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(!1),o=D(),{data:s,isLoading:c}=u({...F(),enabled:o}),{data:d,isLoading:f}=u({...P({query:{hosting:`all`}}),enabled:o}),p=c||f,h=d?.results??[];return(0,U.jsxs)(`div`,{className:`space-y-6`,children:[(0,U.jsx)(G,{assistant:s??null,loading:p}),(0,U.jsx)(K,{assistants:h,activeAssistantId:s?.id??null,loading:p}),(0,U.jsxs)(R,{title:`Hatch New Assistant`,subtitle:`Create a new assistant instance.`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Provision a new assistant. This may take a moment.`}),(0,U.jsx)(a,{variant:`outlined`,leftIcon:t?(0,U.jsx)(S,{className:`animate-spin`}):void 0,onClick:()=>i(!0),disabled:t,className:`shrink-0`,children:`Hatch`})]}),(0,U.jsx)(m,{open:r,title:`Hatch New Assistant`,message:`Are you sure you want to create a new assistant? This will provision new infrastructure.`,confirmLabel:`Hatch`,onConfirm:async()=>{i(!1),n(!0);try{let t=await T(void 0,`create`);if(t.ok){if(v())try{let e=await ne();e.ok&&await ee(e.data,w.getState().currentOrganizationId??void 0)}catch{}_.success(t.status===201?`New assistant hatched successfully.`:`Returned your existing assistant — no new one was created.`),e.invalidateQueries({queryKey:F().queryKey}),e.invalidateQueries({queryKey:P({query:{hosting:`all`}}).queryKey})}else{let e=typeof t.error?.detail==`string`?t.error.detail:`Failed to hatch assistant.`;_.error(e)}}catch{_.error(`Failed to hatch assistant.`)}finally{n(!1)}},onCancel:()=>i(!1)})]})]})}function G({assistant:e,loading:t}){return t?(0,U.jsx)(R,{title:`Assistant Info`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,U.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading assistant info...`]})}):e?(0,U.jsx)(R,{title:`Assistant Info`,subtitle:`Current assistant details.`,children:(0,U.jsxs)(`div`,{className:`grid grid-cols-[140px_minmax(0,1fr)] gap-y-3`,children:[(0,U.jsx)(q,{children:`Name`}),(0,U.jsx)(J,{children:e.name??`Unnamed`}),(0,U.jsx)(q,{children:`Status`}),(0,U.jsx)(`div`,{children:(0,U.jsx)(h,{tone:e.status===`active`?`positive`:`neutral`,children:e.status})}),(0,U.jsx)(q,{children:`Assistant ID`}),(0,U.jsx)(`span`,{className:`break-all font-mono text-body-small-default text-[var(--content-tertiary)]`,children:e.id}),e.machine_id&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(q,{children:`Machine ID`}),(0,U.jsx)(`span`,{className:`break-all font-mono text-body-small-default text-[var(--content-tertiary)]`,children:e.machine_id})]}),(0,U.jsx)(q,{children:`Created`}),(0,U.jsx)(J,{children:new Date(e.created).toLocaleDateString()}),(0,U.jsx)(q,{children:`Last Modified`}),(0,U.jsx)(J,{children:new Date(e.modified).toLocaleDateString()}),e.current_release_version&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(q,{children:`Version`}),(0,U.jsx)(J,{children:e.current_release_version})]})]})}):(0,U.jsx)(R,{title:`Assistant Info`,children:(0,U.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No assistant found. Hatch an assistant to get started.`})})}function K({assistants:e,activeAssistantId:t,loading:n}){return n||e.length===0?null:(0,U.jsx)(R,{title:`All Assistants`,subtitle:`${e.length} assistant${e.length===1?``:`s`} found.`,children:(0,U.jsx)(`div`,{className:`max-h-[300px] space-y-2 overflow-y-auto`,children:e.map(e=>{let n=e.id===t;return(0,U.jsx)(`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,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e.name||`Unnamed`}),(0,U.jsx)(h,{tone:e.status===`active`?`positive`:`neutral`,children:e.status}),n&&(0,U.jsx)(h,{tone:`warning`,children:`Current`})]}),(0,U.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-tertiary)]`,children:e.id})]})},e.id)})})})}function q({children:e}){return(0,U.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e})}function J({children:e}){return(0,U.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:e})}function Y(){let e=z.use.emailRootDomain(),t=z.use.isNonProduction(),n=z.use.setEnvironment();return(0,U.jsx)(R,{title:`Environment`,subtitle:`Environment configuration overrides for this session.`,children:(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-start gap-3 py-3`,children:[(0,U.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:(0,U.jsx)(g,{checked:t,onChange:e=>n({isNonProduction:e}),"aria-label":`Non-Production is ${t?`on`:`off`}`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,U.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Non-Production`}),(0,U.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Indicates a non-production environment. Enables dev-only UI surfaces and diagnostics.`})]})]}),(0,U.jsxs)(`div`,{className:`flex items-start gap-3 py-3`,children:[(0,U.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:(0,U.jsx)(h,{tone:`neutral`,children:e})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,U.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Email Root Domain`}),(0,U.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Root domain used for assistant email addresses (e.g. vellum.me).`})]})]})]})})}async function ie(){let{data:e,response:t}=await te.get({url:`/v1/feature-flags/`,throwOnError:!1});return t?.ok?e?.flags??[]:[]}var X={client:`warning`,assistant:`positive`};function ae(){let e=L(),{data:t}=u({queryKey:[`feature-flag-definitions`],queryFn:ie,enabled:D(),staleTime:300*1e3}),n=(0,H.useMemo)(()=>{let e=new Map;if(!t)return e;for(let n of t)n.type===`string`&&n.values?.length&&e.set(n.key,n.values);return e},[t]),[r,i]=(0,H.useState)(``),a=j(),o=M(),s=(0,H.useMemo)(()=>{let e=[];for(let t of A){let r=O(t.key);if(typeof t.defaultEnabled==`boolean`){let n=a[r],i=o[r],s=t.scope===`both`?n===!0||i===!0:t.scope===`assistant`?i:n;if(typeof s!=`boolean`)continue;e.push({kind:`boolean`,storeKey:r,scope:t.scope,label:t.label,description:t.description,value:s,defaultValue:t.defaultEnabled})}else if(typeof t.defaultEnabled==`string`){let i=a.stringFlags?.[r],s=o.stringFlags?.[r],c=t.scope===`assistant`?s??t.defaultEnabled:i??t.defaultEnabled;e.push({kind:`string`,storeKey:r,scope:t.scope,label:t.label,description:t.description,value:c,defaultValue:t.defaultEnabled,values:n.get(t.key)??t.values})}}return e.sort((e,t)=>e.label.localeCompare(t.label,void 0,{sensitivity:`base`}))},[a,o,n]),c=(0,H.useMemo)(()=>{if(!r.trim())return s;let e=r.trim().toLowerCase();return s.filter(t=>t.label.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.storeKey.toLowerCase().includes(e)||t.scope.includes(e)||t.scope===`both`&&(`client`.includes(e)||`assistant`.includes(e)))},[s,r]);return(0,U.jsx)(R,{title:`Feature Flags`,subtitle:`Active feature flags evaluated for the current session.`,children:(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(re,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-[var(--content-tertiary)]`}),(0,U.jsx)(`input`,{type:`text`,placeholder:`Search flags...`,value:r,onChange:e=>i(e.target.value),className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-default)] py-2 pl-9 pr-3 text-body-medium-default text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] focus:border-[var(--border-focus)] focus:outline-none`})]}),c.length===0&&(0,U.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No matching flags.`}),c.length>0&&(0,U.jsx)(`div`,{className:`max-h-[500px] space-y-2 overflow-y-auto`,children:c.map(t=>(0,U.jsx)(ce,{flag:t,assistantId:e},t.storeKey))})]})})}function Z({scope:e}){return e===`both`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(h,{tone:X.client,children:`client`}),(0,U.jsx)(h,{tone:X.assistant,children:`assistant`})]}):(0,U.jsx)(h,{tone:X[e],children:e})}function oe({flag:e,assistantId:t}){let n=j.use.setFlag(),r=M.use.setFlag();return(0,U.jsxs)(`div`,{className:`flex items-start gap-3 py-3`,children:[(0,U.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:(0,U.jsx)(g,{checked:e.value,onChange:i=>{k(e.scope,`client`)&&n(e.storeKey,i),k(e.scope,`assistant`)&&r(e.storeKey,i,t)},"aria-label":`${e.label} is ${e.value?`on`:`off`}`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e.label}),(0,U.jsx)(Z,{scope:e.scope})]}),(0,U.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e.description}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Default:`}),(0,U.jsx)(h,{tone:`neutral`,children:e.defaultValue?`On`:`Off`})]})]})]})}function se({flag:e,assistantId:t}){let n=j.use.setStringFlag(),r=M.use.setStringFlag(),[i,a]=(0,H.useState)(e.value);(0,H.useEffect)(()=>{a(e.value)},[e.value]);let o=i=>{i!==e.value&&(k(e.scope,`client`)&&n(e.storeKey,i),k(e.scope,`assistant`)&&r(e.storeKey,i,t))},s=i!==e.value,c=e.values&&e.values.length>0?e.values:null,l=s&&c!=null&&!c.includes(i),u=()=>{l||o(i)},d=e=>{e.key===`Enter`&&e.currentTarget.blur()},m=c!=null&&c.includes(e.value);return(0,U.jsx)(`div`,{className:`flex items-start gap-3 py-3`,children:(0,U.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e.label}),(0,U.jsx)(Z,{scope:e.scope})]}),(0,U.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e.description}),m?(0,U.jsx)(p,{value:e.value,onChange:e=>{a(e),o(e)},options:c.map(e=>({value:e,label:e})),className:`w-48`,"aria-label":`${e.label} value`}):(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),onBlur:u,onKeyDown:d,className:f(`w-full rounded-lg border bg-[var(--surface-default)] px-3 py-1.5 text-body-small-default text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] focus:outline-none`,l?`border-[var(--system-negative-strong)]`:`border-[var(--border-base)] focus:border-[var(--border-focus)]`),placeholder:e.defaultValue||`Enter value...`}),l&&(0,U.jsxs)(`span`,{className:`block text-body-small-default text-[var(--system-negative-strong)]`,children:[`Expected one of: `,c.join(`, `)]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Default:`}),(0,U.jsx)(h,{tone:`neutral`,children:e.defaultValue||`(empty)`})]})]})})}function ce({flag:e,assistantId:t}){return e.kind===`string`?(0,U.jsx)(se,{flag:e,assistantId:t}):(0,U.jsx)(oe,{flag:e,assistantId:t})}function le(){let e=(0,H.useCallback)(()=>{t(Error(`[Dev Settings] Test error event`)),_.success(`Sentry error event sent.`)},[]),i=(0,H.useCallback)(()=>{r(`[Dev Settings] Test warning event`,`warning`),_.success(`Sentry warning event sent.`)},[]),a=(0,H.useCallback)(()=>{r(`[Dev Settings] Test info event`,`info`),_.success(`Sentry info event sent.`)},[]),o=(0,H.useCallback)(()=>{r(`[Dev Settings] Test fatal event`,`fatal`),_.success(`Sentry fatal event sent.`)},[]),s=(0,H.useCallback)(()=>{n({name:`[Dev Settings] Test transaction`,op:`test.transaction`,forceTransaction:!0}).end(),_.success(`Sentry performance transaction sent.`)},[]);return(0,U.jsx)(R,{title:`Sentry Testing`,subtitle:`Fire test events to verify Sentry integration is working.`,children:(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsx)(Q,{icon:(0,U.jsx)(B,{className:`h-4 w-4 text-[var(--system-negative-strong)]`}),label:`Fatal Event`,description:`Send a fatal-level event to Sentry.`,onClick:o}),(0,U.jsx)(Q,{icon:(0,U.jsx)(I,{className:`h-4 w-4 text-[var(--system-negative-default)]`}),label:`Error Event`,description:`Capture a test Error exception.`,onClick:e}),(0,U.jsx)(Q,{icon:(0,U.jsx)(C,{className:`h-4 w-4 text-[var(--system-warning-default)]`}),label:`Warning Event`,description:`Send a warning-level message.`,onClick:i}),(0,U.jsx)(Q,{icon:(0,U.jsx)(x,{className:`h-4 w-4 text-[var(--content-tertiary)]`}),label:`Info Event`,description:`Send an info-level message.`,onClick:a}),(0,U.jsx)(Q,{icon:(0,U.jsx)(V,{className:`h-4 w-4 text-[var(--system-positive-default)]`}),label:`Performance Transaction`,description:`Start and end a test transaction span.`,onClick:s})]})})}function Q({icon:e,label:t,description:n,onClick:r}){return(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-lg border border-[var(--border-base)] px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`shrink-0`,children:e}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:t}),(0,U.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:n})]})]}),(0,U.jsxs)(a,{variant:`outlined`,size:`compact`,onClick:r,children:[(0,U.jsx)(b,{className:`h-4 w-4`}),`Send`]})]})}var $=[{id:`feature-flags`,label:`Feature Flags`},{id:`lifecycle`,label:`Assistant Lifecycle`},{id:`sentry`,label:`Sentry Testing`}];function ue(){let e=o(),[t,n]=s(),r=M.use.settingsDeveloperNav(),i=M.use.hasHydrated(),l=(0,H.useMemo)(()=>{let e=t.get(`tab`);return $.find(t=>t.id===e)?.id??`feature-flags`},[t]);if(i&&!r)return(0,U.jsx)(c,{replace:!0,to:E.settings.general});let u=e=>{let r=new URLSearchParams(t.toString());e===`feature-flags`?r.delete(`tab`):r.set(`tab`,e),n(r,{replace:!0})};return(0,U.jsxs)(`div`,{"data-slot":`developer-page`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-4 border-b border-[var(--border-base)]`,children:[(0,U.jsx)(`div`,{role:`tablist`,"aria-label":`Developer sections`,className:`flex items-center gap-1`,children:$.map(e=>{let t=e.id===l;return(0,U.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,"aria-controls":`developer-tab-panel-${e.id}`,id:`developer-tab-${e.id}`,onClick:()=>u(e.id),className:N(`relative -mb-px cursor-pointer border-b-2 px-4 py-2 text-body-medium-default transition-colors`,t?`border-[var(--system-positive-strong)] text-[var(--system-positive-strong)]`:`border-transparent text-[var(--content-tertiary)] hover:text-[var(--content-default)] dark:text-[var(--content-disabled)] dark:hover:text-[var(--content-default)]`),children:e.label},e.id)})}),v()&&(0,U.jsx)(a,{variant:`outlined`,className:`mb-1 shrink-0`,onClick:()=>void e(`${E.selectAssistant}?fromSettings=1`),children:`Choose Assistant`})]}),(0,U.jsxs)(`div`,{id:`developer-tab-panel-${l}`,role:`tabpanel`,"aria-labelledby":`developer-tab-${l}`,className:`flex min-h-0 flex-1 flex-col pt-6`,children:[l===`feature-flags`&&(0,U.jsxs)(`div`,{className:`space-y-6`,children:[(0,U.jsx)(ae,{}),(0,U.jsx)(Y,{})]}),l===`lifecycle`&&(0,U.jsx)(W,{}),l===`sentry`&&(0,U.jsx)(le,{})]})]})}export{ue as DeveloperPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{a as t,m as n,o as r}from"./capture-error-B0wqOYKY.js";import{t as i}from"./react-DJZBPgpf.js";import{t as a}from"./button-D7s2Q_uG.js";import{d as o,h as s,r as c}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as l}from"./QueryClientProvider-DKhXIxGb.js";import{t as u}from"./useQuery-B45lW1Kk.js";import{t as d}from"./jsx-runtime-CVSDxk6A.js";import{t as f}from"./cn-DvW5mxZR.js";import{t as p}from"./dropdown-yOV5eJnU.js";import"./src-D6Nu2Lol.js";import{t as m}from"./confirm-dialog-DbNUkFt6.js";import{t as h}from"./tag-BadGF3FB.js";import{t as g}from"./toggle-_vZlLDBV.js";import{n as _}from"./toast-DLWkiWW6.js";import{S as ee,f as v}from"./local-mode-9ZkSq1Fr.js";import{t as y}from"./createLucideIcon-DIlBzeWM.js";import{t as b}from"./bug-BIPj7Nbx.js";import{t as x}from"./info-BJtskZc-.js";import{t as S}from"./loader-circle-CTs38Ovl.js";import{t as C}from"./triangle-alert-M_S_Pe8C.js";import{l as w}from"./auth-store-CrTf0uWL.js";import{t as te}from"./client.gen-Cuv6iN0E.js";import{c as ne,o as T}from"./api-BSHLYsxJ.js";import{a as E}from"./routes-BKwsRssF.js";import{t as D}from"./use-is-org-ready-BoWiaeMc.js";import{a as O,l as k,o as A}from"./feature-flag-catalog-DEr38CMM.js";import{t as j}from"./client-feature-flag-store-ivPVcKfH.js";import{t as M}from"./assistant-feature-flag-store-D2CUHsmL.js";import{t as N}from"./misc-Bo3spjOe.js";import{Dn as P,aa as re,fn as F,lo as I}from"./index-BiN-6kWM.js";import{t as L}from"./use-active-assistant-id-512RohBL.js";import{t as R}from"./detail-card-CLwQ17AA.js";import{t as z}from"./environment-store-Ck7wXCrL.js";var B=y(`flame`,[[`path`,{d:`M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4`,key:`1slcih`}]]),V=y(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),H=e(i(),1),U=d();function W(){let e=l(),[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(!1),o=D(),{data:s,isLoading:c}=u({...F(),enabled:o}),{data:d,isLoading:f}=u({...P({query:{hosting:`all`}}),enabled:o}),p=c||f,h=d?.results??[];return(0,U.jsxs)(`div`,{className:`space-y-6`,children:[(0,U.jsx)(G,{assistant:s??null,loading:p}),(0,U.jsx)(K,{assistants:h,activeAssistantId:s?.id??null,loading:p}),(0,U.jsxs)(R,{title:`Hatch New Assistant`,subtitle:`Create a new assistant instance.`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Provision a new assistant. This may take a moment.`}),(0,U.jsx)(a,{variant:`outlined`,leftIcon:t?(0,U.jsx)(S,{className:`animate-spin`}):void 0,onClick:()=>i(!0),disabled:t,className:`shrink-0`,children:`Hatch`})]}),(0,U.jsx)(m,{open:r,title:`Hatch New Assistant`,message:`Are you sure you want to create a new assistant? This will provision new infrastructure.`,confirmLabel:`Hatch`,onConfirm:async()=>{i(!1),n(!0);try{let t=await T(void 0,`create`);if(t.ok){if(v())try{let e=await ne();e.ok&&await ee(e.data,w.getState().currentOrganizationId??void 0)}catch{}_.success(t.status===201?`New assistant hatched successfully.`:`Returned your existing assistant — no new one was created.`),e.invalidateQueries({queryKey:F().queryKey}),e.invalidateQueries({queryKey:P({query:{hosting:`all`}}).queryKey})}else{let e=typeof t.error?.detail==`string`?t.error.detail:`Failed to hatch assistant.`;_.error(e)}}catch{_.error(`Failed to hatch assistant.`)}finally{n(!1)}},onCancel:()=>i(!1)})]})]})}function G({assistant:e,loading:t}){return t?(0,U.jsx)(R,{title:`Assistant Info`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,U.jsx)(S,{className:`h-4 w-4 animate-spin`}),`Loading assistant info...`]})}):e?(0,U.jsx)(R,{title:`Assistant Info`,subtitle:`Current assistant details.`,children:(0,U.jsxs)(`div`,{className:`grid grid-cols-[140px_minmax(0,1fr)] gap-y-3`,children:[(0,U.jsx)(q,{children:`Name`}),(0,U.jsx)(J,{children:e.name??`Unnamed`}),(0,U.jsx)(q,{children:`Status`}),(0,U.jsx)(`div`,{children:(0,U.jsx)(h,{tone:e.status===`active`?`positive`:`neutral`,children:e.status})}),(0,U.jsx)(q,{children:`Assistant ID`}),(0,U.jsx)(`span`,{className:`break-all font-mono text-body-small-default text-[var(--content-tertiary)]`,children:e.id}),e.machine_id&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(q,{children:`Machine ID`}),(0,U.jsx)(`span`,{className:`break-all font-mono text-body-small-default text-[var(--content-tertiary)]`,children:e.machine_id})]}),(0,U.jsx)(q,{children:`Created`}),(0,U.jsx)(J,{children:new Date(e.created).toLocaleDateString()}),(0,U.jsx)(q,{children:`Last Modified`}),(0,U.jsx)(J,{children:new Date(e.modified).toLocaleDateString()}),e.current_release_version&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(q,{children:`Version`}),(0,U.jsx)(J,{children:e.current_release_version})]})]})}):(0,U.jsx)(R,{title:`Assistant Info`,children:(0,U.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No assistant found. Hatch an assistant to get started.`})})}function K({assistants:e,activeAssistantId:t,loading:n}){return n||e.length===0?null:(0,U.jsx)(R,{title:`All Assistants`,subtitle:`${e.length} assistant${e.length===1?``:`s`} found.`,children:(0,U.jsx)(`div`,{className:`max-h-[300px] space-y-2 overflow-y-auto`,children:e.map(e=>{let n=e.id===t;return(0,U.jsx)(`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,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e.name||`Unnamed`}),(0,U.jsx)(h,{tone:e.status===`active`?`positive`:`neutral`,children:e.status}),n&&(0,U.jsx)(h,{tone:`warning`,children:`Current`})]}),(0,U.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-tertiary)]`,children:e.id})]})},e.id)})})})}function q({children:e}){return(0,U.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:e})}function J({children:e}){return(0,U.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:e})}function Y(){let e=z.use.emailRootDomain(),t=z.use.isNonProduction(),n=z.use.setEnvironment();return(0,U.jsx)(R,{title:`Environment`,subtitle:`Environment configuration overrides for this session.`,children:(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-start gap-3 py-3`,children:[(0,U.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:(0,U.jsx)(g,{checked:t,onChange:e=>n({isNonProduction:e}),"aria-label":`Non-Production is ${t?`on`:`off`}`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,U.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Non-Production`}),(0,U.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Indicates a non-production environment. Enables dev-only UI surfaces and diagnostics.`})]})]}),(0,U.jsxs)(`div`,{className:`flex items-start gap-3 py-3`,children:[(0,U.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:(0,U.jsx)(h,{tone:`neutral`,children:e})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,U.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Email Root Domain`}),(0,U.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Root domain used for assistant email addresses (e.g. vellum.me).`})]})]})]})})}async function ie(){let{data:e,response:t}=await te.get({url:`/v1/feature-flags/`,throwOnError:!1});return t?.ok?e?.flags??[]:[]}var X={client:`warning`,assistant:`positive`};function ae(){let e=L(),{data:t}=u({queryKey:[`feature-flag-definitions`],queryFn:ie,enabled:D(),staleTime:300*1e3}),n=(0,H.useMemo)(()=>{let e=new Map;if(!t)return e;for(let n of t)n.type===`string`&&n.values?.length&&e.set(n.key,n.values);return e},[t]),[r,i]=(0,H.useState)(``),a=j(),o=M(),s=(0,H.useMemo)(()=>{let e=[];for(let t of A){let r=O(t.key);if(typeof t.defaultEnabled==`boolean`){let n=a[r],i=o[r],s=t.scope===`both`?n===!0||i===!0:t.scope===`assistant`?i:n;if(typeof s!=`boolean`)continue;e.push({kind:`boolean`,storeKey:r,scope:t.scope,label:t.label,description:t.description,value:s,defaultValue:t.defaultEnabled})}else if(typeof t.defaultEnabled==`string`){let i=a.stringFlags?.[r],s=o.stringFlags?.[r],c=t.scope===`assistant`?s??t.defaultEnabled:i??t.defaultEnabled;e.push({kind:`string`,storeKey:r,scope:t.scope,label:t.label,description:t.description,value:c,defaultValue:t.defaultEnabled,values:n.get(t.key)??t.values})}}return e.sort((e,t)=>e.label.localeCompare(t.label,void 0,{sensitivity:`base`}))},[a,o,n]),c=(0,H.useMemo)(()=>{if(!r.trim())return s;let e=r.trim().toLowerCase();return s.filter(t=>t.label.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.storeKey.toLowerCase().includes(e)||t.scope.includes(e)||t.scope===`both`&&(`client`.includes(e)||`assistant`.includes(e)))},[s,r]);return(0,U.jsx)(R,{title:`Feature Flags`,subtitle:`Active feature flags evaluated for the current session.`,children:(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(re,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-[var(--content-tertiary)]`}),(0,U.jsx)(`input`,{type:`text`,placeholder:`Search flags...`,value:r,onChange:e=>i(e.target.value),className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-default)] py-2 pl-9 pr-3 text-body-medium-default text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] focus:border-[var(--border-focus)] focus:outline-none`})]}),c.length===0&&(0,U.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No matching flags.`}),c.length>0&&(0,U.jsx)(`div`,{className:`max-h-[500px] space-y-2 overflow-y-auto`,children:c.map(t=>(0,U.jsx)(ce,{flag:t,assistantId:e},t.storeKey))})]})})}function Z({scope:e}){return e===`both`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(h,{tone:X.client,children:`client`}),(0,U.jsx)(h,{tone:X.assistant,children:`assistant`})]}):(0,U.jsx)(h,{tone:X[e],children:e})}function oe({flag:e,assistantId:t}){let n=j.use.setFlag(),r=M.use.setFlag();return(0,U.jsxs)(`div`,{className:`flex items-start gap-3 py-3`,children:[(0,U.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:(0,U.jsx)(g,{checked:e.value,onChange:i=>{k(e.scope,`client`)&&n(e.storeKey,i),k(e.scope,`assistant`)&&r(e.storeKey,i,t)},"aria-label":`${e.label} is ${e.value?`on`:`off`}`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e.label}),(0,U.jsx)(Z,{scope:e.scope})]}),(0,U.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e.description}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Default:`}),(0,U.jsx)(h,{tone:`neutral`,children:e.defaultValue?`On`:`Off`})]})]})]})}function se({flag:e,assistantId:t}){let n=j.use.setStringFlag(),r=M.use.setStringFlag(),[i,a]=(0,H.useState)(e.value);(0,H.useEffect)(()=>{a(e.value)},[e.value]);let o=i=>{i!==e.value&&(k(e.scope,`client`)&&n(e.storeKey,i),k(e.scope,`assistant`)&&r(e.storeKey,i,t))},s=i!==e.value,c=e.values&&e.values.length>0?e.values:null,l=s&&c!=null&&!c.includes(i),u=()=>{l||o(i)},d=e=>{e.key===`Enter`&&e.currentTarget.blur()},m=c!=null&&c.includes(e.value);return(0,U.jsx)(`div`,{className:`flex items-start gap-3 py-3`,children:(0,U.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e.label}),(0,U.jsx)(Z,{scope:e.scope})]}),(0,U.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e.description}),m?(0,U.jsx)(p,{value:e.value,onChange:e=>{a(e),o(e)},options:c.map(e=>({value:e,label:e})),className:`w-48`,"aria-label":`${e.label} value`}):(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),onBlur:u,onKeyDown:d,className:f(`w-full rounded-lg border bg-[var(--surface-default)] px-3 py-1.5 text-body-small-default text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] focus:outline-none`,l?`border-[var(--system-negative-strong)]`:`border-[var(--border-base)] focus:border-[var(--border-focus)]`),placeholder:e.defaultValue||`Enter value...`}),l&&(0,U.jsxs)(`span`,{className:`block text-body-small-default text-[var(--system-negative-strong)]`,children:[`Expected one of: `,c.join(`, `)]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Default:`}),(0,U.jsx)(h,{tone:`neutral`,children:e.defaultValue||`(empty)`})]})]})})}function ce({flag:e,assistantId:t}){return e.kind===`string`?(0,U.jsx)(se,{flag:e,assistantId:t}):(0,U.jsx)(oe,{flag:e,assistantId:t})}function le(){let e=(0,H.useCallback)(()=>{t(Error(`[Dev Settings] Test error event`)),_.success(`Sentry error event sent.`)},[]),i=(0,H.useCallback)(()=>{r(`[Dev Settings] Test warning event`,`warning`),_.success(`Sentry warning event sent.`)},[]),a=(0,H.useCallback)(()=>{r(`[Dev Settings] Test info event`,`info`),_.success(`Sentry info event sent.`)},[]),o=(0,H.useCallback)(()=>{r(`[Dev Settings] Test fatal event`,`fatal`),_.success(`Sentry fatal event sent.`)},[]),s=(0,H.useCallback)(()=>{n({name:`[Dev Settings] Test transaction`,op:`test.transaction`,forceTransaction:!0}).end(),_.success(`Sentry performance transaction sent.`)},[]);return(0,U.jsx)(R,{title:`Sentry Testing`,subtitle:`Fire test events to verify Sentry integration is working.`,children:(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsx)(Q,{icon:(0,U.jsx)(B,{className:`h-4 w-4 text-[var(--system-negative-strong)]`}),label:`Fatal Event`,description:`Send a fatal-level event to Sentry.`,onClick:o}),(0,U.jsx)(Q,{icon:(0,U.jsx)(I,{className:`h-4 w-4 text-[var(--system-negative-default)]`}),label:`Error Event`,description:`Capture a test Error exception.`,onClick:e}),(0,U.jsx)(Q,{icon:(0,U.jsx)(C,{className:`h-4 w-4 text-[var(--system-warning-default)]`}),label:`Warning Event`,description:`Send a warning-level message.`,onClick:i}),(0,U.jsx)(Q,{icon:(0,U.jsx)(x,{className:`h-4 w-4 text-[var(--content-tertiary)]`}),label:`Info Event`,description:`Send an info-level message.`,onClick:a}),(0,U.jsx)(Q,{icon:(0,U.jsx)(V,{className:`h-4 w-4 text-[var(--system-positive-default)]`}),label:`Performance Transaction`,description:`Start and end a test transaction span.`,onClick:s})]})})}function Q({icon:e,label:t,description:n,onClick:r}){return(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-lg border border-[var(--border-base)] px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`shrink-0`,children:e}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:t}),(0,U.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:n})]})]}),(0,U.jsxs)(a,{variant:`outlined`,size:`compact`,onClick:r,children:[(0,U.jsx)(b,{className:`h-4 w-4`}),`Send`]})]})}var $=[{id:`feature-flags`,label:`Feature Flags`},{id:`lifecycle`,label:`Assistant Lifecycle`},{id:`sentry`,label:`Sentry Testing`}];function ue(){let e=o(),[t,n]=s(),r=M.use.settingsDeveloperNav(),i=M.use.hasHydrated(),l=(0,H.useMemo)(()=>{let e=t.get(`tab`);return $.find(t=>t.id===e)?.id??`feature-flags`},[t]);if(i&&!r)return(0,U.jsx)(c,{replace:!0,to:E.settings.general});let u=e=>{let r=new URLSearchParams(t.toString());e===`feature-flags`?r.delete(`tab`):r.set(`tab`,e),n(r,{replace:!0})};return(0,U.jsxs)(`div`,{"data-slot":`developer-page`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-4 border-b border-[var(--border-base)]`,children:[(0,U.jsx)(`div`,{role:`tablist`,"aria-label":`Developer sections`,className:`flex items-center gap-1`,children:$.map(e=>{let t=e.id===l;return(0,U.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,"aria-controls":`developer-tab-panel-${e.id}`,id:`developer-tab-${e.id}`,onClick:()=>u(e.id),className:N(`relative -mb-px cursor-pointer border-b-2 px-4 py-2 text-body-medium-default transition-colors`,t?`border-[var(--system-positive-strong)] text-[var(--system-positive-strong)]`:`border-transparent text-[var(--content-tertiary)] hover:text-[var(--content-default)] dark:text-[var(--content-disabled)] dark:hover:text-[var(--content-default)]`),children:e.label},e.id)})}),v()&&(0,U.jsx)(a,{variant:`outlined`,className:`mb-1 shrink-0`,onClick:()=>void e(`${E.selectAssistant}?fromSettings=1`),children:`Choose Assistant`})]}),(0,U.jsxs)(`div`,{id:`developer-tab-panel-${l}`,role:`tabpanel`,"aria-labelledby":`developer-tab-${l}`,className:`flex min-h-0 flex-1 flex-col pt-6`,children:[l===`feature-flags`&&(0,U.jsxs)(`div`,{className:`space-y-6`,children:[(0,U.jsx)(ae,{}),(0,U.jsx)(Y,{})]}),l===`lifecycle`&&(0,U.jsx)(W,{}),l===`sentry`&&(0,U.jsx)(le,{})]})]})}export{ue as DeveloperPage};
@@ -1 +1 @@
1
- import{r as e}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t}from"./useQuery-B45lW1Kk.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./notice-G5Imd5pC.js";import{t as i}from"./loader-circle-CTs38Ovl.js";import{a}from"./routes-BKwsRssF.js";import{Dn as o,Ft as s,It as c,Pt as l,Qi as u,Sa as d,v as f}from"./index-LP2PV_QY.js";import{t as p}from"./detail-card-CLwQ17AA.js";var m=n();function h(e){return new Intl.DateTimeFormat(`en`,{month:`short`,day:`numeric`,year:`numeric`}).format(new Date(e))}function g({assistant:e}){let t=e,n=t.platform===`ios`,r=n?u:d,i=e.name||(n?`iOS Device`:t.hostname||`Unknown Device`);return(0,m.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-[var(--border-base)] px-4 py-3`,children:[(0,m.jsx)(r,{className:`h-5 w-5 shrink-0 text-[var(--content-secondary)]`}),(0,m.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,m.jsx)(`div`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:i}),(0,m.jsxs)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[t.hostname&&(0,m.jsx)(`span`,{className:`mr-3`,children:t.hostname}),e.created&&(0,m.jsxs)(`span`,{children:[`Registered `,h(e.created)]})]})]})]})}function _(){let n=c({platformHostedOnly:!0}),u=l(),d=s(),{data:h,isLoading:_}=t({...o({query:{hosting:`local`}}),enabled:n===`full`&&u}),v=h?.results??[];return n===`gated`?(0,m.jsx)(e,{replace:!0,to:a.settings.general}):n===`disabled`?(0,m.jsx)(`div`,{className:`space-y-4`,children:(0,m.jsx)(f,{children:`Log in to the Vellum platform to manage self-hosted assistants.`})}):d?(0,m.jsx)(`div`,{className:`space-y-4`,children:(0,m.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,m.jsx)(i,{className:`h-4 w-4 animate-spin`}),`Loading devices…`]})}):u?(0,m.jsx)(`div`,{className:`space-y-4`,children:(0,m.jsx)(p,{title:`Self-Hosted Assistants`,subtitle:`Self-hosted assistants registered with your Vellum account. Registration lets these assistants use Vellum managed services — inference, web search, integrations — so that you don't have to bring your own API keys.`,children:_?(0,m.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,m.jsx)(i,{className:`h-4 w-4 animate-spin`}),`Loading devices...`]}):v.length===0?(0,m.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No self-hosted assistants registered.`}):(0,m.jsx)(`div`,{className:`space-y-2`,children:v.map(e=>(0,m.jsx)(g,{assistant:e},e.id))})})}):(0,m.jsx)(`div`,{className:`space-y-4`,children:(0,m.jsx)(r,{tone:`warning`,children:`Self-hosted assistant management isn't available for the current assistant state.`})})}export{_ as DevicesPage};
1
+ import{r as e}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t}from"./useQuery-B45lW1Kk.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./notice-G5Imd5pC.js";import{t as i}from"./loader-circle-CTs38Ovl.js";import{a}from"./routes-BKwsRssF.js";import{Dn as o,Ft as s,It as c,Pt as l,Qi as u,Sa as d,v as f}from"./index-BiN-6kWM.js";import{t as p}from"./detail-card-CLwQ17AA.js";var m=n();function h(e){return new Intl.DateTimeFormat(`en`,{month:`short`,day:`numeric`,year:`numeric`}).format(new Date(e))}function g({assistant:e}){let t=e,n=t.platform===`ios`,r=n?u:d,i=e.name||(n?`iOS Device`:t.hostname||`Unknown Device`);return(0,m.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-[var(--border-base)] px-4 py-3`,children:[(0,m.jsx)(r,{className:`h-5 w-5 shrink-0 text-[var(--content-secondary)]`}),(0,m.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,m.jsx)(`div`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:i}),(0,m.jsxs)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[t.hostname&&(0,m.jsx)(`span`,{className:`mr-3`,children:t.hostname}),e.created&&(0,m.jsxs)(`span`,{children:[`Registered `,h(e.created)]})]})]})]})}function _(){let n=c({platformHostedOnly:!0}),u=l(),d=s(),{data:h,isLoading:_}=t({...o({query:{hosting:`local`}}),enabled:n===`full`&&u}),v=h?.results??[];return n===`gated`?(0,m.jsx)(e,{replace:!0,to:a.settings.general}):n===`disabled`?(0,m.jsx)(`div`,{className:`space-y-4`,children:(0,m.jsx)(f,{children:`Log in to the Vellum platform to manage self-hosted assistants.`})}):d?(0,m.jsx)(`div`,{className:`space-y-4`,children:(0,m.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,m.jsx)(i,{className:`h-4 w-4 animate-spin`}),`Loading devices…`]})}):u?(0,m.jsx)(`div`,{className:`space-y-4`,children:(0,m.jsx)(p,{title:`Self-Hosted Assistants`,subtitle:`Self-hosted assistants registered with your Vellum account. Registration lets these assistants use Vellum managed services — inference, web search, integrations — so that you don't have to bring your own API keys.`,children:_?(0,m.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,m.jsx)(i,{className:`h-4 w-4 animate-spin`}),`Loading devices...`]}):v.length===0?(0,m.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No self-hosted assistants registered.`}):(0,m.jsx)(`div`,{className:`space-y-2`,children:v.map(e=>(0,m.jsx)(g,{assistant:e},e.id))})})}):(0,m.jsx)(`div`,{className:`space-y-4`,children:(0,m.jsx)(r,{tone:`warning`,children:`Self-hosted assistant management isn't available for the current assistant state.`})})}export{_ as DevicesPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./loader-circle-CTs38Ovl.js";import{t as i}from"./triangle-alert-M_S_Pe8C.js";import{$t as a,Qt as o,ho as s}from"./index-LP2PV_QY.js";var c=e(t(),1),l=n();function u(){let[e,t]=(0,c.useState)(null);if((0,c.useEffect)(()=>{let e=a(t);return o().then(e=>{e&&t(t=>t??e)}),e},[]),!e)return null;let n=e.kind===`recording`?e.transcription.trim():``,r=e.kind===`recording`?e.audioLevel??0:0;return(0,l.jsx)(`div`,{className:`flex h-screen w-screen items-start justify-center bg-transparent p-4`,children:(0,l.jsxs)(`div`,{className:`flex w-[min(28rem,calc(100vw-2rem))] flex-col gap-1 rounded-xl border border-[var(--border-default)] bg-[var(--surface-base)] px-4 py-2.5 shadow-lg`,children:[(0,l.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,l.jsx)(p,{state:e}),(0,l.jsx)(`span`,{className:`truncate text-[11px] font-medium text-[var(--content-secondary)]`,children:f(e)}),e.kind===`recording`&&(0,l.jsx)(d,{level:r})]}),n&&(0,l.jsx)(`div`,{className:`flex max-h-7 flex-col justify-end overflow-hidden`,children:(0,l.jsx)(`p`,{className:`break-words text-[10px] leading-snug text-[var(--content-tertiary)]`,children:n})})]})})}function d({level:e}){let t=Math.max(0,Math.min(1,e));return(0,l.jsx)(`div`,{className:`ml-auto flex h-4 w-16 shrink-0 items-end gap-0.5`,"aria-hidden":!0,children:[.16,.32,.48,.64,.8,.96].map((e,n)=>(0,l.jsx)(`span`,{className:`w-1 rounded-full bg-[var(--system-negative-strong)] transition-[height,opacity] duration-75`,style:{height:`${6+n*1.5}px`,opacity:t>=e?1:.22}},e))})}function f(e){switch(e.kind){case`recording`:return`Recording…`;case`processing`:return`Processing…`;case`done`:return`Done`;case`error`:return e.message}}function p({state:e}){switch(e.kind){case`recording`:return(0,l.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-[var(--system-negative-strong)]`,"aria-hidden":!0});case`processing`:return(0,l.jsx)(r,{className:`size-4 shrink-0 animate-spin text-[var(--content-secondary)]`,"aria-hidden":!0});case`done`:return(0,l.jsx)(s,{className:`size-4 shrink-0 text-[var(--system-positive-strong)]`,"aria-hidden":!0});case`error`:return(0,l.jsx)(i,{className:`size-4 shrink-0 text-[var(--system-negative-strong)]`,"aria-hidden":!0})}}export{u as DictationOverlayPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./loader-circle-CTs38Ovl.js";import{t as i}from"./triangle-alert-M_S_Pe8C.js";import{$t as a,Qt as o,ho as s}from"./index-BiN-6kWM.js";var c=e(t(),1),l=n();function u(){let[e,t]=(0,c.useState)(null);if((0,c.useEffect)(()=>{let e=a(t);return o().then(e=>{e&&t(t=>t??e)}),e},[]),!e)return null;let n=e.kind===`recording`?e.transcription.trim():``,r=e.kind===`recording`?e.audioLevel??0:0;return(0,l.jsx)(`div`,{className:`flex h-screen w-screen items-start justify-center bg-transparent p-4`,children:(0,l.jsxs)(`div`,{className:`flex w-[min(28rem,calc(100vw-2rem))] flex-col gap-1 rounded-xl border border-[var(--border-default)] bg-[var(--surface-base)] px-4 py-2.5 shadow-lg`,children:[(0,l.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,l.jsx)(p,{state:e}),(0,l.jsx)(`span`,{className:`truncate text-[11px] font-medium text-[var(--content-secondary)]`,children:f(e)}),e.kind===`recording`&&(0,l.jsx)(d,{level:r})]}),n&&(0,l.jsx)(`div`,{className:`flex max-h-7 flex-col justify-end overflow-hidden`,children:(0,l.jsx)(`p`,{className:`break-words text-[10px] leading-snug text-[var(--content-tertiary)]`,children:n})})]})})}function d({level:e}){let t=Math.max(0,Math.min(1,e));return(0,l.jsx)(`div`,{className:`ml-auto flex h-4 w-16 shrink-0 items-end gap-0.5`,"aria-hidden":!0,children:[.16,.32,.48,.64,.8,.96].map((e,n)=>(0,l.jsx)(`span`,{className:`w-1 rounded-full bg-[var(--system-negative-strong)] transition-[height,opacity] duration-75`,style:{height:`${6+n*1.5}px`,opacity:t>=e?1:.22}},e))})}function f(e){switch(e.kind){case`recording`:return`Recording…`;case`processing`:return`Processing…`;case`done`:return`Done`;case`error`:return e.message}}function p({state:e}){switch(e.kind){case`recording`:return(0,l.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-[var(--system-negative-strong)]`,"aria-hidden":!0});case`processing`:return(0,l.jsx)(r,{className:`size-4 shrink-0 animate-spin text-[var(--content-secondary)]`,"aria-hidden":!0});case`done`:return(0,l.jsx)(s,{className:`size-4 shrink-0 text-[var(--system-positive-strong)]`,"aria-hidden":!0});case`error`:return(0,l.jsx)(i,{className:`size-4 shrink-0 text-[var(--system-negative-strong)]`,"aria-hidden":!0})}}export{u as DictationOverlayPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{d as n,p as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-BscuIPxA.js";import"./src-D6Nu2Lol.js";import{n as o}from"./resolved-assistants-store-DMuRxkZC.js";import{t as s}from"./loader-circle-CTs38Ovl.js";import{dt as c,ft as l,ut as u}from"./sdk.gen-Bew9wO5C.js";import{a as d}from"./routes-BKwsRssF.js";import{t as f}from"./use-bus-subscription-RUbeQDfy.js";import{n as p}from"./viewer-store-CInCucV8.js";import{r as m,t as h}from"./edit-chat-session-B1tanC3Z.js";import{Y as g}from"./index-LP2PV_QY.js";var _=e(t(),1);function v({surfaceId:e,enabled:t,onCommentsChanged:n}){let r=(0,_.useRef)(n);return(0,_.useLayoutEffect)(()=>{r.current=n},[n]),(0,_.useCallback)(n=>{if(!t)return;let i=n.message;switch(i.type){case`document_comment_created`:case`document_comment_resolved`:case`document_comment_reopened`:case`document_comment_deleted`:i.surfaceId===e&&r.current();break;default:break}},[e,t])}var y=i();function b(){let{surfaceId:e}=r(),t=n(),i=o.use.activeAssistantId(),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!0),[w,T]=(0,_.useState)(null),E=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(!e){T(`No document ID provided.`),C(!1);return}if(!i)return;let t=!1;return(async()=>{try{let{data:n}=await c({path:{assistant_id:i,id:e},throwOnError:!0});if(t)return;x(n)}catch{t||T(`Failed to load document.`)}finally{t||C(!1)}})(),()=>{t=!0}},[e,i]);let D=(0,_.useCallback)(()=>{E.current?.refreshComments()},[]);f(`sse.event`,v({surfaceId:e??``,enabled:!!e,onCommentsChanged:D}));let O=(0,_.useCallback)(()=>{t(-1)},[t]),k=(0,_.useCallback)(async()=>{if(!b||!i||!e)return;let n=b.conversationId||h(i,e)||(typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`);if(m(i,e,n),n!==b.conversationId)try{await u({path:{assistant_id:i,id:e},body:{conversationId:n},throwOnError:!0})}catch{}p.getState().openDocument(),p.getState().setLoadedDocument({surfaceId:b.surfaceId,conversationId:n,documentName:b.title,content:b.content});let r=`Please review and address my comments on "${b.title}".`;t(`${d.conversation(n)}?prompt=${encodeURIComponent(r)}`)},[b,i,e,t]),A=(0,_.useCallback)(async()=>{if(!b||!i)return;let{data:e,response:t}=await l({path:{assistant_id:i,id:b.surfaceId},throwOnError:!1,parseAs:`blob`});if(!t?.ok||!e)return;let n=URL.createObjectURL(e);Object.assign(document.createElement(`a`),{href:n,download:`${b.title||`document`}.pdf`}).click(),URL.revokeObjectURL(n)},[b,i]);return S?(0,y.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,y.jsx)(s,{size:24,className:`animate-spin`,style:{color:`var(--content-tertiary)`}})}):w||!b||!i?(0,y.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,y.jsx)(a,{variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:w??`Document not found.`})}):(0,y.jsx)(g,{surfaceId:b.surfaceId,assistantId:i,conversationId:b.conversationId,documentName:b.title,content:b.content,onClose:O,onExport:A,onSubmitFeedback:k,handleRef:E})}export{b as DocumentViewerPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{d as n,p as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-BscuIPxA.js";import"./src-D6Nu2Lol.js";import{n as o}from"./resolved-assistants-store-DMuRxkZC.js";import{t as s}from"./loader-circle-CTs38Ovl.js";import{dt as c,ft as l,ut as u}from"./sdk.gen-Bew9wO5C.js";import{a as d}from"./routes-BKwsRssF.js";import{t as f}from"./use-bus-subscription-RUbeQDfy.js";import{n as p}from"./viewer-store-CInCucV8.js";import{r as m,t as h}from"./edit-chat-session-B1tanC3Z.js";import{Y as g}from"./index-BiN-6kWM.js";var _=e(t(),1);function v({surfaceId:e,enabled:t,onCommentsChanged:n}){let r=(0,_.useRef)(n);return(0,_.useLayoutEffect)(()=>{r.current=n},[n]),(0,_.useCallback)(n=>{if(!t)return;let i=n.message;switch(i.type){case`document_comment_created`:case`document_comment_resolved`:case`document_comment_reopened`:case`document_comment_deleted`:i.surfaceId===e&&r.current();break;default:break}},[e,t])}var y=i();function b(){let{surfaceId:e}=r(),t=n(),i=o.use.activeAssistantId(),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!0),[w,T]=(0,_.useState)(null),E=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(!e){T(`No document ID provided.`),C(!1);return}if(!i)return;let t=!1;return(async()=>{try{let{data:n}=await c({path:{assistant_id:i,id:e},throwOnError:!0});if(t)return;x(n)}catch{t||T(`Failed to load document.`)}finally{t||C(!1)}})(),()=>{t=!0}},[e,i]);let D=(0,_.useCallback)(()=>{E.current?.refreshComments()},[]);f(`sse.event`,v({surfaceId:e??``,enabled:!!e,onCommentsChanged:D}));let O=(0,_.useCallback)(()=>{t(-1)},[t]),k=(0,_.useCallback)(async()=>{if(!b||!i||!e)return;let n=b.conversationId||h(i,e)||(typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`);if(m(i,e,n),n!==b.conversationId)try{await u({path:{assistant_id:i,id:e},body:{conversationId:n},throwOnError:!0})}catch{}p.getState().openDocument(),p.getState().setLoadedDocument({surfaceId:b.surfaceId,conversationId:n,documentName:b.title,content:b.content});let r=`Please review and address my comments on "${b.title}".`;t(`${d.conversation(n)}?prompt=${encodeURIComponent(r)}`)},[b,i,e,t]),A=(0,_.useCallback)(async()=>{if(!b||!i)return;let{data:e,response:t}=await l({path:{assistant_id:i,id:b.surfaceId},throwOnError:!1,parseAs:`blob`});if(!t?.ok||!e)return;let n=URL.createObjectURL(e);Object.assign(document.createElement(`a`),{href:n,download:`${b.title||`document`}.pdf`}).click(),URL.revokeObjectURL(n)},[b,i]);return S?(0,y.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,y.jsx)(s,{size:24,className:`animate-spin`,style:{color:`var(--content-tertiary)`}})}):w||!b||!i?(0,y.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,y.jsx)(a,{variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:w??`Document not found.`})}):(0,y.jsx)(g,{surfaceId:b.surfaceId,assistantId:i,conversationId:b.conversationId,documentName:b.title,content:b.content,onClose:O,onExport:A,onSubmitFeedback:k,handleRef:E})}export{b as DocumentViewerPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D7s2Q_uG.js";import{t as r}from"./useQuery-B45lW1Kk.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import"./src-D6Nu2Lol.js";import{t as a}from"./input-CwdmSRlD.js";import{t as o}from"./modal-DX6UN7b0.js";import{t as s}from"./createLucideIcon-DIlBzeWM.js";import{t as c}from"./arrow-left-DpZuwfUr.js";import{t as l}from"./credit-card-XOxZwKz-.js";import{t as u}from"./loader-circle-CTs38Ovl.js";import{$a as d,Hi as f,Sr as p,Va as m,ho as h}from"./index-LP2PV_QY.js";var g=s(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),_=e(t(),1),v=i();function y(e){return e.replace(/\.00$/,``)}function b(e,t,n){let r=y(n),i=y(e),a=y(t);return i===a?`Share Vellum with friends — you'll each earn ${i} credits when they sign up, up to ${r} total.`:`Share Vellum with friends — you'll earn ${i} credits and they'll get ${a} when they sign up, up to ${r} total.`}function x({open:e,onClose:t}){return(0,v.jsx)(o.Root,{open:e,onOpenChange:e=>{e||t()},children:e?(0,v.jsx)(S,{}):null})}function S(){let[e,t]=(0,_.useState)(!1),[i,s]=(0,_.useState)(!1),{data:x,isLoading:S,isError:E,refetch:D,isFetching:O}=r(p()),k=(0,_.useCallback)(e=>{navigator.clipboard.writeText(e).then(()=>{t(!0),setTimeout(()=>t(!1),2e3)})},[]),A=x?b(x.referrer_credit_amount,x.credit_amount,x.earning_cap):`Refer friends to earn free credits.`,j=x?y(x.earning_cap):``,M=i?`Referral Program Terms`:`Earn free credits`;return(0,v.jsxs)(o.Content,{size:`sm`,children:[(0,v.jsx)(o.Header,{children:(0,v.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[i&&(0,v.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:(0,v.jsx)(c,{}),onClick:()=>s(!1),"aria-label":`Back`,className:`mt-0.5`,tintColor:`var(--content-secondary)`}),(0,v.jsxs)(`div`,{className:`min-w-0`,children:[(0,v.jsx)(o.Title,{children:M}),!i&&(0,v.jsx)(o.Description,{children:A})]})]})}),(0,v.jsx)(o.Body,{children:i&&x?(0,v.jsx)(T,{cap:j}):S?(0,v.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[(0,v.jsx)(u,{className:`h-4 w-4 animate-spin`}),`Loading referral information…`]}):E||!x?(0,v.jsxs)(`div`,{className:`space-y-3`,children:[(0,v.jsx)(`p`,{className:`!m-0 text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:`Failed to load referral information.`}),(0,v.jsx)(n,{variant:`outlined`,onClick:()=>void D(),disabled:O,children:O?`Retrying…`:`Try Again`})]}):(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(C,{icon:(0,v.jsx)(g,{className:`h-4 w-4`}),label:`Share your invite link`}),(0,v.jsx)(C,{icon:(0,v.jsx)(f,{className:`h-4 w-4`}),label:`They sign up`}),(0,v.jsx)(C,{icon:(0,v.jsx)(m,{className:`h-4 w-4`}),label:`You earn credits`})]}),(0,v.jsx)(`div`,{style:{borderTop:`1px solid var(--border-base)`}}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(a,{type:`text`,readOnly:!0,value:x.referral_url,fullWidth:!0,wrapperClassName:`flex-1`,className:`font-mono`,onFocus:e=>e.currentTarget.select()}),(0,v.jsx)(n,{variant:`outlined`,iconOnly:e?(0,v.jsx)(h,{}):(0,v.jsx)(d,{}),onClick:()=>k(x.referral_url),"aria-label":`Copy referral link`,className:`h-9 w-9`})]}),(0,v.jsx)(`div`,{style:{borderTop:`1px solid var(--border-base)`}}),(0,v.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,v.jsx)(w,{icon:(0,v.jsx)(f,{className:`h-3.5 w-3.5`}),value:String(x.referred_count),label:`Friends Referred`}),(0,v.jsx)(w,{icon:(0,v.jsx)(l,{className:`h-3.5 w-3.5`}),value:y(x.total_earned),label:`Credits Earned`})]}),(0,v.jsx)(`div`,{style:{borderTop:`1px solid var(--border-base)`}}),(0,v.jsx)(n,{variant:`ghost`,size:`compact`,onClick:()=>s(!0),fullWidth:!0,className:`text-body-small-default`,tintColor:`var(--content-tertiary)`,children:`View Terms and Conditions`})]})})]})}function C({icon:e,label:t}){return(0,v.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,v.jsx)(`div`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`,color:`var(--content-secondary)`},children:e}),(0,v.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:t})]})}function w({icon:e,value:t,label:n}){return(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5 text-body-medium-lighter`,children:[(0,v.jsx)(`span`,{style:{color:`var(--content-tertiary)`},children:e}),(0,v.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:t}),(0,v.jsx)(`span`,{style:{color:`var(--content-tertiary)`},children:n})]})}function T({cap:e}){return(0,v.jsx)(`ul`,{className:`!m-0 !list-none space-y-2 !p-0`,children:[`This promotion is available to new users who sign up through your referral link only.`,`Rewards are earned once your invitee completes the creation of their Vellum account.`,`You may earn up to ${e} free credits through the Referral Program. We may change this limit at any time.`,`We do not grant credits for disposable or high-risk email accounts.`,`Each new user can generate only one (1) reward. No stacking or loophole hunting.`,`Please avoid spamming or misusing your referral link. Our systems actively monitor referral engagement.`,`If we detect suspicious or non-compliant activity, we reserve the right to withhold rewards or deactivate your referral link.`,`We may update, pause, or discontinue this program at any time.`].map(e=>(0,v.jsxs)(`li`,{className:`flex items-start gap-2 text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:[(0,v.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5`,children:`•`}),(0,v.jsx)(`span`,{children:e})]},e))})}export{x as EarnCreditsModal};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D7s2Q_uG.js";import{t as r}from"./useQuery-B45lW1Kk.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import"./src-D6Nu2Lol.js";import{t as a}from"./input-CwdmSRlD.js";import{t as o}from"./modal-DX6UN7b0.js";import{t as s}from"./createLucideIcon-DIlBzeWM.js";import{t as c}from"./arrow-left-DpZuwfUr.js";import{t as l}from"./credit-card-XOxZwKz-.js";import{t as u}from"./loader-circle-CTs38Ovl.js";import{$a as d,Hi as f,Sr as p,Va as m,ho as h}from"./index-BiN-6kWM.js";var g=s(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),_=e(t(),1),v=i();function y(e){return e.replace(/\.00$/,``)}function b(e,t,n){let r=y(n),i=y(e),a=y(t);return i===a?`Share Vellum with friends — you'll each earn ${i} credits when they sign up, up to ${r} total.`:`Share Vellum with friends — you'll earn ${i} credits and they'll get ${a} when they sign up, up to ${r} total.`}function x({open:e,onClose:t}){return(0,v.jsx)(o.Root,{open:e,onOpenChange:e=>{e||t()},children:e?(0,v.jsx)(S,{}):null})}function S(){let[e,t]=(0,_.useState)(!1),[i,s]=(0,_.useState)(!1),{data:x,isLoading:S,isError:E,refetch:D,isFetching:O}=r(p()),k=(0,_.useCallback)(e=>{navigator.clipboard.writeText(e).then(()=>{t(!0),setTimeout(()=>t(!1),2e3)})},[]),A=x?b(x.referrer_credit_amount,x.credit_amount,x.earning_cap):`Refer friends to earn free credits.`,j=x?y(x.earning_cap):``,M=i?`Referral Program Terms`:`Earn free credits`;return(0,v.jsxs)(o.Content,{size:`sm`,children:[(0,v.jsx)(o.Header,{children:(0,v.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[i&&(0,v.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:(0,v.jsx)(c,{}),onClick:()=>s(!1),"aria-label":`Back`,className:`mt-0.5`,tintColor:`var(--content-secondary)`}),(0,v.jsxs)(`div`,{className:`min-w-0`,children:[(0,v.jsx)(o.Title,{children:M}),!i&&(0,v.jsx)(o.Description,{children:A})]})]})}),(0,v.jsx)(o.Body,{children:i&&x?(0,v.jsx)(T,{cap:j}):S?(0,v.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[(0,v.jsx)(u,{className:`h-4 w-4 animate-spin`}),`Loading referral information…`]}):E||!x?(0,v.jsxs)(`div`,{className:`space-y-3`,children:[(0,v.jsx)(`p`,{className:`!m-0 text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:`Failed to load referral information.`}),(0,v.jsx)(n,{variant:`outlined`,onClick:()=>void D(),disabled:O,children:O?`Retrying…`:`Try Again`})]}):(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(C,{icon:(0,v.jsx)(g,{className:`h-4 w-4`}),label:`Share your invite link`}),(0,v.jsx)(C,{icon:(0,v.jsx)(f,{className:`h-4 w-4`}),label:`They sign up`}),(0,v.jsx)(C,{icon:(0,v.jsx)(m,{className:`h-4 w-4`}),label:`You earn credits`})]}),(0,v.jsx)(`div`,{style:{borderTop:`1px solid var(--border-base)`}}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(a,{type:`text`,readOnly:!0,value:x.referral_url,fullWidth:!0,wrapperClassName:`flex-1`,className:`font-mono`,onFocus:e=>e.currentTarget.select()}),(0,v.jsx)(n,{variant:`outlined`,iconOnly:e?(0,v.jsx)(h,{}):(0,v.jsx)(d,{}),onClick:()=>k(x.referral_url),"aria-label":`Copy referral link`,className:`h-9 w-9`})]}),(0,v.jsx)(`div`,{style:{borderTop:`1px solid var(--border-base)`}}),(0,v.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,v.jsx)(w,{icon:(0,v.jsx)(f,{className:`h-3.5 w-3.5`}),value:String(x.referred_count),label:`Friends Referred`}),(0,v.jsx)(w,{icon:(0,v.jsx)(l,{className:`h-3.5 w-3.5`}),value:y(x.total_earned),label:`Credits Earned`})]}),(0,v.jsx)(`div`,{style:{borderTop:`1px solid var(--border-base)`}}),(0,v.jsx)(n,{variant:`ghost`,size:`compact`,onClick:()=>s(!0),fullWidth:!0,className:`text-body-small-default`,tintColor:`var(--content-tertiary)`,children:`View Terms and Conditions`})]})})]})}function C({icon:e,label:t}){return(0,v.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,v.jsx)(`div`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`,color:`var(--content-secondary)`},children:e}),(0,v.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:t})]})}function w({icon:e,value:t,label:n}){return(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5 text-body-medium-lighter`,children:[(0,v.jsx)(`span`,{style:{color:`var(--content-tertiary)`},children:e}),(0,v.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:t}),(0,v.jsx)(`span`,{style:{color:`var(--content-tertiary)`},children:n})]})}function T({cap:e}){return(0,v.jsx)(`ul`,{className:`!m-0 !list-none space-y-2 !p-0`,children:[`This promotion is available to new users who sign up through your referral link only.`,`Rewards are earned once your invitee completes the creation of their Vellum account.`,`You may earn up to ${e} free credits through the Referral Program. We may change this limit at any time.`,`We do not grant credits for disposable or high-risk email accounts.`,`Each new user can generate only one (1) reward. No stacking or loophole hunting.`,`Please avoid spamming or misusing your referral link. Our systems actively monitor referral engagement.`,`If we detect suspicious or non-compliant activity, we reserve the right to withhold rewards or deactivate your referral link.`,`We may update, pause, or discontinue this program at any time.`].map(e=>(0,v.jsxs)(`li`,{className:`flex items-start gap-2 text-body-medium-lighter`,style:{color:`var(--content-secondary)`},children:[(0,v.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5`,children:`•`}),(0,v.jsx)(`span`,{children:e})]},e))})}export{x as EarnCreditsModal};
@@ -1 +1 @@
1
- import{r as e,t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./useQuery-B45lW1Kk.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import"./src-D6Nu2Lol.js";import{t as i}from"./tag-BadGF3FB.js";import{t as a}from"./loader-circle-CTs38Ovl.js";import{t as o}from"./triangle-alert-M_S_Pe8C.js";import{a as s}from"./routes-BKwsRssF.js";import{En as c,It as l,La as u,Sn as d,ia as f,so as p,v as m,wn as h}from"./index-LP2PV_QY.js";import{t as g}from"./use-active-assistant-id-512RohBL.js";var _=r();function v(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function y({title:e,children:t}){return(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:e}),t]})}function b({tone:e=`info`,children:t}){let n=e===`error`;return(0,_.jsx)(`div`,{className:`rounded-md border px-4 py-3 text-body-medium-lighter`,style:{background:n?`var(--surface-negative-subtle, var(--surface-lift))`:`var(--surface-lift)`,borderColor:n?`var(--border-negative, var(--border-base))`:`var(--border-base)`,color:n?`var(--content-negative, var(--content-default))`:`var(--content-default)`},children:(0,_.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n&&(0,_.jsx)(o,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,_.jsx)(`div`,{className:`flex-1`,children:t})]})})}function x({message:e,onRetry:t,retrying:n}){return(0,_.jsx)(b,{tone:`error`,children:(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,_.jsx)(`span`,{children:e}),(0,_.jsx)(`button`,{type:`button`,onClick:t,disabled:n,className:`text-body-small-default underline disabled:opacity-50`,style:{color:`var(--content-default)`},children:n?`Retrying…`:`Retry`})]})})}function S({label:e,value:t,sub:n}){return(0,_.jsxs)(`div`,{className:`rounded-xl border p-3`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:[(0,_.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e}),(0,_.jsx)(`p`,{className:`mt-1 text-title-large tabular-nums`,style:{color:`var(--content-default)`},children:t??`—`}),n&&(0,_.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-disabled)`},children:n})]})}function C({email:e}){let t=e.direction===`inbound`;return(0,_.jsx)(`div`,{className:`rounded-xl border p-4`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,_.jsx)(i,{tone:t?`positive`:`neutral`,leftIcon:t?(0,_.jsx)(u,{}):(0,_.jsx)(f,{}),children:t?`Inbound`:`Outbound`}),(0,_.jsx)(`span`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e.from_address})]}),(0,_.jsx)(`p`,{className:`truncate text-body-medium-default`,style:{color:`var(--content-default)`},children:e.subject||`(no subject)`})]}),(0,_.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[(0,_.jsx)(p,{className:`h-3 w-3`}),(0,_.jsx)(`span`,{children:v(e.created_at)})]})]})})}function w({assistantId:e,platformGate:r}){let i=r===`full`,o=n({...d({path:{assistant_id:e}}),enabled:i}),l=o.data?.results?.[0],u=n({...h({path:{assistant_id:e,id:l?.id??``}}),enabled:i&&!!l?.id}),f=n({...c({path:{assistant_id:e},query:{limit:10}}),enabled:i}),p=u.data?.usage,m=f.data?.results??[];return o.isLoading?(0,_.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,_.jsx)(a,{className:`h-8 w-8 animate-spin`,style:{color:`var(--content-tertiary)`}})}):o.isError?(0,_.jsx)(x,{message:`Couldn't load email addresses.`,onRetry:()=>{o.refetch()},retrying:o.isFetching}):l?(0,_.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,_.jsx)(y,{title:`Totals`,children:(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,_.jsx)(S,{label:`Sent today`,value:p?.sent_today,sub:p?`of ${p.daily_limit} daily limit`:void 0}),(0,_.jsx)(S,{label:`Received today`,value:p?.received_today}),(0,_.jsx)(S,{label:`Sent this month`,value:p?.sent_this_month}),(0,_.jsx)(S,{label:`Received this month`,value:p?.received_this_month})]})}),(0,_.jsx)(y,{title:`Recent Emails`,children:f.isLoading?(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[(0,_.jsx)(a,{className:`h-4 w-4 animate-spin`}),`Loading…`]}):f.isError?(0,_.jsx)(x,{message:`Couldn't load recent emails.`,onRetry:()=>{f.refetch()},retrying:f.isFetching}):m.length===0?(0,_.jsx)(b,{children:`No emails yet.`}):(0,_.jsx)(`div`,{className:`space-y-2`,children:m.map(e=>(0,_.jsx)(C,{email:e},e.id))})})]}):(0,_.jsxs)(b,{children:[`No email address registered yet.`,` `,(0,_.jsx)(t,{to:s.settings.ai,className:`underline`,style:{color:`var(--content-tertiary)`},children:`Set one up in AI Settings → Email.`})]})}function T(){let t=l(),n=g();return t===`gated`?(0,_.jsx)(e,{replace:!0,to:s.logs.root}):t===`disabled`?(0,_.jsx)(m,{children:`Log in to the Vellum platform to view emails.`}):(0,_.jsx)(w,{assistantId:n,platformGate:t})}export{T as EmailsPage};
1
+ import{r as e,t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./useQuery-B45lW1Kk.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import"./src-D6Nu2Lol.js";import{t as i}from"./tag-BadGF3FB.js";import{t as a}from"./loader-circle-CTs38Ovl.js";import{t as o}from"./triangle-alert-M_S_Pe8C.js";import{a as s}from"./routes-BKwsRssF.js";import{En as c,It as l,La as u,Sn as d,ia as f,so as p,v as m,wn as h}from"./index-BiN-6kWM.js";import{t as g}from"./use-active-assistant-id-512RohBL.js";var _=r();function v(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function y({title:e,children:t}){return(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsx)(`h2`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:e}),t]})}function b({tone:e=`info`,children:t}){let n=e===`error`;return(0,_.jsx)(`div`,{className:`rounded-md border px-4 py-3 text-body-medium-lighter`,style:{background:n?`var(--surface-negative-subtle, var(--surface-lift))`:`var(--surface-lift)`,borderColor:n?`var(--border-negative, var(--border-base))`:`var(--border-base)`,color:n?`var(--content-negative, var(--content-default))`:`var(--content-default)`},children:(0,_.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n&&(0,_.jsx)(o,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,_.jsx)(`div`,{className:`flex-1`,children:t})]})})}function x({message:e,onRetry:t,retrying:n}){return(0,_.jsx)(b,{tone:`error`,children:(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,_.jsx)(`span`,{children:e}),(0,_.jsx)(`button`,{type:`button`,onClick:t,disabled:n,className:`text-body-small-default underline disabled:opacity-50`,style:{color:`var(--content-default)`},children:n?`Retrying…`:`Retry`})]})})}function S({label:e,value:t,sub:n}){return(0,_.jsxs)(`div`,{className:`rounded-xl border p-3`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:[(0,_.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e}),(0,_.jsx)(`p`,{className:`mt-1 text-title-large tabular-nums`,style:{color:`var(--content-default)`},children:t??`—`}),n&&(0,_.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-disabled)`},children:n})]})}function C({email:e}){let t=e.direction===`inbound`;return(0,_.jsx)(`div`,{className:`rounded-xl border p-4`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,_.jsx)(i,{tone:t?`positive`:`neutral`,leftIcon:t?(0,_.jsx)(u,{}):(0,_.jsx)(f,{}),children:t?`Inbound`:`Outbound`}),(0,_.jsx)(`span`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e.from_address})]}),(0,_.jsx)(`p`,{className:`truncate text-body-medium-default`,style:{color:`var(--content-default)`},children:e.subject||`(no subject)`})]}),(0,_.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[(0,_.jsx)(p,{className:`h-3 w-3`}),(0,_.jsx)(`span`,{children:v(e.created_at)})]})]})})}function w({assistantId:e,platformGate:r}){let i=r===`full`,o=n({...d({path:{assistant_id:e}}),enabled:i}),l=o.data?.results?.[0],u=n({...h({path:{assistant_id:e,id:l?.id??``}}),enabled:i&&!!l?.id}),f=n({...c({path:{assistant_id:e},query:{limit:10}}),enabled:i}),p=u.data?.usage,m=f.data?.results??[];return o.isLoading?(0,_.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,_.jsx)(a,{className:`h-8 w-8 animate-spin`,style:{color:`var(--content-tertiary)`}})}):o.isError?(0,_.jsx)(x,{message:`Couldn't load email addresses.`,onRetry:()=>{o.refetch()},retrying:o.isFetching}):l?(0,_.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,_.jsx)(y,{title:`Totals`,children:(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,_.jsx)(S,{label:`Sent today`,value:p?.sent_today,sub:p?`of ${p.daily_limit} daily limit`:void 0}),(0,_.jsx)(S,{label:`Received today`,value:p?.received_today}),(0,_.jsx)(S,{label:`Sent this month`,value:p?.sent_this_month}),(0,_.jsx)(S,{label:`Received this month`,value:p?.received_this_month})]})}),(0,_.jsx)(y,{title:`Recent Emails`,children:f.isLoading?(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[(0,_.jsx)(a,{className:`h-4 w-4 animate-spin`}),`Loading…`]}):f.isError?(0,_.jsx)(x,{message:`Couldn't load recent emails.`,onRetry:()=>{f.refetch()},retrying:f.isFetching}):m.length===0?(0,_.jsx)(b,{children:`No emails yet.`}):(0,_.jsx)(`div`,{className:`space-y-2`,children:m.map(e=>(0,_.jsx)(C,{email:e},e.id))})})]}):(0,_.jsxs)(b,{children:[`No email address registered yet.`,` `,(0,_.jsx)(t,{to:s.settings.ai,className:`underline`,style:{color:`var(--content-tertiary)`},children:`Set one up in AI Settings → Email.`})]})}function T(){let t=l(),n=g();return t===`gated`?(0,_.jsx)(e,{replace:!0,to:s.logs.root}):t===`disabled`?(0,_.jsx)(m,{children:`Log in to the Vellum platform to view emails.`}):(0,_.jsx)(w,{assistantId:n,platformGate:t})}export{T as EmailsPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D7s2Q_uG.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./pencil-lwgMCqyH.js";import{$a as a,Za as o,ho as s}from"./index-LP2PV_QY.js";var c=e(t(),1),l=r(),u=`ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace`;function d({content:e,downloadContent:t,fileName:r,mimeType:u=`text/plain`,showEdit:d,isEditing:f,onToggleEdit:p,extraActions:m}){let[h,g]=(0,c.useState)(!1),_=(0,c.useRef)(null),v=(0,c.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{g(!0),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>g(!1),1500)})},[e]),y=t??e,b=(0,c.useCallback)(()=>{let e=new Blob([y],{type:u}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=r,n.click(),URL.revokeObjectURL(t)},[y,r,u]);return(0,c.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]),f?null:(0,l.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex items-center gap-1 rounded-md bg-[var(--surface-primary)] shadow-sm`,children:[d&&p&&(0,l.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:(0,l.jsx)(i,{"aria-hidden":!0}),onClick:p,"aria-label":`Edit file`,className:`hover:bg-[var(--surface-base)]`}),m,(0,l.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:h?(0,l.jsx)(s,{"aria-hidden":!0}):(0,l.jsx)(a,{"aria-hidden":!0}),onClick:v,"aria-label":h?`Copied`:`Copy file contents`,className:`hover:bg-[var(--surface-base)]`}),(0,l.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:(0,l.jsx)(o,{"aria-hidden":!0}),onClick:b,"aria-label":`Download file`,className:`hover:bg-[var(--surface-base)]`})]})}function f({value:e,onChange:t,onSave:n}){return(0,l.jsx)(`textarea`,{className:`m-0 h-full w-full resize-none overflow-auto border-none bg-transparent p-4 text-body-medium-lighter leading-relaxed outline-none`,style:{color:`var(--content-default)`,fontFamily:u},value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),n())},spellCheck:!1})}function p({isDirty:e,isSaving:t,error:r,onSave:i,onDiscard:a}){return(0,l.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t px-3 py-2`,style:{borderColor:`var(--border-element)`},children:[r&&(0,l.jsx)(`span`,{className:`mr-auto text-body-small-default`,style:{color:`var(--system-error)`},children:r}),(0,l.jsx)(n,{variant:`ghost`,size:`compact`,disabled:t,onClick:a,children:`Discard`}),(0,l.jsx)(n,{variant:`primary`,size:`compact`,disabled:!e||t,onClick:i,children:t?`Saving…`:`Save`})]})}function m({content:e,readOnly:t,whiteSpace:n=`pre-wrap`,onStartEdit:r}){return(0,l.jsx)(`pre`,{className:`m-0 h-full overflow-auto p-4 text-body-medium-lighter leading-relaxed${t?``:` cursor-text`}`,style:{color:`var(--content-default)`,fontFamily:u,whiteSpace:n},onClick:t?void 0:r,children:e})}export{m as i,p as n,f as r,d as t};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D7s2Q_uG.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{t as i}from"./pencil-lwgMCqyH.js";import{$a as a,Za as o,ho as s}from"./index-BiN-6kWM.js";var c=e(t(),1),l=r(),u=`ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace`;function d({content:e,downloadContent:t,fileName:r,mimeType:u=`text/plain`,showEdit:d,isEditing:f,onToggleEdit:p,extraActions:m}){let[h,g]=(0,c.useState)(!1),_=(0,c.useRef)(null),v=(0,c.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{g(!0),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>g(!1),1500)})},[e]),y=t??e,b=(0,c.useCallback)(()=>{let e=new Blob([y],{type:u}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=r,n.click(),URL.revokeObjectURL(t)},[y,r,u]);return(0,c.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]),f?null:(0,l.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex items-center gap-1 rounded-md bg-[var(--surface-primary)] shadow-sm`,children:[d&&p&&(0,l.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:(0,l.jsx)(i,{"aria-hidden":!0}),onClick:p,"aria-label":`Edit file`,className:`hover:bg-[var(--surface-base)]`}),m,(0,l.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:h?(0,l.jsx)(s,{"aria-hidden":!0}):(0,l.jsx)(a,{"aria-hidden":!0}),onClick:v,"aria-label":h?`Copied`:`Copy file contents`,className:`hover:bg-[var(--surface-base)]`}),(0,l.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:(0,l.jsx)(o,{"aria-hidden":!0}),onClick:b,"aria-label":`Download file`,className:`hover:bg-[var(--surface-base)]`})]})}function f({value:e,onChange:t,onSave:n}){return(0,l.jsx)(`textarea`,{className:`m-0 h-full w-full resize-none overflow-auto border-none bg-transparent p-4 text-body-medium-lighter leading-relaxed outline-none`,style:{color:`var(--content-default)`,fontFamily:u},value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),n())},spellCheck:!1})}function p({isDirty:e,isSaving:t,error:r,onSave:i,onDiscard:a}){return(0,l.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t px-3 py-2`,style:{borderColor:`var(--border-element)`},children:[r&&(0,l.jsx)(`span`,{className:`mr-auto text-body-small-default`,style:{color:`var(--system-error)`},children:r}),(0,l.jsx)(n,{variant:`ghost`,size:`compact`,disabled:t,onClick:a,children:`Discard`}),(0,l.jsx)(n,{variant:`primary`,size:`compact`,disabled:!e||t,onClick:i,children:t?`Saving…`:`Save`})]})}function m({content:e,readOnly:t,whiteSpace:n=`pre-wrap`,onStartEdit:r}){return(0,l.jsx)(`pre`,{className:`m-0 h-full overflow-auto p-4 text-body-medium-lighter leading-relaxed${t?``:` cursor-text`}`,style:{color:`var(--content-default)`,fontFamily:u,whiteSpace:n},onClick:t?void 0:r,children:e})}export{m as i,p as n,f as r,d as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{a as t,n,o as r,r as i,s as a}from"./device-settings-BBwtGKJb.js";import{t as o}from"./capture-error-B0wqOYKY.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-yOV5eJnU.js";import{c as _,l as v,n as y}from"./src-D6Nu2Lol.js";import{t as b}from"./confirm-dialog-DbNUkFt6.js";import{t as x}from"./notice-G5Imd5pC.js";import{t as S}from"./tag-BadGF3FB.js";import{t as C}from"./input-CwdmSRlD.js";import{t as w}from"./toggle-_vZlLDBV.js";import{n as T}from"./stat-square-B5tBfA4w.js";import{t as E}from"./modal-DX6UN7b0.js";import{n as D}from"./toast-DLWkiWW6.js";import{d as O,f as k,s as A}from"./local-mode-9ZkSq1Fr.js";import{t as j}from"./is-electron-BuSDabCt.js";import{n as M}from"./resolved-assistants-store-DMuRxkZC.js";import{t as N}from"./createLucideIcon-DIlBzeWM.js";import{t as P}from"./bell-CSP2EUlP.js";import{t as F}from"./chevron-right-HpmykQ8I.js";import{t as I}from"./circle-alert-C5TvMkJV.js";import{t as L}from"./hard-drive-C6sJQKXL.js";import{t as R}from"./loader-circle-CTs38Ovl.js";import{t as z}from"./moon-C0wLM1iN.js";import{a as ee,c as te,o as ne,r as re,s as ie,t as ae}from"./resize-errors-tz_Tui32.js";import{t as oe}from"./sparkles-B9QIWdq0.js";import{t as se}from"./triangle-alert-M_S_Pe8C.js";import{n as B,r as V,t as H}from"./api-errors-CwAGZ-xJ.js";import{K as U,_ as W,a as ce,b as le,g as ue,n as de,u as fe,x as pe,y as me}from"./auth-store-CrTf0uWL.js";import{t as he}from"./client.gen-Cuv6iN0E.js";import{S as ge,V as _e,Y as ve,j as ye}from"./sdk.gen-DRL3oRwz.js";import{a as G}from"./routes-BKwsRssF.js";import{t as K}from"./client-feature-flag-store-ivPVcKfH.js";import{n as q,t as be}from"./semver-DmouQEQK.js";import{t as xe}from"./assistant-feature-flag-store-D2CUHsmL.js";import{t as Se}from"./proxy-CQsxT9tJ.js";import{t as Ce}from"./use-reduced-motion-CXbk4fYO.js";import{Bn as we,Cr as Te,Dn as Ee,Dr as De,Fn as Oe,Ft as ke,It as Ae,J as je,Ji as Me,K as Ne,Ki as Pe,Ln as Fe,Mn as Ie,Mt as Le,Nn as Re,Or as ze,Pn as Be,Pt as Ve,Qi as He,Qr as Ue,Rn as We,Sa as Ge,Vr as Ke,Xr as qe,Zr as Je,Zt as Ye,_n as Xe,ar as Ze,ca as Qe,d as $e,et,f as tt,ho as nt,jr as rt,jt as it,l as at,la as ot,mo as st,s as ct,sr as lt,u as ut,ua as dt,v as J,za as ft,zn as pt}from"./index-LP2PV_QY.js";import{t as mt}from"./use-active-assistant-id-512RohBL.js";import{t as Y}from"./detail-card-CLwQ17AA.js";import{t as ht}from"./environment-store-Ck7wXCrL.js";import{i as gt,n as X,r as _t,t as vt}from"./assistant-status-panel-CMdqv7mF.js";var yt=N(`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`}]]),bt=N(`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`}]]),Z=e(s(),1),xt=ue,St=`Please choose a different handle.`;async function Ct(e,t){let{data:n,error:r,response:i}=await ye({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:V(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}=pe(r,`handle`,xt.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=pe(r,`handle`,St);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:V(r,i,`Failed to save handle.`)}}async function wt(e,t,n){let{data:r,error:i,response:a}=await ge({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(B(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new H(a.status,a.status===429?`Too many checks — try again in a moment.`:V(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function Tt(e){return/\d{2,}$/.test(e)}var Q=m(),Et=300,Dt=1400;function Ot({initialHandle:e,inputLabel:t,helperText:n,idleHelperText:r,checkAvailable:i,save:a,onSaved:o,saveSuccessToast:s,fieldId:l}){let[u,d]=(0,Z.useState)(e),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(`idle`),[v,y]=(0,Z.useState)(null),b=Ce(),x=(0,Z.useRef)(null),S=(0,Z.useMemo)(()=>u.trim().toLowerCase(),[u]),w=S===e.toLowerCase();(0,Z.useEffect)(()=>{if(w||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)}},Et);return()=>{window.clearTimeout(t),e.abort()}},[S,w,i]);let T=(()=>{if(v)return v;if(f&&!f.available){let e=f.code;return f.message??(e?xt[e]:`Please choose a different handle.`)}return null})(),E=T?n:w?r??null:m?`Checking availability…`:f?.available?`Available.`:null,O=!w&&!m&&f?.available!==!1&&g!==`saving`,k=(0,Z.useCallback)(async()=>{if(!O)return;_(`saving`),y(null);let e=await a(S);if(e.kind===`ok`){_(`saved`),o(e.data),D.success(s),window.setTimeout(()=>_(`idle`),Dt);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),D.error(e.message)},[O,S,o,a,s]),A=(()=>{if(w&&u.length>0||u.length===0)return null;let e=m?`checking`:f?.available?`available`:f?.available===!1?`invalid`:null;return e?(0,Q.jsx)(je,{mode:`wait`,initial:!1,children:(0,Q.jsxs)(Se.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,Q.jsx)(R,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,Q.jsx)(nt,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":`Available`}),e===`invalid`&&(0,Q.jsx)(I,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":`Not available`})]},e)}):null})(),j=(()=>{switch(g){case`saving`:return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(R,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),`Saving…`]});case`saved`:return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(nt,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Saved`]});default:return`Save`}})();return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(C,{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,Q.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`}),(!w||g!==`idle`)&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(c,{variant:`primary`,size:`compact`,onClick:k,disabled:!O,"aria-live":`polite`,"data-testid":`${l}-save`,children:j})})]})}function kt({initial:e,onSaved:t}){let n=de.use.refreshSession(),r=Tt(e.username)?`Your handle was auto-generated at signup — pick one you like.`:void 0,i=(0,Z.useCallback)(async e=>await le({username:e}),[]),a=(0,Z.useCallback)((e,t)=>W(e,t),[]),o=(0,Z.useCallback)(e=>{t(e),n()},[t,n]);return(0,Q.jsx)(Ot,{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 At({assistant:e,onSaved:t}){let n=e.handle??``,r=f({...Xe({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,Z.useCallback)(async t=>await Ct(e.id,t),[e.id]),s=(0,Z.useCallback)((t,n)=>wt(e.id,t,n),[e.id]);return i?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(C,{label:`Assistant handle`,value:n,readOnly:!0,disabled:!0,leftIcon:(0,Q.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),fullWidth:!0,"data-testid":`assistant-handle-input`}),(0,Q.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,Q.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,Q.jsx)(Ot,{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 jt(){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":!0,"aria-live":`polite`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`div`,{className:`h-3 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Q.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Q.jsx)(`div`,{className:`h-3 w-72 animate-pulse rounded bg-[var(--surface-muted)]`})]}),(0,Q.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`div`,{className:`h-3 w-60 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Q.jsx)(`div`,{className:`h-7 w-16 animate-pulse rounded-md bg-[var(--surface-muted)]`})]}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Loading your profile…`})]})}function Mt({assistant:e}={}){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(null),a=Ce(),[o,s]=(0,Z.useState)(e??null);return(0,Z.useEffect)(()=>{s(e??null)},[e]),(0,Z.useEffect)(()=>{let e=!1;return me().then(t=>{e||n(t)}).catch(t=>{e||i(t instanceof Error?t.message:`Failed to load profile.`)}),()=>{e=!0}},[]),(0,Q.jsx)(Y,{title:`Profile`,subtitle:`Manage your user and assistant public handles.`,children:r?(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:r}):t?(0,Q.jsxs)(Se.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,Q.jsx)(kt,{initial:t,onSaved:n}),o&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsx)(At,{assistant:o,onSaved:s})]})]}):(0,Q.jsx)(jt,{})})}var Nt=Ee({query:{hosting:`platform`}});function Pt(){let e=mt(),t=f(Nt),n=t.data?.results??[];return t.isPending||n.length<2?null:(0,Q.jsx)(Y,{title:`Switch Assistant`,subtitle:`Choose which assistant is active for this account.`,children:(0,Q.jsx)(`div`,{className:`space-y-2`,children:n.map(t=>{let n=t.id===e;return(0,Q.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,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(Ge,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:t.name||`Unnamed`}),t.status!==`active`&&(0,Q.jsx)(S,{tone:`warning`,children:t.status})]})})]}),(0,Q.jsx)(`div`,{className:`shrink-0`,children:n?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-body-small-default text-[var(--system-positive-default)]`,children:[(0,Q.jsx)(nt,{className:`h-4 w-4`}),`Active`]}):(0,Q.jsx)(c,{variant:`outlined`,size:`compact`,disabled:t.status!==`active`,onClick:()=>{U(t.id),D.success(`Switched active assistant.`)},children:`Switch`})})]},t.id)})})})}var Ft=[{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 It(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 Lt({assistantId:e}){let t=d(),n=ht.use.isNonProduction(),r=(0,Z.useMemo)(()=>Ft.filter(e=>!e.devOnly||n),[n]),{data:i,isLoading:a,isError:o}=f(pt({path:{id:e}})),s=(0,Z.useMemo)(()=>i?.idle_timeout_seconds??259200,[i]),[l,u]=(0,Z.useState)(null),p=l??s,m=l!==null,h=ze({onSuccess:()=>{D.success(`Sleep policy saved.`),u(null),t.invalidateQueries({queryKey:we({path:{id:e}})})},onError:()=>{D.error(`Failed to save sleep policy. Please try again.`)}});return a?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(R,{className:`h-4 w-4 animate-spin`}),`Loading sleep settings...`]}):o?(0,Q.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,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:`Idle timeout`}),(0,Q.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,Q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:r.map(e=>(0,Q.jsx)(c,{variant:`outlined`,active:p===e.seconds,onClick:()=>u(e.seconds),children:e.label},e.seconds))}),(0,Q.jsxs)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:[`Current: `,It(p)]})]}),m&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(c,{variant:`primary`,leftIcon:h.isPending?(0,Q.jsx)(R,{className:`animate-spin`}):void 0,onClick:()=>h.mutate({path:{id:e},body:{idle_timeout_seconds:p}}),disabled:h.isPending,children:`Save`}),(0,Q.jsx)(c,{variant:`outlined`,onClick:()=>u(null),disabled:h.isPending,children:`Cancel`})]})]})}function Rt(e,t,n){let r=[e.version];return e.version===n&&r.push(`(latest)`),t&&e.version===t&&r.push(`(current)`),r.join(` `)}var zt=3e3;function Bt(e,t){return t&&e===`preview`?`preview`:`stable`}function Vt({assistantId:e,currentVersion:t,releaseChannel:n,onUpgradeComplete:r}){let i=xe.use.rollbackEnabled(),a=K.use.previewChannel(),o=d(),s=Bt(n,a),l=s===`preview`,[u,m]=(0,Z.useState)(!1),h=(0,Z.useRef)(null),[_,v]=(0,Z.useState)(null),[y,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.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),D.success(S?`Rollback complete — assistant is healthy.`:`Update complete — assistant is healthy.`),r?.()}),!1):zt;f({...Fe({path:{id:e}}),refetchInterval:u?e=>E(e.state.data?.current_release_version):!1});let{data:O,isLoading:k}=f(Te({query:{channel:s}})),A=O?.find(e=>e.is_stable!==!1)??O?.[0],j=_??A?.version??null,M=(0,Z.useMemo)(()=>{if(!i||!j||!t)return!1;let e=q(j),n=q(t);return!e||!n?!1:be(e,n)<0},[i,j,t]),N=(0,Z.useMemo)(()=>{if(!j)return!1;if(!t)return!0;let e=q(j),n=q(t);if(!e||!n)return j!==t;let r=be(e,n);return i?r!==0:r>0},[i,j,t]),P=p({mutationFn:async t=>{let{data:n}=await ve({path:{id:e},body:t,throwOnError:!0});return n}}),F=p({mutationFn:async t=>{let{data:n}=await _e({path:{id:e},body:t,throwOnError:!0});return n}});return(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Q.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:t??`—`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:l?`Preview release`:N?M?`Rollback to`:`Update to`:`Selected`}),(0,Q.jsx)(`span`,{className:`block min-w-0`,children:k?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(R,{className:`h-3 w-3 animate-spin`}),`Loading...`]}):O&&O.length>0?i?(0,Q.jsx)(g,{value:j??``,onChange:e=>v(e===A?.version?null:e),disabled:u||P.isPending||F.isPending,options:O.map(e=>({value:e.version,label:Rt(e,t,A?.version)}))}):(0,Q.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:A?Rt(A,t,A.version):`—`}):`No releases available`})]})]}),(0,Q.jsx)(c,{variant:M?`outlined`:`primary`,className:`min-w-[160px]`,leftIcon:P.isPending||F.isPending||u?(0,Q.jsx)(R,{className:`animate-spin`}):(0,Q.jsx)(dt,{}),onClick:()=>x(!0),disabled:!N||P.isPending||F.isPending||u||k||!O?.length,children:u?S?`Rolling back...`:`Updating...`:M?`Rollback`:l?`Update preview`:`Update`}),l&&(0,Q.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Using Preview releases.`,` `,(0,Q.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,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:w??`You are already on this version.`}),(0,Q.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,D.success(e.detail||`Rollback to ${t} initiated.`)}else{let e=await P.mutateAsync({version:t});if(e.detail?.includes(`Already on the latest`)){D.warning(e.detail);return}h.current=e.version??t??null,D.success(e.detail||`Update to ${e.version??t??`latest`} initiated.`)}C(M),m(!0),o.invalidateQueries({queryKey:We({path:{id:e}})})}catch{D.error(M?`Failed to trigger rollback. Please try again.`:`Failed to trigger update. Please try again.`)}},onCancel:()=>x(!1)})]})}function Ht(){let e=tt.useValue();if(Ye())return null;let t=ut()?`Cmd`:`Ctrl`;return(0,Q.jsx)(Y,{title:`Composer`,children:(0,Q.jsx)(w,{checked:e,onChange:tt.save,label:`Send with ${t}+Enter`,helperText:`When enabled, Enter inserts a new line and ${t}+Enter sends.`})})}function Ut(){let e=Ae({platformHostedOnly:!0}),t=ke(),n=de.use.user()?.id??null,r=de.use.logout(),[i,a]=(0,Z.useState)(!1),o=rt({onSuccess:async()=>{D.success(`Account deletion requested. You will be logged out shortly.`),fe(n),await r(),Ke(G.account.login)},onError:()=>{D.error(`Failed to request account deletion. Please try again.`)}}),s=e===`full`&&t;return(0,Z.useEffect)(()=>{s&&i&&a(!1)},[s,i]),e===`gated`?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{title:`Delete Account`,subtitle:`Permanently delete your account and all associated data.`,variant:`danger`,children:e===`disabled`?(0,Q.jsx)(J,{children:`Log in to the Vellum platform to delete your account.`}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(c,{variant:`dangerOutline`,onClick:()=>a(!0),disabled:o.isPending||s,className:`self-start`,children:`Delete My Account`}),s&&(0,Q.jsx)(R,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})}),(0,Q.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 Wt({title:e,subtitle:t,benefits:n,ctaLabel:r,ctaLeftIcon:i,onAction:a}){return(0,Q.jsx)(Y,{title:e,subtitle:t,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`ul`,{className:`space-y-3`,children:n.map(({icon:e,text:t})=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`},children:(0,Q.jsx)(e,{size:14,style:{color:`var(--content-secondary)`},"aria-hidden":!0})}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]},t))}),(0,Q.jsx)(c,{variant:`primary`,size:`regular`,leftIcon:i,onClick:a,className:`self-start`,children:r})]})})}function Gt(){return $e()?(0,Q.jsx)(Wt,{title:`Get the iOS App`,subtitle:`The Vellum iOS app gives you a native experience.`,benefits:[{icon:P,text:`Push notifications`},{icon:yt,text:`Biometric login`},{icon:bt,text:`Native haptics`},{icon:He,text:`Home screen access`}],ctaLabel:`Download`,ctaLeftIcon:(0,Q.jsx)(He,{size:16}),onAction:()=>{at(),ct()}}):null}async function Kt(){if(!j())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function qt(e){if(!j())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function Jt(){let[e,t]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{Kt().then(t)},[]);let n=async e=>{t(e);try{await qt(e)}catch{t(!e)}};return(0,Q.jsx)(Y,{title:`Launch at Login`,subtitle:`Automatically start Vellum when you log in to your Mac.`,children:(0,Q.jsx)(w,{checked:e,onChange:e=>void n(e),"aria-label":`Launch at Login`})})}function Yt({className:e}){return(0,Q.jsx)(`div`,{role:`presentation`,className:h(`h-px w-full bg-[var(--border-base)]`,e)})}var $=[`youtube.com`,`youtu.be`,`vimeo.com`,`loom.com`];function Xt(e){try{let t=JSON.parse(e);if(Array.isArray(t))return t.filter(e=>typeof e==`string`)}catch{}return[...$]}function Zt(){return n(`mediaEmbedsEnabled`,!0)}function Qt(){let e=i(`mediaEmbedDomains`,``);return e?Xt(e):[...$]}function $t(){let[e,n]=(0,Z.useState)(()=>Zt()),[i,a]=(0,Z.useState)(()=>Qt()),[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(``),d=(0,Z.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([...$])},_=i.length===$.length&&i.every((e,t)=>e===$[t]);return(0,Q.jsxs)(Y,{title:`Media Embeds`,subtitle:`Automatically embed images, videos, and other media shared in chat messages.`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Auto Media Embeds`}),(0,Q.jsx)(w,{checked:e,onChange:f})]}),e&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(Yt,{})}),(0,Q.jsxs)(c,{type:`button`,variant:`ghost`,onClick:()=>s(e=>!e),className:`mt-4 w-full justify-between px-3`,"aria-expanded":o,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[o?(0,Q.jsx)(st,{className:`h-4 w-4`,"aria-hidden":!0}):(0,Q.jsx)(F,{className:`h-4 w-4`,"aria-hidden":!0}),`Video Domain Allowlist`]}),(0,Q.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[i.length,` domain`,i.length===1?``:`s`]})]}),o&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Q.jsx)(C,{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,Q.jsx)(c,{variant:`primary`,size:`compact`,onClick:m,disabled:!d,children:`Add`})]}),i.length>0&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,onClick:g,disabled:_,tintColor:`var(--content-tertiary)`,children:`Reset to Defaults`})}),i.length>0&&(0,Q.jsx)(`ul`,{className:`space-y-2`,children:i.map(e=>(0,Q.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,Q.jsx)(`span`,{className:`font-mono text-[var(--content-default)]`,children:e}),(0,Q.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(Pe,{}),onClick:()=>h(e),"aria-label":`Remove ${e}`})]},e))})]})]})]})}function en(e){return e===`preview`?`preview`:`stable`}function tn(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 nn(e){return e.source_release_version?`Stable ${e.source_release_version}`:e.snapshot_name}function rn(e){return e.filter(e=>e.ready_to_use)}function an(e){return e?.feature_enabled===!1}function on({assistantId:e,onComplete:t}){let n=K.use.previewChannel(),r=d(),[i,a]=(0,Z.useState)(),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,m]=(0,Z.useState)(`restore_backup`),[h,g]=(0,Z.useState)(``),_=Be({path:{assistant_id:e}}),v=Oe({path:{assistant_id:e}}),b=We({path:{id:e}}),{data:C,isLoading:w,isError:T}=f({..._,enabled:n,retry:!1}),E=C?.preview_backups??[],O=(0,Z.useMemo)(()=>rn(E),[E]),k=O[0],A=O.find(e=>e.snapshot_name===h)??k,j=()=>{r.invalidateQueries({queryKey:v}),r.invalidateQueries({queryKey:b}),t?.()},M=p(Ie()),N=p(Re()),P=en(C?.current_channel),F=M.isPending||N.isPending,I=F||an(C)||!C?.latest_preview_release,L=u===`restore_backup`&&!A;if((0,Z.useEffect)(()=>{a(P===`preview`?`release-channel`:void 0)},[P]),!n)return null;let z=C?.standard_upgrade_available??!1;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(y.Root,{type:`single`,collapsible:!0,value:i,onValueChange:e=>a(e||void 0),className:`mt-5 border-t border-[var(--border-base)] pt-5`,children:(0,Q.jsxs)(y.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,Q.jsxs)(y.Trigger,{className:`group justify-between gap-3`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`Release Channel`}),C&&(0,Q.jsx)(S,{tone:P===`preview`?`warning`:`neutral`,children:P===`preview`?`Preview`:`Stable`})]}),(0,Q.jsx)(st,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(y.Content,{children:(0,Q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[w&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(R,{className:`h-4 w-4 animate-spin`}),`Loading release channel...`]}),T&&(0,Q.jsx)(x,{tone:`error`,title:`Could not load release channel status`,children:`Refresh this page before changing release channels.`}),C&&(0,Q.jsxs)(Q.Fragment,{children:[an(C)&&(0,Q.jsx)(x,{tone:`neutral`,title:`Preview channel is unavailable`,children:`The Preview channel is not enabled for this assistant.`}),P===`stable`?(0,Q.jsx)(sn,{status:C,isChangingChannel:F,optInDisabled:I,onOptIn:()=>s(!0)}):(0,Q.jsx)(cn,{status:C,isChangingChannel:F,onOptOut:()=>{let e=k;g(e?.snapshot_name??``),m(e?`restore_backup`:z?`standard_upgrade`:`restore_backup`),l(!0)}})]})]})})]})}),(0,Q.jsx)(un,{open:o,isPending:M.isPending,previewVersion:C?.latest_preview_release?.version,onConfirm:async()=>{try{let t=await M.mutateAsync({path:{assistant_id:e}});D.success(t.detail||`Preview channel enabled.`),s(!1),j()}catch(e){D.error(V(e,void 0,`Could not enable Preview channel.`))}},onCancel:()=>s(!1)}),(0,Q.jsx)(dn,{open:c,backups:O,mode:u,selectedSnapshotName:A?.snapshot_name??``,isPending:N.isPending,restoreModeDisabled:L,standardUpgradeAvailable:z,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`}});D.success(t.detail||`Stable channel enabled.`),l(!1),j()}catch(e){D.error(V(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>l(!1)})]})}function sn({status:e,isChangingChannel:t,optInDisabled:n,onOptIn:r}){return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ln,{status:e}),!e.latest_preview_release&&(0,Q.jsx)(x,{tone:`neutral`,title:`No Preview release is available`,children:`Stable remains the only available release channel.`}),(0,Q.jsx)(c,{variant:`outlined`,leftIcon:t?(0,Q.jsx)(R,{className:`animate-spin`}):(0,Q.jsx)(ot,{}),disabled:n,onClick:r,children:`Opt in to Preview`})]})}function cn({status:e,isChangingChannel:t,onOptOut:n}){return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ln,{status:e}),(0,Q.jsx)(c,{variant:`outlined`,leftIcon:t?(0,Q.jsx)(R,{className:`animate-spin`}):(0,Q.jsx)(Qe,{}),disabled:t,onClick:n,children:`Switch back to Stable`})]})}function ln({status:e}){return(0,Q.jsxs)(`dl`,{className:`grid gap-3 text-body-medium-lighter sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Stable`}),(0,Q.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_stable_release?.version??`None`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Preview`}),(0,Q.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_preview_release?.version??`None`})]})]})}function un({open:e,isPending:t,previewVersion:n,onConfirm:r,onCancel:i}){return(0,Q.jsx)(E.Root,{open:e,onOpenChange:e=>!e&&i(),children:(0,Q.jsxs)(E.Content,{size:`md`,hideCloseButton:t,children:[(0,Q.jsxs)(E.Header,{children:[(0,Q.jsx)(E.Title,{icon:se,children:`Opt in to Preview`}),(0,Q.jsx)(E.Description,{children:`Preview releases may be unstable. A 90-day safety backup is taken before the image changes.`})]}),(0,Q.jsx)(E.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.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,Q.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,Q.jsx)(`li`,{children:`Create and verify a Preview safety backup.`}),(0,Q.jsxs)(`li`,{children:[`Switch to Preview image `,n??`latest`,`.`]}),(0,Q.jsx)(`li`,{children:`Run the normal upgrade path and wait for health.`})]})]})}),(0,Q.jsxs)(E.Footer,{children:[(0,Q.jsx)(c,{variant:`outlined`,disabled:t,onClick:i,children:`Cancel`}),(0,Q.jsx)(c,{variant:`primary`,disabled:t,leftIcon:t?(0,Q.jsx)(R,{className:`animate-spin`}):(0,Q.jsx)(ot,{}),onClick:r,children:t?`Switching...`:`Take Backup and Switch`})]})]})})}function dn({open:e,backups:t,mode:n,selectedSnapshotName:r,isPending:i,restoreModeDisabled:a,standardUpgradeAvailable:o,onModeChange:s,onSnapshotChange:l,onConfirm:u,onCancel:d}){return(0,Q.jsx)(E.Root,{open:e,onOpenChange:e=>!e&&d(),children:(0,Q.jsxs)(E.Content,{size:`md`,hideCloseButton:i,children:[(0,Q.jsxs)(E.Header,{children:[(0,Q.jsx)(E.Title,{icon:se,children:`Switch back to Stable`}),(0,Q.jsx)(E.Description,{children:`Choose how this assistant should leave the Preview channel.`})]}),(0,Q.jsx)(E.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(v,{value:n,onValueChange:s,disabled:i,"aria-label":`Stable channel return method`,children:[(0,Q.jsx)(_,{value:`restore_backup`,disabled:t.length===0,label:`Restore safety backup`,helperText:`Return to the Stable-channel data captured before Preview opt-in.`}),(0,Q.jsx)(_,{value:`standard_upgrade`,disabled:!o,label:`Switch to Stable without restoring backup`,helperText:o?`Keep the current data and directly switch to the Stable image.`:`Unavailable because the latest Stable release is older than this assistant's Preview release.`})]}),n===`restore_backup`&&t.length>0&&(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[`Safety backup`,(0,Q.jsx)(g,{value:r,onChange:l,disabled:i,options:t.map(e=>({value:e.snapshot_name,label:`${nn(e)} - ${tn(e.created_at)}`}))})]}),n===`restore_backup`&&t.length===0&&!o&&(0,Q.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,Q.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,Q.jsxs)(E.Footer,{children:[(0,Q.jsx)(c,{variant:`outlined`,disabled:i,onClick:d,children:`Cancel`}),(0,Q.jsx)(c,{variant:n===`standard_upgrade`?`danger`:`primary`,disabled:i||a||n===`standard_upgrade`&&!o,leftIcon:i?(0,Q.jsx)(R,{className:`animate-spin`}):(0,Q.jsx)(dt,{}),onClick:u,children:i?`Switching...`:`Switch to Stable`})]})]})})}function fn({assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:a}){let o=l(),s=f(lt()),d=s.data,p=!e.is_local,m=d?.plan_id===`pro`,h=f({...Ze(),enabled:m}),_=e.machine_size||`small`,v=ee(h.data?.max_machine_tier??null),y=(0,Z.useMemo)(()=>ne(v,_,(0,Q.jsx)(S,{tone:`positive`,children:`Current`})),[v,_]),b=h.data?.selected_storage_gib??null,[C,w]=(0,Z.useState)(!1),T=v.length>0?v[v.length-1]:null,[O,k]=(0,Z.useState)(null),A=O??T??_,[j,M]=(0,Z.useState)(null),[N,P]=(0,Z.useState)(null),F=De({onSuccess:(e,n)=>{D.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(ae(e,`Failed to resize assistant. Please try again.`))}});if(s.isError&&d==null)return(0,Q.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Q.jsx)(x,{tone:`error`,children:`Could not load your subscription. Please try again.`})});let I=m&&v.includes(A)&&A!==_?A:null,z=m&&b!=null&&!0,se=m&&v.length>0&&ie(_)<ie(v[v.length-1]),B=F.isPending||r,V=b==null?t?.disk?.totalMb??null:b*1024,H=t?.disk&&V!=null?{value:t.disk.usedMb,max:V,caption:`${X(t.disk.usedMb)} of ${X(V)}`}:null,U=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,W=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:`${X(t.memory.currentMb)} of ${X(t.memory.maxMb)}`}:null,ce=p?m?z?(0,Q.jsxs)(`button`,{type:`button`,disabled:B,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,Q.jsx)(oe,{className:`h-3.5 w-3.5`}),`Increase Storage`]}):(0,Q.jsx)(c,{variant:`ghost`,size:`compact`,disabled:B,onClick:()=>w(!0),children:`Resize`}):(0,Q.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>M(`storage`),children:`Resize`}):null,le=p?m?se?(0,Q.jsxs)(`button`,{type:`button`,disabled:B,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,Q.jsx)(oe,{className:`h-3.5 w-3.5`}),`Increase Size`]}):(0,Q.jsx)(c,{variant:`ghost`,size:`compact`,disabled:B,onClick:()=>w(!0),children:`Resize`}):(0,Q.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>M(`machine`),children:`Resize`}):null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,compactAccessory:!0,accessory:(0,Q.jsx)(c,{variant:`ghost`,size:`compact`,iconOnly:n||r?(0,Q.jsx)(R,{className:`animate-spin`}):(0,Q.jsx)(dt,{}),tooltip:r?`Applying resize…`:`Refresh resource metrics`,"aria-label":`Refresh resource metrics`,disabled:n||r,onClick:()=>void i()}),children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_2fr]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Q.jsx)(L,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Disk`})]}),ce]}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1 pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Storage`}),H?(0,Q.jsx)(gt,{value:H.value,max:H.max,caption:H.caption}):n?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(R,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Unavailable`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Q.jsx)(te,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Machine`}),(0,Q.jsx)(S,{tone:`neutral`,children:re[_]})]}),le]}),(0,Q.jsxs)(`div`,{className:`mt-auto grid grid-cols-2 gap-3 pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`CPU`}),U?(0,Q.jsx)(gt,{value:U.value,max:U.max,caption:U.caption}):n?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(R,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Memory`}),W?(0,Q.jsx)(gt,{value:W.value,max:W.max,caption:W.caption}):n?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(R,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,Q.jsx)(E.Root,{open:j!=null,onOpenChange:e=>{e||M(null)},children:(0,Q.jsxs)(E.Content,{size:`sm`,children:[(0,Q.jsxs)(E.Header,{children:[(0,Q.jsx)(E.Title,{children:`Upgrade to Pro`}),(0,Q.jsx)(E.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,Q.jsxs)(E.Footer,{children:[(0,Q.jsx)(c,{variant:`ghost`,onClick:()=>M(null),children:`Cancel`}),(0,Q.jsx)(c,{onClick:()=>{M(null),o(`${G.settings.billing}?adjust_plan=1`)},children:`Upgrade`})]})]})}),(0,Q.jsx)(E.Root,{open:C,onOpenChange:e=>{e||(w(!1),k(null),P(null))},children:(0,Q.jsxs)(E.Content,{size:`sm`,children:[(0,Q.jsxs)(E.Header,{children:[(0,Q.jsx)(E.Title,{icon:te,children:`Resize Assistant`}),(0,Q.jsx)(E.Description,{children:`Resize your assistant's compute and storage. Your assistant will briefly restart.`})]}),(0,Q.jsx)(E.Body,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[v.length===0?(0,Q.jsx)(x,{tone:`warning`,children:`No machine tier configured. Visit the community for help.`}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:`Machine Size`}),(0,Q.jsx)(g,{options:y,value:A,onChange:k,"aria-label":`Compute machine size`,"data-testid":`resize-machine-size`})]}),z?(0,Q.jsx)(x,{tone:`info`,children:`Storage will be expanded to ${b} GiB.`}):(0,Q.jsx)(x,{tone:`neutral`,children:`Storage will not change.`}),N&&(0,Q.jsx)(x,{tone:`error`,children:N})]})}),(0,Q.jsxs)(E.Footer,{className:`items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:[`Need more?`,` `,(0,Q.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,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(c,{variant:`ghost`,onClick:()=>{w(!1),k(null),P(null)},children:`Cancel`}),(0,Q.jsx)(c,{disabled:I==null&&!z||B,leftIcon:B?(0,Q.jsx)(R,{className:`animate-spin`}):void 0,onClick:()=>{P(null);let t={};I!=null&&(t.machine_size=I),z&&b!=null&&(t.storage_gib=b),F.mutate({path:{id:e.id},body:t})},children:N?`Retry`:`Apply`})]})]})]})})]})}function pn({assistantId:e}){let t=l(),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(c,{variant:`dangerOutline`,onClick:()=>r(!0),className:`shrink-0`,children:`Retire Assistant`}),(0,Q.jsx)(it,{open:n,isPending:i,onConfirm:async()=>{a(!0);let n=await Le(e);if(n.ok){r(!1),t(n.nextRoute,{replace:!0});return}D.error(n.error),a(!1),r(!1)},onCancel:()=>r(!1)})]})}var mn=`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 hn(){let e=Intl;if(typeof e.supportedValuesOf==`function`)try{let t=e.supportedValuesOf(`timeZone`);if(t.length>0)return[...t].sort()}catch{}return[...mn].sort()}function gn(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 _n(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour:`numeric`,minute:`2-digit`,hour12:!0}).format(new Date)}catch{return``}}function vn(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 yn({value:e,onChange:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null),l=(0,Z.useRef)(null),u=(0,Z.useMemo)(()=>hn().map(e=>gn(e)).filter(e=>e!==null),[]);(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>{a(n.trim().toLowerCase())},200);return()=>window.clearTimeout(e)},[n]),(0,Z.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,Z.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,Z.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,Q.jsxs)(`div`,{ref:c,className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 md:flex-row md:items-center md:justify-between md:gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Closest city`}),(0,Q.jsxs)(`div`,{className:`relative w-full md:max-w-[280px]`,children:[(0,Q.jsx)(C,{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,Q.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,Q.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,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-body-medium-default`,children:t.city}),t.region&&(0,Q.jsx)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:t.region})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(`span`,{children:_n(t.identifier)}),(0,Q.jsx)(`span`,{children:t.offsetLabel})]})]},t.identifier))})]})]}),(0,Q.jsx)(Yt,{}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Time zone`}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:vn(e)})]})]})}function bn(){let e=K.use.velvet(),[t,n]=(0,Z.useState)(()=>Je({velvetEnabled:e}));return(0,Z.useEffect)(()=>{n(Je({velvetEnabled:e}))},[e]),(0,Z.useEffect)(()=>a(`theme`,()=>{n(Je({velvetEnabled:e}))}),[e]),(0,Z.useEffect)(()=>{qe(t)},[t]),(0,Q.jsx)(Y,{title:`Theme`,children:(0,Q.jsx)(`div`,{className:`max-w-[360px]`,children:(0,Q.jsx)(T,{ariaLabel:`Theme`,value:t,onChange:e=>{n(e),Ue(e),qe(e)},items:[{value:`system`,label:`System`,icon:(0,Q.jsx)(Ge,{className:`h-4 w-4`})},{value:`light`,label:`Light`,icon:(0,Q.jsx)(Me,{className:`h-4 w-4`})},{value:`dark`,label:`Dark`,icon:(0,Q.jsx)(z,{className:`h-4 w-4`})},...e?[{value:`velvet`,label:`Velvet`,icon:(0,Q.jsx)(ft,{className:`h-4 w-4`})}]:[]]})})})}function xn(){let e=M.use.activeAssistantId(),[t,n]=(0,Z.useState)(()=>i(`timezone`,``)),a=(0,Z.useRef)(e);(0,Z.useEffect)(()=>{a.current=e},[e]);let s=(0,Z.useRef)(!1),c=(0,Z.useRef)(null),l=(0,Z.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,he.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,Z.useEffect)(()=>{l.current=u}),(0,Q.jsx)(Y,{title:`Timezone`,subtitle:`Used when displaying times and scheduling reminders.`,children:(0,Q.jsx)(yn,{value:t,onChange:e=>{n(e),r(`timezone`,e),u(e)}})})}function Sn(){let{assistant:e,assistantLoading:t,healthz:n,healthzLoading:r,healthzPolling:i,refetch:a,refetchUntilResized:o}=_t(),s=K.use.multiPlatformAssistant(),c=xe.use.settingsSleepPolicy(),u=ce(),d=l(),f=Ae(),p=Ae({platformHostedOnly:!0}),m=Ve(),h=et({assistantId:e?.id??null,enabled:p===`full`&&m}),g=e?.is_local&&!k()?null:e,_=A(),v=k()&&!!e&&!!_&&O(_);return(0,Z.useEffect)(()=>{!e||window.location.hash!==`#storage-resources`||requestAnimationFrame(()=>{document.getElementById(`storage-resources`)?.scrollIntoView({block:`start`})})},[e]),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[h.status&&h.mode!==`inactive`&&(0,Q.jsx)(Ne,{status:h.status,mode:h.mode,isAcknowledging:h.isAcknowledging,acknowledgeError:h.acknowledgeError?.message??null,onAcknowledge:()=>void h.acknowledge(),onReviewWorkspaceData:()=>void d(`${G.workspace}?sort=size`),onUpgradeStorage:p===`full`?()=>void d(`${G.settings.billing}?adjust_plan=1`):null}),(0,Q.jsx)(Y,{title:`General`,children:(0,Q.jsx)(vt,{assistant:g,assistantLoading:t,healthz:n,healthzLoading:r})}),u&&f===`full`&&(0,Q.jsx)(Mt,{assistant:m?g:null}),p===`full`&&e&&(0,Q.jsx)(fn,{assistant:e,healthz:n,healthzLoading:r,healthzPolling:i,refetch:a,refetchUntilResized:o}),p===`disabled`&&(0,Q.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Q.jsx)(J,{children:`Log in to the Vellum platform to manage compute resources.`})}),(0,Q.jsx)(bn,{}),(0,Q.jsx)(Ht,{}),j()&&(0,Q.jsx)(Jt,{}),p===`full`&&g&&(0,Q.jsxs)(Y,{title:`Software Updates`,children:[(0,Q.jsx)(Vt,{assistantId:g.id,currentVersion:n?.version??g.current_release_version??null,releaseChannel:g.release_channel,onUpgradeComplete:()=>{a()}}),(0,Q.jsx)(on,{assistantId:g.id,onComplete:()=>{a()}})]}),p===`disabled`&&(0,Q.jsx)(Y,{title:`Software Updates`,children:(0,Q.jsx)(J,{children:`Log in to the Vellum platform to manage software updates.`})}),(0,Q.jsx)(Gt,{}),p===`full`&&g&&c&&(0,Q.jsx)(Y,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Q.jsx)(Lt,{assistantId:g.id})}),p===`disabled`&&c&&(0,Q.jsx)(Y,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Q.jsx)(J,{children:`Log in to the Vellum platform to manage sleep policy.`})}),(0,Q.jsx)(xn,{}),(0,Q.jsx)($t,{}),s&&(0,Q.jsx)(Pt,{}),(f===`full`||v)&&g&&(0,Q.jsx)(Y,{variant:`danger`,title:`Retire Assistant`,subtitle:`Permanently retire this assistant and delete all associated data.`,children:(0,Q.jsx)(pn,{assistantId:g.id})}),f===`disabled`&&!v&&(0,Q.jsx)(Y,{variant:`danger`,title:`Retire Assistant`,subtitle:`Permanently retire this assistant and delete all associated data.`,children:(0,Q.jsx)(J,{children:`Log in to the Vellum platform to retire this assistant.`})}),(0,Q.jsx)(Ut,{})]})}export{Sn 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-B0wqOYKY.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-yOV5eJnU.js";import{c as _,l as v,n as y}from"./src-D6Nu2Lol.js";import{t as b}from"./confirm-dialog-DbNUkFt6.js";import{t as x}from"./notice-G5Imd5pC.js";import{t as S}from"./tag-BadGF3FB.js";import{t as C}from"./input-CwdmSRlD.js";import{t as w}from"./toggle-_vZlLDBV.js";import{n as T}from"./stat-square-B5tBfA4w.js";import{t as E}from"./modal-DX6UN7b0.js";import{n as D}from"./toast-DLWkiWW6.js";import{d as O,f as k,s as A}from"./local-mode-9ZkSq1Fr.js";import{t as j}from"./is-electron-BuSDabCt.js";import{n as M}from"./resolved-assistants-store-DMuRxkZC.js";import{t as N}from"./createLucideIcon-DIlBzeWM.js";import{t as P}from"./bell-CSP2EUlP.js";import{t as F}from"./chevron-right-HpmykQ8I.js";import{t as I}from"./circle-alert-C5TvMkJV.js";import{t as L}from"./hard-drive-C6sJQKXL.js";import{t as R}from"./loader-circle-CTs38Ovl.js";import{t as z}from"./moon-C0wLM1iN.js";import{a as ee,c as te,o as ne,r as re,s as ie,t as ae}from"./resize-errors-tz_Tui32.js";import{t as oe}from"./sparkles-B9QIWdq0.js";import{t as se}from"./triangle-alert-M_S_Pe8C.js";import{n as B,r as V,t as H}from"./api-errors-CwAGZ-xJ.js";import{K as U,_ as W,a as ce,b as le,g as ue,n as de,u as fe,x as pe,y as me}from"./auth-store-CrTf0uWL.js";import{t as he}from"./client.gen-Cuv6iN0E.js";import{S as ge,V as _e,Y as ve,j as ye}from"./sdk.gen-DRL3oRwz.js";import{a as G}from"./routes-BKwsRssF.js";import{t as K}from"./client-feature-flag-store-ivPVcKfH.js";import{n as q,t as be}from"./semver-DmouQEQK.js";import{t as xe}from"./assistant-feature-flag-store-D2CUHsmL.js";import{t as Se}from"./proxy-CQsxT9tJ.js";import{t as Ce}from"./use-reduced-motion-CXbk4fYO.js";import{Bn as we,Cr as Te,Dn as Ee,Dr as De,Fn as Oe,Ft as ke,It as Ae,J as je,Ji as Me,K as Ne,Ki as Pe,Ln as Fe,Mn as Ie,Mt as Le,Nn as Re,Or as ze,Pn as Be,Pt as Ve,Qi as He,Qr as Ue,Rn as We,Sa as Ge,Vr as Ke,Xr as qe,Zr as Je,Zt as Ye,_n as Xe,ar as Ze,ca as Qe,d as $e,et,f as tt,ho as nt,jr as rt,jt as it,l as at,la as ot,mo as st,s as ct,sr as lt,u as ut,ua as dt,v as J,za as ft,zn as pt}from"./index-BiN-6kWM.js";import{t as mt}from"./use-active-assistant-id-512RohBL.js";import{t as Y}from"./detail-card-CLwQ17AA.js";import{t as ht}from"./environment-store-Ck7wXCrL.js";import{i as gt,n as X,r as _t,t as vt}from"./assistant-status-panel-CMdqv7mF.js";var yt=N(`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`}]]),bt=N(`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`}]]),Z=e(s(),1),xt=ue,St=`Please choose a different handle.`;async function Ct(e,t){let{data:n,error:r,response:i}=await ye({path:{id:e},body:{handle:t},throwOnError:!1});if(!i)return{kind:`error`,message:V(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}=pe(r,`handle`,xt.taken);return{kind:`taken`,message:e}}if(i.status===400){let{code:e,message:t}=pe(r,`handle`,St);return{kind:`invalid`,code:e,message:t}}return{kind:`error`,message:V(r,i,`Failed to save handle.`)}}async function wt(e,t,n){let{data:r,error:i,response:a}=await ge({path:{assistant_id:e},query:{handle:t},signal:n,throwOnError:!1});if(B(a,i,`Failed to check handle availability.`),!a.ok||!r)throw new H(a.status,a.status===429?`Too many checks — try again in a moment.`:V(i,a,`Failed to check handle availability.`));return{available:r.available,code:r.code??null,message:r.message??null}}function Tt(e){return/\d{2,}$/.test(e)}var Q=m(),Et=300,Dt=1400;function Ot({initialHandle:e,inputLabel:t,helperText:n,idleHelperText:r,checkAvailable:i,save:a,onSaved:o,saveSuccessToast:s,fieldId:l}){let[u,d]=(0,Z.useState)(e),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(`idle`),[v,y]=(0,Z.useState)(null),b=Ce(),x=(0,Z.useRef)(null),S=(0,Z.useMemo)(()=>u.trim().toLowerCase(),[u]),w=S===e.toLowerCase();(0,Z.useEffect)(()=>{if(w||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)}},Et);return()=>{window.clearTimeout(t),e.abort()}},[S,w,i]);let T=(()=>{if(v)return v;if(f&&!f.available){let e=f.code;return f.message??(e?xt[e]:`Please choose a different handle.`)}return null})(),E=T?n:w?r??null:m?`Checking availability…`:f?.available?`Available.`:null,O=!w&&!m&&f?.available!==!1&&g!==`saving`,k=(0,Z.useCallback)(async()=>{if(!O)return;_(`saving`),y(null);let e=await a(S);if(e.kind===`ok`){_(`saved`),o(e.data),D.success(s),window.setTimeout(()=>_(`idle`),Dt);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),D.error(e.message)},[O,S,o,a,s]),A=(()=>{if(w&&u.length>0||u.length===0)return null;let e=m?`checking`:f?.available?`available`:f?.available===!1?`invalid`:null;return e?(0,Q.jsx)(je,{mode:`wait`,initial:!1,children:(0,Q.jsxs)(Se.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,Q.jsx)(R,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),e===`available`&&(0,Q.jsx)(nt,{className:`h-4 w-4 text-[var(--system-positive-strong)]`,"aria-label":`Available`}),e===`invalid`&&(0,Q.jsx)(I,{className:`h-4 w-4 text-[var(--system-negative-strong)]`,"aria-label":`Not available`})]},e)}):null})(),j=(()=>{switch(g){case`saving`:return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(R,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),`Saving…`]});case`saved`:return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(nt,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Saved`]});default:return`Save`}})();return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(C,{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,Q.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`}),(!w||g!==`idle`)&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(c,{variant:`primary`,size:`compact`,onClick:k,disabled:!O,"aria-live":`polite`,"data-testid":`${l}-save`,children:j})})]})}function kt({initial:e,onSaved:t}){let n=de.use.refreshSession(),r=Tt(e.username)?`Your handle was auto-generated at signup — pick one you like.`:void 0,i=(0,Z.useCallback)(async e=>await le({username:e}),[]),a=(0,Z.useCallback)((e,t)=>W(e,t),[]),o=(0,Z.useCallback)(e=>{t(e),n()},[t,n]);return(0,Q.jsx)(Ot,{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 At({assistant:e,onSaved:t}){let n=e.handle??``,r=f({...Xe({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,Z.useCallback)(async t=>await Ct(e.id,t),[e.id]),s=(0,Z.useCallback)((t,n)=>wt(e.id,t,n),[e.id]);return i?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(C,{label:`Assistant handle`,value:n,readOnly:!0,disabled:!0,leftIcon:(0,Q.jsx)(`span`,{className:`select-none font-mono text-[var(--content-tertiary)]`,"aria-hidden":!0,children:`@`}),fullWidth:!0,"data-testid":`assistant-handle-input`}),(0,Q.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,Q.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,Q.jsx)(Ot,{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 jt(){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-busy":!0,"aria-live":`polite`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`div`,{className:`h-3 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Q.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Q.jsx)(`div`,{className:`h-3 w-72 animate-pulse rounded bg-[var(--surface-muted)]`})]}),(0,Q.jsx)(`div`,{className:`h-9 w-full animate-pulse rounded-md bg-[var(--surface-muted)]`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`div`,{className:`h-3 w-60 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,Q.jsx)(`div`,{className:`h-7 w-16 animate-pulse rounded-md bg-[var(--surface-muted)]`})]}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Loading your profile…`})]})}function Mt({assistant:e}={}){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(null),a=Ce(),[o,s]=(0,Z.useState)(e??null);return(0,Z.useEffect)(()=>{s(e??null)},[e]),(0,Z.useEffect)(()=>{let e=!1;return me().then(t=>{e||n(t)}).catch(t=>{e||i(t instanceof Error?t.message:`Failed to load profile.`)}),()=>{e=!0}},[]),(0,Q.jsx)(Y,{title:`Profile`,subtitle:`Manage your user and assistant public handles.`,children:r?(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:r}):t?(0,Q.jsxs)(Se.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,Q.jsx)(kt,{initial:t,onSaved:n}),o&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`border-t border-[var(--border-subtle)]`}),(0,Q.jsx)(At,{assistant:o,onSaved:s})]})]}):(0,Q.jsx)(jt,{})})}var Nt=Ee({query:{hosting:`platform`}});function Pt(){let e=mt(),t=f(Nt),n=t.data?.results??[];return t.isPending||n.length<2?null:(0,Q.jsx)(Y,{title:`Switch Assistant`,subtitle:`Choose which assistant is active for this account.`,children:(0,Q.jsx)(`div`,{className:`space-y-2`,children:n.map(t=>{let n=t.id===e;return(0,Q.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,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(Ge,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:t.name||`Unnamed`}),t.status!==`active`&&(0,Q.jsx)(S,{tone:`warning`,children:t.status})]})})]}),(0,Q.jsx)(`div`,{className:`shrink-0`,children:n?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-body-small-default text-[var(--system-positive-default)]`,children:[(0,Q.jsx)(nt,{className:`h-4 w-4`}),`Active`]}):(0,Q.jsx)(c,{variant:`outlined`,size:`compact`,disabled:t.status!==`active`,onClick:()=>{U(t.id),D.success(`Switched active assistant.`)},children:`Switch`})})]},t.id)})})})}var Ft=[{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 It(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 Lt({assistantId:e}){let t=d(),n=ht.use.isNonProduction(),r=(0,Z.useMemo)(()=>Ft.filter(e=>!e.devOnly||n),[n]),{data:i,isLoading:a,isError:o}=f(pt({path:{id:e}})),s=(0,Z.useMemo)(()=>i?.idle_timeout_seconds??259200,[i]),[l,u]=(0,Z.useState)(null),p=l??s,m=l!==null,h=ze({onSuccess:()=>{D.success(`Sleep policy saved.`),u(null),t.invalidateQueries({queryKey:we({path:{id:e}})})},onError:()=>{D.error(`Failed to save sleep policy. Please try again.`)}});return a?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(R,{className:`h-4 w-4 animate-spin`}),`Loading sleep settings...`]}):o?(0,Q.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,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:`Idle timeout`}),(0,Q.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,Q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:r.map(e=>(0,Q.jsx)(c,{variant:`outlined`,active:p===e.seconds,onClick:()=>u(e.seconds),children:e.label},e.seconds))}),(0,Q.jsxs)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:[`Current: `,It(p)]})]}),m&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(c,{variant:`primary`,leftIcon:h.isPending?(0,Q.jsx)(R,{className:`animate-spin`}):void 0,onClick:()=>h.mutate({path:{id:e},body:{idle_timeout_seconds:p}}),disabled:h.isPending,children:`Save`}),(0,Q.jsx)(c,{variant:`outlined`,onClick:()=>u(null),disabled:h.isPending,children:`Cancel`})]})]})}function Rt(e,t,n){let r=[e.version];return e.version===n&&r.push(`(latest)`),t&&e.version===t&&r.push(`(current)`),r.join(` `)}var zt=3e3;function Bt(e,t){return t&&e===`preview`?`preview`:`stable`}function Vt({assistantId:e,currentVersion:t,releaseChannel:n,onUpgradeComplete:r}){let i=xe.use.rollbackEnabled(),a=K.use.previewChannel(),o=d(),s=Bt(n,a),l=s===`preview`,[u,m]=(0,Z.useState)(!1),h=(0,Z.useRef)(null),[_,v]=(0,Z.useState)(null),[y,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.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),D.success(S?`Rollback complete — assistant is healthy.`:`Update complete — assistant is healthy.`),r?.()}),!1):zt;f({...Fe({path:{id:e}}),refetchInterval:u?e=>E(e.state.data?.current_release_version):!1});let{data:O,isLoading:k}=f(Te({query:{channel:s}})),A=O?.find(e=>e.is_stable!==!1)??O?.[0],j=_??A?.version??null,M=(0,Z.useMemo)(()=>{if(!i||!j||!t)return!1;let e=q(j),n=q(t);return!e||!n?!1:be(e,n)<0},[i,j,t]),N=(0,Z.useMemo)(()=>{if(!j)return!1;if(!t)return!0;let e=q(j),n=q(t);if(!e||!n)return j!==t;let r=be(e,n);return i?r!==0:r>0},[i,j,t]),P=p({mutationFn:async t=>{let{data:n}=await ve({path:{id:e},body:t,throwOnError:!0});return n}}),F=p({mutationFn:async t=>{let{data:n}=await _e({path:{id:e},body:t,throwOnError:!0});return n}});return(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`Current`}),(0,Q.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:t??`—`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 md:contents`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:l?`Preview release`:N?M?`Rollback to`:`Update to`:`Selected`}),(0,Q.jsx)(`span`,{className:`block min-w-0`,children:k?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(R,{className:`h-3 w-3 animate-spin`}),`Loading...`]}):O&&O.length>0?i?(0,Q.jsx)(g,{value:j??``,onChange:e=>v(e===A?.version?null:e),disabled:u||P.isPending||F.isPending,options:O.map(e=>({value:e.version,label:Rt(e,t,A?.version)}))}):(0,Q.jsx)(`span`,{className:`block min-w-0 break-all text-body-medium-lighter text-[var(--content-default)]`,children:A?Rt(A,t,A.version):`—`}):`No releases available`})]})]}),(0,Q.jsx)(c,{variant:M?`outlined`:`primary`,className:`min-w-[160px]`,leftIcon:P.isPending||F.isPending||u?(0,Q.jsx)(R,{className:`animate-spin`}):(0,Q.jsx)(dt,{}),onClick:()=>x(!0),disabled:!N||P.isPending||F.isPending||u||k||!O?.length,children:u?S?`Rolling back...`:`Updating...`:M?`Rollback`:l?`Update preview`:`Update`}),l&&(0,Q.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Using Preview releases.`,` `,(0,Q.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,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-positive-strong)]`,children:w??`You are already on this version.`}),(0,Q.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,D.success(e.detail||`Rollback to ${t} initiated.`)}else{let e=await P.mutateAsync({version:t});if(e.detail?.includes(`Already on the latest`)){D.warning(e.detail);return}h.current=e.version??t??null,D.success(e.detail||`Update to ${e.version??t??`latest`} initiated.`)}C(M),m(!0),o.invalidateQueries({queryKey:We({path:{id:e}})})}catch{D.error(M?`Failed to trigger rollback. Please try again.`:`Failed to trigger update. Please try again.`)}},onCancel:()=>x(!1)})]})}function Ht(){let e=tt.useValue();if(Ye())return null;let t=ut()?`Cmd`:`Ctrl`;return(0,Q.jsx)(Y,{title:`Composer`,children:(0,Q.jsx)(w,{checked:e,onChange:tt.save,label:`Send with ${t}+Enter`,helperText:`When enabled, Enter inserts a new line and ${t}+Enter sends.`})})}function Ut(){let e=Ae({platformHostedOnly:!0}),t=ke(),n=de.use.user()?.id??null,r=de.use.logout(),[i,a]=(0,Z.useState)(!1),o=rt({onSuccess:async()=>{D.success(`Account deletion requested. You will be logged out shortly.`),fe(n),await r(),Ke(G.account.login)},onError:()=>{D.error(`Failed to request account deletion. Please try again.`)}}),s=e===`full`&&t;return(0,Z.useEffect)(()=>{s&&i&&a(!1)},[s,i]),e===`gated`?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{title:`Delete Account`,subtitle:`Permanently delete your account and all associated data.`,variant:`danger`,children:e===`disabled`?(0,Q.jsx)(J,{children:`Log in to the Vellum platform to delete your account.`}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(c,{variant:`dangerOutline`,onClick:()=>a(!0),disabled:o.isPending||s,className:`self-start`,children:`Delete My Account`}),s&&(0,Q.jsx)(R,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`})]})}),(0,Q.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 Wt({title:e,subtitle:t,benefits:n,ctaLabel:r,ctaLeftIcon:i,onAction:a}){return(0,Q.jsx)(Y,{title:e,subtitle:t,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`ul`,{className:`space-y-3`,children:n.map(({icon:e,text:t})=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md`,style:{background:`var(--surface-base)`},children:(0,Q.jsx)(e,{size:14,style:{color:`var(--content-secondary)`},"aria-hidden":!0})}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]},t))}),(0,Q.jsx)(c,{variant:`primary`,size:`regular`,leftIcon:i,onClick:a,className:`self-start`,children:r})]})})}function Gt(){return $e()?(0,Q.jsx)(Wt,{title:`Get the iOS App`,subtitle:`The Vellum iOS app gives you a native experience.`,benefits:[{icon:P,text:`Push notifications`},{icon:yt,text:`Biometric login`},{icon:bt,text:`Native haptics`},{icon:He,text:`Home screen access`}],ctaLabel:`Download`,ctaLeftIcon:(0,Q.jsx)(He,{size:16}),onAction:()=>{at(),ct()}}):null}async function Kt(){if(!j())return!1;let e=window.vellum;return e?.launchAtLogin?e.launchAtLogin.get():!1}async function qt(e){if(!j())return;let t=window.vellum;t?.launchAtLogin&&await t.launchAtLogin.set(e)}function Jt(){let[e,t]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{Kt().then(t)},[]);let n=async e=>{t(e);try{await qt(e)}catch{t(!e)}};return(0,Q.jsx)(Y,{title:`Launch at Login`,subtitle:`Automatically start Vellum when you log in to your Mac.`,children:(0,Q.jsx)(w,{checked:e,onChange:e=>void n(e),"aria-label":`Launch at Login`})})}function Yt({className:e}){return(0,Q.jsx)(`div`,{role:`presentation`,className:h(`h-px w-full bg-[var(--border-base)]`,e)})}var $=[`youtube.com`,`youtu.be`,`vimeo.com`,`loom.com`];function Xt(e){try{let t=JSON.parse(e);if(Array.isArray(t))return t.filter(e=>typeof e==`string`)}catch{}return[...$]}function Zt(){return n(`mediaEmbedsEnabled`,!0)}function Qt(){let e=i(`mediaEmbedDomains`,``);return e?Xt(e):[...$]}function $t(){let[e,n]=(0,Z.useState)(()=>Zt()),[i,a]=(0,Z.useState)(()=>Qt()),[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(``),d=(0,Z.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([...$])},_=i.length===$.length&&i.every((e,t)=>e===$[t]);return(0,Q.jsxs)(Y,{title:`Media Embeds`,subtitle:`Automatically embed images, videos, and other media shared in chat messages.`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:`Auto Media Embeds`}),(0,Q.jsx)(w,{checked:e,onChange:f})]}),e&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(Yt,{})}),(0,Q.jsxs)(c,{type:`button`,variant:`ghost`,onClick:()=>s(e=>!e),className:`mt-4 w-full justify-between px-3`,"aria-expanded":o,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[o?(0,Q.jsx)(st,{className:`h-4 w-4`,"aria-hidden":!0}):(0,Q.jsx)(F,{className:`h-4 w-4`,"aria-hidden":!0}),`Video Domain Allowlist`]}),(0,Q.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[i.length,` domain`,i.length===1?``:`s`]})]}),o&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Q.jsx)(C,{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,Q.jsx)(c,{variant:`primary`,size:`compact`,onClick:m,disabled:!d,children:`Add`})]}),i.length>0&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,onClick:g,disabled:_,tintColor:`var(--content-tertiary)`,children:`Reset to Defaults`})}),i.length>0&&(0,Q.jsx)(`ul`,{className:`space-y-2`,children:i.map(e=>(0,Q.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,Q.jsx)(`span`,{className:`font-mono text-[var(--content-default)]`,children:e}),(0,Q.jsx)(c,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(Pe,{}),onClick:()=>h(e),"aria-label":`Remove ${e}`})]},e))})]})]})]})}function en(e){return e===`preview`?`preview`:`stable`}function tn(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 nn(e){return e.source_release_version?`Stable ${e.source_release_version}`:e.snapshot_name}function rn(e){return e.filter(e=>e.ready_to_use)}function an(e){return e?.feature_enabled===!1}function on({assistantId:e,onComplete:t}){let n=K.use.previewChannel(),r=d(),[i,a]=(0,Z.useState)(),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,m]=(0,Z.useState)(`restore_backup`),[h,g]=(0,Z.useState)(``),_=Be({path:{assistant_id:e}}),v=Oe({path:{assistant_id:e}}),b=We({path:{id:e}}),{data:C,isLoading:w,isError:T}=f({..._,enabled:n,retry:!1}),E=C?.preview_backups??[],O=(0,Z.useMemo)(()=>rn(E),[E]),k=O[0],A=O.find(e=>e.snapshot_name===h)??k,j=()=>{r.invalidateQueries({queryKey:v}),r.invalidateQueries({queryKey:b}),t?.()},M=p(Ie()),N=p(Re()),P=en(C?.current_channel),F=M.isPending||N.isPending,I=F||an(C)||!C?.latest_preview_release,L=u===`restore_backup`&&!A;if((0,Z.useEffect)(()=>{a(P===`preview`?`release-channel`:void 0)},[P]),!n)return null;let z=C?.standard_upgrade_available??!1;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(y.Root,{type:`single`,collapsible:!0,value:i,onValueChange:e=>a(e||void 0),className:`mt-5 border-t border-[var(--border-base)] pt-5`,children:(0,Q.jsxs)(y.Item,{value:`release-channel`,id:`preview-release-channel`,children:[(0,Q.jsxs)(y.Trigger,{className:`group justify-between gap-3`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`Release Channel`}),C&&(0,Q.jsx)(S,{tone:P===`preview`?`warning`:`neutral`,children:P===`preview`?`Preview`:`Stable`})]}),(0,Q.jsx)(st,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(y.Content,{children:(0,Q.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[w&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(R,{className:`h-4 w-4 animate-spin`}),`Loading release channel...`]}),T&&(0,Q.jsx)(x,{tone:`error`,title:`Could not load release channel status`,children:`Refresh this page before changing release channels.`}),C&&(0,Q.jsxs)(Q.Fragment,{children:[an(C)&&(0,Q.jsx)(x,{tone:`neutral`,title:`Preview channel is unavailable`,children:`The Preview channel is not enabled for this assistant.`}),P===`stable`?(0,Q.jsx)(sn,{status:C,isChangingChannel:F,optInDisabled:I,onOptIn:()=>s(!0)}):(0,Q.jsx)(cn,{status:C,isChangingChannel:F,onOptOut:()=>{let e=k;g(e?.snapshot_name??``),m(e?`restore_backup`:z?`standard_upgrade`:`restore_backup`),l(!0)}})]})]})})]})}),(0,Q.jsx)(un,{open:o,isPending:M.isPending,previewVersion:C?.latest_preview_release?.version,onConfirm:async()=>{try{let t=await M.mutateAsync({path:{assistant_id:e}});D.success(t.detail||`Preview channel enabled.`),s(!1),j()}catch(e){D.error(V(e,void 0,`Could not enable Preview channel.`))}},onCancel:()=>s(!1)}),(0,Q.jsx)(dn,{open:c,backups:O,mode:u,selectedSnapshotName:A?.snapshot_name??``,isPending:N.isPending,restoreModeDisabled:L,standardUpgradeAvailable:z,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`}});D.success(t.detail||`Stable channel enabled.`),l(!1),j()}catch(e){D.error(V(e,void 0,`Could not switch to Stable.`))}},onCancel:()=>l(!1)})]})}function sn({status:e,isChangingChannel:t,optInDisabled:n,onOptIn:r}){return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ln,{status:e}),!e.latest_preview_release&&(0,Q.jsx)(x,{tone:`neutral`,title:`No Preview release is available`,children:`Stable remains the only available release channel.`}),(0,Q.jsx)(c,{variant:`outlined`,leftIcon:t?(0,Q.jsx)(R,{className:`animate-spin`}):(0,Q.jsx)(ot,{}),disabled:n,onClick:r,children:`Opt in to Preview`})]})}function cn({status:e,isChangingChannel:t,onOptOut:n}){return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(ln,{status:e}),(0,Q.jsx)(c,{variant:`outlined`,leftIcon:t?(0,Q.jsx)(R,{className:`animate-spin`}):(0,Q.jsx)(Qe,{}),disabled:t,onClick:n,children:`Switch back to Stable`})]})}function ln({status:e}){return(0,Q.jsxs)(`dl`,{className:`grid gap-3 text-body-medium-lighter sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Stable`}),(0,Q.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_stable_release?.version??`None`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-[var(--content-tertiary)]`,children:`Latest Preview`}),(0,Q.jsx)(`dd`,{className:`break-all text-[var(--content-default)]`,children:e.latest_preview_release?.version??`None`})]})]})}function un({open:e,isPending:t,previewVersion:n,onConfirm:r,onCancel:i}){return(0,Q.jsx)(E.Root,{open:e,onOpenChange:e=>!e&&i(),children:(0,Q.jsxs)(E.Content,{size:`md`,hideCloseButton:t,children:[(0,Q.jsxs)(E.Header,{children:[(0,Q.jsx)(E.Title,{icon:se,children:`Opt in to Preview`}),(0,Q.jsx)(E.Description,{children:`Preview releases may be unstable. A 90-day safety backup is taken before the image changes.`})]}),(0,Q.jsx)(E.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.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,Q.jsxs)(`ol`,{className:`list-decimal space-y-2 pl-5 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,Q.jsx)(`li`,{children:`Create and verify a Preview safety backup.`}),(0,Q.jsxs)(`li`,{children:[`Switch to Preview image `,n??`latest`,`.`]}),(0,Q.jsx)(`li`,{children:`Run the normal upgrade path and wait for health.`})]})]})}),(0,Q.jsxs)(E.Footer,{children:[(0,Q.jsx)(c,{variant:`outlined`,disabled:t,onClick:i,children:`Cancel`}),(0,Q.jsx)(c,{variant:`primary`,disabled:t,leftIcon:t?(0,Q.jsx)(R,{className:`animate-spin`}):(0,Q.jsx)(ot,{}),onClick:r,children:t?`Switching...`:`Take Backup and Switch`})]})]})})}function dn({open:e,backups:t,mode:n,selectedSnapshotName:r,isPending:i,restoreModeDisabled:a,standardUpgradeAvailable:o,onModeChange:s,onSnapshotChange:l,onConfirm:u,onCancel:d}){return(0,Q.jsx)(E.Root,{open:e,onOpenChange:e=>!e&&d(),children:(0,Q.jsxs)(E.Content,{size:`md`,hideCloseButton:i,children:[(0,Q.jsxs)(E.Header,{children:[(0,Q.jsx)(E.Title,{icon:se,children:`Switch back to Stable`}),(0,Q.jsx)(E.Description,{children:`Choose how this assistant should leave the Preview channel.`})]}),(0,Q.jsx)(E.Body,{children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(v,{value:n,onValueChange:s,disabled:i,"aria-label":`Stable channel return method`,children:[(0,Q.jsx)(_,{value:`restore_backup`,disabled:t.length===0,label:`Restore safety backup`,helperText:`Return to the Stable-channel data captured before Preview opt-in.`}),(0,Q.jsx)(_,{value:`standard_upgrade`,disabled:!o,label:`Switch to Stable without restoring backup`,helperText:o?`Keep the current data and directly switch to the Stable image.`:`Unavailable because the latest Stable release is older than this assistant's Preview release.`})]}),n===`restore_backup`&&t.length>0&&(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1 text-body-medium-default text-[var(--content-secondary)]`,children:[`Safety backup`,(0,Q.jsx)(g,{value:r,onChange:l,disabled:i,options:t.map(e=>({value:e.snapshot_name,label:`${nn(e)} - ${tn(e.created_at)}`}))})]}),n===`restore_backup`&&t.length===0&&!o&&(0,Q.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,Q.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,Q.jsxs)(E.Footer,{children:[(0,Q.jsx)(c,{variant:`outlined`,disabled:i,onClick:d,children:`Cancel`}),(0,Q.jsx)(c,{variant:n===`standard_upgrade`?`danger`:`primary`,disabled:i||a||n===`standard_upgrade`&&!o,leftIcon:i?(0,Q.jsx)(R,{className:`animate-spin`}):(0,Q.jsx)(dt,{}),onClick:u,children:i?`Switching...`:`Switch to Stable`})]})]})})}function fn({assistant:e,healthz:t,healthzLoading:n,healthzPolling:r,refetch:i,refetchUntilResized:a}){let o=l(),s=f(lt()),d=s.data,p=!e.is_local,m=d?.plan_id===`pro`,h=f({...Ze(),enabled:m}),_=e.machine_size||`small`,v=ee(h.data?.max_machine_tier??null),y=(0,Z.useMemo)(()=>ne(v,_,(0,Q.jsx)(S,{tone:`positive`,children:`Current`})),[v,_]),b=h.data?.selected_storage_gib??null,[C,w]=(0,Z.useState)(!1),T=v.length>0?v[v.length-1]:null,[O,k]=(0,Z.useState)(null),A=O??T??_,[j,M]=(0,Z.useState)(null),[N,P]=(0,Z.useState)(null),F=De({onSuccess:(e,n)=>{D.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(ae(e,`Failed to resize assistant. Please try again.`))}});if(s.isError&&d==null)return(0,Q.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Q.jsx)(x,{tone:`error`,children:`Could not load your subscription. Please try again.`})});let I=m&&v.includes(A)&&A!==_?A:null,z=m&&b!=null&&!0,se=m&&v.length>0&&ie(_)<ie(v[v.length-1]),B=F.isPending||r,V=b==null?t?.disk?.totalMb??null:b*1024,H=t?.disk&&V!=null?{value:t.disk.usedMb,max:V,caption:`${X(t.disk.usedMb)} of ${X(V)}`}:null,U=t?.cpu?{value:t.cpu.currentPercent,max:100,caption:`${t.cpu.currentPercent.toFixed(1)}%`}:null,W=t?.memory?{value:t.memory.currentMb,max:t.memory.maxMb,caption:`${X(t.memory.currentMb)} of ${X(t.memory.maxMb)}`}:null,ce=p?m?z?(0,Q.jsxs)(`button`,{type:`button`,disabled:B,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,Q.jsx)(oe,{className:`h-3.5 w-3.5`}),`Increase Storage`]}):(0,Q.jsx)(c,{variant:`ghost`,size:`compact`,disabled:B,onClick:()=>w(!0),children:`Resize`}):(0,Q.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>M(`storage`),children:`Resize`}):null,le=p?m?se?(0,Q.jsxs)(`button`,{type:`button`,disabled:B,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,Q.jsx)(oe,{className:`h-3.5 w-3.5`}),`Increase Size`]}):(0,Q.jsx)(c,{variant:`ghost`,size:`compact`,disabled:B,onClick:()=>w(!0),children:`Resize`}):(0,Q.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>M(`machine`),children:`Resize`}):null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,compactAccessory:!0,accessory:(0,Q.jsx)(c,{variant:`ghost`,size:`compact`,iconOnly:n||r?(0,Q.jsx)(R,{className:`animate-spin`}):(0,Q.jsx)(dt,{}),tooltip:r?`Applying resize…`:`Refresh resource metrics`,"aria-label":`Refresh resource metrics`,disabled:n||r,onClick:()=>void i()}),children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_2fr]`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Q.jsx)(L,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Disk`})]}),ce]}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1 pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Storage`}),H?(0,Q.jsx)(gt,{value:H.value,max:H.max,caption:H.caption}):n?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(R,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Unavailable`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:(0,Q.jsx)(te,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Machine`}),(0,Q.jsx)(S,{tone:`neutral`,children:re[_]})]}),le]}),(0,Q.jsxs)(`div`,{className:`mt-auto grid grid-cols-2 gap-3 pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`CPU`}),U?(0,Q.jsx)(gt,{value:U.value,max:U.max,caption:U.caption}):n?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(R,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`Memory`}),W?(0,Q.jsx)(gt,{value:W.value,max:W.max,caption:W.caption}):n?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:(0,Q.jsx)(R,{className:`h-3 w-3 animate-spin`})}):(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)]`,children:`—`})]})]})]})]})}),(0,Q.jsx)(E.Root,{open:j!=null,onOpenChange:e=>{e||M(null)},children:(0,Q.jsxs)(E.Content,{size:`sm`,children:[(0,Q.jsxs)(E.Header,{children:[(0,Q.jsx)(E.Title,{children:`Upgrade to Pro`}),(0,Q.jsx)(E.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,Q.jsxs)(E.Footer,{children:[(0,Q.jsx)(c,{variant:`ghost`,onClick:()=>M(null),children:`Cancel`}),(0,Q.jsx)(c,{onClick:()=>{M(null),o(`${G.settings.billing}?adjust_plan=1`)},children:`Upgrade`})]})]})}),(0,Q.jsx)(E.Root,{open:C,onOpenChange:e=>{e||(w(!1),k(null),P(null))},children:(0,Q.jsxs)(E.Content,{size:`sm`,children:[(0,Q.jsxs)(E.Header,{children:[(0,Q.jsx)(E.Title,{icon:te,children:`Resize Assistant`}),(0,Q.jsx)(E.Description,{children:`Resize your assistant's compute and storage. Your assistant will briefly restart.`})]}),(0,Q.jsx)(E.Body,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[v.length===0?(0,Q.jsx)(x,{tone:`warning`,children:`No machine tier configured. Visit the community for help.`}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:`Machine Size`}),(0,Q.jsx)(g,{options:y,value:A,onChange:k,"aria-label":`Compute machine size`,"data-testid":`resize-machine-size`})]}),z?(0,Q.jsx)(x,{tone:`info`,children:`Storage will be expanded to ${b} GiB.`}):(0,Q.jsx)(x,{tone:`neutral`,children:`Storage will not change.`}),N&&(0,Q.jsx)(x,{tone:`error`,children:N})]})}),(0,Q.jsxs)(E.Footer,{className:`items-center justify-between`,children:[(0,Q.jsxs)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:[`Need more?`,` `,(0,Q.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,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(c,{variant:`ghost`,onClick:()=>{w(!1),k(null),P(null)},children:`Cancel`}),(0,Q.jsx)(c,{disabled:I==null&&!z||B,leftIcon:B?(0,Q.jsx)(R,{className:`animate-spin`}):void 0,onClick:()=>{P(null);let t={};I!=null&&(t.machine_size=I),z&&b!=null&&(t.storage_gib=b),F.mutate({path:{id:e.id},body:t})},children:N?`Retry`:`Apply`})]})]})]})})]})}function pn({assistantId:e}){let t=l(),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(c,{variant:`dangerOutline`,onClick:()=>r(!0),className:`shrink-0`,children:`Retire Assistant`}),(0,Q.jsx)(it,{open:n,isPending:i,onConfirm:async()=>{a(!0);let n=await Le(e);if(n.ok){r(!1),t(n.nextRoute,{replace:!0});return}D.error(n.error),a(!1),r(!1)},onCancel:()=>r(!1)})]})}var mn=`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 hn(){let e=Intl;if(typeof e.supportedValuesOf==`function`)try{let t=e.supportedValuesOf(`timeZone`);if(t.length>0)return[...t].sort()}catch{}return[...mn].sort()}function gn(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 _n(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,hour:`numeric`,minute:`2-digit`,hour12:!0}).format(new Date)}catch{return``}}function vn(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 yn({value:e,onChange:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null),l=(0,Z.useRef)(null),u=(0,Z.useMemo)(()=>hn().map(e=>gn(e)).filter(e=>e!==null),[]);(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>{a(n.trim().toLowerCase())},200);return()=>window.clearTimeout(e)},[n]),(0,Z.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,Z.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,Z.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,Q.jsxs)(`div`,{ref:c,className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 md:flex-row md:items-center md:justify-between md:gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Closest city`}),(0,Q.jsxs)(`div`,{className:`relative w-full md:max-w-[280px]`,children:[(0,Q.jsx)(C,{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,Q.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,Q.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,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-body-medium-default`,children:t.city}),t.region&&(0,Q.jsx)(`div`,{className:`truncate text-body-small-default text-[var(--content-tertiary)]`,children:t.region})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(`span`,{children:_n(t.identifier)}),(0,Q.jsx)(`span`,{children:t.offsetLabel})]})]},t.identifier))})]})]}),(0,Q.jsx)(Yt,{}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Time zone`}),(0,Q.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:vn(e)})]})]})}function bn(){let e=K.use.velvet(),[t,n]=(0,Z.useState)(()=>Je({velvetEnabled:e}));return(0,Z.useEffect)(()=>{n(Je({velvetEnabled:e}))},[e]),(0,Z.useEffect)(()=>a(`theme`,()=>{n(Je({velvetEnabled:e}))}),[e]),(0,Z.useEffect)(()=>{qe(t)},[t]),(0,Q.jsx)(Y,{title:`Theme`,children:(0,Q.jsx)(`div`,{className:`max-w-[360px]`,children:(0,Q.jsx)(T,{ariaLabel:`Theme`,value:t,onChange:e=>{n(e),Ue(e),qe(e)},items:[{value:`system`,label:`System`,icon:(0,Q.jsx)(Ge,{className:`h-4 w-4`})},{value:`light`,label:`Light`,icon:(0,Q.jsx)(Me,{className:`h-4 w-4`})},{value:`dark`,label:`Dark`,icon:(0,Q.jsx)(z,{className:`h-4 w-4`})},...e?[{value:`velvet`,label:`Velvet`,icon:(0,Q.jsx)(ft,{className:`h-4 w-4`})}]:[]]})})})}function xn(){let e=M.use.activeAssistantId(),[t,n]=(0,Z.useState)(()=>i(`timezone`,``)),a=(0,Z.useRef)(e);(0,Z.useEffect)(()=>{a.current=e},[e]);let s=(0,Z.useRef)(!1),c=(0,Z.useRef)(null),l=(0,Z.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,he.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,Z.useEffect)(()=>{l.current=u}),(0,Q.jsx)(Y,{title:`Timezone`,subtitle:`Used when displaying times and scheduling reminders.`,children:(0,Q.jsx)(yn,{value:t,onChange:e=>{n(e),r(`timezone`,e),u(e)}})})}function Sn(){let{assistant:e,assistantLoading:t,healthz:n,healthzLoading:r,healthzPolling:i,refetch:a,refetchUntilResized:o}=_t(),s=K.use.multiPlatformAssistant(),c=xe.use.settingsSleepPolicy(),u=ce(),d=l(),f=Ae(),p=Ae({platformHostedOnly:!0}),m=Ve(),h=et({assistantId:e?.id??null,enabled:p===`full`&&m}),g=e?.is_local&&!k()?null:e,_=A(),v=k()&&!!e&&!!_&&O(_);return(0,Z.useEffect)(()=>{!e||window.location.hash!==`#storage-resources`||requestAnimationFrame(()=>{document.getElementById(`storage-resources`)?.scrollIntoView({block:`start`})})},[e]),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[h.status&&h.mode!==`inactive`&&(0,Q.jsx)(Ne,{status:h.status,mode:h.mode,isAcknowledging:h.isAcknowledging,acknowledgeError:h.acknowledgeError?.message??null,onAcknowledge:()=>void h.acknowledge(),onReviewWorkspaceData:()=>void d(`${G.workspace}?sort=size`),onUpgradeStorage:p===`full`?()=>void d(`${G.settings.billing}?adjust_plan=1`):null}),(0,Q.jsx)(Y,{title:`General`,children:(0,Q.jsx)(vt,{assistant:g,assistantLoading:t,healthz:n,healthzLoading:r})}),u&&f===`full`&&(0,Q.jsx)(Mt,{assistant:m?g:null}),p===`full`&&e&&(0,Q.jsx)(fn,{assistant:e,healthz:n,healthzLoading:r,healthzPolling:i,refetch:a,refetchUntilResized:o}),p===`disabled`&&(0,Q.jsx)(Y,{id:`storage-resources`,title:`Compute & Resources`,subtitle:`Monitor resource usage and manage your assistant's compute profile.`,children:(0,Q.jsx)(J,{children:`Log in to the Vellum platform to manage compute resources.`})}),(0,Q.jsx)(bn,{}),(0,Q.jsx)(Ht,{}),j()&&(0,Q.jsx)(Jt,{}),p===`full`&&g&&(0,Q.jsxs)(Y,{title:`Software Updates`,children:[(0,Q.jsx)(Vt,{assistantId:g.id,currentVersion:n?.version??g.current_release_version??null,releaseChannel:g.release_channel,onUpgradeComplete:()=>{a()}}),(0,Q.jsx)(on,{assistantId:g.id,onComplete:()=>{a()}})]}),p===`disabled`&&(0,Q.jsx)(Y,{title:`Software Updates`,children:(0,Q.jsx)(J,{children:`Log in to the Vellum platform to manage software updates.`})}),(0,Q.jsx)(Gt,{}),p===`full`&&g&&c&&(0,Q.jsx)(Y,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Q.jsx)(Lt,{assistantId:g.id})}),p===`disabled`&&c&&(0,Q.jsx)(Y,{title:`Sleep Policy`,subtitle:`Control how long this assistant stays awake when idle.`,children:(0,Q.jsx)(J,{children:`Log in to the Vellum platform to manage sleep policy.`})}),(0,Q.jsx)(xn,{}),(0,Q.jsx)($t,{}),s&&(0,Q.jsx)(Pt,{}),(f===`full`||v)&&g&&(0,Q.jsx)(Y,{variant:`danger`,title:`Retire Assistant`,subtitle:`Permanently retire this assistant and delete all associated data.`,children:(0,Q.jsx)(pn,{assistantId:g.id})}),f===`disabled`&&!v&&(0,Q.jsx)(Y,{variant:`danger`,title:`Retire Assistant`,subtitle:`Permanently retire this assistant and delete all associated data.`,children:(0,Q.jsx)(J,{children:`Log in to the Vellum platform to retire this assistant.`})}),(0,Q.jsx)(Ut,{})]})}export{Sn as GeneralPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,t as n}from"./capture-error-B0wqOYKY.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-BOKTRqXE.js";import{N as ee,_ as te,b as u,f as d,g as f,o as p,r as ne,w as re}from"./local-mode-9ZkSq1Fr.js";import{t as m}from"./is-electron-BuSDabCt.js";import{n as h}from"./resolved-assistants-store-DMuRxkZC.js";import{r as ie}from"./api-errors-CwAGZ-xJ.js";import{A as ae,K as g,Z as _,et as oe,l as v,n as y,nt as b,q as x,rt as se,tt as ce}from"./auth-store-CrTf0uWL.js";import{a as le,o as ue,r as S}from"./api-BSHLYsxJ.js";import{a as C}from"./routes-BKwsRssF.js";import{r as w,t as T}from"./build-state-DqzVxR37.js";import{i as de,p as fe}from"./prefs-Mrqh1A7Y.js";import{t as E}from"./avatar-svg-compositor-Bbqkq_FE.js";import{Lr as D,Pr as O,Rr as k,ft as A}from"./index-LP2PV_QY.js";import{t as pe}from"./provider-key-DH6JmPXt.js";import{BUNDLED_COMPONENTS as j}from"./avatar-bundled-components-UfXe4Pfu.js";var M=e(r(),1);async function me(e,t,r){try{await D(e)||await k(e,t),r.invalidateQueries({queryKey:O(e)})}catch(e){n(e,{context:`onboarding_avatar_sync`})}}function N(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 P=c(),F=3e3,he=800,I=3e5,L=null,R=null,ge={initializing:0,provisioning:.33,connecting:.66,ready:1},z=1500,_e={initializing:`Getting things ready…`,provisioning:`Setting up your assistant…`,connecting:`Connecting to your assistant…`,ready:`Ready`};function ve(e,t,n){if(e>=t)return t;let r=1-(1-Math.min(1,n/z))**3;return e+(t-e)*r}function ye(){let e=w(T(),{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(),w=c.get(`hosting`),T=c.get(`fail`),D=m(),O=d()&&w!==null&&w!==`vellum-cloud`,k=y.use.sessionStatus(),z=O?_(k):k,[B]=(0,M.useState)(()=>N(j)),V=(0,M.useMemo)(()=>{let e=E(j,B.bodyShape,B.eyeStyle,B.color,320);return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`},[B]),[H,U]=(0,M.useState)(`initializing`),[W,G]=(0,M.useState)(null),[be,K]=(0,M.useState)(!1),[xe,Se]=(0,M.useState)(0),[Ce,q]=(0,M.useState)(0),[we,J]=(0,M.useState)(0),Y=(0,M.useRef)(H),X=(0,M.useRef)(0),Z=(0,M.useRef)(0),Q=(0,M.useRef)(0),$=(0,M.useCallback)(e=>{X.current=Q.current,Z.current=Date.now(),Y.current=e,U(e),J(e=>e+1)},[]);return(0,M.useEffect)(()=>{if(T!==null){G(`Simulated hatch failure (developer menu → Replay Hatch Failure).`);return}let i=ye();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(),m,_=!1,E=!1,D=de(),k=()=>{try{fe(``)}catch(e){n(e,{context:`onboarding_mark_completed`})}q(1),Q.current=1,X.current=1,U(`ready`),Y.current=`ready`,s=setTimeout(()=>{a||(async()=>{if(await x.checkAssistant(),!a){if(ae()){x.markExpectingFirstMessage(),e(`${C.assistant}?onboarding=1`,{replace:!0});return}e(C.onboarding.prechat,{replace:!0})}})()},he)},A=e=>me(e,B,r),j=async()=>{if($(`provisioning`),!O){try{let e=await S(),t=b(e);if(!a&&e.ok&&t.kind===`active`){d()&&u({assistantId:e.data.id,name:e.data.name,cloud:`vellum`,runtimeUrl:p(),hatchedAt:new Date().toISOString(),organizationId:v.getState().currentOrganizationId??void 0}),k();return}t.kind===`auto_hatch`&&(E=!0)}catch{}if(a)return}if(O){try{L||=re(void 0,w===`docker`?`docker`:void 0);let e=await L;if(L=null,a)return;if(!e.ok){G(e.error??`Failed to hatch local assistant.`);return}await f(),e.assistantId&&g(e.assistantId),$(`connecting`);let t=!1;for(;!a&&!t;){let e=ne();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`){ee(),await te(),t=!0;break}}}catch{}if(Date.now()-l>=I){G(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{c=setTimeout(e,F)}),c=null}if(a)return;if(e.assistantId&&await y.getState().connectLocalAssistant(e.assistantId),e.assistantId){try{await pe(e.assistantId)}catch(e){n(e,{context:`onboarding_apply_provider_key`})}h.getState().upsertFromApi({id:e.assistantId,name:e.assistantId,status:`active`,is_local:!0,created:new Date().toISOString()}),g(e.assistantId),A(e.assistantId)}k()}catch{if(L=null,a)return;G(`Failed to hatch local assistant. Check CLI logs for details.`)}return}try{R||=ue(D?{version:D}:void 0);let e=await R;if(R=null,a)return;if(e.ok&&(m=e.data.id),_=e.ok&&e.status===201,!e.ok){if(t(`Onboarding hatch request failed`,{level:`warning`,extra:{status:e.status,error:e.error}}),ce(e.status,e.error)){G(oe),K(!0);return}if(!se(e.status)){G(ie(e.error,void 0,`Failed to start your assistant. Please try again.`));return}}}catch(e){if(R=null,n(e,{context:`onboarding_hatch_assistant`}),a)return}M(0)},M=e=>{a||(o=setTimeout(N,e))},N=async()=>{if(!a){if(Date.now()-l>=I){t(`Onboarding hatch wait exceeded timeout`,{level:`warning`,extra:{maxWaitMs:I}}),G(`Your assistant is taking longer than expected. Please try again.`);return}try{let e=await S(m);if(a||m&&!e.ok&&e.status===404&&(m=void 0,e=await S(),a))return;let t=b(e);if(t.kind===`active`){if(e.ok){let t=e.data.id;for(h.getState().upsertFromApi(e.data),g(t),(_||E)&&A(t),d()&&u({assistantId:t,name:e.data.name,cloud:`vellum`,runtimeUrl:p(),hatchedAt:new Date().toISOString(),organizationId:v.getState().currentOrganizationId??void 0}),$(`connecting`);!a;){try{if((await le(t)).ok)break}catch{}if(Date.now()-l>=I){G(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{o=setTimeout(e,F)}),o=null}if(a)return}k();return}if(t.kind===`error`){G(t.message);return}t.kind!==`auto_hatch`&&Y.current===`provisioning`&&$(`connecting`),M(F)}catch(e){if(n(e,{context:`onboarding_poll_assistant`}),a)return;M(F)}}};return j(),()=>{a=!0,o&&clearTimeout(o),s&&clearTimeout(s),c&&clearTimeout(c)}},[xe,T,B,z,e,r,$,O]),(0,M.useEffect)(()=>{Z.current===0&&(Z.current=Date.now());let e,t=()=>{let n=Date.now()-Z.current,r=ge[Y.current],i=ve(X.current,r,n);Q.current=i,q(i),r-i>1e-6&&(e=requestAnimationFrame(t))};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[we]),W?(0,P.jsx)(A,{children:(0,P.jsxs)(`div`,{role:`alert`,className:`mx-auto flex w-full max-w-xl flex-col items-center ${D?`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,P.jsx)(`h1`,{className:D?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:`Something went wrong`}),(0,P.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${D?`mt-3.5`:`mt-4`}`,children:W}),be&&(0,P.jsxs)(`div`,{className:`mt-6 flex w-full max-w-sm flex-col items-center gap-3`,children:[(0,P.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Get started today with a local assistant`}),(0,P.jsx)(i,{asChild:!0,variant:`primary`,size:`regular`,fullWidth:!0,className:D?void 0:`h-11 text-base`,children:(0,P.jsx)(`a`,{href:`${window.location.origin}/download`,children:`Download the macOS app`})})]}),(0,P.jsx)(`img`,{src:V,alt:``,width:160,height:160,className:`${D?`my-auto py-8`:`my-16`} onboarding-avatar-failed`}),(0,P.jsxs)(`div`,{className:`flex w-full flex-col ${D?`gap-2.5 max-w-[280px]`:`gap-2 max-w-sm`}`,children:[(0,P.jsx)(i,{variant:`primary`,size:`regular`,fullWidth:!0,className:D?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),Se(e=>e+1)},children:`Try again`}),(0,P.jsx)(i,{variant:`outlined`,size:`regular`,fullWidth:!0,className:D?void 0:`h-11 text-base`,onClick:()=>void e(O?C.onboarding.hosting:C.onboarding.privacy,{replace:!0}),children:`Back`})]})]})}):(0,P.jsx)(A,{children:(0,P.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${D?`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,P.jsx)(`h1`,{className:D?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:H===`ready`?`Your assistant is ready!`:`Waking up…`}),H!==`ready`&&(0,P.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${D?`mt-3.5`:`mt-4`}`,children:`Hang tight — your assistant will have a few questions for you once it's up.`}),(0,P.jsx)(`img`,{src:V,alt:``,width:160,height:160,className:`${D?`my-auto py-8`:`my-16`} ${H===`ready`?`onboarding-avatar-awake`:`onboarding-avatar-pulse`}`}),(0,P.jsx)(l,{value:Ce,height:6,className:`w-full ${D?`max-w-[200px]`:`max-w-sm`}`,"aria-label":`Assistant startup progress`}),(0,P.jsx)(`p`,{className:`text-[var(--content-tertiary)] ${D?`mt-4 text-label-small-default`:`mt-3 text-body-small-default`}`,children:_e[H]})]})})}export{B as HatchingScreen};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{o as t,t as n}from"./capture-error-B0wqOYKY.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-BOKTRqXE.js";import{N as ee,_ as te,b as u,f as d,g as f,o as p,r as ne,w as re}from"./local-mode-9ZkSq1Fr.js";import{t as m}from"./is-electron-BuSDabCt.js";import{n as h}from"./resolved-assistants-store-DMuRxkZC.js";import{r as ie}from"./api-errors-CwAGZ-xJ.js";import{A as ae,K as g,Z as _,et as oe,l as v,n as y,nt as b,q as x,rt as se,tt as ce}from"./auth-store-CrTf0uWL.js";import{a as le,o as ue,r as S}from"./api-BSHLYsxJ.js";import{a as C}from"./routes-BKwsRssF.js";import{r as w,t as T}from"./build-state-DqzVxR37.js";import{i as de,p as fe}from"./prefs-Mrqh1A7Y.js";import{t as E}from"./avatar-svg-compositor-Bbqkq_FE.js";import{Lr as D,Pr as O,Rr as k,ft as A}from"./index-BiN-6kWM.js";import{t as pe}from"./provider-key-DH6JmPXt.js";import{BUNDLED_COMPONENTS as j}from"./avatar-bundled-components-UfXe4Pfu.js";var M=e(r(),1);async function me(e,t,r){try{await D(e)||await k(e,t),r.invalidateQueries({queryKey:O(e)})}catch(e){n(e,{context:`onboarding_avatar_sync`})}}function N(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 P=c(),F=3e3,he=800,I=3e5,L=null,R=null,ge={initializing:0,provisioning:.33,connecting:.66,ready:1},z=1500,_e={initializing:`Getting things ready…`,provisioning:`Setting up your assistant…`,connecting:`Connecting to your assistant…`,ready:`Ready`};function ve(e,t,n){if(e>=t)return t;let r=1-(1-Math.min(1,n/z))**3;return e+(t-e)*r}function ye(){let e=w(T(),{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(),w=c.get(`hosting`),T=c.get(`fail`),D=m(),O=d()&&w!==null&&w!==`vellum-cloud`,k=y.use.sessionStatus(),z=O?_(k):k,[B]=(0,M.useState)(()=>N(j)),V=(0,M.useMemo)(()=>{let e=E(j,B.bodyShape,B.eyeStyle,B.color,320);return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`},[B]),[H,U]=(0,M.useState)(`initializing`),[W,G]=(0,M.useState)(null),[be,K]=(0,M.useState)(!1),[xe,Se]=(0,M.useState)(0),[Ce,q]=(0,M.useState)(0),[we,J]=(0,M.useState)(0),Y=(0,M.useRef)(H),X=(0,M.useRef)(0),Z=(0,M.useRef)(0),Q=(0,M.useRef)(0),$=(0,M.useCallback)(e=>{X.current=Q.current,Z.current=Date.now(),Y.current=e,U(e),J(e=>e+1)},[]);return(0,M.useEffect)(()=>{if(T!==null){G(`Simulated hatch failure (developer menu → Replay Hatch Failure).`);return}let i=ye();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(),m,_=!1,E=!1,D=de(),k=()=>{try{fe(``)}catch(e){n(e,{context:`onboarding_mark_completed`})}q(1),Q.current=1,X.current=1,U(`ready`),Y.current=`ready`,s=setTimeout(()=>{a||(async()=>{if(await x.checkAssistant(),!a){if(ae()){x.markExpectingFirstMessage(),e(`${C.assistant}?onboarding=1`,{replace:!0});return}e(C.onboarding.prechat,{replace:!0})}})()},he)},A=e=>me(e,B,r),j=async()=>{if($(`provisioning`),!O){try{let e=await S(),t=b(e);if(!a&&e.ok&&t.kind===`active`){d()&&u({assistantId:e.data.id,name:e.data.name,cloud:`vellum`,runtimeUrl:p(),hatchedAt:new Date().toISOString(),organizationId:v.getState().currentOrganizationId??void 0}),k();return}t.kind===`auto_hatch`&&(E=!0)}catch{}if(a)return}if(O){try{L||=re(void 0,w===`docker`?`docker`:void 0);let e=await L;if(L=null,a)return;if(!e.ok){G(e.error??`Failed to hatch local assistant.`);return}await f(),e.assistantId&&g(e.assistantId),$(`connecting`);let t=!1;for(;!a&&!t;){let e=ne();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`){ee(),await te(),t=!0;break}}}catch{}if(Date.now()-l>=I){G(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{c=setTimeout(e,F)}),c=null}if(a)return;if(e.assistantId&&await y.getState().connectLocalAssistant(e.assistantId),e.assistantId){try{await pe(e.assistantId)}catch(e){n(e,{context:`onboarding_apply_provider_key`})}h.getState().upsertFromApi({id:e.assistantId,name:e.assistantId,status:`active`,is_local:!0,created:new Date().toISOString()}),g(e.assistantId),A(e.assistantId)}k()}catch{if(L=null,a)return;G(`Failed to hatch local assistant. Check CLI logs for details.`)}return}try{R||=ue(D?{version:D}:void 0);let e=await R;if(R=null,a)return;if(e.ok&&(m=e.data.id),_=e.ok&&e.status===201,!e.ok){if(t(`Onboarding hatch request failed`,{level:`warning`,extra:{status:e.status,error:e.error}}),ce(e.status,e.error)){G(oe),K(!0);return}if(!se(e.status)){G(ie(e.error,void 0,`Failed to start your assistant. Please try again.`));return}}}catch(e){if(R=null,n(e,{context:`onboarding_hatch_assistant`}),a)return}M(0)},M=e=>{a||(o=setTimeout(N,e))},N=async()=>{if(!a){if(Date.now()-l>=I){t(`Onboarding hatch wait exceeded timeout`,{level:`warning`,extra:{maxWaitMs:I}}),G(`Your assistant is taking longer than expected. Please try again.`);return}try{let e=await S(m);if(a||m&&!e.ok&&e.status===404&&(m=void 0,e=await S(),a))return;let t=b(e);if(t.kind===`active`){if(e.ok){let t=e.data.id;for(h.getState().upsertFromApi(e.data),g(t),(_||E)&&A(t),d()&&u({assistantId:t,name:e.data.name,cloud:`vellum`,runtimeUrl:p(),hatchedAt:new Date().toISOString(),organizationId:v.getState().currentOrganizationId??void 0}),$(`connecting`);!a;){try{if((await le(t)).ok)break}catch{}if(Date.now()-l>=I){G(`Your assistant is taking longer than expected. Please try again.`);return}await new Promise(e=>{o=setTimeout(e,F)}),o=null}if(a)return}k();return}if(t.kind===`error`){G(t.message);return}t.kind!==`auto_hatch`&&Y.current===`provisioning`&&$(`connecting`),M(F)}catch(e){if(n(e,{context:`onboarding_poll_assistant`}),a)return;M(F)}}};return j(),()=>{a=!0,o&&clearTimeout(o),s&&clearTimeout(s),c&&clearTimeout(c)}},[xe,T,B,z,e,r,$,O]),(0,M.useEffect)(()=>{Z.current===0&&(Z.current=Date.now());let e,t=()=>{let n=Date.now()-Z.current,r=ge[Y.current],i=ve(X.current,r,n);Q.current=i,q(i),r-i>1e-6&&(e=requestAnimationFrame(t))};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[we]),W?(0,P.jsx)(A,{children:(0,P.jsxs)(`div`,{role:`alert`,className:`mx-auto flex w-full max-w-xl flex-col items-center ${D?`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,P.jsx)(`h1`,{className:D?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:`Something went wrong`}),(0,P.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${D?`mt-3.5`:`mt-4`}`,children:W}),be&&(0,P.jsxs)(`div`,{className:`mt-6 flex w-full max-w-sm flex-col items-center gap-3`,children:[(0,P.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Get started today with a local assistant`}),(0,P.jsx)(i,{asChild:!0,variant:`primary`,size:`regular`,fullWidth:!0,className:D?void 0:`h-11 text-base`,children:(0,P.jsx)(`a`,{href:`${window.location.origin}/download`,children:`Download the macOS app`})})]}),(0,P.jsx)(`img`,{src:V,alt:``,width:160,height:160,className:`${D?`my-auto py-8`:`my-16`} onboarding-avatar-failed`}),(0,P.jsxs)(`div`,{className:`flex w-full flex-col ${D?`gap-2.5 max-w-[280px]`:`gap-2 max-w-sm`}`,children:[(0,P.jsx)(i,{variant:`primary`,size:`regular`,fullWidth:!0,className:D?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),Se(e=>e+1)},children:`Try again`}),(0,P.jsx)(i,{variant:`outlined`,size:`regular`,fullWidth:!0,className:D?void 0:`h-11 text-base`,onClick:()=>void e(O?C.onboarding.hosting:C.onboarding.privacy,{replace:!0}),children:`Back`})]})]})}):(0,P.jsx)(A,{children:(0,P.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${D?`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,P.jsx)(`h1`,{className:D?`text-title-large`:`text-3xl font-semibold tracking-tight`,children:H===`ready`?`Your assistant is ready!`:`Waking up…`}),H!==`ready`&&(0,P.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${D?`mt-3.5`:`mt-4`}`,children:`Hang tight — your assistant will have a few questions for you once it's up.`}),(0,P.jsx)(`img`,{src:V,alt:``,width:160,height:160,className:`${D?`my-auto py-8`:`my-16`} ${H===`ready`?`onboarding-avatar-awake`:`onboarding-avatar-pulse`}`}),(0,P.jsx)(l,{value:Ce,height:6,className:`w-full ${D?`max-w-[200px]`:`max-w-sm`}`,"aria-label":`Assistant startup progress`}),(0,P.jsx)(`p`,{className:`text-[var(--content-tertiary)] ${D?`mt-4 text-label-small-default`:`mt-3 text-body-small-default`}`,children:_e[H]})]})})}export{B as HatchingScreen};