@vellumai/web 0.8.9 → 0.8.10

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 (74) hide show
  1. package/dist/assets/{account-page-DLWgiDpL.js → account-page-u7ke_44I.js} +1 -1
  2. package/dist/assets/{add-credits-modal-KR3l-hlL.js → add-credits-modal-CjJBB_aT.js} +1 -1
  3. package/dist/assets/{advanced-page-CM1prrIX.js → advanced-page-BybHh4NW.js} +1 -1
  4. package/dist/assets/{ai-page-DfYw7V-1.js → ai-page-BjCnCImt.js} +1 -1
  5. package/dist/assets/{archive-page-C3-LAH2o.js → archive-page-Bn06aNEy.js} +1 -1
  6. package/dist/assets/{assistant-status-panel-AFf9Mjwp.js → assistant-status-panel-ClxIYpxL.js} +1 -1
  7. package/dist/assets/{billing-page-o68CnS02.js → billing-page-XLpuMBWG.js} +1 -1
  8. package/dist/assets/{command-palette-BcHAzecz.js → command-palette-DFTMiCCM.js} +1 -1
  9. package/dist/assets/{community-page-BCX3CsOx.js → community-page-Dt39tUwD.js} +1 -1
  10. package/dist/assets/{connect-page-DXB8Xkpw.js → connect-page-Csfk5gxJ.js} +1 -1
  11. package/dist/assets/{contacts-page-route-8pMuZN4b.js → contacts-page-route-CAfebyIn.js} +1 -1
  12. package/dist/assets/{debug-page-CS2bRZp9.js → debug-page-DuVq7WGa.js} +1 -1
  13. package/dist/assets/{deploy-dialogs-EImApd6S.js → deploy-dialogs-BjBUBG5o.js} +1 -1
  14. package/dist/assets/{developer-page-C6j4GZcn.js → developer-page-BtLYaMJ4.js} +1 -1
  15. package/dist/assets/{devices-page-C1id1sIt.js → devices-page-Dr0ybqr8.js} +1 -1
  16. package/dist/assets/{document-viewer-page-D-zkJQlm.js → document-viewer-page-DZuzK5Y4.js} +1 -1
  17. package/dist/assets/{earn-credits-modal-RXLM_09P.js → earn-credits-modal-BJXnNvv7.js} +1 -1
  18. package/dist/assets/{emails-page-BFlPmeFT.js → emails-page-ChNIsyxX.js} +1 -1
  19. package/dist/assets/{general-page-q3bvwcHU.js → general-page-Joeygf_N.js} +1 -1
  20. package/dist/assets/{hatching-screen-6TxMgPxR.js → hatching-screen-B4BX6YJm.js} +1 -1
  21. package/dist/assets/{home-page-route-mDiWda9f.js → home-page-route-CmVT_FWM.js} +1 -1
  22. package/dist/assets/{hosting-screen-XKK-VeRo.js → hosting-screen-B-KyyLUm.js} +1 -1
  23. package/dist/assets/{identity-page-route-BCiHzwmk.js → identity-page-route-Dl65N_cj.js} +1 -1
  24. package/dist/assets/{index-BjEJFZTJ.js → index-DGojzQtP.js} +20 -20
  25. package/dist/assets/{inspect-page-BrUzgvle.js → inspect-page-DGmhgzNU.js} +1 -1
  26. package/dist/assets/{install-Uj6CrGld.js → install-DzcS2hVv.js} +1 -1
  27. package/dist/assets/{integrations-page-BL9LXHFe.js → integrations-page-D_TaVfYl.js} +1 -1
  28. package/dist/assets/{intelligence-layout-BwYGHEw7.js → intelligence-layout-DZ_lXLTB.js} +1 -1
  29. package/dist/assets/{keyboard-shortcuts-page-QHFTyWOo.js → keyboard-shortcuts-page-CwEtke1e.js} +1 -1
  30. package/dist/assets/{library-detail-page-nUyEDHke.js → library-detail-page-DP_uvWHQ.js} +1 -1
  31. package/dist/assets/{library-page-B0AzCNkJ.js → library-page-D4Ay8lOK.js} +1 -1
  32. package/dist/assets/{login-flow-Bi4ujzeb.js → login-flow-BZiMiMrf.js} +1 -1
  33. package/dist/assets/{login-page-BOH-K9Pj.js → login-page-C-lBEtiR.js} +1 -1
  34. package/dist/assets/{logout-page-B1QXMyiH.js → logout-page-Dd8xdb39.js} +1 -1
  35. package/dist/assets/{logs-layout-zcrIEQRy.js → logs-layout-C2Qs3fI-.js} +1 -1
  36. package/dist/assets/{memory-router-playground-page-CeZ4XMd2.js → memory-router-playground-page-D9miza7X.js} +1 -1
  37. package/dist/assets/{mobile-sidebar-drawer-BjPgVWjw.js → mobile-sidebar-drawer-DrrMr6Xw.js} +1 -1
  38. package/dist/assets/{notifications-page-omwlGRbj.js → notifications-page-aakfxDxE.js} +1 -1
  39. package/dist/assets/{oauth-complete-page--ojS1AzN.js → oauth-complete-page-DAbPV3TG.js} +1 -1
  40. package/dist/assets/{oauth-popup-complete-page-D5wVrngS.js → oauth-popup-complete-page-DyEV43x9.js} +1 -1
  41. package/dist/assets/{plugin-detail-page-Co_JFwRa.js → plugin-detail-page-cM71JV79.js} +1 -1
  42. package/dist/assets/{plugins-page-D7VpzRFc.js → plugins-page-BbOw3iEZ.js} +1 -1
  43. package/dist/assets/{pre-chat-flow-BoePpEU7.js → pre-chat-flow-DYa4Tg43.js} +1 -1
  44. package/dist/assets/{privacy-page-DpKZ9VJG.js → privacy-page-qfuUT3ZP.js} +1 -1
  45. package/dist/assets/{privacy-screen-CEsX-1V3.js → privacy-screen-Iqyv6zx6.js} +1 -1
  46. package/dist/assets/{provider-callback-page-DDEEkkDM.js → provider-callback-page-CxHnf-wJ.js} +1 -1
  47. package/dist/assets/{provider-signup-page-CZqSVAQl.js → provider-signup-page-vOry8yXY.js} +1 -1
  48. package/dist/assets/{review-terms-screen-CYFxXWmR.js → review-terms-screen-DDGg4T4h.js} +1 -1
  49. package/dist/assets/{schedules-page-Dk-YbWK3.js → schedules-page-C6MSsxSW.js} +1 -1
  50. package/dist/assets/{select-assistant-screen-CYpMf074.js → select-assistant-screen-CNC2S4Bq.js} +1 -1
  51. package/dist/assets/{settings-layout-C_sqrv5S.js → settings-layout-BXQK9h6V.js} +1 -1
  52. package/dist/assets/{share-feedback-modal-Cg8gci5A.js → share-feedback-modal-Cd3EJn8y.js} +1 -1
  53. package/dist/assets/{sidebar-tree-Cme65q7r.js → sidebar-tree-CPFfB2hS.js} +1 -1
  54. package/dist/assets/{signup-page-BBM_CboU.js → signup-page-CBvfJsht.js} +1 -1
  55. package/dist/assets/{skills-page-J6mZv9bN.js → skills-page-CS2tWjQe.js} +1 -1
  56. package/dist/assets/{sounds-page-DpRhAAJv.js → sounds-page-C4u0pcg-.js} +1 -1
  57. package/dist/assets/{step-indicator-dots-Dmj2aMuo.js → step-indicator-dots-C_NCj5FH.js} +1 -1
  58. package/dist/assets/{subagent-detail-panel-Dq-GDI61.js → subagent-detail-panel-0yehIKO8.js} +1 -1
  59. package/dist/assets/{system-events-page-DNln669W.js → system-events-page-Dw7NwEcP.js} +1 -1
  60. package/dist/assets/{tiptap-document-editor-DucA37Km.js → tiptap-document-editor-pNgheL8Q.js} +1 -1
  61. package/dist/assets/{tool-detail-panel-CwQTuANT.js → tool-detail-panel-B5SgZOMP.js} +1 -1
  62. package/dist/assets/{trace-page-CKTCZonQ.js → trace-page-C7tNAZHn.js} +1 -1
  63. package/dist/assets/{upgrade-cancel-page-BsW23ioD.js → upgrade-cancel-page-ByiEITdu.js} +1 -1
  64. package/dist/assets/{upgrade-success-page-DqSBwFJv.js → upgrade-success-page-CLOlaEfu.js} +1 -1
  65. package/dist/assets/{usage-page-D6cPGTNn.js → usage-page-Drq5qPw2.js} +1 -1
  66. package/dist/assets/{use-current-platform-assistant-Cu95G65M.js → use-current-platform-assistant-TpNI2OQf.js} +1 -1
  67. package/dist/assets/{use-oauth-complete-deep-link-listener-BQZGv8sr.js → use-oauth-complete-deep-link-listener-aRDKwx8y.js} +1 -1
  68. package/dist/assets/{use-onboarding-login-Cd72-1Qe.js → use-onboarding-login-CWKxGXhS.js} +1 -1
  69. package/dist/assets/{voice-page-D8IZifkA.js → voice-page-DiYRh5kS.js} +1 -1
  70. package/dist/assets/{weather-forecast-display-DgqpUX3a.js → weather-forecast-display-DV6RskYo.js} +1 -1
  71. package/dist/assets/{welcome-screen-B2tizoBp.js → welcome-screen-lzsZvDsg.js} +1 -1
  72. package/dist/assets/{workspace-page-Bu8beso_.js → workspace-page-DPhpvY0s.js} +1 -1
  73. package/dist/index.html +1 -1
  74. package/package.json +1 -1
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{d as n}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as r}from"./QueryClientProvider-DNHWXaGq.js";import{t as i}from"./useQuery-D2zf6Uhu.js";import{t as a}from"./useMutation-BuofVRHk.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./button-DdEh-9f_.js";import{t as c}from"./card-CL5iEMJO.js";import{t as l}from"./input-Cu3PPVCq.js";import{f as u,l as d,s as f,t as p}from"./resolved-assistants-store-ub66utfl.js";import{t as m}from"./is-electron-CavSPgmY.js";import{t as ee}from"./loader-circle-BSAFLoPH.js";import{t as h}from"./pencil-BA9LOIzP.js";import{t as g}from"./x-BDqbYVtS.js";import{B as _,O as v,V as y,a as b,i as x,n as S}from"./auth-store-CiQCAKS1.js";import{t as C}from"./client.gen-BKAMS0D0.js";import{i as w}from"./routes-Dk5Qeryt.js";import{t as T}from"./public-asset-Dx4la7Nv.js";import{A as te,C as E,Ct as D,G as ne,Ha as O,Jn as k,O as re,W as ie,Xn as A,Yn as j,Zn as M,bt as ae,c as N,fo as P,hr as oe,j as F,k as se,l as ce,mo as I,o as le,pr as ue,rt as de,s as fe,vr as pe,w as L}from"./index-BjEJFZTJ.js";import{t as R}from"./onboarding-layout-BIVa2BnX.js";import{c as me,i as he,n as z,o as ge,r as _e,s as ve,t as B}from"./step-indicator-dots-Dmj2aMuo.js";import{t as ye}from"./use-oauth-complete-deep-link-listener-BQZGv8sr.js";var V=e(t(),1);async function be(){try{let{data:e,response:t}=await C.get({url:`/v1/onboarding/recipe/`,throwOnError:!1});if(!t?.ok||!e)return null;let n=e;return typeof n.cohort!=`string`||!Array.isArray(n.tasks)||typeof n.tone!=`string`||typeof n.bootstrap_template!=`string`||typeof n.initial_message!=`string`||!Array.isArray(n.skills)||typeof n.skip_prechat!=`boolean`?null:{cohort:n.cohort,tasks:n.tasks,tone:n.tone,bootstrapTemplate:n.bootstrap_template,initialMessage:n.initial_message,skills:n.skills,skipPrechat:n.skip_prechat}}catch{return null}}var H=o(),xe=[{label:`Push notifications`,detail:`stay in the loop even when the browser is closed`},{label:`Biometric login`,detail:`Face ID & Touch ID for instant, secure access`},{label:`Native haptics`,detail:`tactile feedback that feels part of the device`},{label:`Home screen access`,detail:`launch your assistant with a single tap`}];function Se({onComplete:e}){function t(){N(),le(),e()}return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-md flex-col items-center justify-center px-6 pb-40 text-center`,children:[(0,H.jsx)(`div`,{className:`mb-8 flex size-16 items-center justify-center rounded-2xl border`,style:{background:`var(--surface-overlay)`,borderColor:`var(--border-element)`,boxShadow:`0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04)`,animation:`fadeInUp 0.3s ease-out both`},children:(0,H.jsxs)(`svg`,{width:`28`,height:`28`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--content-default)`},"aria-hidden":!0,children:[(0,H.jsx)(`rect`,{x:`5`,y:`2`,width:`14`,height:`20`,rx:`3`}),(0,H.jsx)(`line`,{x1:`12`,y1:`18`,x2:`12`,y2:`18.01`})]})}),(0,H.jsx)(`p`,{className:`text-label-small-default mb-3 uppercase tracking-[0.2em]`,style:{color:`var(--content-tertiary)`,animation:`fadeInUp 0.3s ease-out 0.05s both`},children:`One more thing`}),(0,H.jsx)(`h1`,{className:`mb-3 text-3xl font-semibold tracking-tight`,style:{color:`var(--content-default)`,animation:`fadeInUp 0.3s ease-out 0.1s both`},children:`Your assistant, in your pocket.`}),(0,H.jsx)(`p`,{className:`text-body-medium-lighter mb-10 max-w-sm`,style:{color:`var(--content-secondary)`,animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`The iOS app keeps your assistant a tap away — with push notifications, biometric login, and native haptics.`}),(0,H.jsx)(`div`,{className:`mb-10 w-full rounded-xl border px-5 py-4`,style:{background:`var(--surface-overlay)`,borderColor:`var(--border-element)`,animation:`fadeInUp 0.3s ease-out 0.2s both`},children:(0,H.jsx)(`ul`,{className:`space-y-4`,children:xe.map((e,t)=>(0,H.jsxs)(`li`,{className:`flex items-start gap-3`,style:{animation:`fadeInUp 0.3s ease-out ${.25+t*.05}s both`},children:[(0,H.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full`,style:{background:`var(--system-positive-weak)`},children:(0,H.jsx)(I,{size:12,style:{color:`var(--system-positive-strong)`}})}),(0,H.jsxs)(`span`,{className:`text-left`,children:[(0,H.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e.label}),(0,H.jsxs)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[` — `,e.detail]})]})]},e.label))})}),(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,style:{animation:`fadeInUp 0.3s ease-out 0.45s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,onClick:t,className:`h-11 text-base`,children:`Download on the App Store`}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:e,className:`h-11 text-base`,children:`Continue in browser`})]})]})})}var U=`google`,Ce=[{id:`gmail`,label:`Gmail`,logoSrc:T(`/images/integrations/gmail.svg`)},{id:`google-calendar`,label:`Google Calendar`,logoSrc:T(`/images/integrations/google-calendar.svg`)},{id:`google-drive`,label:`Google Drive`,logoSrc:T(`/images/integrations/google-drive.svg`)}];function we({assistantId:e,assistantName:t,onConnect:n,onSkip:i,onBack:o}){let c=m(),l=r(),u=v(),d=(0,V.useRef)(null),f=(0,V.useRef)(null),p=(0,V.useRef)(null),h=(0,V.useRef)(null),g=(0,V.useRef)(null),_=(0,V.useRef)(null),y=(0,V.useRef)(null),[b,x]=(0,V.useState)(!1),S=(0,V.useCallback)(()=>{f.current=null,x(!1)},[]),C=(0,V.useCallback)(()=>{g.current&&=(window.removeEventListener(`message`,g.current),null),_.current&&=(window.removeEventListener(`storage`,_.current),null)},[]),T=(0,V.useCallback)(()=>{d.current&&!d.current.closed&&d.current.close(),d.current=null,p.current&&=(clearInterval(p.current),null),h.current&&=(clearTimeout(h.current),null)},[]),E=a({...D()});(0,V.useEffect)(()=>()=>{p.current&&clearInterval(p.current),h.current&&clearTimeout(h.current),d.current&&!d.current.closed&&d.current.close(),g.current&&window.removeEventListener(`message`,g.current),_.current&&window.removeEventListener(`storage`,_.current),y.current&&=(y.current(),null)},[]);let O=(0,V.useCallback)(async()=>{try{return(await l.fetchQuery({...ae({path:{assistant_id:e}}),staleTime:0})).find(e=>e.provider===U&&e.connected)??null}catch{return null}},[e,l]),k=(0,V.useCallback)(async()=>{T(),S(),n((await O())?.scopes_granted??[])},[S,T,O,n]),A=(0,V.useCallback)(e=>{e.type===`vellum:oauth-complete`&&(!f.current||e.requestId!==f.current.requestId||(e.oauthStatus===`connected`?k():(T(),S())))},[S,T,k]),j=(0,V.useCallback)(e=>{let t=f.current;if(!t)return;let n=re(e,window.location.origin,t.requestId);n&&A(n)},[A]),M=(0,V.useCallback)(e=>{let t=f.current;if(!t)return;let n=se(e,t.requestId);n&&(A(n),window.localStorage.removeItem(F(t.requestId)))},[A]);ye((0,V.useCallback)(e=>{let t=f.current;t&&e.requestId===t.requestId&&A({type:`vellum:oauth-complete`,requestId:e.requestId,oauthStatus:e.oauthStatus,oauthProvider:e.oauthProvider,oauthCode:e.oauthCode})},[A]));let N=(0,V.useCallback)(()=>{let t=crypto.randomUUID();if(C(),g.current=j,_.current=M,u){x(!0),f.current={requestId:t},E.mutate({path:{assistant_id:e,provider:U},body:{requested_scopes:[],redirect_after_connect:`${w.account.oauth.popupComplete}?requestId=${t}&native=1`}},{onSuccess(e){ie(e.connect_url)},onError(){S()}}),window.addEventListener(`message`,j),window.addEventListener(`storage`,M),y.current&&y.current();let n=ne(()=>{if(!f.current){n(),y.current=null;return}(async()=>{let e=await O();f.current&&(e?await k():S(),C(),n(),y.current=null)})()});y.current=n;return}let n=window.open(``,`_blank`,`width=500,height=600`);if(n===null){C();return}d.current=n,x(!0),f.current={requestId:t},window.addEventListener(`message`,j),window.addEventListener(`storage`,M),p.current=setInterval(()=>{d.current&&d.current.closed&&f.current&&!h.current&&(h.current=setTimeout(async()=>{h.current=null;let e=f.current;if(!e)return;let t=window.localStorage.getItem(F(e.requestId));if(t)try{let n=JSON.parse(t);if(te(n,e.requestId)){A(n),window.localStorage.removeItem(F(e.requestId)),C();return}}catch{}let n=await O();f.current&&(n?await k():(T(),S()),C())},1e3))},100),E.mutate({path:{assistant_id:e,provider:U},body:{requested_scopes:[],redirect_after_connect:`${w.account.oauth.popupComplete}?requestId=${t}`}},{onSuccess(e){d.current&&!d.current.closed?d.current.location.href=e.connect_url:f.current&&(T(),S(),C())},onError(){T(),S(),C()}})},[e,S,T,O,A,j,M,k,u,C,E]),oe=t||`your assistant`,ce=t||`Your assistant`;return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-md flex-col items-center ${c?`px-8 pt-7 pb-4 electron-prechat-type`:`px-6 pt-12 pb-40`} text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full grid-cols-[auto_1fr_auto] items-center`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`Back`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-secondary)] transition-colors hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(P,{className:`h-4 w-4`})}),(0,H.jsx)(`h1`,{className:`text-center ${c?`text-title-large`:`text-3xl font-semibold tracking-tight`}`,children:`Connect Google`}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`})]}),(0,H.jsx)(`p`,{className:`mt-4 text-center text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`If you use Google, ${oe} can use Gmail, Calendar, and Drive with your permission.`}),(0,H.jsx)(`div`,{className:`mt-6 flex items-stretch justify-center gap-3`,style:{animation:`fadeInUp 0.3s ease-out 0.2s both`},children:Ce.map(e=>(0,H.jsxs)(`div`,{className:`flex w-24 flex-col items-center gap-2.5 rounded-2xl bg-[var(--surface-lift)] px-3 pb-3 pt-4`,children:[(0,H.jsx)(`img`,{src:e.logoSrc,alt:``,width:28,height:28,className:`h-7 w-7 object-contain`,loading:`eager`}),(0,H.jsx)(`span`,{className:`text-center text-xs leading-tight text-[var(--content-tertiary)]`,children:e.label})]},e.id))}),(0,H.jsx)(`p`,{className:`mt-8 text-center text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`fadeInUp 0.3s ease-out 0.25s both`},children:`${ce} will never send email, change calendar events, or edit files without your permission. You can disconnect at any time.`}),(0,H.jsxs)(`div`,{className:`mt-8 flex w-full flex-col gap-2`,style:{animation:`fadeInUp 0.3s ease-out 0.35s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,onClick:N,disabled:b||E.isPending,className:`${c?`h-9`:`h-11 text-base`}`,children:b||E.isPending?(0,H.jsxs)(`span`,{className:`flex items-center justify-center gap-2`,children:[(0,H.jsx)(ee,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),`Waiting for authorization...`]}):`Connect Google`}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:i,disabled:b||E.isPending,className:`${c?`h-9`:`h-11 text-base`}`,children:`Skip for now`})]})]})})}var W=[{id:`grounded`,label:`Grounded`,descriptor:`Calm and precise`,tagline:`Measured. No filler.`,names:[`Penn`,`Sage`,`Atlas`,`Orion`,`Reed`,`Quill`]},{id:`warm`,label:`Warm`,descriptor:`Warm and easy`,tagline:`Friendly and casual.`,names:[`Kit`,`Remy`,`Wren`,`Milo`,`Fenn`,`Cleo`]},{id:`energetic`,label:`Energetic`,descriptor:`Fast and direct`,tagline:`Brief. To the point.`,names:[`Nova`,`Ember`,`Cade`,`Lark`,`Vela`,`Ziggy`]},{id:`poetic`,label:`Poetic`,descriptor:`Quiet and observant`,tagline:`Listens, then replies.`,names:[`Luna`,`Iris`,`Vesper`,`Lyra`,`Juno`,`Ada`]}],Te=6;function Ee(){return W.flatMap(e=>e.names)}function De(){let e=Ee(),t=Math.min(Te,e.length);for(let n=0;n<t;n+=1){let t=n+Math.floor(Math.random()*(e.length-n)),r=e[n];e[n]=e[t],e[t]=r}return e.slice(0,t)}function Oe({userName:e,assistantName:t,selectedGroupId:n,displayedAssistantNames:r,onUserNameChange:i,onAssistantNameChange:a,onGroupChange:o,onBack:c,onComplete:u,onSkip:d}){let f=m();return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-md flex-col items-center ${f?`px-8 pt-11 pb-4 electron-prechat-type`:`px-6 pt-12 pb-40`} text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full items-center ${c?`grid-cols-[auto_1fr_auto]`:``}`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[c?(0,H.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Back`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-secondary)] transition-colors hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(P,{className:`h-4 w-4`})}):null,(0,H.jsx)(`h1`,{className:`text-center ${f?`text-title-large`:`text-3xl font-semibold tracking-tight`}`,children:`Let's get to know each other.`}),c?(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`}):null]}),(0,H.jsx)(`p`,{className:`mt-2 text-center text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`You can change these any time.`}),(0,H.jsxs)(`div`,{className:`${f?`mt-6`:`mt-8`} flex w-full flex-col ${f?`gap-4`:`gap-6`}`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(l,{label:`Your name`,placeholder:`Your name`,value:e,onChange:e=>i(e.target.value),fullWidth:!0}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(l,{label:`What should I go by?`,placeholder:`Assistant name`,value:t,onChange:e=>a(e.target.value),fullWidth:!0}),(0,H.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`A few to try`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let n=e===t;return(0,H.jsx)(`button`,{type:`button`,onClick:()=>a(e),"aria-pressed":n,className:`cursor-pointer rounded-full border px-3 py-1 text-label-small-default transition-colors ${n?`border-[var(--primary-base)] bg-[var(--primary-base)] text-[var(--content-inset)]`:`border-[var(--border-element)] bg-[var(--surface-lift)] text-[var(--content-secondary)] hover:bg-[var(--surface-base)]`}`,children:e},e)})})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Pick a vibe`}),(0,H.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:W.map(e=>(0,H.jsx)(ke,{group:e,isActive:n===e.id,onToggle:()=>o(n===e.id?null:e.id)},e.id))})]})]}),(0,H.jsxs)(`div`,{className:`mt-8 flex w-full flex-col gap-2`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,onClick:u,className:`${f?`h-9`:`h-11 text-base`}`,children:`Let's go`}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:d,className:`${f?`h-9`:`h-11 text-base`}`,children:`Skip`})]})]})})}function ke({group:e,isActive:t,onToggle:n}){return(0,H.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,"aria-label":`${e.label}, ${e.descriptor}`,className:`flex cursor-pointer flex-col items-start gap-0.5 rounded-lg border p-3 text-left transition-colors ${t?`border-[var(--primary-base)] bg-[var(--primary-base)] text-[var(--content-inset)]`:`border-[var(--border-element)] bg-[var(--surface-lift)] hover:bg-[var(--surface-base)]`}`,children:[(0,H.jsx)(`span`,{className:`text-body-medium-default ${t?`text-[var(--content-inset)]`:`text-[var(--content-default)]`}`,children:e.descriptor}),(0,H.jsx)(`span`,{className:`text-body-small-default ${t?`text-[var(--content-inset)] opacity-60`:`text-[var(--content-tertiary)]`}`,children:e.tagline})]})}function Ae({userName:e,assistantName:t,displayedAssistantNames:n,onUserNameChange:r,onAssistantNameChange:i,onBack:a,onContinue:o,onSkip:c,currentStep:u,totalSteps:d}){return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-md flex-col px-6 pb-40 text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full grid-cols-[auto_1fr_auto] items-center pb-4`,style:{paddingTop:`calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 1rem)`,animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[a?(0,H.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,H.jsx)(P,{}),onClick:a,"aria-label":`Back`}):(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`}),(0,H.jsx)(`div`,{className:`flex justify-center`,children:(0,H.jsx)(B,{current:u,total:d})}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`})]}),(0,H.jsxs)(`div`,{className:`flex flex-1 flex-col items-center pt-4`,children:[(0,H.jsx)(`h1`,{className:`text-center text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:`Let's get to know each other.`}),(0,H.jsx)(`p`,{className:`mt-2 text-center text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`You can change these any time.`}),(0,H.jsxs)(`div`,{className:`mt-8 flex w-full flex-col gap-6`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(l,{label:`Your name`,placeholder:`Your name`,value:e,onChange:e=>r(e.target.value),fullWidth:!0}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(l,{label:`What should I go by?`,placeholder:`Assistant name`,value:t,onChange:e=>i(e.target.value),fullWidth:!0}),(0,H.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`A few to try`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.map(e=>{let n=e===t;return(0,H.jsx)(`button`,{type:`button`,onClick:()=>i(e),"aria-pressed":n,className:`cursor-pointer rounded-full border px-3 py-1 text-label-small-default transition-colors ${n?`border-[var(--primary-base)] bg-[var(--primary-base)] text-[var(--content-inset)]`:`border-[var(--border-element)] bg-[var(--surface-lift)] text-[var(--content-secondary)] hover:bg-[var(--surface-base)]`}`,children:e},e)})})]})]})]}),(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-2 pb-4`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,onClick:o,className:`h-11 text-base`,children:`Continue`}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:c,className:`h-11 text-base`,children:`Skip`})]})]})})}var je=[{id:`chatgpt`,label:`ChatGPT`,logoSrc:T(`/images/prior-assistants/chatgpt.svg`)},{id:`claude`,label:`Claude`,logoSrc:T(`/images/prior-assistants/claude.svg`)},{id:`openclaw`,label:`OpenClaw`,logoSrc:T(`/images/prior-assistants/openclaw.png`)},{id:`hermes`,label:`Hermes`,logoSrc:T(`/images/prior-assistants/hermes.png`)},{id:`manus`,label:`Manus`,logoSrc:T(`/images/prior-assistants/manus.svg`)},{id:`gemini`,label:`Gemini`,logoSrc:T(`/images/prior-assistants/gemini.svg`)},{id:`copilot`,label:`Copilot`,logoSrc:T(`/images/prior-assistants/copilot.svg`)}];function Me({selectedAssistants:e,onChange:t,onBack:n,onContinue:r,onSkip:i}){let a=m(),[o,u]=(0,V.useState)(()=>G(e)),[d,f]=(0,V.useState)(()=>o.length>0),p=(0,V.useRef)(K(e));(0,V.useEffect)(()=>{let t=K(e);if(t===p.current)return;let n=G(e);u(n),f(e=>e||n.length>0),p.current=t},[e]),(0,V.useEffect)(()=>{let n=new Set([...e].filter(e=>!e.startsWith(`other:`))),r=new Set;for(let e of o.split(`,`)){let t=e.trim();t&&(r.has(t)||(r.add(t),n.add(`other:${t}`)))}Ne(n,e)||(p.current=K(n),t(n))},[o]);let ee=n=>{let r=new Set(e);r.has(n)?r.delete(n):r.add(n),t(r)},_=(0,V.useMemo)(()=>{let e=new Set;return o.split(`,`).map(e=>e.trim()).filter(t=>!t||e.has(t)?!1:(e.add(t),!0))},[o]),v=e.size===0?`Continue`:`Continue · ${e.size} selected`;return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col items-center ${a?`px-8 pt-7 pb-4 electron-prechat-type`:`px-6 pt-12 pb-40`} text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full items-center grid-cols-[auto_1fr_auto]`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Back`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-secondary)] transition-colors hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(P,{className:`h-4 w-4`})}),(0,H.jsx)(`h1`,{className:`text-center ${a?`text-title-large`:`text-3xl font-semibold tracking-tight`}`,children:`Have you used any of these?`}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`})]}),(0,H.jsx)(`p`,{className:`${a?`mt-3`:`mt-4`} text-center text-body-medium-lighter text-[var(--content-${a?`secondary`:`tertiary`})]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`If you've built anything with another assistant, I can help you bring it over.`}),(0,H.jsxs)(`div`,{className:`${a?`mt-4`:`mt-8`} grid w-full grid-cols-2 gap-2 sm:grid-cols-3 md:grid-cols-4`,style:{animation:`fadeInUp 0.3s ease-out 0.2s both`},children:[je.map(t=>(0,H.jsx)(Pe,{assistant:t,selected:e.has(t.id),onToggle:()=>ee(t.id)},t.id)),d?null:(0,H.jsx)(Fe,{onClick:()=>f(!0)})]}),d?(0,H.jsx)(c,{padding:`md`,className:`mt-3 w-full border-[var(--primary-base)] bg-[color-mix(in_srgb,var(--primary-base)_8%,transparent)]`,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(h,{className:`h-3.5 w-3.5 text-[var(--content-secondary)]`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`text-body-medium-default prechat-md-regular text-[var(--content-default)]`,children:`Something else`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(!1),u(``)},"aria-label":`Dismiss custom assistants`,className:`ml-auto inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md text-[var(--content-tertiary)] hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(g,{className:`h-3 w-3`,"aria-hidden":`true`})})]}),(0,H.jsx)(l,{"aria-label":`Other assistants`,placeholder:`e.g. Perplexity, Poe, Character.AI...`,value:o,onChange:e=>u(e.target.value),helperText:`Separate multiple assistants with commas`,fullWidth:!0}),_.length>0?(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:_.map(e=>(0,H.jsx)(`span`,{className:`rounded-full bg-[var(--primary-base)] px-3 py-1 text-label-small-default text-[var(--content-inset)]`,children:e},e))}):null]})}):null,(0,H.jsxs)(`div`,{className:`${a?`mt-6`:`mt-8`} flex w-full flex-col gap-2`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:e.size===0,onClick:r,className:`${a?`h-9`:`h-11 text-base`}`,children:v}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:i,className:`${a?`h-9`:`h-11 text-base`}`,children:`I haven't used any`})]})]})})}function Ne(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function G(e){return[...e].filter(e=>e.startsWith(`other:`)).map(e=>e.slice(6)).sort().join(`, `)}function K(e){return[...e].filter(e=>e.startsWith(`other:`)).sort().join(`|`)}function Pe({assistant:e,selected:t,onToggle:n}){return(0,H.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,"aria-label":e.label,className:`relative flex h-[88px] w-full cursor-pointer flex-col items-center justify-center gap-1.5 rounded-lg border p-2 transition-colors ${t?`border-[var(--primary-base)] bg-[color-mix(in_srgb,var(--primary-base)_10%,transparent)]`:`border-[var(--border-element)] bg-[var(--surface-lift)] hover:bg-[var(--surface-base)]`}`,children:[(0,H.jsx)(q,{assistant:e,size:32}),(0,H.jsx)(`span`,{className:`line-clamp-2 text-center text-label-medium-default text-[var(--content-default)]`,children:e.label}),t?(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-2 top-2 flex h-4 w-4 items-center justify-center rounded-full bg-[var(--primary-base)]`,children:(0,H.jsx)(I,{className:`h-2.5 w-2.5 text-[var(--content-inset)]`,"aria-hidden":`true`})}):null]})}function Fe({onClick:e}){return(0,H.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Something else`,className:`flex h-[88px] w-full cursor-pointer flex-col items-center justify-center gap-1.5 rounded-lg border border-[var(--border-element)] bg-[var(--surface-lift)] p-2 transition-colors hover:bg-[var(--surface-base)]`,children:[(0,H.jsx)(`span`,{className:`flex h-8 w-8 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,H.jsx)(O,{className:`h-4 w-4 text-[var(--content-secondary)]`,"aria-hidden":`true`})}),(0,H.jsx)(`span`,{className:`line-clamp-2 text-center text-label-medium-default text-[var(--content-default)]`,children:`Something else`})]})}function q({assistant:e,size:t}){if(e.logoSrc)return e.logoSrcDark?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`flex items-center justify-center dark:hidden`,style:{width:t,height:t},"aria-hidden":`true`,children:(0,H.jsx)(`img`,{src:e.logoSrc,alt:``,width:t,height:t,className:`max-h-full max-w-full object-contain`,loading:`eager`})}),(0,H.jsx)(`span`,{className:`hidden items-center justify-center dark:flex`,style:{width:t,height:t},"aria-hidden":`true`,children:(0,H.jsx)(`img`,{src:e.logoSrcDark,alt:``,width:t,height:t,className:`max-h-full max-w-full object-contain`,loading:`eager`})})]}):(0,H.jsx)(`span`,{className:`flex items-center justify-center`,style:{width:t,height:t},children:(0,H.jsx)(`img`,{src:e.logoSrc,alt:``,width:t,height:t,className:`max-h-full max-w-full object-contain`,loading:`eager`})});let n=e.label.slice(0,2).toUpperCase();return(0,H.jsx)(`span`,{className:`flex items-center justify-center rounded-full bg-[var(--surface-base)] text-label-small-default text-[var(--content-default)]`,style:{width:t,height:t},"aria-hidden":`true`,children:n})}function Ie({selectedTasks:e,onChange:t,onBack:n,onContinue:r,onSkip:i}){let a=m(),o=n=>{let r=new Set(e);r.has(n)?r.delete(n):r.add(n),t(r)};return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${a?`px-8 pt-7 pb-4 electron-prechat-type`:`px-6 pt-12 pb-40`} text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full grid-cols-[auto_1fr_auto] items-center`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Back`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-secondary)] transition-colors hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(P,{className:`h-4 w-4`})}),(0,H.jsx)(`h1`,{className:`text-center ${a?`text-title-large`:`text-3xl font-semibold tracking-tight`}`,children:`What are you working on?`}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`})]}),(0,H.jsx)(`p`,{className:`${a?`mt-2`:`mt-4`} text-center text-body-medium-lighter text-[var(--content-${a?`secondary`:`tertiary`})]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`Pick the one or two you do most — you can select more if it really is all of it.`}),(0,H.jsx)(`div`,{className:`${a?`mt-6`:`mt-8`} flex w-full flex-col ${a?`gap-1`:`gap-2`}`,style:{animation:`fadeInUp 0.3s ease-out 0.2s both`},children:E.map(t=>{let n=L[t.iconKey],r=e.has(t.id);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>o(t.id),"aria-pressed":r,className:`group flex w-full cursor-pointer items-center ${a?`gap-2 p-3`:`gap-3 px-4 py-3`} rounded-lg border text-left transition-colors ${r?`border-[var(--primary-base)] bg-[var(--primary-base)]/10`:`border-[var(--border-element)] bg-[var(--surface-lift)] hover:bg-[var(--surface-base)]`}`,children:[(0,H.jsx)(`div`,{className:`flex w-6 shrink-0 items-center justify-center text-[var(--content-secondary)]`,children:n?(0,H.jsx)(n,{className:`h-4 w-4`}):null}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`text-body-medium-default prechat-md-regular text-[var(--content-default)]`,children:t.label}),(0,H.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:t.sublabel})]}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-md ${r?`bg-[var(--primary-base)]`:`border-[1.5px] border-[var(--border-element)]`}`,children:r?(0,H.jsx)(I,{className:`h-3 w-3 text-[var(--content-inset)]`}):null})]},t.id)})}),(0,H.jsxs)(`div`,{className:`${a?`mt-6`:`mt-8`} flex w-full flex-col gap-2`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:e.size===0,onClick:r,className:`${a?`h-9`:`h-11 text-base`}`,children:`Continue`}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:i,className:`${a?`h-9`:`h-11 text-base`}`,children:`I'll set this up later`})]})]})})}var Le=new Set([`gmail`,`google-calendar`,`google-drive`]),Re=[{id:`gmail`,label:`Gmail`,logoSrc:T(`/images/integrations/gmail.svg`)},{id:`outlook`,label:`Outlook`,logoSrc:T(`/images/integrations/outlook.png`)},{id:`google-calendar`,label:`Google Calendar`,logoSrc:T(`/images/integrations/google-calendar.svg`)},{id:`slack`,label:`Slack`,logoSrc:T(`/images/integrations/slack.svg`)},{id:`notion`,label:`Notion`,logoSrc:T(`/images/integrations/notion.svg`)},{id:`linear`,label:`Linear`,logoSrc:T(`/images/integrations/linear-light-logo.svg`)},{id:`jira`,label:`Jira`,logoSrc:T(`/images/integrations/jira.svg`)},{id:`github`,label:`GitHub`,logoSrc:T(`/images/integrations/github.svg`),logoSrcDark:T(`/images/integrations/github-dark.svg`)},{id:`figma`,label:`Figma`,logoSrc:T(`/images/integrations/figma.svg`)},{id:`google-drive`,label:`Google Drive`,logoSrc:T(`/images/integrations/google-drive.svg`)},{id:`excel`,label:`Excel`,logoSrc:T(`/images/integrations/excel.svg`)},{id:`apple-notes`,label:`Apple Notes`,logoSrc:T(`/images/integrations/apple-notes.svg`)}];function J(e){let t=e.map(e=>e.startsWith(`other:`)?e.slice(6):e);return Array.from(new Set(t)).sort()}function ze({selectedTools:e,onChange:t,onBack:n,onContinue:r,onSkip:i}){let a=m(),[o,u]=(0,V.useState)(()=>Ve(e)),[d,f]=(0,V.useState)(()=>o.length>0),p=(0,V.useRef)(Y(e));(0,V.useEffect)(()=>{let t=Y(e);if(t===p.current)return;let n=Ve(e);u(n),f(e=>e||n.length>0),p.current=t},[e]),(0,V.useEffect)(()=>{let n=new Set([...e].filter(e=>!e.startsWith(`other:`))),r=new Set;for(let e of o.split(`,`)){let t=e.trim();t&&(r.has(t)||(r.add(t),n.add(`other:${t}`)))}Be(n,e)||(p.current=Y(n),t(n))},[o]);let ee=n=>{let r=new Set(e);r.has(n)?r.delete(n):r.add(n),t(r)},_=(0,V.useMemo)(()=>{let e=new Set;return o.split(`,`).map(e=>e.trim()).filter(t=>!t||e.has(t)?!1:(e.add(t),!0))},[o]),v=e.size===0?`Continue`:`Continue · ${e.size} selected`;return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col items-center ${a?`px-8 pt-7 pb-4 electron-prechat-type`:`px-6 pt-12 pb-40`} text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full items-center ${n?`grid-cols-[auto_1fr_auto]`:``}`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[n?(0,H.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Back`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-secondary)] transition-colors hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(P,{className:`h-4 w-4`})}):null,(0,H.jsx)(`h1`,{className:`text-center ${a?`text-title-large`:`text-3xl font-semibold tracking-tight`}`,children:`What do you use?`}),n?(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`}):null]}),(0,H.jsx)(`p`,{className:`${a?`mt-3`:`mt-4`} text-center text-body-medium-lighter text-[var(--content-${a?`secondary`:`tertiary`})]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`This helps me tailor how I assist you. No connections needed — you can set those up later.`}),(0,H.jsxs)(`div`,{className:`grid w-full gap-2 ${a?`mt-4 grid-cols-4`:`mt-8 grid-cols-2 sm:grid-cols-3 md:grid-cols-4`}`,style:{animation:`fadeInUp 0.3s ease-out 0.2s both`},children:[Re.map(t=>(0,H.jsx)(X,{tool:t,selected:e.has(t.id),onToggle:()=>ee(t.id),electron:a},t.id)),d?null:(0,H.jsx)(He,{onClick:()=>f(!0),electron:a})]}),d?(0,H.jsx)(c,{padding:a?`sm`:`md`,className:`mt-3 w-full border-[var(--primary-base)] bg-[color-mix(in_srgb,var(--primary-base)_8%,transparent)]`,children:(0,H.jsxs)(`div`,{className:`flex flex-col ${a?`gap-2`:`gap-3`}`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(h,{className:`h-3.5 w-3.5 text-[var(--content-secondary)]`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`text-body-medium-default prechat-md-regular text-[var(--content-default)]`,children:`Something else`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(!1),u(``)},"aria-label":`Dismiss custom tools`,className:`ml-auto inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md text-[var(--content-tertiary)] hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(g,{className:`h-3 w-3`,"aria-hidden":`true`})})]}),(0,H.jsx)(l,{"aria-label":`Other tools`,placeholder:`e.g. Trello, Basecamp, Asana...`,value:o,onChange:e=>u(e.target.value),helperText:`Separate multiple tools with commas`,fullWidth:!0}),_.length>0?(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:_.map(e=>(0,H.jsx)(`span`,{className:`rounded-full bg-[var(--primary-base)] px-3 py-1 text-label-small-default text-[var(--content-inset)]`,children:e},e))}):null]})}):null,(0,H.jsxs)(`div`,{className:`${a?`mt-6`:`mt-8`} flex w-full flex-col gap-2`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:e.size===0,onClick:r,className:`${a?`h-9`:`h-11 text-base`}`,children:v}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:i,className:`${a?`h-9`:`h-11 text-base`}`,children:`I'll set this up later`})]})]})})}function Be(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Ve(e){return[...e].filter(e=>e.startsWith(`other:`)).map(e=>e.slice(6)).sort().join(`, `)}function Y(e){return[...e].filter(e=>e.startsWith(`other:`)).sort().join(`|`)}function X({tool:e,selected:t,onToggle:n,electron:r}){return(0,H.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,"aria-label":e.label,className:`relative flex ${r?`h-[72px]`:`h-[88px]`} w-full cursor-pointer flex-col items-center justify-center gap-1.5 rounded-lg border p-2 transition-colors ${t?`border-[var(--primary-base)] bg-[color-mix(in_srgb,var(--primary-base)_10%,transparent)]`:`border-[var(--border-element)] bg-[var(--surface-lift)] hover:bg-[var(--surface-base)]`}`,children:[(0,H.jsx)(Ue,{tool:e,size:32}),(0,H.jsx)(`span`,{className:`${r?`w-full truncate`:`line-clamp-2`} text-center text-label-medium-default text-[var(--content-default)]`,children:e.label}),t?(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-2 top-2 flex h-4 w-4 items-center justify-center rounded-full bg-[var(--primary-base)]`,children:(0,H.jsx)(I,{className:`h-2.5 w-2.5 text-[var(--content-inset)]`,"aria-hidden":`true`})}):null]})}function He({onClick:e,electron:t}){return(0,H.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Something else`,className:`flex ${t?`min-h-[72px]`:`h-[88px]`} w-full cursor-pointer flex-col items-center justify-center gap-1.5 rounded-lg border border-[var(--border-element)] bg-[var(--surface-lift)] p-2 transition-colors hover:bg-[var(--surface-base)]`,children:[(0,H.jsx)(`span`,{className:`flex h-8 w-8 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,H.jsx)(O,{className:`h-4 w-4 text-[var(--content-secondary)]`,"aria-hidden":`true`})}),(0,H.jsx)(`span`,{className:`line-clamp-2 text-center text-label-medium-default text-[var(--content-default)]`,children:`Something else`})]})}function Ue({tool:e,size:t}){if(e.logoSrc)return e.logoSrcDark?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`flex items-center justify-center dark:hidden`,style:{width:t,height:t},"aria-hidden":`true`,children:(0,H.jsx)(`img`,{src:e.logoSrc,alt:``,width:t,height:t,className:`max-h-full max-w-full object-contain`,loading:`eager`})}),(0,H.jsx)(`span`,{className:`hidden items-center justify-center dark:flex`,style:{width:t,height:t},"aria-hidden":`true`,children:(0,H.jsx)(`img`,{src:e.logoSrcDark,alt:``,width:t,height:t,className:`max-h-full max-w-full object-contain`,loading:`eager`})})]}):(0,H.jsx)(`span`,{className:`flex items-center justify-center`,style:{width:t,height:t},children:(0,H.jsx)(`img`,{src:e.logoSrc,alt:``,width:t,height:t,className:`max-h-full max-w-full object-contain`,loading:`eager`})});let n=e.label.slice(0,2).toUpperCase();return(0,H.jsx)(`span`,{className:`flex items-center justify-center rounded-full bg-[var(--surface-base)] text-label-small-default text-[var(--content-default)]`,style:{width:t,height:t},"aria-hidden":`true`,children:n})}function We({selectedGroupId:e,onGroupChange:t,onBack:n,onContinue:r,onSkip:i,currentStep:a,totalSteps:o}){return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-md flex-col px-6 pb-40 text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full grid-cols-[auto_1fr_auto] items-center pb-4`,style:{paddingTop:`calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 1rem)`,animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[(0,H.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,H.jsx)(P,{}),onClick:n,"aria-label":`Back`}),(0,H.jsx)(`div`,{className:`flex justify-center`,children:(0,H.jsx)(B,{current:a,total:o})}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`})]}),(0,H.jsxs)(`div`,{className:`flex flex-1 flex-col items-center pt-4`,children:[(0,H.jsx)(`h1`,{className:`w-full text-left text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:`What's my vibe?`}),(0,H.jsx)(`p`,{className:`mt-2 w-full text-left text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`You can change this any time.`}),(0,H.jsx)(`div`,{className:`mt-8 flex w-full flex-col gap-3`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:W.map(n=>{let r=e===n.id;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>t(r?null:n.id),"aria-pressed":r,className:`flex cursor-pointer items-center justify-between rounded-xl border px-4 py-4 text-left transition-colors ${r?`border-[var(--content-default)] bg-[var(--surface-lift)]`:`border-[var(--border-element)] bg-[var(--surface-lift)] hover:bg-[var(--surface-base)]`}`,children:[(0,H.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:n.descriptor}),(0,H.jsx)(`span`,{className:`flex h-5 w-5 items-center justify-center rounded-full border-2 transition-colors ${r?`border-[var(--content-default)]`:`border-[var(--content-disabled)]`}`,children:r&&(0,H.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full bg-[var(--content-default)]`})})]},n.id)})})]}),(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-2 pb-4`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,onClick:r,className:`h-11 text-base`,children:`Continue`}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:i,className:`h-11 text-base`,children:`Skip`})]})]})})}function Ge(e){let[t,n]=(0,V.useState)(()=>(e??``).trim()),r=(0,V.useRef)(!1);return(0,V.useEffect)(()=>{if(r.current)return;let t=(e??``).trim();t&&n(e=>e||t)},[e]),{value:t,onChange:(0,V.useCallback)(e=>{r.current=!0,n(e)},[])}}var Ke=[`gmail`,`google-calendar`,`google-drive`],Z=`experiment-activation-flow-2026-06-03`,Q=`BOOTSTRAP-ACTIVATION-RAIL.md`;function $(e,t,n){return t?.initialMessage?t.initialMessage:n?j(e):k}function qe(e){let{mode:t,recipe:n}=e,r=e.connectedScopes!==void 0,i;i=t===`native`?{tools:[],tasks:[],tone:e.tone,googleConnected:!1}:t===`paredDown`?{tools:r?[...Ke]:[],tasks:n?.tasks??[],tone:e.tone,googleConnected:r}:{tools:J([...e.selectedTools]),tasks:[...e.selectedTasks].sort(),tone:e.tone},n&&(i.cohort=n.cohort,i.bootstrapTemplate=n.bootstrapTemplate,i.skills=n.skills),e.activationFlowEnabled&&(i.cohort=Z,i.bootstrapTemplate=Q);let a=e.userName.trim();a&&(i.userName=a);let o=e.assistantName.trim();return o&&(i.assistantName=o),t===`paredDown`?r&&(i.googleScopes=e.connectedScopes):t===`control`&&(r?(i.googleConnected=!0,i.googleScopes=e.connectedScopes):e.googleConnected?(i.googleConnected=!0,i.googleScopes=e.googleScopes):i.googleConnected=!1),t===`control`&&e.selectedPriorAssistants.size>0&&(i.priorAssistants=J([...e.selectedPriorAssistants])),i.initialMessage=$(i,e.activationFlowEnabled?null:n,e.selfIntroGreetingEnabled),i}function Je(e){return!e.localMode||e.platformSession===`present`?!0:e.platformSession===`unknown`&&e.hasCachedPlatformAssistant}function Ye(e){let{paredDown:t}=e;return[{id:`name`,funnelStep:z.nameVibe,enabled:!0},{id:`taskTone`,funnelStep:z.controlWorkType,enabled:!t},{id:`tools`,funnelStep:z.controlTools,enabled:!t},{id:`priorAssistants`,funnelStep:z.controlPriorAssistants,enabled:!t&&e.canOfferPriorAssistants},{id:`google`,funnelStep:t?z.gmailConnect:z.controlGmailConnect,enabled:e.canOfferGoogleStep&&(t||e.hasGoogleTool)},{id:`iosApp`,funnelStep:z.controlGetApp,enabled:!t&&e.showIOSAppStep}].filter(e=>e.enabled).map(({enabled:e,...t})=>t)}function Xe(){return[{id:`nativeName`,funnelStep:null},{id:`nativeVibe`,funnelStep:null}]}var Ze=`1`;function Qe(e){return e===`nativeVibe`||e===Ze?`nativeVibe`:null}function $e(e,t){let n=e.findIndex(e=>e.id===t);return n<0?null:e[n+1]?.id??null}function et(e,t){let n=e.findIndex(e=>e.id===t);return n<=0?null:e[n-1]?.id??null}var tt=3;function nt(){let e=d();return e?.cloud===`vellum`?e.assistantId:f()[0]?.assistantId??null}function rt(){let e=n(),t=S.use.user(),r=x(),a=b(),o=t?.id??null,s=t?.firstName??``,c=t?.lastName??``,l=v(),d=p.use.activeAssistantId(),f=u(),m=ce()&&!fe(),ee=ue.use.stringFlags().preChatOnboardingExperiment20260606??`control`,h=(ue.use.stringFlags().experimentActivationFlow20260603??`control`)===`variant-a`,g=ue.use.selfIntroGreeting(),C=ge(ee),T=ve()??C,te=T===_e.paredDown,E=f?nt():null,D=o?`prechat_native_screen:${o}`:null,[ne,O]=(0,V.useState)(()=>l?`nativeName`:`name`),k=(0,V.useCallback)(e=>{if(D)try{e===null?sessionStorage.removeItem(D):sessionStorage.setItem(D,e)}catch{}},[D]);(0,V.useLayoutEffect)(()=>{if(D)try{let e=Qe(sessionStorage.getItem(D));e&&O(e)}catch{}},[D]),(0,V.useEffect)(()=>{l&&k(ne===`nativeVibe`?`nativeVibe`:null)},[l,ne,k]);let re=S.use.platformSession(),ie=y(re),[j,ae]=(0,V.useState)(()=>new Set),[N,P]=(0,V.useState)(()=>new Set),[F,se]=(0,V.useState)(()=>new Set),{value:I,onChange:le}=Ge(f&&!ie?``:s||c),[L,R]=(0,V.useState)(null),[z]=(0,V.useState)(()=>De()),[B,ye]=(0,V.useState)(``),[xe,U]=(0,V.useState)(!1),[Ce,W]=(0,V.useState)([]),{data:Te}=i({...de(),enabled:!a&&r&&(!f||ie)}),{data:Ee,isLoading:ke}=i({queryKey:[`onboarding-recipe`,o],queryFn:be,enabled:!a&&r&&!l&&!f,staleTime:1/0}),je=Ee??null,Ne=Te?.id??d??E,G=Je({localMode:f,platformSession:re,hasCachedPlatformAssistant:E!==null}),K=G,Pe=G,Fe=(0,V.useCallback)(async()=>{await _.checkAssistant(),e(`${w.assistant}?onboarding=1`,{replace:!0})},[e]),[q,Re]=(0,V.useState)(()=>a||!r?{userId:o,decision:`pending`}:{userId:o,decision:pe()&&oe()?`ok`:`missing`}),J=q.decision;(0,V.useEffect)(()=>{a||!r||q.userId===o&&q.decision!==`pending`||Re({userId:o,decision:pe()&&oe()?`ok`:`missing`})},[q,a,r,o]),(0,V.useEffect)(()=>{if(!a){if(!r){e(w.account.login,{replace:!0});return}if(J===`missing`&&!l){e(w.onboarding.privacy,{replace:!0});return}}},[J,a,r,l,e,Fe,o]);let Be=a||!r||!(l||J===`ok`)||!!ke;function Ve(e,t=T){he(e,{userId:o,variant:me(t)})}let Y=[...j].some(e=>Le.has(e)),X=l?Xe():Ye({paredDown:te,canOfferPriorAssistants:Pe,canOfferGoogleStep:K,hasGoogleTool:Y,showIOSAppStep:m});async function He(e){M(qe({mode:te?`paredDown`:`control`,recipe:je,selectedTools:j,selectedTasks:N,selectedPriorAssistants:e?.selectedPriorAssistants??F,tone:L??je?.tone??`grounded`,userName:I,assistantName:B,selfIntroGreetingEnabled:g,activationFlowEnabled:h,googleConnected:xe,googleScopes:Ce,connectedScopes:e?.connectedScopes}));let t=B.trim();t&&A(t),_.markExpectingFirstMessage(),await Fe()}function Ue(){M(qe({mode:`native`,recipe:null,selectedTools:j,selectedTasks:N,selectedPriorAssistants:F,tone:L??`grounded`,userName:I,assistantName:B,selfIntroGreetingEnabled:g,googleConnected:!1,googleScopes:[]}));let t=B.trim();t&&A(t),k(null),e(w.onboarding.privacy)}let Ke=e=>{l?Ue():He(e)},Z=(e,t)=>{e.funnelStep&&Ve(e.funnelStep);let n=$e(X,e.id);n?O(n):Ke(t)},Q=e=>{let t=et(X,e);t&&O(t)};if(Be)return null;let $=X.find(e=>e.id===ne)??X[0];return $?$.id===`nativeName`?(0,H.jsx)(Ae,{userName:I,assistantName:B,displayedAssistantNames:z,onUserNameChange:le,onAssistantNameChange:ye,onContinue:()=>Z($),onSkip:()=>Z($),currentStep:0,totalSteps:tt}):$.id===`nativeVibe`?(0,H.jsx)(We,{selectedGroupId:L,onGroupChange:R,onBack:()=>Q($.id),onContinue:()=>Z($),onSkip:()=>Z($),currentStep:1,totalSteps:tt}):$.id===`name`?(0,H.jsx)(Oe,{userName:I,assistantName:B,selectedGroupId:L,displayedAssistantNames:z,onUserNameChange:le,onAssistantNameChange:ye,onGroupChange:R,onComplete:()=>Z($),onSkip:()=>Z($)}):$.id===`taskTone`?(0,H.jsx)(Ie,{selectedTasks:N,onChange:P,onBack:()=>Q($.id),onContinue:()=>Z($),onSkip:()=>Z($)}):$.id===`tools`?(0,H.jsx)(ze,{selectedTools:j,onChange:ae,onBack:()=>Q($.id),onContinue:()=>Z($),onSkip:()=>Z($)}):$.id===`priorAssistants`?(0,H.jsx)(Me,{selectedAssistants:F,onChange:se,onBack:()=>Q($.id),onContinue:()=>Z($),onSkip:()=>{let e=new Set;se(e),Z($,{selectedPriorAssistants:e})}}):$.id===`google`?Ne?(0,H.jsx)(we,{assistantId:Ne,assistantName:B,onConnect:e=>{U(!0),W(e),Z($,{connectedScopes:e})},onSkip:()=>Z($),onBack:()=>Q($.id)}):null:$.id===`iosApp`?(0,H.jsx)(Se,{onComplete:()=>Z($)}):null:null}export{rt as PreChatFlow};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{d as n}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as r}from"./QueryClientProvider-DNHWXaGq.js";import{t as i}from"./useQuery-D2zf6Uhu.js";import{t as a}from"./useMutation-BuofVRHk.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{t as s}from"./button-DdEh-9f_.js";import{t as c}from"./card-CL5iEMJO.js";import{t as l}from"./input-Cu3PPVCq.js";import{f as u,l as d,s as f,t as p}from"./resolved-assistants-store-ub66utfl.js";import{t as m}from"./is-electron-CavSPgmY.js";import{t as ee}from"./loader-circle-BSAFLoPH.js";import{t as h}from"./pencil-BA9LOIzP.js";import{t as g}from"./x-BDqbYVtS.js";import{B as _,O as v,V as y,a as b,i as x,n as S}from"./auth-store-CiQCAKS1.js";import{t as C}from"./client.gen-BKAMS0D0.js";import{i as w}from"./routes-Dk5Qeryt.js";import{t as T}from"./public-asset-Dx4la7Nv.js";import{A as te,C as E,Ct as D,G as ne,Ha as O,Jn as k,O as re,W as ie,Xn as A,Yn as j,Zn as M,bt as ae,c as N,fo as P,hr as oe,j as F,k as se,l as ce,mo as I,o as le,pr as ue,rt as de,s as fe,vr as pe,w as L}from"./index-DGojzQtP.js";import{t as R}from"./onboarding-layout-BIVa2BnX.js";import{c as me,i as he,n as z,o as ge,r as _e,s as ve,t as B}from"./step-indicator-dots-C_NCj5FH.js";import{t as ye}from"./use-oauth-complete-deep-link-listener-aRDKwx8y.js";var V=e(t(),1);async function be(){try{let{data:e,response:t}=await C.get({url:`/v1/onboarding/recipe/`,throwOnError:!1});if(!t?.ok||!e)return null;let n=e;return typeof n.cohort!=`string`||!Array.isArray(n.tasks)||typeof n.tone!=`string`||typeof n.bootstrap_template!=`string`||typeof n.initial_message!=`string`||!Array.isArray(n.skills)||typeof n.skip_prechat!=`boolean`?null:{cohort:n.cohort,tasks:n.tasks,tone:n.tone,bootstrapTemplate:n.bootstrap_template,initialMessage:n.initial_message,skills:n.skills,skipPrechat:n.skip_prechat}}catch{return null}}var H=o(),xe=[{label:`Push notifications`,detail:`stay in the loop even when the browser is closed`},{label:`Biometric login`,detail:`Face ID & Touch ID for instant, secure access`},{label:`Native haptics`,detail:`tactile feedback that feels part of the device`},{label:`Home screen access`,detail:`launch your assistant with a single tap`}];function Se({onComplete:e}){function t(){N(),le(),e()}return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-md flex-col items-center justify-center px-6 pb-40 text-center`,children:[(0,H.jsx)(`div`,{className:`mb-8 flex size-16 items-center justify-center rounded-2xl border`,style:{background:`var(--surface-overlay)`,borderColor:`var(--border-element)`,boxShadow:`0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04)`,animation:`fadeInUp 0.3s ease-out both`},children:(0,H.jsxs)(`svg`,{width:`28`,height:`28`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{color:`var(--content-default)`},"aria-hidden":!0,children:[(0,H.jsx)(`rect`,{x:`5`,y:`2`,width:`14`,height:`20`,rx:`3`}),(0,H.jsx)(`line`,{x1:`12`,y1:`18`,x2:`12`,y2:`18.01`})]})}),(0,H.jsx)(`p`,{className:`text-label-small-default mb-3 uppercase tracking-[0.2em]`,style:{color:`var(--content-tertiary)`,animation:`fadeInUp 0.3s ease-out 0.05s both`},children:`One more thing`}),(0,H.jsx)(`h1`,{className:`mb-3 text-3xl font-semibold tracking-tight`,style:{color:`var(--content-default)`,animation:`fadeInUp 0.3s ease-out 0.1s both`},children:`Your assistant, in your pocket.`}),(0,H.jsx)(`p`,{className:`text-body-medium-lighter mb-10 max-w-sm`,style:{color:`var(--content-secondary)`,animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`The iOS app keeps your assistant a tap away — with push notifications, biometric login, and native haptics.`}),(0,H.jsx)(`div`,{className:`mb-10 w-full rounded-xl border px-5 py-4`,style:{background:`var(--surface-overlay)`,borderColor:`var(--border-element)`,animation:`fadeInUp 0.3s ease-out 0.2s both`},children:(0,H.jsx)(`ul`,{className:`space-y-4`,children:xe.map((e,t)=>(0,H.jsxs)(`li`,{className:`flex items-start gap-3`,style:{animation:`fadeInUp 0.3s ease-out ${.25+t*.05}s both`},children:[(0,H.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full`,style:{background:`var(--system-positive-weak)`},children:(0,H.jsx)(I,{size:12,style:{color:`var(--system-positive-strong)`}})}),(0,H.jsxs)(`span`,{className:`text-left`,children:[(0,H.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e.label}),(0,H.jsxs)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[` — `,e.detail]})]})]},e.label))})}),(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,style:{animation:`fadeInUp 0.3s ease-out 0.45s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,onClick:t,className:`h-11 text-base`,children:`Download on the App Store`}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:e,className:`h-11 text-base`,children:`Continue in browser`})]})]})})}var U=`google`,Ce=[{id:`gmail`,label:`Gmail`,logoSrc:T(`/images/integrations/gmail.svg`)},{id:`google-calendar`,label:`Google Calendar`,logoSrc:T(`/images/integrations/google-calendar.svg`)},{id:`google-drive`,label:`Google Drive`,logoSrc:T(`/images/integrations/google-drive.svg`)}];function we({assistantId:e,assistantName:t,onConnect:n,onSkip:i,onBack:o}){let c=m(),l=r(),u=v(),d=(0,V.useRef)(null),f=(0,V.useRef)(null),p=(0,V.useRef)(null),h=(0,V.useRef)(null),g=(0,V.useRef)(null),_=(0,V.useRef)(null),y=(0,V.useRef)(null),[b,x]=(0,V.useState)(!1),S=(0,V.useCallback)(()=>{f.current=null,x(!1)},[]),C=(0,V.useCallback)(()=>{g.current&&=(window.removeEventListener(`message`,g.current),null),_.current&&=(window.removeEventListener(`storage`,_.current),null)},[]),T=(0,V.useCallback)(()=>{d.current&&!d.current.closed&&d.current.close(),d.current=null,p.current&&=(clearInterval(p.current),null),h.current&&=(clearTimeout(h.current),null)},[]),E=a({...D()});(0,V.useEffect)(()=>()=>{p.current&&clearInterval(p.current),h.current&&clearTimeout(h.current),d.current&&!d.current.closed&&d.current.close(),g.current&&window.removeEventListener(`message`,g.current),_.current&&window.removeEventListener(`storage`,_.current),y.current&&=(y.current(),null)},[]);let O=(0,V.useCallback)(async()=>{try{return(await l.fetchQuery({...ae({path:{assistant_id:e}}),staleTime:0})).find(e=>e.provider===U&&e.connected)??null}catch{return null}},[e,l]),k=(0,V.useCallback)(async()=>{T(),S(),n((await O())?.scopes_granted??[])},[S,T,O,n]),A=(0,V.useCallback)(e=>{e.type===`vellum:oauth-complete`&&(!f.current||e.requestId!==f.current.requestId||(e.oauthStatus===`connected`?k():(T(),S())))},[S,T,k]),j=(0,V.useCallback)(e=>{let t=f.current;if(!t)return;let n=re(e,window.location.origin,t.requestId);n&&A(n)},[A]),M=(0,V.useCallback)(e=>{let t=f.current;if(!t)return;let n=se(e,t.requestId);n&&(A(n),window.localStorage.removeItem(F(t.requestId)))},[A]);ye((0,V.useCallback)(e=>{let t=f.current;t&&e.requestId===t.requestId&&A({type:`vellum:oauth-complete`,requestId:e.requestId,oauthStatus:e.oauthStatus,oauthProvider:e.oauthProvider,oauthCode:e.oauthCode})},[A]));let N=(0,V.useCallback)(()=>{let t=crypto.randomUUID();if(C(),g.current=j,_.current=M,u){x(!0),f.current={requestId:t},E.mutate({path:{assistant_id:e,provider:U},body:{requested_scopes:[],redirect_after_connect:`${w.account.oauth.popupComplete}?requestId=${t}&native=1`}},{onSuccess(e){ie(e.connect_url)},onError(){S()}}),window.addEventListener(`message`,j),window.addEventListener(`storage`,M),y.current&&y.current();let n=ne(()=>{if(!f.current){n(),y.current=null;return}(async()=>{let e=await O();f.current&&(e?await k():S(),C(),n(),y.current=null)})()});y.current=n;return}let n=window.open(``,`_blank`,`width=500,height=600`);if(n===null){C();return}d.current=n,x(!0),f.current={requestId:t},window.addEventListener(`message`,j),window.addEventListener(`storage`,M),p.current=setInterval(()=>{d.current&&d.current.closed&&f.current&&!h.current&&(h.current=setTimeout(async()=>{h.current=null;let e=f.current;if(!e)return;let t=window.localStorage.getItem(F(e.requestId));if(t)try{let n=JSON.parse(t);if(te(n,e.requestId)){A(n),window.localStorage.removeItem(F(e.requestId)),C();return}}catch{}let n=await O();f.current&&(n?await k():(T(),S()),C())},1e3))},100),E.mutate({path:{assistant_id:e,provider:U},body:{requested_scopes:[],redirect_after_connect:`${w.account.oauth.popupComplete}?requestId=${t}`}},{onSuccess(e){d.current&&!d.current.closed?d.current.location.href=e.connect_url:f.current&&(T(),S(),C())},onError(){T(),S(),C()}})},[e,S,T,O,A,j,M,k,u,C,E]),oe=t||`your assistant`,ce=t||`Your assistant`;return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-md flex-col items-center ${c?`px-8 pt-7 pb-4 electron-prechat-type`:`px-6 pt-12 pb-40`} text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full grid-cols-[auto_1fr_auto] items-center`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`Back`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-secondary)] transition-colors hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(P,{className:`h-4 w-4`})}),(0,H.jsx)(`h1`,{className:`text-center ${c?`text-title-large`:`text-3xl font-semibold tracking-tight`}`,children:`Connect Google`}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`})]}),(0,H.jsx)(`p`,{className:`mt-4 text-center text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`If you use Google, ${oe} can use Gmail, Calendar, and Drive with your permission.`}),(0,H.jsx)(`div`,{className:`mt-6 flex items-stretch justify-center gap-3`,style:{animation:`fadeInUp 0.3s ease-out 0.2s both`},children:Ce.map(e=>(0,H.jsxs)(`div`,{className:`flex w-24 flex-col items-center gap-2.5 rounded-2xl bg-[var(--surface-lift)] px-3 pb-3 pt-4`,children:[(0,H.jsx)(`img`,{src:e.logoSrc,alt:``,width:28,height:28,className:`h-7 w-7 object-contain`,loading:`eager`}),(0,H.jsx)(`span`,{className:`text-center text-xs leading-tight text-[var(--content-tertiary)]`,children:e.label})]},e.id))}),(0,H.jsx)(`p`,{className:`mt-8 text-center text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`fadeInUp 0.3s ease-out 0.25s both`},children:`${ce} will never send email, change calendar events, or edit files without your permission. You can disconnect at any time.`}),(0,H.jsxs)(`div`,{className:`mt-8 flex w-full flex-col gap-2`,style:{animation:`fadeInUp 0.3s ease-out 0.35s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,onClick:N,disabled:b||E.isPending,className:`${c?`h-9`:`h-11 text-base`}`,children:b||E.isPending?(0,H.jsxs)(`span`,{className:`flex items-center justify-center gap-2`,children:[(0,H.jsx)(ee,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}),`Waiting for authorization...`]}):`Connect Google`}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:i,disabled:b||E.isPending,className:`${c?`h-9`:`h-11 text-base`}`,children:`Skip for now`})]})]})})}var W=[{id:`grounded`,label:`Grounded`,descriptor:`Calm and precise`,tagline:`Measured. No filler.`,names:[`Penn`,`Sage`,`Atlas`,`Orion`,`Reed`,`Quill`]},{id:`warm`,label:`Warm`,descriptor:`Warm and easy`,tagline:`Friendly and casual.`,names:[`Kit`,`Remy`,`Wren`,`Milo`,`Fenn`,`Cleo`]},{id:`energetic`,label:`Energetic`,descriptor:`Fast and direct`,tagline:`Brief. To the point.`,names:[`Nova`,`Ember`,`Cade`,`Lark`,`Vela`,`Ziggy`]},{id:`poetic`,label:`Poetic`,descriptor:`Quiet and observant`,tagline:`Listens, then replies.`,names:[`Luna`,`Iris`,`Vesper`,`Lyra`,`Juno`,`Ada`]}],Te=6;function Ee(){return W.flatMap(e=>e.names)}function De(){let e=Ee(),t=Math.min(Te,e.length);for(let n=0;n<t;n+=1){let t=n+Math.floor(Math.random()*(e.length-n)),r=e[n];e[n]=e[t],e[t]=r}return e.slice(0,t)}function Oe({userName:e,assistantName:t,selectedGroupId:n,displayedAssistantNames:r,onUserNameChange:i,onAssistantNameChange:a,onGroupChange:o,onBack:c,onComplete:u,onSkip:d}){let f=m();return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-md flex-col items-center ${f?`px-8 pt-11 pb-4 electron-prechat-type`:`px-6 pt-12 pb-40`} text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full items-center ${c?`grid-cols-[auto_1fr_auto]`:``}`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[c?(0,H.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Back`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-secondary)] transition-colors hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(P,{className:`h-4 w-4`})}):null,(0,H.jsx)(`h1`,{className:`text-center ${f?`text-title-large`:`text-3xl font-semibold tracking-tight`}`,children:`Let's get to know each other.`}),c?(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`}):null]}),(0,H.jsx)(`p`,{className:`mt-2 text-center text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`You can change these any time.`}),(0,H.jsxs)(`div`,{className:`${f?`mt-6`:`mt-8`} flex w-full flex-col ${f?`gap-4`:`gap-6`}`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(l,{label:`Your name`,placeholder:`Your name`,value:e,onChange:e=>i(e.target.value),fullWidth:!0}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(l,{label:`What should I go by?`,placeholder:`Assistant name`,value:t,onChange:e=>a(e.target.value),fullWidth:!0}),(0,H.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`A few to try`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let n=e===t;return(0,H.jsx)(`button`,{type:`button`,onClick:()=>a(e),"aria-pressed":n,className:`cursor-pointer rounded-full border px-3 py-1 text-label-small-default transition-colors ${n?`border-[var(--primary-base)] bg-[var(--primary-base)] text-[var(--content-inset)]`:`border-[var(--border-element)] bg-[var(--surface-lift)] text-[var(--content-secondary)] hover:bg-[var(--surface-base)]`}`,children:e},e)})})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`p`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:`Pick a vibe`}),(0,H.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:W.map(e=>(0,H.jsx)(ke,{group:e,isActive:n===e.id,onToggle:()=>o(n===e.id?null:e.id)},e.id))})]})]}),(0,H.jsxs)(`div`,{className:`mt-8 flex w-full flex-col gap-2`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,onClick:u,className:`${f?`h-9`:`h-11 text-base`}`,children:`Let's go`}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:d,className:`${f?`h-9`:`h-11 text-base`}`,children:`Skip`})]})]})})}function ke({group:e,isActive:t,onToggle:n}){return(0,H.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,"aria-label":`${e.label}, ${e.descriptor}`,className:`flex cursor-pointer flex-col items-start gap-0.5 rounded-lg border p-3 text-left transition-colors ${t?`border-[var(--primary-base)] bg-[var(--primary-base)] text-[var(--content-inset)]`:`border-[var(--border-element)] bg-[var(--surface-lift)] hover:bg-[var(--surface-base)]`}`,children:[(0,H.jsx)(`span`,{className:`text-body-medium-default ${t?`text-[var(--content-inset)]`:`text-[var(--content-default)]`}`,children:e.descriptor}),(0,H.jsx)(`span`,{className:`text-body-small-default ${t?`text-[var(--content-inset)] opacity-60`:`text-[var(--content-tertiary)]`}`,children:e.tagline})]})}function Ae({userName:e,assistantName:t,displayedAssistantNames:n,onUserNameChange:r,onAssistantNameChange:i,onBack:a,onContinue:o,onSkip:c,currentStep:u,totalSteps:d}){return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-md flex-col px-6 pb-40 text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full grid-cols-[auto_1fr_auto] items-center pb-4`,style:{paddingTop:`calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 1rem)`,animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[a?(0,H.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,H.jsx)(P,{}),onClick:a,"aria-label":`Back`}):(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`}),(0,H.jsx)(`div`,{className:`flex justify-center`,children:(0,H.jsx)(B,{current:u,total:d})}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`})]}),(0,H.jsxs)(`div`,{className:`flex flex-1 flex-col items-center pt-4`,children:[(0,H.jsx)(`h1`,{className:`text-center text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:`Let's get to know each other.`}),(0,H.jsx)(`p`,{className:`mt-2 text-center text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`You can change these any time.`}),(0,H.jsxs)(`div`,{className:`mt-8 flex w-full flex-col gap-6`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(l,{label:`Your name`,placeholder:`Your name`,value:e,onChange:e=>r(e.target.value),fullWidth:!0}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(l,{label:`What should I go by?`,placeholder:`Assistant name`,value:t,onChange:e=>i(e.target.value),fullWidth:!0}),(0,H.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`A few to try`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.map(e=>{let n=e===t;return(0,H.jsx)(`button`,{type:`button`,onClick:()=>i(e),"aria-pressed":n,className:`cursor-pointer rounded-full border px-3 py-1 text-label-small-default transition-colors ${n?`border-[var(--primary-base)] bg-[var(--primary-base)] text-[var(--content-inset)]`:`border-[var(--border-element)] bg-[var(--surface-lift)] text-[var(--content-secondary)] hover:bg-[var(--surface-base)]`}`,children:e},e)})})]})]})]}),(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-2 pb-4`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,onClick:o,className:`h-11 text-base`,children:`Continue`}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:c,className:`h-11 text-base`,children:`Skip`})]})]})})}var je=[{id:`chatgpt`,label:`ChatGPT`,logoSrc:T(`/images/prior-assistants/chatgpt.svg`)},{id:`claude`,label:`Claude`,logoSrc:T(`/images/prior-assistants/claude.svg`)},{id:`openclaw`,label:`OpenClaw`,logoSrc:T(`/images/prior-assistants/openclaw.png`)},{id:`hermes`,label:`Hermes`,logoSrc:T(`/images/prior-assistants/hermes.png`)},{id:`manus`,label:`Manus`,logoSrc:T(`/images/prior-assistants/manus.svg`)},{id:`gemini`,label:`Gemini`,logoSrc:T(`/images/prior-assistants/gemini.svg`)},{id:`copilot`,label:`Copilot`,logoSrc:T(`/images/prior-assistants/copilot.svg`)}];function Me({selectedAssistants:e,onChange:t,onBack:n,onContinue:r,onSkip:i}){let a=m(),[o,u]=(0,V.useState)(()=>G(e)),[d,f]=(0,V.useState)(()=>o.length>0),p=(0,V.useRef)(K(e));(0,V.useEffect)(()=>{let t=K(e);if(t===p.current)return;let n=G(e);u(n),f(e=>e||n.length>0),p.current=t},[e]),(0,V.useEffect)(()=>{let n=new Set([...e].filter(e=>!e.startsWith(`other:`))),r=new Set;for(let e of o.split(`,`)){let t=e.trim();t&&(r.has(t)||(r.add(t),n.add(`other:${t}`)))}Ne(n,e)||(p.current=K(n),t(n))},[o]);let ee=n=>{let r=new Set(e);r.has(n)?r.delete(n):r.add(n),t(r)},_=(0,V.useMemo)(()=>{let e=new Set;return o.split(`,`).map(e=>e.trim()).filter(t=>!t||e.has(t)?!1:(e.add(t),!0))},[o]),v=e.size===0?`Continue`:`Continue · ${e.size} selected`;return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col items-center ${a?`px-8 pt-7 pb-4 electron-prechat-type`:`px-6 pt-12 pb-40`} text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full items-center grid-cols-[auto_1fr_auto]`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Back`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-secondary)] transition-colors hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(P,{className:`h-4 w-4`})}),(0,H.jsx)(`h1`,{className:`text-center ${a?`text-title-large`:`text-3xl font-semibold tracking-tight`}`,children:`Have you used any of these?`}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`})]}),(0,H.jsx)(`p`,{className:`${a?`mt-3`:`mt-4`} text-center text-body-medium-lighter text-[var(--content-${a?`secondary`:`tertiary`})]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`If you've built anything with another assistant, I can help you bring it over.`}),(0,H.jsxs)(`div`,{className:`${a?`mt-4`:`mt-8`} grid w-full grid-cols-2 gap-2 sm:grid-cols-3 md:grid-cols-4`,style:{animation:`fadeInUp 0.3s ease-out 0.2s both`},children:[je.map(t=>(0,H.jsx)(Pe,{assistant:t,selected:e.has(t.id),onToggle:()=>ee(t.id)},t.id)),d?null:(0,H.jsx)(Fe,{onClick:()=>f(!0)})]}),d?(0,H.jsx)(c,{padding:`md`,className:`mt-3 w-full border-[var(--primary-base)] bg-[color-mix(in_srgb,var(--primary-base)_8%,transparent)]`,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(h,{className:`h-3.5 w-3.5 text-[var(--content-secondary)]`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`text-body-medium-default prechat-md-regular text-[var(--content-default)]`,children:`Something else`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(!1),u(``)},"aria-label":`Dismiss custom assistants`,className:`ml-auto inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md text-[var(--content-tertiary)] hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(g,{className:`h-3 w-3`,"aria-hidden":`true`})})]}),(0,H.jsx)(l,{"aria-label":`Other assistants`,placeholder:`e.g. Perplexity, Poe, Character.AI...`,value:o,onChange:e=>u(e.target.value),helperText:`Separate multiple assistants with commas`,fullWidth:!0}),_.length>0?(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:_.map(e=>(0,H.jsx)(`span`,{className:`rounded-full bg-[var(--primary-base)] px-3 py-1 text-label-small-default text-[var(--content-inset)]`,children:e},e))}):null]})}):null,(0,H.jsxs)(`div`,{className:`${a?`mt-6`:`mt-8`} flex w-full flex-col gap-2`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:e.size===0,onClick:r,className:`${a?`h-9`:`h-11 text-base`}`,children:v}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:i,className:`${a?`h-9`:`h-11 text-base`}`,children:`I haven't used any`})]})]})})}function Ne(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function G(e){return[...e].filter(e=>e.startsWith(`other:`)).map(e=>e.slice(6)).sort().join(`, `)}function K(e){return[...e].filter(e=>e.startsWith(`other:`)).sort().join(`|`)}function Pe({assistant:e,selected:t,onToggle:n}){return(0,H.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,"aria-label":e.label,className:`relative flex h-[88px] w-full cursor-pointer flex-col items-center justify-center gap-1.5 rounded-lg border p-2 transition-colors ${t?`border-[var(--primary-base)] bg-[color-mix(in_srgb,var(--primary-base)_10%,transparent)]`:`border-[var(--border-element)] bg-[var(--surface-lift)] hover:bg-[var(--surface-base)]`}`,children:[(0,H.jsx)(q,{assistant:e,size:32}),(0,H.jsx)(`span`,{className:`line-clamp-2 text-center text-label-medium-default text-[var(--content-default)]`,children:e.label}),t?(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-2 top-2 flex h-4 w-4 items-center justify-center rounded-full bg-[var(--primary-base)]`,children:(0,H.jsx)(I,{className:`h-2.5 w-2.5 text-[var(--content-inset)]`,"aria-hidden":`true`})}):null]})}function Fe({onClick:e}){return(0,H.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Something else`,className:`flex h-[88px] w-full cursor-pointer flex-col items-center justify-center gap-1.5 rounded-lg border border-[var(--border-element)] bg-[var(--surface-lift)] p-2 transition-colors hover:bg-[var(--surface-base)]`,children:[(0,H.jsx)(`span`,{className:`flex h-8 w-8 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,H.jsx)(O,{className:`h-4 w-4 text-[var(--content-secondary)]`,"aria-hidden":`true`})}),(0,H.jsx)(`span`,{className:`line-clamp-2 text-center text-label-medium-default text-[var(--content-default)]`,children:`Something else`})]})}function q({assistant:e,size:t}){if(e.logoSrc)return e.logoSrcDark?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`flex items-center justify-center dark:hidden`,style:{width:t,height:t},"aria-hidden":`true`,children:(0,H.jsx)(`img`,{src:e.logoSrc,alt:``,width:t,height:t,className:`max-h-full max-w-full object-contain`,loading:`eager`})}),(0,H.jsx)(`span`,{className:`hidden items-center justify-center dark:flex`,style:{width:t,height:t},"aria-hidden":`true`,children:(0,H.jsx)(`img`,{src:e.logoSrcDark,alt:``,width:t,height:t,className:`max-h-full max-w-full object-contain`,loading:`eager`})})]}):(0,H.jsx)(`span`,{className:`flex items-center justify-center`,style:{width:t,height:t},children:(0,H.jsx)(`img`,{src:e.logoSrc,alt:``,width:t,height:t,className:`max-h-full max-w-full object-contain`,loading:`eager`})});let n=e.label.slice(0,2).toUpperCase();return(0,H.jsx)(`span`,{className:`flex items-center justify-center rounded-full bg-[var(--surface-base)] text-label-small-default text-[var(--content-default)]`,style:{width:t,height:t},"aria-hidden":`true`,children:n})}function Ie({selectedTasks:e,onChange:t,onBack:n,onContinue:r,onSkip:i}){let a=m(),o=n=>{let r=new Set(e);r.has(n)?r.delete(n):r.add(n),t(r)};return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${a?`px-8 pt-7 pb-4 electron-prechat-type`:`px-6 pt-12 pb-40`} text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full grid-cols-[auto_1fr_auto] items-center`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Back`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-secondary)] transition-colors hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(P,{className:`h-4 w-4`})}),(0,H.jsx)(`h1`,{className:`text-center ${a?`text-title-large`:`text-3xl font-semibold tracking-tight`}`,children:`What are you working on?`}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`})]}),(0,H.jsx)(`p`,{className:`${a?`mt-2`:`mt-4`} text-center text-body-medium-lighter text-[var(--content-${a?`secondary`:`tertiary`})]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`Pick the one or two you do most — you can select more if it really is all of it.`}),(0,H.jsx)(`div`,{className:`${a?`mt-6`:`mt-8`} flex w-full flex-col ${a?`gap-1`:`gap-2`}`,style:{animation:`fadeInUp 0.3s ease-out 0.2s both`},children:E.map(t=>{let n=L[t.iconKey],r=e.has(t.id);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>o(t.id),"aria-pressed":r,className:`group flex w-full cursor-pointer items-center ${a?`gap-2 p-3`:`gap-3 px-4 py-3`} rounded-lg border text-left transition-colors ${r?`border-[var(--primary-base)] bg-[var(--primary-base)]/10`:`border-[var(--border-element)] bg-[var(--surface-lift)] hover:bg-[var(--surface-base)]`}`,children:[(0,H.jsx)(`div`,{className:`flex w-6 shrink-0 items-center justify-center text-[var(--content-secondary)]`,children:n?(0,H.jsx)(n,{className:`h-4 w-4`}):null}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`text-body-medium-default prechat-md-regular text-[var(--content-default)]`,children:t.label}),(0,H.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:t.sublabel})]}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-md ${r?`bg-[var(--primary-base)]`:`border-[1.5px] border-[var(--border-element)]`}`,children:r?(0,H.jsx)(I,{className:`h-3 w-3 text-[var(--content-inset)]`}):null})]},t.id)})}),(0,H.jsxs)(`div`,{className:`${a?`mt-6`:`mt-8`} flex w-full flex-col gap-2`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:e.size===0,onClick:r,className:`${a?`h-9`:`h-11 text-base`}`,children:`Continue`}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:i,className:`${a?`h-9`:`h-11 text-base`}`,children:`I'll set this up later`})]})]})})}var Le=new Set([`gmail`,`google-calendar`,`google-drive`]),Re=[{id:`gmail`,label:`Gmail`,logoSrc:T(`/images/integrations/gmail.svg`)},{id:`outlook`,label:`Outlook`,logoSrc:T(`/images/integrations/outlook.png`)},{id:`google-calendar`,label:`Google Calendar`,logoSrc:T(`/images/integrations/google-calendar.svg`)},{id:`slack`,label:`Slack`,logoSrc:T(`/images/integrations/slack.svg`)},{id:`notion`,label:`Notion`,logoSrc:T(`/images/integrations/notion.svg`)},{id:`linear`,label:`Linear`,logoSrc:T(`/images/integrations/linear-light-logo.svg`)},{id:`jira`,label:`Jira`,logoSrc:T(`/images/integrations/jira.svg`)},{id:`github`,label:`GitHub`,logoSrc:T(`/images/integrations/github.svg`),logoSrcDark:T(`/images/integrations/github-dark.svg`)},{id:`figma`,label:`Figma`,logoSrc:T(`/images/integrations/figma.svg`)},{id:`google-drive`,label:`Google Drive`,logoSrc:T(`/images/integrations/google-drive.svg`)},{id:`excel`,label:`Excel`,logoSrc:T(`/images/integrations/excel.svg`)},{id:`apple-notes`,label:`Apple Notes`,logoSrc:T(`/images/integrations/apple-notes.svg`)}];function J(e){let t=e.map(e=>e.startsWith(`other:`)?e.slice(6):e);return Array.from(new Set(t)).sort()}function ze({selectedTools:e,onChange:t,onBack:n,onContinue:r,onSkip:i}){let a=m(),[o,u]=(0,V.useState)(()=>Ve(e)),[d,f]=(0,V.useState)(()=>o.length>0),p=(0,V.useRef)(Y(e));(0,V.useEffect)(()=>{let t=Y(e);if(t===p.current)return;let n=Ve(e);u(n),f(e=>e||n.length>0),p.current=t},[e]),(0,V.useEffect)(()=>{let n=new Set([...e].filter(e=>!e.startsWith(`other:`))),r=new Set;for(let e of o.split(`,`)){let t=e.trim();t&&(r.has(t)||(r.add(t),n.add(`other:${t}`)))}Be(n,e)||(p.current=Y(n),t(n))},[o]);let ee=n=>{let r=new Set(e);r.has(n)?r.delete(n):r.add(n),t(r)},_=(0,V.useMemo)(()=>{let e=new Set;return o.split(`,`).map(e=>e.trim()).filter(t=>!t||e.has(t)?!1:(e.add(t),!0))},[o]),v=e.size===0?`Continue`:`Continue · ${e.size} selected`;return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col items-center ${a?`px-8 pt-7 pb-4 electron-prechat-type`:`px-6 pt-12 pb-40`} text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full items-center ${n?`grid-cols-[auto_1fr_auto]`:``}`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[n?(0,H.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Back`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-secondary)] transition-colors hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(P,{className:`h-4 w-4`})}):null,(0,H.jsx)(`h1`,{className:`text-center ${a?`text-title-large`:`text-3xl font-semibold tracking-tight`}`,children:`What do you use?`}),n?(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`}):null]}),(0,H.jsx)(`p`,{className:`${a?`mt-3`:`mt-4`} text-center text-body-medium-lighter text-[var(--content-${a?`secondary`:`tertiary`})]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`This helps me tailor how I assist you. No connections needed — you can set those up later.`}),(0,H.jsxs)(`div`,{className:`grid w-full gap-2 ${a?`mt-4 grid-cols-4`:`mt-8 grid-cols-2 sm:grid-cols-3 md:grid-cols-4`}`,style:{animation:`fadeInUp 0.3s ease-out 0.2s both`},children:[Re.map(t=>(0,H.jsx)(X,{tool:t,selected:e.has(t.id),onToggle:()=>ee(t.id),electron:a},t.id)),d?null:(0,H.jsx)(He,{onClick:()=>f(!0),electron:a})]}),d?(0,H.jsx)(c,{padding:a?`sm`:`md`,className:`mt-3 w-full border-[var(--primary-base)] bg-[color-mix(in_srgb,var(--primary-base)_8%,transparent)]`,children:(0,H.jsxs)(`div`,{className:`flex flex-col ${a?`gap-2`:`gap-3`}`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(h,{className:`h-3.5 w-3.5 text-[var(--content-secondary)]`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`text-body-medium-default prechat-md-regular text-[var(--content-default)]`,children:`Something else`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(!1),u(``)},"aria-label":`Dismiss custom tools`,className:`ml-auto inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md text-[var(--content-tertiary)] hover:bg-[var(--surface-base)]`,children:(0,H.jsx)(g,{className:`h-3 w-3`,"aria-hidden":`true`})})]}),(0,H.jsx)(l,{"aria-label":`Other tools`,placeholder:`e.g. Trello, Basecamp, Asana...`,value:o,onChange:e=>u(e.target.value),helperText:`Separate multiple tools with commas`,fullWidth:!0}),_.length>0?(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:_.map(e=>(0,H.jsx)(`span`,{className:`rounded-full bg-[var(--primary-base)] px-3 py-1 text-label-small-default text-[var(--content-inset)]`,children:e},e))}):null]})}):null,(0,H.jsxs)(`div`,{className:`${a?`mt-6`:`mt-8`} flex w-full flex-col gap-2`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:e.size===0,onClick:r,className:`${a?`h-9`:`h-11 text-base`}`,children:v}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:i,className:`${a?`h-9`:`h-11 text-base`}`,children:`I'll set this up later`})]})]})})}function Be(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Ve(e){return[...e].filter(e=>e.startsWith(`other:`)).map(e=>e.slice(6)).sort().join(`, `)}function Y(e){return[...e].filter(e=>e.startsWith(`other:`)).sort().join(`|`)}function X({tool:e,selected:t,onToggle:n,electron:r}){return(0,H.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,"aria-label":e.label,className:`relative flex ${r?`h-[72px]`:`h-[88px]`} w-full cursor-pointer flex-col items-center justify-center gap-1.5 rounded-lg border p-2 transition-colors ${t?`border-[var(--primary-base)] bg-[color-mix(in_srgb,var(--primary-base)_10%,transparent)]`:`border-[var(--border-element)] bg-[var(--surface-lift)] hover:bg-[var(--surface-base)]`}`,children:[(0,H.jsx)(Ue,{tool:e,size:32}),(0,H.jsx)(`span`,{className:`${r?`w-full truncate`:`line-clamp-2`} text-center text-label-medium-default text-[var(--content-default)]`,children:e.label}),t?(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-2 top-2 flex h-4 w-4 items-center justify-center rounded-full bg-[var(--primary-base)]`,children:(0,H.jsx)(I,{className:`h-2.5 w-2.5 text-[var(--content-inset)]`,"aria-hidden":`true`})}):null]})}function He({onClick:e,electron:t}){return(0,H.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Something else`,className:`flex ${t?`min-h-[72px]`:`h-[88px]`} w-full cursor-pointer flex-col items-center justify-center gap-1.5 rounded-lg border border-[var(--border-element)] bg-[var(--surface-lift)] p-2 transition-colors hover:bg-[var(--surface-base)]`,children:[(0,H.jsx)(`span`,{className:`flex h-8 w-8 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,H.jsx)(O,{className:`h-4 w-4 text-[var(--content-secondary)]`,"aria-hidden":`true`})}),(0,H.jsx)(`span`,{className:`line-clamp-2 text-center text-label-medium-default text-[var(--content-default)]`,children:`Something else`})]})}function Ue({tool:e,size:t}){if(e.logoSrc)return e.logoSrcDark?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`flex items-center justify-center dark:hidden`,style:{width:t,height:t},"aria-hidden":`true`,children:(0,H.jsx)(`img`,{src:e.logoSrc,alt:``,width:t,height:t,className:`max-h-full max-w-full object-contain`,loading:`eager`})}),(0,H.jsx)(`span`,{className:`hidden items-center justify-center dark:flex`,style:{width:t,height:t},"aria-hidden":`true`,children:(0,H.jsx)(`img`,{src:e.logoSrcDark,alt:``,width:t,height:t,className:`max-h-full max-w-full object-contain`,loading:`eager`})})]}):(0,H.jsx)(`span`,{className:`flex items-center justify-center`,style:{width:t,height:t},children:(0,H.jsx)(`img`,{src:e.logoSrc,alt:``,width:t,height:t,className:`max-h-full max-w-full object-contain`,loading:`eager`})});let n=e.label.slice(0,2).toUpperCase();return(0,H.jsx)(`span`,{className:`flex items-center justify-center rounded-full bg-[var(--surface-base)] text-label-small-default text-[var(--content-default)]`,style:{width:t,height:t},"aria-hidden":`true`,children:n})}function We({selectedGroupId:e,onGroupChange:t,onBack:n,onContinue:r,onSkip:i,currentStep:a,totalSteps:o}){return(0,H.jsx)(R,{showCreatureFooter:!1,children:(0,H.jsxs)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-md flex-col px-6 pb-40 text-[var(--content-default)]`,children:[(0,H.jsxs)(`div`,{className:`grid w-full grid-cols-[auto_1fr_auto] items-center pb-4`,style:{paddingTop:`calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 1rem)`,animation:`fadeInUp 0.3s ease-out 0.1s both`},children:[(0,H.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,H.jsx)(P,{}),onClick:n,"aria-label":`Back`}),(0,H.jsx)(`div`,{className:`flex justify-center`,children:(0,H.jsx)(B,{current:a,total:o})}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-8 w-8`})]}),(0,H.jsxs)(`div`,{className:`flex flex-1 flex-col items-center pt-4`,children:[(0,H.jsx)(`h1`,{className:`w-full text-left text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:`What's my vibe?`}),(0,H.jsx)(`p`,{className:`mt-2 w-full text-left text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`fadeInUp 0.3s ease-out 0.15s both`},children:`You can change this any time.`}),(0,H.jsx)(`div`,{className:`mt-8 flex w-full flex-col gap-3`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:W.map(n=>{let r=e===n.id;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>t(r?null:n.id),"aria-pressed":r,className:`flex cursor-pointer items-center justify-between rounded-xl border px-4 py-4 text-left transition-colors ${r?`border-[var(--content-default)] bg-[var(--surface-lift)]`:`border-[var(--border-element)] bg-[var(--surface-lift)] hover:bg-[var(--surface-base)]`}`,children:[(0,H.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:n.descriptor}),(0,H.jsx)(`span`,{className:`flex h-5 w-5 items-center justify-center rounded-full border-2 transition-colors ${r?`border-[var(--content-default)]`:`border-[var(--content-disabled)]`}`,children:r&&(0,H.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full bg-[var(--content-default)]`})})]},n.id)})})]}),(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-2 pb-4`,style:{animation:`fadeInUp 0.3s ease-out 0.3s both`},children:[(0,H.jsx)(s,{variant:`primary`,size:`regular`,fullWidth:!0,onClick:r,className:`h-11 text-base`,children:`Continue`}),(0,H.jsx)(s,{variant:`ghost`,size:`regular`,fullWidth:!0,onClick:i,className:`h-11 text-base`,children:`Skip`})]})]})})}function Ge(e){let[t,n]=(0,V.useState)(()=>(e??``).trim()),r=(0,V.useRef)(!1);return(0,V.useEffect)(()=>{if(r.current)return;let t=(e??``).trim();t&&n(e=>e||t)},[e]),{value:t,onChange:(0,V.useCallback)(e=>{r.current=!0,n(e)},[])}}var Ke=[`gmail`,`google-calendar`,`google-drive`],Z=`experiment-activation-flow-2026-06-03`,Q=`BOOTSTRAP-ACTIVATION-RAIL.md`;function $(e,t,n){return t?.initialMessage?t.initialMessage:n?j(e):k}function qe(e){let{mode:t,recipe:n}=e,r=e.connectedScopes!==void 0,i;i=t===`native`?{tools:[],tasks:[],tone:e.tone,googleConnected:!1}:t===`paredDown`?{tools:r?[...Ke]:[],tasks:n?.tasks??[],tone:e.tone,googleConnected:r}:{tools:J([...e.selectedTools]),tasks:[...e.selectedTasks].sort(),tone:e.tone},n&&(i.cohort=n.cohort,i.bootstrapTemplate=n.bootstrapTemplate,i.skills=n.skills),e.activationFlowEnabled&&(i.cohort=Z,i.bootstrapTemplate=Q);let a=e.userName.trim();a&&(i.userName=a);let o=e.assistantName.trim();return o&&(i.assistantName=o),t===`paredDown`?r&&(i.googleScopes=e.connectedScopes):t===`control`&&(r?(i.googleConnected=!0,i.googleScopes=e.connectedScopes):e.googleConnected?(i.googleConnected=!0,i.googleScopes=e.googleScopes):i.googleConnected=!1),t===`control`&&e.selectedPriorAssistants.size>0&&(i.priorAssistants=J([...e.selectedPriorAssistants])),i.initialMessage=$(i,e.activationFlowEnabled?null:n,e.selfIntroGreetingEnabled),i}function Je(e){return!e.localMode||e.platformSession===`present`?!0:e.platformSession===`unknown`&&e.hasCachedPlatformAssistant}function Ye(e){let{paredDown:t}=e;return[{id:`name`,funnelStep:z.nameVibe,enabled:!0},{id:`taskTone`,funnelStep:z.controlWorkType,enabled:!t},{id:`tools`,funnelStep:z.controlTools,enabled:!t},{id:`priorAssistants`,funnelStep:z.controlPriorAssistants,enabled:!t&&e.canOfferPriorAssistants},{id:`google`,funnelStep:t?z.gmailConnect:z.controlGmailConnect,enabled:e.canOfferGoogleStep&&(t||e.hasGoogleTool)},{id:`iosApp`,funnelStep:z.controlGetApp,enabled:!t&&e.showIOSAppStep}].filter(e=>e.enabled).map(({enabled:e,...t})=>t)}function Xe(){return[{id:`nativeName`,funnelStep:null},{id:`nativeVibe`,funnelStep:null}]}var Ze=`1`;function Qe(e){return e===`nativeVibe`||e===Ze?`nativeVibe`:null}function $e(e,t){let n=e.findIndex(e=>e.id===t);return n<0?null:e[n+1]?.id??null}function et(e,t){let n=e.findIndex(e=>e.id===t);return n<=0?null:e[n-1]?.id??null}var tt=3;function nt(){let e=d();return e?.cloud===`vellum`?e.assistantId:f()[0]?.assistantId??null}function rt(){let e=n(),t=S.use.user(),r=x(),a=b(),o=t?.id??null,s=t?.firstName??``,c=t?.lastName??``,l=v(),d=p.use.activeAssistantId(),f=u(),m=ce()&&!fe(),ee=ue.use.stringFlags().preChatOnboardingExperiment20260606??`control`,h=(ue.use.stringFlags().experimentActivationFlow20260603??`control`)===`variant-a`,g=ue.use.selfIntroGreeting(),C=ge(ee),T=ve()??C,te=T===_e.paredDown,E=f?nt():null,D=o?`prechat_native_screen:${o}`:null,[ne,O]=(0,V.useState)(()=>l?`nativeName`:`name`),k=(0,V.useCallback)(e=>{if(D)try{e===null?sessionStorage.removeItem(D):sessionStorage.setItem(D,e)}catch{}},[D]);(0,V.useLayoutEffect)(()=>{if(D)try{let e=Qe(sessionStorage.getItem(D));e&&O(e)}catch{}},[D]),(0,V.useEffect)(()=>{l&&k(ne===`nativeVibe`?`nativeVibe`:null)},[l,ne,k]);let re=S.use.platformSession(),ie=y(re),[j,ae]=(0,V.useState)(()=>new Set),[N,P]=(0,V.useState)(()=>new Set),[F,se]=(0,V.useState)(()=>new Set),{value:I,onChange:le}=Ge(f&&!ie?``:s||c),[L,R]=(0,V.useState)(null),[z]=(0,V.useState)(()=>De()),[B,ye]=(0,V.useState)(``),[xe,U]=(0,V.useState)(!1),[Ce,W]=(0,V.useState)([]),{data:Te}=i({...de(),enabled:!a&&r&&(!f||ie)}),{data:Ee,isLoading:ke}=i({queryKey:[`onboarding-recipe`,o],queryFn:be,enabled:!a&&r&&!l&&!f,staleTime:1/0}),je=Ee??null,Ne=Te?.id??d??E,G=Je({localMode:f,platformSession:re,hasCachedPlatformAssistant:E!==null}),K=G,Pe=G,Fe=(0,V.useCallback)(async()=>{await _.checkAssistant(),e(`${w.assistant}?onboarding=1`,{replace:!0})},[e]),[q,Re]=(0,V.useState)(()=>a||!r?{userId:o,decision:`pending`}:{userId:o,decision:pe()&&oe()?`ok`:`missing`}),J=q.decision;(0,V.useEffect)(()=>{a||!r||q.userId===o&&q.decision!==`pending`||Re({userId:o,decision:pe()&&oe()?`ok`:`missing`})},[q,a,r,o]),(0,V.useEffect)(()=>{if(!a){if(!r){e(w.account.login,{replace:!0});return}if(J===`missing`&&!l){e(w.onboarding.privacy,{replace:!0});return}}},[J,a,r,l,e,Fe,o]);let Be=a||!r||!(l||J===`ok`)||!!ke;function Ve(e,t=T){he(e,{userId:o,variant:me(t)})}let Y=[...j].some(e=>Le.has(e)),X=l?Xe():Ye({paredDown:te,canOfferPriorAssistants:Pe,canOfferGoogleStep:K,hasGoogleTool:Y,showIOSAppStep:m});async function He(e){M(qe({mode:te?`paredDown`:`control`,recipe:je,selectedTools:j,selectedTasks:N,selectedPriorAssistants:e?.selectedPriorAssistants??F,tone:L??je?.tone??`grounded`,userName:I,assistantName:B,selfIntroGreetingEnabled:g,activationFlowEnabled:h,googleConnected:xe,googleScopes:Ce,connectedScopes:e?.connectedScopes}));let t=B.trim();t&&A(t),_.markExpectingFirstMessage(),await Fe()}function Ue(){M(qe({mode:`native`,recipe:null,selectedTools:j,selectedTasks:N,selectedPriorAssistants:F,tone:L??`grounded`,userName:I,assistantName:B,selfIntroGreetingEnabled:g,googleConnected:!1,googleScopes:[]}));let t=B.trim();t&&A(t),k(null),e(w.onboarding.privacy)}let Ke=e=>{l?Ue():He(e)},Z=(e,t)=>{e.funnelStep&&Ve(e.funnelStep);let n=$e(X,e.id);n?O(n):Ke(t)},Q=e=>{let t=et(X,e);t&&O(t)};if(Be)return null;let $=X.find(e=>e.id===ne)??X[0];return $?$.id===`nativeName`?(0,H.jsx)(Ae,{userName:I,assistantName:B,displayedAssistantNames:z,onUserNameChange:le,onAssistantNameChange:ye,onContinue:()=>Z($),onSkip:()=>Z($),currentStep:0,totalSteps:tt}):$.id===`nativeVibe`?(0,H.jsx)(We,{selectedGroupId:L,onGroupChange:R,onBack:()=>Q($.id),onContinue:()=>Z($),onSkip:()=>Z($),currentStep:1,totalSteps:tt}):$.id===`name`?(0,H.jsx)(Oe,{userName:I,assistantName:B,selectedGroupId:L,displayedAssistantNames:z,onUserNameChange:le,onAssistantNameChange:ye,onGroupChange:R,onComplete:()=>Z($),onSkip:()=>Z($)}):$.id===`taskTone`?(0,H.jsx)(Ie,{selectedTasks:N,onChange:P,onBack:()=>Q($.id),onContinue:()=>Z($),onSkip:()=>Z($)}):$.id===`tools`?(0,H.jsx)(ze,{selectedTools:j,onChange:ae,onBack:()=>Q($.id),onContinue:()=>Z($),onSkip:()=>Z($)}):$.id===`priorAssistants`?(0,H.jsx)(Me,{selectedAssistants:F,onChange:se,onBack:()=>Q($.id),onContinue:()=>Z($),onSkip:()=>{let e=new Set;se(e),Z($,{selectedPriorAssistants:e})}}):$.id===`google`?Ne?(0,H.jsx)(we,{assistantId:Ne,assistantName:B,onConnect:e=>{U(!0),W(e),Z($,{connectedScopes:e})},onSkip:()=>Z($),onBack:()=>Q($.id)}):null:$.id===`iosApp`?(0,H.jsx)(Se,{onComplete:()=>Z($)}):null:null}export{rt as PreChatFlow};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{n as t,o as n,r}from"./device-settings-C07QvMzm.js";import{t as i}from"./react-DJZBPgpf.js";import{T as a}from"./portal-container-DIXEBWUe.js";import{n as o}from"./QueryClientProvider-DNHWXaGq.js";import{t as s}from"./useQuery-D2zf6Uhu.js";import{t as c}from"./useMutation-BuofVRHk.js";import{t as l}from"./jsx-runtime-CVSDxk6A.js";import{t as u}from"./button-DdEh-9f_.js";import{t as d}from"./card-CL5iEMJO.js";import{t as f}from"./dropdown-CocFV5yi.js";import{t as p}from"./confirm-dialog-NYG-K9zN.js";import{t as m}from"./notice-CF2pptne.js";import{t as h}from"./tag-Ccr7Quy6.js";import{t as g}from"./input-Cu3PPVCq.js";import{t as _}from"./toggle-CEm3M86o.js";import{n as v}from"./toast-DU1nH33j.js";import{t as y}from"./chevron-right-zTNPbA1m.js";import{t as b}from"./loader-circle-BSAFLoPH.js";import{t as x}from"./pencil-BA9LOIzP.js";import{t as S}from"./x-BDqbYVtS.js";import{C,O as w,S as T,b as E,d as D,r as O,v as k,w as A,x as j,y as ee}from"./auth-store-CiQCAKS1.js";import{t as te}from"./sdk.gen-BO4vbMAj.js";import{$ as M,Gi as N,Ni as P,Q as F,S as I,b as L,d as R,et as z,f as ne,nt as re,p as ie,po as ae,tt as oe,u as B,x as V}from"./index-BjEJFZTJ.js";import{t as H}from"./use-active-assistant-id-BIhArlF_.js";import{t as U}from"./detail-card-B5j4Rqau.js";var W=e(i(),1),G=l();function K(){let e=z({platformHostedOnly:!0}),t=F(),n=M(),r=o(),{data:i,isLoading:a,isError:l}=s({...oe(),enabled:e===`full`&&t}),u=c({mutationFn:async e=>{let{data:t}=await te({body:{access_consented:e},throwOnError:!0});return t},onSuccess:e=>{r.setQueryData(re(),e),v.success(e?.access_consented?`Admin data access enabled.`:`Admin data access disabled.`)},onError:()=>{v.error(`Failed to update log access consent.`)}});if(e===`gated`)return null;let d=e===`full`&&n,f=i?.access_consented??!1,p=e!==`full`||!t||a||l||u.isPending;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Allow admin access to assistant data`}),(0,G.jsxs)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-tertiary)]`,children:[`Lets Vellum administrators reach privileged data on your assistant pod for debugging — today this means tailing the daily assistant log at`,` `,(0,G.jsx)(`code`,{className:`rounded bg-[var(--surface-base)] px-1.5 font-mono text-[var(--content-secondary)] dark:bg-[var(--surface-lift)] dark:text-[var(--content-default)]`,children:`/workspace/data/logs/assistant-YYYY-MM-DD.log`}),`. Off by default. Turn on temporarily when asking support to investigate an issue, then turn off when you're done.`]}),e===`full`&&l&&(0,G.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--system-negative-strong)]`,children:`Failed to load consent setting.`})]}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:e===`disabled`?null:(0,G.jsxs)(G.Fragment,{children:[(u.isPending||d)&&(0,G.jsx)(b,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),(0,G.jsx)(_,{checked:f,disabled:p,onChange:()=>u.mutate(!f)})]})})]}),e===`disabled`&&(0,G.jsx)(m,{tone:`info`,className:`mt-3`,children:`Log in to the Vellum platform to manage admin data access.`})]})}function se(){let e=w(),[t,n]=(0,W.useState)(()=>j()),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(`Face ID`),[s,c]=(0,W.useState)(!1);if((0,W.useEffect)(()=>{e&&(E().then(i),ee().then(o))},[e]),!e||!r)return null;let l=async()=>{c(!0);try{if(t)T(!1),await k(),n(!1);else{let e=A();e&&await C(e),T(!0),n(!0)}}finally{c(!1)}};return(0,G.jsx)(U,{title:`Security`,children:(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsxs)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:[`Use `,a,` for sign-in`]}),(0,G.jsxs)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-tertiary)]`,children:[`When your session expires, verify with `,a,` or your device passcode instead of signing in again.`]})]}),(0,G.jsx)(_,{checked:t,onChange:()=>void l(),disabled:s})]})})}function q(){return(0,G.jsx)(`div`,{className:`h-px bg-[var(--surface-active)] dark:bg-[var(--surface-lift)]`})}var J=B.map(e=>({value:e.id,label:e.label,icon:(0,G.jsx)(e.icon,{className:`h-3.5 w-3.5`})}));function ce(){let e=H(),t=o(),{data:n,isError:r}=s({queryKey:[`thresholds`,e],queryFn:()=>ne(e),staleTime:3e4}),[i,a]=(0,W.useState)(`relaxed`),[c,l]=(0,W.useState)(`conservative`),[u,p]=(0,W.useState)(`strict`),[m,h]=(0,W.useState)(!1),g=(0,W.useRef)(!1),[_,v]=(0,W.useState)(!1),b=(0,W.useRef)(null),x=(0,W.useRef)(null);(0,W.useEffect)(()=>{!n||g.current||(a(R(n.interactive).id),l(R(n.autonomous).id),p(R(n.headless).id),v(!0))},[n]),(0,W.useEffect)(()=>()=>{b.current!==null&&(clearTimeout(b.current),b.current=null,x.current?.(),x.current=null)},[]);let S=(0,W.useCallback)((n,r,i)=>{if(!e||!_)return;let a=B.find(e=>e.id===n)?.riskThreshold,o=B.find(e=>e.id===r)?.riskThreshold,s=B.find(e=>e.id===i)?.riskThreshold;!a||!o||!s||ie(e,{interactive:a,autonomous:o,headless:s}).then(()=>{t.invalidateQueries({queryKey:[`thresholds`,e]})}).catch(()=>{})},[e,_,t]),C=(0,W.useCallback)((e,t,n)=>{b.current!==null&&clearTimeout(b.current),x.current=()=>S(e,t,n),b.current=setTimeout(()=>{x.current?.(),b.current=null,x.current=null},500)},[S]),w=(0,W.useCallback)(e=>{g.current=!0,a(e),C(e,c,u)},[c,u,C]),T=(0,W.useCallback)(e=>{g.current=!0,l(e),C(i,e,u)},[i,u,C]),E=(0,W.useCallback)(e=>{g.current=!0,p(e),C(i,c,e)},[i,c,C]),D=B.find(e=>e.id===i),O=B.find(e=>e.id===c),k=B.find(e=>e.id===u),A=!e||!_;return(0,G.jsxs)(d,{children:[(0,G.jsx)(`h2`,{className:`text-title-medium text-[var(--content-default)]`,children:`Risk Tolerance`}),(0,G.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Control which actions your assistant can take without asking first. Each action is classified by risk level — your tolerance determines which levels auto-approve.`}),r&&(0,G.jsx)(`p`,{className:`mt-2 text-body-small-default text-[var(--system-negative-strong)]`,children:`Could not load threshold settings. Check your connection and reload.`}),(0,G.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Conversations`}),(0,G.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`When you're chatting with your assistant directly.`}),(0,G.jsx)(`div`,{className:`mt-2`,style:{maxWidth:280},children:(0,G.jsx)(f,{value:i,onChange:w,options:J,disabled:A})}),D&&(0,G.jsx)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:D.description})]}),(0,G.jsx)(q,{}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),className:`flex items-center gap-1 text-[var(--content-secondary)] hover:text-[var(--content-default)] transition-colors`,"aria-expanded":m,children:[m?(0,G.jsx)(ae,{className:`h-4 w-4`}):(0,G.jsx)(y,{className:`h-4 w-4`}),(0,G.jsx)(`span`,{className:`text-body-medium-default`,children:`Advanced`})]}),(0,G.jsxs)(`div`,{className:m?`mt-4 space-y-4`:`hidden`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Background`}),(0,G.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`When your assistant acts without you — scheduled tasks, background jobs, and external triggers.`}),(0,G.jsx)(`div`,{className:`mt-2`,style:{maxWidth:280},children:(0,G.jsx)(f,{value:c,onChange:T,options:J,disabled:A})}),O&&(0,G.jsx)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:O.description})]}),(0,G.jsx)(q,{}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Headless`}),(0,G.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`When triggered externally with no interactive client.`}),(0,G.jsx)(`div`,{className:`mt-2`,style:{maxWidth:280},children:(0,G.jsx)(f,{value:u,onChange:E,options:J,disabled:A})}),k&&(0,G.jsx)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:k.description})]})]})]})]})]})}var Y=e(a(),1),le=[`bash`,`file_read`,`file_write`,`file_edit`,`web_fetch`,`skill_load`],ue=[{value:`low`,label:`Low`,description:`Auto-approve without prompting`},{value:`medium`,label:`Medium`,description:`Prompt before executing`},{value:`high`,label:`High`,description:`Always require explicit approval`}];function de({assistantId:e,existingRule:t,onClose:n,onSaved:r}){let i=(0,W.useRef)(null),[a,o]=(0,W.useState)(t.tool),[s,c]=(0,W.useState)(t.pattern),[l,u]=(0,W.useState)(t.risk),[d,p]=(0,W.useState)(t.description??``),[h,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(null),b=s.trim(),x=b.length>0&&!h,C=(0,W.useCallback)(async n=>{if(n.preventDefault(),!x)return;let i=d.trim()||`${a} — ${b}`;_(!0),y(null);try{await I(e,t.id,{risk:l,description:i}),r()}catch(e){y(e instanceof Error?e.message:`Failed to save trust rule.`)}finally{_(!1)}},[e,x,d,t,r,l,a,b]);return(0,Y.createPortal)((0,G.jsx)(`div`,{ref:i,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`trust-rule-form-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onKeyDown:(0,W.useCallback)(e=>{e.key===`Escape`&&n()},[n]),onClick:(0,W.useCallback)(e=>{e.target===i.current&&n()},[n]),children:(0,G.jsxs)(`div`,{className:`mx-4 flex max-h-[calc(100vh-2rem)] w-full max-w-md flex-col rounded-xl border border-[var(--border-base)] bg-[var(--surface-lift)] shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--border-base)] px-6 py-4`,children:[(0,G.jsx)(`h2`,{id:`trust-rule-form-title`,className:`text-title-medium text-[var(--content-default)]`,children:`Edit Trust Rule`}),(0,G.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close`,className:`rounded-lg p-1.5 text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-base)] hover:text-[var(--content-default)]`,children:(0,G.jsx)(S,{className:`h-4 w-4`})})]}),(0,G.jsxs)(`form`,{onSubmit:e=>void C(e),className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-6 py-4`,children:[v&&(0,G.jsx)(m,{tone:`error`,children:v}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`trust-rule-tool`,className:`block text-body-medium-default text-[var(--content-default)]`,children:`Tool`}),(0,G.jsx)(`div`,{className:`mt-1`,children:(0,G.jsx)(f,{value:a,onChange:o,disabled:!0,options:le.map(e=>({value:e,label:e}))})})]}),(0,G.jsx)(g,{label:`Pattern`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`e.g., git *`,disabled:!0}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:`Risk Level`}),(0,G.jsx)(`div`,{className:`mt-2 flex gap-2`,children:ue.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>u(e.value),className:`flex-1 rounded-lg border px-3 py-2 text-left text-body-small-default transition-colors ${l===e.value?e.value===`low`?`border-[var(--system-positive-strong)] bg-[var(--system-positive-weak)] text-[var(--system-positive-strong)]`:e.value===`medium`?`border-[var(--system-warning-strong)] bg-[var(--system-warning-weak)] text-[var(--system-warning-strong)]`:`border-[var(--system-negative-strong)] bg-[var(--system-negative-weak)] text-[var(--system-negative-strong)]`:`border-[var(--border-element)] text-[var(--content-default)] hover:bg-[var(--surface-base)]`}`,children:[(0,G.jsx)(`div`,{children:e.label}),(0,G.jsx)(`div`,{className:`mt-0.5 text-label-medium-default leading-tight opacity-70`,children:e.description})]},e.value))})]}),(0,G.jsx)(g,{label:`Description (optional)`,type:`text`,value:d,onChange:e=>p(e.target.value),placeholder:`${a} — ${b||`pattern`}`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-lg border border-[var(--border-element)] bg-white px-4 py-2 text-body-medium-default text-[var(--content-default)] transition-colors hover:bg-[var(--surface-base)] dark:border-[var(--border-base)] dark:bg-[var(--surface-lift)] dark:hover:bg-[var(--ghost-hover)]`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`submit`,disabled:!x,className:`rounded-lg bg-[var(--system-positive-strong)] px-4 py-2 text-body-medium-default text-white transition-colors hover:bg-[var(--system-positive-strong)] disabled:cursor-not-allowed disabled:opacity-50`,children:h?`Saving…`:`Save`})]})]})]})}),document.body)}function fe(e){return e.origin===`default`&&!e.userModified}function pe(e,t){let n=new Set,r=[];for(let t of e)n.has(t.id)||(n.add(t.id),r.push(t));for(let e of t)n.has(e.id)||(n.add(e.id),r.push(e));return r.sort((e,t)=>e.tool===t.tool?e.description.localeCompare(t.description):e.tool.localeCompare(t.tool))}function me(e){switch(e){case`low`:return`positive`;case`medium`:return`warning`;case`high`:return`negative`}}function X(e){return e.charAt(0).toUpperCase()+e.slice(1)}function he({assistantId:e,onClose:t}){let n=(0,W.useRef)(null),[r,i]=(0,W.useState)([]),[a,o]=(0,W.useState)(!0),[s,c]=(0,W.useState)(null),[l,d]=(0,W.useState)(null),[f,g]=(0,W.useState)(null),[v,y]=(0,W.useState)(!1),b=(0,W.useCallback)(async t=>{if(t){let[t,n]=await Promise.all([V(e),V(e,{origin:`default`})]);return pe(t,n)}return V(e)},[e]),S=(0,W.useCallback)(async()=>{o(!0);try{i(await b(v)),c(null)}catch(e){c(e instanceof Error?e.message:`Failed to load trust rules.`)}finally{o(!1)}},[b,v]);(0,W.useEffect)(()=>{let e=!1;return(async()=>{o(!0);try{let t=await b(v);e||(i(t),c(null))}catch(t){e||c(t instanceof Error?t.message:`Failed to load trust rules.`)}finally{e||o(!1)}})(),()=>{e=!0}},[b,v]);let C=(0,W.useCallback)(async()=>{if(f)try{await L(e,f.id),S()}catch(e){c(e instanceof Error?e.message:`Failed to delete trust rule.`)}finally{g(null)}},[e,f,S]);return(0,Y.createPortal)((0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{ref:n,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`trust-rules-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onKeyDown:(0,W.useCallback)(e=>{e.key===`Escape`&&t()},[t]),onClick:(0,W.useCallback)(e=>{e.target===n.current&&t()},[t]),children:(0,G.jsxs)(`div`,{className:`mx-4 flex max-h-[80vh] w-full max-w-2xl flex-col rounded-xl border border-[var(--border-base)] bg-[var(--surface-lift)] shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--border-base)] px-6 py-4`,children:[(0,G.jsx)(`h2`,{id:`trust-rules-title`,className:`text-title-medium text-[var(--content-default)]`,children:`Trust Rules`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(_,{checked:v,onChange:y,label:`Show all defaults`}),(0,G.jsx)(u,{variant:`outlined`,onClick:t,children:`Done`})]})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-4`,children:[s&&(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsx)(m,{tone:`error`,children:s})}),a?(0,G.jsx)(`div`,{className:`flex h-48 items-center justify-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Loading…`}):r.length===0?(0,G.jsxs)(`div`,{className:`flex h-48 flex-col items-center justify-center gap-2 px-6 text-[var(--content-tertiary)]`,children:[(0,G.jsx)(N,{className:`h-8 w-8`}),(0,G.jsx)(`p`,{className:`max-w-xs text-center text-body-medium-lighter`,children:`No trust rules yet. Rules are created when you classify actions from permission prompts.`})]}):(0,G.jsx)(`ul`,{className:`divide-y divide-[var(--border-base)]`,children:r.map(e=>{let t=fe(e);return(0,G.jsxs)(`li`,{className:`flex items-start gap-3 py-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e.tool}),(0,G.jsx)(h,{tone:me(e.risk),children:X(e.risk)}),e.origin===`default`&&(0,G.jsx)(h,{tone:`neutral`,children:`Default`}),e.userModified&&(0,G.jsx)(h,{tone:`warning`,children:`Modified`})]}),(0,G.jsx)(`div`,{className:`mt-1 truncate font-mono text-body-small-default text-[var(--content-secondary)]`,children:e.pattern}),e.description&&(0,G.jsx)(`div`,{className:`mt-0.5 truncate text-body-small-default text-[var(--content-tertiary)]`,children:e.description})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsx)(`button`,{type:`button`,"aria-label":`Edit ${e.tool} rule`,onClick:()=>d(e),className:`rounded-lg p-1.5 text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-base)] hover:text-[var(--content-default)]`,children:(0,G.jsx)(x,{className:`h-4 w-4`})}),(!t||e.userModified)&&(0,G.jsx)(`button`,{type:`button`,"aria-label":`Delete ${e.tool} rule`,onClick:()=>g(e),className:`rounded-lg p-1.5 text-[var(--system-negative-strong)] transition-colors hover:bg-[var(--system-negative-weak)]`,children:(0,G.jsx)(P,{className:`h-4 w-4`})})]})]},e.id)})})]})]})}),l&&(0,G.jsx)(de,{assistantId:e,existingRule:l,onClose:()=>d(null),onSaved:()=>{d(null),S()}}),(0,G.jsx)(p,{open:f!==null,title:`Delete Trust Rule?`,message:f?`Remove the ${X(f.risk).toLowerCase()}-risk rule for ${f.tool} matching "${f.pattern}"?`:``,confirmLabel:`Delete`,cancelLabel:`Cancel`,destructive:!0,onConfirm:()=>void C(),onCancel:()=>g(null)})]}),document.body)}function Z(){let e=H(),[t,n]=(0,W.useState)(!1);return(0,G.jsxs)(d,{children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(N,{className:`mt-0.5 h-5 w-5 shrink-0 text-[var(--content-secondary)]`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`h2`,{className:`text-title-medium text-[var(--content-default)]`,children:`Trust Rules`}),(0,G.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Manage per-tool rules that control which actions auto-approve and which require your explicit permission.`})]}),(0,G.jsx)(u,{variant:`outlined`,onClick:()=>n(!0),children:`Manage`})]}),t&&(0,G.jsx)(he,{assistantId:e,onClose:()=>n(!1)})]})}var ge=[{value:`dontRetain`,label:`Don't retain`},{value:`oneHour`,label:`1 hour`},{value:`oneDay`,label:`1 day`},{value:`sevenDays`,label:`7 days`},{value:`thirtyDays`,label:`30 days`},{value:`ninetyDays`,label:`90 days`},{value:`keepForever`,label:`Keep forever`}],_e=`thirtyDays`;function Q({label:e,helperText:t,checked:n,onChange:r}){return(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e}),(0,G.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-tertiary)]`,children:t})]}),(0,G.jsx)(_,{checked:n,onChange:r,label:e})]})}function $(){return(0,G.jsx)(`div`,{className:`h-px bg-[var(--surface-active)] dark:bg-[var(--surface-lift)]`})}function ve(){let e=z({platformHostedOnly:!0}),i=O(),[a,o]=(0,W.useState)(()=>t(`shareAnalytics`,!0)),[s,c]=(0,W.useState)(()=>t(`shareDiagnostics`,!0)),[l,u]=(0,W.useState)(()=>r(`llmLogRetention`,_e));return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(se,{}),(0,G.jsx)(Z,{}),(0,G.jsx)(ce,{}),(0,G.jsx)(U,{title:`Privacy`,children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(Q,{label:`Share Analytics`,helperText:`Send anonymous product usage data. Your conversations and personal data are never included.`,checked:a,onChange:()=>{let e=!a;o(e),D(`share_analytics`,e,i)}}),(0,G.jsx)($,{}),(0,G.jsx)(Q,{label:`Share Diagnostics`,helperText:`Send crash reports and performance metrics. Your conversations and personal data are never included.`,checked:s,onChange:()=>{let e=!s;c(e),D(`share_diagnostics`,e,i)}}),(0,G.jsx)($,{}),(0,G.jsx)(K,{}),e!==`gated`&&(0,G.jsx)($,{}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`llm-log-retention`,className:`block text-body-medium-default text-[var(--content-default)]`,children:`LLM Request Log Retention`}),(0,G.jsx)(`div`,{className:`mt-2`,style:{maxWidth:280},children:(0,G.jsx)(f,{value:l,onChange:e=>{u(e),n(`llmLogRetention`,e)},options:ge})}),(0,G.jsx)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:`How long to keep LLM request and response logs on this device. These logs record the prompts and completions sent to model providers and are used for debugging. Shorter retention improves privacy; longer retention helps troubleshoot issues.`})]})]})})]})}export{ve as PrivacyPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{n as t,o as n,r}from"./device-settings-C07QvMzm.js";import{t as i}from"./react-DJZBPgpf.js";import{T as a}from"./portal-container-DIXEBWUe.js";import{n as o}from"./QueryClientProvider-DNHWXaGq.js";import{t as s}from"./useQuery-D2zf6Uhu.js";import{t as c}from"./useMutation-BuofVRHk.js";import{t as l}from"./jsx-runtime-CVSDxk6A.js";import{t as u}from"./button-DdEh-9f_.js";import{t as d}from"./card-CL5iEMJO.js";import{t as f}from"./dropdown-CocFV5yi.js";import{t as p}from"./confirm-dialog-NYG-K9zN.js";import{t as m}from"./notice-CF2pptne.js";import{t as h}from"./tag-Ccr7Quy6.js";import{t as g}from"./input-Cu3PPVCq.js";import{t as _}from"./toggle-CEm3M86o.js";import{n as v}from"./toast-DU1nH33j.js";import{t as y}from"./chevron-right-zTNPbA1m.js";import{t as b}from"./loader-circle-BSAFLoPH.js";import{t as x}from"./pencil-BA9LOIzP.js";import{t as S}from"./x-BDqbYVtS.js";import{C,O as w,S as T,b as E,d as D,r as O,v as k,w as A,x as j,y as ee}from"./auth-store-CiQCAKS1.js";import{t as te}from"./sdk.gen-BO4vbMAj.js";import{$ as M,Gi as N,Ni as P,Q as F,S as I,b as L,d as R,et as z,f as ne,nt as re,p as ie,po as ae,tt as oe,u as B,x as V}from"./index-DGojzQtP.js";import{t as H}from"./use-active-assistant-id-BIhArlF_.js";import{t as U}from"./detail-card-B5j4Rqau.js";var W=e(i(),1),G=l();function K(){let e=z({platformHostedOnly:!0}),t=F(),n=M(),r=o(),{data:i,isLoading:a,isError:l}=s({...oe(),enabled:e===`full`&&t}),u=c({mutationFn:async e=>{let{data:t}=await te({body:{access_consented:e},throwOnError:!0});return t},onSuccess:e=>{r.setQueryData(re(),e),v.success(e?.access_consented?`Admin data access enabled.`:`Admin data access disabled.`)},onError:()=>{v.error(`Failed to update log access consent.`)}});if(e===`gated`)return null;let d=e===`full`&&n,f=i?.access_consented??!1,p=e!==`full`||!t||a||l||u.isPending;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Allow admin access to assistant data`}),(0,G.jsxs)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-tertiary)]`,children:[`Lets Vellum administrators reach privileged data on your assistant pod for debugging — today this means tailing the daily assistant log at`,` `,(0,G.jsx)(`code`,{className:`rounded bg-[var(--surface-base)] px-1.5 font-mono text-[var(--content-secondary)] dark:bg-[var(--surface-lift)] dark:text-[var(--content-default)]`,children:`/workspace/data/logs/assistant-YYYY-MM-DD.log`}),`. Off by default. Turn on temporarily when asking support to investigate an issue, then turn off when you're done.`]}),e===`full`&&l&&(0,G.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--system-negative-strong)]`,children:`Failed to load consent setting.`})]}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:e===`disabled`?null:(0,G.jsxs)(G.Fragment,{children:[(u.isPending||d)&&(0,G.jsx)(b,{className:`h-4 w-4 animate-spin text-[var(--content-tertiary)]`}),(0,G.jsx)(_,{checked:f,disabled:p,onChange:()=>u.mutate(!f)})]})})]}),e===`disabled`&&(0,G.jsx)(m,{tone:`info`,className:`mt-3`,children:`Log in to the Vellum platform to manage admin data access.`})]})}function se(){let e=w(),[t,n]=(0,W.useState)(()=>j()),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(`Face ID`),[s,c]=(0,W.useState)(!1);if((0,W.useEffect)(()=>{e&&(E().then(i),ee().then(o))},[e]),!e||!r)return null;let l=async()=>{c(!0);try{if(t)T(!1),await k(),n(!1);else{let e=A();e&&await C(e),T(!0),n(!0)}}finally{c(!1)}};return(0,G.jsx)(U,{title:`Security`,children:(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsxs)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:[`Use `,a,` for sign-in`]}),(0,G.jsxs)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-tertiary)]`,children:[`When your session expires, verify with `,a,` or your device passcode instead of signing in again.`]})]}),(0,G.jsx)(_,{checked:t,onChange:()=>void l(),disabled:s})]})})}function q(){return(0,G.jsx)(`div`,{className:`h-px bg-[var(--surface-active)] dark:bg-[var(--surface-lift)]`})}var J=B.map(e=>({value:e.id,label:e.label,icon:(0,G.jsx)(e.icon,{className:`h-3.5 w-3.5`})}));function ce(){let e=H(),t=o(),{data:n,isError:r}=s({queryKey:[`thresholds`,e],queryFn:()=>ne(e),staleTime:3e4}),[i,a]=(0,W.useState)(`relaxed`),[c,l]=(0,W.useState)(`conservative`),[u,p]=(0,W.useState)(`strict`),[m,h]=(0,W.useState)(!1),g=(0,W.useRef)(!1),[_,v]=(0,W.useState)(!1),b=(0,W.useRef)(null),x=(0,W.useRef)(null);(0,W.useEffect)(()=>{!n||g.current||(a(R(n.interactive).id),l(R(n.autonomous).id),p(R(n.headless).id),v(!0))},[n]),(0,W.useEffect)(()=>()=>{b.current!==null&&(clearTimeout(b.current),b.current=null,x.current?.(),x.current=null)},[]);let S=(0,W.useCallback)((n,r,i)=>{if(!e||!_)return;let a=B.find(e=>e.id===n)?.riskThreshold,o=B.find(e=>e.id===r)?.riskThreshold,s=B.find(e=>e.id===i)?.riskThreshold;!a||!o||!s||ie(e,{interactive:a,autonomous:o,headless:s}).then(()=>{t.invalidateQueries({queryKey:[`thresholds`,e]})}).catch(()=>{})},[e,_,t]),C=(0,W.useCallback)((e,t,n)=>{b.current!==null&&clearTimeout(b.current),x.current=()=>S(e,t,n),b.current=setTimeout(()=>{x.current?.(),b.current=null,x.current=null},500)},[S]),w=(0,W.useCallback)(e=>{g.current=!0,a(e),C(e,c,u)},[c,u,C]),T=(0,W.useCallback)(e=>{g.current=!0,l(e),C(i,e,u)},[i,u,C]),E=(0,W.useCallback)(e=>{g.current=!0,p(e),C(i,c,e)},[i,c,C]),D=B.find(e=>e.id===i),O=B.find(e=>e.id===c),k=B.find(e=>e.id===u),A=!e||!_;return(0,G.jsxs)(d,{children:[(0,G.jsx)(`h2`,{className:`text-title-medium text-[var(--content-default)]`,children:`Risk Tolerance`}),(0,G.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Control which actions your assistant can take without asking first. Each action is classified by risk level — your tolerance determines which levels auto-approve.`}),r&&(0,G.jsx)(`p`,{className:`mt-2 text-body-small-default text-[var(--system-negative-strong)]`,children:`Could not load threshold settings. Check your connection and reload.`}),(0,G.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Conversations`}),(0,G.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`When you're chatting with your assistant directly.`}),(0,G.jsx)(`div`,{className:`mt-2`,style:{maxWidth:280},children:(0,G.jsx)(f,{value:i,onChange:w,options:J,disabled:A})}),D&&(0,G.jsx)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:D.description})]}),(0,G.jsx)(q,{}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),className:`flex items-center gap-1 text-[var(--content-secondary)] hover:text-[var(--content-default)] transition-colors`,"aria-expanded":m,children:[m?(0,G.jsx)(ae,{className:`h-4 w-4`}):(0,G.jsx)(y,{className:`h-4 w-4`}),(0,G.jsx)(`span`,{className:`text-body-medium-default`,children:`Advanced`})]}),(0,G.jsxs)(`div`,{className:m?`mt-4 space-y-4`:`hidden`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Background`}),(0,G.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`When your assistant acts without you — scheduled tasks, background jobs, and external triggers.`}),(0,G.jsx)(`div`,{className:`mt-2`,style:{maxWidth:280},children:(0,G.jsx)(f,{value:c,onChange:T,options:J,disabled:A})}),O&&(0,G.jsx)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:O.description})]}),(0,G.jsx)(q,{}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Headless`}),(0,G.jsx)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`When triggered externally with no interactive client.`}),(0,G.jsx)(`div`,{className:`mt-2`,style:{maxWidth:280},children:(0,G.jsx)(f,{value:u,onChange:E,options:J,disabled:A})}),k&&(0,G.jsx)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:k.description})]})]})]})]})]})}var Y=e(a(),1),le=[`bash`,`file_read`,`file_write`,`file_edit`,`web_fetch`,`skill_load`],ue=[{value:`low`,label:`Low`,description:`Auto-approve without prompting`},{value:`medium`,label:`Medium`,description:`Prompt before executing`},{value:`high`,label:`High`,description:`Always require explicit approval`}];function de({assistantId:e,existingRule:t,onClose:n,onSaved:r}){let i=(0,W.useRef)(null),[a,o]=(0,W.useState)(t.tool),[s,c]=(0,W.useState)(t.pattern),[l,u]=(0,W.useState)(t.risk),[d,p]=(0,W.useState)(t.description??``),[h,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(null),b=s.trim(),x=b.length>0&&!h,C=(0,W.useCallback)(async n=>{if(n.preventDefault(),!x)return;let i=d.trim()||`${a} — ${b}`;_(!0),y(null);try{await I(e,t.id,{risk:l,description:i}),r()}catch(e){y(e instanceof Error?e.message:`Failed to save trust rule.`)}finally{_(!1)}},[e,x,d,t,r,l,a,b]);return(0,Y.createPortal)((0,G.jsx)(`div`,{ref:i,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`trust-rule-form-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onKeyDown:(0,W.useCallback)(e=>{e.key===`Escape`&&n()},[n]),onClick:(0,W.useCallback)(e=>{e.target===i.current&&n()},[n]),children:(0,G.jsxs)(`div`,{className:`mx-4 flex max-h-[calc(100vh-2rem)] w-full max-w-md flex-col rounded-xl border border-[var(--border-base)] bg-[var(--surface-lift)] shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--border-base)] px-6 py-4`,children:[(0,G.jsx)(`h2`,{id:`trust-rule-form-title`,className:`text-title-medium text-[var(--content-default)]`,children:`Edit Trust Rule`}),(0,G.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close`,className:`rounded-lg p-1.5 text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-base)] hover:text-[var(--content-default)]`,children:(0,G.jsx)(S,{className:`h-4 w-4`})})]}),(0,G.jsxs)(`form`,{onSubmit:e=>void C(e),className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-6 py-4`,children:[v&&(0,G.jsx)(m,{tone:`error`,children:v}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`trust-rule-tool`,className:`block text-body-medium-default text-[var(--content-default)]`,children:`Tool`}),(0,G.jsx)(`div`,{className:`mt-1`,children:(0,G.jsx)(f,{value:a,onChange:o,disabled:!0,options:le.map(e=>({value:e,label:e}))})})]}),(0,G.jsx)(g,{label:`Pattern`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`e.g., git *`,disabled:!0}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:`Risk Level`}),(0,G.jsx)(`div`,{className:`mt-2 flex gap-2`,children:ue.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>u(e.value),className:`flex-1 rounded-lg border px-3 py-2 text-left text-body-small-default transition-colors ${l===e.value?e.value===`low`?`border-[var(--system-positive-strong)] bg-[var(--system-positive-weak)] text-[var(--system-positive-strong)]`:e.value===`medium`?`border-[var(--system-warning-strong)] bg-[var(--system-warning-weak)] text-[var(--system-warning-strong)]`:`border-[var(--system-negative-strong)] bg-[var(--system-negative-weak)] text-[var(--system-negative-strong)]`:`border-[var(--border-element)] text-[var(--content-default)] hover:bg-[var(--surface-base)]`}`,children:[(0,G.jsx)(`div`,{children:e.label}),(0,G.jsx)(`div`,{className:`mt-0.5 text-label-medium-default leading-tight opacity-70`,children:e.description})]},e.value))})]}),(0,G.jsx)(g,{label:`Description (optional)`,type:`text`,value:d,onChange:e=>p(e.target.value),placeholder:`${a} — ${b||`pattern`}`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-lg border border-[var(--border-element)] bg-white px-4 py-2 text-body-medium-default text-[var(--content-default)] transition-colors hover:bg-[var(--surface-base)] dark:border-[var(--border-base)] dark:bg-[var(--surface-lift)] dark:hover:bg-[var(--ghost-hover)]`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`submit`,disabled:!x,className:`rounded-lg bg-[var(--system-positive-strong)] px-4 py-2 text-body-medium-default text-white transition-colors hover:bg-[var(--system-positive-strong)] disabled:cursor-not-allowed disabled:opacity-50`,children:h?`Saving…`:`Save`})]})]})]})}),document.body)}function fe(e){return e.origin===`default`&&!e.userModified}function pe(e,t){let n=new Set,r=[];for(let t of e)n.has(t.id)||(n.add(t.id),r.push(t));for(let e of t)n.has(e.id)||(n.add(e.id),r.push(e));return r.sort((e,t)=>e.tool===t.tool?e.description.localeCompare(t.description):e.tool.localeCompare(t.tool))}function me(e){switch(e){case`low`:return`positive`;case`medium`:return`warning`;case`high`:return`negative`}}function X(e){return e.charAt(0).toUpperCase()+e.slice(1)}function he({assistantId:e,onClose:t}){let n=(0,W.useRef)(null),[r,i]=(0,W.useState)([]),[a,o]=(0,W.useState)(!0),[s,c]=(0,W.useState)(null),[l,d]=(0,W.useState)(null),[f,g]=(0,W.useState)(null),[v,y]=(0,W.useState)(!1),b=(0,W.useCallback)(async t=>{if(t){let[t,n]=await Promise.all([V(e),V(e,{origin:`default`})]);return pe(t,n)}return V(e)},[e]),S=(0,W.useCallback)(async()=>{o(!0);try{i(await b(v)),c(null)}catch(e){c(e instanceof Error?e.message:`Failed to load trust rules.`)}finally{o(!1)}},[b,v]);(0,W.useEffect)(()=>{let e=!1;return(async()=>{o(!0);try{let t=await b(v);e||(i(t),c(null))}catch(t){e||c(t instanceof Error?t.message:`Failed to load trust rules.`)}finally{e||o(!1)}})(),()=>{e=!0}},[b,v]);let C=(0,W.useCallback)(async()=>{if(f)try{await L(e,f.id),S()}catch(e){c(e instanceof Error?e.message:`Failed to delete trust rule.`)}finally{g(null)}},[e,f,S]);return(0,Y.createPortal)((0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{ref:n,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`trust-rules-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onKeyDown:(0,W.useCallback)(e=>{e.key===`Escape`&&t()},[t]),onClick:(0,W.useCallback)(e=>{e.target===n.current&&t()},[t]),children:(0,G.jsxs)(`div`,{className:`mx-4 flex max-h-[80vh] w-full max-w-2xl flex-col rounded-xl border border-[var(--border-base)] bg-[var(--surface-lift)] shadow-xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--border-base)] px-6 py-4`,children:[(0,G.jsx)(`h2`,{id:`trust-rules-title`,className:`text-title-medium text-[var(--content-default)]`,children:`Trust Rules`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(_,{checked:v,onChange:y,label:`Show all defaults`}),(0,G.jsx)(u,{variant:`outlined`,onClick:t,children:`Done`})]})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-4`,children:[s&&(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsx)(m,{tone:`error`,children:s})}),a?(0,G.jsx)(`div`,{className:`flex h-48 items-center justify-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Loading…`}):r.length===0?(0,G.jsxs)(`div`,{className:`flex h-48 flex-col items-center justify-center gap-2 px-6 text-[var(--content-tertiary)]`,children:[(0,G.jsx)(N,{className:`h-8 w-8`}),(0,G.jsx)(`p`,{className:`max-w-xs text-center text-body-medium-lighter`,children:`No trust rules yet. Rules are created when you classify actions from permission prompts.`})]}):(0,G.jsx)(`ul`,{className:`divide-y divide-[var(--border-base)]`,children:r.map(e=>{let t=fe(e);return(0,G.jsxs)(`li`,{className:`flex items-start gap-3 py-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e.tool}),(0,G.jsx)(h,{tone:me(e.risk),children:X(e.risk)}),e.origin===`default`&&(0,G.jsx)(h,{tone:`neutral`,children:`Default`}),e.userModified&&(0,G.jsx)(h,{tone:`warning`,children:`Modified`})]}),(0,G.jsx)(`div`,{className:`mt-1 truncate font-mono text-body-small-default text-[var(--content-secondary)]`,children:e.pattern}),e.description&&(0,G.jsx)(`div`,{className:`mt-0.5 truncate text-body-small-default text-[var(--content-tertiary)]`,children:e.description})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsx)(`button`,{type:`button`,"aria-label":`Edit ${e.tool} rule`,onClick:()=>d(e),className:`rounded-lg p-1.5 text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-base)] hover:text-[var(--content-default)]`,children:(0,G.jsx)(x,{className:`h-4 w-4`})}),(!t||e.userModified)&&(0,G.jsx)(`button`,{type:`button`,"aria-label":`Delete ${e.tool} rule`,onClick:()=>g(e),className:`rounded-lg p-1.5 text-[var(--system-negative-strong)] transition-colors hover:bg-[var(--system-negative-weak)]`,children:(0,G.jsx)(P,{className:`h-4 w-4`})})]})]},e.id)})})]})]})}),l&&(0,G.jsx)(de,{assistantId:e,existingRule:l,onClose:()=>d(null),onSaved:()=>{d(null),S()}}),(0,G.jsx)(p,{open:f!==null,title:`Delete Trust Rule?`,message:f?`Remove the ${X(f.risk).toLowerCase()}-risk rule for ${f.tool} matching "${f.pattern}"?`:``,confirmLabel:`Delete`,cancelLabel:`Cancel`,destructive:!0,onConfirm:()=>void C(),onCancel:()=>g(null)})]}),document.body)}function Z(){let e=H(),[t,n]=(0,W.useState)(!1);return(0,G.jsxs)(d,{children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(N,{className:`mt-0.5 h-5 w-5 shrink-0 text-[var(--content-secondary)]`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`h2`,{className:`text-title-medium text-[var(--content-default)]`,children:`Trust Rules`}),(0,G.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Manage per-tool rules that control which actions auto-approve and which require your explicit permission.`})]}),(0,G.jsx)(u,{variant:`outlined`,onClick:()=>n(!0),children:`Manage`})]}),t&&(0,G.jsx)(he,{assistantId:e,onClose:()=>n(!1)})]})}var ge=[{value:`dontRetain`,label:`Don't retain`},{value:`oneHour`,label:`1 hour`},{value:`oneDay`,label:`1 day`},{value:`sevenDays`,label:`7 days`},{value:`thirtyDays`,label:`30 days`},{value:`ninetyDays`,label:`90 days`},{value:`keepForever`,label:`Keep forever`}],_e=`thirtyDays`;function Q({label:e,helperText:t,checked:n,onChange:r}){return(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`div`,{className:`text-body-medium-default text-[var(--content-default)]`,children:e}),(0,G.jsx)(`p`,{className:`mt-1 text-body-small-default text-[var(--content-tertiary)]`,children:t})]}),(0,G.jsx)(_,{checked:n,onChange:r,label:e})]})}function $(){return(0,G.jsx)(`div`,{className:`h-px bg-[var(--surface-active)] dark:bg-[var(--surface-lift)]`})}function ve(){let e=z({platformHostedOnly:!0}),i=O(),[a,o]=(0,W.useState)(()=>t(`shareAnalytics`,!0)),[s,c]=(0,W.useState)(()=>t(`shareDiagnostics`,!0)),[l,u]=(0,W.useState)(()=>r(`llmLogRetention`,_e));return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(se,{}),(0,G.jsx)(Z,{}),(0,G.jsx)(ce,{}),(0,G.jsx)(U,{title:`Privacy`,children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(Q,{label:`Share Analytics`,helperText:`Send anonymous product usage data. Your conversations and personal data are never included.`,checked:a,onChange:()=>{let e=!a;o(e),D(`share_analytics`,e,i)}}),(0,G.jsx)($,{}),(0,G.jsx)(Q,{label:`Share Diagnostics`,helperText:`Send crash reports and performance metrics. Your conversations and personal data are never included.`,checked:s,onChange:()=>{let e=!s;c(e),D(`share_diagnostics`,e,i)}}),(0,G.jsx)($,{}),(0,G.jsx)(K,{}),e!==`gated`&&(0,G.jsx)($,{}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`llm-log-retention`,className:`block text-body-medium-default text-[var(--content-default)]`,children:`LLM Request Log Retention`}),(0,G.jsx)(`div`,{className:`mt-2`,style:{maxWidth:280},children:(0,G.jsx)(f,{value:l,onChange:e=>{u(e),n(`llmLogRetention`,e)},options:ge})}),(0,G.jsx)(`p`,{className:`mt-2 text-body-small-default text-[var(--content-tertiary)]`,children:`How long to keep LLM request and response logs on this device. These logs record the prompts and completions sent to model providers and are used for debugging. Shorter retention improves privacy; longer retention helps troubleshoot issues.`})]})]})})]})}export{ve as PrivacyPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{d as n,h as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./button-DdEh-9f_.js";import{t as o}from"./card-CL5iEMJO.js";import{t as s}from"./checkbox-qlcBvCFW.js";import{t as c}from"./toggle-CEm3M86o.js";import{t as l}from"./is-electron-CavSPgmY.js";import{O as u,n as d,r as f,u as p}from"./auth-store-CiQCAKS1.js";import{i as m,r as h}from"./routes-Dk5Qeryt.js";import{Sr as g,Va as _,br as v,pr as y,xr as b,yr as x}from"./index-BjEJFZTJ.js";import{t as S}from"./onboarding-layout-BIVa2BnX.js";import{a as C,c as w,i as T,n as E,o as D,t as O}from"./step-indicator-dots-Dmj2aMuo.js";var k=e(t(),1),A=i();function j({label:e,helperText:t,checked:n,onChange:r}){let i=(0,k.useId)();return(0,A.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,A.jsx)(c,{checked:n,onChange:r,id:i}),(0,A.jsxs)(`label`,{htmlFor:i,className:`min-w-0 flex-1 cursor-pointer`,children:[(0,A.jsx)(`span`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:e}),(0,A.jsx)(`span`,{className:`mt-1 block text-body-small-default text-[var(--content-tertiary)]`,children:t})]})]})}var M=`[&_button[data-state=checked]]:bg-[var(--primary-base)] [&_svg]:text-[var(--content-inset)]`;function N(){let e=n(),[t]=r(),i=d.use.user()?.id??null,c=l(),N=u(),P=D(y.use.stringFlags().preChatOnboardingExperiment20260606??`control`),[F,I]=v(),[L,R]=b(),[z,B]=g(),[V,H]=x(),U=f();(0,k.useEffect)(()=>{N||C()},[N]);let W=(0,k.useCallback)(()=>{if(p({userId:i,tos:z,ai:V,shareAnalytics:F,shareDiagnostics:L,hasPlatformSession:U}),!N){let e=w(P);T(E.privacyTos,{userId:i,variant:e})}let n=t.get(`hosting`),r=new URLSearchParams;n&&r.set(`hosting`,n);let a=r.toString();e(`${m.onboarding.hatching}${a?`?${a}`:``}`)},[V,U,N,e,P,t,F,L,z,i]),G=(0,A.jsxs)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:[`I agree to the`,` `,(0,A.jsx)(`a`,{href:h(m.docs.legal.termsOfUse),target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Terms of Service`}),` `,`and`,` `,(0,A.jsx)(`a`,{href:h(m.docs.legal.privacyPolicy),target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Privacy Policy`})]}),K=(0,A.jsxs)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:[`I agree to the`,` `,(0,A.jsx)(`a`,{href:h(m.docs.legal.dataSharing),target:`_blank`,rel:`noreferrer`,className:`underline`,children:`AI Data Sharing Policy`})]});return(0,A.jsx)(S,{children:(0,A.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center px-6 ${c?`pb-16`:`py-16`} text-[var(--content-default)]`,style:c?{paddingTop:`calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 1.5rem)`}:void 0,children:[N&&(0,A.jsx)(`div`,{className:`mb-8 flex w-full justify-center`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:(0,A.jsx)(O,{current:2,total:3})}),(0,A.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight`,children:`Before You Start`}),(0,A.jsx)(`p`,{className:`mt-4 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Choose your privacy preferences. You can update these anytime in the Settings.`}),(0,A.jsx)(o,{padding:`md`,className:`mt-8 w-full`,children:(0,A.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,A.jsx)(j,{label:`Share Analytics`,helperText:`Send anonymous product usage data.`,checked:F,onChange:I}),(0,A.jsx)(`div`,{className:`h-px bg-[var(--surface-active)] dark:bg-[var(--surface-lift)]`}),(0,A.jsx)(j,{label:`Share Diagnostics`,helperText:`Send crash reports and performance metrics.`,checked:L,onChange:R}),(0,A.jsx)(`div`,{className:`h-px bg-[var(--surface-active)] dark:bg-[var(--surface-lift)]`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,A.jsx)(_,{className:`h-4 w-4 shrink-0`}),(0,A.jsx)(`span`,{children:`Your conversations and personal data are never included.`})]})]})}),(0,A.jsx)(`div`,{className:`mt-6 flex w-full items-start`,children:(0,A.jsx)(s,{checked:V,onCheckedChange:e=>H(e===!0),label:K,"aria-label":`I agree to the AI Data Sharing Policy`,className:M})}),(0,A.jsx)(`div`,{className:`mt-4 flex w-full items-start`,children:(0,A.jsx)(s,{checked:z,onCheckedChange:e=>B(e===!0),label:G,"aria-label":`I agree to the Terms of Service and Privacy Policy`,className:M})}),(0,A.jsxs)(`div`,{className:`mt-8 flex w-full flex-col gap-2`,children:[(0,A.jsx)(a,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:!z||!V,onClick:W,className:`h-11 text-base`,children:`Start`}),(0,A.jsx)(a,{variant:`outlined`,size:`regular`,fullWidth:!0,onClick:()=>e(-1),className:`h-11 text-base`,children:`Back`})]})]})})}export{N as PrivacyScreen};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{d as n,h as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./button-DdEh-9f_.js";import{t as o}from"./card-CL5iEMJO.js";import{t as s}from"./checkbox-qlcBvCFW.js";import{t as c}from"./toggle-CEm3M86o.js";import{t as l}from"./is-electron-CavSPgmY.js";import{O as u,n as d,r as f,u as p}from"./auth-store-CiQCAKS1.js";import{i as m,r as h}from"./routes-Dk5Qeryt.js";import{Sr as g,Va as _,br as v,pr as y,xr as b,yr as x}from"./index-DGojzQtP.js";import{t as S}from"./onboarding-layout-BIVa2BnX.js";import{a as C,c as w,i as T,n as E,o as D,t as O}from"./step-indicator-dots-C_NCj5FH.js";var k=e(t(),1),A=i();function j({label:e,helperText:t,checked:n,onChange:r}){let i=(0,k.useId)();return(0,A.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,A.jsx)(c,{checked:n,onChange:r,id:i}),(0,A.jsxs)(`label`,{htmlFor:i,className:`min-w-0 flex-1 cursor-pointer`,children:[(0,A.jsx)(`span`,{className:`block text-body-medium-default text-[var(--content-default)]`,children:e}),(0,A.jsx)(`span`,{className:`mt-1 block text-body-small-default text-[var(--content-tertiary)]`,children:t})]})]})}var M=`[&_button[data-state=checked]]:bg-[var(--primary-base)] [&_svg]:text-[var(--content-inset)]`;function N(){let e=n(),[t]=r(),i=d.use.user()?.id??null,c=l(),N=u(),P=D(y.use.stringFlags().preChatOnboardingExperiment20260606??`control`),[F,I]=v(),[L,R]=b(),[z,B]=g(),[V,H]=x(),U=f();(0,k.useEffect)(()=>{N||C()},[N]);let W=(0,k.useCallback)(()=>{if(p({userId:i,tos:z,ai:V,shareAnalytics:F,shareDiagnostics:L,hasPlatformSession:U}),!N){let e=w(P);T(E.privacyTos,{userId:i,variant:e})}let n=t.get(`hosting`),r=new URLSearchParams;n&&r.set(`hosting`,n);let a=r.toString();e(`${m.onboarding.hatching}${a?`?${a}`:``}`)},[V,U,N,e,P,t,F,L,z,i]),G=(0,A.jsxs)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:[`I agree to the`,` `,(0,A.jsx)(`a`,{href:h(m.docs.legal.termsOfUse),target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Terms of Service`}),` `,`and`,` `,(0,A.jsx)(`a`,{href:h(m.docs.legal.privacyPolicy),target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Privacy Policy`})]}),K=(0,A.jsxs)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:[`I agree to the`,` `,(0,A.jsx)(`a`,{href:h(m.docs.legal.dataSharing),target:`_blank`,rel:`noreferrer`,className:`underline`,children:`AI Data Sharing Policy`})]});return(0,A.jsx)(S,{children:(0,A.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center px-6 ${c?`pb-16`:`py-16`} text-[var(--content-default)]`,style:c?{paddingTop:`calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 1.5rem)`}:void 0,children:[N&&(0,A.jsx)(`div`,{className:`mb-8 flex w-full justify-center`,style:{animation:`fadeInUp 0.3s ease-out 0.1s both`},children:(0,A.jsx)(O,{current:2,total:3})}),(0,A.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight`,children:`Before You Start`}),(0,A.jsx)(`p`,{className:`mt-4 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Choose your privacy preferences. You can update these anytime in the Settings.`}),(0,A.jsx)(o,{padding:`md`,className:`mt-8 w-full`,children:(0,A.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,A.jsx)(j,{label:`Share Analytics`,helperText:`Send anonymous product usage data.`,checked:F,onChange:I}),(0,A.jsx)(`div`,{className:`h-px bg-[var(--surface-active)] dark:bg-[var(--surface-lift)]`}),(0,A.jsx)(j,{label:`Share Diagnostics`,helperText:`Send crash reports and performance metrics.`,checked:L,onChange:R}),(0,A.jsx)(`div`,{className:`h-px bg-[var(--surface-active)] dark:bg-[var(--surface-lift)]`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,A.jsx)(_,{className:`h-4 w-4 shrink-0`}),(0,A.jsx)(`span`,{children:`Your conversations and personal data are never included.`})]})]})}),(0,A.jsx)(`div`,{className:`mt-6 flex w-full items-start`,children:(0,A.jsx)(s,{checked:V,onCheckedChange:e=>H(e===!0),label:K,"aria-label":`I agree to the AI Data Sharing Policy`,className:M})}),(0,A.jsx)(`div`,{className:`mt-4 flex w-full items-start`,children:(0,A.jsx)(s,{checked:z,onCheckedChange:e=>B(e===!0),label:G,"aria-label":`I agree to the Terms of Service and Privacy Policy`,className:M})}),(0,A.jsxs)(`div`,{className:`mt-8 flex w-full flex-col gap-2`,children:[(0,A.jsx)(a,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:!z||!V,onClick:W,className:`h-11 text-base`,children:`Start`}),(0,A.jsx)(a,{variant:`outlined`,size:`regular`,fullWidth:!0,onClick:()=>e(-1),className:`h-11 text-base`,children:`Back`})]})]})})}export{N as PrivacyScreen};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-CZsNGL6n.js";import{t as n}from"./react-DJZBPgpf.js";import{d as r,h as i,t as a}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{b as s,f as c}from"./resolved-assistants-store-ub66utfl.js";import{I as l,M as u,n as d}from"./auth-store-CiQCAKS1.js";import{c as f}from"./api-DEEx3e9R.js";import{i as p}from"./routes-Dk5Qeryt.js";import{H as m}from"./index-BjEJFZTJ.js";import{r as h,t as g}from"./account-shell-qQqbocXz.js";import{a as _,i as v}from"./login-flow-Bi4ujzeb.js";var y=e(n(),1),b=o();function x(){let[e]=i(),n=r(),o=d.use.refreshSession(),x=e.get(`error`),[S,C]=(0,y.useState)(null),w=(0,y.useRef)(!1),T=e.get(`returnTo`),E=v(e);return(0,y.useEffect)(()=>{w.current||x||(w.current=!0,(async()=>{try{let t=await l(),r=u(t.ok&&!!t.data.user,t.ok?[]:t.flows??[]);switch(r.kind){case`authenticated`:{if(await o(),c())try{let e=await f();if(e.ok&&e.data.length>0&&(await s(e.data),!T)){n(p.assistant,{replace:!0});break}}catch{}let e=p.assistant,{destination:t,requiresFullPageNavigation:r}=_({returnTo:T,fallback:e,authIntent:E});r?window.location.href=t:n(t,{replace:!0});break}case`provider_signup`:{let t=e.get(`returnTo`);n(t?`${p.account.providerSignup}?returnTo=${encodeURIComponent(t)}`:p.account.providerSignup,{replace:!0});break}case`error`:C(r.message);break}}catch(e){t(e,{context:`provider_callback`}),C(`Something went wrong. Please try signing in again.`)}})())},[E,x,o,T,n,e]),x===`signup_closed`?(0,b.jsxs)(g,{children:[(0,b.jsx)(h,{title:`Signups are currently closed`,subtitle:`Join the community to request access or learn when signups reopen.`}),(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,b.jsx)(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-white no-underline transition-colors hover:bg-[var(--primary-hover)]`,children:`Join the community`}),(0,b.jsx)(a,{to:p.account.login,className:`text-sm font-medium text-[var(--content-emphasised)] hover:underline`,children:`Back to sign in`})]})]}):x||S?(0,b.jsxs)(g,{children:[(0,b.jsx)(h,{title:`Authentication failed`,subtitle:S??`Something went wrong during social sign-in. Please try again or use a different method.`}),(0,b.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,b.jsx)(a,{to:p.account.login,className:`inline-flex items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-white no-underline transition-colors hover:bg-[var(--primary-hover)]`,children:`Back to sign in`})})]}):(0,b.jsx)(g,{children:(0,b.jsx)(h,{title:`Completing sign-in...`,subtitle:`Please wait while we finish authenticating you.`})})}export{x as ProviderCallbackPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-CZsNGL6n.js";import{t as n}from"./react-DJZBPgpf.js";import{d as r,h as i,t as a}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as o}from"./jsx-runtime-CVSDxk6A.js";import{b as s,f as c}from"./resolved-assistants-store-ub66utfl.js";import{I as l,M as u,n as d}from"./auth-store-CiQCAKS1.js";import{c as f}from"./api-DEEx3e9R.js";import{i as p}from"./routes-Dk5Qeryt.js";import{H as m}from"./index-DGojzQtP.js";import{r as h,t as g}from"./account-shell-qQqbocXz.js";import{a as _,i as v}from"./login-flow-BZiMiMrf.js";var y=e(n(),1),b=o();function x(){let[e]=i(),n=r(),o=d.use.refreshSession(),x=e.get(`error`),[S,C]=(0,y.useState)(null),w=(0,y.useRef)(!1),T=e.get(`returnTo`),E=v(e);return(0,y.useEffect)(()=>{w.current||x||(w.current=!0,(async()=>{try{let t=await l(),r=u(t.ok&&!!t.data.user,t.ok?[]:t.flows??[]);switch(r.kind){case`authenticated`:{if(await o(),c())try{let e=await f();if(e.ok&&e.data.length>0&&(await s(e.data),!T)){n(p.assistant,{replace:!0});break}}catch{}let e=p.assistant,{destination:t,requiresFullPageNavigation:r}=_({returnTo:T,fallback:e,authIntent:E});r?window.location.href=t:n(t,{replace:!0});break}case`provider_signup`:{let t=e.get(`returnTo`);n(t?`${p.account.providerSignup}?returnTo=${encodeURIComponent(t)}`:p.account.providerSignup,{replace:!0});break}case`error`:C(r.message);break}}catch(e){t(e,{context:`provider_callback`}),C(`Something went wrong. Please try signing in again.`)}})())},[E,x,o,T,n,e]),x===`signup_closed`?(0,b.jsxs)(g,{children:[(0,b.jsx)(h,{title:`Signups are currently closed`,subtitle:`Join the community to request access or learn when signups reopen.`}),(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,b.jsx)(`a`,{href:m,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-white no-underline transition-colors hover:bg-[var(--primary-hover)]`,children:`Join the community`}),(0,b.jsx)(a,{to:p.account.login,className:`text-sm font-medium text-[var(--content-emphasised)] hover:underline`,children:`Back to sign in`})]})]}):x||S?(0,b.jsxs)(g,{children:[(0,b.jsx)(h,{title:`Authentication failed`,subtitle:S??`Something went wrong during social sign-in. Please try again or use a different method.`}),(0,b.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,b.jsx)(a,{to:p.account.login,className:`inline-flex items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-white no-underline transition-colors hover:bg-[var(--primary-hover)]`,children:`Back to sign in`})})]}):(0,b.jsx)(g,{children:(0,b.jsx)(h,{title:`Completing sign-in...`,subtitle:`Please wait while we finish authenticating you.`})})}export{x as ProviderCallbackPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{d as n,h as r,t as i}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{F as o,L as s,R as c,n as l}from"./auth-store-CiQCAKS1.js";import{i as u}from"./routes-Dk5Qeryt.js";import{i as d,n as f,r as p,t as m}from"./account-shell-qQqbocXz.js";import{a as h,o as g}from"./login-flow-Bi4ujzeb.js";var _=e(t(),1),v=a();function y(){let e=n(),[t]=r(),a=l.use.refreshSession(),y=t.get(`returnTo`),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)(``),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(!0),A=(0,_.useRef)(!1);return(0,_.useEffect)(()=>{A.current||(A.current=!0,(async()=>{try{let t=await o();if(!t.ok){e(u.account.login,{replace:!0});return}x(t.data.user.email??``),C(t.data.user.username??``),k(!1)}catch{e(u.account.login,{replace:!0})}})())},[e]),O?(0,v.jsx)(m,{children:(0,v.jsx)(p,{title:`Completing signup...`,subtitle:`Please wait while we load your information.`})}):(0,v.jsxs)(m,{children:[(0,v.jsx)(p,{title:`Complete your account`,subtitle:`We need a few more details to finish setting up your account.`}),(0,v.jsxs)(f,{onSubmit:async t=>{t.preventDefault(),T(null),D(!0);try{let t=await c({email:b,username:S});if(!t.ok){if(s(t)){await a();let t=g(y,u.account.root);t.requiresFullPageNavigation?window.location.href=t.destination:e(t.destination);return}T(t.errors[0]?.message??`Failed to complete signup.`);return}await a();let n=h({returnTo:y,fallback:u.account.root,authIntent:`signup`});n.requiresFullPageNavigation?window.location.href=n.destination:e(n.destination)}catch{T(`Something went wrong. Please try again.`)}finally{D(!1)}},error:w,submitLabel:`Complete signup`,submittingLabel:`Completing...`,isSubmitting:E,footer:(0,v.jsx)(i,{to:u.account.login,className:`text-sm text-stone-400 hover:text-stone-300`,children:`← Back to sign in`}),children:[(0,v.jsx)(d,{id:`email`,type:`email`,autoComplete:`email`,placeholder:`Email`,value:b,onChange:e=>x(e.target.value),required:!0}),(0,v.jsx)(d,{id:`username`,type:`text`,autoComplete:`username`,placeholder:`Username`,value:S,onChange:e=>C(e.target.value),required:!0})]})]})}export{y as ProviderSignupPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{d as n,h as r,t as i}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{F as o,L as s,R as c,n as l}from"./auth-store-CiQCAKS1.js";import{i as u}from"./routes-Dk5Qeryt.js";import{i as d,n as f,r as p,t as m}from"./account-shell-qQqbocXz.js";import{a as h,o as g}from"./login-flow-BZiMiMrf.js";var _=e(t(),1),v=a();function y(){let e=n(),[t]=r(),a=l.use.refreshSession(),y=t.get(`returnTo`),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)(``),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(!0),A=(0,_.useRef)(!1);return(0,_.useEffect)(()=>{A.current||(A.current=!0,(async()=>{try{let t=await o();if(!t.ok){e(u.account.login,{replace:!0});return}x(t.data.user.email??``),C(t.data.user.username??``),k(!1)}catch{e(u.account.login,{replace:!0})}})())},[e]),O?(0,v.jsx)(m,{children:(0,v.jsx)(p,{title:`Completing signup...`,subtitle:`Please wait while we load your information.`})}):(0,v.jsxs)(m,{children:[(0,v.jsx)(p,{title:`Complete your account`,subtitle:`We need a few more details to finish setting up your account.`}),(0,v.jsxs)(f,{onSubmit:async t=>{t.preventDefault(),T(null),D(!0);try{let t=await c({email:b,username:S});if(!t.ok){if(s(t)){await a();let t=g(y,u.account.root);t.requiresFullPageNavigation?window.location.href=t.destination:e(t.destination);return}T(t.errors[0]?.message??`Failed to complete signup.`);return}await a();let n=h({returnTo:y,fallback:u.account.root,authIntent:`signup`});n.requiresFullPageNavigation?window.location.href=n.destination:e(n.destination)}catch{T(`Something went wrong. Please try again.`)}finally{D(!1)}},error:w,submitLabel:`Complete signup`,submittingLabel:`Completing...`,isSubmitting:E,footer:(0,v.jsx)(i,{to:u.account.login,className:`text-sm text-stone-400 hover:text-stone-300`,children:`← Back to sign in`}),children:[(0,v.jsx)(d,{id:`email`,type:`email`,autoComplete:`email`,placeholder:`Email`,value:b,onChange:e=>x(e.target.value),required:!0}),(0,v.jsx)(d,{id:`username`,type:`text`,autoComplete:`username`,placeholder:`Username`,value:S,onChange:e=>C(e.target.value),required:!0})]})]})}export{y as ProviderSignupPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{d as n,h as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./button-DdEh-9f_.js";import{t as o}from"./checkbox-qlcBvCFW.js";import{t as s}from"./is-electron-CavSPgmY.js";import{j as c,n as l,r as u,u as d}from"./auth-store-CiQCAKS1.js";import{i as f,r as p}from"./routes-Dk5Qeryt.js";import{Sr as m,br as h,or as g,xr as _,yr as v}from"./index-BjEJFZTJ.js";import{t as y}from"./onboarding-layout-BIVa2BnX.js";var b=e(t(),1),x=i(),S=`[&_button[data-state=checked]]:bg-[var(--primary-base)] [&_svg]:text-[var(--content-inset)]`;function C(){let e=n(),[t]=r(),i=l.use.user()?.id??null,C=l.use.logout(),w=s(),T=u(),[E,D]=m(),[O,k]=v(),[A]=h(),[j]=_(),M=(0,b.useCallback)(()=>{d({userId:i,tos:E,ai:O,shareAnalytics:A,shareDiagnostics:j,hasPlatformSession:T}),e(c(t.get(`returnTo`),f.assistant),{replace:!0})},[O,T,e,t,A,j,E,i]),N=(0,b.useCallback)(async()=>{await C(),g(f.account.login)},[C]),P=(0,x.jsxs)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:[`I agree to the`,` `,(0,x.jsx)(`a`,{href:p(f.docs.legal.termsOfUse),target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Terms of Service`}),` `,`and`,` `,(0,x.jsx)(`a`,{href:p(f.docs.legal.privacyPolicy),target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Privacy Policy`})]}),F=(0,x.jsxs)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:[`I agree to the`,` `,(0,x.jsx)(`a`,{href:p(f.docs.legal.dataSharing),target:`_blank`,rel:`noreferrer`,className:`underline`,children:`AI Data Sharing Policy`})]});return(0,x.jsx)(y,{showCreatureFooter:!1,children:(0,x.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center px-6 ${w?`pb-16`:`py-16`} text-[var(--content-default)]`,style:w?{paddingTop:`calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 1.5rem)`}:void 0,children:[(0,x.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight`,children:`Updated Terms`}),(0,x.jsx)(`p`,{className:`mt-4 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`We've updated our terms. Please review and re-accept to continue.`}),(0,x.jsx)(`div`,{className:`mt-8 flex w-full items-start`,children:(0,x.jsx)(o,{checked:O,onCheckedChange:e=>k(e===!0),label:F,"aria-label":`I agree to the AI Data Sharing Policy`,className:S})}),(0,x.jsx)(`div`,{className:`mt-4 flex w-full items-start`,children:(0,x.jsx)(o,{checked:E,onCheckedChange:e=>D(e===!0),label:P,"aria-label":`I agree to the Terms of Service and Privacy Policy`,className:S})}),(0,x.jsxs)(`div`,{className:`mt-8 flex w-full flex-col gap-2`,children:[(0,x.jsx)(a,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:!E||!O,onClick:M,className:`h-11 text-base`,children:`Continue`}),(0,x.jsx)(a,{variant:`outlined`,size:`regular`,fullWidth:!0,onClick:N,className:`h-11 text-base`,children:`Log out`})]})]})})}export{C as ReviewTermsScreen};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{d as n,h as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./button-DdEh-9f_.js";import{t as o}from"./checkbox-qlcBvCFW.js";import{t as s}from"./is-electron-CavSPgmY.js";import{j as c,n as l,r as u,u as d}from"./auth-store-CiQCAKS1.js";import{i as f,r as p}from"./routes-Dk5Qeryt.js";import{Sr as m,br as h,or as g,xr as _,yr as v}from"./index-DGojzQtP.js";import{t as y}from"./onboarding-layout-BIVa2BnX.js";var b=e(t(),1),x=i(),S=`[&_button[data-state=checked]]:bg-[var(--primary-base)] [&_svg]:text-[var(--content-inset)]`;function C(){let e=n(),[t]=r(),i=l.use.user()?.id??null,C=l.use.logout(),w=s(),T=u(),[E,D]=m(),[O,k]=v(),[A]=h(),[j]=_(),M=(0,b.useCallback)(()=>{d({userId:i,tos:E,ai:O,shareAnalytics:A,shareDiagnostics:j,hasPlatformSession:T}),e(c(t.get(`returnTo`),f.assistant),{replace:!0})},[O,T,e,t,A,j,E,i]),N=(0,b.useCallback)(async()=>{await C(),g(f.account.login)},[C]),P=(0,x.jsxs)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:[`I agree to the`,` `,(0,x.jsx)(`a`,{href:p(f.docs.legal.termsOfUse),target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Terms of Service`}),` `,`and`,` `,(0,x.jsx)(`a`,{href:p(f.docs.legal.privacyPolicy),target:`_blank`,rel:`noreferrer`,className:`underline`,children:`Privacy Policy`})]}),F=(0,x.jsxs)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:[`I agree to the`,` `,(0,x.jsx)(`a`,{href:p(f.docs.legal.dataSharing),target:`_blank`,rel:`noreferrer`,className:`underline`,children:`AI Data Sharing Policy`})]});return(0,x.jsx)(y,{showCreatureFooter:!1,children:(0,x.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center px-6 ${w?`pb-16`:`py-16`} text-[var(--content-default)]`,style:w?{paddingTop:`calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 1.5rem)`}:void 0,children:[(0,x.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight`,children:`Updated Terms`}),(0,x.jsx)(`p`,{className:`mt-4 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`We've updated our terms. Please review and re-accept to continue.`}),(0,x.jsx)(`div`,{className:`mt-8 flex w-full items-start`,children:(0,x.jsx)(o,{checked:O,onCheckedChange:e=>k(e===!0),label:F,"aria-label":`I agree to the AI Data Sharing Policy`,className:S})}),(0,x.jsx)(`div`,{className:`mt-4 flex w-full items-start`,children:(0,x.jsx)(o,{checked:E,onCheckedChange:e=>D(e===!0),label:P,"aria-label":`I agree to the Terms of Service and Privacy Policy`,className:S})}),(0,x.jsxs)(`div`,{className:`mt-8 flex w-full flex-col gap-2`,children:[(0,x.jsx)(a,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:!E||!O,onClick:M,className:`h-11 text-base`,children:`Continue`}),(0,x.jsx)(a,{variant:`outlined`,size:`regular`,fullWidth:!0,onClick:N,className:`h-11 text-base`,children:`Log out`})]})]})})}export{C as ReviewTermsScreen};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-CZsNGL6n.js";import{t as n}from"./react-DJZBPgpf.js";import{d as r,p as i}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as a}from"./QueryClientProvider-DNHWXaGq.js";import{t as o}from"./useQuery-D2zf6Uhu.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./button-DdEh-9f_.js";import{t as l}from"./notice-CF2pptne.js";import{t as u}from"./tag-Ccr7Quy6.js";import{t as d}from"./panel-item-FzMfzMJA.js";import{n as f,t as p}from"./input-Cu3PPVCq.js";import{t as m}from"./toggle-CEm3M86o.js";import{t as h}from"./modal-BYMhDpQo.js";import{n as g}from"./toast-DU1nH33j.js";import{t as _}from"./calendar-CP_Q3Aw6.js";import{t as v}from"./chevron-right-zTNPbA1m.js";import{t as y}from"./loader-circle-BSAFLoPH.js";import{D as b,E as x,O as S,T as C,_n as w,dn as T,fn as E,gt as D,hn as O,ht as k,mn as A,mt as j,pn as M,pt as N,vn as P}from"./sdk.gen-AJllUeDf.js";import{n as F,r as I,t as L}from"./api-errors-ChauV4ed.js";import{i as R}from"./routes-Dk5Qeryt.js";import{c as ee,l as te,s as ne}from"./query-tags-Cez88bzY.js";import{t as re}from"./assistant-feature-flag-store-0382ImYF.js";import{t as ie}from"./effective-timezone-CKEcAtDc.js";import{Ni as ae,Pn as oe,bo as z,ha as se,ho as ce,ia as B,na as V}from"./index-BjEJFZTJ.js";import{t as le}from"./use-active-assistant-id-BIhArlF_.js";import{t as H}from"./detail-card-B5j4Rqau.js";import{n as ue}from"./usage-window-D5EMg2nb.js";import{t as de}from"./schedules-BJAra2Ob.js";var U=e(n(),1);async function fe(e,t){let{error:n,response:r}=await w({path:{assistant_id:e},body:t,throwOnError:!1});if(F(r,n,`Failed to create schedule.`),!r.ok)throw new L(r.status,I(n,r,`Failed to create schedule.`))}async function pe(e,t,n){let{error:r,response:i}=await E({path:{assistant_id:e,id:t},body:n,throwOnError:!1});if(F(i,r,`Failed to update schedule.`),!i.ok)throw new L(i.status,I(r,i,`Failed to update schedule.`))}async function me(e){return de(e)}async function he(e,t,n=10){let{data:r,error:i,response:a}=await A({path:{assistant_id:e,id:t},query:{limit:n},throwOnError:!1});if(F(a,i,`Failed to load schedule runs.`),!a.ok)throw new L(a.status,I(i,a,`Failed to load schedule runs.`));return r?.runs??[]}async function ge(e,t){let{data:n,error:r,response:i}=await P({path:{assistant_id:e},query:{from:t.from,to:t.to},throwOnError:!1});if(F(i,r,`Failed to load schedule usage.`),!i.ok)throw new L(i.status,I(r,i,`Failed to load schedule usage.`));return n?.summaries??[]}async function _e(e,t,n){let{error:r,response:i}=await O({path:{assistant_id:e,id:t},body:{enabled:n},throwOnError:!1});if(F(i,r,`Failed to toggle schedule.`),!i.ok)throw new L(i.status,I(r,i,`Failed to toggle schedule.`))}async function ve(e,t){let{error:n,response:r}=await T({path:{assistant_id:e,id:t},throwOnError:!1});if(F(r,n,`Failed to delete schedule.`),!r.ok&&r.status!==204)throw new L(r.status,I(n,r,`Failed to delete schedule.`))}async function ye(e,t){let{error:n,response:r}=await M({path:{assistant_id:e,id:t},throwOnError:!1});if(F(r,n,`Failed to run schedule.`),!r.ok)throw new L(r.status,I(n,r,`Failed to run schedule.`))}async function W(e,t=10){let{data:n,error:r,response:i}=await D({path:{assistant_id:e},query:{limit:t},throwOnError:!1});if(F(i,r,`Failed to load heartbeat runs.`),!i.ok)throw new L(i.status,I(r,i,`Failed to load heartbeat runs.`));return(n?.runs??[]).map(e=>({id:e.id,jobId:`heartbeat`,status:e.status,startedAt:e.startedAt??e.scheduledFor,finishedAt:e.finishedAt,durationMs:e.durationMs,output:e.skipReason?`Skipped: ${e.skipReason}`:null,error:e.error,conversationId:e.conversationId,conversationExists:e.conversationExists,conversationArchivedAt:e.conversationArchivedAt,estimatedCostUsd:e.estimatedCostUsd,createdAt:e.createdAt}))}async function G(e,t=10){let{data:n,error:r,response:i}=await S({path:{assistant_id:e},query:{limit:t},throwOnError:!1});if(F(i,r,`Failed to load consolidation runs.`),!i.ok)throw new L(i.status,I(r,i,`Failed to load consolidation runs.`));return(n?.runs??[]).map(e=>({id:e.id,jobId:`consolidation`,status:e.status,startedAt:e.startedAt??e.scheduledFor,finishedAt:e.finishedAt,durationMs:e.durationMs,output:null,error:e.error,conversationId:e.conversationId,conversationExists:e.conversationExists,conversationArchivedAt:e.conversationArchivedAt,estimatedCostUsd:e.estimatedCostUsd,createdAt:e.createdAt}))}async function be(e){let{data:t,error:n,response:r}=await N({path:{assistant_id:e},throwOnError:!1});if(F(r,n,`Failed to load heartbeat config.`),!r.ok||!t)throw new L(r.status,I(n,r,`Failed to load heartbeat config.`));return t}async function K(e,t){let{data:n,error:r,response:i}=await e();if(F(i,r,t),!i.ok||!n)throw new L(i.status,I(r,i,t));return n}async function xe(e,t){return K(()=>j({path:{assistant_id:e},body:t,throwOnError:!1}),`Failed to update heartbeat config.`)}async function Se(e){let{data:t,error:n,response:r}=await k({path:{assistant_id:e},throwOnError:!1});if(F(r,n,`Failed to run heartbeat.`),!r.ok||!t)throw new L(r.status,I(n,r,`Failed to run heartbeat.`));return t}async function Ce(e){let{data:t,error:n,response:r}=await C({path:{assistant_id:e},throwOnError:!1});if(F(r,n,`Failed to load consolidation config.`),!r.ok||!t)throw new L(r.status,I(n,r,`Failed to load consolidation config.`));return t}async function we(e,t){return K(()=>x({path:{assistant_id:e},body:t,throwOnError:!1}),`Failed to update consolidation config.`)}async function Te(e){let{data:t,error:n,response:r}=await b({path:{assistant_id:e},throwOnError:!1});if(F(r,n,`Failed to run consolidation.`),!r.ok||!t)throw new L(r.status,I(n,r,`Failed to run consolidation.`));return t}var q=s(),Ee=[{label:`Every hour`,expression:`0 * * * *`},{label:`Every day at 9am`,expression:`0 9 * * *`},{label:`Every weekday at 9am`,expression:`0 9 * * 1-5`},{label:`Every Monday at 9am`,expression:`0 9 * * 1`},{label:`Every 1st of month, 9am`,expression:`0 9 1 * *`}];function J({isOpen:e,assistantId:t,onClose:n,onCreated:r}){return(0,q.jsx)(h.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,q.jsx)(De,{assistantId:t,onClose:n,onCreated:r}):null})}function De({assistantId:e,onClose:t,onCreated:n}){let[r,i]=(0,U.useState)(``),[a,o]=(0,U.useState)(``),[s,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(``),[m,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(null),y=r.trim(),b=a.trim(),x=s.trim(),S=y.length>0&&b.length>0&&x.length>0&&!m;return(0,q.jsxs)(h.Content,{size:`md`,children:[(0,q.jsxs)(h.Header,{children:[(0,q.jsx)(h.Title,{children:`Create schedule`}),(0,q.jsx)(h.Description,{children:`Schedule a recurring instruction for your assistant. Runs in execute mode — the message is delivered to the assistant on each fire.`})]}),(0,q.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),S){g(!0),v(null);try{let t={name:y,expression:b,message:x},r=u.trim();r&&(t.timezone=r),await fe(e,t),g(!1),n()}catch(e){v(e instanceof Error?e.message:`Failed to create schedule.`),g(!1)}}},children:[(0,q.jsx)(h.Body,{children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsx)(p,{label:`Name`,placeholder:`Morning briefing`,value:r,onChange:e=>i(e.target.value),required:!0,autoFocus:!0,fullWidth:!0}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(p,{label:`Cron expression`,placeholder:`0 9 * * *`,value:a,onChange:e=>o(e.target.value),required:!0,fullWidth:!0,helperText:`Standard 5-field cron (minute hour day month weekday). RRULE expressions are also accepted.`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Ee.map(e=>(0,q.jsx)(c,{variant:`outlined`,size:`compact`,type:`button`,onClick:()=>o(e.expression),children:e.label},e.expression))})]}),(0,q.jsx)(p,{label:`Timezone (optional)`,placeholder:`America/New_York`,value:u,onChange:e=>d(e.target.value),fullWidth:!0,helperText:`IANA timezone name. Leave blank to use UTC.`}),(0,q.jsx)(f,{label:`Message`,placeholder:`What should the assistant do on each fire?`,value:s,onChange:e=>l(e.target.value),required:!0,fullWidth:!0,rows:4}),_?(0,q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:_}):null]})}),(0,q.jsxs)(h.Footer,{children:[(0,q.jsx)(c,{variant:`outlined`,onClick:t,type:`button`,children:`Cancel`}),(0,q.jsx)(c,{variant:`primary`,type:`submit`,disabled:!S,children:m?`Creating…`:`Create schedule`})]})]})]})}function Oe(e=ie(),t=Date.now()){return ue(`7d`,e,t)}function Y(e){return e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0}):`—`}function ke(e){return e==null?`—`:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}var Ae=new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:4});function X(e){return e==null||!Number.isFinite(e)?`—`:Ae.format(e)}function je(e){return`${e.toLocaleString()} ${e===1?`run`:`runs`}`}function Me(e){let t=Math.round(e/6e4);return t>=60&&t%60==0?`Every ${t/60} hr`:`Every ${t} min`}function Ne(e){return!!e.createdFromConversationId&&e.createdFromConversationExists===!0&&e.createdFromConversationArchivedAt==null}function Pe(e){return!!e.conversationId&&e.conversationExists===!0&&e.conversationArchivedAt==null}function Fe(e){return Ne(e)?e.createdFromConversationId??null:null}function Ie(e){return Pe(e)?e.conversationId??null:null}function Le(e){return typeof e==`string`&&e.length>0}var Z={heartbeat:`system-heartbeat`,consolidation:`system-consolidation`};function Re(e,t){return e&&t}function ze(e){switch(e){case Z.heartbeat:return`heartbeat`;case Z.consolidation:return`consolidation`;default:return null}}function Be(e){if(e.cronExpression)return e.timezone?`Cron: ${e.cronExpression} (${e.timezone})`:`Cron: ${e.cronExpression}`;let t=Me(e.intervalMs);return e.activeHoursStart!=null&&e.activeHoursEnd!=null&&(t+=` (${e.activeHoursStart}:00–${e.activeHoursEnd}:00)`),t}function Ve(e){return Me(e.intervalMs)}var He={execute:`positive`,notify:`warning`,script:`neutral`},Ue=1800;function We(e){let t=[],n=[];for(let r of e)r.isOneShot?n.push(r):t.push(r);return t.sort((e,t)=>e.enabled===t.enabled?(e.nextRunAt??1/0)-(t.nextRunAt??1/0):e.enabled?-1:1),n.sort((e,t)=>{let n=e.lastRunAt??e.nextRunAt??0;return(t.lastRunAt??t.nextRunAt??0)-n}),{recurring:t,oneTime:n}}function Ge(e,t,n=!0){return{queryKey:ee(e,t),queryFn:()=>e?ge(e,Oe(t)):Promise.resolve([]),enabled:n,staleTime:1e4}}function Ke(e){return{scheduleId:e,runCount:0,totalEstimatedCostUsd:0,eventCount:0}}function qe(e,t,n){let r=(t??[]).filter(e=>{let t=e.startedAt??e.createdAt;return t>=n.from&&t<=n.to});return{scheduleId:e,runCount:r.length,totalEstimatedCostUsd:r.reduce((e,t)=>{let n=t.estimatedCostUsd;return typeof n==`number`&&Number.isFinite(n)?e+n:e},0),eventCount:0}}function Q({status:e}){return(0,q.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:e===`ok`||e===`completed`?`var(--system-positive-strong)`:e===`error`||e===`failed`?`var(--system-negative-strong)`:`var(--content-tertiary)`},"aria-label":e??`unknown`})}function Je({scheduleName:e,usage:t,onOpenUsage:n}){if(t.status===`loading`)return(0,q.jsxs)(`div`,{"aria-label":`Loading schedule usage`,className:`flex w-[136px] shrink-0 items-center justify-end gap-3`,children:[(0,q.jsx)(`span`,{className:`h-8 w-14 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,q.jsx)(`span`,{className:`h-8 w-14 animate-pulse rounded bg-[var(--surface-muted)]`})]});let r=t.status===`error`,i=r?`--`:X(t.summary.totalEstimatedCostUsd),a=r?`--`:je(t.summary.runCount);return(0,q.jsxs)(`div`,{className:`flex w-[136px] shrink-0 items-center justify-end gap-3 text-right`,children:[n?(0,q.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":`View usage for ${e}`,className:`min-w-[54px] cursor-pointer rounded px-1 py-0.5 text-right transition-colors hover:bg-[var(--surface-hover)]`,children:[(0,q.jsx)(`span`,{className:`block text-label-small-default text-[var(--content-tertiary)]`,children:`Cost`}),(0,q.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-default)]`,children:i})]}):(0,q.jsxs)(`span`,{"aria-label":`Cost for ${e} in the last 7 days: ${i}`,className:`block min-w-[54px] px-1 py-0.5`,children:[(0,q.jsx)(`span`,{className:`block text-label-small-default text-[var(--content-tertiary)]`,children:`Cost`}),(0,q.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-default)]`,children:i})]}),(0,q.jsxs)(`span`,{"aria-label":`Runs for ${e} in the last 7 days: ${a}`,className:`block min-w-[54px] px-1 py-0.5`,children:[(0,q.jsx)(`span`,{className:`block text-label-small-default text-[var(--content-tertiary)]`,children:`Runs`}),(0,q.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-default)]`,children:a})]})]})}function $({runs:e,isLoading:t,emptyMessage:n=`No runs yet.`}){let i=r(),[a,o]=(0,U.useState)(null);return(0,q.jsx)(H,{title:`Recent runs`,children:t?(0,q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,q.jsx)(y,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,q.jsx)(`p`,{className:`py-4 text-center text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:n}):(0,q.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.map((e,t)=>{let n=Ie(e),r=Le(e.output),s=Le(e.error),c=!n&&(r||s),l=a===e.id,u=`schedule-run-details-${t}`;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(d,{label:(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,q.jsx)(Q,{status:e.status}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`block text-body-medium-lighter text-[var(--content-default)]`,children:Y(e.startedAt)}),(0,q.jsxs)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[ke(e.durationMs),` ·`,` `,X(e.estimatedCostUsd),e.status===`error`&&e.error&&(0,q.jsxs)(`span`,{className:`ml-2 text-[var(--system-negative-strong)]`,children:[e.error.slice(0,80),e.error.length>80?`…`:``]})]})]}),n||c?(0,q.jsx)(v,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform ${l?`rotate-90`:``}`}):null]}),onSelect:n?()=>i(R.conversation(n)):c?()=>o(l?null:e.id):void 0,"aria-label":`Run at ${Y(e.startedAt)}`,"aria-expanded":c?l:void 0,"aria-controls":c?u:void 0,className:`h-auto py-2.5 gap-3 -mx-2 px-2`}),c&&l?(0,q.jsx)(`div`,{id:u,className:`px-2 pb-3`,children:(0,q.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[r?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,q.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,s?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,q.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null]},e.id)})})})}function Ye({schedule:e,assistantId:n,onUpdated:r}){let i=Math.round((e.timeoutMs??6e4)/1e3),[a,o]=(0,U.useState)(!1),[s,l]=(0,U.useState)(String(i)),[u,d]=(0,U.useState)(!1),f=()=>{l(String(i)),o(!0)},m=async i=>{d(!0);try{await pe(n,e.id,{timeoutMs:i}),o(!1),r()}catch(e){t(e,{context:`schedule_update_timeout`}),g.error(`Failed to update timeout.`)}finally{d(!1)}};return a?(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Timeout`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(p,{type:`number`,min:1,max:Ue,value:s,onChange:e=>l(e.target.value),className:`w-24`,"aria-label":`Timeout in seconds`}),(0,q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:`sec`}),(0,q.jsx)(c,{size:`compact`,onClick:()=>{let e=Number(s);if(!Number.isInteger(e)||e<1||e>1800){g.error(`Timeout must be a whole number between 1 and ${Ue} seconds.`);return}m(e*1e3)},disabled:u,children:u?`Saving…`:`Save`}),(0,q.jsx)(c,{variant:`outlined`,size:`compact`,onClick:()=>o(!1),disabled:u,children:`Cancel`})]})]}):(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Timeout`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`span`,{children:[i,`s`,e.timeoutMs==null?` (default)`:``]}),(0,q.jsx)(c,{variant:`outlined`,size:`compact`,onClick:f,children:`Edit`}),e.timeoutMs!=null&&(0,q.jsx)(c,{variant:`outlined`,size:`compact`,onClick:()=>void m(null),disabled:u,children:`Reset`})]})]})}function Xe({schedule:e,assistantId:n,onBack:i,onDeleted:a,onUpdated:s}){let l=r(),{data:d,isLoading:f,refetch:p}=o({queryKey:ne(n,e.id),queryFn:()=>he(n,e.id),staleTime:1e4}),[m,h]=(0,U.useState)(!1),[_,v]=(0,U.useState)(!1),[b,x]=(0,U.useState)(!1),S=async()=>{h(!0);try{await ye(n,e.id),p()}catch(e){t(e,{context:`schedule_run_now`}),g.error(`Failed to run schedule.`)}finally{h(!1)}},C=async()=>{x(!0);try{await ve(n,e.id),a()}catch(e){t(e,{context:`schedule_delete`}),g.error(`Failed to delete schedule.`),x(!1),v(!1)}},w=Fe(e);return(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:i,className:`flex items-center gap-1.5 text-body-medium-lighter text-[var(--content-secondary)] hover:text-[var(--content-default)] transition-colors`,children:[(0,q.jsx)(z,{className:`h-4 w-4`}),`Back to schedules`]}),(0,q.jsx)(H,{title:e.name,subtitle:e.description??void 0,accessory:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(u,{tone:He[e.mode]??`neutral`,children:e.mode}),(0,q.jsx)(c,{variant:`outlined`,size:`compact`,leftIcon:(0,q.jsx)(ce,{className:`h-3.5 w-3.5`}),onClick:()=>l(R.logs.usageForSchedule(e.id)),children:`View usage`}),w?(0,q.jsx)(c,{variant:`outlined`,size:`compact`,leftIcon:(0,q.jsx)(se,{className:`h-3.5 w-3.5`}),onClick:()=>l(R.conversation(w)),children:`Source`}):null,e.mode===`script`&&(0,q.jsx)(c,{variant:`outlined`,size:`compact`,leftIcon:m?(0,q.jsx)(y,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(B,{className:`h-3.5 w-3.5`}),onClick:S,disabled:m,children:m?`Running…`:`Run now`})]}),children:(0,q.jsxs)(`div`,{className:`space-y-2 text-body-medium-lighter`,children:[e.mode===`script`&&e.script&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)] text-body-small-default`,children:`Command`}),(0,q.jsx)(`pre`,{className:`mt-1 rounded-md bg-[var(--surface-sunken)] p-2 text-body-small-default font-mono text-[var(--content-default)] whitespace-pre-wrap break-all`,children:e.script})]}),e.mode===`script`&&(0,q.jsx)(Ye,{schedule:e,assistantId:n,onUpdated:s}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Status`}),(0,q.jsx)(`span`,{children:e.enabled?`Enabled`:`Disabled`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Next run`}),(0,q.jsx)(`span`,{children:Y(e.nextRunAt)})]}),e.lastRunAt&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Last run`}),(0,q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(Q,{status:e.lastStatus}),Y(e.lastRunAt)]})]})]})}),(0,q.jsx)($,{runs:d,isLoading:f}),(0,q.jsx)(H,{title:`Danger zone`,children:(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Delete this schedule`}),(0,q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Permanently removes the schedule and all its run history. This cannot be undone.`})]}),_?(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,q.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>v(!1),disabled:b,children:`Cancel`}),(0,q.jsx)(c,{variant:`danger`,size:`compact`,onClick:()=>void C(),disabled:b,children:b?`Deleting…`:`Yes, delete`})]}):(0,q.jsx)(c,{variant:`dangerOutline`,size:`compact`,leftIcon:(0,q.jsx)(ae,{className:`h-3.5 w-3.5`}),onClick:()=>v(!0),children:`Delete`})]})})]})}function Ze({schedule:e,usage:t,onClick:n,onToggle:r,onOpenUsage:i}){return(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 py-3 first:pt-0 last:pb-0 [&+&]:border-t [&+&]:border-[var(--border-base)]`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:n,className:`min-w-0 flex-1 text-left`,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:e.name}),(0,q.jsx)(u,{tone:He[e.mode]??`neutral`,children:e.mode})]}),(0,q.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:e.description}),e.lastRunAt&&(0,q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,q.jsx)(Q,{status:e.lastStatus}),Y(e.lastRunAt)]})]})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[(0,q.jsx)(Je,{scheduleName:e.name,usage:t,onOpenUsage:i}),(0,q.jsx)(m,{checked:e.enabled,onChange:r,"aria-label":`Toggle ${e.name}`}),(0,q.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Open ${e.name}`,className:`flex h-7 w-7 cursor-pointer items-center justify-center rounded text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-hover)]`,children:(0,q.jsx)(v,{className:`h-4 w-4`})})]})]})}function Qe({kind:e,assistantId:t,name:n,subtitle:r,enabled:i,nextRunAt:a,lastRunAt:s,isRunning:l,onBack:d,onRunNow:f}){let{data:p,isLoading:m}=o({queryKey:[`system-task-runs`,t,e],queryFn:()=>e===`heartbeat`?W(t):G(t),staleTime:1e4});return(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:d,className:`flex items-center gap-1.5 text-body-medium-lighter text-[var(--content-secondary)] hover:text-[var(--content-default)] transition-colors`,children:[(0,q.jsx)(z,{className:`h-4 w-4`}),`Back to schedules`]}),(0,q.jsx)(H,{title:n,subtitle:r,accessory:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(u,{tone:`neutral`,children:`system`}),(0,q.jsx)(c,{variant:`outlined`,size:`compact`,leftIcon:l?(0,q.jsx)(y,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(B,{className:`h-3.5 w-3.5`}),onClick:f,disabled:l,children:l?`Running…`:`Run now`})]}),children:(0,q.jsxs)(`div`,{className:`space-y-2 text-body-medium-lighter`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Status`}),(0,q.jsx)(`span`,{children:i?`Enabled`:`Disabled`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Next run`}),(0,q.jsx)(`span`,{children:Y(a)})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Last run`}),(0,q.jsx)(`span`,{children:Y(s)})]})]})}),(0,q.jsx)($,{runs:p,isLoading:m})]})}function $e({name:e,subtitle:t,enabled:n,nextRunAt:r,lastRunAt:i,usage:a,showToggle:o,onClick:s,onToggle:c}){return(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-md px-2 py-3 transition-colors hover:bg-[var(--surface-hover)] [&+&]:border-t [&+&]:border-[var(--border-base)]`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":`Open ${e}`,className:`flex min-w-0 flex-1 cursor-pointer flex-wrap items-center gap-3 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,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:e}),(0,q.jsx)(u,{tone:`neutral`,children:`system`})]}),(0,q.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:t}),(0,q.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-body-small-default text-[var(--content-tertiary)]`,children:[r?(0,q.jsxs)(`span`,{children:[`Next: `,Y(r)]}):null,i?(0,q.jsxs)(`span`,{children:[`Last: `,Y(i)]}):null]})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-3`,children:[(0,q.jsx)(Je,{scheduleName:e,usage:a}),o?null:(0,q.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:n?`var(--system-positive-strong)`:`var(--content-disabled)`},"aria-label":n?`enabled`:`disabled`}),(0,q.jsx)(v,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]}),o?(0,q.jsx)(m,{checked:n,onChange:c,"aria-label":`Toggle ${e}`}):null]})}function et({heartbeatConfig:e,consolidationConfig:t,heartbeatUsage:n,consolidationUsage:r,isLoading:i,hasError:a,onRetry:o,onSelectHeartbeat:s,onSelectConsolidation:c,showSystemTaskToggles:u,onToggleHeartbeat:d,onToggleConsolidation:f}){let p=e!=null,m=t?.available===!0;return!i&&!a&&!p&&!m?null:(0,q.jsx)(H,{title:`System`,subtitle:`Built-in jobs managed by the assistant runtime.`,children:i?(0,q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,q.jsx)(y,{className:`h-5 w-5 animate-spin text-stone-400`})}):a&&!p&&!m?(0,q.jsxs)(l,{tone:`error`,children:[`Failed to load system jobs.`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:o,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]}):(0,q.jsxs)(`div`,{children:[p?(0,q.jsx)($e,{name:`Heartbeat`,subtitle:Be(e),enabled:e.enabled,nextRunAt:e.nextRunAt,lastRunAt:e.lastRunAt,usage:n,showToggle:u,onClick:s,onToggle:d}):null,m?(0,q.jsx)($e,{name:`Consolidation`,subtitle:Ve(t),enabled:t.enabled,nextRunAt:t.nextRunAt,lastRunAt:t.lastRunAt,usage:r,showToggle:u,onClick:c,onToggle:f}):null,a?(0,q.jsx)(`div`,{className:`pt-3 first:pt-0`,children:(0,q.jsxs)(l,{tone:`error`,children:[`Some system jobs failed to load.`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:o,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]})}):null]})})}function tt(e,n){let r=a(),{data:i,isLoading:s,isError:c,refetch:l}=o({queryKey:[`heartbeat-config`,e],queryFn:()=>be(e),enabled:!!e,staleTime:1e4}),{data:u,isLoading:d,isError:f,refetch:p}=o({queryKey:[`consolidation-config`,e],queryFn:()=>Ce(e),enabled:!!e,staleTime:1e4}),{data:m,isLoading:h,isError:_,refetch:v}=o({queryKey:[`system-task-runs-summary`,e,`heartbeat`,100],queryFn:()=>W(e,100),enabled:!!e&&i!=null,staleTime:1e4}),{data:y,isLoading:b,isError:x,refetch:S}=o({queryKey:[`system-task-runs-summary`,e,`consolidation`,100],queryFn:()=>G(e,100),enabled:!!e&&u?.available===!0,staleTime:1e4}),C=(0,U.useMemo)(()=>Oe(n),[n]),w=(0,U.useMemo)(()=>h?{status:`loading`}:_?{status:`error`}:{status:`ready`,summary:qe(Z.heartbeat,m,C)},[m,_,h,C]),T=(0,U.useMemo)(()=>b?{status:`loading`}:x?{status:`error`}:{status:`ready`,summary:qe(Z.consolidation,y,C)},[y,x,b,C]),[E,D]=(0,U.useState)(!1),[O,k]=(0,U.useState)(!1),A=(0,U.useRef)([]),j=(0,U.useCallback)(t=>{if(!e)return;let n=()=>{r.invalidateQueries({queryKey:[`system-task-runs`,e,t]})};n();let i=setTimeout(n,1e3),a=setTimeout(n,5e3);A.current.push(i,a)},[e,r]),M=(0,U.useCallback)(async n=>{if(!e)return;let r=n===`heartbeat`?D:k,i=n===`heartbeat`?Se:Te,a=n===`heartbeat`?l:p,o=n===`heartbeat`?v:S,s=n===`heartbeat`?`Heartbeat started.`:`Consolidation queued.`,c=n===`heartbeat`?`Heartbeat skipped.`:`Consolidation already queued or running.`;r(!0);try{let t=await i(e);a(),j(n),o(),t.ran?g.success(s):g.info(c)}catch(e){t(e,{context:`${n}_run_now`}),g.error(`Failed to run ${n}.`)}finally{r(!1)}},[e,p,S,l,v,j]),N=(0,U.useCallback)(async(n,i)=>{if(!e)return;let a=n===`heartbeat`?xe:we,o=[`${n}-config`,e],s=n===`heartbeat`?`Heartbeat`:`Consolidation`;try{let t=await a(e,{enabled:i});r.setQueryData(o,t),g.success(i?`${s} enabled.`:`${s} disabled.`)}catch(e){t(e,{context:`${n}_toggle`}),g.error(`Failed to toggle ${s.toLowerCase()}.`)}},[e,r]),P=(0,U.useCallback)(()=>{l(),p(),v(),S()},[p,S,l,v]);return(0,U.useEffect)(()=>{let e=A;return()=>{for(let t of e.current)clearTimeout(t);e.current=[]}},[]),{heartbeatConfig:i,consolidationConfig:u,heartbeatUsage:w,consolidationUsage:T,isLoading:s||d,hasError:c||f,hasAnySystemTask:i!=null||u?.available===!0,isHeartbeatRunning:E,isConsolidationRunning:O,isHeartbeatLoading:s,isHeartbeatError:c,isConsolidationLoading:d,isConsolidationError:f,refetchHeartbeat:l,refetchConsolidation:p,handleRunNow:M,handleToggle:N,refetchAll:P}}function nt({onCreate:e}){return(0,q.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-lift)] px-6 py-16 text-center`,children:[(0,q.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--tag-bg-neutral)]`,children:(0,q.jsx)(_,{className:`h-6 w-6 text-[var(--content-faint)]`})}),(0,q.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`No schedules`}),(0,q.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-quiet)]`,children:`Scheduled automations will appear here once created. You can create one yourself or ask your assistant to set it up.`}),(0,q.jsx)(`div`,{className:`mt-4`,children:(0,q.jsxs)(c,{variant:`primary`,onClick:e,children:[(0,q.jsx)(V,{className:`h-4 w-4`}),`Create schedule`]})})]})}function rt({onBack:e}){return(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:e,className:`flex items-center gap-1.5 text-body-medium-lighter text-[var(--content-secondary)] hover:text-[var(--content-default)] transition-colors`,children:[(0,q.jsx)(z,{className:`h-4 w-4`}),`Back to schedules`]}),(0,q.jsx)(l,{tone:`error`,children:`Schedule not found. It may have been deleted or the link may be out of date.`})]})}function it(){let e=r(),{scheduleId:n}=i(),a=oe(),s=Re(re.use.hasHydrated(),re.use.systemScheduleToggles()),u=le(),{data:d,isLoading:f,isError:p,refetch:m}=o({queryKey:te(u),queryFn:()=>me(u),staleTime:1e4}),{data:h,isLoading:_,isError:v}=o(Ge(u,a,n==null)),b=tt(u,a),x=ze(n),[S,C]=(0,U.useState)(!1),w=(0,U.useMemo)(()=>n&&!x?d?.find(e=>e.id===n)??null:null,[d,n,x]),T=(0,U.useMemo)(()=>new Map((h??[]).map(e=>[e.scheduleId,e])),[h]),E=(0,U.useCallback)(e=>_?{status:`loading`}:v?{status:`error`}:{status:`ready`,summary:T.get(e)??Ke(e)},[v,_,T]),D=()=>e(R.settings.schedules),O=t=>e(R.settings.schedule(t)),k=(0,U.useCallback)(()=>{C(!1),m(),g.success(`Schedule created.`)},[m]),A=(0,U.useCallback)(async(e,n)=>{try{await _e(u,e,n),m()}catch(e){t(e,{context:`schedule_toggle`}),g.error(`Failed to toggle schedule.`)}},[u,m]);if(x===`heartbeat`&&b.heartbeatConfig)return(0,q.jsx)(Qe,{kind:`heartbeat`,assistantId:u,name:`Heartbeat`,subtitle:Be(b.heartbeatConfig),enabled:b.heartbeatConfig.enabled,nextRunAt:b.heartbeatConfig.nextRunAt,lastRunAt:b.heartbeatConfig.lastRunAt,isRunning:b.isHeartbeatRunning,onBack:D,onRunNow:()=>void b.handleRunNow(`heartbeat`)},`heartbeat`);if(x===`consolidation`&&b.consolidationConfig?.available===!0)return(0,q.jsx)(Qe,{kind:`consolidation`,assistantId:u,name:`Consolidation`,subtitle:Ve(b.consolidationConfig),enabled:b.consolidationConfig.enabled,nextRunAt:b.consolidationConfig.nextRunAt,lastRunAt:b.consolidationConfig.lastRunAt,isRunning:b.isConsolidationRunning,onBack:D,onRunNow:()=>void b.handleRunNow(`consolidation`)},`consolidation`);if(w)return(0,q.jsx)(Xe,{schedule:w,assistantId:u,onBack:D,onDeleted:()=>{D(),m()},onUpdated:()=>void m()},w.id);if(f||x&&b.isLoading)return(0,q.jsx)(`div`,{className:`w-full`,children:(0,q.jsx)(`div`,{className:`flex min-h-[400px] items-center justify-center`,children:(0,q.jsx)(y,{className:`h-6 w-6 animate-spin text-stone-400`})})});if(p&&!d)return(0,q.jsx)(`div`,{className:`w-full`,children:(0,q.jsxs)(l,{tone:`error`,children:[`Failed to load schedules.`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]})});if(x&&b.hasError)return(0,q.jsxs)(`div`,{className:`mx-auto max-w-[940px] space-y-3`,children:[(0,q.jsxs)(l,{tone:`error`,children:[`Failed to load`,` `,x===`heartbeat`?`heartbeat`:`consolidation`,` `,`schedule.`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:()=>{x===`heartbeat`?b.refetchHeartbeat():b.refetchConsolidation()},className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]}),(0,q.jsxs)(c,{variant:`outlined`,onClick:D,children:[(0,q.jsx)(z,{className:`h-4 w-4`}),`Back to schedules`]})]});if(n!=null)return(0,q.jsx)(rt,{onBack:D});if(!d||d.length===0&&!b.hasAnySystemTask&&!b.isLoading&&!b.hasError)return(0,q.jsxs)(`div`,{className:`w-full`,children:[(0,q.jsx)(nt,{onCreate:()=>C(!0)}),u?(0,q.jsx)(J,{isOpen:S,assistantId:u,onClose:()=>C(!1),onCreated:k}):null]});let{recurring:j,oneTime:M}=We(d);return(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,q.jsxs)(c,{variant:`primary`,onClick:()=>C(!0),children:[(0,q.jsx)(V,{className:`h-4 w-4`}),`New schedule`]})}),v?(0,q.jsx)(l,{tone:`warning`,className:`py-2 text-body-small-default`,children:`Schedule usage stats are unavailable right now.`}):null,j.length>0&&(0,q.jsx)(H,{title:`Schedules`,subtitle:`Recurring automations managed by your assistant.`,children:(0,q.jsx)(`div`,{children:j.map(t=>(0,q.jsx)(Ze,{schedule:t,usage:E(t.id),onClick:()=>O(t.id),onToggle:e=>void A(t.id,e),onOpenUsage:()=>e(R.logs.usageForSchedule(t.id))},t.id))})}),(0,q.jsx)(et,{heartbeatConfig:b.heartbeatConfig,consolidationConfig:b.consolidationConfig,heartbeatUsage:b.heartbeatUsage,consolidationUsage:b.consolidationUsage,isLoading:b.isLoading,hasError:b.hasError,onRetry:b.refetchAll,onSelectHeartbeat:()=>O(Z.heartbeat),onSelectConsolidation:()=>O(Z.consolidation),showSystemTaskToggles:s,onToggleHeartbeat:e=>void b.handleToggle(`heartbeat`,e),onToggleConsolidation:e=>void b.handleToggle(`consolidation`,e)}),M.length>0&&(0,q.jsx)(H,{title:`One-time`,subtitle:`One-shot automations that run once at a scheduled time.`,children:(0,q.jsx)(`div`,{children:M.map(t=>(0,q.jsx)(Ze,{schedule:t,usage:E(t.id),onClick:()=>O(t.id),onToggle:e=>void A(t.id,e),onOpenUsage:()=>e(R.logs.usageForSchedule(t.id))},t.id))})}),u?(0,q.jsx)(J,{isOpen:S,assistantId:u,onClose:()=>C(!1),onCreated:k}):null]})}export{it as SchedulesPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-CZsNGL6n.js";import{t as n}from"./react-DJZBPgpf.js";import{d as r,p as i}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as a}from"./QueryClientProvider-DNHWXaGq.js";import{t as o}from"./useQuery-D2zf6Uhu.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./button-DdEh-9f_.js";import{t as l}from"./notice-CF2pptne.js";import{t as u}from"./tag-Ccr7Quy6.js";import{t as d}from"./panel-item-FzMfzMJA.js";import{n as f,t as p}from"./input-Cu3PPVCq.js";import{t as m}from"./toggle-CEm3M86o.js";import{t as h}from"./modal-BYMhDpQo.js";import{n as g}from"./toast-DU1nH33j.js";import{t as _}from"./calendar-CP_Q3Aw6.js";import{t as v}from"./chevron-right-zTNPbA1m.js";import{t as y}from"./loader-circle-BSAFLoPH.js";import{D as b,E as x,O as S,T as C,_n as w,dn as T,fn as E,gt as D,hn as O,ht as k,mn as A,mt as j,pn as M,pt as N,vn as P}from"./sdk.gen-AJllUeDf.js";import{n as F,r as I,t as L}from"./api-errors-ChauV4ed.js";import{i as R}from"./routes-Dk5Qeryt.js";import{c as ee,l as te,s as ne}from"./query-tags-Cez88bzY.js";import{t as re}from"./assistant-feature-flag-store-0382ImYF.js";import{t as ie}from"./effective-timezone-CKEcAtDc.js";import{Ni as ae,Pn as oe,bo as z,ha as se,ho as ce,ia as B,na as V}from"./index-DGojzQtP.js";import{t as le}from"./use-active-assistant-id-BIhArlF_.js";import{t as H}from"./detail-card-B5j4Rqau.js";import{n as ue}from"./usage-window-D5EMg2nb.js";import{t as de}from"./schedules-BJAra2Ob.js";var U=e(n(),1);async function fe(e,t){let{error:n,response:r}=await w({path:{assistant_id:e},body:t,throwOnError:!1});if(F(r,n,`Failed to create schedule.`),!r.ok)throw new L(r.status,I(n,r,`Failed to create schedule.`))}async function pe(e,t,n){let{error:r,response:i}=await E({path:{assistant_id:e,id:t},body:n,throwOnError:!1});if(F(i,r,`Failed to update schedule.`),!i.ok)throw new L(i.status,I(r,i,`Failed to update schedule.`))}async function me(e){return de(e)}async function he(e,t,n=10){let{data:r,error:i,response:a}=await A({path:{assistant_id:e,id:t},query:{limit:n},throwOnError:!1});if(F(a,i,`Failed to load schedule runs.`),!a.ok)throw new L(a.status,I(i,a,`Failed to load schedule runs.`));return r?.runs??[]}async function ge(e,t){let{data:n,error:r,response:i}=await P({path:{assistant_id:e},query:{from:t.from,to:t.to},throwOnError:!1});if(F(i,r,`Failed to load schedule usage.`),!i.ok)throw new L(i.status,I(r,i,`Failed to load schedule usage.`));return n?.summaries??[]}async function _e(e,t,n){let{error:r,response:i}=await O({path:{assistant_id:e,id:t},body:{enabled:n},throwOnError:!1});if(F(i,r,`Failed to toggle schedule.`),!i.ok)throw new L(i.status,I(r,i,`Failed to toggle schedule.`))}async function ve(e,t){let{error:n,response:r}=await T({path:{assistant_id:e,id:t},throwOnError:!1});if(F(r,n,`Failed to delete schedule.`),!r.ok&&r.status!==204)throw new L(r.status,I(n,r,`Failed to delete schedule.`))}async function ye(e,t){let{error:n,response:r}=await M({path:{assistant_id:e,id:t},throwOnError:!1});if(F(r,n,`Failed to run schedule.`),!r.ok)throw new L(r.status,I(n,r,`Failed to run schedule.`))}async function W(e,t=10){let{data:n,error:r,response:i}=await D({path:{assistant_id:e},query:{limit:t},throwOnError:!1});if(F(i,r,`Failed to load heartbeat runs.`),!i.ok)throw new L(i.status,I(r,i,`Failed to load heartbeat runs.`));return(n?.runs??[]).map(e=>({id:e.id,jobId:`heartbeat`,status:e.status,startedAt:e.startedAt??e.scheduledFor,finishedAt:e.finishedAt,durationMs:e.durationMs,output:e.skipReason?`Skipped: ${e.skipReason}`:null,error:e.error,conversationId:e.conversationId,conversationExists:e.conversationExists,conversationArchivedAt:e.conversationArchivedAt,estimatedCostUsd:e.estimatedCostUsd,createdAt:e.createdAt}))}async function G(e,t=10){let{data:n,error:r,response:i}=await S({path:{assistant_id:e},query:{limit:t},throwOnError:!1});if(F(i,r,`Failed to load consolidation runs.`),!i.ok)throw new L(i.status,I(r,i,`Failed to load consolidation runs.`));return(n?.runs??[]).map(e=>({id:e.id,jobId:`consolidation`,status:e.status,startedAt:e.startedAt??e.scheduledFor,finishedAt:e.finishedAt,durationMs:e.durationMs,output:null,error:e.error,conversationId:e.conversationId,conversationExists:e.conversationExists,conversationArchivedAt:e.conversationArchivedAt,estimatedCostUsd:e.estimatedCostUsd,createdAt:e.createdAt}))}async function be(e){let{data:t,error:n,response:r}=await N({path:{assistant_id:e},throwOnError:!1});if(F(r,n,`Failed to load heartbeat config.`),!r.ok||!t)throw new L(r.status,I(n,r,`Failed to load heartbeat config.`));return t}async function K(e,t){let{data:n,error:r,response:i}=await e();if(F(i,r,t),!i.ok||!n)throw new L(i.status,I(r,i,t));return n}async function xe(e,t){return K(()=>j({path:{assistant_id:e},body:t,throwOnError:!1}),`Failed to update heartbeat config.`)}async function Se(e){let{data:t,error:n,response:r}=await k({path:{assistant_id:e},throwOnError:!1});if(F(r,n,`Failed to run heartbeat.`),!r.ok||!t)throw new L(r.status,I(n,r,`Failed to run heartbeat.`));return t}async function Ce(e){let{data:t,error:n,response:r}=await C({path:{assistant_id:e},throwOnError:!1});if(F(r,n,`Failed to load consolidation config.`),!r.ok||!t)throw new L(r.status,I(n,r,`Failed to load consolidation config.`));return t}async function we(e,t){return K(()=>x({path:{assistant_id:e},body:t,throwOnError:!1}),`Failed to update consolidation config.`)}async function Te(e){let{data:t,error:n,response:r}=await b({path:{assistant_id:e},throwOnError:!1});if(F(r,n,`Failed to run consolidation.`),!r.ok||!t)throw new L(r.status,I(n,r,`Failed to run consolidation.`));return t}var q=s(),Ee=[{label:`Every hour`,expression:`0 * * * *`},{label:`Every day at 9am`,expression:`0 9 * * *`},{label:`Every weekday at 9am`,expression:`0 9 * * 1-5`},{label:`Every Monday at 9am`,expression:`0 9 * * 1`},{label:`Every 1st of month, 9am`,expression:`0 9 1 * *`}];function J({isOpen:e,assistantId:t,onClose:n,onCreated:r}){return(0,q.jsx)(h.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,q.jsx)(De,{assistantId:t,onClose:n,onCreated:r}):null})}function De({assistantId:e,onClose:t,onCreated:n}){let[r,i]=(0,U.useState)(``),[a,o]=(0,U.useState)(``),[s,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(``),[m,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(null),y=r.trim(),b=a.trim(),x=s.trim(),S=y.length>0&&b.length>0&&x.length>0&&!m;return(0,q.jsxs)(h.Content,{size:`md`,children:[(0,q.jsxs)(h.Header,{children:[(0,q.jsx)(h.Title,{children:`Create schedule`}),(0,q.jsx)(h.Description,{children:`Schedule a recurring instruction for your assistant. Runs in execute mode — the message is delivered to the assistant on each fire.`})]}),(0,q.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),S){g(!0),v(null);try{let t={name:y,expression:b,message:x},r=u.trim();r&&(t.timezone=r),await fe(e,t),g(!1),n()}catch(e){v(e instanceof Error?e.message:`Failed to create schedule.`),g(!1)}}},children:[(0,q.jsx)(h.Body,{children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsx)(p,{label:`Name`,placeholder:`Morning briefing`,value:r,onChange:e=>i(e.target.value),required:!0,autoFocus:!0,fullWidth:!0}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(p,{label:`Cron expression`,placeholder:`0 9 * * *`,value:a,onChange:e=>o(e.target.value),required:!0,fullWidth:!0,helperText:`Standard 5-field cron (minute hour day month weekday). RRULE expressions are also accepted.`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Ee.map(e=>(0,q.jsx)(c,{variant:`outlined`,size:`compact`,type:`button`,onClick:()=>o(e.expression),children:e.label},e.expression))})]}),(0,q.jsx)(p,{label:`Timezone (optional)`,placeholder:`America/New_York`,value:u,onChange:e=>d(e.target.value),fullWidth:!0,helperText:`IANA timezone name. Leave blank to use UTC.`}),(0,q.jsx)(f,{label:`Message`,placeholder:`What should the assistant do on each fire?`,value:s,onChange:e=>l(e.target.value),required:!0,fullWidth:!0,rows:4}),_?(0,q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:_}):null]})}),(0,q.jsxs)(h.Footer,{children:[(0,q.jsx)(c,{variant:`outlined`,onClick:t,type:`button`,children:`Cancel`}),(0,q.jsx)(c,{variant:`primary`,type:`submit`,disabled:!S,children:m?`Creating…`:`Create schedule`})]})]})]})}function Oe(e=ie(),t=Date.now()){return ue(`7d`,e,t)}function Y(e){return e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0}):`—`}function ke(e){return e==null?`—`:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}var Ae=new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:4});function X(e){return e==null||!Number.isFinite(e)?`—`:Ae.format(e)}function je(e){return`${e.toLocaleString()} ${e===1?`run`:`runs`}`}function Me(e){let t=Math.round(e/6e4);return t>=60&&t%60==0?`Every ${t/60} hr`:`Every ${t} min`}function Ne(e){return!!e.createdFromConversationId&&e.createdFromConversationExists===!0&&e.createdFromConversationArchivedAt==null}function Pe(e){return!!e.conversationId&&e.conversationExists===!0&&e.conversationArchivedAt==null}function Fe(e){return Ne(e)?e.createdFromConversationId??null:null}function Ie(e){return Pe(e)?e.conversationId??null:null}function Le(e){return typeof e==`string`&&e.length>0}var Z={heartbeat:`system-heartbeat`,consolidation:`system-consolidation`};function Re(e,t){return e&&t}function ze(e){switch(e){case Z.heartbeat:return`heartbeat`;case Z.consolidation:return`consolidation`;default:return null}}function Be(e){if(e.cronExpression)return e.timezone?`Cron: ${e.cronExpression} (${e.timezone})`:`Cron: ${e.cronExpression}`;let t=Me(e.intervalMs);return e.activeHoursStart!=null&&e.activeHoursEnd!=null&&(t+=` (${e.activeHoursStart}:00–${e.activeHoursEnd}:00)`),t}function Ve(e){return Me(e.intervalMs)}var He={execute:`positive`,notify:`warning`,script:`neutral`},Ue=1800;function We(e){let t=[],n=[];for(let r of e)r.isOneShot?n.push(r):t.push(r);return t.sort((e,t)=>e.enabled===t.enabled?(e.nextRunAt??1/0)-(t.nextRunAt??1/0):e.enabled?-1:1),n.sort((e,t)=>{let n=e.lastRunAt??e.nextRunAt??0;return(t.lastRunAt??t.nextRunAt??0)-n}),{recurring:t,oneTime:n}}function Ge(e,t,n=!0){return{queryKey:ee(e,t),queryFn:()=>e?ge(e,Oe(t)):Promise.resolve([]),enabled:n,staleTime:1e4}}function Ke(e){return{scheduleId:e,runCount:0,totalEstimatedCostUsd:0,eventCount:0}}function qe(e,t,n){let r=(t??[]).filter(e=>{let t=e.startedAt??e.createdAt;return t>=n.from&&t<=n.to});return{scheduleId:e,runCount:r.length,totalEstimatedCostUsd:r.reduce((e,t)=>{let n=t.estimatedCostUsd;return typeof n==`number`&&Number.isFinite(n)?e+n:e},0),eventCount:0}}function Q({status:e}){return(0,q.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:e===`ok`||e===`completed`?`var(--system-positive-strong)`:e===`error`||e===`failed`?`var(--system-negative-strong)`:`var(--content-tertiary)`},"aria-label":e??`unknown`})}function Je({scheduleName:e,usage:t,onOpenUsage:n}){if(t.status===`loading`)return(0,q.jsxs)(`div`,{"aria-label":`Loading schedule usage`,className:`flex w-[136px] shrink-0 items-center justify-end gap-3`,children:[(0,q.jsx)(`span`,{className:`h-8 w-14 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,q.jsx)(`span`,{className:`h-8 w-14 animate-pulse rounded bg-[var(--surface-muted)]`})]});let r=t.status===`error`,i=r?`--`:X(t.summary.totalEstimatedCostUsd),a=r?`--`:je(t.summary.runCount);return(0,q.jsxs)(`div`,{className:`flex w-[136px] shrink-0 items-center justify-end gap-3 text-right`,children:[n?(0,q.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":`View usage for ${e}`,className:`min-w-[54px] cursor-pointer rounded px-1 py-0.5 text-right transition-colors hover:bg-[var(--surface-hover)]`,children:[(0,q.jsx)(`span`,{className:`block text-label-small-default text-[var(--content-tertiary)]`,children:`Cost`}),(0,q.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-default)]`,children:i})]}):(0,q.jsxs)(`span`,{"aria-label":`Cost for ${e} in the last 7 days: ${i}`,className:`block min-w-[54px] px-1 py-0.5`,children:[(0,q.jsx)(`span`,{className:`block text-label-small-default text-[var(--content-tertiary)]`,children:`Cost`}),(0,q.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-default)]`,children:i})]}),(0,q.jsxs)(`span`,{"aria-label":`Runs for ${e} in the last 7 days: ${a}`,className:`block min-w-[54px] px-1 py-0.5`,children:[(0,q.jsx)(`span`,{className:`block text-label-small-default text-[var(--content-tertiary)]`,children:`Runs`}),(0,q.jsx)(`span`,{className:`block text-body-small-default text-[var(--content-default)]`,children:a})]})]})}function $({runs:e,isLoading:t,emptyMessage:n=`No runs yet.`}){let i=r(),[a,o]=(0,U.useState)(null);return(0,q.jsx)(H,{title:`Recent runs`,children:t?(0,q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,q.jsx)(y,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,q.jsx)(`p`,{className:`py-4 text-center text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:n}):(0,q.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.map((e,t)=>{let n=Ie(e),r=Le(e.output),s=Le(e.error),c=!n&&(r||s),l=a===e.id,u=`schedule-run-details-${t}`;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(d,{label:(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,q.jsx)(Q,{status:e.status}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`block text-body-medium-lighter text-[var(--content-default)]`,children:Y(e.startedAt)}),(0,q.jsxs)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[ke(e.durationMs),` ·`,` `,X(e.estimatedCostUsd),e.status===`error`&&e.error&&(0,q.jsxs)(`span`,{className:`ml-2 text-[var(--system-negative-strong)]`,children:[e.error.slice(0,80),e.error.length>80?`…`:``]})]})]}),n||c?(0,q.jsx)(v,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform ${l?`rotate-90`:``}`}):null]}),onSelect:n?()=>i(R.conversation(n)):c?()=>o(l?null:e.id):void 0,"aria-label":`Run at ${Y(e.startedAt)}`,"aria-expanded":c?l:void 0,"aria-controls":c?u:void 0,className:`h-auto py-2.5 gap-3 -mx-2 px-2`}),c&&l?(0,q.jsx)(`div`,{id:u,className:`px-2 pb-3`,children:(0,q.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[r?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,q.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,s?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,q.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null]},e.id)})})})}function Ye({schedule:e,assistantId:n,onUpdated:r}){let i=Math.round((e.timeoutMs??6e4)/1e3),[a,o]=(0,U.useState)(!1),[s,l]=(0,U.useState)(String(i)),[u,d]=(0,U.useState)(!1),f=()=>{l(String(i)),o(!0)},m=async i=>{d(!0);try{await pe(n,e.id,{timeoutMs:i}),o(!1),r()}catch(e){t(e,{context:`schedule_update_timeout`}),g.error(`Failed to update timeout.`)}finally{d(!1)}};return a?(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Timeout`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(p,{type:`number`,min:1,max:Ue,value:s,onChange:e=>l(e.target.value),className:`w-24`,"aria-label":`Timeout in seconds`}),(0,q.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:`sec`}),(0,q.jsx)(c,{size:`compact`,onClick:()=>{let e=Number(s);if(!Number.isInteger(e)||e<1||e>1800){g.error(`Timeout must be a whole number between 1 and ${Ue} seconds.`);return}m(e*1e3)},disabled:u,children:u?`Saving…`:`Save`}),(0,q.jsx)(c,{variant:`outlined`,size:`compact`,onClick:()=>o(!1),disabled:u,children:`Cancel`})]})]}):(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Timeout`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`span`,{children:[i,`s`,e.timeoutMs==null?` (default)`:``]}),(0,q.jsx)(c,{variant:`outlined`,size:`compact`,onClick:f,children:`Edit`}),e.timeoutMs!=null&&(0,q.jsx)(c,{variant:`outlined`,size:`compact`,onClick:()=>void m(null),disabled:u,children:`Reset`})]})]})}function Xe({schedule:e,assistantId:n,onBack:i,onDeleted:a,onUpdated:s}){let l=r(),{data:d,isLoading:f,refetch:p}=o({queryKey:ne(n,e.id),queryFn:()=>he(n,e.id),staleTime:1e4}),[m,h]=(0,U.useState)(!1),[_,v]=(0,U.useState)(!1),[b,x]=(0,U.useState)(!1),S=async()=>{h(!0);try{await ye(n,e.id),p()}catch(e){t(e,{context:`schedule_run_now`}),g.error(`Failed to run schedule.`)}finally{h(!1)}},C=async()=>{x(!0);try{await ve(n,e.id),a()}catch(e){t(e,{context:`schedule_delete`}),g.error(`Failed to delete schedule.`),x(!1),v(!1)}},w=Fe(e);return(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:i,className:`flex items-center gap-1.5 text-body-medium-lighter text-[var(--content-secondary)] hover:text-[var(--content-default)] transition-colors`,children:[(0,q.jsx)(z,{className:`h-4 w-4`}),`Back to schedules`]}),(0,q.jsx)(H,{title:e.name,subtitle:e.description??void 0,accessory:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(u,{tone:He[e.mode]??`neutral`,children:e.mode}),(0,q.jsx)(c,{variant:`outlined`,size:`compact`,leftIcon:(0,q.jsx)(ce,{className:`h-3.5 w-3.5`}),onClick:()=>l(R.logs.usageForSchedule(e.id)),children:`View usage`}),w?(0,q.jsx)(c,{variant:`outlined`,size:`compact`,leftIcon:(0,q.jsx)(se,{className:`h-3.5 w-3.5`}),onClick:()=>l(R.conversation(w)),children:`Source`}):null,e.mode===`script`&&(0,q.jsx)(c,{variant:`outlined`,size:`compact`,leftIcon:m?(0,q.jsx)(y,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(B,{className:`h-3.5 w-3.5`}),onClick:S,disabled:m,children:m?`Running…`:`Run now`})]}),children:(0,q.jsxs)(`div`,{className:`space-y-2 text-body-medium-lighter`,children:[e.mode===`script`&&e.script&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)] text-body-small-default`,children:`Command`}),(0,q.jsx)(`pre`,{className:`mt-1 rounded-md bg-[var(--surface-sunken)] p-2 text-body-small-default font-mono text-[var(--content-default)] whitespace-pre-wrap break-all`,children:e.script})]}),e.mode===`script`&&(0,q.jsx)(Ye,{schedule:e,assistantId:n,onUpdated:s}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Status`}),(0,q.jsx)(`span`,{children:e.enabled?`Enabled`:`Disabled`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Next run`}),(0,q.jsx)(`span`,{children:Y(e.nextRunAt)})]}),e.lastRunAt&&(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Last run`}),(0,q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(Q,{status:e.lastStatus}),Y(e.lastRunAt)]})]})]})}),(0,q.jsx)($,{runs:d,isLoading:f}),(0,q.jsx)(H,{title:`Danger zone`,children:(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Delete this schedule`}),(0,q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Permanently removes the schedule and all its run history. This cannot be undone.`})]}),_?(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,q.jsx)(c,{variant:`ghost`,size:`compact`,onClick:()=>v(!1),disabled:b,children:`Cancel`}),(0,q.jsx)(c,{variant:`danger`,size:`compact`,onClick:()=>void C(),disabled:b,children:b?`Deleting…`:`Yes, delete`})]}):(0,q.jsx)(c,{variant:`dangerOutline`,size:`compact`,leftIcon:(0,q.jsx)(ae,{className:`h-3.5 w-3.5`}),onClick:()=>v(!0),children:`Delete`})]})})]})}function Ze({schedule:e,usage:t,onClick:n,onToggle:r,onOpenUsage:i}){return(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 py-3 first:pt-0 last:pb-0 [&+&]:border-t [&+&]:border-[var(--border-base)]`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:n,className:`min-w-0 flex-1 text-left`,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:e.name}),(0,q.jsx)(u,{tone:He[e.mode]??`neutral`,children:e.mode})]}),(0,q.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:e.description}),e.lastRunAt&&(0,q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,q.jsx)(Q,{status:e.lastStatus}),Y(e.lastRunAt)]})]})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[(0,q.jsx)(Je,{scheduleName:e.name,usage:t,onOpenUsage:i}),(0,q.jsx)(m,{checked:e.enabled,onChange:r,"aria-label":`Toggle ${e.name}`}),(0,q.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Open ${e.name}`,className:`flex h-7 w-7 cursor-pointer items-center justify-center rounded text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-hover)]`,children:(0,q.jsx)(v,{className:`h-4 w-4`})})]})]})}function Qe({kind:e,assistantId:t,name:n,subtitle:r,enabled:i,nextRunAt:a,lastRunAt:s,isRunning:l,onBack:d,onRunNow:f}){let{data:p,isLoading:m}=o({queryKey:[`system-task-runs`,t,e],queryFn:()=>e===`heartbeat`?W(t):G(t),staleTime:1e4});return(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:d,className:`flex items-center gap-1.5 text-body-medium-lighter text-[var(--content-secondary)] hover:text-[var(--content-default)] transition-colors`,children:[(0,q.jsx)(z,{className:`h-4 w-4`}),`Back to schedules`]}),(0,q.jsx)(H,{title:n,subtitle:r,accessory:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(u,{tone:`neutral`,children:`system`}),(0,q.jsx)(c,{variant:`outlined`,size:`compact`,leftIcon:l?(0,q.jsx)(y,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(B,{className:`h-3.5 w-3.5`}),onClick:f,disabled:l,children:l?`Running…`:`Run now`})]}),children:(0,q.jsxs)(`div`,{className:`space-y-2 text-body-medium-lighter`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Status`}),(0,q.jsx)(`span`,{children:i?`Enabled`:`Disabled`})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Next run`}),(0,q.jsx)(`span`,{children:Y(a)})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Last run`}),(0,q.jsx)(`span`,{children:Y(s)})]})]})}),(0,q.jsx)($,{runs:p,isLoading:m})]})}function $e({name:e,subtitle:t,enabled:n,nextRunAt:r,lastRunAt:i,usage:a,showToggle:o,onClick:s,onToggle:c}){return(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-md px-2 py-3 transition-colors hover:bg-[var(--surface-hover)] [&+&]:border-t [&+&]:border-[var(--border-base)]`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":`Open ${e}`,className:`flex min-w-0 flex-1 cursor-pointer flex-wrap items-center gap-3 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,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:e}),(0,q.jsx)(u,{tone:`neutral`,children:`system`})]}),(0,q.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:t}),(0,q.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-body-small-default text-[var(--content-tertiary)]`,children:[r?(0,q.jsxs)(`span`,{children:[`Next: `,Y(r)]}):null,i?(0,q.jsxs)(`span`,{children:[`Last: `,Y(i)]}):null]})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-3`,children:[(0,q.jsx)(Je,{scheduleName:e,usage:a}),o?null:(0,q.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:n?`var(--system-positive-strong)`:`var(--content-disabled)`},"aria-label":n?`enabled`:`disabled`}),(0,q.jsx)(v,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]}),o?(0,q.jsx)(m,{checked:n,onChange:c,"aria-label":`Toggle ${e}`}):null]})}function et({heartbeatConfig:e,consolidationConfig:t,heartbeatUsage:n,consolidationUsage:r,isLoading:i,hasError:a,onRetry:o,onSelectHeartbeat:s,onSelectConsolidation:c,showSystemTaskToggles:u,onToggleHeartbeat:d,onToggleConsolidation:f}){let p=e!=null,m=t?.available===!0;return!i&&!a&&!p&&!m?null:(0,q.jsx)(H,{title:`System`,subtitle:`Built-in jobs managed by the assistant runtime.`,children:i?(0,q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,q.jsx)(y,{className:`h-5 w-5 animate-spin text-stone-400`})}):a&&!p&&!m?(0,q.jsxs)(l,{tone:`error`,children:[`Failed to load system jobs.`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:o,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]}):(0,q.jsxs)(`div`,{children:[p?(0,q.jsx)($e,{name:`Heartbeat`,subtitle:Be(e),enabled:e.enabled,nextRunAt:e.nextRunAt,lastRunAt:e.lastRunAt,usage:n,showToggle:u,onClick:s,onToggle:d}):null,m?(0,q.jsx)($e,{name:`Consolidation`,subtitle:Ve(t),enabled:t.enabled,nextRunAt:t.nextRunAt,lastRunAt:t.lastRunAt,usage:r,showToggle:u,onClick:c,onToggle:f}):null,a?(0,q.jsx)(`div`,{className:`pt-3 first:pt-0`,children:(0,q.jsxs)(l,{tone:`error`,children:[`Some system jobs failed to load.`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:o,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]})}):null]})})}function tt(e,n){let r=a(),{data:i,isLoading:s,isError:c,refetch:l}=o({queryKey:[`heartbeat-config`,e],queryFn:()=>be(e),enabled:!!e,staleTime:1e4}),{data:u,isLoading:d,isError:f,refetch:p}=o({queryKey:[`consolidation-config`,e],queryFn:()=>Ce(e),enabled:!!e,staleTime:1e4}),{data:m,isLoading:h,isError:_,refetch:v}=o({queryKey:[`system-task-runs-summary`,e,`heartbeat`,100],queryFn:()=>W(e,100),enabled:!!e&&i!=null,staleTime:1e4}),{data:y,isLoading:b,isError:x,refetch:S}=o({queryKey:[`system-task-runs-summary`,e,`consolidation`,100],queryFn:()=>G(e,100),enabled:!!e&&u?.available===!0,staleTime:1e4}),C=(0,U.useMemo)(()=>Oe(n),[n]),w=(0,U.useMemo)(()=>h?{status:`loading`}:_?{status:`error`}:{status:`ready`,summary:qe(Z.heartbeat,m,C)},[m,_,h,C]),T=(0,U.useMemo)(()=>b?{status:`loading`}:x?{status:`error`}:{status:`ready`,summary:qe(Z.consolidation,y,C)},[y,x,b,C]),[E,D]=(0,U.useState)(!1),[O,k]=(0,U.useState)(!1),A=(0,U.useRef)([]),j=(0,U.useCallback)(t=>{if(!e)return;let n=()=>{r.invalidateQueries({queryKey:[`system-task-runs`,e,t]})};n();let i=setTimeout(n,1e3),a=setTimeout(n,5e3);A.current.push(i,a)},[e,r]),M=(0,U.useCallback)(async n=>{if(!e)return;let r=n===`heartbeat`?D:k,i=n===`heartbeat`?Se:Te,a=n===`heartbeat`?l:p,o=n===`heartbeat`?v:S,s=n===`heartbeat`?`Heartbeat started.`:`Consolidation queued.`,c=n===`heartbeat`?`Heartbeat skipped.`:`Consolidation already queued or running.`;r(!0);try{let t=await i(e);a(),j(n),o(),t.ran?g.success(s):g.info(c)}catch(e){t(e,{context:`${n}_run_now`}),g.error(`Failed to run ${n}.`)}finally{r(!1)}},[e,p,S,l,v,j]),N=(0,U.useCallback)(async(n,i)=>{if(!e)return;let a=n===`heartbeat`?xe:we,o=[`${n}-config`,e],s=n===`heartbeat`?`Heartbeat`:`Consolidation`;try{let t=await a(e,{enabled:i});r.setQueryData(o,t),g.success(i?`${s} enabled.`:`${s} disabled.`)}catch(e){t(e,{context:`${n}_toggle`}),g.error(`Failed to toggle ${s.toLowerCase()}.`)}},[e,r]),P=(0,U.useCallback)(()=>{l(),p(),v(),S()},[p,S,l,v]);return(0,U.useEffect)(()=>{let e=A;return()=>{for(let t of e.current)clearTimeout(t);e.current=[]}},[]),{heartbeatConfig:i,consolidationConfig:u,heartbeatUsage:w,consolidationUsage:T,isLoading:s||d,hasError:c||f,hasAnySystemTask:i!=null||u?.available===!0,isHeartbeatRunning:E,isConsolidationRunning:O,isHeartbeatLoading:s,isHeartbeatError:c,isConsolidationLoading:d,isConsolidationError:f,refetchHeartbeat:l,refetchConsolidation:p,handleRunNow:M,handleToggle:N,refetchAll:P}}function nt({onCreate:e}){return(0,q.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-lift)] px-6 py-16 text-center`,children:[(0,q.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--tag-bg-neutral)]`,children:(0,q.jsx)(_,{className:`h-6 w-6 text-[var(--content-faint)]`})}),(0,q.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`No schedules`}),(0,q.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-quiet)]`,children:`Scheduled automations will appear here once created. You can create one yourself or ask your assistant to set it up.`}),(0,q.jsx)(`div`,{className:`mt-4`,children:(0,q.jsxs)(c,{variant:`primary`,onClick:e,children:[(0,q.jsx)(V,{className:`h-4 w-4`}),`Create schedule`]})})]})}function rt({onBack:e}){return(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:e,className:`flex items-center gap-1.5 text-body-medium-lighter text-[var(--content-secondary)] hover:text-[var(--content-default)] transition-colors`,children:[(0,q.jsx)(z,{className:`h-4 w-4`}),`Back to schedules`]}),(0,q.jsx)(l,{tone:`error`,children:`Schedule not found. It may have been deleted or the link may be out of date.`})]})}function it(){let e=r(),{scheduleId:n}=i(),a=oe(),s=Re(re.use.hasHydrated(),re.use.systemScheduleToggles()),u=le(),{data:d,isLoading:f,isError:p,refetch:m}=o({queryKey:te(u),queryFn:()=>me(u),staleTime:1e4}),{data:h,isLoading:_,isError:v}=o(Ge(u,a,n==null)),b=tt(u,a),x=ze(n),[S,C]=(0,U.useState)(!1),w=(0,U.useMemo)(()=>n&&!x?d?.find(e=>e.id===n)??null:null,[d,n,x]),T=(0,U.useMemo)(()=>new Map((h??[]).map(e=>[e.scheduleId,e])),[h]),E=(0,U.useCallback)(e=>_?{status:`loading`}:v?{status:`error`}:{status:`ready`,summary:T.get(e)??Ke(e)},[v,_,T]),D=()=>e(R.settings.schedules),O=t=>e(R.settings.schedule(t)),k=(0,U.useCallback)(()=>{C(!1),m(),g.success(`Schedule created.`)},[m]),A=(0,U.useCallback)(async(e,n)=>{try{await _e(u,e,n),m()}catch(e){t(e,{context:`schedule_toggle`}),g.error(`Failed to toggle schedule.`)}},[u,m]);if(x===`heartbeat`&&b.heartbeatConfig)return(0,q.jsx)(Qe,{kind:`heartbeat`,assistantId:u,name:`Heartbeat`,subtitle:Be(b.heartbeatConfig),enabled:b.heartbeatConfig.enabled,nextRunAt:b.heartbeatConfig.nextRunAt,lastRunAt:b.heartbeatConfig.lastRunAt,isRunning:b.isHeartbeatRunning,onBack:D,onRunNow:()=>void b.handleRunNow(`heartbeat`)},`heartbeat`);if(x===`consolidation`&&b.consolidationConfig?.available===!0)return(0,q.jsx)(Qe,{kind:`consolidation`,assistantId:u,name:`Consolidation`,subtitle:Ve(b.consolidationConfig),enabled:b.consolidationConfig.enabled,nextRunAt:b.consolidationConfig.nextRunAt,lastRunAt:b.consolidationConfig.lastRunAt,isRunning:b.isConsolidationRunning,onBack:D,onRunNow:()=>void b.handleRunNow(`consolidation`)},`consolidation`);if(w)return(0,q.jsx)(Xe,{schedule:w,assistantId:u,onBack:D,onDeleted:()=>{D(),m()},onUpdated:()=>void m()},w.id);if(f||x&&b.isLoading)return(0,q.jsx)(`div`,{className:`w-full`,children:(0,q.jsx)(`div`,{className:`flex min-h-[400px] items-center justify-center`,children:(0,q.jsx)(y,{className:`h-6 w-6 animate-spin text-stone-400`})})});if(p&&!d)return(0,q.jsx)(`div`,{className:`w-full`,children:(0,q.jsxs)(l,{tone:`error`,children:[`Failed to load schedules.`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:()=>void m(),className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]})});if(x&&b.hasError)return(0,q.jsxs)(`div`,{className:`mx-auto max-w-[940px] space-y-3`,children:[(0,q.jsxs)(l,{tone:`error`,children:[`Failed to load`,` `,x===`heartbeat`?`heartbeat`:`consolidation`,` `,`schedule.`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:()=>{x===`heartbeat`?b.refetchHeartbeat():b.refetchConsolidation()},className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]}),(0,q.jsxs)(c,{variant:`outlined`,onClick:D,children:[(0,q.jsx)(z,{className:`h-4 w-4`}),`Back to schedules`]})]});if(n!=null)return(0,q.jsx)(rt,{onBack:D});if(!d||d.length===0&&!b.hasAnySystemTask&&!b.isLoading&&!b.hasError)return(0,q.jsxs)(`div`,{className:`w-full`,children:[(0,q.jsx)(nt,{onCreate:()=>C(!0)}),u?(0,q.jsx)(J,{isOpen:S,assistantId:u,onClose:()=>C(!1),onCreated:k}):null]});let{recurring:j,oneTime:M}=We(d);return(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,q.jsxs)(c,{variant:`primary`,onClick:()=>C(!0),children:[(0,q.jsx)(V,{className:`h-4 w-4`}),`New schedule`]})}),v?(0,q.jsx)(l,{tone:`warning`,className:`py-2 text-body-small-default`,children:`Schedule usage stats are unavailable right now.`}):null,j.length>0&&(0,q.jsx)(H,{title:`Schedules`,subtitle:`Recurring automations managed by your assistant.`,children:(0,q.jsx)(`div`,{children:j.map(t=>(0,q.jsx)(Ze,{schedule:t,usage:E(t.id),onClick:()=>O(t.id),onToggle:e=>void A(t.id,e),onOpenUsage:()=>e(R.logs.usageForSchedule(t.id))},t.id))})}),(0,q.jsx)(et,{heartbeatConfig:b.heartbeatConfig,consolidationConfig:b.consolidationConfig,heartbeatUsage:b.heartbeatUsage,consolidationUsage:b.consolidationUsage,isLoading:b.isLoading,hasError:b.hasError,onRetry:b.refetchAll,onSelectHeartbeat:()=>O(Z.heartbeat),onSelectConsolidation:()=>O(Z.consolidation),showSystemTaskToggles:s,onToggleHeartbeat:e=>void b.handleToggle(`heartbeat`,e),onToggleConsolidation:e=>void b.handleToggle(`consolidation`,e)}),M.length>0&&(0,q.jsx)(H,{title:`One-time`,subtitle:`One-shot automations that run once at a scheduled time.`,children:(0,q.jsx)(`div`,{children:M.map(t=>(0,q.jsx)(Ze,{schedule:t,usage:E(t.id),onClick:()=>O(t.id),onToggle:e=>void A(t.id,e),onOpenUsage:()=>e(R.logs.usageForSchedule(t.id))},t.id))})}),u?(0,q.jsx)(J,{isOpen:S,assistantId:u,onClose:()=>C(!1),onCreated:k}):null]})}export{it as SchedulesPage};