@vellumai/web 0.11.2-dev.202608050137.0c8f50a → 0.11.2-dev.202608050309.fa8263f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/access-INPRM_aM.js +1 -0
- package/dist/assets/{account-page-oJluvmyu.js → account-page-DjVlZWVH.js} +1 -1
- package/dist/assets/{acp-run-detail-panel-SF3Cd2Y1.js → acp-run-detail-panel-CYIyDAYY.js} +1 -1
- package/dist/assets/{activity-steps-panel-Bf7vfY3x.js → activity-steps-panel-DI7oxT6n.js} +1 -1
- package/dist/assets/{add-credits-modal-Bf2YtuiY.js → add-credits-modal-BsOahXBH.js} +1 -1
- package/dist/assets/{ai-page-DzDrUG4B.js → ai-page-DOo45fbr.js} +1 -1
- package/dist/assets/{api-Du7TU0QH.js → api-BbdlW3Wt.js} +1 -1
- package/dist/assets/{api-DZ1FASA0.js → api-nvrU4YoP.js} +1 -1
- package/dist/assets/{app-card-D_hiQfXt.js → app-card-DRJg7paP.js} +1 -1
- package/dist/assets/{assistant-feature-flag-store-B38SPaJa.js → assistant-feature-flag-store-N5OiUTEL.js} +1 -1
- package/dist/assets/{assistant-status-panel-BWsrTfK7.js → assistant-status-panel-SNr_dm8a.js} +1 -1
- package/dist/assets/auth-store-BZjAJNpH.js +2 -0
- package/dist/assets/{avatar-random-YP7nnkKq.js → avatar-random-B2ASlInK.js} +1 -1
- package/dist/assets/{background-task-detail-panel-CVc1_RgU.js → background-task-detail-panel-qWFvJ3e4.js} +1 -1
- package/dist/assets/{billing-page-savrq3xn.js → billing-page-BRrzQ-GL.js} +1 -1
- package/dist/assets/{bookmarks-page-sxUYn21c.js → bookmarks-page-Av_hWQOR.js} +1 -1
- package/dist/assets/{browser-OiWKXQtn.js → browser-COAyWDHw.js} +1 -1
- package/dist/assets/{build-state-DQX02fuw.js → build-state-BOnYvQ5M.js} +1 -1
- package/dist/assets/{channels-page-route--BPWHssi.js → channels-page-route-BPJlOqGo.js} +1 -1
- package/dist/assets/{chat-markdown-message-DNvDe2IS.js → chat-markdown-message-DZrSbzma.js} +1 -1
- package/dist/assets/checkout-continuation-D8RJlny7.js +1 -0
- package/dist/assets/{checkout-page-DoEIUiiE.js → checkout-page-DrZpel2T.js} +1 -1
- package/dist/assets/{client-feature-flag-store-DXK8Z7NT.js → client-feature-flag-store-D52k_a_E.js} +1 -1
- package/dist/assets/{client-perf-BrZz3Mpl.js → client-perf-DjfIe5LZ.js} +1 -1
- package/dist/assets/{command-palette-BzCLrSWF.js → command-palette-BigjlvPf.js} +1 -1
- package/dist/assets/{command-palette-window-page-Bar4rPii.js → command-palette-window-page-Bj33Fonm.js} +1 -1
- package/dist/assets/{composer-settings-BAq8X7A3.js → composer-settings-C22o1zsH.js} +1 -1
- package/dist/assets/{contacts-page-route-CKzbasmB.js → contacts-page-route-CT-F9Uyv.js} +1 -1
- package/dist/assets/{conversation-cache-BfZuxKKb.js → conversation-cache-NwL8DG0h.js} +1 -1
- package/dist/assets/{conversation-list-fetchers-DeJjdZ02.js → conversation-list-fetchers-ZLqN0i2Q.js} +1 -1
- package/dist/assets/{conversation-navigation-Bvhw1EOw.js → conversation-navigation-7utFvr1F.js} +1 -1
- package/dist/assets/{conversation-queries-BKN00Bls.js → conversation-queries-NcoEa-m7.js} +1 -1
- package/dist/assets/{credential-entry-page-BmdIrT2Y.js → credential-entry-page-Bcp2UvSU.js} +1 -1
- package/dist/assets/{credentials-page-C8fLd-2y.js → credentials-page-Dw2YMFyU.js} +1 -1
- package/dist/assets/{debug-page-BJ24FQmL.js → debug-page-6wX9N5-9.js} +1 -1
- package/dist/assets/{developer-page-BxS6g7X8.js → developer-page-Cf2Hsxff.js} +1 -1
- package/dist/assets/{diagnostics-_ZD3ioXN.js → diagnostics-Bss-eL9u.js} +1 -1
- package/dist/assets/{doctor-handoff-store-ChvNtnd_.js → doctor-handoff-store-Dgsz1SEJ.js} +1 -1
- package/dist/assets/{document-viewer-page-DEPRfmWT.js → document-viewer-page-D1GxRw_5.js} +1 -1
- package/dist/assets/{emails-page-BnDY30p0.js → emails-page-Dw8E0XPa.js} +1 -1
- package/dist/assets/{first-run-scope-Df_gGGNm.js → first-run-scope-vVgdnaxO.js} +1 -1
- package/dist/assets/{funnel-events-BKW4C5Jf.js → funnel-events-tVQwgCuQ.js} +1 -1
- package/dist/assets/{general-page-BIb0cuR1.js → general-page-BmOj-tFZ.js} +1 -1
- package/dist/assets/{haptics-DhLyE78C.js → haptics-CWVeK4vK.js} +1 -1
- package/dist/assets/{hatching-screen-Pr6og78J.js → hatching-screen-DX0u6V13.js} +1 -1
- package/dist/assets/{home-page-route-DjjXxxpU.js → home-page-route-CeMb7_IF.js} +1 -1
- package/dist/assets/{hosting-screen-CAMZoYZo.js → hosting-screen-DVSH4SEC.js} +1 -1
- package/dist/assets/{identity-page-route-CwJWYmVY.js → identity-page-route-C0xhDqb2.js} +1 -1
- package/dist/assets/{index-DeRGsIP3.js → index-COilDRK7.js} +1 -1
- package/dist/assets/{ingest-BrVPryb7.js → ingest-DLPNupgb.js} +1 -1
- package/dist/assets/{inspect-page-BjO9-p7V.js → inspect-page-Fs-9_UT8.js} +1 -1
- package/dist/assets/{integrations-page-JKlyqr71.js → integrations-page-haNwPw96.js} +1 -1
- package/dist/assets/{latest-assistant-text-Cb-Ghdzy.js → latest-assistant-text-Di1iMJIt.js} +1 -1
- package/dist/assets/{library-detail-page-Y1duKURD.js → library-detail-page-BB2oncWf.js} +1 -1
- package/dist/assets/{library-page-CRKnpdDM.js → library-page-ekBrsMsl.js} +1 -1
- package/dist/assets/{local-runtime-upgrade-BT6QBEBd.js → local-runtime-upgrade-yBKK0VHQ.js} +1 -1
- package/dist/assets/{login-flow-CMvSPkyf.js → login-flow-Cv6fd0k7.js} +1 -1
- package/dist/assets/{login-page-CRPDaiVk.js → login-page-Bhg7nETo.js} +1 -1
- package/dist/assets/{logout-page-CWpu9g04.js → logout-page-B0WXwIfk.js} +1 -1
- package/dist/assets/{logs-layout-bwOKn4Pa.js → logs-layout-CuUiFCNM.js} +1 -1
- package/dist/assets/{memory-page-route-UOYcnMLZ.js → memory-page-route-C8DzIVRN.js} +1 -1
- package/dist/assets/{memory-router-playground-page-BGD7o886.js → memory-router-playground-page-CmALtUEX.js} +1 -1
- package/dist/assets/{message-files-panel-vxGafAAF.js → message-files-panel-39eP4laA.js} +1 -1
- package/dist/assets/{messages-BdRhAWrP.js → messages-uHyh-apY.js} +1 -1
- package/dist/assets/{mobile-sidebar-drawer-DhERtMv3.js → mobile-sidebar-drawer-Cl-CxiPz.js} +1 -1
- package/dist/assets/native-anchor-RFjMKDmu.js +1 -0
- package/dist/assets/{navigation-resolver-C8Qyk5eO.js → navigation-resolver-BICOcF3M.js} +1 -1
- package/dist/assets/{notifications-DT6MYNFs.js → notifications-CeLmbVpH.js} +1 -1
- package/dist/assets/{notifications-page-CW_cMCqc.js → notifications-page-o2vT9Bmw.js} +1 -1
- package/dist/assets/{open-workspace-file-1J9ToS-d.js → open-workspace-file-DxlQEPBv.js} +2 -2
- package/dist/assets/{pairing-page-BgztYa3j.js → pairing-page-CioXlSXf.js} +1 -1
- package/dist/assets/{personality-page-2RRxkXCV.js → personality-page-BwGgtwRz.js} +1 -1
- package/dist/assets/{plans-page-44i492TS.js → plans-page-wWqD3Ie9.js} +1 -1
- package/dist/assets/{platform-detection-HB9owK_1.js → platform-detection-ClZAYwCS.js} +1 -1
- package/dist/assets/{platform-login-notice-CnAT6TJZ.js → platform-login-notice-DrQazymT.js} +1 -1
- package/dist/assets/{platform-loopback-page-BguKV0pz.js → platform-loopback-page-BVuXQaib.js} +1 -1
- package/dist/assets/{privacy-page-D4Ft3SSy.js → privacy-page-CeoXjDjo.js} +1 -1
- package/dist/assets/{privacy-screen-CauLgurD.js → privacy-screen-C4qzL1Ul.js} +1 -1
- package/dist/assets/{provider-callback-page-Cea5TFlV.js → provider-callback-page-CTQ986md.js} +1 -1
- package/dist/assets/{provider-signup-page-B5_miKb-.js → provider-signup-page-C-w5SLvU.js} +1 -1
- package/dist/assets/{push-registration-DXLfEroH.js → push-registration-BGoSmgni.js} +1 -1
- package/dist/assets/{research-onboarding-route-Z29ryU4y.js → research-onboarding-route-B8XpYAVW.js} +1 -1
- package/dist/assets/{retire-confirm-dialog-B-dxIKuG.js → retire-confirm-dialog-pqyV2Phc.js} +1 -1
- package/dist/assets/{review-terms-screen-XYNkBr0N.js → review-terms-screen-9A0cBzHW.js} +1 -1
- package/dist/assets/{routes-72rOaVXx.js → routes-DQmLqZE4.js} +12 -12
- package/dist/assets/{runtime-upgrade-banner-DSBdNsGU.js → runtime-upgrade-banner-DLrDr2eV.js} +1 -1
- package/dist/assets/{schedules-page-cRU86Tk_.js → schedules-page-BE16OokW.js} +1 -1
- package/dist/assets/{select-assistant-screen-D-kNYuuJ.js → select-assistant-screen-Dp6ms36y.js} +1 -1
- package/dist/assets/{settings-layout-Dh8J0arK.js → settings-layout-BccfBcC9.js} +1 -1
- package/dist/assets/{settings-navigation-Bz99iCom.js → settings-navigation-4wNM9U6G.js} +1 -1
- package/dist/assets/{share-feedback-modal-C6RtPO1y.js → share-feedback-modal-D8jik8C_.js} +1 -1
- package/dist/assets/{sidebar-tree-92PU_1JK.js → sidebar-tree-D-eWxuiT.js} +1 -1
- package/dist/assets/{signup-page-sW5_KNjN.js → signup-page-BZfNDRR7.js} +1 -1
- package/dist/assets/{skill-detail-page-DxrSMloo.js → skill-detail-page-Dv2PDJqy.js} +1 -1
- package/dist/assets/{subagent-detail-panel-Db9YPzqQ.js → subagent-detail-panel-2CCPEQV9.js} +1 -1
- package/dist/assets/{subagent-store-BXOhShEO.js → subagent-store-bjcKwT3Z.js} +1 -1
- package/dist/assets/{system-events-page-CQJ_53SO.js → system-events-page-DLap6GYQ.js} +1 -1
- package/dist/assets/{theme-stage-page-DkYOEAhj.js → theme-stage-page-BkfUP6id.js} +1 -1
- package/dist/assets/{tool-detail-panel-Cf007F2i.js → tool-detail-panel-XRiIAX_W.js} +1 -1
- package/dist/assets/{transcript-message-body-shared-B8cE25F6.js → transcript-message-body-shared-NonvqK2W.js} +1 -1
- package/dist/assets/{upgrade-cancel-page-BVTXE0dB.js → upgrade-cancel-page-Bjhnk_UH.js} +1 -1
- package/dist/assets/{upgrade-success-page-DgbZEPpF.js → upgrade-success-page-CAf6RjeY.js} +1 -1
- package/dist/assets/{use-app-theme-FEeKltJv.js → use-app-theme-DCACPYkF.js} +1 -1
- package/dist/assets/{use-assistant-capability-De7J71CP.js → use-assistant-capability-BMfO1JSS.js} +1 -1
- package/dist/assets/{use-assistant-identity-details-Dk2Qehe0.js → use-assistant-identity-details-62Drj54o.js} +1 -1
- package/dist/assets/{use-attachment-preview-D0T316St.js → use-attachment-preview-BahM3Fpa.js} +1 -1
- package/dist/assets/{use-attachment-squares-frmKddbN.js → use-attachment-squares-D-EgqhGW.js} +1 -1
- package/dist/assets/{use-checkout-dismiss-refresh-CExvyXix.js → use-checkout-dismiss-refresh-CyeZ_3L2.js} +1 -1
- package/dist/assets/{use-command-palette-sections-CWOLQX1W.js → use-command-palette-sections-CQkC-d-4.js} +1 -1
- package/dist/assets/{use-edge-swipe-BeF8H02p.js → use-edge-swipe-Cy1q_g93.js} +1 -1
- package/dist/assets/{use-edge-swipe-back-3Bk1xDr0.js → use-edge-swipe-back-CMMid7We.js} +1 -1
- package/dist/assets/{use-edit-app-DxKkV6Hk.js → use-edit-app-s9REmFwp.js} +1 -1
- package/dist/assets/{use-is-org-ready-CfmZwxdN.js → use-is-org-ready-CNHq_yBF.js} +1 -1
- package/dist/assets/{use-onboarding-login-CJ7p0ITq.js → use-onboarding-login-D5l9Xmkv.js} +1 -1
- package/dist/assets/{use-platform-assistant-id-BBcUWy3-.js → use-platform-assistant-id-ziur35ah.js} +1 -1
- package/dist/assets/{use-platform-gate-CijNH8dw.js → use-platform-gate-Cx6EwFNs.js} +1 -1
- package/dist/assets/{use-return-to-short-circuit-C2YqlJVv.js → use-return-to-short-circuit-C7h8gHr0.js} +1 -1
- package/dist/assets/{use-sticky-profiles-DmcmSOsO.js → use-sticky-profiles-Bz0Gst-X.js} +1 -1
- package/dist/assets/{use-subagent-card-data-DGBTouhd.js → use-subagent-card-data-BB49eUCK.js} +1 -1
- package/dist/assets/use-transcript-message-by-id-DIG7klGi.js +1 -0
- package/dist/assets/{use-transcript-messages-DEs7Ih4P.js → use-transcript-messages-BL8C5d75.js} +1 -1
- package/dist/assets/{use-voice-sample-preview-CXWDRLHi.js → use-voice-sample-preview-CG9dYvdC.js} +1 -1
- package/dist/assets/{viewer-store-CGDw5Wtf.js → viewer-store-C-Uj2CzB.js} +1 -1
- package/dist/assets/{voice-list-Dn_1H-ZV.js → voice-list-Bza1jX_c.js} +1 -1
- package/dist/assets/{voice-page-CSzqo58x.js → voice-page-DuYLAxew.js} +1 -1
- package/dist/assets/{welcome-screen-WLx6gBF8.js → welcome-screen-D4wb-el5.js} +1 -1
- package/dist/assets/{workflow-store-Cotm4qOw.js → workflow-store-2S0CxvX3.js} +1 -1
- package/dist/assets/{workspace-page-C2UHPyt-.js → workspace-page-C1v1cUsu.js} +1 -1
- package/dist/index.html +59 -59
- package/package.json +1 -1
- package/dist/assets/access-DIC4wO8s.js +0 -1
- package/dist/assets/auth-store-AVhhOiz_.js +0 -2
- package/dist/assets/checkout-continuation-Cl65aymU.js +0 -1
- package/dist/assets/native-anchor-S15uxlUB.js +0 -1
- package/dist/assets/use-transcript-message-by-id-nvkX1iRu.js +0 -1
- /package/dist/assets/{feature-flag-catalog-K0ruEmRc.js → feature-flag-catalog-Ccklc1QS.js} +0 -0
- /package/dist/assets/{native-biometric-DSA3t7PV.js → native-biometric-Brq7EN1d.js} +0 -0
- /package/dist/assets/{remote-gateway-session-BKw7UXep.js → remote-gateway-session-C9Gb2ZfG.js} +0 -0
package/dist/assets/{use-attachment-squares-frmKddbN.js → use-attachment-squares-D-EgqhGW.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{n}from"./button-fyWSnR9X.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{t as i}from"./typography-DEI9Ra9z.js";import{t as a}from"./archive-BQ3zdIPv.js";import{a as o,c as s,l as c,o as l,r as u,s as d,t as f,u as p}from"./use-attachment-preview-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{n}from"./button-fyWSnR9X.js";import{t as r}from"./jsx-runtime-D3ZM-ToX.js";import{t as i}from"./typography-DEI9Ra9z.js";import{t as a}from"./archive-BQ3zdIPv.js";import{a as o,c as s,l as c,o as l,r as u,s as d,t as f,u as p}from"./use-attachment-preview-BahM3Fpa.js";import"./src-ly8ixpHd.js";import{t as m}from"./download-Cnb8zZrK.js";import{t as h}from"./file-text-CwGsMgaa.js";import{t as g}from"./file-DOePafLU.js";import{m as _}from"./native-biometric-Brq7EN1d.js";import{a as v,n as y,o as b}from"./pdf-preview-DXBz91H7.js";var x=e(t(),1),S=r(),C=`h-16 w-16 shrink-0 rounded-lg`,w={image:(0,S.jsx)(s,{className:`h-6 w-6`}),video:(0,S.jsx)(d,{className:`h-6 w-6`}),audio:(0,S.jsx)(c,{className:`h-6 w-6`}),pdf:(0,S.jsx)(o,{className:`h-6 w-6`}),code:(0,S.jsx)(p,{className:`h-6 w-6`}),archive:(0,S.jsx)(a,{className:`h-6 w-6`}),spreadsheet:(0,S.jsx)(l,{className:`h-6 w-6`}),document:(0,S.jsx)(h,{className:`h-6 w-6`}),text:(0,S.jsx)(h,{className:`h-6 w-6`}),file:(0,S.jsx)(g,{className:`h-6 w-6`})};function T({attachment:e,onPreview:t,onDownload:r,onPreviewError:a}){let{filename:o,mimeType:s,sizeBytes:c,previewUrl:l,thumbnailUrl:u}=e,d=y(s,o),f=d===`image`&&l!==null,p=d===`video`&&u!=null?u:null,h=!f&&p===null,g=t!=null,T=b(o,18),E=v(c),D=_(),O=(0,x.useCallback)(e=>{e.stopPropagation(),r?.()},[r]);return(0,S.jsxs)(`div`,{role:g?`button`:f?`img`:void 0,"aria-label":o,title:o,tabIndex:g?0:void 0,onClick:g?t:void 0,onKeyDown:g?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t?.())}:void 0,className:`group/square flex flex-col gap-1${g?` cursor-pointer`:``}`,children:[(0,S.jsxs)(`div`,{className:`relative w-fit`,children:[(0,S.jsx)(`div`,{className:`${C} flex items-center justify-center overflow-hidden bg-[var(--surface-lift)] bg-cover bg-center text-[var(--content-secondary)]${h?` border border-[var(--border-element)]`:``}`,style:p?{backgroundImage:`url(${JSON.stringify(p)})`}:void 0,children:f?(0,S.jsx)(`img`,{src:l,alt:``,"aria-hidden":!0,onError:a,className:`h-full w-full object-cover`}):p?null:w[d]}),r&&(0,S.jsx)(`div`,{className:`pointer-events-none absolute inset-0 rounded-lg bg-black/50 opacity-0 transition-opacity group-hover/square:pointer-events-auto group-hover/square:opacity-100 group-focus-within/square:pointer-events-auto group-focus-within/square:opacity-100`,children:(0,S.jsx)(n,{content:`Download`,children:(0,S.jsx)(`button`,{type:`button`,onClick:O,onKeyDown:e=>e.stopPropagation(),"aria-label":`Download ${o}`,className:`absolute bottom-1 right-1 flex h-6 w-6 items-center justify-center rounded-md text-white/80 transition-colors hover:bg-white/20 hover:text-white`,children:(0,S.jsx)(m,{className:`h-3.5 w-3.5`})})})})]}),(0,S.jsx)(i,{variant:`label-small-default`,className:`max-w-[64px] truncate text-[var(--content-tertiary)]`,children:T}),!D&&(0,S.jsx)(i,{variant:`label-small-default`,className:`text-[var(--content-disabled)]`,children:E})]})}function E({attachments:e,assistantId:t}){let[n,r]=(0,x.useState)(new Set),i=(0,x.useCallback)(e=>{r(t=>t.has(e)?t:new Set(t).add(e))},[]),a=(0,x.useMemo)(()=>n.size===0?e:e.map(e=>n.has(e.id)?{...e,previewUrl:null}:e),[e,n]),{openPreview:o,previewModal:s}=f(t,a);return{displayAttachments:a,renderSquare:(0,x.useCallback)((n,r)=>(0,S.jsx)(T,{attachment:n,onPreview:()=>o(n),onDownload:()=>void u(e[r]??n,t),onPreviewError:()=>i(n.id)},n.id),[e,t,o,i]),openPreview:o,markImageFailed:i,previewModal:s}}export{C as n,E as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-fyWSnR9X.js";import{n as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{c as a,g as o,n as s}from"./QueryClientProvider-CMu7CkQU.js";import{t as c}from"./useQuery-Bz-fbQ-m.js";import{t as l}from"./useMutation-CXGTrp4W.js";import{t as u}from"./jsx-runtime-D3ZM-ToX.js";import{t as d}from"./typography-DEI9Ra9z.js";import{t as f}from"./createLucideIcon-CAM1RhH8.js";import{t as p}from"./arrow-right-ChqGeAaW.js";import{t as m}from"./check-Dt2rQhdg.js";import{t as h}from"./circle-alert-DQMH8VJH.js";import{t as g}from"./circle-check-DvrCdroD.js";import{t as _}from"./coins-CcTuNVlN.js";import{n as v,t as y}from"./sliders-horizontal-BwdOIxz8.js";import{t as b}from"./hard-drive-sI2ZzmqM.js";import{t as x}from"./info-DkhVkzmK.js";import{t as S}from"./loader-circle-DWWXcfTQ.js";import{t as C}from"./triangle-alert-D6bAGtMw.js";import{t as w}from"./notice-Dslxs3H6.js";import{t as T}from"./modal-D946-vqt.js";import{n as E}from"./toast-DJj-rM9J.js";import{t as ee}from"./confirm-dialog-Ro8nszbc.js";import{t as D}from"./dropdown-Dj83uU1o.js";import{n as O}from"./resolved-assistants-store-BymuLyDm.js";import{$ as k,Y as A,d as j,f as M,l as te,u as N}from"./auth-store-AVhhOiz_.js";import{S as ne,b as re}from"./native-biometric-DSA3t7PV.js";import{d as P}from"./routes-CAe1h0Db.js";import{f as F}from"./platform-detection-HB9owK_1.js";import{n as I}from"./use-assistant-avatar-2AaP2LdS.js";import{r as ie}from"./use-is-org-ready-CfmZwxdN.js";import{n as ae,r as oe}from"./browser-OiWKXQtn.js";import{C as se,O as ce,Tt as le,at as ue,c as de,ct as fe,dt as L,et as pe,it as me,l as R,lt as z,nt as he,ot as ge,r as _e,rt as ve,st as ye,tt as B,ut as V,y as be}from"./react-query.gen-B0XpEMFg.js";import{t as H}from"./avatar-bundled-components-BvKt7I7O.js";import{r as xe}from"./use-avatar-accent-var-BafXGBXW.js";import{t as U}from"./misc-BBsGq1IU.js";import{n as Se,t as Ce}from"./avatar-tone-BOo-ADtK.js";import{t as we}from"./chat-avatar-B-PiUu6F.js";import{t as Te}from"./avatar-renderer-DIISZw2O.js";import{n as W}from"./use-bundled-avatar-components-8xinhvVj.js";import{t as Ee}from"./android-consumption-only-DVgl1UqJ.js";import{c as De,i as G,l as Oe,n as K,r as ke,t as Ae}from"./machine-sizes-CvnllWMa.js";import{a as je,i as Me,n as Ne,r as Pe,t as Fe}from"./provisioning-targets-BK0r8PFS.js";import{t as Ie}from"./environment-store-CaT6bPjE.js";var Le=f(`computer`,[[`rect`,{width:`14`,height:`8`,x:`5`,y:`2`,rx:`2`,key:`wc9tft`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,key:`w68u3i`}],[`path`,{d:`M6 18h2`,key:`rwmk9e`}],[`path`,{d:`M12 18h6`,key:`aqd8w3`}]]),q=u();function Re({children:e,redirectToBilling:t=!1}){return F()?t?(0,q.jsx)(r,{replace:!0,to:P.settings.usageBilling}):(0,q.jsx)(w,{tone:`info`,children:Ee}):e}var J=e(t(),1);function ze({icon:e}){return(0,q.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-negative-strong) 12%, transparent)`},children:(0,q.jsx)(e,{className:`h-5 w-5`,style:{color:`var(--system-negative-strong)`},"aria-hidden":`true`})})}var Y={fontFamily:`var(--font-serif)`,fontSize:`32px`,fontWeight:400,lineHeight:1.2,letterSpacing:`0.64px`};function X({title:e,subtitle:t}){return(0,q.jsxs)(`header`,{className:`flex flex-col items-center gap-2 pt-12 text-center`,children:[(0,q.jsx)(`h2`,{className:`text-[var(--content-emphasised)]`,style:Y,children:e}),t&&(0,q.jsx)(`p`,{className:`text-[14px] font-normal text-[var(--content-secondary)]`,children:t})]})}var Be=[{bodyShape:`star`,eyeStyle:`curious`,color:`yellow`,size:103,position:`-left-[28px] -top-[33px]`,rotate:180},{bodyShape:`star`,eyeStyle:`curious`,color:`orange`,size:109,position:`left-[63%] -top-[62px] -translate-x-1/2`,rotate:-8},{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`,size:76,position:`-right-[25px] top-[60px]`,rotate:1},{bodyShape:`stack`,eyeStyle:`gentle`,color:`purple`,size:110,position:`-left-[39px] top-[74%]`,rotate:0},{bodyShape:`urchin`,eyeStyle:`goofy`,color:`pink`,size:137,position:`-right-[42px] -bottom-[40px]`,rotate:180},{bodyShape:`sprout`,eyeStyle:`curious`,color:`orange`,size:72,position:`left-[37%] -bottom-[22px] -translate-x-1/2`,rotate:0}],Ve=[{bodyShape:`star`,eyeStyle:`curious`,color:`yellow`,size:103,position:`-left-[28px] -top-[33px]`,rotate:180},{bodyShape:`star`,eyeStyle:`curious`,color:`orange`,size:109,position:`left-[63%] -top-[62px] -translate-x-1/2`,rotate:-8},{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`,size:76,position:`-right-[25px] top-[60px]`,rotate:1}];function He({variant:e=`full`}){let t=W();return t?(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`creature-corners`,className:`pointer-events-none absolute inset-0 select-none`,children:(e===`top`?Ve:Be).map((e,n)=>(0,q.jsx)(`span`,{className:`absolute ${e.position}`,style:{rotate:`${e.rotate}deg`},children:(0,q.jsx)(Te,{components:t,bodyShapeId:e.bodyShape,eyeStyleId:e.eyeStyle,colorId:e.color,size:e.size})},n))}):null}var Z={waitingStatus:`Upgrading your assistant…`,snagStatus:`We hit a snag upgrading your assistant`,snagCaption:`Retry in the background and we'll keep working on your upgrade.`,confirmingStatus:`Confirming your upgrade…`,confirmTimeoutStatus:`Still confirming your upgrade`,confirmTimeoutCaption:`Your payment went through safely. This can take a minute.`,backgroundConfirmMessage:`Your assistant is still upgrading. Chatting won't be available until it finishes. You can keep waiting here, or continue and we'll let you know when it's ready.`,backgroundExitToast:`Your upgrade continues in the background.`,backgroundRetryToast:`We'll retry your upgrade in the background.`,completeSubtitle:`Enjoy the new found power.`,fetchErrorBody:`We hit a problem checking your subscription. Your upgrade may still be processing. Return to billing to refresh.`},Q={waitingStatus:`Updating your assistant…`,snagStatus:`We hit a snag updating your assistant`,snagCaption:`Retry in the background and we'll keep working on your plan change.`,confirmingStatus:`Confirming your plan change…`,confirmTimeoutStatus:`Still confirming your plan change`,confirmTimeoutCaption:`Your plan change was submitted. This can take a minute.`,backgroundConfirmMessage:`Your assistant is still updating. Chatting won't be available until it finishes. You can keep waiting here, or continue and we'll let you know when it's ready.`,backgroundExitToast:`Your plan change continues in the background.`,backgroundRetryToast:`We'll retry your plan change in the background.`,completeSubtitle:`Your plan changes are live.`,fetchErrorBody:`We hit a problem checking your subscription. Your plan change may still be processing. Return to billing to refresh.`},Ue={upgrade:Z,downgrade:Q,change:Q};function We(e=`upgrade`){return Ue[e]}function Ge(e,t=!0){let{data:n}=c({..._e(),enabled:t&&e==null}),{data:r}=c({...ce({path:{id:e??``}}),enabled:t&&e!=null});return e==null?n:r}function Ke({assistantId:e,direction:t}){let r=i(),a=Ge(e,ie())?.name||`your assistant`;return(0,q.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 pb-16 [animation:onboarding-step-in_350ms_ease-out] motion-reduce:[animation:none]`,children:[(0,q.jsx)(He,{variant:`full`}),(0,q.jsxs)(`div`,{className:`relative flex w-full flex-col items-center`,children:[(0,q.jsx)(X,{title:`You're all set!`,subtitle:We(t).completeSubtitle}),(0,q.jsx)(`div`,{className:`mt-10 flex w-full flex-col items-center gap-10`,children:(0,q.jsxs)(n,{variant:`primary`,"data-testid":`onboarding-complete-return`,onClick:()=>{e!=null&&A(e),r(P.assistant,{replace:!0})},children:[`Return to `,a]})})]})]})}function qe(e=!0,t){let n=Ge(t,e),r=t??n?.id,{data:i,isError:a,isFetching:o,dataUpdatedAt:s,errorUpdatedAt:l}=c({...de({path:{assistant_id:r??``}}),enabled:e&&!!r});return{assistant:n,assistantId:r,domains:i,domainsError:a,domainsFetching:o,domainsUpdatedAt:s,domainsErrorUpdatedAt:l}}var Je=1e3,Ye=1e4,Xe=2500,Ze=2e3,Qe=1e4,$e=[`machine_size`,`subdomain`,`non_field_errors`],et={subdomain_taken:`That subdomain is already taken. Try another.`,assistant_already_has_domain:`Your assistant already has a custom domain.`,no_assistant_to_attach_domain:`We couldn't find an assistant to attach this domain to.`,exceeds_machine_tier:`That machine size isn't available on your plan.`,provisioning_submission_failed:`We couldn't queue your upgrade just now. Try again in a moment.`,no_active_pro:`We couldn't confirm your Pro plan yet. Try again in a moment.`,no_provisionable_assistants:`We couldn't find an assistant to upgrade yet. Try again in a moment.`},tt={provisioning_submission_failed:`We couldn't queue your plan change just now. Try again in a moment.`,no_provisionable_assistants:`We couldn't find an assistant to update yet. Try again in a moment.`};function nt(e,t,n=`upgrade`){if(e&&typeof e==`object`){let t=e;if(typeof t.error==`string`){let e=(n===`upgrade`?void 0:tt[t.error])??et[t.error];if(e)return e}for(let e of $e){let n=t[e];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(typeof t.detail==`string`)return t.detail}return t}var rt=`h-8 rounded-lg border border-[var(--border-element)] bg-[var(--field-bg)] px-2.5 text-[14px] text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none transition-[border-color] duration-150 focus:border-[var(--border-active)] disabled:cursor-not-allowed disabled:opacity-60`,it=`text-[11px] font-medium text-[var(--content-secondary)]`;function at({onExit:e,machineBusy:t=!1,assistantId:r}){let i=s(),a=Ie.use.emailRootDomain(),{assistant:o,assistantId:c,domains:u}=qe(!0,r),d=u?.results[0],[f,p]=(0,J.useState)(``),[m,h]=(0,J.useState)(`hi`),[g,_]=(0,J.useState)(!1);(0,J.useEffect)(()=>{if(!g){if(d){p(d.subdomain),_(!0);return}!o?.handle||f||(p(o.handle),_(!0))}},[o?.handle,d,g,f]);let[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(!1),S=l(ge()),C=!!d||b,E=S.isPending||b;return(0,J.useEffect)(()=>{if(!b)return;let t=setTimeout(e,800);return()=>clearTimeout(t)},[b,e]),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(T.Body,{className:`animate-[onboarding-step-in_350ms_ease-out] space-y-6 pb-0 motion-reduce:animate-none`,children:[(0,q.jsx)(He,{variant:`top`}),(0,q.jsx)(X,{title:`Assistant Email`,subtitle:`Set up an email for your assistant.`}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`label`,{htmlFor:`onboarding-email-prefix`,className:it,children:`Prefix`}),(0,q.jsx)(`input`,{id:`onboarding-email-prefix`,value:m,onChange:e=>h(e.target.value.toLowerCase().trim()),disabled:E||C,readOnly:C,placeholder:`hi`,className:`${rt} w-24`})]}),(0,q.jsx)(`span`,{className:`flex h-8 items-center text-[var(--content-secondary)]`,children:`@`}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,q.jsx)(`label`,{htmlFor:`onboarding-email-handle`,className:it,children:`Handle (public)`}),(0,q.jsx)(`input`,{id:`onboarding-email-handle`,value:f,onChange:e=>{p(e.target.value.toLowerCase().trim()),v&&y(null)},disabled:E||C,readOnly:C,autoFocus:!0,placeholder:`my-assistant`,"aria-invalid":!!v,className:`${rt} w-full min-w-0`})]}),(0,q.jsxs)(`span`,{className:`flex h-8 shrink-0 items-center text-[14px] text-[var(--content-tertiary)]`,children:[`.`,a]})]}),v&&(0,q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:v}),C&&(0,q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`This domain has been set and cannot be changed.`})]}),t&&!C&&(0,q.jsx)(w,{tone:`neutral`,children:`Your assistant is restarting — you can set the domain in a moment.`}),!C&&(0,q.jsx)(w,{tone:`info`,className:`border-transparent bg-[var(--surface-active)]`,children:(0,q.jsx)(`span`,{className:`font-medium text-[var(--content-tertiary)]`,children:`You won't be able to change the handle once set.`})}),b?(0,q.jsx)(w,{tone:`success`,children:`Domain set — redirecting…`}):null]}),(0,q.jsx)(T.Footer,{className:`items-center pt-6`,children:C?(0,q.jsx)(n,{variant:`primary`,"data-testid":`onboarding-domain-continue`,onClick:e,children:`Continue`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(n,{variant:`outlined`,"data-testid":`onboarding-domain-skip`,disabled:E,onClick:()=>{E||S.mutate({body:{skipped:!0}},{onSuccess:e,onError:()=>e()})},children:`Skip`}),(0,q.jsx)(n,{variant:`primary`,"data-testid":`onboarding-domain-set`,disabled:!f||E||t,onClick:()=>{E||t||!f||S.mutate({body:{subdomain:f,...m?{email_username:m}:{}}},{onSuccess:()=>{y(null),x(!0),i.invalidateQueries({queryKey:be()}),i.invalidateQueries({queryKey:R({path:{assistant_id:c??``}})}),i.invalidateQueries({queryKey:z()})},onError:e=>{y(nt(e,`Couldn't register that subdomain. Try a different one.`))}})},children:`Next`})]})})]})}function ot({onGoToBilling:e,direction:t}){return(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-10 text-center`,children:[(0,q.jsx)(ze,{icon:h}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(d,{variant:`title-small`,as:`h1`,children:`Couldn't reach billing`}),(0,q.jsx)(d,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:We(t).fetchErrorBody})]}),(0,q.jsx)(n,{variant:`primary`,"data-testid":`onboarding-go-to-billing`,onClick:e,children:`Go to billing`})]})}function st(e){let t=e/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}function $(e){return`${st(e)}/mo`}function ct(e){return`${e>0?`+`:`−`}${st(Math.abs(e))}/mo`}function lt(e){return`${e} GB storage`}function ut(e){return`${st(e*100)} of bundled credits`}function dt(e){let{targets:t,fromSnapshot:n,machineFloor:r,credits:i}=e,a=[];return t.machineSize==null?r!=null&&n.machineSize!=null&&n.machineSize!==r&&a.push({key:`machine`,label:`Machine`,from:G[n.machineSize],to:G[r]}):n.machineSize!==t.machineSize&&a.push({key:`machine`,label:`Machine`,from:n.machineSize==null?void 0:G[n.machineSize],to:G[t.machineSize]}),t.storageGib!=null&&(n.storageGib==null||t.storageGib>n.storageGib)&&a.push({key:`storage`,label:`Storage`,from:n.storageGib==null?void 0:`${n.storageGib} GB`,to:`${t.storageGib} GB`}),i!=null&&a.push({key:`credits`,label:`Credits`,from:i.from,to:i.to}),a}var ft=60,pt=ft*2;function mt({imageUrl:e,animateIn:t=!0}){return(0,q.jsxs)(`div`,{"aria-hidden":!0,"data-testid":`takeover-backdrop`,className:`pointer-events-none absolute inset-0 overflow-hidden${t?` provision-avatar-reveal`:``}`,children:[(0,q.jsx)(`img`,{src:e,alt:``,decoding:`async`,draggable:!1,className:`absolute left-1/2 top-1/2 max-w-none -translate-x-1/2 -translate-y-1/2 object-cover object-center`,style:{filter:`blur(${ft}px)`,width:`calc(100% + ${pt*2}px)`,height:`calc(100% + ${pt*2}px)`}}),(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/55`})]})}function ht(e){let t=e?.match(/^credits_(\d+)$/)?.[1];return t==null?null:Number(t)}function gt(e,t){if(t!=null)return e?.credit_tiers?.find(e=>e.tier===t)}function _t(e){let t=ie(),{data:n}=c({...pe(),enabled:t&&e});return n?.plans.find(e=>e.id===`pro`)}function vt(e,t){return t==null?0:gt(e,t)?.credits_usd??ht(t)}function yt(e){let t=_t(e!=null);if(e==null||t==null)return null;let n;if(e.kind===`package`){let r=t.packages.find(t=>t.key===e.packageKey);n=r?.credits_usd??gt(t,r?.credit_tier)?.credits_usd}else n=gt(t,e.creditTier)?.credits_usd;return n==null?null:{fromUsd:0,toUsd:n}}function bt(e){let t=_t(e!=null);if(e==null)return null;let n=vt(t,e.fromTier),r=vt(t,e.toTier);return n==null||r==null?null:{fromUsd:n,toUsd:r}}function xt(e){let t=O.use.activeAssistantId(),n=e===void 0?t:e,{components:r,traits:i,customImageUrl:a,isLoading:o}=I(n),s=(0,J.useMemo)(()=>j(),[M()]),c=s!=null&&N(s)?s:null,l=n!=null&&!o,u=c!=null&&(n==null||n===c.assistantId),d=u&&!(l&&(r!=null||i!=null||a!=null))?c:null,f=d?d.components:r,p=d?d.traits:i,m=d?null:a,h=l||u,g=xe(f,p)??(m?null:(f??H).colors?.[0]?.hex??null);return{tintHex:h&&g?Se(g):Ce,backdropImageUrl:h?m:null,ready:h,avatar:{components:f,traits:p,customImageUrl:m}}}function St(e,t){let[n,r]=(0,J.useState)(e),i=(0,J.useRef)(0);return(0,J.useEffect)(()=>{i.current=performance.now()},[]),(0,J.useEffect)(()=>{if(t<=0||e===n)return;let a=t-(performance.now()-i.current);if(a<=0){i.current=performance.now(),r(e);return}let o=setTimeout(()=>{i.current=performance.now(),r(e)},a);return()=>clearTimeout(o)},[e,n,t]),t<=0?e:n}var Ct=`--takeover-surface`,wt=`var(${Ct},${Ce})`,Tt=`color-mix(in srgb, var(--content-emphasised) 10%, transparent)`,Et=240,Dt=1.414,Ot=[{minHeight:680,size:Et},{minHeight:600,size:184}],kt=132;function At(e){for(let t of Ot)if(e>=t.minHeight)return t.size;return kt}function jt(){let[e,t]=(0,J.useState)(()=>At(typeof window>`u`?1/0:window.innerHeight));return(0,J.useEffect)(()=>{let e=()=>t(At(window.innerHeight));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}var Mt={machine:v,storage:b,credits:_},Nt={idle:``,working:` is-working`,settling:` is-settling`,stalled:` is-stalled`,grown:` is-evolved`};function Pt(e,t){return e===`DONE`||e===`NOT_APPLICABLE`?`grown`:e===`STALLED`?`stalled`:e===`WAITING`||e===`RESIZING`?t?`settling`:`working`:`idle`}function Ft({assistantId:e,mode:t,downsizing:n=!1}){let{avatar:r,ready:i}=xt(e),a=W(),o=jt(),s=t===`working`||t===`settling`;return(0,q.jsxs)(`div`,{"aria-hidden":!0,className:`provision-avatar-evolve relative z-10 flex flex-col items-center${Nt[i?t:`idle`]}${n?` is-downsizing`:``}`,style:{"--provision-avatar-size":`${o}px`,"--provision-avatar-growth":Dt},children:[(0,q.jsxs)(`div`,{className:`provision-avatar-stage`,children:[(0,q.jsx)(`div`,{"data-testid":`provision-avatar-placeholder`,className:`provision-avatar-placeholder${i?` is-resolved`:``}`}),(0,q.jsx)(`div`,{className:`provision-avatar-layer`,children:(0,q.jsx)(`div`,{className:`provision-avatar-current`,children:(0,q.jsx)(`div`,{className:`provision-avatar-strain`,children:i&&(0,q.jsx)(`div`,{className:`provision-avatar-reveal`,children:(0,q.jsx)(we,{components:r.components??a,traits:r.traits,customImageUrl:r.customImageUrl,size:o,isAssistantBusy:s})})})})})]}),(0,q.jsx)(`div`,{className:`provision-avatar-shadow`})]})}function It({status:e,caption:t}){return(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,q.jsx)(`h1`,{className:`text-[var(--content-emphasised)]`,style:Y,children:e}),t&&(0,q.jsx)(d,{variant:`body-medium-lighter`,as:`p`,className:`max-w-sm text-[var(--content-secondary)]`,children:t})]})}function Lt({icon:e,label:t,from:n,to:r,done:i=!1,pending:a=!1,testId:o}){let s=null;return i?s=`Complete`:a&&(s=`Pending`),(0,q.jsxs)(`div`,{"data-testid":o,className:`flex min-w-0 flex-auto items-center gap-2 rounded-lg px-2 py-1.5${a?` opacity-70`:``}`,style:{backgroundColor:Tt},children:[(0,q.jsx)(`span`,{className:`hidden h-6 w-6 shrink-0 items-center justify-center min-[420px]:flex`,children:(0,q.jsx)(e,{className:`h-3.5 w-3.5 text-[var(--content-tertiary)]`,"aria-hidden":`true`})}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 text-left wrap-anywhere`,children:[(0,q.jsx)(`span`,{className:`text-[12px] font-medium leading-tight text-[var(--content-tertiary)]`,children:t}),(0,q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-[14px] font-medium leading-[18px] text-[var(--content-emphasised)]`,children:[n&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{children:n}),(0,q.jsx)(`span`,{className:`sr-only`,children:`to`}),(0,q.jsx)(p,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":`true`})]}),(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{children:r}),i?(0,q.jsx)(m,{"data-testid":`chip-check`,className:`h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`,"aria-hidden":`true`}):a&&(0,q.jsx)(S,{"data-testid":`chip-spinner`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-[var(--content-tertiary)] motion-reduce:animate-none`,"aria-hidden":`true`})]}),s&&(0,q.jsx)(`span`,{className:`sr-only`,children:s})]})]})]})}function Rt({label:e}){return(0,q.jsx)(`span`,{className:`rounded-lg px-3 py-2 text-[14px] text-[var(--content-emphasised)]`,style:{backgroundColor:Tt},children:e})}function zt({children:e,wide:t=!1,testId:n}){return(0,q.jsx)(`div`,{"data-testid":n,className:`flex w-full ${t?`max-w-2xl`:`max-w-sm`} items-stretch justify-center gap-2`,children:e})}function Bt(e,t){return e===`credits`?!0:t?.[e]===!0}function Vt({intent:e,creditsChange:t,targets:n,fromSnapshot:r,machineFloor:i,landed:a,allDone:o=!1,creditsOnly:s=!1}){let c=yt(e),l=bt(t),u=c??l,d=dt({targets:n,fromSnapshot:r,machineFloor:i,credits:u==null?null:{from:$(u.fromUsd*100),to:$(u.toUsd*100)}}),f=s?d.filter(e=>e.key===`credits`):d,p=f.filter(e=>o||Bt(e.key,a)).map(e=>e.label).join(`, `),[m]=(0,J.useState)(p),h=p===m?``:`${p} complete`;return f.length===0?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(zt,{testId:`resource-chips`,wide:f.length>=3,children:f.map(e=>{let t=o||Bt(e.key,a);return(0,q.jsx)(Lt,{testId:`chip-${e.key}`,icon:Mt[e.key],label:e.label,from:e.from,to:e.to,done:t,pending:!t},e.key)})}),(0,q.jsx)(`p`,{"aria-live":`polite`,className:`sr-only`,"data-testid":`chip-announcement`,children:h})]})}function Ht({intent:e}){if(e.kind===`package`)return(0,q.jsx)(zt,{children:(0,q.jsx)(Rt,{label:`${e.packageKey.charAt(0).toUpperCase()+e.packageKey.slice(1)} package`})});let t=[e.machineTier,e.storageTier,e.creditTier].filter(e=>e!=null).length;return(0,q.jsxs)(zt,{wide:t>=3,children:[e.machineTier!=null&&(0,q.jsx)(Lt,{icon:v,label:`Machine`,to:K[e.machineTier]??e.machineTier}),e.storageTier!=null&&(0,q.jsx)(Lt,{icon:b,label:`Storage`,to:e.storageTier.toUpperCase()}),e.creditTier!=null&&(0,q.jsx)(Rt,{label:`${e.creditTier.replace(`credits_`,``)} credits`})]})}function Ut({state:e,direction:t,softWaiting:r,intent:i,creditsChange:a,targets:o,fromSnapshot:s,machineFloor:c,landed:l,celebrating:u,onCelebrationEnd:d,assistantId:f,escapeAvailable:p,onEscape:m,onPhaseChange:h,kickError:g,confirm:_,dwellMs:v=Xe,phaseMinMs:y=900}){let b=We(t),x=(0,J.useRef)(d);(0,J.useEffect)(()=>{x.current=d},[d]);let S=St(e,y),C=S===`DONE`||S===`NOT_APPLICABLE`,w=S===`RESIZING`?`WAITING`:S,T=(0,J.useRef)(h);(0,J.useEffect)(()=>{T.current=h},[h]),(0,J.useEffect)(()=>{T.current?.(S)},[S]);let{tintHex:E,backdropImageUrl:ee}=xt(f),D=u&&C;return(0,J.useEffect)(()=>{if(!D)return;let e=setTimeout(()=>x.current(),v);return()=>clearTimeout(e)},[D,v]),(0,q.jsxs)(`div`,{"data-theme":`dark`,className:`provision-surface-settle relative flex h-full min-h-[420px] w-full flex-col items-center [justify-content:safe_center] gap-10 px-6 py-10 text-center`,style:{[Ct]:E,backgroundColor:wt},children:[ee&&(0,q.jsx)(mt,{imageUrl:ee}),(0,q.jsx)(Ft,{assistantId:f,mode:Pt(S,r),downsizing:t===`downgrade`}),(0,q.jsx)(`div`,{className:`relative z-10 flex min-h-[144px] w-full flex-col items-center gap-8 [animation:onboarding-step-in_420ms_ease-out] motion-reduce:[animation:none]`,children:A()},w)]});function O(e=`Continue in the background`){return p?(0,q.jsx)(n,{variant:`ghost`,"data-testid":`provisioning-escape`,onClick:m,children:e}):null}function k({allDone:e=!1,creditsOnly:t=!1}={}){return(0,q.jsx)(Vt,{intent:i,creditsChange:a,targets:o,fromSnapshot:s,machineFloor:c,landed:l,allDone:e,creditsOnly:t})}function A(){if(S===`CONFIRMING`)return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(It,{status:b.confirmingStatus,caption:`This might take a couple seconds.`}),i&&(0,q.jsx)(Ht,{intent:i}),O()]});if(S===`WAITING`||S===`RESIZING`)return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(It,{status:b.waitingStatus,caption:r?`Still working — this can take a minute or two.`:`This might take a couple seconds.`}),k(),O()]});if(S===`DONE`)return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(It,{status:`All done!`}),k({allDone:!0})]});if(S===`NOT_APPLICABLE`)return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(It,{status:`Your plan is ready`}),k({allDone:!0,creditsOnly:!0})]});if(S===`STALLED`){let e=g!=null;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(It,{status:e?b.snagStatus:`This is taking longer than expected`,caption:e?nt(g,b.snagCaption,t):`This may take a couple of minutes.`}),k(),e?O(`Retry in the background`):O()]})}return S===`CONFIRM_TIMEOUT`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(It,{status:b.confirmTimeoutStatus,caption:b.confirmTimeoutCaption}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,q.jsx)(n,{variant:`outlined`,"data-testid":`onboarding-go-to-billing`,onClick:_.onGoToBilling,children:`Go to billing`}),(0,q.jsx)(n,{variant:`primary`,"data-testid":`onboarding-retry`,onClick:_.onRetry,children:`Try again`})]})]}):null}}function Wt(e){let{planId:t,targets:n,actuals:r,initialActuals:i,resizeOperationInFlight:a,sawOperation:o,msSinceWatchStart:s,confirmExpired:c,serverVerdict:l=null,statusObservedSinceTargetsMet:u=!0,targetsProveNoop:d=!0}=e;if(t!==`pro`)return{state:c?`CONFIRM_TIMEOUT`:`CONFIRMING`,softWaiting:!1};let f=o||a,p=l===`started`||l===`in_progress`,m=o||d&&u;if(!a){let e=p?m:f||l===`already_done`||i!=null&&!je(n,i);if(je(n,r)){if(e)return{state:`DONE`,softWaiting:!1};if(!p&&(d||l===`not_applicable`))return{state:`NOT_APPLICABLE`,softWaiting:!1}}else{if(l===`already_done`)return{state:`DONE`,softWaiting:!1};if(l===`not_applicable`)return{state:`NOT_APPLICABLE`,softWaiting:!1}}}return s!=null&&s>=9e4?{state:`STALLED`,softWaiting:!1}:f||l===`started`||l===`in_progress`?{state:`RESIZING`,softWaiting:!1}:{state:`WAITING`,softWaiting:s!=null&&s>=3e4}}var Gt=2e3,Kt=1e3,qt=[`DONE`,`NOT_APPLICABLE`,`CONFIRM_TIMEOUT`],Jt={assistantId:null,machine:null,storage:null};function Yt({open:e,canLowerResources:t=!1,verdictRecheckMs:n=Qe}){let r=s(),i=ie(),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(0),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(null),[S,C]=(0,J.useState)(null),[w,T]=(0,J.useState)(null),[E,ee]=(0,J.useState)(Jt),[D,O]=(0,J.useState)(null),[A,j]=(0,J.useState)(!1),M=(0,J.useRef)(!1),te=(0,J.useRef)(!1),N=(0,J.useRef)(0),[ne,re]=(0,J.useState)(!1),[P,F]=(0,J.useState)(null),[I,ae]=(0,J.useState)(null),[oe,le]=(0,J.useState)(null),[ue,de]=(0,J.useState)(()=>Date.now()),[pe,me]=(0,J.useState)(!0);(0,J.useEffect)(()=>{e||(d(!1),p(0),h(null),_(null),y(null),re(!1),F(null),ae(null),le(null),me(!0),x(null),C(null),T(null),ee(Jt),O(null),j(!1),M.current=!1,te.current=!1,N.current+=1)},[e]),(0,J.useEffect)(()=>{e&&(h(Date.now()),r.invalidateQueries({queryKey:L()}),r.invalidateQueries({queryKey:z()}))},[e,r]);let R=g!=null,he=c({...V(),refetchInterval:e=>e.state.data?.plan_id===`pro`||u?!1:Je,refetchIntervalInBackground:!1,enabled:e&&i&&!R}),ge=(m!=null&&he.dataUpdatedAt>=m?he.data?.plan_id:null)??null;(0,J.useEffect)(()=>{if(!e||R||ge!==`pro`)return;let t=Date.now();_(t),de(t)},[e,R,ge]),(0,J.useEffect)(()=>{if(!e||R)return;let t=setTimeout(()=>d(!0),Ye);return()=>clearTimeout(t)},[e,R,f]);let ve=(0,J.useCallback)(()=>{d(!1),p(e=>e+1),k.getState().fetchOrganizations(),r.invalidateQueries({queryKey:L()})},[r]),B=(0,J.useCallback)(()=>{let e=Date.now();y(e),de(e)},[]),{mutate:be}=l(ye()),H=(0,J.useCallback)(e=>{let t=N.current;be({},{onSuccess:n=>{t===N.current&&(O(null),Ne(n)?te.current?O({error:n.reason??`no_active_pro`}):(te.current=!0,j(!0),e===`escape`&&B()):(x(n.state),e===`escape`&&B()))},onError:e=>{t===N.current&&O(e)}})},[be,B]);(0,J.useEffect)(()=>{!e||!i||!R||M.current||(M.current=!0,H(`auto`))},[e,i,R,H]),(0,J.useEffect)(()=>{if(!A)return;let e=N.current,t=setTimeout(()=>{j(!1),e===N.current&&H(`auto`)},Ze);return()=>clearTimeout(t)},[A,H]);let xe=(0,J.useCallback)(()=>H(`escape`),[H]),U=c({...fe(),enabled:e&&i&&R}),Se=pe?Gt:!1,Ce=c({..._e(),enabled:e&&i&&R,refetchInterval:e=>e.state.data?.id==null?Se:!1,retry:!1}),we=R&&m!=null&&U.dataUpdatedAt>=m,Te=we&&!U.isPending&&!U.isFetching,W=(we?U.data?.primary_assistant_id:null)??(U.isPending?null:Ce.data?.id??null),Ee=c({...ce({path:{id:W??`unresolved`}}),enabled:e&&i&&R&&W!=null,refetchInterval:Se,retry:!1}),G=se({path:{id:W??`unresolved`}}),K=c({...G,enabled:e&&i&&R&&W!=null,refetchInterval:Se,retry:!1}),ke=(0,J.useRef)(0),[Ie,Le]=(0,J.useState)(0),q=o(G.queryKey);(0,J.useEffect)(()=>r.getQueryCache().subscribe(t=>{if(!(t.type!==`updated`||t.query.queryHash!==q)){if(t.action.type===`fetch`)ke.current+=1;else if(t.action.type===`success`&&!t.action.manual){let n=ke.current,r=e&&Pe(t.action.data);a.schedule(()=>{Le(n),r&&(re(!0),F(W))})}}}),[r,q,e,W]);let Re=Pe(K.data),ze=P===W,Y=U.data,X=(0,J.useMemo)(()=>Y?{machineSize:De(Y.max_machine_tier),storageGib:Y.selected_storage_gib??null}:null,[Y]),Be=Y!=null&&Y.max_machine_tier==null?Ae:null,Ve=Y?Y.domain_setup_available&&Y.primary_assistant_id!=null:void 0,He=Ee.data,Z=(0,J.useMemo)(()=>He?{machineSize:He.machine_size??null,storageGib:He.provisioned_storage_gib??null}:null,[He]),Q=oe===W,Ue=(0,J.useMemo)(()=>{let e=Fe(X,Z),t=X?.machineSize??Be;if(t==null)return e;let n=Z?.machineSize??null;if(n==null)return{...e,machine:!1};let r=(Q?I?.machineSize:null)??n,i=Oe(t)<Oe(r);return{...e,machine:i?Oe(n)<=Oe(t):Oe(n)>=Oe(t)}},[X,Z,I,Q,Be]),We=je(X,Z),Ge=w===W;(0,J.useEffect)(()=>{e&&(We?(C(e=>e!=null&&Ge?e:Date.now()),T(W)):(C(null),T(null)))},[e,We,W,Ge]);let Ke=E.assistantId===W;(0,J.useEffect)(()=>{if(!e)return;let t=ke.current;ee(e=>{let n=e.assistantId===W?e:Jt,r=Ue.machine?n.machine??t:null,i=Ue.storage?n.storage??t:null;return e.assistantId===W&&e.machine===r&&e.storage===i?e:{assistantId:W,machine:r,storage:i}})},[e,Ue,W]);let qe=(0,J.useMemo)(()=>{let e=Me(K.data),t=e=>e!=null&&Ke&&Ie>e;return{machine:Ue.machine&&!e.machine&&t(E.machine),storage:Ue.storage&&!e.storage&&t(E.storage)}},[Ue,E,Ke,Ie,K.data]);(0,J.useEffect)(()=>{!e||!Z||I!=null&&Q||(ae(Z),le(W))},[e,Z,W,I,Q]);let Xe=v??g,$e=Xe==null?null:Math.max(0,ue-Xe),et=!t,{state:tt,softWaiting:nt}=Wt({planId:R?`pro`:ge,targets:X,actuals:Z,initialActuals:Q?I:null,resizeOperationInFlight:Re,sawOperation:ne&&ze,msSinceWatchStart:$e,confirmExpired:u,serverVerdict:b,statusObservedSinceTargetsMet:S!=null&&Ge&&K.dataUpdatedAt>S,targetsProveNoop:et}),rt=qt.includes(tt),it=e&&R&&!rt;(0,J.useEffect)(()=>{me(it)},[it]),(0,J.useEffect)(()=>{if(!e||!R||rt)return;let t=setInterval(()=>de(Date.now()),Kt);return()=>clearInterval(t)},[e,R,rt]);let at=!et&&(b===`started`||b===`in_progress`)&&!(ne&&ze);return(0,J.useEffect)(()=>{if(!e||!R||rt||!at)return;let t=setInterval(()=>H(`auto`),n);return()=>clearInterval(t)},[e,R,rt,at,n,H]),{state:tt,softWaiting:nt,targets:X,actualsSnapshot:I,machineFloor:Be,landed:qe,assistantId:W,domainStepAvailable:Ve,onboardingSettled:Te,confirmError:!R&&he.isError,targetsError:R&&U.isError&&(!Y||!we),escapeEligible:$e!=null&&$e>=6e4,retryConfirm:ve,kickProvisioning:xe,kickError:D}}var Xt=200,Zt=380;function Qt(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0}var $t=e=>e===`WAITING`||e===`RESIZING`||e===`STALLED`,en=e=>e===`DONE`||e===`NOT_APPLICABLE`,tn={machineSize:null,storageGib:null};function nn({open:e,onClose:t,dwellMs:n,phaseMinMs:r,mode:i=`checkout`,resizeContext:a}){let o=i===`resize`,c=s(),[l,u]=(0,J.useState)(`provisioning`),[d,f]=(0,J.useState)(`idle`),p=(0,J.useRef)([]),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(!1),S=o?a?.direction:void 0,C=We(S),w=Yt({open:e,canLowerResources:o?a?.canLowerResources===!0:!1}),D=(0,J.useRef)(!1);(0,J.useEffect)(()=>{if(e){D.current=!0,h(o?null:ne()),y(e=>e??Date.now());return}p.current.forEach(clearTimeout),p.current=[],u(`provisioning`),f(`idle`),_(null),y(null),x(!1),D.current&&(D.current=!1,te())},[e,o]),(0,J.useEffect)(()=>()=>{p.current.forEach(clearTimeout)},[]),(0,J.useEffect)(()=>{l===`complete`&&re()},[l]);let O=$t(w.state),k=en(g??w.state),{targets:A,assistantId:j,domainStepAvailable:M,onboardingSettled:N}=w,P=o?a?.fromSnapshot:void 0,F=w.actualsSnapshot,I={machineSize:P?.machineSize??F?.machineSize??null,storageGib:P?.storageGib??F?.storageGib??null},{tintHex:ie,backdropImageUrl:ae}=xt(j),oe=o&&M===!0,{domains:se,domainsError:ce,domainsFetching:le,domainsUpdatedAt:ue,domainsErrorUpdatedAt:de}=qe(e&&oe,j),fe=(se?.results.length??0)>0,L=(0,J.useRef)(null);(0,J.useEffect)(()=>{if(!e){L.current=null;return}!oe||j==null||L.current!==j&&(L.current=j,c.invalidateQueries({queryKey:R({path:{assistant_id:j}})}))},[e,oe,j,c]);let pe=!le&&(v!=null&&ue>=v||v!=null&&!!ce&&de>=v),[me,z]=(0,J.useState)(!1),he=N&&(!oe||pe);(0,J.useEffect)(()=>{if(!e){z(!1);return}he&&z(!0)},[e,he]);let ge=(0,J.useCallback)(()=>{let e=o?M===!0&&!fe?`domain`:`complete`:M===!1?`complete`:`domain`;if(Qt()){u(e);return}f(`covering`),p.current.push(setTimeout(()=>{u(e),f(`revealing`),p.current.push(setTimeout(()=>f(`idle`),Zt))},Xt))},[M,o,fe]),_e=(0,J.useCallback)(()=>{x(!0)},[]),ve=(0,J.useCallback)(()=>{w.kickProvisioning(),E.info(w.kickError==null?C.backgroundExitToast:C.backgroundRetryToast),x(!1),t()},[w,t,C]),ye=(0,J.useCallback)(()=>{x(!1)},[]),B=l===`provisioning`&&(w.confirmError||w.targetsError),V=l===`provisioning`&&!B,be=V&&!k,H=`transition-[background-color] duration-300 ease-out${V?` bg-black p-0`:``}`,xe=V?`[animation:fadeIn_0.45s_ease-out_both]`:d===`revealing`?`[animation:fadeInUp_0.42s_ease-out_0.12s_both]`:`[animation:fadeIn_0.25s_ease-out_both]`;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(T.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,q.jsxs)(T.Content,{size:`md`,hideCloseButton:l!==`complete`,dismissOnOverlayClick:!be,onEscapeKeyDown:be?e=>e.preventDefault():void 0,onInteractOutside:be?e=>e.preventDefault():void 0,"data-theme":V?`dark`:void 0,overlayClassName:H,className:V?`overflow-y-auto inset-0 max-w-none w-screen h-screen max-h-none rounded-none border-0`:`overflow-hidden`,style:{[Ct]:ie},children:[(0,q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col motion-reduce:[animation:none] ${xe}`,children:U()},l),d!==`idle`&&(0,q.jsx)(`div`,{"aria-hidden":!0,"data-testid":`takeover-exit-sheet`,className:`pointer-events-none fixed inset-0 z-50 ${d===`covering`?`[animation:fadeIn_200ms_ease-in_both]`:`[animation:fadeIn_380ms_ease-out_both_reverse]`}`,style:{backgroundColor:wt},children:ae&&(0,q.jsx)(mt,{imageUrl:ae,animateIn:!1})})]})}),(0,q.jsx)(ee,{open:b&&O,title:`Continue in the background?`,message:C.backgroundConfirmMessage,confirmLabel:`Continue`,cancelLabel:`Keep waiting`,onConfirm:ve,onCancel:ye})]});function U(){return l===`provisioning`?w.confirmError||w.targetsError?(0,q.jsx)(ot,{onGoToBilling:t,direction:S}):(0,q.jsx)(Ut,{state:w.state,direction:S,softWaiting:w.softWaiting,intent:m,creditsChange:o?a?.credits:void 0,targets:A??tn,fromSnapshot:I,machineFloor:w.machineFloor,landed:w.landed,celebrating:me,onCelebrationEnd:ge,assistantId:j,escapeAvailable:O&&w.escapeEligible,onEscape:_e,onPhaseChange:_,kickError:w.kickError,confirm:{onRetry:w.retryConfirm,onGoToBilling:t},dwellMs:n,phaseMinMs:r}):l===`domain`?(0,q.jsx)(at,{machineBusy:O,assistantId:j,onExit:()=>u(`complete`)}):(0,q.jsx)(Ke,{assistantId:j,direction:S})}}function rn(e){return e!=null&&!e.customized}function an(e){return rn(e)?e.name:`Custom`}var on=[`mighty`,`super`,`ultra`],sn=[`free`,...on];function cn(e){return sn.indexOf(e)}function ln(e,t){if(e===null)return`upgrade`;let n=cn(e),r=cn(t);return n===-1||r===-1?`upgrade`:r===n?`current`:r<n?`downgrade`:`upgrade`}function un(e,t){if(e.length===0)return null;let n=[...e].sort((e,t)=>on.indexOf(e.key)-on.indexOf(t.key));if(!t)return n[0];let r=n.findIndex(e=>e.key===t);return r===-1?n[0]:r>=n.length-1?null:n[r+1]}var dn={free:{bodyShape:`ninja`,eyeStyle:`angry`,color:`yellow`},mighty:{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`},super:{bodyShape:`urchin`,eyeStyle:`goofy`,color:`teal`},ultra:{bodyShape:`sprout`,eyeStyle:`curious`,color:`orange`}};function fn({tier:e,size:t=40}){let n=dn[e]??dn.free,r=W();return(0,q.jsx)(`div`,{"aria-hidden":!0,className:`inline-flex shrink-0`,children:r?(0,q.jsx)(Te,{components:r,bodyShapeId:n.bodyShape,colorId:n.color,size:t}):(0,q.jsx)(`div`,{style:{width:t,height:t}})})}var pn=`Small`;function mn(e){return e?.machine_size?G[e.machine_size]??e.machine_size:pn}function hn(e){let t=e?.credits_usd??0,n=e?.storage_gib??4;return[{icon:Le,label:`${mn(e)} Machine`},{icon:_,label:`${st(t*100)} credits`},{icon:b,label:`${n} GB`}]}function gn(e,t=[]){let n=e?.credits_usd??0,r=e?.storage_gib??4,i=ke[e?.machine_size??`small`];return[`${mn(e)} machine${i?` (${i})`:``}`,lt(r),ut(n),...t]}var _n={machine:`Configurable machine size`,storage:`Configurable storage`,credits:`Pay-as-you-go and bundled credits`};function vn(e,t){let n=[`${e.machineTier?K[e.machineTier]??t.machine_tiers.find(t=>t.tier===e.machineTier)?.label??e.machineTier:pn} Machine`];if(e.storageGib!=null&&n.push(`${e.storageGib} GB`),e.creditTier!=null){let r=gt(t,e.creditTier)?.credits_usd??ht(e.creditTier);n.push(r==null?`Credit bundle`:`${r} credits/mo`)}return n}function yn(e,t){let n=new Set([_n.machine]);return e.storageGib!=null&&n.add(_n.storage),e.creditTier!=null&&n.add(_n.credits),[...vn(e,t),...t.included_features.filter(e=>!n.has(e))]}var bn=`billing-portal-return-snapshot`;function xn(e){try{sessionStorage.removeItem(bn),sessionStorage.setItem(bn,JSON.stringify(e))}catch{}}function Sn(){if(typeof sessionStorage>`u`)return null;try{let e=sessionStorage.getItem(bn);if(!e)return null;let t=JSON.parse(e);return typeof t.cancel_at_period_end!=`boolean`||typeof t.plan_id!=`string`?null:{cancel_at_period_end:t.cancel_at_period_end,cancel_at:t.cancel_at??null,plan_id:t.plan_id}}catch{return null}}function Cn(){try{sessionStorage.removeItem(bn)}catch{}}function wn(e){return e?{cancel_at_period_end:e.cancel_at_period_end,cancel_at:e.cancel_at??null,plan_id:e.plan_id}:null}function Tn(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function En(e){return e?e.cancel_at??e.current_period_end??null:null}function Dn(e){let t=s();return(0,J.useEffect)(()=>oe(()=>{t.invalidateQueries(V())}),[t]),le({onSuccess:t=>{e&&xn(e),ae(t.portal_url)},onError:()=>{E.error(`Couldn't open the billing portal. Please try again.`,{id:`billing-portal-session-error`})}})}function On(e){return e.disabled===!0}function kn({machineTiers:e,storageTiers:t,selectedMachineTier:n,selectedStorageTier:r,onMachineTierChange:i,onStorageTierChange:a,currentMachinePriceCents:o,currentStoragePriceCents:s}){let c=(0,J.useMemo)(()=>e.map(e=>{let t=K[e.tier]??e.label,n=o==null?`+${$(e.price_cents)}`:e.price_cents===o?`(${$(e.price_cents)}, current)`:ct(e.price_cents-o);return{value:e.tier,label:`${t} ${n}`,disabled:On(e)}}),[e,o]),l=(0,J.useMemo)(()=>t.map(e=>{let t=s==null?`+${$(e.price_cents)}`:e.price_cents===s?`(${$(e.price_cents)}, current)`:ct(e.price_cents-s);return{value:e.tier,label:`${e.storage_gib} GB ${t}`,disabled:On(e)}}),[t,s]);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(d,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Machine`}),(0,q.jsx)(`span`,{title:`Determines the CPU and memory allocated to your assistant`,children:(0,q.jsx)(x,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,q.jsx)(D,{"aria-label":`Machine tier`,placeholder:`Select a machine tier`,value:n??``,onChange:i,options:c})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(d,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Storage`}),(0,q.jsx)(`span`,{title:`Persistent disk space for your assistant's files and data`,children:(0,q.jsx)(x,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,q.jsx)(D,{"aria-label":`Storage tier`,placeholder:`Select a storage tier`,value:r??``,onChange:a,options:l})]})]})}var An=new Set([`active`,`trialing`,`past_due`]);function jn(e){return e.plan_id!==`base`&&e.cancel_at_period_end!==!0&&!e.cancel_at&&e.status!=null&&An.has(e.status)}var Mn=[`target_plan_id`,`confirm`,`machine_tier`,`storage_tier`,`credit_tier`,`package`,`non_field_errors`];function Nn(e,t){if(e&&typeof e==`object`){for(let t of Mn)if(t in e){let n=e[t];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(`detail`in e&&typeof e.detail==`string`)return e.detail}return t}function Pn(e,t){let n=e.filter(e=>!On(e));return t!==null&&n.some(e=>e.tier===t)?t:n[0]?.tier??null}function Fn(e,t,n){return t===void 0?n:t!==null&&(t===n||e.some(e=>e.tier===t))?t:null}function In(e){return e.length?Math.min(...e.map(e=>e.price_cents)):0}function Ln(){let e=s(),t=l(me());return{changePackage:async n=>{try{let r=await t.mutateAsync({body:{package:n}});return await Promise.all([e.invalidateQueries({queryKey:L()}),e.invalidateQueries({queryKey:B()}),e.invalidateQueries({queryKey:z()})]),r}catch(e){return E.error(Nn(e,`Failed to change your plan. Please try again.`)),null}},isPending:t.isPending}}function Rn({enabled:e=!0}={}){let t=s(),n=ie(),r=e&&n,i=c({...V(),enabled:r}),a=i.data,o=a!=null&&a.plan_id!==`base`,u=c({...fe(),enabled:r&&o}),d=c({...pe(),enabled:r&&o}).data?.plans.find(e=>e.id===`pro`)?.machine_tiers??[],f=e=>d.find(t=>t.tier===e)?.price_cents??null,p=l(ve()),m=l(ue()),h=l(he()),g={machineTier:u.data?.max_machine_tier??null,storageTier:u.data?.selected_storage_tier??null,storageGib:u.data?.selected_storage_gib??null,creditTier:a?.selected_credit_tier??null},_=a!=null&&a.plan_id!==`base`&&a.status!=null&&An.has(a.status)&&a.cancel_at_period_end!==!0&&!a.cancel_at,v=!o||!u.isPending,y=!o||u.isSuccess&&u.data!=null&&!u.isFetching&&u.dataUpdatedAt>=i.dataUpdatedAt,b=p.isPending||m.isPending||h.isPending,x=()=>Promise.all([t.invalidateQueries({queryKey:L()}),t.invalidateQueries({queryKey:z()}),t.invalidateQueries({queryKey:B()})]);return{changeTiers:async e=>{let t=e.machineTier!==g.machineTier,n=e.storageTier!==g.storageTier,r=e.creditTier!==g.creditTier,i=f(e.machineTier),a=f(g.machineTier),o=t&&i!=null&&a!=null&&i<a,s=[];if(t&&s.push(new Promise(t=>{p.mutate({body:{machine_tier:e.machineTier}},{onSuccess:()=>t({dimension:`machine`,ok:!0}),onError:e=>t({dimension:`machine`,ok:!1,error:e})})})),n&&s.push(new Promise(t=>{m.mutate({body:{storage_tier:e.storageTier}},{onSuccess:()=>t({dimension:`storage`,ok:!0}),onError:e=>t({dimension:`storage`,ok:!1,error:e})})})),r&&s.push(new Promise(t=>{h.mutate({body:{credit_tier:e.creditTier}},{onSuccess:()=>t({dimension:`credit`,ok:!0}),onError:e=>t({dimension:`credit`,ok:!1,error:e})})})),s.length===0)return{needsResize:!1,creditChanged:!1};let c=await Promise.all(s);await x();let l=c.some(e=>e.ok&&e.dimension===`machine`)&&!o,u=c.some(e=>e.ok&&e.dimension===`storage`),d=l||u,_=c.some(e=>e.ok&&e.dimension===`credit`),v=c.filter(e=>!e.ok);if(v.length>0){let e=v.map(e=>Nn(e.error,`Failed to update ${e.dimension} tier.`)).join(` `);return E.error(e),d||_?{needsResize:d,creditChanged:_}:null}return{needsResize:d,creditChanged:_}},isPending:b,current:g,eligible:_,currentReady:v,currentKnown:y,primaryAssistantId:y?u.data?.primary_assistant_id??null:null}}var zn=`__none__`,Bn=`No extra credits`;function Vn(e){let{proPlan:t,seed:n,machineTier:r,storageTier:i,creditChoice:a}=e,o=t.machine_tiers,s=t.storage_tiers,c=t.credit_tiers??[],l=o.find(e=>e.tier===r)??null,u=s.find(e=>e.tier===i)??null,d=a&&a!==`__none__`?c.find(e=>e.tier===a)??null:null,f=n==null?null:o.find(e=>e.tier===n.machineTier)??null,p=n==null?null:s.find(e=>e.tier===n.storageTier)??null,m=n!=null&&n.creditTier!=null?c.find(e=>e.tier===n.creditTier)??null:null,h=n!=null&&n.machineTier!=null&&f==null,g=n!=null&&p==null,_=[{key:`base`,label:`Platform fee: ${$(t.base_price_cents)}`,changed:!1}];if(l!=null){let e=n!=null&&!h&&f?.tier!==l.tier;_.push({key:`machine`,label:l.description,previousLabel:e&&f!=null?f.description:void 0,changed:e})}if(u!=null){let e=n!=null&&!g&&p?.tier!==u.tier;_.push({key:`storage`,label:lt(u.storage_gib),previousLabel:e&&p!=null?lt(p.storage_gib):void 0,changed:e})}let v=a===`__none__`?Bn:d==null?null:ut(d.credits_usd);if(v!=null){let e=n!=null&&(n.creditTier??`__none__`)!==a,t=n?.creditTier==null?Bn:m==null?void 0:ut(m.credits_usd);_.push({key:`credit`,label:v,previousLabel:e?t:void 0,changed:e})}let y=t.base_price_cents+(l?.price_cents??0)+(u?.price_cents??0)+(d?.price_cents??0),b=h||g||n!=null&&n.creditTier!=null&&m==null;if(n==null||b)return{totalCents:y,previousTotalCents:null,deltaCents:null,rows:_};let x=t.base_price_cents+(f?.price_cents??0)+(p?.price_cents??0)+(m?.price_cents??0);return{totalCents:y,previousTotalCents:x,deltaCents:y-x,rows:_}}function Hn(e){return(0,q.jsxs)(`span`,{className:`text-[12px] font-medium text-[var(--content-disabled)]`,children:[`+`,$(e)]})}function Un({open:e,proPlan:t,pending:r,currentStorageGib:i,initialSelection:a,onClose:o,onContinue:s}){let c=e?a??null:null,[l,u]=(0,J.useState)(()=>c?.machineTier??``),[d,f]=(0,J.useState)(()=>c?.storageTier??``),[p,m]=(0,J.useState)(()=>c?c.creditTier??`__none__`:``),[h,v]=(0,J.useState)({open:e,initialSelection:a});(h.open!==e||h.initialSelection!==a)&&(v({open:e,initialSelection:a}),u(c?.machineTier??``),f(c?.storageTier??``),m(c?c.creditTier??`__none__`:``));let x=t.machine_tiers,S=(0,J.useMemo)(()=>t.storage_tiers.filter(e=>!e.legacy||e.tier===a?.storageTier),[t.storage_tiers,a?.storageTier]),C=t.credit_tiers??[],w=(0,J.useMemo)(()=>(t.credit_tiers??[]).filter(e=>!e.legacy),[t.credit_tiers]),E=e=>On(e)||e.legacy&&e.tier!==a?.storageTier||i!=null&&e.storage_gib<i,ee=x.map(e=>({value:e.tier,label:e.description,icon:(0,q.jsx)(Le,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents),disabled:On(e)})),O=S.map(e=>({value:e.tier,label:e.label,icon:(0,q.jsx)(b,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents),disabled:E(e)})),k=p&&p!==`__none__`?C.find(e=>e.tier===p)??null:null,A=k?.legacy?k:null,j=[{value:zn,label:Bn,icon:(0,q.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0})},...w.map(e=>({value:e.tier,label:e.label,icon:(0,q.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents)})),...A?[{value:A.tier,label:A.label,icon:(0,q.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(A.price_cents),disabled:!0}]:[]],M=x.find(e=>e.tier===l)??null,te=d!==``&&d===a?.storageTier,N=S.find(e=>e.tier===d&&(te||!E(e)))??null,ne=p===`__none__`||p===a?.creditTier||w.some(e=>e.tier===p),re=p!==``&&ne?p:null,P=M!=null&&N!=null&&re!=null,F=a!=null&&l===(a.machineTier??``)&&d===a.storageTier&&p===(a.creditTier??`__none__`),I=(0,J.useMemo)(()=>Vn({proPlan:t,seed:a??null,machineTier:l,storageTier:d,creditChoice:p}),[t,a,l,d,p]);return(0,q.jsx)(T.Root,{open:e,onOpenChange:e=>{e||o()},children:(0,q.jsx)(T.Content,{size:`lg`,"data-theme":`light`,hideCloseButton:!0,overlayClassName:`backdrop-blur-[2px]`,className:`max-w-[820px] md:min-h-[min(608px,calc(100vh-4rem))]`,children:(0,q.jsx)(T.Body,{className:`p-4`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-8 md:flex-row md:gap-12`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6 md:flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`div`,{className:`flex shrink-0 items-center justify-center rounded-xl bg-[var(--surface-active)] p-[14px]`,children:(0,q.jsx)(y,{className:`h-6 w-6 text-[var(--content-emphasised)]`,"aria-hidden":!0})}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,q.jsx)(T.Title,{className:`text-[16px] font-medium text-[var(--content-emphasised)]`,children:`Create a custom plan`}),(0,q.jsx)(T.Description,{className:`mt-0 text-[14px] font-medium leading-[18px] text-[var(--content-tertiary)]`,children:`Just better.`})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Select a machine size:`}),(0,q.jsx)(D,{"aria-label":`Machine size`,placeholder:`Select a machine size`,value:l,onChange:u,options:ee})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Select storage:`}),(0,q.jsx)(D,{"aria-label":`Storage`,placeholder:`Select storage`,value:d,onChange:f,options:O})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Bundle some credits:`}),(0,q.jsx)(D,{"aria-label":`Credit bundle`,placeholder:`Select a credit bundle`,value:p,onChange:m,options:j})]})]}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-16 md:pt-[5px]`,children:[(0,q.jsx)(`span`,{className:`text-[16px] font-medium text-[var(--content-emphasised)]`,children:`Recap`}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-[24px] font-medium text-[var(--content-default)]`,children:$(I.totalCents)}),I.deltaCents!=null&&I.deltaCents!==0&&I.previousTotalCents!=null&&(0,q.jsxs)(`span`,{className:`text-[12px] font-medium ${I.deltaCents>0?`text-[var(--system-positive-strong)]`:`text-[var(--system-negative-strong)]`}`,children:[ct(I.deltaCents),` compared to previous (`,st(I.previousTotalCents),`)`]}),(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-tertiary)]`,children:`Total`})]}),(0,q.jsx)(`div`,{className:`h-px w-full bg-[var(--border-hover)]`}),(0,q.jsx)(`span`,{className:`text-[12px] font-medium text-[var(--content-tertiary)]`,children:`Your selection:`}),(0,q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:I.rows.map(e=>(0,q.jsxs)(`li`,{className:`flex flex-col gap-2`,children:[e.previousLabel!=null&&(0,q.jsxs)(`div`,{className:`relative flex w-fit items-start gap-2`,children:[(0,q.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-disabled)]`,"aria-hidden":!0}),(0,q.jsx)(`s`,{className:`text-[14px] font-medium leading-[18px] text-[var(--content-disabled)] no-underline`,children:e.previousLabel}),(0,q.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute -left-1 right-0 top-[9px] h-px bg-[var(--content-disabled)]`})]}),(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0 ${e.changed?`text-[var(--system-positive-strong)]`:`text-[var(--content-secondary)]`}`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-[14px] font-medium leading-[18px] text-[var(--content-secondary)]`,children:e.label})]})]},e.key))}),(0,q.jsx)(n,{variant:`primary`,fullWidth:!0,disabled:!P||F||r,onClick:()=>{!P||F||r||s({machineTier:M.tier,storageTier:N.tier,creditTier:re===`__none__`?null:re})},children:`Continue`}),(0,q.jsx)(n,{variant:`ghost`,fullWidth:!0,disabled:r,onClick:o,children:`Cancel`})]})]})]})})})})}function Wn({className:e,"data-testid":t,children:n}){return(0,q.jsx)(`div`,{"aria-hidden":!0,"data-testid":t,className:U(`flex size-[52px] shrink-0 items-center justify-center rounded-xl`,e),children:n})}var Gn=32;function Kn(){let{ready:e,avatar:t}=xt();return(0,q.jsx)(Wn,{"data-testid":`assistant-avatar-tile`,className:`bg-[var(--surface-active)]`,children:e?(0,q.jsx)(we,{components:t.components,traits:t.traits,customImageUrl:t.customImageUrl,size:Gn}):null})}var qn={free:{tagline:`Get to know your assistant.`,cta:`Start Free`,priceCaption:`Forever`},mighty:{tagline:`More capacity for consistent use.`,cta:`Power Up`,priceCaption:`Billed monthly`,recommended:!0},super:{tagline:`Do more, think less about the how.`,cta:`Go Super`,priceCaption:`Billed monthly`,extraFeatures:[`Assistant email and subdomain`]},ultra:{tagline:`Your second brain, running full speed.`,cta:`Unleash Ultra`,priceCaption:`Billed monthly`,extraFeatures:[`Assistant email and subdomain`]}};function Jn(e){return qn[e]}function Yn(e){return`Downgrade to ${e}`}var Xn=`Billed monthly · prorated difference charged today`,Zn=`Billed monthly · prorated difference charged today or credited next invoice`,Qn=`Billed monthly · prorated credit on your next invoice`,$n=`Your machine downsizes now and your storage stays. No refund.`,er=`Continue`,tr=`The plan includes`,nr=`Your plan will include`;function rr(e,t,n){let r=n?Jn(n)?.tagline??``:``;switch(e){case`downgrade`:return{title:Yn(t),subtitle:``,priceCaption:Qn,checklistHeading:nr,note:$n,confirmLabel:Yn(t),destructive:!0};case`switch`:return{title:`Switch to ${t}`,subtitle:r,priceCaption:Zn,checklistHeading:tr,note:``,confirmLabel:er,destructive:!1};default:return{title:`Upgrade to ${t}`,subtitle:r,priceCaption:Xn,checklistHeading:tr,note:``,confirmLabel:er,destructive:!1}}}function ir({open:e,relation:t,packageName:r,targetPackage:i,pending:a,onCancel:o,onConfirm:s}){let c=(0,J.useRef)(null),l=(0,J.useId)(),u=rr(t,r,i?.key??null),f=i?{price:$(i.total_price_cents),highlights:gn(i,Jn(i.key)?.extraFeatures??[])}:null,p=u.subtitle,m=u.note?{"aria-describedby":l}:p?{}:{"aria-describedby":void 0};return(0,q.jsx)(T.Root,{open:e,onOpenChange:e=>{!e&&!a&&o()},children:(0,q.jsxs)(T.Content,{size:`sm`,hideCloseButton:!0,className:`gap-4 p-4 max-w-[421px]`,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus()},...m,children:[(0,q.jsxs)(T.Header,{className:`flex-row items-center gap-3 p-0 pb-2`,children:[u.destructive?(0,q.jsx)(Wn,{"data-testid":`package-switch-warning-tile`,className:`bg-[var(--system-negative-weak)]`,children:(0,q.jsx)(C,{className:`size-6 text-[var(--system-negative-strong)]`})}):(0,q.jsx)(Kn,{}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,q.jsx)(T.Title,{className:`text-title-small text-[var(--content-emphasised)] [&>span]:whitespace-normal`,children:u.title}),p?(0,q.jsx)(T.Description,{className:`mt-0 text-body-medium-default text-[var(--content-tertiary)]`,children:p}):null]})]}),f?(0,q.jsxs)(T.Body,{className:`flex flex-col gap-4 p-0`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,q.jsx)(d,{as:`p`,variant:`title-large`,className:`text-[var(--content-default)]`,children:f.price}),(0,q.jsx)(d,{as:`p`,variant:`label-medium-default`,className:`leading-[15px] text-[var(--content-tertiary)]`,children:u.priceCaption})]}),(0,q.jsx)(`div`,{className:`h-px w-full bg-[var(--border-hover)]`}),(0,q.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:u.checklistHeading}),(0,q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:f.highlights.map(e=>(0,q.jsxs)(`li`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(g,{className:`size-4 shrink-0 text-[var(--content-secondary)]`,"aria-hidden":!0}),(0,q.jsx)(d,{as:`span`,variant:`body-medium-default`,className:`text-[var(--content-default)]`,children:e})]},e))})]}):null,u.note?(0,q.jsx)(d,{id:l,as:`p`,variant:`body-medium-default`,className:`text-[var(--content-secondary)]`,children:u.note}):null,(0,q.jsxs)(T.Footer,{className:`flex-col gap-4 p-0`,children:[(0,q.jsx)(n,{fullWidth:!0,variant:u.destructive?`danger`:`primary`,onClick:s,disabled:a,"data-testid":`confirm-package-switch-button`,children:u.confirmLabel}),(0,q.jsx)(n,{ref:c,fullWidth:!0,variant:`ghost`,onClick:o,disabled:a,children:`Cancel`})]})]})})}function ar(){let e=s();(0,J.useEffect)(()=>oe(()=>{e.invalidateQueries({queryKey:L()}),e.invalidateQueries({queryKey:B()}),e.invalidateQueries({queryKey:z()})}),[e])}export{ln as A,mn as C,rn as D,on as E,qe as F,Ge as I,Re as L,ct as M,st as N,un as O,$ as P,vn as S,fn as T,Tn as _,Un as a,Dn as b,An as c,In as d,Fn as f,Cn as g,wn as h,Jn as i,nn as j,an as k,Nn as l,kn as m,ir as n,Rn as o,Pn as p,Yn as r,Ln as s,ar as t,jn as u,En as v,hn as w,yn as x,Sn as y};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-fyWSnR9X.js";import{n as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{c as a,g as o,n as s}from"./QueryClientProvider-CMu7CkQU.js";import{t as c}from"./useQuery-Bz-fbQ-m.js";import{t as l}from"./useMutation-CXGTrp4W.js";import{t as u}from"./jsx-runtime-D3ZM-ToX.js";import{t as d}from"./typography-DEI9Ra9z.js";import{t as f}from"./createLucideIcon-CAM1RhH8.js";import{t as p}from"./arrow-right-ChqGeAaW.js";import{t as m}from"./check-Dt2rQhdg.js";import{t as h}from"./circle-alert-DQMH8VJH.js";import{t as g}from"./circle-check-DvrCdroD.js";import{t as _}from"./coins-CcTuNVlN.js";import{n as v,t as y}from"./sliders-horizontal-BwdOIxz8.js";import{t as b}from"./hard-drive-sI2ZzmqM.js";import{t as x}from"./info-DkhVkzmK.js";import{t as S}from"./loader-circle-DWWXcfTQ.js";import{t as C}from"./triangle-alert-D6bAGtMw.js";import{t as w}from"./notice-Dslxs3H6.js";import{t as T}from"./modal-D946-vqt.js";import{n as E}from"./toast-DJj-rM9J.js";import{t as ee}from"./confirm-dialog-Ro8nszbc.js";import{t as D}from"./dropdown-Dj83uU1o.js";import{n as O}from"./resolved-assistants-store-BymuLyDm.js";import{$ as k,Y as A,d as j,f as M,l as te,u as N}from"./auth-store-BZjAJNpH.js";import{S as ne,b as re}from"./native-biometric-Brq7EN1d.js";import{d as P}from"./routes-CAe1h0Db.js";import{f as F}from"./platform-detection-ClZAYwCS.js";import{n as I}from"./use-assistant-avatar-2AaP2LdS.js";import{r as ie}from"./use-is-org-ready-CNHq_yBF.js";import{n as ae,r as oe}from"./browser-COAyWDHw.js";import{C as se,O as ce,Tt as le,at as ue,c as de,ct as fe,dt as L,et as pe,it as me,l as R,lt as z,nt as he,ot as ge,r as _e,rt as ve,st as ye,tt as B,ut as V,y as be}from"./react-query.gen-B0XpEMFg.js";import{t as H}from"./avatar-bundled-components-BvKt7I7O.js";import{r as xe}from"./use-avatar-accent-var-BafXGBXW.js";import{t as U}from"./misc-BBsGq1IU.js";import{n as Se,t as Ce}from"./avatar-tone-BOo-ADtK.js";import{t as we}from"./chat-avatar-B-PiUu6F.js";import{t as Te}from"./avatar-renderer-DIISZw2O.js";import{n as W}from"./use-bundled-avatar-components-8xinhvVj.js";import{t as Ee}from"./android-consumption-only-DVgl1UqJ.js";import{c as De,i as G,l as Oe,n as K,r as ke,t as Ae}from"./machine-sizes-CvnllWMa.js";import{a as je,i as Me,n as Ne,r as Pe,t as Fe}from"./provisioning-targets-BK0r8PFS.js";import{t as Ie}from"./environment-store-CaT6bPjE.js";var Le=f(`computer`,[[`rect`,{width:`14`,height:`8`,x:`5`,y:`2`,rx:`2`,key:`wc9tft`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,key:`w68u3i`}],[`path`,{d:`M6 18h2`,key:`rwmk9e`}],[`path`,{d:`M12 18h6`,key:`aqd8w3`}]]),q=u();function Re({children:e,redirectToBilling:t=!1}){return F()?t?(0,q.jsx)(r,{replace:!0,to:P.settings.usageBilling}):(0,q.jsx)(w,{tone:`info`,children:Ee}):e}var J=e(t(),1);function ze({icon:e}){return(0,q.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-negative-strong) 12%, transparent)`},children:(0,q.jsx)(e,{className:`h-5 w-5`,style:{color:`var(--system-negative-strong)`},"aria-hidden":`true`})})}var Y={fontFamily:`var(--font-serif)`,fontSize:`32px`,fontWeight:400,lineHeight:1.2,letterSpacing:`0.64px`};function X({title:e,subtitle:t}){return(0,q.jsxs)(`header`,{className:`flex flex-col items-center gap-2 pt-12 text-center`,children:[(0,q.jsx)(`h2`,{className:`text-[var(--content-emphasised)]`,style:Y,children:e}),t&&(0,q.jsx)(`p`,{className:`text-[14px] font-normal text-[var(--content-secondary)]`,children:t})]})}var Be=[{bodyShape:`star`,eyeStyle:`curious`,color:`yellow`,size:103,position:`-left-[28px] -top-[33px]`,rotate:180},{bodyShape:`star`,eyeStyle:`curious`,color:`orange`,size:109,position:`left-[63%] -top-[62px] -translate-x-1/2`,rotate:-8},{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`,size:76,position:`-right-[25px] top-[60px]`,rotate:1},{bodyShape:`stack`,eyeStyle:`gentle`,color:`purple`,size:110,position:`-left-[39px] top-[74%]`,rotate:0},{bodyShape:`urchin`,eyeStyle:`goofy`,color:`pink`,size:137,position:`-right-[42px] -bottom-[40px]`,rotate:180},{bodyShape:`sprout`,eyeStyle:`curious`,color:`orange`,size:72,position:`left-[37%] -bottom-[22px] -translate-x-1/2`,rotate:0}],Ve=[{bodyShape:`star`,eyeStyle:`curious`,color:`yellow`,size:103,position:`-left-[28px] -top-[33px]`,rotate:180},{bodyShape:`star`,eyeStyle:`curious`,color:`orange`,size:109,position:`left-[63%] -top-[62px] -translate-x-1/2`,rotate:-8},{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`,size:76,position:`-right-[25px] top-[60px]`,rotate:1}];function He({variant:e=`full`}){let t=W();return t?(0,q.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`creature-corners`,className:`pointer-events-none absolute inset-0 select-none`,children:(e===`top`?Ve:Be).map((e,n)=>(0,q.jsx)(`span`,{className:`absolute ${e.position}`,style:{rotate:`${e.rotate}deg`},children:(0,q.jsx)(Te,{components:t,bodyShapeId:e.bodyShape,eyeStyleId:e.eyeStyle,colorId:e.color,size:e.size})},n))}):null}var Z={waitingStatus:`Upgrading your assistant…`,snagStatus:`We hit a snag upgrading your assistant`,snagCaption:`Retry in the background and we'll keep working on your upgrade.`,confirmingStatus:`Confirming your upgrade…`,confirmTimeoutStatus:`Still confirming your upgrade`,confirmTimeoutCaption:`Your payment went through safely. This can take a minute.`,backgroundConfirmMessage:`Your assistant is still upgrading. Chatting won't be available until it finishes. You can keep waiting here, or continue and we'll let you know when it's ready.`,backgroundExitToast:`Your upgrade continues in the background.`,backgroundRetryToast:`We'll retry your upgrade in the background.`,completeSubtitle:`Enjoy the new found power.`,fetchErrorBody:`We hit a problem checking your subscription. Your upgrade may still be processing. Return to billing to refresh.`},Q={waitingStatus:`Updating your assistant…`,snagStatus:`We hit a snag updating your assistant`,snagCaption:`Retry in the background and we'll keep working on your plan change.`,confirmingStatus:`Confirming your plan change…`,confirmTimeoutStatus:`Still confirming your plan change`,confirmTimeoutCaption:`Your plan change was submitted. This can take a minute.`,backgroundConfirmMessage:`Your assistant is still updating. Chatting won't be available until it finishes. You can keep waiting here, or continue and we'll let you know when it's ready.`,backgroundExitToast:`Your plan change continues in the background.`,backgroundRetryToast:`We'll retry your plan change in the background.`,completeSubtitle:`Your plan changes are live.`,fetchErrorBody:`We hit a problem checking your subscription. Your plan change may still be processing. Return to billing to refresh.`},Ue={upgrade:Z,downgrade:Q,change:Q};function We(e=`upgrade`){return Ue[e]}function Ge(e,t=!0){let{data:n}=c({..._e(),enabled:t&&e==null}),{data:r}=c({...ce({path:{id:e??``}}),enabled:t&&e!=null});return e==null?n:r}function Ke({assistantId:e,direction:t}){let r=i(),a=Ge(e,ie())?.name||`your assistant`;return(0,q.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 pb-16 [animation:onboarding-step-in_350ms_ease-out] motion-reduce:[animation:none]`,children:[(0,q.jsx)(He,{variant:`full`}),(0,q.jsxs)(`div`,{className:`relative flex w-full flex-col items-center`,children:[(0,q.jsx)(X,{title:`You're all set!`,subtitle:We(t).completeSubtitle}),(0,q.jsx)(`div`,{className:`mt-10 flex w-full flex-col items-center gap-10`,children:(0,q.jsxs)(n,{variant:`primary`,"data-testid":`onboarding-complete-return`,onClick:()=>{e!=null&&A(e),r(P.assistant,{replace:!0})},children:[`Return to `,a]})})]})]})}function qe(e=!0,t){let n=Ge(t,e),r=t??n?.id,{data:i,isError:a,isFetching:o,dataUpdatedAt:s,errorUpdatedAt:l}=c({...de({path:{assistant_id:r??``}}),enabled:e&&!!r});return{assistant:n,assistantId:r,domains:i,domainsError:a,domainsFetching:o,domainsUpdatedAt:s,domainsErrorUpdatedAt:l}}var Je=1e3,Ye=1e4,Xe=2500,Ze=2e3,Qe=1e4,$e=[`machine_size`,`subdomain`,`non_field_errors`],et={subdomain_taken:`That subdomain is already taken. Try another.`,assistant_already_has_domain:`Your assistant already has a custom domain.`,no_assistant_to_attach_domain:`We couldn't find an assistant to attach this domain to.`,exceeds_machine_tier:`That machine size isn't available on your plan.`,provisioning_submission_failed:`We couldn't queue your upgrade just now. Try again in a moment.`,no_active_pro:`We couldn't confirm your Pro plan yet. Try again in a moment.`,no_provisionable_assistants:`We couldn't find an assistant to upgrade yet. Try again in a moment.`},tt={provisioning_submission_failed:`We couldn't queue your plan change just now. Try again in a moment.`,no_provisionable_assistants:`We couldn't find an assistant to update yet. Try again in a moment.`};function nt(e,t,n=`upgrade`){if(e&&typeof e==`object`){let t=e;if(typeof t.error==`string`){let e=(n===`upgrade`?void 0:tt[t.error])??et[t.error];if(e)return e}for(let e of $e){let n=t[e];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(typeof t.detail==`string`)return t.detail}return t}var rt=`h-8 rounded-lg border border-[var(--border-element)] bg-[var(--field-bg)] px-2.5 text-[14px] text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none transition-[border-color] duration-150 focus:border-[var(--border-active)] disabled:cursor-not-allowed disabled:opacity-60`,it=`text-[11px] font-medium text-[var(--content-secondary)]`;function at({onExit:e,machineBusy:t=!1,assistantId:r}){let i=s(),a=Ie.use.emailRootDomain(),{assistant:o,assistantId:c,domains:u}=qe(!0,r),d=u?.results[0],[f,p]=(0,J.useState)(``),[m,h]=(0,J.useState)(`hi`),[g,_]=(0,J.useState)(!1);(0,J.useEffect)(()=>{if(!g){if(d){p(d.subdomain),_(!0);return}!o?.handle||f||(p(o.handle),_(!0))}},[o?.handle,d,g,f]);let[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(!1),S=l(ge()),C=!!d||b,E=S.isPending||b;return(0,J.useEffect)(()=>{if(!b)return;let t=setTimeout(e,800);return()=>clearTimeout(t)},[b,e]),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(T.Body,{className:`animate-[onboarding-step-in_350ms_ease-out] space-y-6 pb-0 motion-reduce:animate-none`,children:[(0,q.jsx)(He,{variant:`top`}),(0,q.jsx)(X,{title:`Assistant Email`,subtitle:`Set up an email for your assistant.`}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`label`,{htmlFor:`onboarding-email-prefix`,className:it,children:`Prefix`}),(0,q.jsx)(`input`,{id:`onboarding-email-prefix`,value:m,onChange:e=>h(e.target.value.toLowerCase().trim()),disabled:E||C,readOnly:C,placeholder:`hi`,className:`${rt} w-24`})]}),(0,q.jsx)(`span`,{className:`flex h-8 items-center text-[var(--content-secondary)]`,children:`@`}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,q.jsx)(`label`,{htmlFor:`onboarding-email-handle`,className:it,children:`Handle (public)`}),(0,q.jsx)(`input`,{id:`onboarding-email-handle`,value:f,onChange:e=>{p(e.target.value.toLowerCase().trim()),v&&y(null)},disabled:E||C,readOnly:C,autoFocus:!0,placeholder:`my-assistant`,"aria-invalid":!!v,className:`${rt} w-full min-w-0`})]}),(0,q.jsxs)(`span`,{className:`flex h-8 shrink-0 items-center text-[14px] text-[var(--content-tertiary)]`,children:[`.`,a]})]}),v&&(0,q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:v}),C&&(0,q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`This domain has been set and cannot be changed.`})]}),t&&!C&&(0,q.jsx)(w,{tone:`neutral`,children:`Your assistant is restarting — you can set the domain in a moment.`}),!C&&(0,q.jsx)(w,{tone:`info`,className:`border-transparent bg-[var(--surface-active)]`,children:(0,q.jsx)(`span`,{className:`font-medium text-[var(--content-tertiary)]`,children:`You won't be able to change the handle once set.`})}),b?(0,q.jsx)(w,{tone:`success`,children:`Domain set — redirecting…`}):null]}),(0,q.jsx)(T.Footer,{className:`items-center pt-6`,children:C?(0,q.jsx)(n,{variant:`primary`,"data-testid":`onboarding-domain-continue`,onClick:e,children:`Continue`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(n,{variant:`outlined`,"data-testid":`onboarding-domain-skip`,disabled:E,onClick:()=>{E||S.mutate({body:{skipped:!0}},{onSuccess:e,onError:()=>e()})},children:`Skip`}),(0,q.jsx)(n,{variant:`primary`,"data-testid":`onboarding-domain-set`,disabled:!f||E||t,onClick:()=>{E||t||!f||S.mutate({body:{subdomain:f,...m?{email_username:m}:{}}},{onSuccess:()=>{y(null),x(!0),i.invalidateQueries({queryKey:be()}),i.invalidateQueries({queryKey:R({path:{assistant_id:c??``}})}),i.invalidateQueries({queryKey:z()})},onError:e=>{y(nt(e,`Couldn't register that subdomain. Try a different one.`))}})},children:`Next`})]})})]})}function ot({onGoToBilling:e,direction:t}){return(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-10 text-center`,children:[(0,q.jsx)(ze,{icon:h}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(d,{variant:`title-small`,as:`h1`,children:`Couldn't reach billing`}),(0,q.jsx)(d,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:We(t).fetchErrorBody})]}),(0,q.jsx)(n,{variant:`primary`,"data-testid":`onboarding-go-to-billing`,onClick:e,children:`Go to billing`})]})}function st(e){let t=e/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}function $(e){return`${st(e)}/mo`}function ct(e){return`${e>0?`+`:`−`}${st(Math.abs(e))}/mo`}function lt(e){return`${e} GB storage`}function ut(e){return`${st(e*100)} of bundled credits`}function dt(e){let{targets:t,fromSnapshot:n,machineFloor:r,credits:i}=e,a=[];return t.machineSize==null?r!=null&&n.machineSize!=null&&n.machineSize!==r&&a.push({key:`machine`,label:`Machine`,from:G[n.machineSize],to:G[r]}):n.machineSize!==t.machineSize&&a.push({key:`machine`,label:`Machine`,from:n.machineSize==null?void 0:G[n.machineSize],to:G[t.machineSize]}),t.storageGib!=null&&(n.storageGib==null||t.storageGib>n.storageGib)&&a.push({key:`storage`,label:`Storage`,from:n.storageGib==null?void 0:`${n.storageGib} GB`,to:`${t.storageGib} GB`}),i!=null&&a.push({key:`credits`,label:`Credits`,from:i.from,to:i.to}),a}var ft=60,pt=ft*2;function mt({imageUrl:e,animateIn:t=!0}){return(0,q.jsxs)(`div`,{"aria-hidden":!0,"data-testid":`takeover-backdrop`,className:`pointer-events-none absolute inset-0 overflow-hidden${t?` provision-avatar-reveal`:``}`,children:[(0,q.jsx)(`img`,{src:e,alt:``,decoding:`async`,draggable:!1,className:`absolute left-1/2 top-1/2 max-w-none -translate-x-1/2 -translate-y-1/2 object-cover object-center`,style:{filter:`blur(${ft}px)`,width:`calc(100% + ${pt*2}px)`,height:`calc(100% + ${pt*2}px)`}}),(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/55`})]})}function ht(e){let t=e?.match(/^credits_(\d+)$/)?.[1];return t==null?null:Number(t)}function gt(e,t){if(t!=null)return e?.credit_tiers?.find(e=>e.tier===t)}function _t(e){let t=ie(),{data:n}=c({...pe(),enabled:t&&e});return n?.plans.find(e=>e.id===`pro`)}function vt(e,t){return t==null?0:gt(e,t)?.credits_usd??ht(t)}function yt(e){let t=_t(e!=null);if(e==null||t==null)return null;let n;if(e.kind===`package`){let r=t.packages.find(t=>t.key===e.packageKey);n=r?.credits_usd??gt(t,r?.credit_tier)?.credits_usd}else n=gt(t,e.creditTier)?.credits_usd;return n==null?null:{fromUsd:0,toUsd:n}}function bt(e){let t=_t(e!=null);if(e==null)return null;let n=vt(t,e.fromTier),r=vt(t,e.toTier);return n==null||r==null?null:{fromUsd:n,toUsd:r}}function xt(e){let t=O.use.activeAssistantId(),n=e===void 0?t:e,{components:r,traits:i,customImageUrl:a,isLoading:o}=I(n),s=(0,J.useMemo)(()=>j(),[M()]),c=s!=null&&N(s)?s:null,l=n!=null&&!o,u=c!=null&&(n==null||n===c.assistantId),d=u&&!(l&&(r!=null||i!=null||a!=null))?c:null,f=d?d.components:r,p=d?d.traits:i,m=d?null:a,h=l||u,g=xe(f,p)??(m?null:(f??H).colors?.[0]?.hex??null);return{tintHex:h&&g?Se(g):Ce,backdropImageUrl:h?m:null,ready:h,avatar:{components:f,traits:p,customImageUrl:m}}}function St(e,t){let[n,r]=(0,J.useState)(e),i=(0,J.useRef)(0);return(0,J.useEffect)(()=>{i.current=performance.now()},[]),(0,J.useEffect)(()=>{if(t<=0||e===n)return;let a=t-(performance.now()-i.current);if(a<=0){i.current=performance.now(),r(e);return}let o=setTimeout(()=>{i.current=performance.now(),r(e)},a);return()=>clearTimeout(o)},[e,n,t]),t<=0?e:n}var Ct=`--takeover-surface`,wt=`var(${Ct},${Ce})`,Tt=`color-mix(in srgb, var(--content-emphasised) 10%, transparent)`,Et=240,Dt=1.414,Ot=[{minHeight:680,size:Et},{minHeight:600,size:184}],kt=132;function At(e){for(let t of Ot)if(e>=t.minHeight)return t.size;return kt}function jt(){let[e,t]=(0,J.useState)(()=>At(typeof window>`u`?1/0:window.innerHeight));return(0,J.useEffect)(()=>{let e=()=>t(At(window.innerHeight));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}var Mt={machine:v,storage:b,credits:_},Nt={idle:``,working:` is-working`,settling:` is-settling`,stalled:` is-stalled`,grown:` is-evolved`};function Pt(e,t){return e===`DONE`||e===`NOT_APPLICABLE`?`grown`:e===`STALLED`?`stalled`:e===`WAITING`||e===`RESIZING`?t?`settling`:`working`:`idle`}function Ft({assistantId:e,mode:t,downsizing:n=!1}){let{avatar:r,ready:i}=xt(e),a=W(),o=jt(),s=t===`working`||t===`settling`;return(0,q.jsxs)(`div`,{"aria-hidden":!0,className:`provision-avatar-evolve relative z-10 flex flex-col items-center${Nt[i?t:`idle`]}${n?` is-downsizing`:``}`,style:{"--provision-avatar-size":`${o}px`,"--provision-avatar-growth":Dt},children:[(0,q.jsxs)(`div`,{className:`provision-avatar-stage`,children:[(0,q.jsx)(`div`,{"data-testid":`provision-avatar-placeholder`,className:`provision-avatar-placeholder${i?` is-resolved`:``}`}),(0,q.jsx)(`div`,{className:`provision-avatar-layer`,children:(0,q.jsx)(`div`,{className:`provision-avatar-current`,children:(0,q.jsx)(`div`,{className:`provision-avatar-strain`,children:i&&(0,q.jsx)(`div`,{className:`provision-avatar-reveal`,children:(0,q.jsx)(we,{components:r.components??a,traits:r.traits,customImageUrl:r.customImageUrl,size:o,isAssistantBusy:s})})})})})]}),(0,q.jsx)(`div`,{className:`provision-avatar-shadow`})]})}function It({status:e,caption:t}){return(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,q.jsx)(`h1`,{className:`text-[var(--content-emphasised)]`,style:Y,children:e}),t&&(0,q.jsx)(d,{variant:`body-medium-lighter`,as:`p`,className:`max-w-sm text-[var(--content-secondary)]`,children:t})]})}function Lt({icon:e,label:t,from:n,to:r,done:i=!1,pending:a=!1,testId:o}){let s=null;return i?s=`Complete`:a&&(s=`Pending`),(0,q.jsxs)(`div`,{"data-testid":o,className:`flex min-w-0 flex-auto items-center gap-2 rounded-lg px-2 py-1.5${a?` opacity-70`:``}`,style:{backgroundColor:Tt},children:[(0,q.jsx)(`span`,{className:`hidden h-6 w-6 shrink-0 items-center justify-center min-[420px]:flex`,children:(0,q.jsx)(e,{className:`h-3.5 w-3.5 text-[var(--content-tertiary)]`,"aria-hidden":`true`})}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 text-left wrap-anywhere`,children:[(0,q.jsx)(`span`,{className:`text-[12px] font-medium leading-tight text-[var(--content-tertiary)]`,children:t}),(0,q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-[14px] font-medium leading-[18px] text-[var(--content-emphasised)]`,children:[n&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{children:n}),(0,q.jsx)(`span`,{className:`sr-only`,children:`to`}),(0,q.jsx)(p,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":`true`})]}),(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{children:r}),i?(0,q.jsx)(m,{"data-testid":`chip-check`,className:`h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`,"aria-hidden":`true`}):a&&(0,q.jsx)(S,{"data-testid":`chip-spinner`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-[var(--content-tertiary)] motion-reduce:animate-none`,"aria-hidden":`true`})]}),s&&(0,q.jsx)(`span`,{className:`sr-only`,children:s})]})]})]})}function Rt({label:e}){return(0,q.jsx)(`span`,{className:`rounded-lg px-3 py-2 text-[14px] text-[var(--content-emphasised)]`,style:{backgroundColor:Tt},children:e})}function zt({children:e,wide:t=!1,testId:n}){return(0,q.jsx)(`div`,{"data-testid":n,className:`flex w-full ${t?`max-w-2xl`:`max-w-sm`} items-stretch justify-center gap-2`,children:e})}function Bt(e,t){return e===`credits`?!0:t?.[e]===!0}function Vt({intent:e,creditsChange:t,targets:n,fromSnapshot:r,machineFloor:i,landed:a,allDone:o=!1,creditsOnly:s=!1}){let c=yt(e),l=bt(t),u=c??l,d=dt({targets:n,fromSnapshot:r,machineFloor:i,credits:u==null?null:{from:$(u.fromUsd*100),to:$(u.toUsd*100)}}),f=s?d.filter(e=>e.key===`credits`):d,p=f.filter(e=>o||Bt(e.key,a)).map(e=>e.label).join(`, `),[m]=(0,J.useState)(p),h=p===m?``:`${p} complete`;return f.length===0?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(zt,{testId:`resource-chips`,wide:f.length>=3,children:f.map(e=>{let t=o||Bt(e.key,a);return(0,q.jsx)(Lt,{testId:`chip-${e.key}`,icon:Mt[e.key],label:e.label,from:e.from,to:e.to,done:t,pending:!t},e.key)})}),(0,q.jsx)(`p`,{"aria-live":`polite`,className:`sr-only`,"data-testid":`chip-announcement`,children:h})]})}function Ht({intent:e}){if(e.kind===`package`)return(0,q.jsx)(zt,{children:(0,q.jsx)(Rt,{label:`${e.packageKey.charAt(0).toUpperCase()+e.packageKey.slice(1)} package`})});let t=[e.machineTier,e.storageTier,e.creditTier].filter(e=>e!=null).length;return(0,q.jsxs)(zt,{wide:t>=3,children:[e.machineTier!=null&&(0,q.jsx)(Lt,{icon:v,label:`Machine`,to:K[e.machineTier]??e.machineTier}),e.storageTier!=null&&(0,q.jsx)(Lt,{icon:b,label:`Storage`,to:e.storageTier.toUpperCase()}),e.creditTier!=null&&(0,q.jsx)(Rt,{label:`${e.creditTier.replace(`credits_`,``)} credits`})]})}function Ut({state:e,direction:t,softWaiting:r,intent:i,creditsChange:a,targets:o,fromSnapshot:s,machineFloor:c,landed:l,celebrating:u,onCelebrationEnd:d,assistantId:f,escapeAvailable:p,onEscape:m,onPhaseChange:h,kickError:g,confirm:_,dwellMs:v=Xe,phaseMinMs:y=900}){let b=We(t),x=(0,J.useRef)(d);(0,J.useEffect)(()=>{x.current=d},[d]);let S=St(e,y),C=S===`DONE`||S===`NOT_APPLICABLE`,w=S===`RESIZING`?`WAITING`:S,T=(0,J.useRef)(h);(0,J.useEffect)(()=>{T.current=h},[h]),(0,J.useEffect)(()=>{T.current?.(S)},[S]);let{tintHex:E,backdropImageUrl:ee}=xt(f),D=u&&C;return(0,J.useEffect)(()=>{if(!D)return;let e=setTimeout(()=>x.current(),v);return()=>clearTimeout(e)},[D,v]),(0,q.jsxs)(`div`,{"data-theme":`dark`,className:`provision-surface-settle relative flex h-full min-h-[420px] w-full flex-col items-center [justify-content:safe_center] gap-10 px-6 py-10 text-center`,style:{[Ct]:E,backgroundColor:wt},children:[ee&&(0,q.jsx)(mt,{imageUrl:ee}),(0,q.jsx)(Ft,{assistantId:f,mode:Pt(S,r),downsizing:t===`downgrade`}),(0,q.jsx)(`div`,{className:`relative z-10 flex min-h-[144px] w-full flex-col items-center gap-8 [animation:onboarding-step-in_420ms_ease-out] motion-reduce:[animation:none]`,children:A()},w)]});function O(e=`Continue in the background`){return p?(0,q.jsx)(n,{variant:`ghost`,"data-testid":`provisioning-escape`,onClick:m,children:e}):null}function k({allDone:e=!1,creditsOnly:t=!1}={}){return(0,q.jsx)(Vt,{intent:i,creditsChange:a,targets:o,fromSnapshot:s,machineFloor:c,landed:l,allDone:e,creditsOnly:t})}function A(){if(S===`CONFIRMING`)return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(It,{status:b.confirmingStatus,caption:`This might take a couple seconds.`}),i&&(0,q.jsx)(Ht,{intent:i}),O()]});if(S===`WAITING`||S===`RESIZING`)return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(It,{status:b.waitingStatus,caption:r?`Still working — this can take a minute or two.`:`This might take a couple seconds.`}),k(),O()]});if(S===`DONE`)return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(It,{status:`All done!`}),k({allDone:!0})]});if(S===`NOT_APPLICABLE`)return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(It,{status:`Your plan is ready`}),k({allDone:!0,creditsOnly:!0})]});if(S===`STALLED`){let e=g!=null;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(It,{status:e?b.snagStatus:`This is taking longer than expected`,caption:e?nt(g,b.snagCaption,t):`This may take a couple of minutes.`}),k(),e?O(`Retry in the background`):O()]})}return S===`CONFIRM_TIMEOUT`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(It,{status:b.confirmTimeoutStatus,caption:b.confirmTimeoutCaption}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,q.jsx)(n,{variant:`outlined`,"data-testid":`onboarding-go-to-billing`,onClick:_.onGoToBilling,children:`Go to billing`}),(0,q.jsx)(n,{variant:`primary`,"data-testid":`onboarding-retry`,onClick:_.onRetry,children:`Try again`})]})]}):null}}function Wt(e){let{planId:t,targets:n,actuals:r,initialActuals:i,resizeOperationInFlight:a,sawOperation:o,msSinceWatchStart:s,confirmExpired:c,serverVerdict:l=null,statusObservedSinceTargetsMet:u=!0,targetsProveNoop:d=!0}=e;if(t!==`pro`)return{state:c?`CONFIRM_TIMEOUT`:`CONFIRMING`,softWaiting:!1};let f=o||a,p=l===`started`||l===`in_progress`,m=o||d&&u;if(!a){let e=p?m:f||l===`already_done`||i!=null&&!je(n,i);if(je(n,r)){if(e)return{state:`DONE`,softWaiting:!1};if(!p&&(d||l===`not_applicable`))return{state:`NOT_APPLICABLE`,softWaiting:!1}}else{if(l===`already_done`)return{state:`DONE`,softWaiting:!1};if(l===`not_applicable`)return{state:`NOT_APPLICABLE`,softWaiting:!1}}}return s!=null&&s>=9e4?{state:`STALLED`,softWaiting:!1}:f||l===`started`||l===`in_progress`?{state:`RESIZING`,softWaiting:!1}:{state:`WAITING`,softWaiting:s!=null&&s>=3e4}}var Gt=2e3,Kt=1e3,qt=[`DONE`,`NOT_APPLICABLE`,`CONFIRM_TIMEOUT`],Jt={assistantId:null,machine:null,storage:null};function Yt({open:e,canLowerResources:t=!1,verdictRecheckMs:n=Qe}){let r=s(),i=ie(),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(0),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(null),[S,C]=(0,J.useState)(null),[w,T]=(0,J.useState)(null),[E,ee]=(0,J.useState)(Jt),[D,O]=(0,J.useState)(null),[A,j]=(0,J.useState)(!1),M=(0,J.useRef)(!1),te=(0,J.useRef)(!1),N=(0,J.useRef)(0),[ne,re]=(0,J.useState)(!1),[P,F]=(0,J.useState)(null),[I,ae]=(0,J.useState)(null),[oe,le]=(0,J.useState)(null),[ue,de]=(0,J.useState)(()=>Date.now()),[pe,me]=(0,J.useState)(!0);(0,J.useEffect)(()=>{e||(d(!1),p(0),h(null),_(null),y(null),re(!1),F(null),ae(null),le(null),me(!0),x(null),C(null),T(null),ee(Jt),O(null),j(!1),M.current=!1,te.current=!1,N.current+=1)},[e]),(0,J.useEffect)(()=>{e&&(h(Date.now()),r.invalidateQueries({queryKey:L()}),r.invalidateQueries({queryKey:z()}))},[e,r]);let R=g!=null,he=c({...V(),refetchInterval:e=>e.state.data?.plan_id===`pro`||u?!1:Je,refetchIntervalInBackground:!1,enabled:e&&i&&!R}),ge=(m!=null&&he.dataUpdatedAt>=m?he.data?.plan_id:null)??null;(0,J.useEffect)(()=>{if(!e||R||ge!==`pro`)return;let t=Date.now();_(t),de(t)},[e,R,ge]),(0,J.useEffect)(()=>{if(!e||R)return;let t=setTimeout(()=>d(!0),Ye);return()=>clearTimeout(t)},[e,R,f]);let ve=(0,J.useCallback)(()=>{d(!1),p(e=>e+1),k.getState().fetchOrganizations(),r.invalidateQueries({queryKey:L()})},[r]),B=(0,J.useCallback)(()=>{let e=Date.now();y(e),de(e)},[]),{mutate:be}=l(ye()),H=(0,J.useCallback)(e=>{let t=N.current;be({},{onSuccess:n=>{t===N.current&&(O(null),Ne(n)?te.current?O({error:n.reason??`no_active_pro`}):(te.current=!0,j(!0),e===`escape`&&B()):(x(n.state),e===`escape`&&B()))},onError:e=>{t===N.current&&O(e)}})},[be,B]);(0,J.useEffect)(()=>{!e||!i||!R||M.current||(M.current=!0,H(`auto`))},[e,i,R,H]),(0,J.useEffect)(()=>{if(!A)return;let e=N.current,t=setTimeout(()=>{j(!1),e===N.current&&H(`auto`)},Ze);return()=>clearTimeout(t)},[A,H]);let xe=(0,J.useCallback)(()=>H(`escape`),[H]),U=c({...fe(),enabled:e&&i&&R}),Se=pe?Gt:!1,Ce=c({..._e(),enabled:e&&i&&R,refetchInterval:e=>e.state.data?.id==null?Se:!1,retry:!1}),we=R&&m!=null&&U.dataUpdatedAt>=m,Te=we&&!U.isPending&&!U.isFetching,W=(we?U.data?.primary_assistant_id:null)??(U.isPending?null:Ce.data?.id??null),Ee=c({...ce({path:{id:W??`unresolved`}}),enabled:e&&i&&R&&W!=null,refetchInterval:Se,retry:!1}),G=se({path:{id:W??`unresolved`}}),K=c({...G,enabled:e&&i&&R&&W!=null,refetchInterval:Se,retry:!1}),ke=(0,J.useRef)(0),[Ie,Le]=(0,J.useState)(0),q=o(G.queryKey);(0,J.useEffect)(()=>r.getQueryCache().subscribe(t=>{if(!(t.type!==`updated`||t.query.queryHash!==q)){if(t.action.type===`fetch`)ke.current+=1;else if(t.action.type===`success`&&!t.action.manual){let n=ke.current,r=e&&Pe(t.action.data);a.schedule(()=>{Le(n),r&&(re(!0),F(W))})}}}),[r,q,e,W]);let Re=Pe(K.data),ze=P===W,Y=U.data,X=(0,J.useMemo)(()=>Y?{machineSize:De(Y.max_machine_tier),storageGib:Y.selected_storage_gib??null}:null,[Y]),Be=Y!=null&&Y.max_machine_tier==null?Ae:null,Ve=Y?Y.domain_setup_available&&Y.primary_assistant_id!=null:void 0,He=Ee.data,Z=(0,J.useMemo)(()=>He?{machineSize:He.machine_size??null,storageGib:He.provisioned_storage_gib??null}:null,[He]),Q=oe===W,Ue=(0,J.useMemo)(()=>{let e=Fe(X,Z),t=X?.machineSize??Be;if(t==null)return e;let n=Z?.machineSize??null;if(n==null)return{...e,machine:!1};let r=(Q?I?.machineSize:null)??n,i=Oe(t)<Oe(r);return{...e,machine:i?Oe(n)<=Oe(t):Oe(n)>=Oe(t)}},[X,Z,I,Q,Be]),We=je(X,Z),Ge=w===W;(0,J.useEffect)(()=>{e&&(We?(C(e=>e!=null&&Ge?e:Date.now()),T(W)):(C(null),T(null)))},[e,We,W,Ge]);let Ke=E.assistantId===W;(0,J.useEffect)(()=>{if(!e)return;let t=ke.current;ee(e=>{let n=e.assistantId===W?e:Jt,r=Ue.machine?n.machine??t:null,i=Ue.storage?n.storage??t:null;return e.assistantId===W&&e.machine===r&&e.storage===i?e:{assistantId:W,machine:r,storage:i}})},[e,Ue,W]);let qe=(0,J.useMemo)(()=>{let e=Me(K.data),t=e=>e!=null&&Ke&&Ie>e;return{machine:Ue.machine&&!e.machine&&t(E.machine),storage:Ue.storage&&!e.storage&&t(E.storage)}},[Ue,E,Ke,Ie,K.data]);(0,J.useEffect)(()=>{!e||!Z||I!=null&&Q||(ae(Z),le(W))},[e,Z,W,I,Q]);let Xe=v??g,$e=Xe==null?null:Math.max(0,ue-Xe),et=!t,{state:tt,softWaiting:nt}=Wt({planId:R?`pro`:ge,targets:X,actuals:Z,initialActuals:Q?I:null,resizeOperationInFlight:Re,sawOperation:ne&&ze,msSinceWatchStart:$e,confirmExpired:u,serverVerdict:b,statusObservedSinceTargetsMet:S!=null&&Ge&&K.dataUpdatedAt>S,targetsProveNoop:et}),rt=qt.includes(tt),it=e&&R&&!rt;(0,J.useEffect)(()=>{me(it)},[it]),(0,J.useEffect)(()=>{if(!e||!R||rt)return;let t=setInterval(()=>de(Date.now()),Kt);return()=>clearInterval(t)},[e,R,rt]);let at=!et&&(b===`started`||b===`in_progress`)&&!(ne&&ze);return(0,J.useEffect)(()=>{if(!e||!R||rt||!at)return;let t=setInterval(()=>H(`auto`),n);return()=>clearInterval(t)},[e,R,rt,at,n,H]),{state:tt,softWaiting:nt,targets:X,actualsSnapshot:I,machineFloor:Be,landed:qe,assistantId:W,domainStepAvailable:Ve,onboardingSettled:Te,confirmError:!R&&he.isError,targetsError:R&&U.isError&&(!Y||!we),escapeEligible:$e!=null&&$e>=6e4,retryConfirm:ve,kickProvisioning:xe,kickError:D}}var Xt=200,Zt=380;function Qt(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0}var $t=e=>e===`WAITING`||e===`RESIZING`||e===`STALLED`,en=e=>e===`DONE`||e===`NOT_APPLICABLE`,tn={machineSize:null,storageGib:null};function nn({open:e,onClose:t,dwellMs:n,phaseMinMs:r,mode:i=`checkout`,resizeContext:a}){let o=i===`resize`,c=s(),[l,u]=(0,J.useState)(`provisioning`),[d,f]=(0,J.useState)(`idle`),p=(0,J.useRef)([]),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(!1),S=o?a?.direction:void 0,C=We(S),w=Yt({open:e,canLowerResources:o?a?.canLowerResources===!0:!1}),D=(0,J.useRef)(!1);(0,J.useEffect)(()=>{if(e){D.current=!0,h(o?null:ne()),y(e=>e??Date.now());return}p.current.forEach(clearTimeout),p.current=[],u(`provisioning`),f(`idle`),_(null),y(null),x(!1),D.current&&(D.current=!1,te())},[e,o]),(0,J.useEffect)(()=>()=>{p.current.forEach(clearTimeout)},[]),(0,J.useEffect)(()=>{l===`complete`&&re()},[l]);let O=$t(w.state),k=en(g??w.state),{targets:A,assistantId:j,domainStepAvailable:M,onboardingSettled:N}=w,P=o?a?.fromSnapshot:void 0,F=w.actualsSnapshot,I={machineSize:P?.machineSize??F?.machineSize??null,storageGib:P?.storageGib??F?.storageGib??null},{tintHex:ie,backdropImageUrl:ae}=xt(j),oe=o&&M===!0,{domains:se,domainsError:ce,domainsFetching:le,domainsUpdatedAt:ue,domainsErrorUpdatedAt:de}=qe(e&&oe,j),fe=(se?.results.length??0)>0,L=(0,J.useRef)(null);(0,J.useEffect)(()=>{if(!e){L.current=null;return}!oe||j==null||L.current!==j&&(L.current=j,c.invalidateQueries({queryKey:R({path:{assistant_id:j}})}))},[e,oe,j,c]);let pe=!le&&(v!=null&&ue>=v||v!=null&&!!ce&&de>=v),[me,z]=(0,J.useState)(!1),he=N&&(!oe||pe);(0,J.useEffect)(()=>{if(!e){z(!1);return}he&&z(!0)},[e,he]);let ge=(0,J.useCallback)(()=>{let e=o?M===!0&&!fe?`domain`:`complete`:M===!1?`complete`:`domain`;if(Qt()){u(e);return}f(`covering`),p.current.push(setTimeout(()=>{u(e),f(`revealing`),p.current.push(setTimeout(()=>f(`idle`),Zt))},Xt))},[M,o,fe]),_e=(0,J.useCallback)(()=>{x(!0)},[]),ve=(0,J.useCallback)(()=>{w.kickProvisioning(),E.info(w.kickError==null?C.backgroundExitToast:C.backgroundRetryToast),x(!1),t()},[w,t,C]),ye=(0,J.useCallback)(()=>{x(!1)},[]),B=l===`provisioning`&&(w.confirmError||w.targetsError),V=l===`provisioning`&&!B,be=V&&!k,H=`transition-[background-color] duration-300 ease-out${V?` bg-black p-0`:``}`,xe=V?`[animation:fadeIn_0.45s_ease-out_both]`:d===`revealing`?`[animation:fadeInUp_0.42s_ease-out_0.12s_both]`:`[animation:fadeIn_0.25s_ease-out_both]`;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(T.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,q.jsxs)(T.Content,{size:`md`,hideCloseButton:l!==`complete`,dismissOnOverlayClick:!be,onEscapeKeyDown:be?e=>e.preventDefault():void 0,onInteractOutside:be?e=>e.preventDefault():void 0,"data-theme":V?`dark`:void 0,overlayClassName:H,className:V?`overflow-y-auto inset-0 max-w-none w-screen h-screen max-h-none rounded-none border-0`:`overflow-hidden`,style:{[Ct]:ie},children:[(0,q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col motion-reduce:[animation:none] ${xe}`,children:U()},l),d!==`idle`&&(0,q.jsx)(`div`,{"aria-hidden":!0,"data-testid":`takeover-exit-sheet`,className:`pointer-events-none fixed inset-0 z-50 ${d===`covering`?`[animation:fadeIn_200ms_ease-in_both]`:`[animation:fadeIn_380ms_ease-out_both_reverse]`}`,style:{backgroundColor:wt},children:ae&&(0,q.jsx)(mt,{imageUrl:ae,animateIn:!1})})]})}),(0,q.jsx)(ee,{open:b&&O,title:`Continue in the background?`,message:C.backgroundConfirmMessage,confirmLabel:`Continue`,cancelLabel:`Keep waiting`,onConfirm:ve,onCancel:ye})]});function U(){return l===`provisioning`?w.confirmError||w.targetsError?(0,q.jsx)(ot,{onGoToBilling:t,direction:S}):(0,q.jsx)(Ut,{state:w.state,direction:S,softWaiting:w.softWaiting,intent:m,creditsChange:o?a?.credits:void 0,targets:A??tn,fromSnapshot:I,machineFloor:w.machineFloor,landed:w.landed,celebrating:me,onCelebrationEnd:ge,assistantId:j,escapeAvailable:O&&w.escapeEligible,onEscape:_e,onPhaseChange:_,kickError:w.kickError,confirm:{onRetry:w.retryConfirm,onGoToBilling:t},dwellMs:n,phaseMinMs:r}):l===`domain`?(0,q.jsx)(at,{machineBusy:O,assistantId:j,onExit:()=>u(`complete`)}):(0,q.jsx)(Ke,{assistantId:j,direction:S})}}function rn(e){return e!=null&&!e.customized}function an(e){return rn(e)?e.name:`Custom`}var on=[`mighty`,`super`,`ultra`],sn=[`free`,...on];function cn(e){return sn.indexOf(e)}function ln(e,t){if(e===null)return`upgrade`;let n=cn(e),r=cn(t);return n===-1||r===-1?`upgrade`:r===n?`current`:r<n?`downgrade`:`upgrade`}function un(e,t){if(e.length===0)return null;let n=[...e].sort((e,t)=>on.indexOf(e.key)-on.indexOf(t.key));if(!t)return n[0];let r=n.findIndex(e=>e.key===t);return r===-1?n[0]:r>=n.length-1?null:n[r+1]}var dn={free:{bodyShape:`ninja`,eyeStyle:`angry`,color:`yellow`},mighty:{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`},super:{bodyShape:`urchin`,eyeStyle:`goofy`,color:`teal`},ultra:{bodyShape:`sprout`,eyeStyle:`curious`,color:`orange`}};function fn({tier:e,size:t=40}){let n=dn[e]??dn.free,r=W();return(0,q.jsx)(`div`,{"aria-hidden":!0,className:`inline-flex shrink-0`,children:r?(0,q.jsx)(Te,{components:r,bodyShapeId:n.bodyShape,colorId:n.color,size:t}):(0,q.jsx)(`div`,{style:{width:t,height:t}})})}var pn=`Small`;function mn(e){return e?.machine_size?G[e.machine_size]??e.machine_size:pn}function hn(e){let t=e?.credits_usd??0,n=e?.storage_gib??4;return[{icon:Le,label:`${mn(e)} Machine`},{icon:_,label:`${st(t*100)} credits`},{icon:b,label:`${n} GB`}]}function gn(e,t=[]){let n=e?.credits_usd??0,r=e?.storage_gib??4,i=ke[e?.machine_size??`small`];return[`${mn(e)} machine${i?` (${i})`:``}`,lt(r),ut(n),...t]}var _n={machine:`Configurable machine size`,storage:`Configurable storage`,credits:`Pay-as-you-go and bundled credits`};function vn(e,t){let n=[`${e.machineTier?K[e.machineTier]??t.machine_tiers.find(t=>t.tier===e.machineTier)?.label??e.machineTier:pn} Machine`];if(e.storageGib!=null&&n.push(`${e.storageGib} GB`),e.creditTier!=null){let r=gt(t,e.creditTier)?.credits_usd??ht(e.creditTier);n.push(r==null?`Credit bundle`:`${r} credits/mo`)}return n}function yn(e,t){let n=new Set([_n.machine]);return e.storageGib!=null&&n.add(_n.storage),e.creditTier!=null&&n.add(_n.credits),[...vn(e,t),...t.included_features.filter(e=>!n.has(e))]}var bn=`billing-portal-return-snapshot`;function xn(e){try{sessionStorage.removeItem(bn),sessionStorage.setItem(bn,JSON.stringify(e))}catch{}}function Sn(){if(typeof sessionStorage>`u`)return null;try{let e=sessionStorage.getItem(bn);if(!e)return null;let t=JSON.parse(e);return typeof t.cancel_at_period_end!=`boolean`||typeof t.plan_id!=`string`?null:{cancel_at_period_end:t.cancel_at_period_end,cancel_at:t.cancel_at??null,plan_id:t.plan_id}}catch{return null}}function Cn(){try{sessionStorage.removeItem(bn)}catch{}}function wn(e){return e?{cancel_at_period_end:e.cancel_at_period_end,cancel_at:e.cancel_at??null,plan_id:e.plan_id}:null}function Tn(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function En(e){return e?e.cancel_at??e.current_period_end??null:null}function Dn(e){let t=s();return(0,J.useEffect)(()=>oe(()=>{t.invalidateQueries(V())}),[t]),le({onSuccess:t=>{e&&xn(e),ae(t.portal_url)},onError:()=>{E.error(`Couldn't open the billing portal. Please try again.`,{id:`billing-portal-session-error`})}})}function On(e){return e.disabled===!0}function kn({machineTiers:e,storageTiers:t,selectedMachineTier:n,selectedStorageTier:r,onMachineTierChange:i,onStorageTierChange:a,currentMachinePriceCents:o,currentStoragePriceCents:s}){let c=(0,J.useMemo)(()=>e.map(e=>{let t=K[e.tier]??e.label,n=o==null?`+${$(e.price_cents)}`:e.price_cents===o?`(${$(e.price_cents)}, current)`:ct(e.price_cents-o);return{value:e.tier,label:`${t} ${n}`,disabled:On(e)}}),[e,o]),l=(0,J.useMemo)(()=>t.map(e=>{let t=s==null?`+${$(e.price_cents)}`:e.price_cents===s?`(${$(e.price_cents)}, current)`:ct(e.price_cents-s);return{value:e.tier,label:`${e.storage_gib} GB ${t}`,disabled:On(e)}}),[t,s]);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(d,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Machine`}),(0,q.jsx)(`span`,{title:`Determines the CPU and memory allocated to your assistant`,children:(0,q.jsx)(x,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,q.jsx)(D,{"aria-label":`Machine tier`,placeholder:`Select a machine tier`,value:n??``,onChange:i,options:c})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(d,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Storage`}),(0,q.jsx)(`span`,{title:`Persistent disk space for your assistant's files and data`,children:(0,q.jsx)(x,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,q.jsx)(D,{"aria-label":`Storage tier`,placeholder:`Select a storage tier`,value:r??``,onChange:a,options:l})]})]})}var An=new Set([`active`,`trialing`,`past_due`]);function jn(e){return e.plan_id!==`base`&&e.cancel_at_period_end!==!0&&!e.cancel_at&&e.status!=null&&An.has(e.status)}var Mn=[`target_plan_id`,`confirm`,`machine_tier`,`storage_tier`,`credit_tier`,`package`,`non_field_errors`];function Nn(e,t){if(e&&typeof e==`object`){for(let t of Mn)if(t in e){let n=e[t];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(`detail`in e&&typeof e.detail==`string`)return e.detail}return t}function Pn(e,t){let n=e.filter(e=>!On(e));return t!==null&&n.some(e=>e.tier===t)?t:n[0]?.tier??null}function Fn(e,t,n){return t===void 0?n:t!==null&&(t===n||e.some(e=>e.tier===t))?t:null}function In(e){return e.length?Math.min(...e.map(e=>e.price_cents)):0}function Ln(){let e=s(),t=l(me());return{changePackage:async n=>{try{let r=await t.mutateAsync({body:{package:n}});return await Promise.all([e.invalidateQueries({queryKey:L()}),e.invalidateQueries({queryKey:B()}),e.invalidateQueries({queryKey:z()})]),r}catch(e){return E.error(Nn(e,`Failed to change your plan. Please try again.`)),null}},isPending:t.isPending}}function Rn({enabled:e=!0}={}){let t=s(),n=ie(),r=e&&n,i=c({...V(),enabled:r}),a=i.data,o=a!=null&&a.plan_id!==`base`,u=c({...fe(),enabled:r&&o}),d=c({...pe(),enabled:r&&o}).data?.plans.find(e=>e.id===`pro`)?.machine_tiers??[],f=e=>d.find(t=>t.tier===e)?.price_cents??null,p=l(ve()),m=l(ue()),h=l(he()),g={machineTier:u.data?.max_machine_tier??null,storageTier:u.data?.selected_storage_tier??null,storageGib:u.data?.selected_storage_gib??null,creditTier:a?.selected_credit_tier??null},_=a!=null&&a.plan_id!==`base`&&a.status!=null&&An.has(a.status)&&a.cancel_at_period_end!==!0&&!a.cancel_at,v=!o||!u.isPending,y=!o||u.isSuccess&&u.data!=null&&!u.isFetching&&u.dataUpdatedAt>=i.dataUpdatedAt,b=p.isPending||m.isPending||h.isPending,x=()=>Promise.all([t.invalidateQueries({queryKey:L()}),t.invalidateQueries({queryKey:z()}),t.invalidateQueries({queryKey:B()})]);return{changeTiers:async e=>{let t=e.machineTier!==g.machineTier,n=e.storageTier!==g.storageTier,r=e.creditTier!==g.creditTier,i=f(e.machineTier),a=f(g.machineTier),o=t&&i!=null&&a!=null&&i<a,s=[];if(t&&s.push(new Promise(t=>{p.mutate({body:{machine_tier:e.machineTier}},{onSuccess:()=>t({dimension:`machine`,ok:!0}),onError:e=>t({dimension:`machine`,ok:!1,error:e})})})),n&&s.push(new Promise(t=>{m.mutate({body:{storage_tier:e.storageTier}},{onSuccess:()=>t({dimension:`storage`,ok:!0}),onError:e=>t({dimension:`storage`,ok:!1,error:e})})})),r&&s.push(new Promise(t=>{h.mutate({body:{credit_tier:e.creditTier}},{onSuccess:()=>t({dimension:`credit`,ok:!0}),onError:e=>t({dimension:`credit`,ok:!1,error:e})})})),s.length===0)return{needsResize:!1,creditChanged:!1};let c=await Promise.all(s);await x();let l=c.some(e=>e.ok&&e.dimension===`machine`)&&!o,u=c.some(e=>e.ok&&e.dimension===`storage`),d=l||u,_=c.some(e=>e.ok&&e.dimension===`credit`),v=c.filter(e=>!e.ok);if(v.length>0){let e=v.map(e=>Nn(e.error,`Failed to update ${e.dimension} tier.`)).join(` `);return E.error(e),d||_?{needsResize:d,creditChanged:_}:null}return{needsResize:d,creditChanged:_}},isPending:b,current:g,eligible:_,currentReady:v,currentKnown:y,primaryAssistantId:y?u.data?.primary_assistant_id??null:null}}var zn=`__none__`,Bn=`No extra credits`;function Vn(e){let{proPlan:t,seed:n,machineTier:r,storageTier:i,creditChoice:a}=e,o=t.machine_tiers,s=t.storage_tiers,c=t.credit_tiers??[],l=o.find(e=>e.tier===r)??null,u=s.find(e=>e.tier===i)??null,d=a&&a!==`__none__`?c.find(e=>e.tier===a)??null:null,f=n==null?null:o.find(e=>e.tier===n.machineTier)??null,p=n==null?null:s.find(e=>e.tier===n.storageTier)??null,m=n!=null&&n.creditTier!=null?c.find(e=>e.tier===n.creditTier)??null:null,h=n!=null&&n.machineTier!=null&&f==null,g=n!=null&&p==null,_=[{key:`base`,label:`Platform fee: ${$(t.base_price_cents)}`,changed:!1}];if(l!=null){let e=n!=null&&!h&&f?.tier!==l.tier;_.push({key:`machine`,label:l.description,previousLabel:e&&f!=null?f.description:void 0,changed:e})}if(u!=null){let e=n!=null&&!g&&p?.tier!==u.tier;_.push({key:`storage`,label:lt(u.storage_gib),previousLabel:e&&p!=null?lt(p.storage_gib):void 0,changed:e})}let v=a===`__none__`?Bn:d==null?null:ut(d.credits_usd);if(v!=null){let e=n!=null&&(n.creditTier??`__none__`)!==a,t=n?.creditTier==null?Bn:m==null?void 0:ut(m.credits_usd);_.push({key:`credit`,label:v,previousLabel:e?t:void 0,changed:e})}let y=t.base_price_cents+(l?.price_cents??0)+(u?.price_cents??0)+(d?.price_cents??0),b=h||g||n!=null&&n.creditTier!=null&&m==null;if(n==null||b)return{totalCents:y,previousTotalCents:null,deltaCents:null,rows:_};let x=t.base_price_cents+(f?.price_cents??0)+(p?.price_cents??0)+(m?.price_cents??0);return{totalCents:y,previousTotalCents:x,deltaCents:y-x,rows:_}}function Hn(e){return(0,q.jsxs)(`span`,{className:`text-[12px] font-medium text-[var(--content-disabled)]`,children:[`+`,$(e)]})}function Un({open:e,proPlan:t,pending:r,currentStorageGib:i,initialSelection:a,onClose:o,onContinue:s}){let c=e?a??null:null,[l,u]=(0,J.useState)(()=>c?.machineTier??``),[d,f]=(0,J.useState)(()=>c?.storageTier??``),[p,m]=(0,J.useState)(()=>c?c.creditTier??`__none__`:``),[h,v]=(0,J.useState)({open:e,initialSelection:a});(h.open!==e||h.initialSelection!==a)&&(v({open:e,initialSelection:a}),u(c?.machineTier??``),f(c?.storageTier??``),m(c?c.creditTier??`__none__`:``));let x=t.machine_tiers,S=(0,J.useMemo)(()=>t.storage_tiers.filter(e=>!e.legacy||e.tier===a?.storageTier),[t.storage_tiers,a?.storageTier]),C=t.credit_tiers??[],w=(0,J.useMemo)(()=>(t.credit_tiers??[]).filter(e=>!e.legacy),[t.credit_tiers]),E=e=>On(e)||e.legacy&&e.tier!==a?.storageTier||i!=null&&e.storage_gib<i,ee=x.map(e=>({value:e.tier,label:e.description,icon:(0,q.jsx)(Le,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents),disabled:On(e)})),O=S.map(e=>({value:e.tier,label:e.label,icon:(0,q.jsx)(b,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents),disabled:E(e)})),k=p&&p!==`__none__`?C.find(e=>e.tier===p)??null:null,A=k?.legacy?k:null,j=[{value:zn,label:Bn,icon:(0,q.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0})},...w.map(e=>({value:e.tier,label:e.label,icon:(0,q.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents)})),...A?[{value:A.tier,label:A.label,icon:(0,q.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(A.price_cents),disabled:!0}]:[]],M=x.find(e=>e.tier===l)??null,te=d!==``&&d===a?.storageTier,N=S.find(e=>e.tier===d&&(te||!E(e)))??null,ne=p===`__none__`||p===a?.creditTier||w.some(e=>e.tier===p),re=p!==``&&ne?p:null,P=M!=null&&N!=null&&re!=null,F=a!=null&&l===(a.machineTier??``)&&d===a.storageTier&&p===(a.creditTier??`__none__`),I=(0,J.useMemo)(()=>Vn({proPlan:t,seed:a??null,machineTier:l,storageTier:d,creditChoice:p}),[t,a,l,d,p]);return(0,q.jsx)(T.Root,{open:e,onOpenChange:e=>{e||o()},children:(0,q.jsx)(T.Content,{size:`lg`,"data-theme":`light`,hideCloseButton:!0,overlayClassName:`backdrop-blur-[2px]`,className:`max-w-[820px] md:min-h-[min(608px,calc(100vh-4rem))]`,children:(0,q.jsx)(T.Body,{className:`p-4`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-8 md:flex-row md:gap-12`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6 md:flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`div`,{className:`flex shrink-0 items-center justify-center rounded-xl bg-[var(--surface-active)] p-[14px]`,children:(0,q.jsx)(y,{className:`h-6 w-6 text-[var(--content-emphasised)]`,"aria-hidden":!0})}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,q.jsx)(T.Title,{className:`text-[16px] font-medium text-[var(--content-emphasised)]`,children:`Create a custom plan`}),(0,q.jsx)(T.Description,{className:`mt-0 text-[14px] font-medium leading-[18px] text-[var(--content-tertiary)]`,children:`Just better.`})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Select a machine size:`}),(0,q.jsx)(D,{"aria-label":`Machine size`,placeholder:`Select a machine size`,value:l,onChange:u,options:ee})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Select storage:`}),(0,q.jsx)(D,{"aria-label":`Storage`,placeholder:`Select storage`,value:d,onChange:f,options:O})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Bundle some credits:`}),(0,q.jsx)(D,{"aria-label":`Credit bundle`,placeholder:`Select a credit bundle`,value:p,onChange:m,options:j})]})]}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-16 md:pt-[5px]`,children:[(0,q.jsx)(`span`,{className:`text-[16px] font-medium text-[var(--content-emphasised)]`,children:`Recap`}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-[24px] font-medium text-[var(--content-default)]`,children:$(I.totalCents)}),I.deltaCents!=null&&I.deltaCents!==0&&I.previousTotalCents!=null&&(0,q.jsxs)(`span`,{className:`text-[12px] font-medium ${I.deltaCents>0?`text-[var(--system-positive-strong)]`:`text-[var(--system-negative-strong)]`}`,children:[ct(I.deltaCents),` compared to previous (`,st(I.previousTotalCents),`)`]}),(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-tertiary)]`,children:`Total`})]}),(0,q.jsx)(`div`,{className:`h-px w-full bg-[var(--border-hover)]`}),(0,q.jsx)(`span`,{className:`text-[12px] font-medium text-[var(--content-tertiary)]`,children:`Your selection:`}),(0,q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:I.rows.map(e=>(0,q.jsxs)(`li`,{className:`flex flex-col gap-2`,children:[e.previousLabel!=null&&(0,q.jsxs)(`div`,{className:`relative flex w-fit items-start gap-2`,children:[(0,q.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-disabled)]`,"aria-hidden":!0}),(0,q.jsx)(`s`,{className:`text-[14px] font-medium leading-[18px] text-[var(--content-disabled)] no-underline`,children:e.previousLabel}),(0,q.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute -left-1 right-0 top-[9px] h-px bg-[var(--content-disabled)]`})]}),(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0 ${e.changed?`text-[var(--system-positive-strong)]`:`text-[var(--content-secondary)]`}`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-[14px] font-medium leading-[18px] text-[var(--content-secondary)]`,children:e.label})]})]},e.key))}),(0,q.jsx)(n,{variant:`primary`,fullWidth:!0,disabled:!P||F||r,onClick:()=>{!P||F||r||s({machineTier:M.tier,storageTier:N.tier,creditTier:re===`__none__`?null:re})},children:`Continue`}),(0,q.jsx)(n,{variant:`ghost`,fullWidth:!0,disabled:r,onClick:o,children:`Cancel`})]})]})]})})})})}function Wn({className:e,"data-testid":t,children:n}){return(0,q.jsx)(`div`,{"aria-hidden":!0,"data-testid":t,className:U(`flex size-[52px] shrink-0 items-center justify-center rounded-xl`,e),children:n})}var Gn=32;function Kn(){let{ready:e,avatar:t}=xt();return(0,q.jsx)(Wn,{"data-testid":`assistant-avatar-tile`,className:`bg-[var(--surface-active)]`,children:e?(0,q.jsx)(we,{components:t.components,traits:t.traits,customImageUrl:t.customImageUrl,size:Gn}):null})}var qn={free:{tagline:`Get to know your assistant.`,cta:`Start Free`,priceCaption:`Forever`},mighty:{tagline:`More capacity for consistent use.`,cta:`Power Up`,priceCaption:`Billed monthly`,recommended:!0},super:{tagline:`Do more, think less about the how.`,cta:`Go Super`,priceCaption:`Billed monthly`,extraFeatures:[`Assistant email and subdomain`]},ultra:{tagline:`Your second brain, running full speed.`,cta:`Unleash Ultra`,priceCaption:`Billed monthly`,extraFeatures:[`Assistant email and subdomain`]}};function Jn(e){return qn[e]}function Yn(e){return`Downgrade to ${e}`}var Xn=`Billed monthly · prorated difference charged today`,Zn=`Billed monthly · prorated difference charged today or credited next invoice`,Qn=`Billed monthly · prorated credit on your next invoice`,$n=`Your machine downsizes now and your storage stays. No refund.`,er=`Continue`,tr=`The plan includes`,nr=`Your plan will include`;function rr(e,t,n){let r=n?Jn(n)?.tagline??``:``;switch(e){case`downgrade`:return{title:Yn(t),subtitle:``,priceCaption:Qn,checklistHeading:nr,note:$n,confirmLabel:Yn(t),destructive:!0};case`switch`:return{title:`Switch to ${t}`,subtitle:r,priceCaption:Zn,checklistHeading:tr,note:``,confirmLabel:er,destructive:!1};default:return{title:`Upgrade to ${t}`,subtitle:r,priceCaption:Xn,checklistHeading:tr,note:``,confirmLabel:er,destructive:!1}}}function ir({open:e,relation:t,packageName:r,targetPackage:i,pending:a,onCancel:o,onConfirm:s}){let c=(0,J.useRef)(null),l=(0,J.useId)(),u=rr(t,r,i?.key??null),f=i?{price:$(i.total_price_cents),highlights:gn(i,Jn(i.key)?.extraFeatures??[])}:null,p=u.subtitle,m=u.note?{"aria-describedby":l}:p?{}:{"aria-describedby":void 0};return(0,q.jsx)(T.Root,{open:e,onOpenChange:e=>{!e&&!a&&o()},children:(0,q.jsxs)(T.Content,{size:`sm`,hideCloseButton:!0,className:`gap-4 p-4 max-w-[421px]`,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus()},...m,children:[(0,q.jsxs)(T.Header,{className:`flex-row items-center gap-3 p-0 pb-2`,children:[u.destructive?(0,q.jsx)(Wn,{"data-testid":`package-switch-warning-tile`,className:`bg-[var(--system-negative-weak)]`,children:(0,q.jsx)(C,{className:`size-6 text-[var(--system-negative-strong)]`})}):(0,q.jsx)(Kn,{}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,q.jsx)(T.Title,{className:`text-title-small text-[var(--content-emphasised)] [&>span]:whitespace-normal`,children:u.title}),p?(0,q.jsx)(T.Description,{className:`mt-0 text-body-medium-default text-[var(--content-tertiary)]`,children:p}):null]})]}),f?(0,q.jsxs)(T.Body,{className:`flex flex-col gap-4 p-0`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,q.jsx)(d,{as:`p`,variant:`title-large`,className:`text-[var(--content-default)]`,children:f.price}),(0,q.jsx)(d,{as:`p`,variant:`label-medium-default`,className:`leading-[15px] text-[var(--content-tertiary)]`,children:u.priceCaption})]}),(0,q.jsx)(`div`,{className:`h-px w-full bg-[var(--border-hover)]`}),(0,q.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:u.checklistHeading}),(0,q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:f.highlights.map(e=>(0,q.jsxs)(`li`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(g,{className:`size-4 shrink-0 text-[var(--content-secondary)]`,"aria-hidden":!0}),(0,q.jsx)(d,{as:`span`,variant:`body-medium-default`,className:`text-[var(--content-default)]`,children:e})]},e))})]}):null,u.note?(0,q.jsx)(d,{id:l,as:`p`,variant:`body-medium-default`,className:`text-[var(--content-secondary)]`,children:u.note}):null,(0,q.jsxs)(T.Footer,{className:`flex-col gap-4 p-0`,children:[(0,q.jsx)(n,{fullWidth:!0,variant:u.destructive?`danger`:`primary`,onClick:s,disabled:a,"data-testid":`confirm-package-switch-button`,children:u.confirmLabel}),(0,q.jsx)(n,{ref:c,fullWidth:!0,variant:`ghost`,onClick:o,disabled:a,children:`Cancel`})]})]})})}function ar(){let e=s();(0,J.useEffect)(()=>oe(()=>{e.invalidateQueries({queryKey:L()}),e.invalidateQueries({queryKey:B()}),e.invalidateQueries({queryKey:z()})}),[e])}export{ln as A,mn as C,rn as D,on as E,qe as F,Ge as I,Re as L,ct as M,st as N,un as O,$ as P,vn as S,fn as T,Tn as _,Un as a,Dn as b,An as c,In as d,Fn as f,Cn as g,wn as h,Jn as i,nn as j,an as k,Nn as l,kn as m,ir as n,Rn as o,Pn as p,Yn as r,Ln as s,ar as t,jn as u,En as v,hn as w,yn as x,Sn as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{n}from"./QueryClientProvider-CMu7CkQU.js";import{t as r}from"./useQuery-Bz-fbQ-m.js";import{t as i}from"./createLucideIcon-CAM1RhH8.js";import{t as a}from"./calendar-qrPKlf1H.js";import{t as o}from"./globe-CdLn4IX7.js";import{t as s}from"./layout-grid-Ct4RT2Ea.js";import{t as c}from"./message-square-CHUvAEY9.js";import{t as l}from"./monitor-RX4oi4Nj.js";import{t as u}from"./settings-6_RIT4kT.js";import{n as d,t as f}from"./create-selectors-CEbfsat6.js";import{Z as p,_ as m,i as h,p as g}from"./local-mode-BR8wpdXp.js";import{t as _}from"./is-electron-DLs5KNwr.js";import{n as v}from"./resolved-assistants-store-BymuLyDm.js";import{i as y}from"./utils-CGftFn10.js";import{a as b,n as x}from"./api-errors-37rFaJd8.js";import{X as S,ct as C,rt as w,tt as T}from"./auth-store-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{n}from"./QueryClientProvider-CMu7CkQU.js";import{t as r}from"./useQuery-Bz-fbQ-m.js";import{t as i}from"./createLucideIcon-CAM1RhH8.js";import{t as a}from"./calendar-qrPKlf1H.js";import{t as o}from"./globe-CdLn4IX7.js";import{t as s}from"./layout-grid-Ct4RT2Ea.js";import{t as c}from"./message-square-CHUvAEY9.js";import{t as l}from"./monitor-RX4oi4Nj.js";import{t as u}from"./settings-6_RIT4kT.js";import{n as d,t as f}from"./create-selectors-CEbfsat6.js";import{Z as p,_ as m,i as h,p as g}from"./local-mode-BR8wpdXp.js";import{t as _}from"./is-electron-DLs5KNwr.js";import{n as v}from"./resolved-assistants-store-BymuLyDm.js";import{i as y}from"./utils-CGftFn10.js";import{a as b,n as x}from"./api-errors-37rFaJd8.js";import{X as S,ct as C,rt as w,tt as T}from"./auth-store-BZjAJNpH.js";import{nt as E}from"./sdk.gen-DKp2Mbw9.js";import{ar as D}from"./sdk.gen-qwmaWHuE.js";import{a as O,i as k,r as A}from"./feature-flag-catalog-Ccklc1QS.js";import{t as j}from"./client-feature-flag-store-D52k_a_E.js";import{d as M}from"./routes-CAe1h0Db.js";import{i as ee,r as N}from"./use-is-org-ready-CNHq_yBF.js";import{t as P}from"./haptics-CWVeK4vK.js";import{F}from"./react-query.gen-B0XpEMFg.js";import{s as te}from"./chat-Dy2BC2i1.js";var I=i(`contact`,[[`path`,{d:`M16 2v2`,key:`scm5qe`}],[`path`,{d:`M7 22v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2`,key:`1waht3`}],[`path`,{d:`M8 2v2`,key:`pbkmx`}],[`circle`,{cx:`12`,cy:`11`,r:`3`,key:`itu57m`}],[`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`,key:`12vinp`}]]),L=i(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),R=e(t(),1);function z({sessionStatus:e,hasPlatformSession:t}){let r=n(),i=N(),a=w(e)&&!p()&&(t||!g())&&i;v.use.assistants();let o=S(),s=o&&!h().some(e=>e.assistantId===o)?o:null,{data:c}=C({enabled:a,selectedPlatformAssistantId:s});(0,R.useEffect)(()=>{T.setInputs({sessionStatus:e,hasPlatformSession:t,queryClient:r,selectedPlatformAssistantId:s,isOrgReady:i}),T.respondToInputs()},[e,t,r,s,i]),(0,R.useEffect)(()=>{c&&T.applyServerResult(c)},[c])}var B=`0.8.5`,V=5e3,H=6e4;function U(e,t=!0){return y(B)&&t?{staleTime:e,refetchInterval:!1}:{staleTime:V,refetchInterval:V}}function W(){return U(H)}function G(e){return U(1/0,e)}var K=new Set(Object.keys(A)),q=new Set(Object.keys(k));async function J(e){let t=j.getState().scopeKey,{data:n,error:r,response:i}=await E({throwOnError:!1,signal:e});if(x(i,r,`Failed to fetch client feature flags`),!i.ok||!n)throw b(r,i);return{scopeKey:t,flags:n.flags}}function Y(e){let t={},n={};for(let[r,i]of Object.entries(e)){let e=O(r);typeof i==`boolean`&&K.has(e)?t[e]=i:typeof i==`string`&&q.has(e)&&(n[e]=i)}return{boolFlags:t,stringFlags:n}}function X(e,t=!1){let n=G(t),i=ee(),a=j.use.scopeKey(),o=e&&!m(),s=o&&i===`ready`,{data:c,isError:l}=r({queryKey:F(),queryFn:({signal:e})=>J(e),enabled:s,...n,refetchOnWindowFocus:!1,refetchOnReconnect:!1});(0,R.useEffect)(()=>{if(c?.flags){let{boolFlags:e,stringFlags:t}=Y(c.flags),n=j.getState();n.setFlags(e,c.scopeKey),Object.keys(t).length>0&&n.setStringFlags(t,c.scopeKey);return}e&&(!o||i===`unavailable`||l)&&j.getState().settleWithoutServerValues(a)},[a,c,e,l,o,i])}var Z=f(d((e,t)=>({isOpen:!1,open:()=>e({isOpen:!0}),close:()=>e({isOpen:!1}),toggle:()=>e({isOpen:!t().isOpen})})));async function ne(){if(!_())return!1;let e=window.vellum?.commandPalette?.open;return e?(await e(),!0):!1}async function re(){_()&&await window.vellum?.commandPalette?.dismiss()}async function ie(e){_()&&await window.vellum?.commandPalette?.select(e)}var Q={query:``,queryTokens:[],results:{conversations:[],memories:[],schedules:[],contacts:[]}};function ae(e,t){return e||t.split(/\s+/).filter(e=>e.length>0)}async function oe(e,t,n){let r=n?.limit??10;try{let{data:i,response:a}=await D({path:{assistant_id:e},query:{q:t,limit:r,categories:`conversations,schedules,contacts`},throwOnError:!1,signal:n?.signal});return!a?.ok||!i?Q:{query:i.query,queryTokens:ae(i.queryTokens,i.query),results:i.results}}catch(n){return n instanceof DOMException&&n.name===`AbortError`||console.error(`[global-search] search failed`,{assistantId:e,query:t,err:n}),Q}}var se=150,ce=2,$=[];function le({itemCount:e,onSelect:t,assistantId:n,isOpen:r,onClose:i}){let a=Z.use.isOpen(),o=r??a,s=Z.use.open(),c=Z.use.close(),[l,u]=(0,R.useState)(``),[d,f]=(0,R.useState)(0),[p,m]=(0,R.useState)(!1),[h,g]=(0,R.useState)(null),[_,v]=(0,R.useState)($),y=(0,R.useRef)(()=>0);(0,R.useLayoutEffect)(()=>{y.current=typeof e==`function`?e:()=>e});let b=(0,R.useRef)(null),x=(0,R.useRef)(null),S=(0,R.useCallback)(()=>{b.current&&=(clearTimeout(b.current),null),x.current?.abort(),x.current=null},[]),C=(0,R.useCallback)(()=>{s(),f(0)},[s]),w=(0,R.useCallback)(()=>{c(),u(``),f(0),m(!1),g(null),v($),S(),i?.()},[c,S,i]),T=(0,R.useCallback)(()=>{o?w():C()},[o,w,C]);(0,R.useEffect)(()=>{o||(u(``),f(0),m(!1),g(null),v($),S())},[o,S]);let E=(0,R.useCallback)(e=>{S();let t=e.trim();if(t.length<ce||!n){m(!1),g(null),v($);return}m(!0),b.current=setTimeout(()=>{if(!n){m(!1);return}let e=new AbortController;x.current=e,oe(n,t,{signal:e.signal}).then(t=>{x.current===e&&(g(t.results),v(t.queryTokens),m(!1))}).catch(()=>{x.current===e&&m(!1)})},se)},[S,n]),D=(0,R.useCallback)(e=>{u(e),f(0),E(e)},[E]);return(0,R.useEffect)(()=>()=>{x.current?.abort(),b.current&&clearTimeout(b.current)},[]),{isOpen:o,query:l,selectedIndex:d,isSearching:p,searchResults:h,searchTokens:_,open:C,close:w,toggle:T,setQuery:D,handleKeyDown:(0,R.useCallback)(e=>{if(e.key===`k`&&(e.metaKey||e.ctrlKey)){e.preventDefault(),w();return}let n=y.current();switch(e.key){case`ArrowDown`:e.preventDefault(),n>0&&f(e=>Math.min(e+1,n-1));break;case`ArrowUp`:e.preventDefault(),f(e=>Math.max(e-1,0));break;case`Enter`:e.preventDefault(),n>0&&t?.(d);break;case`Escape`:e.preventDefault(),w();break}},[t,d,w])}}function ue(e){return{id:`actions`,label:`Actions`,items:[{id:`action-new-conversation`,icon:L,title:`New Conversation`,shortcutHint:_()?`⌘N`:`⌘⇧O`},{id:`action-current-conversation`,icon:l,title:`Current Conversation`,shortcutHint:`⌘⇧N`},{id:`action-settings`,icon:u,title:`Settings`,shortcutHint:`⌘,`},{id:`action-library`,icon:s,title:`Library`},{id:`action-intelligence`,icon:o,title:e}]}}function de(e,t){let n=[],r=e.conversations.filter(e=>!t.has(e.id)).map(e=>({id:`search-conv-${e.id}`,icon:c,title:e.title??`Untitled`,snippet:e.excerpt||void 0}));r.length>0&&n.push({id:`search-conversations`,label:`Conversations`,items:r});let i=e.schedules.map(e=>({id:`search-schedule-${e.id}`,icon:a,title:e.name,subtitle:e.expression??e.message}));i.length>0&&n.push({id:`search-schedules`,label:`Schedules`,items:i});let o=e.contacts.map(e=>({id:`search-contact-${e.id}`,icon:I,title:e.displayName,subtitle:e.notes??void 0}));return o.length>0&&n.push({id:`search-contacts`,label:`Contacts`,items:o}),n}function fe(e){return{id:`conversations`,label:`Recent`,items:e.slice(0,5).map(e=>({id:`conv-${e.conversationId}`,icon:c,title:e.title??`Untitled`,subtitle:e.lastMessageAt?te(e.lastMessageAt):void 0}))}}function pe(e,t){switch(e.id){case`action-new-conversation`:t.startNewConversation();break;case`action-current-conversation`:P.light(),t.navigate(M.assistant);break;case`action-settings`:P.light(),t.navigateToSettings();break;case`action-intelligence`:P.light(),t.navigate(M.identity);break;case`action-library`:P.light(),t.navigate(M.library.root);break;default:if(e.id.startsWith(`conv-`)){let n=e.id.slice(5);t.switchConversation(n)}else if(e.id.startsWith(`search-conv-`)){let n=e.id.slice(12);t.switchConversation(n)}else e.id.startsWith(`search-schedule-`)?(P.light(),t.navigate(M.schedules.detail(e.id.slice(16)))):e.id.startsWith(`search-contact-`)&&(P.light(),t.navigate(M.identity));break}}function me({assistantId:e,assistantName:t,conversations:n,activeConversationId:r,startNewConversation:i,switchConversation:a,navigate:o,navigateToSettings:s,isOpen:c,onClose:l,onItemSelect:u}){let d=(0,R.useMemo)(()=>{let e=ue(t??`Assistant`),r=fe(n);return[e,...r.items.length>0?[r]:[]]},[n,t]),f=(0,R.useMemo)(()=>new Set(n.slice(0,5).map(e=>e.conversationId)),[n]),p=(0,R.useCallback)(e=>{if(u){u(e);return}pe(e,{startNewConversation:i,switchConversation:a,navigate:o,activeConversationId:r,navigateToSettings:s})},[i,a,o,r,s,u]),m=(0,R.useRef)([]),h=(0,R.useRef)(()=>{}),g=le({itemCount:()=>m.current.reduce((e,t)=>e+t.items.length,0),onSelect:(0,R.useCallback)(e=>{let t=e;for(let e of m.current){if(t<e.items.length){let n=e.items[t];p(n),h.current();return}t-=e.items.length}},[p]),assistantId:e,isOpen:c,onClose:l});(0,R.useLayoutEffect)(()=>{h.current=g.close});let _=(0,R.useMemo)(()=>{if(!g.query.trim())return d;let e=g.query.toLowerCase().trim();return d.map(t=>({...t,items:t.items.filter(t=>t.title.toLowerCase().includes(e))})).filter(e=>e.items.length>0)},[d,g.query]),v=(0,R.useMemo)(()=>{let e=g.searchResults?de(g.searchResults,f):[];return[..._,...e]},[_,g.searchResults,f]);return(0,R.useLayoutEffect)(()=>{m.current=v}),{commandPalette:g,mergedSections:v,handleItemSelect:(0,R.useCallback)(e=>{p(e),h.current()},[p])}}export{Z as a,z as c,ie as i,L as l,re as n,X as o,ne as r,W as s,me as t,I as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./haptics-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./haptics-CWVeK4vK.js";import{t as r}from"./pointer-CQ4DXHXb.js";var i=e(t(),1),a=.5,o=100,s=.3,c=.7,l=10,u=.3;function d(e){return Math.min(o,e*s)}function f(e){return e*a}function p(e){return e instanceof Element?e.closest(`input, textarea, select, [contenteditable]:not([contenteditable="false"]), [data-message-text]`)!==null:!1}function m(e,t,n){return!(e>f(t)||n&&e>20)}function h(e,t){return Math.abs(t)>Math.abs(e)*c}function g(e,t){return Math.abs(e)<l&&Math.abs(t)<l?`pending`:h(e,t)||e<=0?`cancel`:`confirm`}function _(e,t){return e<=t?e:t+(e-t)*u}function v(e,t){return Math.min(0,e-t)}function y(e,t){return e>=t}function b(e,t){for(let n=0;n<e.length;n+=1){let r=e[n];if(r&&r.identifier===t)return r}return null}function x({enabled:e,onConfirm:t,onMove:a,onCommit:o,onCancel:s}){let c=(0,i.useRef)(null),l=(0,i.useRef)(e),u=(0,i.useRef)({onConfirm:t,onMove:a,onCommit:o,onCancel:s});(0,i.useLayoutEffect)(()=>{l.current=e,u.current={onConfirm:t,onMove:a,onCommit:o,onCancel:s}}),(0,i.useEffect)(()=>{if(!r())return;let e=()=>d(window.innerWidth),t=e=>{c.current=null,u.current.onCancel(e)},i=e=>{if(!l.current||c.current||e.touches.length!==1)return;let t=e.touches[0];t&&m(t.clientX,window.innerWidth,p(e.target))&&(c.current={touchId:t.identifier,startX:t.clientX,startY:t.clientY,confirmed:!1,hasFiredHaptic:!1})},a=r=>{let i=c.current;if(!i)return;if(r.touches.length>1){t(!1);return}let a=b(r.touches,i.touchId);if(!a)return;let o=a.clientX-i.startX,s=a.clientY-i.startY;if(!i.confirmed){let e=g(o,s);if(e===`pending`)return;if(e===`cancel`){t(!1);return}i.confirmed=!0,u.current.onConfirm?.()}let l=e();if(h(o,s)&&o<l){t(!0);return}o>=l&&!i.hasFiredHaptic&&(i.hasFiredHaptic=!0,n.light()),u.current.onMove(o,l,a.clientX)},o=n=>{let r=c.current;if(!r)return;let i=b(n.changedTouches,r.touchId),a=i?i.clientX-r.startX:0,o=e();r.confirmed&&y(a,o)?(c.current=null,u.current.onCommit(a,o)):r.confirmed?t(!0):t(!1)},s=()=>{t(c.current?.confirmed??!1)};return document.addEventListener(`touchstart`,i,{passive:!0}),document.addEventListener(`touchmove`,a,{passive:!0}),document.addEventListener(`touchend`,o,{passive:!0}),document.addEventListener(`touchcancel`,s,{passive:!0}),()=>{c.current=null,document.removeEventListener(`touchstart`,i),document.removeEventListener(`touchmove`,a),document.removeEventListener(`touchend`,o),document.removeEventListener(`touchcancel`,s)}},[])}export{_ as n,x as r,v as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{n,r}from"./use-edge-swipe-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{n,r}from"./use-edge-swipe-Cy1q_g93.js";import{t as i}from"./edge-swipe-arbiter-store-Bc5Sp7hi.js";var a=e(t(),1),o=200,s=180,c=200,l=.25,u=50;function d(e){e.style.transition=``,e.style.transform=``,e.style.willChange=``,e.style.opacity=``}function f({containerRef:e,onBack:t,enabled:f,navKey:p}){let m=(0,a.useRef)(t);(0,a.useLayoutEffect)(()=>{m.current=t},[t]);let h=(0,a.useRef)(!1),g=(0,a.useRef)(new Set),_=(0,a.useRef)(!1),v=i.use.registerBackOwner(),y=i.use.unregisterBackOwner();(0,a.useEffect)(()=>{if(f)return v(),y},[f,v,y]),(0,a.useEffect)(()=>{_.current=!1;let t=g.current;return()=>{_.current=!0;for(let e of t)clearTimeout(e);t.clear();let n=e.current;n&&d(n)}},[e]);let b=(e,t)=>{let n=setTimeout(()=>{g.current.delete(n),_.current||e()},t);g.current.add(n)},x=(e,t)=>{e.style.transform=t===0?``:`translateX(${t}px)`},S=e=>{e.style.transition=`transform ${o}ms ease-out`,x(e,0);let t=()=>{e.removeEventListener(`transitionend`,t),d(e)};e.addEventListener(`transitionend`,t,{once:!0}),b(()=>d(e),o+u)},C=e=>{e.style.transition=`transform ${s}ms ease-in`,x(e,window.innerWidth);let t=!1,n=()=>{if(t||_.current)return;t=!0,e.removeEventListener(`transitionend`,n);let r=-(window.innerWidth*l);e.style.transition=`none`,e.style.transform=`translateX(${r}px)`,e.style.opacity=`0`,e.offsetWidth,h.current=!0,m.current(),b(()=>{h.current&&(h.current=!1,d(e))},c*2)};e.addEventListener(`transitionend`,n,{once:!0}),b(n,s+u)};r({enabled:f,onConfirm:()=>{let t=e.current;t&&(t.style.transition=`none`,t.style.willChange=`transform`)},onMove:(t,r)=>{let i=e.current;i&&x(i,n(t,r))},onCommit:()=>{let t=e.current;if(!t){m.current();return}C(t)},onCancel:t=>{let n=e.current;n&&(t?S(n):d(n))}}),(0,a.useLayoutEffect)(()=>{if(!h.current)return;h.current=!1;let t=e.current;if(!t)return;let n=!1,r=()=>{n||(n=!0,t.removeEventListener(`transitionend`,r),d(t))};t.style.transition=`transform ${c}ms ease-out, opacity ${c}ms ease-out`,t.style.transform=``,t.style.opacity=``,t.addEventListener(`transitionend`,r,{once:!0});let i=setTimeout(r,c+u);return()=>{clearTimeout(i),t.removeEventListener(`transitionend`,r),d(t)}},[p,e])}export{f as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-fyWSnR9X.js";import{l as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as a}from"./jsx-runtime-D3ZM-ToX.js";import{t as o}from"./typography-DEI9Ra9z.js";import{t as s}from"./createLucideIcon-CAM1RhH8.js";import{t as c}from"./chevron-up-DofScvyy.js";import{t as l}from"./menu-D7gzADvH.js";import{I as u,N as d}from"./src-ly8ixpHd.js";import{t as f}from"./globe-CdLn4IX7.js";import{t as p}from"./loader-circle-DWWXcfTQ.js";import{n as m,t as h}from"./minimize-2-Dj9FY4aF.js";import{t as g}from"./pencil-Cm5DdeRM.js";import{t as _}from"./x-D4O9yIS7.js";import{n as v}from"./resolved-assistants-store-BymuLyDm.js";import{t as y}from"./client.gen-CV05d-kw.js";import{n as b}from"./event-bus-DYZhc6yM.js";import{d as x}from"./routes-CAe1h0Db.js";import{t as S}from"./conversation-store-DAowsv-z.js";import{i as C}from"./viewer-store-CGDw5Wtf.js";import{n as w}from"./use-is-mobile-MmHo-OM6.js";import{t as T}from"./misc-BBsGq1IU.js";import{r as E,t as D}from"./edit-chat-session-DJ2tzvAz.js";import{n as O,t as k}from"./sandbox-bridge-TDSWydru.js";var A=s(`expand`,[[`path`,{d:`m15 15 6 6`,key:`1s409w`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}],[`path`,{d:`M3 16v5h5`,key:`1t08am`}],[`path`,{d:`m3 21 6-6`,key:`wwnumi`}],[`path`,{d:`M3 8V3h5`,key:`1ln10m`}],[`path`,{d:`M9 9 3 3`,key:`v551iv`}]]),j=s(`share`,[[`path`,{d:`M12 2v13`,key:`1km8f5`}],[`path`,{d:`m16 6-4-4-4 4`,key:`13yo43`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}]]),M=a(),N=e(t(),1),P=`flags.toggleAppsSandboxDisabled`,F=!1,I=new Set;function L(){return F}function R(e){let t=e===void 0?!F:e===!0;if(t===F)return console.info(`[vellumDebug] ${P}: already ${String(t)}.`),F;F=t,t?console.warn(`[vellumDebug] ${P} = true: app iframes render without the sandbox attribute. App HTML runs same-origin with the host and can reach its DOM, storage, and cookies. Open apps reload to pick this up. Call it again, or reload the page, to restore the sandbox.`):console.info(`[vellumDebug] ${P} = false: app iframes are sandboxed again.`);for(let e of I)e();return F}function z(e){return I.add(e),()=>{I.delete(e)}}function B(){return(0,N.useSyncExternalStore)(z,L,()=>!1)}function V({appName:e,onEdit:t,isEditing:r,onShare:i,isSharing:a,onDeploy:s,isDeploying:l,onToggleFullscreen:u,onClose:d}){let h=w(),v=h&&r===!0&&t!=null,y=i!=null&&s!=null;return(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-t-xl bg-[var(--surface-lift)] px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`hidden md:flex items-center min-w-[72px]`,children:t!=null&&(r?(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(A,{}),onClick:t,tooltip:`Expand app`,"aria-label":`Expand app`}):(0,M.jsx)(n,{onClick:t,children:`Edit`}))}),(0,M.jsx)(o,{variant:`body-large-default`,className:T(`flex-1 truncate text-left md:text-center text-[var(--content-emphasised)]`,v&&`cursor-pointer`),style:{lineHeight:1.4},onClick:v?t:void 0,children:e}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-[72px] justify-end`,children:[y?(0,M.jsx)(H,{onShare:i,isSharing:a,onDeploy:s,isDeploying:l,isMobile:h}):(0,M.jsxs)(M.Fragment,{children:[s!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:l?(0,M.jsx)(p,{className:`animate-spin`}):(0,M.jsx)(f,{}),onClick:s,disabled:l,tooltip:l?`Deploying…`:`Deploy`,"aria-label":l?`Deploying…`:`Deploy`}),i!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:a?(0,M.jsx)(p,{className:`animate-spin`}):(0,M.jsx)(j,{}),onClick:i,disabled:a,tooltip:a?`Sharing…`:`Share`,"aria-label":a?`Sharing…`:`Share`})]}),u!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(m,{}),onClick:u,tooltip:`Fullscreen`,"aria-label":`Fullscreen`}),t!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:r?(0,M.jsx)(c,{}):(0,M.jsx)(g,{}),onClick:t,tooltip:r?`Open app`:`Edit`,"aria-label":r?`Open app`:`Edit`,active:r,className:`md:hidden`}),(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(_,{}),onClick:d,tooltip:`Close`,"aria-label":`Close`})]})]})}function H({onShare:e,isSharing:t,onDeploy:r,isDeploying:i,isMobile:a}){let[o,s]=(0,N.useState)(!1),c=t||i,m=c?(0,M.jsx)(p,{className:`animate-spin`}):(0,M.jsx)(j,{}),h=t?`Sharing…`:i?`Deploying…`:`Share & deploy`;return a?(0,M.jsxs)(u.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(u.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:m,disabled:c,tooltip:h,"aria-label":h})}),(0,M.jsxs)(u.Content,{"aria-describedby":void 0,children:[(0,M.jsx)(u.Header,{className:`sr-only`,children:(0,M.jsx)(u.Title,{children:`Share & deploy`})}),(0,M.jsxs)(u.Body,{className:`pt-0`,children:[(0,M.jsx)(d,{icon:j,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Share`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Export as .vellum file`})]}),onSelect:()=>{s(!1),e()}}),(0,M.jsx)(d,{icon:f,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Deploy to Vercel`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Publish as a static page`})]}),onSelect:()=>{s(!1),r()}})]})]})]}):(0,M.jsxs)(l.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(l.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:m,disabled:c,tooltip:h,"aria-label":h})}),(0,M.jsxs)(l.Content,{align:`end`,sideOffset:4,children:[(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(j,{size:14}),onSelect:()=>e(),className:`whitespace-nowrap`,children:`Share`}),(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(f,{size:14}),onSelect:()=>r(),className:`whitespace-nowrap`,children:`Deploy to Vercel`})]})]})}var U=[`assistant:`,`conversation:`,`conversations:`,`apps:`,`plugins:`,`feature-flags:`];function W(e){return U.some(t=>e.startsWith(t))}function G(e,t){if(e.length===0)return[];let n=new Set(e);return t.filter(e=>n.has(e)&&!W(e))}function K(e,t){let{frameId:n,assistantId:r,appId:i,enabled:a=!0,onAction:o,onOpenVellumLink:s}=t,c=(0,N.useRef)(new Map);(0,N.useEffect)(()=>{let t=c.current,l=async c=>{let l=c.data;if(!l||l.frameId!==n||c.source!==e.current?.contentWindow)return;if(l.type===`vellum_subscribe`){if(!a)return;let{subId:e,tags:n}=l;typeof e==`string`&&Array.isArray(n)&&t.set(e,new Set(n.filter(e=>typeof e==`string`)));return}if(l.type===`vellum_unsubscribe`){let{subId:e}=l;typeof e==`string`&&t.delete(e);return}if(l.type===`vellum_surface_action`){o?.(l.actionId,l.data);return}if(l.type===`vellum_open_link`){if(!navigator.userActivation?.isActive)return;s?.(l.href,l.linkText);return}if(l.type===`vellum_asset_request`){let{callId:t,path:n}=l,o=e.current,s=(e,t)=>{o?.contentWindow?.postMessage(e,`*`,t??[])};if(!a){s({type:`vellum_asset_response`,callId:t,error:`Asset proxy disabled`});return}if(!i){s({type:`vellum_asset_response`,callId:t,error:`No app context for assets`});return}if(typeof n!=`string`||n===``||n.includes(`..`)){s({type:`vellum_asset_response`,callId:t,error:`Invalid asset path`});return}try{let e=`/v1/assistants/${r}/apps/${i}/asset/${n.split(`/`).map(encodeURIComponent).join(`/`)}`,{data:a,response:o}=await y.get({url:e,parseAs:`blob`,throwOnError:!1});if(!o?.ok||!(a instanceof Blob)){s({type:`vellum_asset_response`,callId:t,error:`Asset fetch failed (${o?.status??0})`});return}let c=await a.arrayBuffer();s({type:`vellum_asset_response`,callId:t,buffer:c,contentType:a.type||`application/octet-stream`},[c])}catch(e){s({type:`vellum_asset_response`,callId:t,error:e instanceof Error?e.message:`Asset proxy error`})}return}if(!a||l.type!==`vellum_fetch_request`)return;let{callId:u,path:d,method:f,headers:p,body:m}=l,h=e.current,g=e=>{h?.contentWindow?.postMessage(e,`*`)};if(!k.test(d)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: only /v1/x/ custom routes are allowed`});return}try{let e=new URL(d,`https://placeholder`).pathname;if(!k.test(e)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: path traversal detected`});return}}catch{g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: invalid path`});return}let _=`/v1/assistants/${r}/${d.replace(/^\/v1\//,``)}`;try{let e={url:_,throwOnError:!1,headers:p&&Object.keys(p).length>0?p:void 0,body:m?JSON.parse(m):void 0},t=await(f===`POST`?y.post:f===`PUT`?y.put:f===`PATCH`?y.patch:f===`DELETE`?y.delete:y.get)(e),n=t.response,r=t.data??t.error,i=r==null?``:typeof r==`string`?r:JSON.stringify(r);g({type:`vellum_fetch_response`,callId:u,status:n?.status??0,statusText:n?.statusText??``,body:i})}catch(e){g({type:`vellum_fetch_response`,callId:u,error:e instanceof Error?e.message:`Fetch proxy error`})}};window.addEventListener(`message`,l);let u=b(`sse.event`,r=>{let i=r.message;if(!i||i.type!==`sync_changed`||!Array.isArray(i.tags))return;let a=e.current?.contentWindow;if(!a||t.size===0)return;let o=i.tags.filter(e=>typeof e==`string`);for(let[e,r]of t){let t=G([...r],o);t.length>0&&a.postMessage({type:`vellum_event`,frameId:n,subId:e,event:{type:`sync_changed`,tags:t}},`*`)}});return()=>{window.removeEventListener(`message`,l),u()}},[n,r,i,a,o,s,e])}var q=`allow-scripts allow-popups allow-popups-to-escape-sandbox`;function J({appId:e,appName:t,html:r,assistantId:i,onClose:a,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,route:f,enableFullscreen:p=!1,onAction:m}){let g=(0,N.useRef)(null),[_,v]=(0,N.useState)(!1),y=(0,N.useCallback)(()=>v(e=>!e),[]);(0,N.useEffect)(()=>{v(!1)},[e]),(0,N.useEffect)(()=>{if(!_)return;let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),v(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_]);let b=(0,N.useMemo)(()=>O(r,e,{fetch:!0,route:f}),[r,e,f]),x=B(),S=(0,N.useMemo)(()=>{let t=0;for(let e=0;e<r.length;e++)t=(t<<5)-t+r.charCodeAt(e)|0;return`app-${e}-${t}${x?`-nosandbox`:``}`},[r,e,x]);return K(g,{frameId:e,assistantId:i,appId:e,onAction:m}),(0,M.jsxs)(`div`,{"data-testid":`app-viewer-root`,className:T(`flex flex-col overflow-hidden bg-[var(--surface-base)]`,_?`fixed inset-0 z-[60]`:`h-full rounded-xl`),children:[!_&&(0,M.jsx)(V,{appName:t,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,onToggleFullscreen:p?y:void 0,onClose:a}),(0,M.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[_&&(0,M.jsx)(`div`,{className:`absolute z-10`,style:{top:`max(0.75rem, var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,right:`max(0.75rem, var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))`},children:(0,M.jsx)(n,{variant:`primary`,iconOnly:(0,M.jsx)(h,{}),onClick:y,tooltip:`Exit fullscreen`})}),(0,M.jsx)(`iframe`,{ref:g,srcDoc:b,sandbox:x?void 0:q,referrerPolicy:`no-referrer`,title:t,className:`h-full w-full border-none`},S)]})]})}function Y(){let e=v.use.activeAssistantId(),t=w(),n=i(),{pathname:a}=r();return(0,N.useCallback)(r=>{if(!e)return;let i=D(e,r.appId)??crypto.randomUUID();E(e,r.appId,i);let o=C.getState();(o.activeAppId!==r.appId||!o.openedAppState)&&(o.openApp(r.appId),o.setLoadedApp(r)),S.getState().setEditingConversationId(i),t?o.minimizeApp():o.enterAppEditing();let s=x.conversation(i);a!==s&&n(s)},[e,t,n,a])}export{j as a,R as i,J as n,K as r,Y as t};
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-fyWSnR9X.js";import{l as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as a}from"./jsx-runtime-D3ZM-ToX.js";import{t as o}from"./typography-DEI9Ra9z.js";import{t as s}from"./createLucideIcon-CAM1RhH8.js";import{t as c}from"./chevron-up-DofScvyy.js";import{t as l}from"./menu-D7gzADvH.js";import{I as u,N as d}from"./src-ly8ixpHd.js";import{t as f}from"./globe-CdLn4IX7.js";import{t as p}from"./loader-circle-DWWXcfTQ.js";import{n as m,t as h}from"./minimize-2-Dj9FY4aF.js";import{t as g}from"./pencil-Cm5DdeRM.js";import{t as _}from"./x-D4O9yIS7.js";import{n as v}from"./resolved-assistants-store-BymuLyDm.js";import{t as y}from"./client.gen-CV05d-kw.js";import{n as b}from"./event-bus-DYZhc6yM.js";import{d as x}from"./routes-CAe1h0Db.js";import{t as S}from"./conversation-store-DAowsv-z.js";import{i as C}from"./viewer-store-C-Uj2CzB.js";import{n as w}from"./use-is-mobile-MmHo-OM6.js";import{t as T}from"./misc-BBsGq1IU.js";import{r as E,t as D}from"./edit-chat-session-DJ2tzvAz.js";import{n as O,t as k}from"./sandbox-bridge-TDSWydru.js";var A=s(`expand`,[[`path`,{d:`m15 15 6 6`,key:`1s409w`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}],[`path`,{d:`M3 16v5h5`,key:`1t08am`}],[`path`,{d:`m3 21 6-6`,key:`wwnumi`}],[`path`,{d:`M3 8V3h5`,key:`1ln10m`}],[`path`,{d:`M9 9 3 3`,key:`v551iv`}]]),j=s(`share`,[[`path`,{d:`M12 2v13`,key:`1km8f5`}],[`path`,{d:`m16 6-4-4-4 4`,key:`13yo43`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}]]),M=a(),N=e(t(),1),P=`flags.toggleAppsSandboxDisabled`,F=!1,I=new Set;function L(){return F}function R(e){let t=e===void 0?!F:e===!0;if(t===F)return console.info(`[vellumDebug] ${P}: already ${String(t)}.`),F;F=t,t?console.warn(`[vellumDebug] ${P} = true: app iframes render without the sandbox attribute. App HTML runs same-origin with the host and can reach its DOM, storage, and cookies. Open apps reload to pick this up. Call it again, or reload the page, to restore the sandbox.`):console.info(`[vellumDebug] ${P} = false: app iframes are sandboxed again.`);for(let e of I)e();return F}function z(e){return I.add(e),()=>{I.delete(e)}}function B(){return(0,N.useSyncExternalStore)(z,L,()=>!1)}function V({appName:e,onEdit:t,isEditing:r,onShare:i,isSharing:a,onDeploy:s,isDeploying:l,onToggleFullscreen:u,onClose:d}){let h=w(),v=h&&r===!0&&t!=null,y=i!=null&&s!=null;return(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-t-xl bg-[var(--surface-lift)] px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`hidden md:flex items-center min-w-[72px]`,children:t!=null&&(r?(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(A,{}),onClick:t,tooltip:`Expand app`,"aria-label":`Expand app`}):(0,M.jsx)(n,{onClick:t,children:`Edit`}))}),(0,M.jsx)(o,{variant:`body-large-default`,className:T(`flex-1 truncate text-left md:text-center text-[var(--content-emphasised)]`,v&&`cursor-pointer`),style:{lineHeight:1.4},onClick:v?t:void 0,children:e}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-[72px] justify-end`,children:[y?(0,M.jsx)(H,{onShare:i,isSharing:a,onDeploy:s,isDeploying:l,isMobile:h}):(0,M.jsxs)(M.Fragment,{children:[s!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:l?(0,M.jsx)(p,{className:`animate-spin`}):(0,M.jsx)(f,{}),onClick:s,disabled:l,tooltip:l?`Deploying…`:`Deploy`,"aria-label":l?`Deploying…`:`Deploy`}),i!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:a?(0,M.jsx)(p,{className:`animate-spin`}):(0,M.jsx)(j,{}),onClick:i,disabled:a,tooltip:a?`Sharing…`:`Share`,"aria-label":a?`Sharing…`:`Share`})]}),u!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(m,{}),onClick:u,tooltip:`Fullscreen`,"aria-label":`Fullscreen`}),t!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:r?(0,M.jsx)(c,{}):(0,M.jsx)(g,{}),onClick:t,tooltip:r?`Open app`:`Edit`,"aria-label":r?`Open app`:`Edit`,active:r,className:`md:hidden`}),(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(_,{}),onClick:d,tooltip:`Close`,"aria-label":`Close`})]})]})}function H({onShare:e,isSharing:t,onDeploy:r,isDeploying:i,isMobile:a}){let[o,s]=(0,N.useState)(!1),c=t||i,m=c?(0,M.jsx)(p,{className:`animate-spin`}):(0,M.jsx)(j,{}),h=t?`Sharing…`:i?`Deploying…`:`Share & deploy`;return a?(0,M.jsxs)(u.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(u.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:m,disabled:c,tooltip:h,"aria-label":h})}),(0,M.jsxs)(u.Content,{"aria-describedby":void 0,children:[(0,M.jsx)(u.Header,{className:`sr-only`,children:(0,M.jsx)(u.Title,{children:`Share & deploy`})}),(0,M.jsxs)(u.Body,{className:`pt-0`,children:[(0,M.jsx)(d,{icon:j,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Share`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Export as .vellum file`})]}),onSelect:()=>{s(!1),e()}}),(0,M.jsx)(d,{icon:f,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Deploy to Vercel`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Publish as a static page`})]}),onSelect:()=>{s(!1),r()}})]})]})]}):(0,M.jsxs)(l.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(l.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:m,disabled:c,tooltip:h,"aria-label":h})}),(0,M.jsxs)(l.Content,{align:`end`,sideOffset:4,children:[(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(j,{size:14}),onSelect:()=>e(),className:`whitespace-nowrap`,children:`Share`}),(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(f,{size:14}),onSelect:()=>r(),className:`whitespace-nowrap`,children:`Deploy to Vercel`})]})]})}var U=[`assistant:`,`conversation:`,`conversations:`,`apps:`,`plugins:`,`feature-flags:`];function W(e){return U.some(t=>e.startsWith(t))}function G(e,t){if(e.length===0)return[];let n=new Set(e);return t.filter(e=>n.has(e)&&!W(e))}function K(e,t){let{frameId:n,assistantId:r,appId:i,enabled:a=!0,onAction:o,onOpenVellumLink:s}=t,c=(0,N.useRef)(new Map);(0,N.useEffect)(()=>{let t=c.current,l=async c=>{let l=c.data;if(!l||l.frameId!==n||c.source!==e.current?.contentWindow)return;if(l.type===`vellum_subscribe`){if(!a)return;let{subId:e,tags:n}=l;typeof e==`string`&&Array.isArray(n)&&t.set(e,new Set(n.filter(e=>typeof e==`string`)));return}if(l.type===`vellum_unsubscribe`){let{subId:e}=l;typeof e==`string`&&t.delete(e);return}if(l.type===`vellum_surface_action`){o?.(l.actionId,l.data);return}if(l.type===`vellum_open_link`){if(!navigator.userActivation?.isActive)return;s?.(l.href,l.linkText);return}if(l.type===`vellum_asset_request`){let{callId:t,path:n}=l,o=e.current,s=(e,t)=>{o?.contentWindow?.postMessage(e,`*`,t??[])};if(!a){s({type:`vellum_asset_response`,callId:t,error:`Asset proxy disabled`});return}if(!i){s({type:`vellum_asset_response`,callId:t,error:`No app context for assets`});return}if(typeof n!=`string`||n===``||n.includes(`..`)){s({type:`vellum_asset_response`,callId:t,error:`Invalid asset path`});return}try{let e=`/v1/assistants/${r}/apps/${i}/asset/${n.split(`/`).map(encodeURIComponent).join(`/`)}`,{data:a,response:o}=await y.get({url:e,parseAs:`blob`,throwOnError:!1});if(!o?.ok||!(a instanceof Blob)){s({type:`vellum_asset_response`,callId:t,error:`Asset fetch failed (${o?.status??0})`});return}let c=await a.arrayBuffer();s({type:`vellum_asset_response`,callId:t,buffer:c,contentType:a.type||`application/octet-stream`},[c])}catch(e){s({type:`vellum_asset_response`,callId:t,error:e instanceof Error?e.message:`Asset proxy error`})}return}if(!a||l.type!==`vellum_fetch_request`)return;let{callId:u,path:d,method:f,headers:p,body:m}=l,h=e.current,g=e=>{h?.contentWindow?.postMessage(e,`*`)};if(!k.test(d)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: only /v1/x/ custom routes are allowed`});return}try{let e=new URL(d,`https://placeholder`).pathname;if(!k.test(e)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: path traversal detected`});return}}catch{g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: invalid path`});return}let _=`/v1/assistants/${r}/${d.replace(/^\/v1\//,``)}`;try{let e={url:_,throwOnError:!1,headers:p&&Object.keys(p).length>0?p:void 0,body:m?JSON.parse(m):void 0},t=await(f===`POST`?y.post:f===`PUT`?y.put:f===`PATCH`?y.patch:f===`DELETE`?y.delete:y.get)(e),n=t.response,r=t.data??t.error,i=r==null?``:typeof r==`string`?r:JSON.stringify(r);g({type:`vellum_fetch_response`,callId:u,status:n?.status??0,statusText:n?.statusText??``,body:i})}catch(e){g({type:`vellum_fetch_response`,callId:u,error:e instanceof Error?e.message:`Fetch proxy error`})}};window.addEventListener(`message`,l);let u=b(`sse.event`,r=>{let i=r.message;if(!i||i.type!==`sync_changed`||!Array.isArray(i.tags))return;let a=e.current?.contentWindow;if(!a||t.size===0)return;let o=i.tags.filter(e=>typeof e==`string`);for(let[e,r]of t){let t=G([...r],o);t.length>0&&a.postMessage({type:`vellum_event`,frameId:n,subId:e,event:{type:`sync_changed`,tags:t}},`*`)}});return()=>{window.removeEventListener(`message`,l),u()}},[n,r,i,a,o,s,e])}var q=`allow-scripts allow-popups allow-popups-to-escape-sandbox`;function J({appId:e,appName:t,html:r,assistantId:i,onClose:a,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,route:f,enableFullscreen:p=!1,onAction:m}){let g=(0,N.useRef)(null),[_,v]=(0,N.useState)(!1),y=(0,N.useCallback)(()=>v(e=>!e),[]);(0,N.useEffect)(()=>{v(!1)},[e]),(0,N.useEffect)(()=>{if(!_)return;let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),v(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_]);let b=(0,N.useMemo)(()=>O(r,e,{fetch:!0,route:f}),[r,e,f]),x=B(),S=(0,N.useMemo)(()=>{let t=0;for(let e=0;e<r.length;e++)t=(t<<5)-t+r.charCodeAt(e)|0;return`app-${e}-${t}${x?`-nosandbox`:``}`},[r,e,x]);return K(g,{frameId:e,assistantId:i,appId:e,onAction:m}),(0,M.jsxs)(`div`,{"data-testid":`app-viewer-root`,className:T(`flex flex-col overflow-hidden bg-[var(--surface-base)]`,_?`fixed inset-0 z-[60]`:`h-full rounded-xl`),children:[!_&&(0,M.jsx)(V,{appName:t,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,onToggleFullscreen:p?y:void 0,onClose:a}),(0,M.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[_&&(0,M.jsx)(`div`,{className:`absolute z-10`,style:{top:`max(0.75rem, var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,right:`max(0.75rem, var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))`},children:(0,M.jsx)(n,{variant:`primary`,iconOnly:(0,M.jsx)(h,{}),onClick:y,tooltip:`Exit fullscreen`})}),(0,M.jsx)(`iframe`,{ref:g,srcDoc:b,sandbox:x?void 0:q,referrerPolicy:`no-referrer`,title:t,className:`h-full w-full border-none`},S)]})]})}function Y(){let e=v.use.activeAssistantId(),t=w(),n=i(),{pathname:a}=r();return(0,N.useCallback)(r=>{if(!e)return;let i=D(e,r.appId)??crypto.randomUUID();E(e,r.appId,i);let o=C.getState();(o.activeAppId!==r.appId||!o.openedAppState)&&(o.openApp(r.appId),o.setLoadedApp(r)),S.getState().setEditingConversationId(i),t?o.minimizeApp():o.enterAppEditing();let s=x.conversation(i);a!==s&&n(s)},[e,t,n,a])}export{j as a,R as i,J as n,K as r,Y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,Z as t,et as n,i as r,n as i,nt as a}from"./auth-store-
|
|
1
|
+
import{$ as e,Z as t,et as n,i as r,n as i,nt as a}from"./auth-store-BZjAJNpH.js";var o=5e3;function s(e,t,n){return!n||e!=null?`ready`:t===`error`?`unavailable`:`resolving`}function c(){return s(n(),e.use.status(),r())}function l(){return s(t(),e.getState().status,a(i.getState().platformSession))}function u(){return c()===`ready`}export{c as i,l as n,u as r,o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{l as n}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as r}from"./is-electron-DLs5KNwr.js";import{f as i}from"./native-biometric-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{l as n}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as r}from"./is-electron-DLs5KNwr.js";import{f as i}from"./native-biometric-Brq7EN1d.js";import{d as a}from"./routes-CAe1h0Db.js";import{i as o}from"./navigation-resolver-BICOcF3M.js";import{t as s}from"./build-state-BOnYvQ5M.js";import{n as c}from"./login-flow-Cv6fd0k7.js";var l=e(t(),1);function u(e){let t=n(),[u,d]=(0,l.useState)(!1),[f,p]=(0,l.useState)(null),m=(0,l.useRef)(0);return{loading:u,error:f,login:async()=>{let n=e??o(s({sessionSettled:!0,isAuthenticated:!0}),t.pathname),r=++m.current;p(null),d(!0);try{await i(c,`${a.account.providerCallback}?returnTo=${encodeURIComponent(n)}`,{returnTo:n})}catch{if(r!==m.current)return;p(`Something went wrong. Please try again.`),d(!1)}},cancel:()=>{m.current++,d(!1),p(null),r()&&window.vellum?.auth?.cancelOAuth()}}}export{u as t};
|
package/dist/assets/{use-platform-assistant-id-BBcUWy3-.js → use-platform-assistant-id-ziur35ah.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{K as n}from"./auth-store-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{K as n}from"./auth-store-BZjAJNpH.js";var r=e(t(),1);function i(e,t){let[i,a]=(0,r.useState)({platformAssistantId:null,isLoading:!1,error:null});return(0,r.useEffect)(()=>{if(!t||!e){a({platformAssistantId:null,isLoading:!1,error:null});return}let r=!0;return a({platformAssistantId:null,isLoading:!0,error:null}),n(e).then(e=>{r&&a({platformAssistantId:e,isLoading:!1,error:null})}).catch(e=>{r&&a({platformAssistantId:null,isLoading:!1,error:e instanceof Error?e:Error(String(e))})}),()=>{r=!1}},[e,t]),i}export{i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{g as n,p as r}from"./local-mode-BR8wpdXp.js";import{ht as i,i as a,o}from"./auth-store-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{g as n,p as r}from"./local-mode-BR8wpdXp.js";import{ht as i,i as a,o}from"./auth-store-BZjAJNpH.js";var s=e(t(),1);function c(){let e=i.use.assistantState();return!!(e.kind===`self_hosted`||e.kind===`active`&&e.isLocal)}function l(){let e=i.use.assistantState();return e.kind===`active`&&!e.isLocal}function u(){let e=i.use.assistantState();return e.kind===`loading`||e.kind===`initializing`||e.kind===`cleaning_up`}function d(e={}){let t=p(e);return t===`pending`?`disabled`:t}function f(e={}){let t=p(e),n=m(t===`pending`,e.settleTimeoutMs??5e3);return t===`pending`&&n?`disabled`:t}function p(e){let t=a(),i=o(),s=n(),l=c(),u=i?`disabled`:`pending`;return e.platformHostedOnly?l?`gated`:t?`full`:u:r()&&s?`gated`:t?`full`:u}function m(e,t){let[n,r]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{if(!e){r(!1);return}let n=setTimeout(()=>r(!0),t);return()=>{clearTimeout(n)}},[e,t]),n}export{f as a,d as i,c as n,u as r,l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{m as n,n as r}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./loader-circle-DWWXcfTQ.js";import{a as o,s}from"./auth-store-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{m as n,n as r}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./loader-circle-DWWXcfTQ.js";import{a as o,s}from"./auth-store-BZjAJNpH.js";import{w as c}from"./native-biometric-Brq7EN1d.js";import{d as l}from"./routes-CAe1h0Db.js";import{a as u}from"./use-platform-gate-Cx6EwFNs.js";import{t as d}from"./hard-navigate-BYoBFmE4.js";import{a as f,o as p}from"./login-flow-Cv6fd0k7.js";var m=i();function h(){return(0,m.jsx)(a,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`,"aria-label":`Loading`})}var g=e(t(),1);function _({to:e}){let t=f(e);return(0,g.useEffect)(()=>{t&&d(e)},[t,e]),t?null:(0,m.jsx)(r,{to:e,replace:!0})}function v(){let[e]=n(),t=o(),r=s(),i=u(),a=e.get(`returnTo`),d=c(a,l.assistant);if(!a)return{kind:`proceed`,returnTo:null};if(r)return{kind:`wait`};if(!t)return{kind:`proceed`,returnTo:d};if(p(d)){if(i===`pending`)return{kind:`wait`};if(i===`disabled`)return{kind:`proceed`,returnTo:d}}return{kind:`redirect`,node:(0,m.jsx)(_,{to:d})}}export{h as n,v as t};
|