@vellumai/web 0.10.9-dev.202607161831.8c8f521 → 0.10.9-dev.202607162126.2d253b7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{account-page-CCZpTHv1.js → account-page-Dvn91k1X.js} +1 -1
- package/dist/assets/{acp-run-detail-panel-_lrMbea8.js → acp-run-detail-panel-Z31n86e4.js} +1 -1
- package/dist/assets/{activity-steps-panel-BKxs_GpV.js → activity-steps-panel-4k-GWBPN.js} +1 -1
- package/dist/assets/{ai-page-DAUTMyhs.js → ai-page-DQC2nlRD.js} +1 -1
- package/dist/assets/{api-key-screen-I0bww5Lq.js → api-key-screen-E0VRb6_J.js} +1 -1
- package/dist/assets/{background-task-detail-panel-9D4qDvVk.js → background-task-detail-panel-BD0_vWCR.js} +1 -1
- package/dist/assets/{billing-page-BIXRwKAk.js → billing-page-D8e1Y-L4.js} +1 -1
- package/dist/assets/{bookmarks-page-CcR6dcce.js → bookmarks-page-qBq2E1Nq.js} +1 -1
- package/dist/assets/{channels-page-route-BW5Er71R.js → channels-page-route-D8JLt4Hr.js} +1 -1
- package/dist/assets/{command-palette-C_DIgz5Q.js → command-palette-Dyuq3z8h.js} +1 -1
- package/dist/assets/{command-palette-window-page-gW0wAaqm.js → command-palette-window-page-CTWIp-eS.js} +1 -1
- package/dist/assets/{community-page-DmSpoKI5.js → community-page-C8WmDVET.js} +1 -1
- package/dist/assets/{contacts-page-route-B5ihu406.js → contacts-page-route-BH-d1Gx7.js} +1 -1
- package/dist/assets/{credentials-page-BCwpTieE.js → credentials-page-FvDtHanb.js} +1 -1
- package/dist/assets/{debug-page-CxXAWEQK.js → debug-page-D4Sca6Rg.js} +1 -1
- package/dist/assets/{deploy-dialogs-B3xWKJ80.js → deploy-dialogs-VIsg83qz.js} +1 -1
- package/dist/assets/{detail-panel-stop-button-D3RATpA-.js → detail-panel-stop-button-Dt2UIyNB.js} +1 -1
- package/dist/assets/{developer-page-CO7ynw7D.js → developer-page-cnI-eUjv.js} +1 -1
- package/dist/assets/{dictation-overlay-page-BRyRajlm.js → dictation-overlay-page-DSLUFhF9.js} +1 -1
- package/dist/assets/{document-viewer-page-wGxEjJ6s.js → document-viewer-page-CqZ1exEy.js} +1 -1
- package/dist/assets/{emails-page-Bj3jGaiH.js → emails-page-BWgk2Z-k.js} +1 -1
- package/dist/assets/general-page-CXZbi2Zb.js +1 -0
- package/dist/assets/{hatching-screen-BeThiAoY.js → hatching-screen-8QQ5Mr8W.js} +1 -1
- package/dist/assets/{home-page-route-DcRfMT7t.js → home-page-route-e6YKZPOA.js} +1 -1
- package/dist/assets/{hosting-screen-CfNJYjlS.js → hosting-screen-sIKnFlur.js} +1 -1
- package/dist/assets/identity-page-route-Dg5W344E.js +7 -0
- package/dist/assets/{index-DglwxsvA.js → index-CFQIPKjY.js} +8 -8
- package/dist/assets/{inspect-page-CfY2ujI9.js → inspect-page-BuyIWBj-.js} +1 -1
- package/dist/assets/{integrations-page-tzKO6Tqd.js → integrations-page-Bbrw2Uh7.js} +1 -1
- package/dist/assets/{intelligence-layout-DmOQmOQL.js → intelligence-layout-BsK19MtR.js} +1 -1
- package/dist/assets/{latest-assistant-text-PVDAChQ2.js → latest-assistant-text-Qj7hDn1c.js} +1 -1
- package/dist/assets/{library-detail-page-D1qABwGL.js → library-detail-page-D-3NxcfG.js} +1 -1
- package/dist/assets/{library-page-Cc3ZzzQX.js → library-page-DJL8fVvG.js} +1 -1
- package/dist/assets/{logout-page-B6cf9X3l.js → logout-page-BxeOwXvN.js} +1 -1
- package/dist/assets/{logs-layout-BktGpFvY.js → logs-layout-ezxror9r.js} +1 -1
- package/dist/assets/{memory-page-route-CAcOOaPn.js → memory-page-route-BjJp6GG6.js} +1 -1
- package/dist/assets/{memory-router-playground-page-Butejuyj.js → memory-router-playground-page-kmzI1jaf.js} +1 -1
- package/dist/assets/{messages-Bh85VLCd.js → messages-DWh9qzBE.js} +1 -1
- package/dist/assets/{mobile-sidebar-drawer-Cp2poD2Q.js → mobile-sidebar-drawer-D_oNDC56.js} +1 -1
- package/dist/assets/{notifications-page-U2jH4rfU.js → notifications-page-DzLRSw-u.js} +1 -1
- package/dist/assets/{oauth-complete-page-C5fVZrbG.js → oauth-complete-page-rHhstJnQ.js} +1 -1
- package/dist/assets/{oauth-popup-complete-page-CU1OWA7c.js → oauth-popup-complete-page-Ad6o_mHW.js} +1 -1
- package/dist/assets/{pairing-page-AOzsN6ID.js → pairing-page-gVKFhrvD.js} +1 -1
- package/dist/assets/{personality-page-DAlsAWJR.js → personality-page-CXeTTR9o.js} +1 -1
- package/dist/assets/{plugins-page-CpdP0Jsz.js → plugins-page-DuMlB4ii.js} +1 -1
- package/dist/assets/{privacy-page-KhIuDaMZ.js → privacy-page-pCFzcJzc.js} +1 -1
- package/dist/assets/{privacy-screen-D4cNMe58.js → privacy-screen-6ZLxuz0S.js} +1 -1
- package/dist/assets/{provider-callback-page-qq15ztlr.js → provider-callback-page-Cqt0UHpc.js} +1 -1
- package/dist/assets/{quick-input-page-joZ1snmq.js → quick-input-page-DIFKuIc3.js} +1 -1
- package/dist/assets/{research-mock-page-D45wW9I_.js → research-mock-page-bxXiu2Bj.js} +1 -1
- package/dist/assets/research-onboarding-route-Dc93dQDk.js +43 -0
- package/dist/assets/{review-terms-screen-D48F_rvC.js → review-terms-screen-CIWKcVhq.js} +1 -1
- package/dist/assets/{risk-C5kUSSLu.js → risk-BtPQZGh-.js} +1 -1
- package/dist/assets/{schedules-page-B4wPERNe.js → schedules-page-DtTKGidy.js} +1 -1
- package/dist/assets/{select-assistant-screen-Ds8S0lHD.js → select-assistant-screen-hWhI5kZ_.js} +1 -1
- package/dist/assets/{settings-layout-TGkB8Eny.js → settings-layout-CMEu1Mzb.js} +1 -1
- package/dist/assets/{share-feedback-modal-409NP3X1.js → share-feedback-modal-CamJi5dX.js} +1 -1
- package/dist/assets/{sidebar-tree-Cs6cFnG2.js → sidebar-tree-C_TcfNts.js} +1 -1
- package/dist/assets/{signup-page-E1B2kmMT.js → signup-page-CrZg16Yg.js} +1 -1
- package/dist/assets/{site-favicon-Bsh4glAL.js → site-favicon-CEvSq5Ys.js} +1 -1
- package/dist/assets/{skill-detail-page-jMIyfUs_.js → skill-detail-page-DK14Cp9u.js} +1 -1
- package/dist/assets/{skill-detail-panel-7sTZP8ra.js → skill-detail-panel-B1mM9MZQ.js} +1 -1
- package/dist/assets/{skills-page-D3OTDTES.js → skills-page-CyL4OD_Q.js} +1 -1
- package/dist/assets/{start-screen-ByKXdi-m.js → start-screen-CZ7j59Pl.js} +1 -1
- package/dist/assets/{subagent-detail-panel-jSEOh5tT.js → subagent-detail-panel-CTJjZGP8.js} +1 -1
- package/dist/assets/{system-events-page--AiaEwyg.js → system-events-page-DtaGaAoh.js} +1 -1
- package/dist/assets/{theme-stage-page-nI4ojIYO.js → theme-stage-page-Xj_RDfrS.js} +1 -1
- package/dist/assets/{tiptap-document-editor-CpP7BiuD.js → tiptap-document-editor-C0g4DNLq.js} +1 -1
- package/dist/assets/{tool-detail-panel-hAWze9O3.js → tool-detail-panel-CKKbVoIf.js} +1 -1
- package/dist/assets/{upgrade-cancel-page-DkyUk5eu.js → upgrade-cancel-page-Chq89ltm.js} +1 -1
- package/dist/assets/{upgrade-success-page-Bm_OLV34.js → upgrade-success-page-uZXxxn_J.js} +1 -1
- package/dist/assets/{use-assistant-identity-details-CmVqcz5B.js → use-assistant-identity-details-BDGF_Qun.js} +1 -1
- package/dist/assets/{use-edge-swipe-back-ChhW2Yn_.js → use-edge-swipe-back-D56kIRTP.js} +1 -1
- package/dist/assets/{use-invite-link-dialog-CqDYf0rC.js → use-invite-link-dialog-l_72sgiY.js} +1 -1
- package/dist/assets/{use-skill-actions-T8UKexNG.js → use-skill-actions-D1b_YIKn.js} +1 -1
- package/dist/assets/{use-skill-categories-CURWXK_d.js → use-skill-categories-Bpashk58.js} +1 -1
- package/dist/assets/{use-skill-detail-files-Ddn5JjrQ.js → use-skill-detail-files-8u7UCzno.js} +1 -1
- package/dist/assets/{voice-page-CXudm9dD.js → voice-page-BHZza2d9.js} +1 -1
- package/dist/assets/{weather-forecast-display-CtBYS3RS.js → weather-forecast-display-Cmq5dnFc.js} +1 -1
- package/dist/assets/{welcome-screen-CwMgCfoH.js → welcome-screen-Crxq3jKT.js} +1 -1
- package/dist/assets/{workflow-detail-panel-Dna_IU6V.js → workflow-detail-panel-Bf0TdDD-.js} +1 -1
- package/dist/assets/{workspace-page-ClmjoyUi.js → workspace-page-DQ5QNkGq.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/general-page-laeNeI8F.js +0 -1
- package/dist/assets/identity-page-route-C-K0OkH_.js +0 -7
- package/dist/assets/research-onboarding-route-DJiO0r-Z.js +0 -42
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/native-file-CHp_Tbhe.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-BewR0kVT.js","assets/dist-DyRKd0bN2.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e,t}from"./chunk-jRWAZmH_.js";import{t as n}from"./capture-error-Dhiismgm.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-BQVYX8n_.js";import{t as a}from"./preload-helper-BewR0kVT.js";import{m as o,u as s}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as c}from"./QueryClientProvider-DKhXIxGb.js";import{t as l}from"./useQuery-B45lW1Kk.js";import{t as u}from"./useMutation-Lj4VunQV.js";import{t as d}from"./jsx-runtime-CVSDxk6A.js";import{t as f}from"./typography-Cqi8q9o7.js";import{t as p}from"./card-D8zyWtZh.js";import{t as m}from"./createLucideIcon-Bjb-Kuq7.js";import{t as h}from"./arrow-left-C2re-gYj.js";import{t as g}from"./check-CkQjevXL.js";import{t as _}from"./chevron-down-DwIPfcCg.js";import{t as v}from"./circle-alert-_RJjkRGu.js";import{t as y}from"./circle-check-DWe3QGcN.js";import{n as b,o as x}from"./list-row-spYsDF9a.js";import{t as S}from"./cpu-CEyjQpZz.js";import{t as C}from"./credit-card-BY-vD21O.js";import{n as w,t as T}from"./domain-field-DKKi4dF-.js";import{t as E}from"./download-B6XjnEzx.js";import{t as D}from"./external-link-Cczz6xJ4.js";import{t as O}from"./file-text-DA128T4K.js";import{t as k}from"./hard-drive-BXh9qCfi.js";import{t as A}from"./info-DLFMsCl-.js";import{t as j}from"./loader-circle-C9QrtO3C.js";import{a as M,c as ee,i as te,n as N,r as P,t as ne}from"./resize-errors-yH10K9Qq.js";import{t as re}from"./sparkles-BK3KXCjl.js";import{t as ie}from"./triangle-alert-CnjNKhNx.js";import{t as F}from"./notice-B8UI-BOp.js";import{j as ae,r as I}from"./src-clcV9W6_.js";import{t as L}from"./tag-D0AE0-aA.js";import{t as R}from"./input-6HVXMszw.js";import{t as z}from"./toggle-CWrJ2t4S.js";import{t as B}from"./modal-bIQsMU63.js";import{n as V}from"./toast-CZmbu5xl.js";import{t as oe}from"./confirm-dialog-kE8y7s20.js";import{t as H}from"./dropdown-CuE5AuVj.js";import{Cr as se}from"./sdk.gen-C9GJEKYV.js";import{Ft as ce,It as le,Lt as ue,Rt as de,c as fe,d as pe,ht as me}from"./react-query.gen-CWfp8GEM.js";import{t as he}from"./api-errors-CrWDzVca.js";import{ct as ge,st as _e}from"./sdk.gen-Z7XkRg5O.js";import{c as U}from"./routes-GPGveWZ8.js";import{n as ve,t as ye}from"./browser-804KO6w7.js";import{t as W}from"./effective-timezone-Cp9o8K5B.js";import{$ as be,B as xe,Dt as Se,Et as Ce,G as we,H as Te,J as Ee,K as De,O as Oe,Q as ke,R as Ae,U as je,V as Me,W as Ne,X as Pe,Y as Fe,Z as Ie,at as Le,c as Re,ct as ze,dt as Be,et as Ve,it as He,nt as Ue,ot as We,q as Ge,r as Ke,rt as qe,st as Je,tt as Ye,ut as Xe,wt as Ze,y as Qe,yt as $e,z as et}from"./react-query.gen-B-P32qsC.js";import{Da as tt,Fr as nt,H as rt,Ha as it,Ii as at,Ir as ot,Yn as st,ci as ct,la as lt,li as ut,m as dt,ui as ft,zi as pt}from"./index-DglwxsvA.js";import{t as mt}from"./use-active-assistant-id-DpxCpOc4.js";import{t as ht}from"./add-credits-modal-ByK3VreF.js";import{t as gt}from"./schedules-CTsHce7J.js";import{i as _t,n as vt,r as yt,t as bt}from"./profile-metadata-VB4MBtgt.js";import{t as xt}from"./environment-store-BX22hkIL.js";var St=m(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),Ct=m(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),wt=m(`party-popper`,[[`path`,{d:`M5.8 11.3 2 22l10.7-3.79`,key:`gwxi1d`}],[`path`,{d:`M4 3h.01`,key:`1vcuye`}],[`path`,{d:`M22 8h.01`,key:`1mrtc2`}],[`path`,{d:`M15 2h.01`,key:`1cjtqr`}],[`path`,{d:`M22 20h.01`,key:`1mrys2`}],[`path`,{d:`m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10`,key:`hbicv8`}],[`path`,{d:`m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17`,key:`1i94pl`}],[`path`,{d:`m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7`,key:`1cofks`}],[`path`,{d:`M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z`,key:`4kbmks`}]]),Tt=m(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Et=m(`tree-palm`,[[`path`,{d:`M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4`,key:`foxbe7`}],[`path`,{d:`M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3`,key:`18arnh`}],[`path`,{d:`M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35`,key:`ywahnh`}],[`path`,{d:`M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14`,key:`ft0feo`}]]),G=e(r(),1),K=d();function Dt({onBack:e}){let t=s(),{data:n}=l(Ke()),r=n?.name||`your assistant`;return(0,K.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(ellipse 60% 50% at 50% 38%, color-mix(in oklab, var(--system-positive-strong) 14%, transparent), transparent)`},"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,K.jsx)(`div`,{className:`absolute h-24 w-24 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 18%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite`},"aria-hidden":`true`}),(0,K.jsx)(`div`,{className:`absolute h-16 w-16 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 12%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite 0.5s`},"aria-hidden":`true`}),(0,K.jsx)(wt,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,K.jsx)(`h1`,{className:`relative mb-2 text-[var(--content-emphasised)]`,style:{fontFamily:`var(--font-serif)`,fontSize:`28px`,lineHeight:1,fontWeight:400,animation:`welcome-reveal 600ms ease-out 150ms both`},children:`You're all set`}),(0,K.jsx)(`p`,{className:`relative mb-6 max-w-[320px] text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`welcome-reveal 600ms ease-out 300ms both`},children:`Your assistant just got a serious upgrade.`}),(0,K.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,K.jsxs)(i,{variant:`primary`,"data-testid":`onboarding-complete-return`,onClick:()=>t(U.assistant,{replace:!0}),children:[`Return to `,r]})}),(0,K.jsx)(`div`,{className:`absolute bottom-4 left-4`,children:(0,K.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-complete-back`,onClick:e,leftIcon:(0,K.jsx)(h,{className:`h-4 w-4`}),children:`Back`})})]})}function Ot({current:e,total:t=2}){return(0,K.jsx)(`div`,{className:`flex items-center justify-center gap-1.5`,children:Array.from({length:t},(t,n)=>(0,K.jsx)(`div`,{className:`h-1.5 rounded-full transition-all duration-300`,style:{width:n===e?20:6,backgroundColor:n<=e?`var(--content-default)`:`var(--border-element)`}},n))})}function kt({icon:e,tone:t=`positive`}){let n=t===`positive`?`--system-positive-strong`:t===`warning`?`--system-mid-strong`:`--system-negative-strong`;return(0,K.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(${n}) 12%, transparent)`},children:(0,K.jsx)(e,{className:`h-5 w-5`,style:{color:`var(${n})`},"aria-hidden":`true`})})}var At=1e3,jt=1e4;function Mt(e){return te[e]??te.medium}var Nt=[`machine_size`,`subdomain`,`non_field_errors`],Pt={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.`};function Ft(e,t){if(e&&typeof e==`object`){let t=e;if(typeof t.error==`string`){let e=Pt[t.error];if(e)return e}for(let e of Nt){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}function It({onBack:e,onExit:t}){let n=c(),r=xt.use.emailRootDomain(),{data:a}=l(Ke()),o=a?.id,{data:s}=l({...Re({path:{assistant_id:o??``}}),enabled:!!o}),d=s?.results?.[0],[p,m]=(0,G.useState)(``),[g,_]=(0,G.useState)(`hi`),[v,y]=(0,G.useState)(!1);(0,G.useEffect)(()=>{if(!v){if(d){m(d.subdomain),y(!0);return}!a?.handle||p||(m(a.handle),y(!0))}},[a?.handle,d,v,p]);let[b,x]=(0,G.useState)(null),[S,C]=(0,G.useState)(!1),w=u(Ye()),E=!!d||S,D=w.isPending||S;return(0,G.useEffect)(()=>{if(!S)return;let e=setTimeout(t,800);return()=>clearTimeout(e)},[S,t]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(B.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,K.jsx)(kt,{icon:lt}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(f,{variant:`title-small`,as:`h1`,children:`Assistant email`}),(0,K.jsx)(f,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Set up an email address for your assistant.`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(f,{variant:`body-small-default`,as:`label`,className:`text-[var(--content-secondary)]`,children:`Email address`}),(0,K.jsx)(T,{subdomain:p,autoFocus:!0,onSubdomainChange:e=>{m(e),b&&x(null)},domainSuffix:r,disabled:D,error:b,locked:E,lockedMessage:`This domain has been set and cannot be changed.`,prefix:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`input`,{value:g,onChange:e=>_(e.target.value.toLowerCase().trim()),disabled:D||E,readOnly:E,placeholder:`hi`,"aria-label":`Email username`,size:Math.max(g.length,2),className:`h-full w-0 min-w-[2ch] flex-none bg-transparent pl-3 pr-1.5 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none disabled:cursor-not-allowed disabled:opacity-60`,style:{width:`${Math.max(g.length,2)+1.5}ch`}}),(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-[var(--content-secondary)]`,children:`@`})]})})]}),!E&&(0,K.jsxs)(F,{tone:`info`,children:[(0,K.jsx)(`span`,{className:`font-mono`,children:p||`<subdomain>`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),S?(0,K.jsx)(F,{tone:`success`,children:`Domain set — redirecting…`}):null]}),(0,K.jsxs)(B.Footer,{className:`relative items-center justify-between`,children:[(0,K.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-back`,disabled:D,onClick:e,leftIcon:(0,K.jsx)(h,{className:`h-4 w-4`}),children:`Back`}),(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,K.jsx)(Ot,{current:0})}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:E?(0,K.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-continue`,onClick:t,children:`Continue`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-skip`,disabled:D,onClick:()=>{D||w.mutate({body:{skipped:!0}},{onSuccess:t,onError:()=>t()})},children:`Do later`}),(0,K.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-set`,disabled:!p||D,onClick:()=>{D||!p||w.mutate({body:{subdomain:p,...g?{email_username:g}:{}}},{onSuccess:()=>{x(null),C(!0),n.invalidateQueries({queryKey:Qe()})},onError:e=>{x(Ft(e,`Couldn't register that subdomain. Try a different one.`))}})},children:`Set domain`})]})})]})]})}function Lt({onGoToBilling:e}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-10 text-center`,children:[(0,K.jsx)(kt,{icon:v,tone:`negative`}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(f,{variant:`title-small`,as:`h1`,children:`Couldn't reach billing`}),(0,K.jsx)(f,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`We hit a problem checking your subscription. Your upgrade may still be processing — return to billing to refresh.`})]}),(0,K.jsx)(i,{variant:`primary`,"data-testid":`onboarding-go-to-billing`,onClick:e,children:`Go to billing`})]})}function Rt({message:e,onRetry:t,onGoToBilling:n}){return(0,K.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,K.jsx)(kt,{icon:v,tone:`warning`}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(f,{variant:`title-small`,as:`h1`,children:`Taking longer than expected`}),(0,K.jsx)(f,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:e})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,K.jsx)(i,{variant:`outlined`,"data-testid":`onboarding-go-to-billing`,onClick:n,children:`Go to billing`}),(0,K.jsx)(i,{variant:`primary`,"data-testid":`onboarding-retry`,onClick:t,children:`Try again`})]})]})}function zt({title:e,body:t}){return(0,K.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,K.jsxs)(`div`,{className:`relative flex h-11 w-11 items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute h-14 w-14 rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`,animation:`onboarding-glow 2.4s ease-in-out infinite`},"aria-hidden":`true`}),(0,K.jsx)(`div`,{className:`absolute h-9 w-9 rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 8%, transparent)`,animation:`onboarding-glow 2.4s ease-in-out infinite 0.4s`},"aria-hidden":`true`}),(0,K.jsx)(j,{className:`relative h-5 w-5 animate-spin text-[var(--system-positive-strong)]`,"aria-hidden":`true`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(f,{variant:`title-small`,as:`h1`,children:e}),(0,K.jsx)(f,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:t})]})]})}function Bt({icon:e,label:t,from:n,fromDetail:r,to:i,toDetail:a}){return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,K.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`},children:(0,K.jsx)(e,{className:`h-4 w-4 text-[var(--system-positive-strong)]`})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:t}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)] line-through`,children:n}),r&&(0,K.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)] line-through`,children:r})]}),(0,K.jsx)(it,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`}),(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:i}),a&&(0,K.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:a})]})]})]})]})}function Vt({storageGib:e,maxTier:t,onBack:n,onAdvance:r,dotIndex:a,dotTotal:o}){let{data:s}=l(Ke()),c=s?.machine_size||`small`,d=s?.provisioned_storage_gib??null,p=Mt(t),m=p.length>0?p[p.length-1]:c,g=m!==c,_=e!=null&&(d==null||d<e),[v,y]=(0,G.useState)(null),b=u(Oe());return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(B.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,K.jsx)(kt,{icon:S}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(f,{variant:`title-small`,as:`h1`,children:`Your assistant's new resources`}),(0,K.jsx)(f,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Your assistant will go offline briefly while it resizes.`})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[g&&(0,K.jsx)(Bt,{icon:S,label:`Machine`,from:P[c],fromDetail:N[c],to:P[m],toDetail:N[m]}),_&&(0,K.jsx)(Bt,{icon:k,label:`Storage`,from:d==null?`—`:`${d} GiB`,to:`${e} GiB`}),!g&&!_&&(0,K.jsx)(F,{tone:`neutral`,children:`Your assistant is already running at the maximum size for your plan.`})]}),v?(0,K.jsx)(F,{tone:`error`,children:v}):null]}),(0,K.jsxs)(B.Footer,{className:`relative items-center justify-between`,children:[(0,K.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-back`,disabled:b.isPending,onClick:n,leftIcon:(0,K.jsx)(h,{className:`h-4 w-4`}),children:`Back`}),(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,K.jsx)(Ot,{current:a,total:o})}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-skip`,disabled:b.isPending,onClick:r,children:`Do later`}),(0,K.jsx)(i,{variant:`primary`,"data-testid":`onboarding-setup-continue`,disabled:b.isPending||!s?.id,onClick:()=>{b.isPending||!s?.id||b.mutate({path:{id:s.id},body:{machine_size:m,...e==null?{}:{storage_gib:e}}},{onSuccess:()=>{y(null),r()},onError:e=>{y(Ft(e,`Couldn't apply changes. Please try again.`))}})},children:`Apply & Restart`})]})]})]})}function Ht({onContinue:e,continueDisabled:t=!1}){return(0,K.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(ellipse 60% 50% at 50% 38%, color-mix(in oklab, var(--system-positive-strong) 14%, transparent), transparent)`},"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,K.jsx)(`div`,{className:`absolute h-24 w-24 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 18%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite`},"aria-hidden":`true`}),(0,K.jsx)(`div`,{className:`absolute h-16 w-16 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 12%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite 0.5s`},"aria-hidden":`true`}),(0,K.jsx)(w,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,K.jsx)(`h1`,{className:`relative mb-2 text-[var(--content-emphasised)]`,style:{fontFamily:`var(--font-serif)`,fontSize:`28px`,lineHeight:1,fontWeight:400,animation:`welcome-reveal 600ms ease-out 150ms both`},children:`Welcome to Pro`}),(0,K.jsx)(`p`,{className:`relative mb-6 max-w-[320px] text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`welcome-reveal 600ms ease-out 300ms both`},children:`More compute, more storage, and more features. Let's set everything up.`}),(0,K.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,K.jsx)(i,{variant:`primary`,"data-testid":`onboarding-welcome-continue`,disabled:t,onClick:e,children:`Get started`})}),(0,K.jsx)(`p`,{className:`relative mt-6 max-w-[320px] text-body-small-default text-[var(--content-tertiary)]`,style:{animation:`welcome-reveal 600ms ease-out 600ms both`},children:`This quick setup gets your Pro features ready to go. You can close it anytime and turn these features on later from Settings.`})]})}function Ut({open:e,onClose:t}){let n=c(),[r,i]=(0,G.useState)(`confirm-pro`),[a,o]=(0,G.useState)(!1),[s,u]=(0,G.useState)(0);(0,G.useEffect)(()=>{e&&(n.invalidateQueries({queryKey:Le()}),n.invalidateQueries({queryKey:qe()}))},[e,n]);let d=(0,G.useCallback)(()=>{o(!1),u(e=>e+1),n.invalidateQueries({queryKey:Le()})},[n]),f=l({...He(),refetchInterval:e=>e.state.data?.plan_id===`pro`||a?!1:At,refetchIntervalInBackground:!1,enabled:e&&r===`confirm-pro`});(0,G.useEffect)(()=>{if(!e||r!==`confirm-pro`)return;let t=setTimeout(()=>o(!0),jt);return()=>clearTimeout(t)},[e,r,s]),(0,G.useEffect)(()=>{r===`confirm-pro`&&f.data?.plan_id===`pro`&&i(`welcome`)},[r,f.data?.plan_id]);let p=l({...Ue(),enabled:e&&r!==`confirm-pro`});l({...Ke(),enabled:e});let m=p.data?.domain_setup_available,h=(0,G.useCallback)(()=>{i(m===!1?`setup`:`domain`)},[m]),g=(0,G.useCallback)(()=>{i(m===!1?`welcome`:`domain`)},[m]),_=r===`welcome`;return(0,K.jsx)(B.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,K.jsx)(B.Content,{size:`md`,hideCloseButton:!_,dismissOnOverlayClick:!_,onEscapeKeyDown:_?e=>e.preventDefault():void 0,onInteractOutside:_?e=>e.preventDefault():void 0,className:`overflow-hidden`,children:v()})});function v(){if(r===`confirm-pro`)return f.isError?(0,K.jsx)(Lt,{onGoToBilling:t}):a?(0,K.jsx)(Rt,{message:`We're still confirming your upgrade.`,onRetry:d,onGoToBilling:t}):(0,K.jsx)(zt,{title:`Finalizing your upgrade…`,body:`This usually takes a few seconds.`});if(r===`welcome`)return p.isError?(0,K.jsx)(Lt,{onGoToBilling:t}):(0,K.jsx)(Ht,{onContinue:h,continueDisabled:p.isPending||p.isFetching});if(r===`domain`)return(0,K.jsx)(It,{onBack:()=>i(`welcome`),onExit:()=>i(`setup`)});if(r===`setup`){if(p.isError)return(0,K.jsx)(Lt,{onGoToBilling:t});let e=p.data?.max_machine_tier??null,n=m!==!1;return(0,K.jsx)(Vt,{storageGib:p.data?.selected_storage_gib??null,maxTier:e,onBack:g,onAdvance:()=>i(`complete`),dotIndex:+!!n,dotTotal:n?2:1})}return r===`complete`?(0,K.jsx)(Dt,{onBack:()=>i(`setup`)}):null}}function Wt(e){if(!e)return{};let t={};for(let n of e.callSites)!n.id||!n.displayName||(t[n.id]={id:n.id,displayName:n.displayName,description:n.description,domain:n.domain});return t}function q(e){return Number.isFinite(e)?Math.round(e).toLocaleString():`0`}function Gt(e){return!Number.isFinite(e)||e===0?`$0.00`:`$${e.toFixed(2)}`}var Kt=`model`,qt={model:`Model`,task:`Action`,profile:`Profile`},Jt=[{value:`model`,label:qt.model},{value:`task`,label:qt.task},{value:`profile`,label:qt.profile}];function Yt(e){return e===`model`||e===`task`||e===`profile`}function Xt(e){switch(e){case`model`:return`model`;case`task`:return`call_site`;case`profile`:return`inference_profile`}}function Zt(e){switch(e){case`model`:return`model`;case`task`:return`llm_call_site`;case`profile`:return`inference_profile`}}function Qt(e,t,n){if(e===`task`){let e=t.groupKey;return e?n.callSites?.[e]?.displayName??t.group:t.group}if(e===`profile`){let e=t.groupKey;return e?n.profiles?.[e]?.displayName??t.group:t.group||`Default / Unset`}return t.group}function $t(e,t,n){return!e||e.length===0?[]:e.map(e=>{let r=Qt(t,e,n);return r===e.group?e:{...e,group:r}})}var en=6,tn=`value:`,nn=`null:`;function rn(e,t=`schedule`){return e===null?`${nn}${Yt(t)?Xt(t):t}`:`${tn}${e}`}function an(e){return[...e].sort((e,t)=>{if(e.date!==t.date)return e.date<t.date?-1:1;let n=un(e.bucketId),r=un(t.bucketId);return n===r?e.bucketId===t.bucketId?0:e.bucketId<t.bucketId?-1:1:n-r})}function on(e){return e.map(e=>({bucketId:e.bucketId,date:e.date,displayLabel:e.displayLabel,totalInputTokens:e.totalInputTokens,totalOutputTokens:e.totalOutputTokens,totalEstimatedCostUsd:e.totalEstimatedCostUsd,eventCount:e.eventCount,groups:{}}))}function sn(e,t,n){return t!==`task`&&t!==`profile`?[...e]:e.map(e=>{let r=!1,i={};for(let[a,o]of Object.entries(e.groups)){let e=Qt(t,ln(o),n);e===o.group?i[a]=o:(r=!0,i[a]={...o,group:e})}return r?{...e,groups:i}:e})}function cn(e){let t=new Map;for(let n of e)for(let[e,r]of Object.entries(n.groups)){let n=t.get(e);t.set(e,{label:n?.label??r.group,totalEstimatedCostUsd:(n?.totalEstimatedCostUsd??0)+r.totalEstimatedCostUsd})}let n=Array.from(t.entries()).sort(([e,t],[n,r])=>t.totalEstimatedCostUsd===r.totalEstimatedCostUsd?t.label===r.label?e===n?0:e<n?-1:1:t.label<r.label?-1:1:r.totalEstimatedCostUsd-t.totalEstimatedCostUsd).map(([e,t],n)=>({seriesKey:e,label:t.label,totalEstimatedCostUsd:t.totalEstimatedCostUsd,colorIndex:n}));return{items:n,visibleItems:n.slice(0,en)}}function ln(e){return{group:e.group,groupId:e.groupKey,groupKey:e.groupKey,totalInputTokens:e.totalInputTokens,totalOutputTokens:e.totalOutputTokens,totalCacheCreationTokens:0,totalCacheReadTokens:0,totalEstimatedCostUsd:e.totalEstimatedCostUsd,eventCount:e.eventCount,turnCount:null}}function un(e){let t=e.lastIndexOf(`|`);if(t<0)return 0;let n=Number(e.slice(t+1));return Number.isFinite(n)?n:0}var dn=140,fn=40,pn=28,mn=2,hn=2,gn=1e-6,_n=12,vn=220,yn=56,bn=[40,80,60,100,50,70,30],xn=[18,24,28,35,42,50,64,78,92,106,118,96,84,74,68,80,88,72,56,48,40,34,26,20],Sn=[`var(--usage-trend-stack-positive, var(--system-positive-strong, #10b981))`,`var(--usage-trend-stack-info, var(--system-info-strong, #3b82f6))`,`var(--usage-trend-stack-mid, var(--system-mid-strong, #f59e0b))`,`var(--usage-trend-stack-secondary, var(--content-secondary, #6b7280))`,`var(--usage-trend-stack-negative, var(--system-negative-strong, #f87171))`,`var(--usage-trend-stack-tertiary, var(--content-tertiary, #9ca3af))`];function Cn(e){return Sn[e%Sn.length]}function wn(e){return e.displayLabel?e.displayLabel:e.date}function Tn(e,t){let n=e+_n,r=t+_n;return n+vn>window.innerWidth&&(n=e-vn-_n),r+yn>window.innerHeight&&(r=t-yn-_n),{x:n,y:r}}function En({buckets:e,isHourly:t,legendItems:n}){let[r,i]=(0,G.useState)(null),a=(0,G.useMemo)(()=>an(e),[e]),o=(0,G.useMemo)(()=>cn(e),[e]),s=n??o.items,c=n??o.visibleItems,l=(0,G.useMemo)(()=>a.reduce((e,t)=>Math.max(e,t.totalEstimatedCostUsd),0),[a]),u=(0,G.useCallback)((e,t)=>{let n=Tn(e.clientX,e.clientY);i({...t,x:n.x,y:n.y})},[]),d=(0,G.useCallback)(()=>i(null),[]);if(a.length===0){let e=(0,K.jsx)(jn,{title:t?`No hourly data`:`No daily data`,subtitle:`No usage recorded in this time range`});return c.length===0?e:(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,(0,K.jsx)(An,{items:c})]})}let f=t?pn:fn;return(0,K.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-end gap-2`,style:{height:`${dn}px`},"aria-hidden":`true`,children:a.map(e=>{let t=l>0?e.totalEstimatedCostUsd/l:0,r=Math.max(mn,dn*t);return(0,K.jsx)(`div`,{className:`flex items-end`,style:{width:`${f}px`,minWidth:`${f}px`,height:`${r}px`,opacity:e.totalEstimatedCostUsd>0?1:.3},title:`${wn(e)}: ${Gt(e.totalEstimatedCostUsd)}`,"data-usage-series-bar":e.bucketId,children:(0,K.jsx)(On,{bucket:e,height:r,legendItems:s,hasLegendOverride:n!=null,onSegmentHover:u,onSegmentLeave:d})},e.bucketId)})}),(0,K.jsx)(`div`,{className:`flex items-start gap-2`,children:a.map(e=>(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-0.5`,style:{width:`${f}px`,minWidth:`${f}px`},children:[(0,K.jsx)(`span`,{className:`truncate text-[10px]`,style:{color:`var(--content-secondary)`},children:Gt(e.totalEstimatedCostUsd)}),(0,K.jsx)(`span`,{className:`truncate text-[10px]`,style:{color:`var(--content-tertiary)`},children:wn(e)})]},e.bucketId))}),c.length>0?(0,K.jsx)(An,{items:c}):null]}),r?(0,K.jsx)(kn,{tooltip:r}):null]})}function Dn({isHourly:e}){let t=e?xn:bn,n=e?pn:fn;return(0,K.jsx)(`div`,{className:`flex items-end gap-2`,style:{height:`${dn}px`},"aria-hidden":`true`,children:t.map((e,t)=>(0,K.jsx)(`div`,{className:`rounded-sm`,style:{width:`${n}px`,height:`${e}px`,background:`color-mix(in srgb, var(--border-base) 40%, transparent)`}},t))})}function On({bucket:e,height:t,legendItems:n,hasLegendOverride:r,onSegmentHover:i,onSegmentLeave:a}){let o=Object.keys(e.groups).length>0,s=n.filter(e=>(e.state??`active`)===`active`).flatMap(t=>{let n=e.groups[t.seriesKey];return!n||n.totalEstimatedCostUsd<=0?[]:[{item:t,value:n}]});if(s.length===0&&!o&&!r){let n={label:`Total`,bucketLabel:wn(e),cost:Gt(e.totalEstimatedCostUsd)};return(0,K.jsx)(`div`,{className:`w-full rounded-sm`,title:`${n.label}: ${n.cost}`,onMouseEnter:e=>i(e,n),onMouseMove:e=>i(e,n),onMouseLeave:a,style:{height:`${t}px`,background:Cn(0)},"data-usage-series-segment-label":n.label,"data-usage-fallback-segment":`true`})}return s.length===0?null:(0,K.jsx)(`div`,{className:`flex w-full flex-col-reverse overflow-hidden rounded-sm`,style:{height:`${t}px`},"data-usage-series-stack":e.bucketId,children:s.map(({item:n,value:r})=>{let o={label:n.label,bucketLabel:wn(e),cost:Gt(r.totalEstimatedCostUsd)};return(0,K.jsx)(`div`,{title:`${o.label}: ${o.cost}`,onMouseEnter:e=>i(e,o),onMouseMove:e=>i(e,o),onMouseLeave:a,style:{height:`${Math.max(hn,t*r.totalEstimatedCostUsd/Math.max(e.totalEstimatedCostUsd,gn))}px`,background:Cn(n.colorIndex)},"data-usage-series-segment":n.seriesKey,"data-usage-series-segment-label":n.label,"data-usage-series-color-index":n.colorIndex},n.seriesKey)})})}function kn({tooltip:e}){return(0,K.jsxs)(`div`,{className:`pointer-events-none fixed z-50 max-w-[220px] rounded-md border px-2 py-1 shadow-xl`,style:{left:`${e.x}px`,top:`${e.y}px`,background:`var(--surface-overlay, var(--surface-lift))`,borderColor:`var(--border-base)`},"aria-hidden":`true`,children:[(0,K.jsx)(`div`,{className:`truncate text-body-small-default`,style:{color:`var(--content-default)`},children:e.label}),(0,K.jsxs)(`div`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[e.bucketLabel,` · `,e.cost]})]})}function An({items:e}){return(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pt-1`,children:e.map(e=>{let t=e.state??`active`,n=t===`inactive`;return(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,"data-usage-legend-state":t,children:[(0,K.jsx)(`span`,{className:`h-[7px] w-[7px] shrink-0 rounded-full`,style:{background:n?`var(--content-tertiary)`:Cn(e.colorIndex),opacity:n?.45:1},"aria-hidden":`true`,"data-usage-series-color-index":e.colorIndex}),(0,K.jsx)(`span`,{className:n?`truncate text-[10px] line-through`:`truncate text-[10px]`,style:{color:`var(--content-tertiary)`,opacity:n?.65:1},children:e.label})]},e.seriesKey)})})}function jn({title:e,subtitle:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-md py-12 text-center`,style:{color:`var(--content-tertiary)`},children:[(0,K.jsx)(`p`,{className:`text-body-medium-default`,style:{color:`var(--content-secondary)`},children:e}),(0,K.jsx)(`p`,{className:`mt-1 text-body-small-default`,children:t})]})}function Mn(e){return Yt(e)?Xt(e):e}function Nn(e){return Ln({from:e.from,to:e.to},e.scheduleId)}function Pn(e){return Ln({from:e.from,to:e.to,...e.granularity?{granularity:e.granularity}:{},...e.tz?{tz:e.tz}:{}},e.scheduleId)}function Fn(e){return Ln({from:e.from,to:e.to,groupBy:Mn(e.groupBy)},e.scheduleId)}function In(e){return Ln({from:e.from,to:e.to,granularity:e.granularity,groupBy:Mn(e.groupBy),...e.tz?{tz:e.tz}:{}},e.scheduleId)}function Ln(e,t){return t?{...e,scheduleId:t}:e}function Rn(e){return[`${q(e.totalInputTokens)} direct`,`${q(e.totalCacheCreationTokens)} cache created`,`${q(e.totalCacheReadTokens)} cache read`,`${q(e.totalOutputTokens)} out`].join(` / `)}function zn(e){return!Number.isFinite(e)||e===0?`0`:e>=1e6||e>=999950&&e<1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toLocaleString()}function Bn(e){return`${zn(e.totalInputTokens+e.totalCacheCreationTokens+e.totalCacheReadTokens)} in / ${zn(e.totalOutputTokens)} out`}var Vn=`task`,Hn=`model`,Un=new Set([400,404,422]),Wn=3,Gn=new Set([`today`,`yesterday`,`7d`,`30d`,`90d`,`all`]),Kn=new Set([`actor`,`provider`,`model`,`conversation`,`task`,`profile`,`schedule`]),qn={task:qt.task,profile:qt.profile,model:qt.model,provider:`Provider`,actor:`Actor`,conversation:`Conversation`,schedule:`Schedule`},Jn=[{value:`task`,label:qn.task},{value:`profile`,label:qn.profile},{value:`model`,label:qn.model},{value:`provider`,label:qn.provider},{value:`schedule`,label:qn.schedule},{value:`conversation`,label:qn.conversation}];function Yn(e){let t=e.get(`range`),n=e.get(`groupBy`),r=$n(n)?n:Vn;return{range:Qn(t)?t:`7d`,groupBy:r,scheduleId:r===`schedule`?Xn(e):void 0}}function Xn(e){let t=e.get(`scheduleId`);if(!(!t||t.trim().length===0))return t}function Zn(e,t){let n=new URLSearchParams(e);return t.range!==void 0&&n.set(`range`,t.range),t.groupBy!==void 0&&n.set(`groupBy`,t.groupBy),t.scheduleId!==void 0&&(t.scheduleId===null||t.scheduleId.trim().length===0?n.delete(`scheduleId`):n.set(`scheduleId`,t.scheduleId)),n.get(`groupBy`)!==`schedule`&&n.delete(`scheduleId`),n}function Qn(e){return e!=null&&Gn.has(e)}function $n(e){return e!=null&&Kn.has(e)}function er(e){return e!==`conversation`}function tr(e,t){return e!==`task`&&e!==`profile`?!1:rr(t)}function nr(e,t){return!rr(t)&&e<Wn}function rr(e){return e instanceof he&&Un.has(e.status)}function ir(e,t){let n=e===`hourly`?`Hourly Trend`:`Daily Trend`;return!t||t===`conversation`?n:`${n} by ${qn[t]}`}function ar({requestedGranularity:e,isLoading:t,buckets:n}){return e===`hourly`&&(t||!n||n.length===0||n.some(or))?`hourly`:`daily`}function or(e){return e.bucketId.includes(`|`)||sr(e.date)}function sr(e){return/^\d{4}-\d{2}-\d{2} ([01]\d|2[0-3]):00$/.test(e)}function cr(e,t,n=Date.now()){return yt(e,t,n)}function lr(e){return e===`today`||e===`yesterday`?`hourly`:`daily`}function ur({prompt:e,children:t,variant:n=`outlined`,size:r=`regular`,className:a}){let o=s(),c=(0,G.useCallback)(()=>{ot(o,{prompt:e})},[o,e]);return(0,K.jsx)(i,{variant:n,size:r,leftIcon:(0,K.jsx)(re,{}),onClick:c,className:a,children:t})}var dr=[{value:`today`,label:`Today`},{value:`yesterday`,label:`Yesterday`},{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`},{value:`90d`,label:`Last 90 days`},{value:`all`,label:`All time`}],fr=300*1e3,pr=[`Please load the llm-cost-optimizer skill.`,`Analyze my recent LLM usage and explain the biggest cost contributors by call site, model, and profile.`,`Check my current llm.default, llm.callSites, and llm.profiles.`,`Give me a concise summary of what is driving cost and what you would optimize first.`,`Do not change config yet.`].join(` `),mr=[`Please load the llm-cost-optimizer skill.`,`Analyze my recent LLM usage and current LLM config, then recommend the safest cost-optimization changes.`,`If changes are clearly safe, show me the exact config commands you would run and ask for confirmation before applying them.`].join(` `);function hr({assistantId:e}){let[t,n]=o(),{range:r,groupBy:i,scheduleId:a}=(0,G.useMemo)(()=>Yn(t),[t]),s=st(),c=(0,G.useCallback)(e=>{n(t=>Zn(t,e),{replace:!0})},[n]),u=(0,G.useMemo)(()=>cr(r,s),[r,s]),d=(0,G.useMemo)(()=>lr(r),[r]),f=l({queryKey:me({path:{assistant_id:e}}),queryFn:()=>gt(e),staleTime:1e4}),p=(0,G.useCallback)(e=>{c({range:e})},[c]),m=l({...de({path:{assistant_id:e},query:Nn({from:u.from,to:u.to,scheduleId:a})})}),h=l({queryKey:ce({path:{assistant_id:e},query:Fn({from:u.from,to:u.to,groupBy:i,scheduleId:a})}),queryFn:async({signal:t})=>{try{let{data:n}=await se({path:{assistant_id:e},query:Fn({from:u.from,to:u.to,groupBy:i,scheduleId:a}),signal:t,throwOnError:!0});return{groupBy:i,response:n}}catch(n){if(!tr(i,n))throw n;let{data:r}=await se({path:{assistant_id:e},query:Fn({from:u.from,to:u.to,groupBy:Hn,scheduleId:a}),signal:t,throwOnError:!0});return{groupBy:Hn,response:r}}},retry:nr}),g=h.data?.groupBy??i,_=er(g)?g:void 0,v=l({...ue({path:{assistant_id:e},query:In({from:u.from,to:u.to,granularity:d,groupBy:_??`actor`,tz:s,scheduleId:a})}),enabled:!!_,retry:nr}),y=l({...le({path:{assistant_id:e},query:Pn({from:u.from,to:u.to,granularity:d,tz:s,scheduleId:a})}),enabled:!_||v.isError}),b=l({...pe({path:{assistant_id:e}}),enabled:g===`task`,staleTime:1/0}),x=l({...fe({path:{assistant_id:e}}),select:bt,enabled:g===`profile`,staleTime:fr}),S=(0,G.useMemo)(()=>({callSites:Wt(b.data),profiles:x.data??{}}),[b.data,x.data]),C=(0,G.useMemo)(()=>{let e=h.data;if(e)return $t(e.response.breakdown,e.groupBy,S)},[h.data,S]),w=(0,G.useMemo)(()=>{if(!(!_||!v.data))return sn(v.data.buckets,_,S)},[v.data,_,S]),T=(0,G.useMemo)(()=>{if(y.data)return on(y.data.buckets)},[y.data]),E=(0,G.useMemo)(()=>_?v.error?T?{isLoading:!1,error:null,data:T,refetch:y.refetch}:{isLoading:y.isLoading||!T&&!y.error,error:y.error??v.error,data:void 0,refetch:y.error?y.refetch:v.refetch}:{isLoading:v.isLoading,error:v.error,data:w,refetch:v.refetch}:{isLoading:y.isLoading,error:y.error,data:T,refetch:y.refetch},[T,y.error,y.isLoading,y.refetch,w,_,v.error,v.isLoading,v.refetch]),D=ar({requestedGranularity:d,isLoading:E.isLoading,buckets:E.data}),O=D===`hourly`,k=_&&v.error?void 0:g,A=(0,G.useMemo)(()=>{if(!(g!==`schedule`||!a))return gr(f.data,a)},[g,a,f.data]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsx)(`h3`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:`Usage`}),(0,K.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,K.jsx)(yr,{range:r,onChange:p})})]}),(0,K.jsx)(`section`,{"aria-label":`Totals`,children:(0,K.jsx)(xr,{query:m,skeleton:(0,K.jsx)(wr,{}),render:e=>(0,K.jsx)(Sr,{totals:e})})}),(0,K.jsx)(br,{title:`Inference Usage`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsx)(`h4`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:ir(D,k)}),(0,K.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,K.jsx)(Tr,{value:g,onChange:e=>{e===i&&g!==i&&(h.refetch(),v.refetch()),c({groupBy:e,scheduleId:e===`schedule`?void 0:null})}})})]}),(0,K.jsx)(xr,{query:E,skeleton:(0,K.jsx)(Dn,{isHourly:O}),render:e=>(0,K.jsx)(En,{buckets:e,isHourly:O,legendItems:A})})]})}),(0,K.jsx)(Er,{query:h,groups:C}),(0,K.jsx)(vr,{})]})}function gr(e,t){let n=e??[];return[...n.some(e=>e.id===t)?[]:[{id:t,label:_r(t)}],...n.map(e=>({id:e.id,label:e.name||e.id}))].map((e,n)=>({seriesKey:rn(e.id,`schedule`),label:e.label,colorIndex:n,state:e.id===t?`active`:`inactive`}))}function _r(e){return`Unknown schedule (${e})`}function vr(){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(`div`,{className:`h-px w-full`,style:{background:`linear-gradient(to right, transparent, var(--border-base), transparent)`}}),(0,K.jsx)(br,{title:`Cost assistant`,subtitle:`Review recent spend and tune model profile choices.`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md px-3 py-3 sm:flex-row sm:items-center`,children:[(0,K.jsx)(ur,{prompt:pr,children:`Analyze costs with assistant`}),(0,K.jsx)(ur,{prompt:mr,variant:`ghost`,children:`Optimize settings`})]})})]})}function yr({range:e,onChange:t}){return(0,K.jsx)(`div`,{className:`flex items-center`,children:(0,K.jsx)(H,{value:e,onChange:t,options:dr.map(e=>({value:e.value,label:e.label}))})})}function br({title:e,subtitle:t,children:n}){return(0,K.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-md border px-4 py-4`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`h3`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),t?(0,K.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:t}):null]}),n]})}function xr({query:e,skeleton:t,render:n}){return e.isLoading?(0,K.jsx)(K.Fragment,{children:t}):e.error?(0,K.jsx)(jr,{message:e.error instanceof Error?e.error.message:`Failed to load usage.`,onRetry:()=>e.refetch()}):e.data?(0,K.jsx)(K.Fragment,{children:n(e.data)}):(0,K.jsx)(K.Fragment,{children:t})}function Sr({totals:e}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{style:{fontSize:`30px`,fontWeight:600,lineHeight:1,color:`var(--content-default)`},children:Gt(e.totalEstimatedCostUsd)}),(0,K.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-secondary)`},children:`Cost`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:q(e.eventCount)}),(0,K.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-secondary)`},children:`LLM Calls`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,K.jsx)(Cr,{label:`Direct Input Tokens`,value:q(e.totalInputTokens)}),(0,K.jsx)(Cr,{label:`Output Tokens`,value:q(e.totalOutputTokens)}),(0,K.jsx)(Cr,{label:`Cache Created`,value:q(e.totalCacheCreationTokens)}),(0,K.jsx)(Cr,{label:`Cache Read`,value:q(e.totalCacheReadTokens)})]})]})}function Cr({label:e,value:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-3 py-2`,style:{background:`color-mix(in srgb, var(--border-base) 15%, transparent)`},children:[(0,K.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-default)`},children:t}),(0,K.jsx)(`span`,{className:`text-label-medium-default`,style:{color:`var(--content-tertiary)`},children:e})]})}function wr(){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":`true`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(J,{width:140,height:30}),(0,K.jsx)(J,{width:90,height:12})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(J,{width:60,height:16}),(0,K.jsx)(J,{width:60,height:12})]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:Array.from({length:4}).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-3 py-2`,style:{background:`color-mix(in srgb, var(--border-base) 15%, transparent)`},children:[(0,K.jsx)(J,{width:`50%`,height:12}),(0,K.jsx)(J,{width:`70%`,height:11})]},t))})]})}function Tr({value:e,onChange:t}){return(0,K.jsx)(`div`,{className:`flex items-center`,children:(0,K.jsx)(H,{value:e,onChange:t,menuAlign:`end`,menuMinWidth:196,options:Jn.map(e=>({value:e.value,label:e.label}))})})}function Er({query:e,groups:t}){let[n,r]=(0,G.useState)(new Set),i=e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,K.jsx)(br,{title:`Breakdown`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(Dr,{label:`% of total`,active:n.has(`pct`),onClick:()=>i(`pct`)}),(0,K.jsx)(Dr,{label:`Tokens`,active:n.has(`tokens`),onClick:()=>i(`tokens`)}),(0,K.jsx)(Dr,{label:`Turns`,active:n.has(`turns`),onClick:()=>i(`turns`)})]}),(0,K.jsx)(xr,{query:e,skeleton:(0,K.jsx)(kr,{}),render:e=>(0,K.jsx)(Or,{groups:t??e.response.breakdown,showPct:n.has(`pct`),showTokens:n.has(`tokens`),showTurns:n.has(`turns`)})})]})})}function Dr({label:e,active:t,onClick:n}){return(0,K.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-full border px-2.5 py-1 text-label-medium-default`,style:{borderColor:t?`var(--content-secondary)`:`var(--border-base)`,background:t?`color-mix(in srgb, var(--content-secondary) 15%, transparent)`:`transparent`,color:t?`var(--content-default)`:`var(--content-tertiary)`},children:e})}function Or({groups:e,showPct:t,showTokens:n,showTurns:r}){if(e.length===0)return(0,K.jsx)(Ar,{title:`No breakdown data`,subtitle:`No usage recorded for this grouping`});let i=e.reduce((e,t)=>e+t.totalEstimatedCostUsd,0);return(0,K.jsx)(`div`,{className:`overflow-hidden rounded-md`,children:(0,K.jsxs)(`table`,{className:`w-full table-fixed`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{style:{borderBottom:`1px solid var(--border-base)`},children:[(0,K.jsx)(`th`,{className:`px-3 py-2.5 text-left text-label-medium-default`,style:{color:`var(--content-tertiary)`},children:`Group`}),n?(0,K.jsx)(`th`,{className:`px-3 py-2.5 text-left text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`35%`},children:`Tokens`}):null,r?(0,K.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`72px`},children:`Turns`}):null,t?(0,K.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`64px`},children:`%`}):null,(0,K.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`100px`},children:`Cost`})]})}),(0,K.jsx)(`tbody`,{children:e.map((e,a)=>{let o=Rn(e),s=Bn(e),c=i>0?Math.round(e.totalEstimatedCostUsd/i*100):0;return(0,K.jsxs)(`tr`,{style:{borderTop:a===0?`none`:`1px solid var(--border-base)`},children:[(0,K.jsx)(`td`,{className:`min-w-0 px-3 py-2`,style:{color:`var(--content-default)`},children:(0,K.jsx)(`span`,{className:`block truncate text-body-medium-lighter`,title:e.group,children:e.group})}),n?(0,K.jsx)(`td`,{className:`min-w-0 px-3 py-2`,style:{color:`var(--content-secondary)`},children:(0,K.jsx)(`span`,{className:`block truncate text-body-small-default`,title:o,children:s})}):null,r?(0,K.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,K.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e.turnCount==null?`—`:e.turnCount.toLocaleString()})}):null,t?(0,K.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,K.jsxs)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[c,`%`]})}):null,(0,K.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,K.jsx)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-default)`},children:Gt(e.totalEstimatedCostUsd)})})]},e.groupKey??e.groupId??`${e.group}-${a}`)})})]})})}function kr(){return(0,K.jsx)(`div`,{className:`flex flex-col gap-2`,"aria-hidden":`true`,children:Array.from({length:4}).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(J,{width:100,height:14}),(0,K.jsx)(J,{width:`60%`,height:12}),(0,K.jsx)(J,{width:50,height:14})]},t))})}function J({width:e,height:t}){return(0,K.jsx)(`div`,{className:`rounded-sm`,style:{width:typeof e==`number`?`${e}px`:e,height:`${t}px`,background:`color-mix(in srgb, var(--border-base) 40%, transparent)`}})}function Ar({title:e,subtitle:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1 py-8 text-center`,children:[(0,K.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),(0,K.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:t})]})}function jr({message:e,onRetry:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(ie,{className:`h-4 w-4 shrink-0`,style:{color:`var(--system-negative-strong, #f87171)`}}),(0,K.jsx)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-default)`},children:e})]}),t?(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`self-start rounded-md border px-3 py-1 text-body-small-default`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`,color:`var(--content-default)`},children:`Retry`}):null]})}var Mr=`billing-portal-return-snapshot`;function Nr(e){try{sessionStorage.removeItem(Mr),sessionStorage.setItem(Mr,JSON.stringify(e))}catch{}}function Pr(){if(typeof sessionStorage>`u`)return null;try{let e=sessionStorage.getItem(Mr);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 Fr(){try{sessionStorage.removeItem(Mr)}catch{}}function Ir(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 Lr(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function Rr(e){return e?e.cancel_at??e.current_period_end??null:null}function zr(e){let t=c();return(0,G.useEffect)(()=>ve(()=>{t.invalidateQueries(He())}),[t]),Ce({onSuccess:t=>{e&&Nr(e),ye(t.portal_url)},onError:()=>{V.error(`Couldn't open the billing portal. Please try again.`,{id:`billing-portal-session-error`})}})}function Br(e){let t=e/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}function Y(e){return`${Br(e)}/mo`}function Vr(e){return`${e>0?`+`:`−`}${Br(Math.abs(e))}/mo`}var Hr={medium:`Medium`,large:`Large`,xl:`XL`};function Ur(e){return e.disabled===!0}function Wr({machineTiers:e,storageTiers:t,selectedMachineTier:n,selectedStorageTier:r,onMachineTierChange:i,onStorageTierChange:a,currentMachinePriceCents:o,currentStoragePriceCents:s}){let c=(0,G.useMemo)(()=>e.map(e=>{let t=Hr[e.tier]??e.label,n=o==null?`+${Y(e.price_cents)}`:e.price_cents===o?`(${Y(e.price_cents)}, current)`:Vr(e.price_cents-o);return{value:e.tier,label:`${t} ${n}`,disabled:Ur(e)}}),[e,o]),l=(0,G.useMemo)(()=>t.map(e=>{let t=s==null?`+${Y(e.price_cents)}`:e.price_cents===s?`(${Y(e.price_cents)}, current)`:Vr(e.price_cents-s);return{value:e.tier,label:`${e.storage_gib} GiB ${t}`,disabled:Ur(e)}}),[t,s]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(f,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Machine`}),(0,K.jsx)(`span`,{title:`Determines the CPU and memory allocated to your assistant`,children:(0,K.jsx)(A,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(H,{"aria-label":`Machine tier`,placeholder:`Select a machine tier`,value:n??``,onChange:i,options:c})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(f,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Storage`}),(0,K.jsx)(`span`,{title:`Persistent disk space for your assistant's files and data`,children:(0,K.jsx)(A,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(H,{"aria-label":`Storage tier`,placeholder:`Select a storage tier`,value:r??``,onChange:a,options:l})]})]})}var Gr=new Set([`active`,`trialing`,`past_due`]),Kr=[`target_plan_id`,`confirm`,`machine_tier`,`storage_tier`,`credit_tier`,`non_field_errors`];function qr(e,t){if(e&&typeof e==`object`){for(let t of Kr)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 Jr(e,t){let n=e.filter(e=>!Ur(e));return t!==null&&n.some(e=>e.tier===t)?t:n[0]?.tier??null}function Yr(e,t,n){return t===void 0?n:t!==null&&(t===n||e.some(e=>e.tier===t))?t:null}function Xr(e){return e.length?Math.min(...e.map(e=>e.price_cents)):0}function Zr({open:e,onCancel:t,onConfirm:n,confirming:r,lostFeatures:a}){return(0,K.jsx)(B.Root,{open:e,onOpenChange:e=>{!e&&!r&&t()},children:(0,K.jsxs)(B.Content,{size:`md`,hideCloseButton:!0,children:[(0,K.jsx)(B.Header,{children:(0,K.jsx)(B.Title,{icon:ie,children:`Downgrade to Base?`})}),(0,K.jsxs)(B.Body,{children:[(0,K.jsx)(f,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,K.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:a.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(f,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,K.jsxs)(B.Footer,{children:[(0,K.jsx)(i,{variant:`outlined`,onClick:t,disabled:r,children:`Keep Pro`}),(0,K.jsx)(i,{variant:`danger`,onClick:n,disabled:r,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]})})}var Qr=`__none__`;function $r(e){return`${e.label} — ${Y(e.price_cents)}`}function ei({creditTiers:e,selectedCreditTier:t,onCreditTierChange:n,disabled:r=!1}){let i=(0,G.useMemo)(()=>[{value:Qr,label:`No credit bundle — ${Y(0)}`},...e.map(e=>({value:e.tier,label:$r(e)}))],[e]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(f,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Credit bundle`}),(0,K.jsx)(`span`,{title:`A monthly allotment of credits added to your Pro Plan subscription`,children:(0,K.jsx)(A,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(H,{"aria-label":`Credit bundle`,placeholder:`Select a credit bundle`,disabled:r,value:t??Qr,onChange:e=>n(e===Qr?null:e),options:i})]})}function ti({features:e,variant:t,header:n,maxInline:r=3}){return t===`inline`?(0,K.jsx)(K.Fragment,{children:e.slice(0,r).join(`, `)}):(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n&&(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-secondary)]`,children:n}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,K.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(y,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,K.jsx)(f,{as:`span`,variant:`body-medium-default`,children:e})]},e))})]})}function ni({plan:e,isCurrent:t,onPro:n,cancelAtPeriodEnd:r,isCanceled:a,cancelDate:o,formatGraceDate:s,proTierChangeMode:c,creditTiersEnabled:l,creditTiers:u,displayCreditTier:d,onCreditTierChange:m,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:_,onStorageTierChange:v,machineTiersForPicker:y,storageTiersForPicker:b,currentMachinePrice:x,currentStoragePrice:S,currentCreditPriceUnknown:C,proCurrentTotalCents:T,proLiveTotalCents:E,proTotalDelta:D,onboardingLoading:O,tierChangePending:k,machineChanged:M,storageChanged:ee,creditChanged:te,tierChangeError:N,upgradePending:P,portalPending:ne,onUpgrade:re,onApplyTierChange:ie,onDowngradeClick:ae,onKeepPlan:I}){let R=e.id===`pro`,z=e.id===`base`,B=R&&n&&r&&!a,V=R&&(!t||t&&c),oe=R&&t&&c;return(0,K.jsxs)(p,{padding:`lg`,className:`flex flex-col bg-[var(--surface-base)]`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)]`,children:R?(0,K.jsx)(w,{className:`h-5 w-5 text-[var(--content-default)]`}):(0,K.jsx)(Et,{className:`h-5 w-5 text-[var(--content-default)]`})}),(0,K.jsxs)(`div`,{className:`flex min-h-6 items-center gap-2`,children:[(0,K.jsx)(f,{as:`h3`,variant:`title-small`,children:e.name}),t&&(0,K.jsx)(L,{tone:`positive`,children:`Current`})]}),(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`-mt-2 text-[var(--content-tertiary)]`,children:z?`All you need for a capable assistant`:`More features, more compute, more storage`}),B&&o&&(0,K.jsxs)(f,{as:`p`,variant:`body-small-default`,className:`text-[var(--system-mid-strong)]`,"data-testid":`modal-cancels-on`,children:[`Your plan ends on `,s(o)]}),(0,K.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:z?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(f,{as:`p`,variant:`title-medium`,children:`Free`}),(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:`Forever`})]}):t&&!(V&&E!=null)&&(T==null||C)?O?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`}),(0,K.jsx)(f,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,K.jsx)(f,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-price-unavailable`,children:`Current plan pricing unavailable`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(f,{as:`p`,variant:`title-medium`,"data-testid":`modal-pro-price`,children:V&&E!=null?(0,K.jsxs)(K.Fragment,{children:[Y(E),D!=null&&D!==0&&(0,K.jsxs)(`span`,{className:`ml-1 text-[var(--content-tertiary)]`,children:[`(`,Vr(D),`)`]})]}):T==null?e.id===`pro`?`From ${Y(e.base_price_cents+Xr(e.machine_tiers)+Xr(e.storage_tiers))}`:null:`Currently ${Y(T)}`}),V&&D!=null&&D!==0&&(0,K.jsx)(`span`,{title:`Your Pro Plan subscription will change from ${Y(T)} to ${Y(E)}.`,children:(0,K.jsx)(A,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),e.id===`pro`&&(0,K.jsxs)(f,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-base-fee`,children:[Br(e.base_price_cents),` base fee`]})]})}),(0,K.jsx)(ti,{features:e.included_features,variant:`checklist`}),R&&!l&&(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-credits-not-included`,children:`*Credits not included`})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex flex-1 flex-col justify-end gap-4`,children:[!t&&R&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,K.jsx)(ei,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:m,disabled:P}),(0,K.jsx)(Wr,{machineTiers:y,storageTiers:b,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:_,onStorageTierChange:v}),(0,K.jsx)(i,{variant:`primary`,className:`w-full`,onClick:re,disabled:P||!h||!g,"data-testid":`modal-upgrade-to-pro-button`,children:`Upgrade to Pro`})]}),oe&&(O?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`}),(0,K.jsx)(f,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,K.jsx)(ei,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:m,disabled:k}),(0,K.jsx)(Wr,{machineTiers:y,storageTiers:b,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:_,onStorageTierChange:v,currentMachinePriceCents:x,currentStoragePriceCents:S}),N&&(0,K.jsx)(F,{tone:`error`,children:N}),(0,K.jsx)(i,{variant:`primary`,className:`w-full`,onClick:ie,disabled:k||!M&&!ee&&!te,"data-testid":`modal-change-tier-button`,children:`Update Plan`})]})),!t&&z&&n&&!r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,K.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:ae,disabled:ne,"data-testid":`modal-downgrade-to-base-button`,children:`Downgrade to Base`})]}),B&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,K.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:I,disabled:ne,"data-testid":`modal-keep-plan-button`,children:`Keep your Plan`})]})]})]})}function ri({open:e,onClose:t,onTierUpgraded:n}){let r=c(),a=l(Pe()),o=l(He()),s=u(We()),d=u(be()),p=u(Ve()),m=u(ke()),g=zr(Ir(o.data)),[_,v]=(0,G.useState)(`plans`),[y,b]=(0,G.useState)(!1),[x,S]=(0,G.useState)(null),[C,w]=(0,G.useState)(null),[T,E]=(0,G.useState)(void 0);(0,G.useEffect)(()=>ve(()=>{r.invalidateQueries({queryKey:Le()}),r.invalidateQueries({queryKey:Ie()}),r.invalidateQueries({queryKey:qe()}),t()}),[r,t]);let D=o.data?.plan_id,O=D===`pro`,k=l({...Ue(),enabled:O}),A=k.data?.max_machine_tier??null,M=k.data?.selected_storage_tier??null,ee=k.data?.selected_storage_gib??null,te=o.data?.cancel_at_period_end===!0||!!o.data?.cancel_at,N=o.data?.status===`canceled`,P=Rr(o.data),ne=o.data?.status,re=ne!=null&&Gr.has(ne),ae=O&&re&&!te&&!N,I=a.data?.plans.find(e=>e.id===`pro`),L=I?.credit_tiers??[],R=L.length>0,z=o.data?.selected_credit_tier??null,oe=e=>L.find(t=>t.tier===e)?.price_cents??0,H=oe(z),se=z!=null&&!L.some(e=>e.tier===z),ce=T===void 0?z:T,le=oe(ce),ue=I?.machine_tiers??[],de=ae&&ee!=null?(I?.storage_tiers??[]).map(e=>e.storage_gib<ee?{...e,disabled:!0}:e):I?.storage_tiers??[];(0,G.useEffect)(()=>{if(!e){S(null),w(null),E(void 0);return}if(I){if(ae){if(A==null||M==null)return;S(e=>Jr(ue,e??A)),w(e=>Jr(de,e??M)),E(e=>Yr(L,e,z));return}S(e=>Jr(I.machine_tiers,e)),w(e=>Jr(I.storage_tiers,e)),E(e=>Yr(L,e,null))}},[e,I,ae,A,M,z]);let fe=a.data?.plans.find(e=>e.id===`base`),pe=new Set(fe?.included_features??[]),me=(I?.included_features??[]).filter(e=>!pe.has(e)),he=()=>{if(!s.isPending){if(!x||!C){V.error(`Pick a machine and storage tier to continue.`,{id:`pro-upgrade-error`});return}s.mutate({body:{target_plan_id:`pro`,confirm:!0,machine_tier:x,storage_tier:C,credit_tier:ce}},{onSuccess:e=>{if(e.checkout_url){ye(e.checkout_url);return}if(e.status===`no_op`){V.info(`You're already on Pro.`,{id:`pro-upgrade`}),t();return}V.error(e.message??`Failed to start upgrade. Please try again.`,{id:`pro-upgrade-error`})},onError:e=>{V.error(qr(e,`Failed to start upgrade. Please try again.`),{id:`pro-upgrade-error`})}})}},ge=()=>{g.isPending||(v(`plans`),g.mutate({}))},_e=()=>{r.invalidateQueries({queryKey:Le()}),r.invalidateQueries({queryKey:qe()}),r.invalidateQueries({queryKey:Ie()})},U=d.isPending||p.isPending||m.isPending,W=x!=null&&x!==A,xe=C!=null&&C!==M,Se=R&&T!==void 0&&T!==z,Ce=e=>ue.find(t=>t.tier===e)?.price_cents??null,we=e=>de.find(t=>t.tier===e)?.price_cents??null,Te=Ce(x),Ee=we(C),De=Ce(A),Oe=we(M),Ae=W&&Te!=null&&De!=null&&Te<De,je=()=>{if(U)return;let e=[];W&&x&&e.push(new Promise(e=>{d.mutate({body:{machine_tier:x}},{onSuccess:()=>e({dimension:`machine`,ok:!0}),onError:t=>e({dimension:`machine`,ok:!1,error:t})})})),xe&&C&&e.push(new Promise(e=>{p.mutate({body:{storage_tier:C}},{onSuccess:()=>e({dimension:`storage`,ok:!0}),onError:t=>e({dimension:`storage`,ok:!1,error:t})})})),Se&&e.push(new Promise(e=>{m.mutate({body:{credit_tier:ce}},{onSuccess:()=>e({dimension:`credit`,ok:!0}),onError:t=>e({dimension:`credit`,ok:!1,error:t})})})),Promise.all(e).then(e=>{_e();let r=e.some(e=>e.ok&&e.dimension===`storage`),i=e.some(e=>e.ok&&e.dimension===`machine`)&&!Ae,a=(r||i)&&!!n,o=e.filter(e=>!e.ok);if(o.length>0){let e=o.map(e=>qr(e.error,`Failed to update ${e.dimension} tier.`)).join(` `);V.error(e,{id:`pro-tier-change-error`}),a&&(t(),n());return}a?(t(),n()):V.success(Se&&!W&&!xe?`Credit bundle updated.`:`Plan updated.`,{id:`pro-tier-change`})})},Me=()=>{if(!U){if(Ae){b(!0);return}je()}},Ne=()=>{b(!1),je()},Fe=e=>Te!=null&&Ee!=null?e.base_price_cents+Te+Ee+le:null,Re=e=>De!=null&&Oe!=null?e.base_price_cents+De+Oe+H:null,ze=d.isError||p.isError||m.isError?qr(d.error??p.error??m.error,`Failed to update plan. Please try again.`):null,Be=a.isLoading||o.isLoading,Ge=a.isError||o.isError||!a.data||!o.data;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(B.Root,{open:e,onOpenChange:e=>{e||(v(`plans`),t())},children:(0,K.jsx)(B.Content,{size:_===`plans`?`lg`:`md`,children:_===`downgrade-confirm`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(B.Header,{children:(0,K.jsx)(B.Title,{icon:ie,children:`Downgrade to Base?`})}),(0,K.jsxs)(B.Body,{children:[(0,K.jsx)(f,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,K.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:me.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(f,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,K.jsxs)(B.Footer,{children:[(0,K.jsx)(i,{variant:`ghost`,onClick:()=>v(`plans`),disabled:g.isPending,leftIcon:(0,K.jsx)(h,{className:`h-4 w-4`}),children:`Back`}),(0,K.jsx)(i,{variant:`danger`,onClick:ge,disabled:g.isPending,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(B.Header,{children:(0,K.jsx)(B.Title,{className:`sr-only`,children:`Upgrade Plan`})}),(0,K.jsx)(B.Body,{children:Be?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`}),(0,K.jsx)(f,{as:`span`,variant:`body-medium-lighter`,children:`Loading plans...`})]}):Ge?(0,K.jsx)(F,{tone:`error`,children:`Failed to load plans. Please try again later.`}):(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-2 pb-2 pt-4 text-center`,children:[(0,K.jsx)(f,{as:`p`,variant:`title-medium`,children:`Your Assistant, Your Way`}),(0,K.jsx)(f,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-secondary)]`,children:`Choose the plan that works best for you and your assistant.`})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:a.data.plans.map(e=>{let t=e.id===D,n=e.id===`pro`&&I?Fe(I):null,r=e.id===`pro`&&I?Re(I):null;return(0,K.jsx)(ni,{plan:e,isCurrent:t,onPro:O,cancelAtPeriodEnd:te,isCanceled:N,cancelDate:P,formatGraceDate:Lr,proTierChangeMode:ae,creditTiersEnabled:R,creditTiers:L,displayCreditTier:ce,onCreditTierChange:E,selectedMachineTier:x,selectedStorageTier:C,onMachineTierChange:S,onStorageTierChange:w,machineTiersForPicker:ue,storageTiersForPicker:de,currentMachinePrice:De,currentStoragePrice:Oe,currentCreditPriceUnknown:se,proCurrentTotalCents:r,proLiveTotalCents:n,proTotalDelta:n!=null&&r!=null?n-r:null,onboardingLoading:k.isLoading,tierChangePending:U,machineChanged:W,storageChanged:xe,creditChanged:Se,tierChangeError:ze,upgradePending:s.isPending,portalPending:g.isPending,onUpgrade:he,onApplyTierChange:Me,onDowngradeClick:()=>v(`downgrade-confirm`),onKeepPlan:()=>g.mutate({})},e.id)})})]})}),(0,K.jsxs)(B.Footer,{className:`relative items-center`,children:[(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`pointer-events-none absolute inset-x-0 text-center text-[var(--content-tertiary)]`,children:(0,K.jsx)(`span`,{className:`pointer-events-auto`,children:`You can change or cancel your plan at any time from billing settings.`})}),(0,K.jsx)(`div`,{className:`ml-auto`,children:(0,K.jsx)(i,{variant:`outlined`,onClick:t,"data-testid":`modal-cancel-button`,children:`Cancel`})})]})]})})}),(0,K.jsx)(Zr,{open:y,onCancel:()=>b(!1),onConfirm:Ne,confirming:U,lostFeatures:[`Reduced CPU and memory for your assistant — it will resize to the smaller compute profile.`]})]})}var ii={visa:`Visa`,mastercard:`Mastercard`,amex:`Amex`,discover:`Discover`,diners:`Diners Club`,jcb:`JCB`,unionpay:`UnionPay`};function ai(e){return ii[e.toLowerCase()]??e}function oi(e,t){return`${ai(e??`card`)} •••• ${t??`????`}`}function si({open:e,confirming:t,onCancel:n,onConfirm:r}){return(0,K.jsx)(oe,{open:e,title:`Disable automatic top-ups?`,message:`Auto top-ups will stop. Any saved payment method stays on file.`,confirmLabel:t?`Disabling…`:`Disable`,cancelLabel:`Keep enabled`,destructive:!0,onConfirm:r,onCancel:n})}var ci={threshold_usd:`100`,amount_usd:`10`,monthly_cap_usd:``};function li(e){if(e===``||e===`-`)return e;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function ui(e){let t={},n=parseFloat(e.threshold_usd),r=parseFloat(e.amount_usd);if((!Number.isFinite(r)||r<10||r>500)&&(t.amount_usd=`Must be between $10 and $500`),(!Number.isFinite(n)||n<1||n>100)&&(t.threshold_usd=`Must be between $1 and $100`),e.monthly_cap_usd!==``){let n=parseFloat(e.monthly_cap_usd);!Number.isFinite(n)||n<25||n>1e4?t.monthly_cap_usd=`Must be between $25 and $10,000`:Number.isFinite(r)&&n<r&&(t.monthly_cap_usd=`Must be at least the top-up amount`)}return t}function di(e,t,n,r){if(n[e])return n[e];if(r)return t[e]}function fi({initialValues:e=ci,submitting:t,serverErrors:n,onSave:r,onCancel:a}){let[o,s]=(0,G.useState)(e),[c,l]=(0,G.useState)({threshold_usd:!1,amount_usd:!1,monthly_cap_usd:!1}),u=ui(o),d=e=>t=>{s(n=>({...n,[e]:t.target.value}))},f=e=>()=>{l(t=>({...t,[e]:!0})),s(t=>({...t,[e]:li(t[e])}))},p=e=>di(e,u,n,c[e]);return(0,K.jsx)(`div`,{className:`mt-4`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,K.jsx)(R,{type:`number`,step:`1`,label:`Auto-Reload when balance below`,value:o.threshold_usd,onChange:d(`threshold_usd`),onBlur:f(`threshold_usd`),errorText:p(`threshold_usd`),"data-testid":`auto-top-up-threshold-input`,fullWidth:!0})}),(0,K.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,K.jsx)(R,{type:`number`,step:`1`,label:`Add amount when auto reloading`,value:o.amount_usd,onChange:d(`amount_usd`),onBlur:f(`amount_usd`),errorText:p(`amount_usd`),"data-testid":`auto-top-up-amount-input`,fullWidth:!0})}),(0,K.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,K.jsx)(R,{type:`number`,step:`1`,label:`Monthly spending cap`,helperText:`Pauses auto top-ups for the rest of the month once spending reaches this amount. Manual purchases also count toward the total. Leave empty for no limit.`,value:o.monthly_cap_usd,onChange:d(`monthly_cap_usd`),onBlur:f(`monthly_cap_usd`),errorText:p(`monthly_cap_usd`),"data-testid":`auto-top-up-cap-input`,fullWidth:!0})}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-[18px]`,children:[(0,K.jsx)(i,{variant:`outlined`,onClick:a,disabled:t,children:`Cancel`}),(0,K.jsx)(i,{variant:`primary`,onClick:()=>{l({threshold_usd:!0,amount_usd:!0,monthly_cap_usd:!0});let e={threshold_usd:li(o.threshold_usd),amount_usd:li(o.amount_usd),monthly_cap_usd:li(o.monthly_cap_usd)};s(e);let t=ui(e);if(Object.keys(t).length!==0)return;let n=e=>e===``?``:`${parseInt(e,10)}.00`;r({threshold_usd:n(e.threshold_usd),amount_usd:n(e.amount_usd),monthly_cap_usd:e.monthly_cap_usd===``?``:n(e.monthly_cap_usd)})},disabled:t,"data-testid":`auto-top-up-save-button`,children:`Save`})]})]})})}function pi(e){if(!e)return``;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function mi(e){if(!e)return`$0`;let t=parseFloat(e);if(!Number.isFinite(t))return`$0`;let n=Math.abs(t).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2}),r=n.endsWith(`.00`)?n.slice(0,-3):n;return t<0?`-$${r}`:`$${r}`}var hi={enabled:!1,threshold_usd:null,amount_usd:null,monthly_cap_usd:null,has_payment_method:!1,payment_method_brand:null,payment_method_last4:null,stripe_payment_method_updated_at:null,last_charge_at:null,last_failure_at:null,last_failure_reason:null,disabled_due_to_repeated_failures:!1,paused_until:null,current_month_credits_purchased_usd:`0.00`,current_month_charged_usd:`0.00`,next_trigger_amount_usd:null,stubbed:!1};function gi(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&typeof r[0]==`string`&&(t[n]=r[0]);return t}function _i(e){let{brand:t,last4:n}=e;return!t&&!n?null:n?`Charged to ${oi(t,n)}`:`Charged to ${ai(t??`card`)}`}function vi(){let e=c(),t=l(xe()),n=u(Ne()),r=u(Ae()),[a,o]=(0,G.useState)(`view`),[s,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1);if((0,G.useEffect)(()=>{m&&t.data?.has_payment_method&&h(!1)},[m,t.data?.has_payment_method]),t.isLoading)return(0,K.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,K.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Loading…`})});if(t.isError||!t.data)return(0,K.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,K.jsx)(F,{tone:`error`,children:`Failed to load auto top-up configuration.`})});let g=t.data,_=g.enabled===!0,v=g.disabled_due_to_repeated_failures===!0&&!_,y=()=>{n.reset(),r.reset(),o(`form`)},b=()=>{o(`view`),d(!1)},x=()=>{r.reset(),p(!1)},S=t=>{n.mutate({body:{enabled:!0,threshold_usd:t.threshold_usd,amount_usd:t.amount_usd,monthly_cap_usd:t.monthly_cap_usd===``?null:t.monthly_cap_usd}},{onSuccess:t=>{Te(e,void 0,e=>({...t,payment_method_brand:e?.payment_method_brand??null,payment_method_last4:e?.payment_method_last4??null})),e.invalidateQueries({queryKey:Me()}),b()}})},C=()=>{r.mutate({},{onSuccess:()=>{Te(e,void 0,e=>({...hi,has_payment_method:e?.has_payment_method??!1,payment_method_brand:e?.payment_method_brand??null,payment_method_last4:e?.payment_method_last4??null,stripe_payment_method_updated_at:e?.stripe_payment_method_updated_at??null})),p(!1),o(`view`),d(!1)}})},w=e=>{if(e&&!_){if(!g.has_payment_method||v){h(!0);return}h(!1),d(!0),y();return}if(!e&&!_&&s){b();return}!e&&_&&p(!0)},T=a===`form`,E=gi(n.error),D=n.isError&&Object.keys(E).length===0,O=_||s,k=_i({brand:g.payment_method_brand,last4:g.payment_method_last4});return(0,K.jsxs)(`div`,{"data-testid":`auto-top-up-card`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(z,{checked:O,onChange:w,label:`Enable Auto-Reload`}),_&&!T&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`text-right`,children:[(0,K.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-summary`,children:[`Add `,mi(g.amount_usd),` when the balance falls under `,mi(g.threshold_usd)]}),g.monthly_cap_usd!=null&&(0,K.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-cap-progress`,children:[mi(g.current_month_credits_purchased_usd),` of`,` `,mi(g.monthly_cap_usd),` this month`]})]}),(0,K.jsx)(i,{variant:`outlined`,onClick:y,"data-testid":`auto-top-up-edit-button`,children:`Adjust`})]})]}),v&&(0,K.jsx)(F,{tone:`warning`,className:`mt-3`,"data-testid":`auto-top-up-declined-cutoff`,children:`We paused automatic reloads after several declined payments. Add a new payment method below to turn auto-reload back on.`}),(0,K.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-in-out`,style:{gridTemplateRows:m&&!v?`1fr`:`0fr`},children:(0,K.jsx)(`div`,{className:`overflow-hidden`,children:(0,K.jsx)(F,{tone:`warning`,className:`mt-3`,children:`You must first add a Payment Method before you can enable automatic credit reloads.`})})}),D&&(0,K.jsx)(F,{tone:`error`,className:`mt-4`,"data-testid":`auto-top-up-update-error`,children:`Failed to save automatic top-ups. Please try again.`}),r.isError&&(0,K.jsx)(F,{tone:`error`,className:`mt-4`,"data-testid":`auto-top-up-disable-error`,children:`Failed to disable automatic top-ups. Please try again.`}),T&&(0,K.jsx)(fi,{initialValues:_?{threshold_usd:pi(g.threshold_usd),amount_usd:pi(g.amount_usd),monthly_cap_usd:pi(g.monthly_cap_usd)}:void 0,submitting:n.isPending,serverErrors:E,onCancel:b,onSave:S}),_&&!g.has_payment_method&&(0,K.jsx)(F,{tone:`warning`,className:`mt-3`,"data-testid":`auto-top-up-no-pm`,children:`You must add a Payment Method.`}),_&&g.has_payment_method&&(0,K.jsx)(`p`,{className:`mt-3 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-saved-pm`,children:k??`Charged to a saved card`}),(_||T)&&(0,K.jsx)(F,{tone:`info`,className:`mt-4`,children:`If you're too close to your monthly limit, the auto-reload will only top up to that limit.`}),(0,K.jsx)(si,{open:f,confirming:r.isPending,onCancel:x,onConfirm:C})]})}function yi(e){let t=parseFloat(e);return Number.isFinite(t)?`$${t.toFixed(2)}`:`$${e}`}function bi(e){if(e.trim()===``)return;let t=parseFloat(e);if(!Number.isFinite(t)||t<1||t>1e3)return`Must be between $1 and $1,000`;if(!/^\d+(\.\d{1,2})?$/.test(e.trim()))return`Use at most two decimal places`}function xi(){let e=c(),t=l(De()),n=u(Fe()),[r,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(!1);if(t.isLoading)return(0,K.jsx)(`div`,{"data-testid":`low-balance-alert-card`,children:(0,K.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Loading…`})});if(t.isError||!t.data)return(0,K.jsx)(`div`,{"data-testid":`low-balance-alert-card`,children:(0,K.jsx)(F,{tone:`error`,children:`Failed to load low-balance alert settings.`})});let d=t.data,f=r??d.threshold_usd??``,p=bi(f),m=e=>{a(e.target.value)},h=t=>{n.mutate({body:{threshold_usd:t}},{onSuccess:t=>{Ee(e,void 0,t),e.invalidateQueries({queryKey:Ge()}),a(null),s(!1)}})},g=()=>{if(s(!0),p)return;let e=f.trim();h(e===``?null:parseFloat(e).toFixed(2))},_=()=>{a(``),s(!1),h(null)},v=n.isError,y=o?p:void 0;return(0,K.jsxs)(`div`,{"data-testid":`low-balance-alert-card`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`min-w-[12rem] flex-1`,children:(0,K.jsx)(R,{type:`number`,step:`0.01`,label:`Alert me when my balance drops below`,helperText:`Default is ${yi(d.default_threshold_usd)} when unset`,placeholder:d.effective_threshold_usd,value:f,onChange:m,onBlur:()=>s(!0),errorText:y,"data-testid":`low-balance-alert-input`,fullWidth:!0})}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-[18px]`,children:[d.threshold_usd!=null&&(0,K.jsx)(i,{variant:`outlined`,onClick:_,disabled:n.isPending,"data-testid":`low-balance-alert-reset-button`,children:`Reset to default`}),(0,K.jsx)(i,{variant:`primary`,onClick:g,disabled:n.isPending,"data-testid":`low-balance-alert-save-button`,children:`Save`})]})]}),v&&(0,K.jsx)(F,{tone:`error`,className:`mt-4`,"data-testid":`low-balance-alert-update-error`,children:`Failed to save low-balance alert. Please try again.`})]})}var Si=2e3;function Ci(e){let t=parseFloat(e);if(Number.isNaN(t))return`0`;let n=Math.abs(t).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2}),r=n.endsWith(`.00`)?n.slice(0,-3):n;return t<0?`-${r}`:r}function wi(){let e=c(),{data:t,isLoading:n,isError:r}=l(Je()),a=t??null,[o,s]=(0,G.useState)(!1),u=(0,G.useRef)(0),d=(0,G.useRef)(null),m=Se({onSuccess:()=>{e.invalidateQueries({queryKey:ze()})},onError:()=>{u.current<3&&(d.current=setTimeout(()=>{m.reset()},Si))}});(0,G.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let h=m.mutate;(0,G.useEffect)(()=>{a&&a.settled_balance===`0.00`&&a.pending_compute===`0.00`&&a.effective_balance===`0.00`&&u.current<3&&!m.isPending&&!m.isError&&!m.isSuccess&&(u.current+=1,h({}))},[a,m.isPending,m.isError,m.isSuccess,h]);let g=(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(f,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Balance`}),(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`An overview of your credit balance and pending charges.`})]}),(0,K.jsx)(i,{variant:`primary`,onClick:()=>s(!0),disabled:n||!a,"data-testid":`add-credits-button`,children:`Add Credits`})]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(p,{padding:`md`,children:[g,n?(0,K.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`}),`Loading billing summary...`]}):r?(0,K.jsx)(`div`,{className:`mt-4`,children:(0,K.jsx)(F,{tone:`error`,children:`Failed to load billing summary. Please try again later.`})}):a?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`mt-4`,children:(()=>{if(!a)return null;let e=parseFloat(a.effective_balance)<0,t=parseFloat(a.settled_balance)<0,n=parseFloat(a.pending_compute)<0;return(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,K.jsx)(I,{icon:(0,K.jsx)(tt,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,K.jsx)(`span`,{"data-testid":`effective-balance`,children:Ci(a.effective_balance)}),label:`Balance`,tone:e?`negative`:`default`}),(0,K.jsx)(I,{icon:(0,K.jsx)(St,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,K.jsx)(`span`,{"data-testid":`settled-balance`,children:Ci(a.settled_balance)}),label:`Settled Balance`,tone:t?`negative`:`default`}),(0,K.jsx)(I,{icon:(0,K.jsx)(Ct,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,K.jsx)(`span`,{"data-testid":`pending-charges`,children:Ci(a.pending_compute)}),label:a.is_degraded?`Pending Usage (estimated)`:`Pending Usage`,tone:a.is_degraded?`muted`:n?`negative`:`default`})]})})()}),a.is_degraded&&(0,K.jsx)(`div`,{className:`mt-4`,children:(0,K.jsx)(F,{tone:`warning`,children:`Pending charges could not be calculated. The balance shown may be incomplete.`})})]}):(0,K.jsx)(`p`,{className:`mt-4 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No billing information available.`}),(0,K.jsx)(`div`,{className:`mt-6 border-t border-[var(--border-base)] pt-6`,children:(0,K.jsx)(vi,{})}),(0,K.jsx)(`div`,{className:`mt-6 border-t border-[var(--border-base)] pt-6`,children:(0,K.jsx)(xi,{})})]}),(0,K.jsx)(ht,{open:o,onOpenChange:s})]})}var Ti=1e3,Ei=15e3,Di=3e3,Oi=45e3,ki=`billing-portal-return`;function Ai(e,t){if(!e)return{kind:`info`,message:`Subscription updated.`};let n=e.cancel_at_period_end||!!e.cancel_at,r=t.cancel_at_period_end||!!t.cancel_at;return!n&&r?{kind:`info`,message:`Pro plan canceled. You'll have access until ${t.cancel_at?Lr(t.cancel_at):`the end of your billing period`}.`}:n&&!r?{kind:`success`,message:`Pro plan reactivated.`}:{kind:`info`,message:`Subscription updated.`}}function ji(){let[e]=o(),t=s(),n=c(),r=(0,G.useRef)(null);return(0,G.useEffect)(()=>()=>{r.current!==null&&(clearInterval(r.current),r.current=null)},[]),(0,G.useEffect)(()=>{if(e.get(`portal_return`)!==`true`)return;let i={current:!1},a=Pr(),o=He(),s=Le(),c=Date.now();async function l(){await n.invalidateQueries({queryKey:s});let e=await n.fetchQuery(o);return{cancel_at_period_end:e.cancel_at_period_end,cancel_at:e.cancel_at}}async function u(){let e=await l();for(;!i.current&&a&&e.cancel_at_period_end===a.cancel_at_period_end&&e.cancel_at===a.cancel_at&&Date.now()-c<Ei&&(await new Promise(e=>setTimeout(e,Ti)),!i.current);)e=await l();return e}return(async()=>{try{let e=await u();if(i.current)return;let{kind:t,message:n}=Ai(a,e);t===`success`?V.success(n,{id:ki}):V.info(n,{id:ki})}catch{if(i.current)return;V.info(`Subscription updated.`,{id:ki})}finally{if(!i.current){Fr(),t(U.settings.billing,{replace:!0});let e=Date.now();r.current!==null&&clearInterval(r.current),r.current=setInterval(()=>{if(Date.now()-e>=Oi){r.current!==null&&(clearInterval(r.current),r.current=null);return}l().catch(e=>{console.error(`billing poll error:`,e)})},Di)}}})(),()=>{i.current=!0}},[e,t,n]),null}var Mi=[7,30,90].map(e=>({value:`${e}`,label:`Last ${e} days`}));function Ni(e,t=W()){let{fromDate:n,toDate:r}=vt(e,t);return{from:n,to:r}}function Pi(e,t){let n=new Date(e),r=new Date(t);return Math.round((r.getTime()-n.getTime())/864e5)+1}function Fi({from:e,to:t}){let n=Pi(e,t);return n===7?7:n===90?90:30}function Ii({value:e,onChange:t}){let n=st(),r=(0,G.useMemo)(()=>`${Fi(e)}`,[e]);return(0,K.jsx)(H,{options:Mi,value:r,onChange:e=>{let r=Number(e);t(Ni(r,n),r)},"aria-label":`Date range`})}var Li={strokeDasharray:`3 3`,stroke:`var(--border-subtle)`,strokeOpacity:.4},Ri={fontSize:12,fill:`var(--content-tertiary)`},zi={stroke:`var(--border-subtle)`,strokeOpacity:.4},Bi=[`#3b82f6`,`#10b981`,`#f59e0b`,`#ef4444`,`#8b5cf6`,`#06b6d4`,`#ec4899`,`#84cc16`];function Vi({item:e}){return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5 text-[13px] text-[var(--content-default)]`,children:[(0,K.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,K.jsx)(`span`,{children:e.label}),(0,K.jsx)(`span`,{className:`ml-auto tabular-nums`,children:e.value})]})}function Hi({active:e,payload:t,hoveredKey:n,label:r,labelMap:i,colorMap:a,formatValue:o,showTotal:s,formatLabel:c}){if(!e||!t?.length)return null;let l=t.filter(e=>e.value!=null&&e.dataKey!=null).map(e=>({key:String(e.dataKey),label:i[String(e.dataKey)]??String(e.dataKey),value:o(Number(e.value)),color:a[String(e.dataKey)]??`#6b7280`,numericValue:Number(e.value)})).sort((e,t)=>e.numericValue===t.numericValue?e.label.localeCompare(t.label):t.numericValue-e.numericValue),u=n?l.find(e=>e.key===n):null,d=u?l.filter(e=>e.key!==n):l,f=l.reduce((e,t)=>e+t.numericValue,0);return(0,K.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-overlay)] px-3.5 py-2.5 shadow-[var(--shadow-popover)]`,children:[(0,K.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-[var(--content-secondary)]`,children:(c??_t)(String(r))}),u&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Vi,{item:u}),d.length>0&&(0,K.jsx)(`div`,{className:`my-1.5 border-t border-[var(--border-subtle)]`})]}),d.map(e=>(0,K.jsx)(Vi,{item:e},e.key)),s&&(0,K.jsx)(`div`,{className:`mt-1 flex items-center gap-2 border-t border-[var(--border-subtle)] pt-1.5 text-[13px] font-semibold text-[var(--content-default)]`,children:(0,K.jsxs)(`span`,{children:[`Total: `,o(f)]})})]})}function Ui(e,t){let[n,r]=e,[i,a]=t,o=r-n||1;return e=>i+(e-n)/o*(a-i)}function Wi(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t,r;return r=n<=1?1:n<=2?2:n<=2.5?2.5:n<=5?5:10,r*t}function Gi(e){if(e>=1)return+!Number.isInteger(e);let t=e/10**Math.floor(Math.log10(e)),n=Math.abs(t-2.5)<.01;return Math.ceil(-Math.log10(e))+ +!!n}function Ki(e,t){let n=Math.max(0,...e),r=t?.tickCount??5;return n===0?t?.integerOnly?r:1:t?.integerOnly?Math.max(1,Math.ceil(n/r))*r:Wi(n/r)*r}function qi(e,t){if(e===0)return[0];let n=e/t,r=10**(n>=1?0:Math.ceil(-Math.log10(n))+2),i=[];for(let e=0;e<=t;e++)i.push(Math.round(n*e*r)/r);return i}function Ji(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return[`M${e},${t+a}`,`A${a},${a} 0 0 1 ${e+a},${t}`,`H${e+n-a}`,`A${a},${a} 0 0 1 ${e+n},${t+a}`,`V${t+r}`,`H${e}`,`Z`].join(``)}function Yi(e,t){if(e<=0)return[];if(t)return e<=3?Array.from({length:e},(e,t)=>t):[0,Math.floor(e/2),e-1];let n=Math.max(1,Math.ceil(e/Math.min(e,12))),r=[];for(let t=0;t<e;t+=n)r.push(t);return r[r.length-1]!==e-1&&r.push(e-1),r}var Xi=40,Zi={fontSize:11,fill:`var(--content-tertiary)`},Qi={runtime_proxy_api:`#3b82f6`,oauth_proxy:`#f59e0b`};function $i(e,t){return Qi[e]??Bi[t%Bi.length]??`#6b7280`}function ea(e,t){let n=new Set,r={};for(let t of e)for(let e of t.groups)n.add(e.group_key),r[e.group_key]=e.group_label;return{data:e.map(e=>{let n={date:e.date};for(let r of e.groups)n[r.group_key]=t===`spend`?parseFloat(r.total_usd):r.event_count;return n}),stackKeys:Array.from(n),labelMap:r}}function ta({stackKeys:e,labelMap:t}){return(0,K.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-5 gap-y-1 pt-3 text-body-small-default`,children:e.map((e,n)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rounded-sm`,style:{backgroundColor:$i(e,n)}}),(0,K.jsx)(`span`,{className:`text-[var(--content-quiet)]`,children:t[e]??e})]},e))})}var na=350,ra={top:8,right:4,bottom:32,left:0},ia=.2,aa=5,oa=12,sa=200;function ca({buckets:e,metric:t,onBarClick:n}){let r=nt(),i=(0,G.useRef)(null),[a,o]=(0,G.useState)(0);(0,G.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&o(e.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]);let{data:s,stackKeys:c,labelMap:l}=(0,G.useMemo)(()=>ea(e,t),[e,t]),u=(0,G.useMemo)(()=>{let e={};for(let t=0;t<c.length;t++)e[c[t]]=$i(c[t],t);return e},[c]),d=(0,G.useCallback)(e=>t===`spend`?`$${e.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`:e.toLocaleString(`en-US`),[t]),[f,p]=(0,G.useState)(null),m=r?Xi:56,h=r?Zi:Ri,g=ra.left+m,_=Math.max(0,a-g-ra.right),v=ra.top,y=na-ra.top-ra.bottom,b=(0,G.useMemo)(()=>s.map(e=>c.reduce((t,n)=>t+(Number(e[n])||0),0)),[s,c]),x=t===`events`,S=(0,G.useMemo)(()=>Ki(b,{integerOnly:x,tickCount:aa}),[b,x]),C=(0,G.useMemo)(()=>qi(S,aa),[S]),w=(0,G.useCallback)(e=>{if(t===`spend`){if(e===0)return`$0`;let t=S/aa,n=Math.max(t<1?2:0,Gi(t));return`$${e.toLocaleString(`en-US`,{minimumFractionDigits:n,maximumFractionDigits:n})}`}return e.toLocaleString(`en-US`)},[t,S]),T=(0,G.useMemo)(()=>Ui([0,S],[v+y,v]),[S,v,y]),E=s.length,D=E>0?_/E:0,O=D*(1-ia),k=(D-O)/2,A=(0,G.useMemo)(()=>Yi(E,r),[E,r]),j=c.length===0,M=j?[]:s.map((e,t)=>{let n=g+t*D+k,r=0;return{di:t,x:n,segments:c.map((t,i)=>{let a=Number(e[t])||0,o=r;r+=a;let s=T(r),l=T(o)-s,u=i===c.length-1;return{key:t,val:a,x:n,y:s,h:l,color:$i(t,i),isLast:u}})}}),ee=(e,t,n)=>{let r=i.current?.getBoundingClientRect();r&&p({x:e.clientX-r.left,y:e.clientY-r.top,datumIndex:t,hoveredKey:n})},te=()=>p(null),N=e=>{n&&n(e)},P=f?c.filter(e=>(Number(s[f.datumIndex]?.[e])||0)>0).map(e=>({dataKey:e,value:Number(s[f.datumIndex]?.[e])||0})):[],ne={left:f?Math.max(0,Math.min(f.x+oa,a-sa)):0,top:f?f.y-oa:0,visibility:f?`visible`:`hidden`};return(0,K.jsxs)(`div`,{onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`div`,{ref:i,className:`relative w-full`,style:{height:na},children:j?(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center text-body-medium-lighter text-[var(--content-faint)]`,children:`No usage data for this period`}):a>0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`svg`,{width:a,height:na,className:`block`,children:[C.map(e=>(0,K.jsx)(`line`,{x1:g,x2:g+_,y1:T(e),y2:T(e),stroke:Li.stroke,strokeOpacity:Li.strokeOpacity,strokeDasharray:Li.strokeDasharray},e)),(0,K.jsx)(`line`,{x1:g,x2:g+_,y1:v+y,y2:v+y,stroke:zi.stroke,strokeOpacity:zi.strokeOpacity}),C.map(e=>(0,K.jsx)(`text`,{x:g-8,y:T(e),textAnchor:`end`,dominantBaseline:`middle`,fontSize:h.fontSize,fill:h.fill,children:w(e)},e)),A.map(e=>{let t=s[e];return t?(0,K.jsx)(`text`,{x:g+e*D+D/2,y:v+y+20,textAnchor:`middle`,fontSize:h.fontSize,fill:h.fill,children:_t(String(t.date))},e):null}),M.map(({di:e,segments:t})=>t.map(t=>{if(t.h<=0)return null;let r=f?.hoveredKey&&f.hoveredKey!==t.key?.4:1,i={key:`${e}-${t.key}`,fill:t.color,opacity:r,cursor:n?`pointer`:void 0,onMouseMove:n=>ee(n,e,t.key),onMouseLeave:te,onClick:()=>N(t.key)};return t.isLast?(0,K.jsx)(`path`,{...i,d:Ji(t.x,t.y,O,t.h,3)}):(0,K.jsx)(`rect`,{...i,x:t.x,y:t.y,width:O,height:t.h})}))]}),(0,K.jsx)(`div`,{className:`pointer-events-none absolute z-[1] max-w-[calc(100vw-32px)] -translate-y-full`,style:ne,children:(0,K.jsx)(Hi,{active:!!f,payload:P,hoveredKey:f?.hoveredKey??void 0,label:f?String(s[f.datumIndex]?.date):``,labelMap:l,colorMap:u,formatValue:d})})]}):null}),!j&&(0,K.jsx)(ta,{stackKeys:c,labelMap:l})]})}function la(e=W()){return Ni(30,e)}function ua(e){if(e)return e.usageSource===`oauth_proxy`?`oauth_provider`:Zt(e.llmDimension??`model`)}function da(e,t=W()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource,group_by:ua(e.drilldown)}:{}}}function fa(e,t=W()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource}:{}}}function pa(e,t,n){return e===`full`&&t!==`gated`&&n}function ma(e){let t=st(),n=pa(ft({platformHostedOnly:!0}),ft(),ct()),r=l({...Xe({query:da(e,t)}),enabled:n}),i=l({...Be({query:fa(e,t)}),enabled:n});return{series:r.data,totals:i.data,isLoading:r.isLoading||i.isLoading,isError:r.isError||i.isError}}var ha=[{value:`spend`,label:`Spend ($)`},{value:`events`,label:`Events`}];function ga(e){if(e===void 0)return`—`;let t=parseFloat(e);return Number.isNaN(t)?`$0.00`:`$${t.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function _a(e){return e===void 0?`—`:e.toLocaleString(`en-US`)}function va(){let e=st(),[t,n]=(0,G.useState)(30),[r,i]=(0,G.useState)(()=>la(e)),a=(0,G.useMemo)(()=>t===null?r:Ni(t,e),[t,r,e]),o=(e,t)=>{n(t),i(e)},[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(`spend`),{series:d,totals:m,isLoading:g,isError:_}=ma({dateRange:a,setDateRange:e=>{n(null),i(e)},drilldown:s,setDrilldown:c}),v=s?void 0:e=>{let t={runtime_proxy_api:`runtime_proxy`,oauth_proxy:`oauth_proxy`}[e];t&&c({usageSource:t,...t===`runtime_proxy`?{llmDimension:Kt}:{}})};return(0,K.jsx)(p,{padding:`md`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(f,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Usage`}),(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`Overview of your spending habits.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 [&_[role=combobox]]:h-8 [&_[role=radio]]:h-7`,children:[(0,K.jsx)(Ii,{value:a,onChange:o}),(0,K.jsx)(`div`,{className:`w-44`,children:(0,K.jsx)(ae,{items:ha,value:l,onChange:u,ariaLabel:`Chart metric`})})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[(0,K.jsx)(I,{icon:(0,K.jsx)(tt,{className:`h-4 w-4`,"aria-hidden":!0}),value:g?(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):ga(m?.total_usd),label:`Spend`}),(0,K.jsx)(I,{icon:(0,K.jsx)(Tt,{className:`h-4 w-4`,"aria-hidden":!0}),value:g?(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):_a(m?.event_count),label:`Events`})]}),s&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsx)(`div`,{children:(0,K.jsxs)(`button`,{className:`flex items-center gap-1.5 text-body-medium-lighter text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)]`,onClick:()=>c(null),children:[(0,K.jsx)(h,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:`Back to all usage`}),(0,K.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:`/`}),(0,K.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:s.usageSource===`runtime_proxy`?`LLM Spend`:`OAuth Spend`})]})}),s.usageSource===`runtime_proxy`&&(0,K.jsx)(`div`,{className:`w-56`,children:(0,K.jsx)(ae,{items:Jt,value:s.llmDimension??`model`,onChange:e=>c({usageSource:`runtime_proxy`,llmDimension:e}),ariaLabel:`LLM spend dimension`})})]}),g?(0,K.jsx)(`div`,{className:`flex h-[345px] items-center justify-center rounded-xl bg-[var(--surface-base)]`,children:(0,K.jsx)(j,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}):_?(0,K.jsx)(`div`,{className:`flex h-[345px] items-center justify-center rounded-xl bg-[var(--surface-base)] text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Failed to load usage data.`}):d?(0,K.jsx)(`div`,{className:`rounded-xl bg-[var(--surface-base)] p-3`,children:(0,K.jsx)(ca,{buckets:d.buckets,metric:l,onBarClick:v})}):null]})})}function ya(){let{data:e}=l(He()),t=zr((0,G.useMemo)(()=>Ir(e),[e]));if(!e||e.plan_id!==`pro`||e.status===`canceled`||!e.cancel_at_period_end&&!e.cancel_at)return null;let n=Rr(e);return n?(0,K.jsx)(F,{tone:`info`,title:`Your Pro plan will end on ${Lr(n)}.`,actions:(0,K.jsx)(i,{variant:`outlined`,size:`compact`,onClick:()=>t.mutate({}),disabled:t.isPending,leftIcon:t.isPending?(0,K.jsx)(j,{className:`animate-spin`}):void 0,"data-testid":`grace-period-reactivate-button`,children:`Reactivate`}),"data-testid":`grace-period-banner`,children:`You'll keep Pro features until then.`}):null}var ba=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),xa=t(((e,t)=>{var n=ba();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),X=e(t(((e,t)=>{t.exports=xa()()}))(),1);function Sa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ca(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Sa(Object(n),!0).forEach(function(t){Ta(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sa(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wa(e){"@babel/helpers - typeof";return wa=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},wa(e)}function Ta(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ea(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Da(e,t){if(e==null)return{};var n=Ea(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Oa(e,t){return ka(e)||Aa(e,t)||ja(e,t)||Na()}function ka(e){if(Array.isArray(e))return e}function Aa(e,t){var n=e&&(typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`]);if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function ja(e,t){if(e){if(typeof e==`string`)return Ma(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ma(e,t)}}function Ma(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Na(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
import{o as e,t}from"./chunk-jRWAZmH_.js";import{t as n}from"./capture-error-Dhiismgm.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-BQVYX8n_.js";import{t as a}from"./preload-helper-BewR0kVT.js";import{m as o,u as s}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as c}from"./QueryClientProvider-DKhXIxGb.js";import{t as l}from"./useQuery-B45lW1Kk.js";import{t as u}from"./useMutation-Lj4VunQV.js";import{t as d}from"./jsx-runtime-CVSDxk6A.js";import{t as f}from"./typography-Cqi8q9o7.js";import{t as p}from"./card-D8zyWtZh.js";import{t as m}from"./createLucideIcon-Bjb-Kuq7.js";import{t as h}from"./arrow-left-C2re-gYj.js";import{t as g}from"./check-CkQjevXL.js";import{t as _}from"./chevron-down-DwIPfcCg.js";import{t as v}from"./circle-alert-_RJjkRGu.js";import{t as y}from"./circle-check-DWe3QGcN.js";import{n as b,o as x}from"./list-row-spYsDF9a.js";import{t as S}from"./cpu-CEyjQpZz.js";import{t as C}from"./credit-card-BY-vD21O.js";import{n as w,t as T}from"./domain-field-DKKi4dF-.js";import{t as E}from"./download-B6XjnEzx.js";import{t as D}from"./external-link-Cczz6xJ4.js";import{t as O}from"./file-text-DA128T4K.js";import{t as k}from"./hard-drive-BXh9qCfi.js";import{t as A}from"./info-DLFMsCl-.js";import{t as j}from"./loader-circle-C9QrtO3C.js";import{a as M,c as ee,i as te,n as N,r as P,t as ne}from"./resize-errors-yH10K9Qq.js";import{t as re}from"./sparkles-BK3KXCjl.js";import{t as ie}from"./triangle-alert-CnjNKhNx.js";import{t as F}from"./notice-B8UI-BOp.js";import{j as ae,r as I}from"./src-clcV9W6_.js";import{t as L}from"./tag-D0AE0-aA.js";import{t as R}from"./input-6HVXMszw.js";import{t as z}from"./toggle-CWrJ2t4S.js";import{t as B}from"./modal-bIQsMU63.js";import{n as V}from"./toast-CZmbu5xl.js";import{t as oe}from"./confirm-dialog-kE8y7s20.js";import{t as H}from"./dropdown-CuE5AuVj.js";import{Cr as se}from"./sdk.gen-C9GJEKYV.js";import{Ft as ce,It as le,Lt as ue,Rt as de,c as fe,d as pe,ht as me}from"./react-query.gen-CWfp8GEM.js";import{t as he}from"./api-errors-CrWDzVca.js";import{ct as ge,st as _e}from"./sdk.gen-Z7XkRg5O.js";import{c as U}from"./routes-GPGveWZ8.js";import{n as ve,t as ye}from"./browser-804KO6w7.js";import{t as W}from"./effective-timezone-Cp9o8K5B.js";import{$ as be,B as xe,Dt as Se,Et as Ce,G as we,H as Te,J as Ee,K as De,O as Oe,Q as ke,R as Ae,U as je,V as Me,W as Ne,X as Pe,Y as Fe,Z as Ie,at as Le,c as Re,ct as ze,dt as Be,et as Ve,it as He,nt as Ue,ot as We,q as Ge,r as Ke,rt as qe,st as Je,tt as Ye,ut as Xe,wt as Ze,y as Qe,yt as $e,z as et}from"./react-query.gen-B-P32qsC.js";import{Da as tt,Fr as nt,H as rt,Ha as it,Ii as at,Ir as ot,Yn as st,ci as ct,la as lt,li as ut,m as dt,ui as ft,zi as pt}from"./index-CFQIPKjY.js";import{t as mt}from"./use-active-assistant-id-DpxCpOc4.js";import{t as ht}from"./add-credits-modal-ByK3VreF.js";import{t as gt}from"./schedules-CTsHce7J.js";import{i as _t,n as vt,r as yt,t as bt}from"./profile-metadata-VB4MBtgt.js";import{t as xt}from"./environment-store-BX22hkIL.js";var St=m(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),Ct=m(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),wt=m(`party-popper`,[[`path`,{d:`M5.8 11.3 2 22l10.7-3.79`,key:`gwxi1d`}],[`path`,{d:`M4 3h.01`,key:`1vcuye`}],[`path`,{d:`M22 8h.01`,key:`1mrtc2`}],[`path`,{d:`M15 2h.01`,key:`1cjtqr`}],[`path`,{d:`M22 20h.01`,key:`1mrys2`}],[`path`,{d:`m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10`,key:`hbicv8`}],[`path`,{d:`m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17`,key:`1i94pl`}],[`path`,{d:`m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7`,key:`1cofks`}],[`path`,{d:`M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z`,key:`4kbmks`}]]),Tt=m(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Et=m(`tree-palm`,[[`path`,{d:`M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4`,key:`foxbe7`}],[`path`,{d:`M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3`,key:`18arnh`}],[`path`,{d:`M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35`,key:`ywahnh`}],[`path`,{d:`M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14`,key:`ft0feo`}]]),G=e(r(),1),K=d();function Dt({onBack:e}){let t=s(),{data:n}=l(Ke()),r=n?.name||`your assistant`;return(0,K.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(ellipse 60% 50% at 50% 38%, color-mix(in oklab, var(--system-positive-strong) 14%, transparent), transparent)`},"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,K.jsx)(`div`,{className:`absolute h-24 w-24 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 18%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite`},"aria-hidden":`true`}),(0,K.jsx)(`div`,{className:`absolute h-16 w-16 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 12%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite 0.5s`},"aria-hidden":`true`}),(0,K.jsx)(wt,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,K.jsx)(`h1`,{className:`relative mb-2 text-[var(--content-emphasised)]`,style:{fontFamily:`var(--font-serif)`,fontSize:`28px`,lineHeight:1,fontWeight:400,animation:`welcome-reveal 600ms ease-out 150ms both`},children:`You're all set`}),(0,K.jsx)(`p`,{className:`relative mb-6 max-w-[320px] text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`welcome-reveal 600ms ease-out 300ms both`},children:`Your assistant just got a serious upgrade.`}),(0,K.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,K.jsxs)(i,{variant:`primary`,"data-testid":`onboarding-complete-return`,onClick:()=>t(U.assistant,{replace:!0}),children:[`Return to `,r]})}),(0,K.jsx)(`div`,{className:`absolute bottom-4 left-4`,children:(0,K.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-complete-back`,onClick:e,leftIcon:(0,K.jsx)(h,{className:`h-4 w-4`}),children:`Back`})})]})}function Ot({current:e,total:t=2}){return(0,K.jsx)(`div`,{className:`flex items-center justify-center gap-1.5`,children:Array.from({length:t},(t,n)=>(0,K.jsx)(`div`,{className:`h-1.5 rounded-full transition-all duration-300`,style:{width:n===e?20:6,backgroundColor:n<=e?`var(--content-default)`:`var(--border-element)`}},n))})}function kt({icon:e,tone:t=`positive`}){let n=t===`positive`?`--system-positive-strong`:t===`warning`?`--system-mid-strong`:`--system-negative-strong`;return(0,K.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(${n}) 12%, transparent)`},children:(0,K.jsx)(e,{className:`h-5 w-5`,style:{color:`var(${n})`},"aria-hidden":`true`})})}var At=1e3,jt=1e4;function Mt(e){return te[e]??te.medium}var Nt=[`machine_size`,`subdomain`,`non_field_errors`],Pt={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.`};function Ft(e,t){if(e&&typeof e==`object`){let t=e;if(typeof t.error==`string`){let e=Pt[t.error];if(e)return e}for(let e of Nt){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}function It({onBack:e,onExit:t}){let n=c(),r=xt.use.emailRootDomain(),{data:a}=l(Ke()),o=a?.id,{data:s}=l({...Re({path:{assistant_id:o??``}}),enabled:!!o}),d=s?.results?.[0],[p,m]=(0,G.useState)(``),[g,_]=(0,G.useState)(`hi`),[v,y]=(0,G.useState)(!1);(0,G.useEffect)(()=>{if(!v){if(d){m(d.subdomain),y(!0);return}!a?.handle||p||(m(a.handle),y(!0))}},[a?.handle,d,v,p]);let[b,x]=(0,G.useState)(null),[S,C]=(0,G.useState)(!1),w=u(Ye()),E=!!d||S,D=w.isPending||S;return(0,G.useEffect)(()=>{if(!S)return;let e=setTimeout(t,800);return()=>clearTimeout(e)},[S,t]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(B.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,K.jsx)(kt,{icon:lt}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(f,{variant:`title-small`,as:`h1`,children:`Assistant email`}),(0,K.jsx)(f,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Set up an email address for your assistant.`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(f,{variant:`body-small-default`,as:`label`,className:`text-[var(--content-secondary)]`,children:`Email address`}),(0,K.jsx)(T,{subdomain:p,autoFocus:!0,onSubdomainChange:e=>{m(e),b&&x(null)},domainSuffix:r,disabled:D,error:b,locked:E,lockedMessage:`This domain has been set and cannot be changed.`,prefix:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`input`,{value:g,onChange:e=>_(e.target.value.toLowerCase().trim()),disabled:D||E,readOnly:E,placeholder:`hi`,"aria-label":`Email username`,size:Math.max(g.length,2),className:`h-full w-0 min-w-[2ch] flex-none bg-transparent pl-3 pr-1.5 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none disabled:cursor-not-allowed disabled:opacity-60`,style:{width:`${Math.max(g.length,2)+1.5}ch`}}),(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-[var(--content-secondary)]`,children:`@`})]})})]}),!E&&(0,K.jsxs)(F,{tone:`info`,children:[(0,K.jsx)(`span`,{className:`font-mono`,children:p||`<subdomain>`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),S?(0,K.jsx)(F,{tone:`success`,children:`Domain set — redirecting…`}):null]}),(0,K.jsxs)(B.Footer,{className:`relative items-center justify-between`,children:[(0,K.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-back`,disabled:D,onClick:e,leftIcon:(0,K.jsx)(h,{className:`h-4 w-4`}),children:`Back`}),(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,K.jsx)(Ot,{current:0})}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:E?(0,K.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-continue`,onClick:t,children:`Continue`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-skip`,disabled:D,onClick:()=>{D||w.mutate({body:{skipped:!0}},{onSuccess:t,onError:()=>t()})},children:`Do later`}),(0,K.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-set`,disabled:!p||D,onClick:()=>{D||!p||w.mutate({body:{subdomain:p,...g?{email_username:g}:{}}},{onSuccess:()=>{x(null),C(!0),n.invalidateQueries({queryKey:Qe()})},onError:e=>{x(Ft(e,`Couldn't register that subdomain. Try a different one.`))}})},children:`Set domain`})]})})]})]})}function Lt({onGoToBilling:e}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-10 text-center`,children:[(0,K.jsx)(kt,{icon:v,tone:`negative`}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(f,{variant:`title-small`,as:`h1`,children:`Couldn't reach billing`}),(0,K.jsx)(f,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`We hit a problem checking your subscription. Your upgrade may still be processing — return to billing to refresh.`})]}),(0,K.jsx)(i,{variant:`primary`,"data-testid":`onboarding-go-to-billing`,onClick:e,children:`Go to billing`})]})}function Rt({message:e,onRetry:t,onGoToBilling:n}){return(0,K.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,K.jsx)(kt,{icon:v,tone:`warning`}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(f,{variant:`title-small`,as:`h1`,children:`Taking longer than expected`}),(0,K.jsx)(f,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:e})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,K.jsx)(i,{variant:`outlined`,"data-testid":`onboarding-go-to-billing`,onClick:n,children:`Go to billing`}),(0,K.jsx)(i,{variant:`primary`,"data-testid":`onboarding-retry`,onClick:t,children:`Try again`})]})]})}function zt({title:e,body:t}){return(0,K.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,K.jsxs)(`div`,{className:`relative flex h-11 w-11 items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute h-14 w-14 rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`,animation:`onboarding-glow 2.4s ease-in-out infinite`},"aria-hidden":`true`}),(0,K.jsx)(`div`,{className:`absolute h-9 w-9 rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 8%, transparent)`,animation:`onboarding-glow 2.4s ease-in-out infinite 0.4s`},"aria-hidden":`true`}),(0,K.jsx)(j,{className:`relative h-5 w-5 animate-spin text-[var(--system-positive-strong)]`,"aria-hidden":`true`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(f,{variant:`title-small`,as:`h1`,children:e}),(0,K.jsx)(f,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:t})]})]})}function Bt({icon:e,label:t,from:n,fromDetail:r,to:i,toDetail:a}){return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,K.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`},children:(0,K.jsx)(e,{className:`h-4 w-4 text-[var(--system-positive-strong)]`})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:t}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)] line-through`,children:n}),r&&(0,K.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)] line-through`,children:r})]}),(0,K.jsx)(it,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`}),(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:i}),a&&(0,K.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:a})]})]})]})]})}function Vt({storageGib:e,maxTier:t,onBack:n,onAdvance:r,dotIndex:a,dotTotal:o}){let{data:s}=l(Ke()),c=s?.machine_size||`small`,d=s?.provisioned_storage_gib??null,p=Mt(t),m=p.length>0?p[p.length-1]:c,g=m!==c,_=e!=null&&(d==null||d<e),[v,y]=(0,G.useState)(null),b=u(Oe());return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(B.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,K.jsx)(kt,{icon:S}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(f,{variant:`title-small`,as:`h1`,children:`Your assistant's new resources`}),(0,K.jsx)(f,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Your assistant will go offline briefly while it resizes.`})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[g&&(0,K.jsx)(Bt,{icon:S,label:`Machine`,from:P[c],fromDetail:N[c],to:P[m],toDetail:N[m]}),_&&(0,K.jsx)(Bt,{icon:k,label:`Storage`,from:d==null?`—`:`${d} GiB`,to:`${e} GiB`}),!g&&!_&&(0,K.jsx)(F,{tone:`neutral`,children:`Your assistant is already running at the maximum size for your plan.`})]}),v?(0,K.jsx)(F,{tone:`error`,children:v}):null]}),(0,K.jsxs)(B.Footer,{className:`relative items-center justify-between`,children:[(0,K.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-back`,disabled:b.isPending,onClick:n,leftIcon:(0,K.jsx)(h,{className:`h-4 w-4`}),children:`Back`}),(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,K.jsx)(Ot,{current:a,total:o})}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-skip`,disabled:b.isPending,onClick:r,children:`Do later`}),(0,K.jsx)(i,{variant:`primary`,"data-testid":`onboarding-setup-continue`,disabled:b.isPending||!s?.id,onClick:()=>{b.isPending||!s?.id||b.mutate({path:{id:s.id},body:{machine_size:m,...e==null?{}:{storage_gib:e}}},{onSuccess:()=>{y(null),r()},onError:e=>{y(Ft(e,`Couldn't apply changes. Please try again.`))}})},children:`Apply & Restart`})]})]})]})}function Ht({onContinue:e,continueDisabled:t=!1}){return(0,K.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(ellipse 60% 50% at 50% 38%, color-mix(in oklab, var(--system-positive-strong) 14%, transparent), transparent)`},"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,K.jsx)(`div`,{className:`absolute h-24 w-24 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 18%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite`},"aria-hidden":`true`}),(0,K.jsx)(`div`,{className:`absolute h-16 w-16 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 12%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite 0.5s`},"aria-hidden":`true`}),(0,K.jsx)(w,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,K.jsx)(`h1`,{className:`relative mb-2 text-[var(--content-emphasised)]`,style:{fontFamily:`var(--font-serif)`,fontSize:`28px`,lineHeight:1,fontWeight:400,animation:`welcome-reveal 600ms ease-out 150ms both`},children:`Welcome to Pro`}),(0,K.jsx)(`p`,{className:`relative mb-6 max-w-[320px] text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`welcome-reveal 600ms ease-out 300ms both`},children:`More compute, more storage, and more features. Let's set everything up.`}),(0,K.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,K.jsx)(i,{variant:`primary`,"data-testid":`onboarding-welcome-continue`,disabled:t,onClick:e,children:`Get started`})}),(0,K.jsx)(`p`,{className:`relative mt-6 max-w-[320px] text-body-small-default text-[var(--content-tertiary)]`,style:{animation:`welcome-reveal 600ms ease-out 600ms both`},children:`This quick setup gets your Pro features ready to go. You can close it anytime and turn these features on later from Settings.`})]})}function Ut({open:e,onClose:t}){let n=c(),[r,i]=(0,G.useState)(`confirm-pro`),[a,o]=(0,G.useState)(!1),[s,u]=(0,G.useState)(0);(0,G.useEffect)(()=>{e&&(n.invalidateQueries({queryKey:Le()}),n.invalidateQueries({queryKey:qe()}))},[e,n]);let d=(0,G.useCallback)(()=>{o(!1),u(e=>e+1),n.invalidateQueries({queryKey:Le()})},[n]),f=l({...He(),refetchInterval:e=>e.state.data?.plan_id===`pro`||a?!1:At,refetchIntervalInBackground:!1,enabled:e&&r===`confirm-pro`});(0,G.useEffect)(()=>{if(!e||r!==`confirm-pro`)return;let t=setTimeout(()=>o(!0),jt);return()=>clearTimeout(t)},[e,r,s]),(0,G.useEffect)(()=>{r===`confirm-pro`&&f.data?.plan_id===`pro`&&i(`welcome`)},[r,f.data?.plan_id]);let p=l({...Ue(),enabled:e&&r!==`confirm-pro`});l({...Ke(),enabled:e});let m=p.data?.domain_setup_available,h=(0,G.useCallback)(()=>{i(m===!1?`setup`:`domain`)},[m]),g=(0,G.useCallback)(()=>{i(m===!1?`welcome`:`domain`)},[m]),_=r===`welcome`;return(0,K.jsx)(B.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,K.jsx)(B.Content,{size:`md`,hideCloseButton:!_,dismissOnOverlayClick:!_,onEscapeKeyDown:_?e=>e.preventDefault():void 0,onInteractOutside:_?e=>e.preventDefault():void 0,className:`overflow-hidden`,children:v()})});function v(){if(r===`confirm-pro`)return f.isError?(0,K.jsx)(Lt,{onGoToBilling:t}):a?(0,K.jsx)(Rt,{message:`We're still confirming your upgrade.`,onRetry:d,onGoToBilling:t}):(0,K.jsx)(zt,{title:`Finalizing your upgrade…`,body:`This usually takes a few seconds.`});if(r===`welcome`)return p.isError?(0,K.jsx)(Lt,{onGoToBilling:t}):(0,K.jsx)(Ht,{onContinue:h,continueDisabled:p.isPending||p.isFetching});if(r===`domain`)return(0,K.jsx)(It,{onBack:()=>i(`welcome`),onExit:()=>i(`setup`)});if(r===`setup`){if(p.isError)return(0,K.jsx)(Lt,{onGoToBilling:t});let e=p.data?.max_machine_tier??null,n=m!==!1;return(0,K.jsx)(Vt,{storageGib:p.data?.selected_storage_gib??null,maxTier:e,onBack:g,onAdvance:()=>i(`complete`),dotIndex:+!!n,dotTotal:n?2:1})}return r===`complete`?(0,K.jsx)(Dt,{onBack:()=>i(`setup`)}):null}}function Wt(e){if(!e)return{};let t={};for(let n of e.callSites)!n.id||!n.displayName||(t[n.id]={id:n.id,displayName:n.displayName,description:n.description,domain:n.domain});return t}function q(e){return Number.isFinite(e)?Math.round(e).toLocaleString():`0`}function Gt(e){return!Number.isFinite(e)||e===0?`$0.00`:`$${e.toFixed(2)}`}var Kt=`model`,qt={model:`Model`,task:`Action`,profile:`Profile`},Jt=[{value:`model`,label:qt.model},{value:`task`,label:qt.task},{value:`profile`,label:qt.profile}];function Yt(e){return e===`model`||e===`task`||e===`profile`}function Xt(e){switch(e){case`model`:return`model`;case`task`:return`call_site`;case`profile`:return`inference_profile`}}function Zt(e){switch(e){case`model`:return`model`;case`task`:return`llm_call_site`;case`profile`:return`inference_profile`}}function Qt(e,t,n){if(e===`task`){let e=t.groupKey;return e?n.callSites?.[e]?.displayName??t.group:t.group}if(e===`profile`){let e=t.groupKey;return e?n.profiles?.[e]?.displayName??t.group:t.group||`Default / Unset`}return t.group}function $t(e,t,n){return!e||e.length===0?[]:e.map(e=>{let r=Qt(t,e,n);return r===e.group?e:{...e,group:r}})}var en=6,tn=`value:`,nn=`null:`;function rn(e,t=`schedule`){return e===null?`${nn}${Yt(t)?Xt(t):t}`:`${tn}${e}`}function an(e){return[...e].sort((e,t)=>{if(e.date!==t.date)return e.date<t.date?-1:1;let n=un(e.bucketId),r=un(t.bucketId);return n===r?e.bucketId===t.bucketId?0:e.bucketId<t.bucketId?-1:1:n-r})}function on(e){return e.map(e=>({bucketId:e.bucketId,date:e.date,displayLabel:e.displayLabel,totalInputTokens:e.totalInputTokens,totalOutputTokens:e.totalOutputTokens,totalEstimatedCostUsd:e.totalEstimatedCostUsd,eventCount:e.eventCount,groups:{}}))}function sn(e,t,n){return t!==`task`&&t!==`profile`?[...e]:e.map(e=>{let r=!1,i={};for(let[a,o]of Object.entries(e.groups)){let e=Qt(t,ln(o),n);e===o.group?i[a]=o:(r=!0,i[a]={...o,group:e})}return r?{...e,groups:i}:e})}function cn(e){let t=new Map;for(let n of e)for(let[e,r]of Object.entries(n.groups)){let n=t.get(e);t.set(e,{label:n?.label??r.group,totalEstimatedCostUsd:(n?.totalEstimatedCostUsd??0)+r.totalEstimatedCostUsd})}let n=Array.from(t.entries()).sort(([e,t],[n,r])=>t.totalEstimatedCostUsd===r.totalEstimatedCostUsd?t.label===r.label?e===n?0:e<n?-1:1:t.label<r.label?-1:1:r.totalEstimatedCostUsd-t.totalEstimatedCostUsd).map(([e,t],n)=>({seriesKey:e,label:t.label,totalEstimatedCostUsd:t.totalEstimatedCostUsd,colorIndex:n}));return{items:n,visibleItems:n.slice(0,en)}}function ln(e){return{group:e.group,groupId:e.groupKey,groupKey:e.groupKey,totalInputTokens:e.totalInputTokens,totalOutputTokens:e.totalOutputTokens,totalCacheCreationTokens:0,totalCacheReadTokens:0,totalEstimatedCostUsd:e.totalEstimatedCostUsd,eventCount:e.eventCount,turnCount:null}}function un(e){let t=e.lastIndexOf(`|`);if(t<0)return 0;let n=Number(e.slice(t+1));return Number.isFinite(n)?n:0}var dn=140,fn=40,pn=28,mn=2,hn=2,gn=1e-6,_n=12,vn=220,yn=56,bn=[40,80,60,100,50,70,30],xn=[18,24,28,35,42,50,64,78,92,106,118,96,84,74,68,80,88,72,56,48,40,34,26,20],Sn=[`var(--usage-trend-stack-positive, var(--system-positive-strong, #10b981))`,`var(--usage-trend-stack-info, var(--system-info-strong, #3b82f6))`,`var(--usage-trend-stack-mid, var(--system-mid-strong, #f59e0b))`,`var(--usage-trend-stack-secondary, var(--content-secondary, #6b7280))`,`var(--usage-trend-stack-negative, var(--system-negative-strong, #f87171))`,`var(--usage-trend-stack-tertiary, var(--content-tertiary, #9ca3af))`];function Cn(e){return Sn[e%Sn.length]}function wn(e){return e.displayLabel?e.displayLabel:e.date}function Tn(e,t){let n=e+_n,r=t+_n;return n+vn>window.innerWidth&&(n=e-vn-_n),r+yn>window.innerHeight&&(r=t-yn-_n),{x:n,y:r}}function En({buckets:e,isHourly:t,legendItems:n}){let[r,i]=(0,G.useState)(null),a=(0,G.useMemo)(()=>an(e),[e]),o=(0,G.useMemo)(()=>cn(e),[e]),s=n??o.items,c=n??o.visibleItems,l=(0,G.useMemo)(()=>a.reduce((e,t)=>Math.max(e,t.totalEstimatedCostUsd),0),[a]),u=(0,G.useCallback)((e,t)=>{let n=Tn(e.clientX,e.clientY);i({...t,x:n.x,y:n.y})},[]),d=(0,G.useCallback)(()=>i(null),[]);if(a.length===0){let e=(0,K.jsx)(jn,{title:t?`No hourly data`:`No daily data`,subtitle:`No usage recorded in this time range`});return c.length===0?e:(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,(0,K.jsx)(An,{items:c})]})}let f=t?pn:fn;return(0,K.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`div`,{className:`flex items-end gap-2`,style:{height:`${dn}px`},"aria-hidden":`true`,children:a.map(e=>{let t=l>0?e.totalEstimatedCostUsd/l:0,r=Math.max(mn,dn*t);return(0,K.jsx)(`div`,{className:`flex items-end`,style:{width:`${f}px`,minWidth:`${f}px`,height:`${r}px`,opacity:e.totalEstimatedCostUsd>0?1:.3},title:`${wn(e)}: ${Gt(e.totalEstimatedCostUsd)}`,"data-usage-series-bar":e.bucketId,children:(0,K.jsx)(On,{bucket:e,height:r,legendItems:s,hasLegendOverride:n!=null,onSegmentHover:u,onSegmentLeave:d})},e.bucketId)})}),(0,K.jsx)(`div`,{className:`flex items-start gap-2`,children:a.map(e=>(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-0.5`,style:{width:`${f}px`,minWidth:`${f}px`},children:[(0,K.jsx)(`span`,{className:`truncate text-[10px]`,style:{color:`var(--content-secondary)`},children:Gt(e.totalEstimatedCostUsd)}),(0,K.jsx)(`span`,{className:`truncate text-[10px]`,style:{color:`var(--content-tertiary)`},children:wn(e)})]},e.bucketId))}),c.length>0?(0,K.jsx)(An,{items:c}):null]}),r?(0,K.jsx)(kn,{tooltip:r}):null]})}function Dn({isHourly:e}){let t=e?xn:bn,n=e?pn:fn;return(0,K.jsx)(`div`,{className:`flex items-end gap-2`,style:{height:`${dn}px`},"aria-hidden":`true`,children:t.map((e,t)=>(0,K.jsx)(`div`,{className:`rounded-sm`,style:{width:`${n}px`,height:`${e}px`,background:`color-mix(in srgb, var(--border-base) 40%, transparent)`}},t))})}function On({bucket:e,height:t,legendItems:n,hasLegendOverride:r,onSegmentHover:i,onSegmentLeave:a}){let o=Object.keys(e.groups).length>0,s=n.filter(e=>(e.state??`active`)===`active`).flatMap(t=>{let n=e.groups[t.seriesKey];return!n||n.totalEstimatedCostUsd<=0?[]:[{item:t,value:n}]});if(s.length===0&&!o&&!r){let n={label:`Total`,bucketLabel:wn(e),cost:Gt(e.totalEstimatedCostUsd)};return(0,K.jsx)(`div`,{className:`w-full rounded-sm`,title:`${n.label}: ${n.cost}`,onMouseEnter:e=>i(e,n),onMouseMove:e=>i(e,n),onMouseLeave:a,style:{height:`${t}px`,background:Cn(0)},"data-usage-series-segment-label":n.label,"data-usage-fallback-segment":`true`})}return s.length===0?null:(0,K.jsx)(`div`,{className:`flex w-full flex-col-reverse overflow-hidden rounded-sm`,style:{height:`${t}px`},"data-usage-series-stack":e.bucketId,children:s.map(({item:n,value:r})=>{let o={label:n.label,bucketLabel:wn(e),cost:Gt(r.totalEstimatedCostUsd)};return(0,K.jsx)(`div`,{title:`${o.label}: ${o.cost}`,onMouseEnter:e=>i(e,o),onMouseMove:e=>i(e,o),onMouseLeave:a,style:{height:`${Math.max(hn,t*r.totalEstimatedCostUsd/Math.max(e.totalEstimatedCostUsd,gn))}px`,background:Cn(n.colorIndex)},"data-usage-series-segment":n.seriesKey,"data-usage-series-segment-label":n.label,"data-usage-series-color-index":n.colorIndex},n.seriesKey)})})}function kn({tooltip:e}){return(0,K.jsxs)(`div`,{className:`pointer-events-none fixed z-50 max-w-[220px] rounded-md border px-2 py-1 shadow-xl`,style:{left:`${e.x}px`,top:`${e.y}px`,background:`var(--surface-overlay, var(--surface-lift))`,borderColor:`var(--border-base)`},"aria-hidden":`true`,children:[(0,K.jsx)(`div`,{className:`truncate text-body-small-default`,style:{color:`var(--content-default)`},children:e.label}),(0,K.jsxs)(`div`,{className:`truncate text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[e.bucketLabel,` · `,e.cost]})]})}function An({items:e}){return(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 pt-1`,children:e.map(e=>{let t=e.state??`active`,n=t===`inactive`;return(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,"data-usage-legend-state":t,children:[(0,K.jsx)(`span`,{className:`h-[7px] w-[7px] shrink-0 rounded-full`,style:{background:n?`var(--content-tertiary)`:Cn(e.colorIndex),opacity:n?.45:1},"aria-hidden":`true`,"data-usage-series-color-index":e.colorIndex}),(0,K.jsx)(`span`,{className:n?`truncate text-[10px] line-through`:`truncate text-[10px]`,style:{color:`var(--content-tertiary)`,opacity:n?.65:1},children:e.label})]},e.seriesKey)})})}function jn({title:e,subtitle:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-md py-12 text-center`,style:{color:`var(--content-tertiary)`},children:[(0,K.jsx)(`p`,{className:`text-body-medium-default`,style:{color:`var(--content-secondary)`},children:e}),(0,K.jsx)(`p`,{className:`mt-1 text-body-small-default`,children:t})]})}function Mn(e){return Yt(e)?Xt(e):e}function Nn(e){return Ln({from:e.from,to:e.to},e.scheduleId)}function Pn(e){return Ln({from:e.from,to:e.to,...e.granularity?{granularity:e.granularity}:{},...e.tz?{tz:e.tz}:{}},e.scheduleId)}function Fn(e){return Ln({from:e.from,to:e.to,groupBy:Mn(e.groupBy)},e.scheduleId)}function In(e){return Ln({from:e.from,to:e.to,granularity:e.granularity,groupBy:Mn(e.groupBy),...e.tz?{tz:e.tz}:{}},e.scheduleId)}function Ln(e,t){return t?{...e,scheduleId:t}:e}function Rn(e){return[`${q(e.totalInputTokens)} direct`,`${q(e.totalCacheCreationTokens)} cache created`,`${q(e.totalCacheReadTokens)} cache read`,`${q(e.totalOutputTokens)} out`].join(` / `)}function zn(e){return!Number.isFinite(e)||e===0?`0`:e>=1e6||e>=999950&&e<1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toLocaleString()}function Bn(e){return`${zn(e.totalInputTokens+e.totalCacheCreationTokens+e.totalCacheReadTokens)} in / ${zn(e.totalOutputTokens)} out`}var Vn=`task`,Hn=`model`,Un=new Set([400,404,422]),Wn=3,Gn=new Set([`today`,`yesterday`,`7d`,`30d`,`90d`,`all`]),Kn=new Set([`actor`,`provider`,`model`,`conversation`,`task`,`profile`,`schedule`]),qn={task:qt.task,profile:qt.profile,model:qt.model,provider:`Provider`,actor:`Actor`,conversation:`Conversation`,schedule:`Schedule`},Jn=[{value:`task`,label:qn.task},{value:`profile`,label:qn.profile},{value:`model`,label:qn.model},{value:`provider`,label:qn.provider},{value:`schedule`,label:qn.schedule},{value:`conversation`,label:qn.conversation}];function Yn(e){let t=e.get(`range`),n=e.get(`groupBy`),r=$n(n)?n:Vn;return{range:Qn(t)?t:`7d`,groupBy:r,scheduleId:r===`schedule`?Xn(e):void 0}}function Xn(e){let t=e.get(`scheduleId`);if(!(!t||t.trim().length===0))return t}function Zn(e,t){let n=new URLSearchParams(e);return t.range!==void 0&&n.set(`range`,t.range),t.groupBy!==void 0&&n.set(`groupBy`,t.groupBy),t.scheduleId!==void 0&&(t.scheduleId===null||t.scheduleId.trim().length===0?n.delete(`scheduleId`):n.set(`scheduleId`,t.scheduleId)),n.get(`groupBy`)!==`schedule`&&n.delete(`scheduleId`),n}function Qn(e){return e!=null&&Gn.has(e)}function $n(e){return e!=null&&Kn.has(e)}function er(e){return e!==`conversation`}function tr(e,t){return e!==`task`&&e!==`profile`?!1:rr(t)}function nr(e,t){return!rr(t)&&e<Wn}function rr(e){return e instanceof he&&Un.has(e.status)}function ir(e,t){let n=e===`hourly`?`Hourly Trend`:`Daily Trend`;return!t||t===`conversation`?n:`${n} by ${qn[t]}`}function ar({requestedGranularity:e,isLoading:t,buckets:n}){return e===`hourly`&&(t||!n||n.length===0||n.some(or))?`hourly`:`daily`}function or(e){return e.bucketId.includes(`|`)||sr(e.date)}function sr(e){return/^\d{4}-\d{2}-\d{2} ([01]\d|2[0-3]):00$/.test(e)}function cr(e,t,n=Date.now()){return yt(e,t,n)}function lr(e){return e===`today`||e===`yesterday`?`hourly`:`daily`}function ur({prompt:e,children:t,variant:n=`outlined`,size:r=`regular`,className:a}){let o=s(),c=(0,G.useCallback)(()=>{ot(o,{prompt:e})},[o,e]);return(0,K.jsx)(i,{variant:n,size:r,leftIcon:(0,K.jsx)(re,{}),onClick:c,className:a,children:t})}var dr=[{value:`today`,label:`Today`},{value:`yesterday`,label:`Yesterday`},{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`},{value:`90d`,label:`Last 90 days`},{value:`all`,label:`All time`}],fr=300*1e3,pr=[`Please load the llm-cost-optimizer skill.`,`Analyze my recent LLM usage and explain the biggest cost contributors by call site, model, and profile.`,`Check my current llm.default, llm.callSites, and llm.profiles.`,`Give me a concise summary of what is driving cost and what you would optimize first.`,`Do not change config yet.`].join(` `),mr=[`Please load the llm-cost-optimizer skill.`,`Analyze my recent LLM usage and current LLM config, then recommend the safest cost-optimization changes.`,`If changes are clearly safe, show me the exact config commands you would run and ask for confirmation before applying them.`].join(` `);function hr({assistantId:e}){let[t,n]=o(),{range:r,groupBy:i,scheduleId:a}=(0,G.useMemo)(()=>Yn(t),[t]),s=st(),c=(0,G.useCallback)(e=>{n(t=>Zn(t,e),{replace:!0})},[n]),u=(0,G.useMemo)(()=>cr(r,s),[r,s]),d=(0,G.useMemo)(()=>lr(r),[r]),f=l({queryKey:me({path:{assistant_id:e}}),queryFn:()=>gt(e),staleTime:1e4}),p=(0,G.useCallback)(e=>{c({range:e})},[c]),m=l({...de({path:{assistant_id:e},query:Nn({from:u.from,to:u.to,scheduleId:a})})}),h=l({queryKey:ce({path:{assistant_id:e},query:Fn({from:u.from,to:u.to,groupBy:i,scheduleId:a})}),queryFn:async({signal:t})=>{try{let{data:n}=await se({path:{assistant_id:e},query:Fn({from:u.from,to:u.to,groupBy:i,scheduleId:a}),signal:t,throwOnError:!0});return{groupBy:i,response:n}}catch(n){if(!tr(i,n))throw n;let{data:r}=await se({path:{assistant_id:e},query:Fn({from:u.from,to:u.to,groupBy:Hn,scheduleId:a}),signal:t,throwOnError:!0});return{groupBy:Hn,response:r}}},retry:nr}),g=h.data?.groupBy??i,_=er(g)?g:void 0,v=l({...ue({path:{assistant_id:e},query:In({from:u.from,to:u.to,granularity:d,groupBy:_??`actor`,tz:s,scheduleId:a})}),enabled:!!_,retry:nr}),y=l({...le({path:{assistant_id:e},query:Pn({from:u.from,to:u.to,granularity:d,tz:s,scheduleId:a})}),enabled:!_||v.isError}),b=l({...pe({path:{assistant_id:e}}),enabled:g===`task`,staleTime:1/0}),x=l({...fe({path:{assistant_id:e}}),select:bt,enabled:g===`profile`,staleTime:fr}),S=(0,G.useMemo)(()=>({callSites:Wt(b.data),profiles:x.data??{}}),[b.data,x.data]),C=(0,G.useMemo)(()=>{let e=h.data;if(e)return $t(e.response.breakdown,e.groupBy,S)},[h.data,S]),w=(0,G.useMemo)(()=>{if(!(!_||!v.data))return sn(v.data.buckets,_,S)},[v.data,_,S]),T=(0,G.useMemo)(()=>{if(y.data)return on(y.data.buckets)},[y.data]),E=(0,G.useMemo)(()=>_?v.error?T?{isLoading:!1,error:null,data:T,refetch:y.refetch}:{isLoading:y.isLoading||!T&&!y.error,error:y.error??v.error,data:void 0,refetch:y.error?y.refetch:v.refetch}:{isLoading:v.isLoading,error:v.error,data:w,refetch:v.refetch}:{isLoading:y.isLoading,error:y.error,data:T,refetch:y.refetch},[T,y.error,y.isLoading,y.refetch,w,_,v.error,v.isLoading,v.refetch]),D=ar({requestedGranularity:d,isLoading:E.isLoading,buckets:E.data}),O=D===`hourly`,k=_&&v.error?void 0:g,A=(0,G.useMemo)(()=>{if(!(g!==`schedule`||!a))return gr(f.data,a)},[g,a,f.data]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsx)(`h3`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:`Usage`}),(0,K.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,K.jsx)(yr,{range:r,onChange:p})})]}),(0,K.jsx)(`section`,{"aria-label":`Totals`,children:(0,K.jsx)(xr,{query:m,skeleton:(0,K.jsx)(wr,{}),render:e=>(0,K.jsx)(Sr,{totals:e})})}),(0,K.jsx)(br,{title:`Inference Usage`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsx)(`h4`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:ir(D,k)}),(0,K.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,K.jsx)(Tr,{value:g,onChange:e=>{e===i&&g!==i&&(h.refetch(),v.refetch()),c({groupBy:e,scheduleId:e===`schedule`?void 0:null})}})})]}),(0,K.jsx)(xr,{query:E,skeleton:(0,K.jsx)(Dn,{isHourly:O}),render:e=>(0,K.jsx)(En,{buckets:e,isHourly:O,legendItems:A})})]})}),(0,K.jsx)(Er,{query:h,groups:C}),(0,K.jsx)(vr,{})]})}function gr(e,t){let n=e??[];return[...n.some(e=>e.id===t)?[]:[{id:t,label:_r(t)}],...n.map(e=>({id:e.id,label:e.name||e.id}))].map((e,n)=>({seriesKey:rn(e.id,`schedule`),label:e.label,colorIndex:n,state:e.id===t?`active`:`inactive`}))}function _r(e){return`Unknown schedule (${e})`}function vr(){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(`div`,{className:`h-px w-full`,style:{background:`linear-gradient(to right, transparent, var(--border-base), transparent)`}}),(0,K.jsx)(br,{title:`Cost assistant`,subtitle:`Review recent spend and tune model profile choices.`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md px-3 py-3 sm:flex-row sm:items-center`,children:[(0,K.jsx)(ur,{prompt:pr,children:`Analyze costs with assistant`}),(0,K.jsx)(ur,{prompt:mr,variant:`ghost`,children:`Optimize settings`})]})})]})}function yr({range:e,onChange:t}){return(0,K.jsx)(`div`,{className:`flex items-center`,children:(0,K.jsx)(H,{value:e,onChange:t,options:dr.map(e=>({value:e.value,label:e.label}))})})}function br({title:e,subtitle:t,children:n}){return(0,K.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-md border px-4 py-4`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`},children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`h3`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),t?(0,K.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:t}):null]}),n]})}function xr({query:e,skeleton:t,render:n}){return e.isLoading?(0,K.jsx)(K.Fragment,{children:t}):e.error?(0,K.jsx)(jr,{message:e.error instanceof Error?e.error.message:`Failed to load usage.`,onRetry:()=>e.refetch()}):e.data?(0,K.jsx)(K.Fragment,{children:n(e.data)}):(0,K.jsx)(K.Fragment,{children:t})}function Sr({totals:e}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{style:{fontSize:`30px`,fontWeight:600,lineHeight:1,color:`var(--content-default)`},children:Gt(e.totalEstimatedCostUsd)}),(0,K.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-secondary)`},children:`Cost`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:q(e.eventCount)}),(0,K.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-secondary)`},children:`LLM Calls`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,K.jsx)(Cr,{label:`Direct Input Tokens`,value:q(e.totalInputTokens)}),(0,K.jsx)(Cr,{label:`Output Tokens`,value:q(e.totalOutputTokens)}),(0,K.jsx)(Cr,{label:`Cache Created`,value:q(e.totalCacheCreationTokens)}),(0,K.jsx)(Cr,{label:`Cache Read`,value:q(e.totalCacheReadTokens)})]})]})}function Cr({label:e,value:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-3 py-2`,style:{background:`color-mix(in srgb, var(--border-base) 15%, transparent)`},children:[(0,K.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-default)`},children:t}),(0,K.jsx)(`span`,{className:`text-label-medium-default`,style:{color:`var(--content-tertiary)`},children:e})]})}function wr(){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":`true`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(J,{width:140,height:30}),(0,K.jsx)(J,{width:90,height:12})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(J,{width:60,height:16}),(0,K.jsx)(J,{width:60,height:12})]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:Array.from({length:4}).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-3 py-2`,style:{background:`color-mix(in srgb, var(--border-base) 15%, transparent)`},children:[(0,K.jsx)(J,{width:`50%`,height:12}),(0,K.jsx)(J,{width:`70%`,height:11})]},t))})]})}function Tr({value:e,onChange:t}){return(0,K.jsx)(`div`,{className:`flex items-center`,children:(0,K.jsx)(H,{value:e,onChange:t,menuAlign:`end`,menuMinWidth:196,options:Jn.map(e=>({value:e.value,label:e.label}))})})}function Er({query:e,groups:t}){let[n,r]=(0,G.useState)(new Set),i=e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,K.jsx)(br,{title:`Breakdown`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(Dr,{label:`% of total`,active:n.has(`pct`),onClick:()=>i(`pct`)}),(0,K.jsx)(Dr,{label:`Tokens`,active:n.has(`tokens`),onClick:()=>i(`tokens`)}),(0,K.jsx)(Dr,{label:`Turns`,active:n.has(`turns`),onClick:()=>i(`turns`)})]}),(0,K.jsx)(xr,{query:e,skeleton:(0,K.jsx)(kr,{}),render:e=>(0,K.jsx)(Or,{groups:t??e.response.breakdown,showPct:n.has(`pct`),showTokens:n.has(`tokens`),showTurns:n.has(`turns`)})})]})})}function Dr({label:e,active:t,onClick:n}){return(0,K.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-full border px-2.5 py-1 text-label-medium-default`,style:{borderColor:t?`var(--content-secondary)`:`var(--border-base)`,background:t?`color-mix(in srgb, var(--content-secondary) 15%, transparent)`:`transparent`,color:t?`var(--content-default)`:`var(--content-tertiary)`},children:e})}function Or({groups:e,showPct:t,showTokens:n,showTurns:r}){if(e.length===0)return(0,K.jsx)(Ar,{title:`No breakdown data`,subtitle:`No usage recorded for this grouping`});let i=e.reduce((e,t)=>e+t.totalEstimatedCostUsd,0);return(0,K.jsx)(`div`,{className:`overflow-hidden rounded-md`,children:(0,K.jsxs)(`table`,{className:`w-full table-fixed`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{style:{borderBottom:`1px solid var(--border-base)`},children:[(0,K.jsx)(`th`,{className:`px-3 py-2.5 text-left text-label-medium-default`,style:{color:`var(--content-tertiary)`},children:`Group`}),n?(0,K.jsx)(`th`,{className:`px-3 py-2.5 text-left text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`35%`},children:`Tokens`}):null,r?(0,K.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`72px`},children:`Turns`}):null,t?(0,K.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`64px`},children:`%`}):null,(0,K.jsx)(`th`,{className:`px-3 py-2.5 text-right text-label-medium-default`,style:{color:`var(--content-tertiary)`,width:`100px`},children:`Cost`})]})}),(0,K.jsx)(`tbody`,{children:e.map((e,a)=>{let o=Rn(e),s=Bn(e),c=i>0?Math.round(e.totalEstimatedCostUsd/i*100):0;return(0,K.jsxs)(`tr`,{style:{borderTop:a===0?`none`:`1px solid var(--border-base)`},children:[(0,K.jsx)(`td`,{className:`min-w-0 px-3 py-2`,style:{color:`var(--content-default)`},children:(0,K.jsx)(`span`,{className:`block truncate text-body-medium-lighter`,title:e.group,children:e.group})}),n?(0,K.jsx)(`td`,{className:`min-w-0 px-3 py-2`,style:{color:`var(--content-secondary)`},children:(0,K.jsx)(`span`,{className:`block truncate text-body-small-default`,title:o,children:s})}):null,r?(0,K.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,K.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:e.turnCount==null?`—`:e.turnCount.toLocaleString()})}):null,t?(0,K.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,K.jsxs)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:[c,`%`]})}):null,(0,K.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2 text-right`,children:(0,K.jsx)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-default)`},children:Gt(e.totalEstimatedCostUsd)})})]},e.groupKey??e.groupId??`${e.group}-${a}`)})})]})})}function kr(){return(0,K.jsx)(`div`,{className:`flex flex-col gap-2`,"aria-hidden":`true`,children:Array.from({length:4}).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(J,{width:100,height:14}),(0,K.jsx)(J,{width:`60%`,height:12}),(0,K.jsx)(J,{width:50,height:14})]},t))})}function J({width:e,height:t}){return(0,K.jsx)(`div`,{className:`rounded-sm`,style:{width:typeof e==`number`?`${e}px`:e,height:`${t}px`,background:`color-mix(in srgb, var(--border-base) 40%, transparent)`}})}function Ar({title:e,subtitle:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1 py-8 text-center`,children:[(0,K.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),(0,K.jsx)(`span`,{className:`text-body-small-default`,style:{color:`var(--content-tertiary)`},children:t})]})}function jr({message:e,onRetry:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(ie,{className:`h-4 w-4 shrink-0`,style:{color:`var(--system-negative-strong, #f87171)`}}),(0,K.jsx)(`span`,{className:`text-body-medium-lighter`,style:{color:`var(--content-default)`},children:e})]}),t?(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`self-start rounded-md border px-3 py-1 text-body-small-default`,style:{background:`var(--surface-lift)`,borderColor:`var(--border-base)`,color:`var(--content-default)`},children:`Retry`}):null]})}var Mr=`billing-portal-return-snapshot`;function Nr(e){try{sessionStorage.removeItem(Mr),sessionStorage.setItem(Mr,JSON.stringify(e))}catch{}}function Pr(){if(typeof sessionStorage>`u`)return null;try{let e=sessionStorage.getItem(Mr);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 Fr(){try{sessionStorage.removeItem(Mr)}catch{}}function Ir(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 Lr(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function Rr(e){return e?e.cancel_at??e.current_period_end??null:null}function zr(e){let t=c();return(0,G.useEffect)(()=>ve(()=>{t.invalidateQueries(He())}),[t]),Ce({onSuccess:t=>{e&&Nr(e),ye(t.portal_url)},onError:()=>{V.error(`Couldn't open the billing portal. Please try again.`,{id:`billing-portal-session-error`})}})}function Br(e){let t=e/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}function Y(e){return`${Br(e)}/mo`}function Vr(e){return`${e>0?`+`:`−`}${Br(Math.abs(e))}/mo`}var Hr={medium:`Medium`,large:`Large`,xl:`XL`};function Ur(e){return e.disabled===!0}function Wr({machineTiers:e,storageTiers:t,selectedMachineTier:n,selectedStorageTier:r,onMachineTierChange:i,onStorageTierChange:a,currentMachinePriceCents:o,currentStoragePriceCents:s}){let c=(0,G.useMemo)(()=>e.map(e=>{let t=Hr[e.tier]??e.label,n=o==null?`+${Y(e.price_cents)}`:e.price_cents===o?`(${Y(e.price_cents)}, current)`:Vr(e.price_cents-o);return{value:e.tier,label:`${t} ${n}`,disabled:Ur(e)}}),[e,o]),l=(0,G.useMemo)(()=>t.map(e=>{let t=s==null?`+${Y(e.price_cents)}`:e.price_cents===s?`(${Y(e.price_cents)}, current)`:Vr(e.price_cents-s);return{value:e.tier,label:`${e.storage_gib} GiB ${t}`,disabled:Ur(e)}}),[t,s]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(f,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Machine`}),(0,K.jsx)(`span`,{title:`Determines the CPU and memory allocated to your assistant`,children:(0,K.jsx)(A,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(H,{"aria-label":`Machine tier`,placeholder:`Select a machine tier`,value:n??``,onChange:i,options:c})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(f,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Storage`}),(0,K.jsx)(`span`,{title:`Persistent disk space for your assistant's files and data`,children:(0,K.jsx)(A,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(H,{"aria-label":`Storage tier`,placeholder:`Select a storage tier`,value:r??``,onChange:a,options:l})]})]})}var Gr=new Set([`active`,`trialing`,`past_due`]),Kr=[`target_plan_id`,`confirm`,`machine_tier`,`storage_tier`,`credit_tier`,`non_field_errors`];function qr(e,t){if(e&&typeof e==`object`){for(let t of Kr)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 Jr(e,t){let n=e.filter(e=>!Ur(e));return t!==null&&n.some(e=>e.tier===t)?t:n[0]?.tier??null}function Yr(e,t,n){return t===void 0?n:t!==null&&(t===n||e.some(e=>e.tier===t))?t:null}function Xr(e){return e.length?Math.min(...e.map(e=>e.price_cents)):0}function Zr({open:e,onCancel:t,onConfirm:n,confirming:r,lostFeatures:a}){return(0,K.jsx)(B.Root,{open:e,onOpenChange:e=>{!e&&!r&&t()},children:(0,K.jsxs)(B.Content,{size:`md`,hideCloseButton:!0,children:[(0,K.jsx)(B.Header,{children:(0,K.jsx)(B.Title,{icon:ie,children:`Downgrade to Base?`})}),(0,K.jsxs)(B.Body,{children:[(0,K.jsx)(f,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,K.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:a.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(f,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,K.jsxs)(B.Footer,{children:[(0,K.jsx)(i,{variant:`outlined`,onClick:t,disabled:r,children:`Keep Pro`}),(0,K.jsx)(i,{variant:`danger`,onClick:n,disabled:r,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]})})}var Qr=`__none__`;function $r(e){return`${e.label} — ${Y(e.price_cents)}`}function ei({creditTiers:e,selectedCreditTier:t,onCreditTierChange:n,disabled:r=!1}){let i=(0,G.useMemo)(()=>[{value:Qr,label:`No credit bundle — ${Y(0)}`},...e.map(e=>({value:e.tier,label:$r(e)}))],[e]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(f,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Credit bundle`}),(0,K.jsx)(`span`,{title:`A monthly allotment of credits added to your Pro Plan subscription`,children:(0,K.jsx)(A,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(H,{"aria-label":`Credit bundle`,placeholder:`Select a credit bundle`,disabled:r,value:t??Qr,onChange:e=>n(e===Qr?null:e),options:i})]})}function ti({features:e,variant:t,header:n,maxInline:r=3}){return t===`inline`?(0,K.jsx)(K.Fragment,{children:e.slice(0,r).join(`, `)}):(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n&&(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-secondary)]`,children:n}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,K.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(y,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,K.jsx)(f,{as:`span`,variant:`body-medium-default`,children:e})]},e))})]})}function ni({plan:e,isCurrent:t,onPro:n,cancelAtPeriodEnd:r,isCanceled:a,cancelDate:o,formatGraceDate:s,proTierChangeMode:c,creditTiersEnabled:l,creditTiers:u,displayCreditTier:d,onCreditTierChange:m,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:_,onStorageTierChange:v,machineTiersForPicker:y,storageTiersForPicker:b,currentMachinePrice:x,currentStoragePrice:S,currentCreditPriceUnknown:C,proCurrentTotalCents:T,proLiveTotalCents:E,proTotalDelta:D,onboardingLoading:O,tierChangePending:k,machineChanged:M,storageChanged:ee,creditChanged:te,tierChangeError:N,upgradePending:P,portalPending:ne,onUpgrade:re,onApplyTierChange:ie,onDowngradeClick:ae,onKeepPlan:I}){let R=e.id===`pro`,z=e.id===`base`,B=R&&n&&r&&!a,V=R&&(!t||t&&c),oe=R&&t&&c;return(0,K.jsxs)(p,{padding:`lg`,className:`flex flex-col bg-[var(--surface-base)]`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)]`,children:R?(0,K.jsx)(w,{className:`h-5 w-5 text-[var(--content-default)]`}):(0,K.jsx)(Et,{className:`h-5 w-5 text-[var(--content-default)]`})}),(0,K.jsxs)(`div`,{className:`flex min-h-6 items-center gap-2`,children:[(0,K.jsx)(f,{as:`h3`,variant:`title-small`,children:e.name}),t&&(0,K.jsx)(L,{tone:`positive`,children:`Current`})]}),(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`-mt-2 text-[var(--content-tertiary)]`,children:z?`All you need for a capable assistant`:`More features, more compute, more storage`}),B&&o&&(0,K.jsxs)(f,{as:`p`,variant:`body-small-default`,className:`text-[var(--system-mid-strong)]`,"data-testid":`modal-cancels-on`,children:[`Your plan ends on `,s(o)]}),(0,K.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:z?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(f,{as:`p`,variant:`title-medium`,children:`Free`}),(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:`Forever`})]}):t&&!(V&&E!=null)&&(T==null||C)?O?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`}),(0,K.jsx)(f,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,K.jsx)(f,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-price-unavailable`,children:`Current plan pricing unavailable`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(f,{as:`p`,variant:`title-medium`,"data-testid":`modal-pro-price`,children:V&&E!=null?(0,K.jsxs)(K.Fragment,{children:[Y(E),D!=null&&D!==0&&(0,K.jsxs)(`span`,{className:`ml-1 text-[var(--content-tertiary)]`,children:[`(`,Vr(D),`)`]})]}):T==null?e.id===`pro`?`From ${Y(e.base_price_cents+Xr(e.machine_tiers)+Xr(e.storage_tiers))}`:null:`Currently ${Y(T)}`}),V&&D!=null&&D!==0&&(0,K.jsx)(`span`,{title:`Your Pro Plan subscription will change from ${Y(T)} to ${Y(E)}.`,children:(0,K.jsx)(A,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),e.id===`pro`&&(0,K.jsxs)(f,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-base-fee`,children:[Br(e.base_price_cents),` base fee`]})]})}),(0,K.jsx)(ti,{features:e.included_features,variant:`checklist`}),R&&!l&&(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-credits-not-included`,children:`*Credits not included`})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex flex-1 flex-col justify-end gap-4`,children:[!t&&R&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,K.jsx)(ei,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:m,disabled:P}),(0,K.jsx)(Wr,{machineTiers:y,storageTiers:b,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:_,onStorageTierChange:v}),(0,K.jsx)(i,{variant:`primary`,className:`w-full`,onClick:re,disabled:P||!h||!g,"data-testid":`modal-upgrade-to-pro-button`,children:`Upgrade to Pro`})]}),oe&&(O?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`}),(0,K.jsx)(f,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,K.jsx)(ei,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:m,disabled:k}),(0,K.jsx)(Wr,{machineTiers:y,storageTiers:b,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:_,onStorageTierChange:v,currentMachinePriceCents:x,currentStoragePriceCents:S}),N&&(0,K.jsx)(F,{tone:`error`,children:N}),(0,K.jsx)(i,{variant:`primary`,className:`w-full`,onClick:ie,disabled:k||!M&&!ee&&!te,"data-testid":`modal-change-tier-button`,children:`Update Plan`})]})),!t&&z&&n&&!r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,K.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:ae,disabled:ne,"data-testid":`modal-downgrade-to-base-button`,children:`Downgrade to Base`})]}),B&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,K.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:I,disabled:ne,"data-testid":`modal-keep-plan-button`,children:`Keep your Plan`})]})]})]})}function ri({open:e,onClose:t,onTierUpgraded:n}){let r=c(),a=l(Pe()),o=l(He()),s=u(We()),d=u(be()),p=u(Ve()),m=u(ke()),g=zr(Ir(o.data)),[_,v]=(0,G.useState)(`plans`),[y,b]=(0,G.useState)(!1),[x,S]=(0,G.useState)(null),[C,w]=(0,G.useState)(null),[T,E]=(0,G.useState)(void 0);(0,G.useEffect)(()=>ve(()=>{r.invalidateQueries({queryKey:Le()}),r.invalidateQueries({queryKey:Ie()}),r.invalidateQueries({queryKey:qe()}),t()}),[r,t]);let D=o.data?.plan_id,O=D===`pro`,k=l({...Ue(),enabled:O}),A=k.data?.max_machine_tier??null,M=k.data?.selected_storage_tier??null,ee=k.data?.selected_storage_gib??null,te=o.data?.cancel_at_period_end===!0||!!o.data?.cancel_at,N=o.data?.status===`canceled`,P=Rr(o.data),ne=o.data?.status,re=ne!=null&&Gr.has(ne),ae=O&&re&&!te&&!N,I=a.data?.plans.find(e=>e.id===`pro`),L=I?.credit_tiers??[],R=L.length>0,z=o.data?.selected_credit_tier??null,oe=e=>L.find(t=>t.tier===e)?.price_cents??0,H=oe(z),se=z!=null&&!L.some(e=>e.tier===z),ce=T===void 0?z:T,le=oe(ce),ue=I?.machine_tiers??[],de=ae&&ee!=null?(I?.storage_tiers??[]).map(e=>e.storage_gib<ee?{...e,disabled:!0}:e):I?.storage_tiers??[];(0,G.useEffect)(()=>{if(!e){S(null),w(null),E(void 0);return}if(I){if(ae){if(A==null||M==null)return;S(e=>Jr(ue,e??A)),w(e=>Jr(de,e??M)),E(e=>Yr(L,e,z));return}S(e=>Jr(I.machine_tiers,e)),w(e=>Jr(I.storage_tiers,e)),E(e=>Yr(L,e,null))}},[e,I,ae,A,M,z]);let fe=a.data?.plans.find(e=>e.id===`base`),pe=new Set(fe?.included_features??[]),me=(I?.included_features??[]).filter(e=>!pe.has(e)),he=()=>{if(!s.isPending){if(!x||!C){V.error(`Pick a machine and storage tier to continue.`,{id:`pro-upgrade-error`});return}s.mutate({body:{target_plan_id:`pro`,confirm:!0,machine_tier:x,storage_tier:C,credit_tier:ce}},{onSuccess:e=>{if(e.checkout_url){ye(e.checkout_url);return}if(e.status===`no_op`){V.info(`You're already on Pro.`,{id:`pro-upgrade`}),t();return}V.error(e.message??`Failed to start upgrade. Please try again.`,{id:`pro-upgrade-error`})},onError:e=>{V.error(qr(e,`Failed to start upgrade. Please try again.`),{id:`pro-upgrade-error`})}})}},ge=()=>{g.isPending||(v(`plans`),g.mutate({}))},_e=()=>{r.invalidateQueries({queryKey:Le()}),r.invalidateQueries({queryKey:qe()}),r.invalidateQueries({queryKey:Ie()})},U=d.isPending||p.isPending||m.isPending,W=x!=null&&x!==A,xe=C!=null&&C!==M,Se=R&&T!==void 0&&T!==z,Ce=e=>ue.find(t=>t.tier===e)?.price_cents??null,we=e=>de.find(t=>t.tier===e)?.price_cents??null,Te=Ce(x),Ee=we(C),De=Ce(A),Oe=we(M),Ae=W&&Te!=null&&De!=null&&Te<De,je=()=>{if(U)return;let e=[];W&&x&&e.push(new Promise(e=>{d.mutate({body:{machine_tier:x}},{onSuccess:()=>e({dimension:`machine`,ok:!0}),onError:t=>e({dimension:`machine`,ok:!1,error:t})})})),xe&&C&&e.push(new Promise(e=>{p.mutate({body:{storage_tier:C}},{onSuccess:()=>e({dimension:`storage`,ok:!0}),onError:t=>e({dimension:`storage`,ok:!1,error:t})})})),Se&&e.push(new Promise(e=>{m.mutate({body:{credit_tier:ce}},{onSuccess:()=>e({dimension:`credit`,ok:!0}),onError:t=>e({dimension:`credit`,ok:!1,error:t})})})),Promise.all(e).then(e=>{_e();let r=e.some(e=>e.ok&&e.dimension===`storage`),i=e.some(e=>e.ok&&e.dimension===`machine`)&&!Ae,a=(r||i)&&!!n,o=e.filter(e=>!e.ok);if(o.length>0){let e=o.map(e=>qr(e.error,`Failed to update ${e.dimension} tier.`)).join(` `);V.error(e,{id:`pro-tier-change-error`}),a&&(t(),n());return}a?(t(),n()):V.success(Se&&!W&&!xe?`Credit bundle updated.`:`Plan updated.`,{id:`pro-tier-change`})})},Me=()=>{if(!U){if(Ae){b(!0);return}je()}},Ne=()=>{b(!1),je()},Fe=e=>Te!=null&&Ee!=null?e.base_price_cents+Te+Ee+le:null,Re=e=>De!=null&&Oe!=null?e.base_price_cents+De+Oe+H:null,ze=d.isError||p.isError||m.isError?qr(d.error??p.error??m.error,`Failed to update plan. Please try again.`):null,Be=a.isLoading||o.isLoading,Ge=a.isError||o.isError||!a.data||!o.data;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(B.Root,{open:e,onOpenChange:e=>{e||(v(`plans`),t())},children:(0,K.jsx)(B.Content,{size:_===`plans`?`lg`:`md`,children:_===`downgrade-confirm`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(B.Header,{children:(0,K.jsx)(B.Title,{icon:ie,children:`Downgrade to Base?`})}),(0,K.jsxs)(B.Body,{children:[(0,K.jsx)(f,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,K.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:me.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(f,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,K.jsxs)(B.Footer,{children:[(0,K.jsx)(i,{variant:`ghost`,onClick:()=>v(`plans`),disabled:g.isPending,leftIcon:(0,K.jsx)(h,{className:`h-4 w-4`}),children:`Back`}),(0,K.jsx)(i,{variant:`danger`,onClick:ge,disabled:g.isPending,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(B.Header,{children:(0,K.jsx)(B.Title,{className:`sr-only`,children:`Upgrade Plan`})}),(0,K.jsx)(B.Body,{children:Be?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`}),(0,K.jsx)(f,{as:`span`,variant:`body-medium-lighter`,children:`Loading plans...`})]}):Ge?(0,K.jsx)(F,{tone:`error`,children:`Failed to load plans. Please try again later.`}):(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-2 pb-2 pt-4 text-center`,children:[(0,K.jsx)(f,{as:`p`,variant:`title-medium`,children:`Your Assistant, Your Way`}),(0,K.jsx)(f,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-secondary)]`,children:`Choose the plan that works best for you and your assistant.`})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:a.data.plans.map(e=>{let t=e.id===D,n=e.id===`pro`&&I?Fe(I):null,r=e.id===`pro`&&I?Re(I):null;return(0,K.jsx)(ni,{plan:e,isCurrent:t,onPro:O,cancelAtPeriodEnd:te,isCanceled:N,cancelDate:P,formatGraceDate:Lr,proTierChangeMode:ae,creditTiersEnabled:R,creditTiers:L,displayCreditTier:ce,onCreditTierChange:E,selectedMachineTier:x,selectedStorageTier:C,onMachineTierChange:S,onStorageTierChange:w,machineTiersForPicker:ue,storageTiersForPicker:de,currentMachinePrice:De,currentStoragePrice:Oe,currentCreditPriceUnknown:se,proCurrentTotalCents:r,proLiveTotalCents:n,proTotalDelta:n!=null&&r!=null?n-r:null,onboardingLoading:k.isLoading,tierChangePending:U,machineChanged:W,storageChanged:xe,creditChanged:Se,tierChangeError:ze,upgradePending:s.isPending,portalPending:g.isPending,onUpgrade:he,onApplyTierChange:Me,onDowngradeClick:()=>v(`downgrade-confirm`),onKeepPlan:()=>g.mutate({})},e.id)})})]})}),(0,K.jsxs)(B.Footer,{className:`relative items-center`,children:[(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`pointer-events-none absolute inset-x-0 text-center text-[var(--content-tertiary)]`,children:(0,K.jsx)(`span`,{className:`pointer-events-auto`,children:`You can change or cancel your plan at any time from billing settings.`})}),(0,K.jsx)(`div`,{className:`ml-auto`,children:(0,K.jsx)(i,{variant:`outlined`,onClick:t,"data-testid":`modal-cancel-button`,children:`Cancel`})})]})]})})}),(0,K.jsx)(Zr,{open:y,onCancel:()=>b(!1),onConfirm:Ne,confirming:U,lostFeatures:[`Reduced CPU and memory for your assistant — it will resize to the smaller compute profile.`]})]})}var ii={visa:`Visa`,mastercard:`Mastercard`,amex:`Amex`,discover:`Discover`,diners:`Diners Club`,jcb:`JCB`,unionpay:`UnionPay`};function ai(e){return ii[e.toLowerCase()]??e}function oi(e,t){return`${ai(e??`card`)} •••• ${t??`????`}`}function si({open:e,confirming:t,onCancel:n,onConfirm:r}){return(0,K.jsx)(oe,{open:e,title:`Disable automatic top-ups?`,message:`Auto top-ups will stop. Any saved payment method stays on file.`,confirmLabel:t?`Disabling…`:`Disable`,cancelLabel:`Keep enabled`,destructive:!0,onConfirm:r,onCancel:n})}var ci={threshold_usd:`100`,amount_usd:`10`,monthly_cap_usd:``};function li(e){if(e===``||e===`-`)return e;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function ui(e){let t={},n=parseFloat(e.threshold_usd),r=parseFloat(e.amount_usd);if((!Number.isFinite(r)||r<10||r>500)&&(t.amount_usd=`Must be between $10 and $500`),(!Number.isFinite(n)||n<1||n>100)&&(t.threshold_usd=`Must be between $1 and $100`),e.monthly_cap_usd!==``){let n=parseFloat(e.monthly_cap_usd);!Number.isFinite(n)||n<25||n>1e4?t.monthly_cap_usd=`Must be between $25 and $10,000`:Number.isFinite(r)&&n<r&&(t.monthly_cap_usd=`Must be at least the top-up amount`)}return t}function di(e,t,n,r){if(n[e])return n[e];if(r)return t[e]}function fi({initialValues:e=ci,submitting:t,serverErrors:n,onSave:r,onCancel:a}){let[o,s]=(0,G.useState)(e),[c,l]=(0,G.useState)({threshold_usd:!1,amount_usd:!1,monthly_cap_usd:!1}),u=ui(o),d=e=>t=>{s(n=>({...n,[e]:t.target.value}))},f=e=>()=>{l(t=>({...t,[e]:!0})),s(t=>({...t,[e]:li(t[e])}))},p=e=>di(e,u,n,c[e]);return(0,K.jsx)(`div`,{className:`mt-4`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,K.jsx)(R,{type:`number`,step:`1`,label:`Auto-Reload when balance below`,value:o.threshold_usd,onChange:d(`threshold_usd`),onBlur:f(`threshold_usd`),errorText:p(`threshold_usd`),"data-testid":`auto-top-up-threshold-input`,fullWidth:!0})}),(0,K.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,K.jsx)(R,{type:`number`,step:`1`,label:`Add amount when auto reloading`,value:o.amount_usd,onChange:d(`amount_usd`),onBlur:f(`amount_usd`),errorText:p(`amount_usd`),"data-testid":`auto-top-up-amount-input`,fullWidth:!0})}),(0,K.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,K.jsx)(R,{type:`number`,step:`1`,label:`Monthly spending cap`,helperText:`Pauses auto top-ups for the rest of the month once spending reaches this amount. Manual purchases also count toward the total. Leave empty for no limit.`,value:o.monthly_cap_usd,onChange:d(`monthly_cap_usd`),onBlur:f(`monthly_cap_usd`),errorText:p(`monthly_cap_usd`),"data-testid":`auto-top-up-cap-input`,fullWidth:!0})}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-[18px]`,children:[(0,K.jsx)(i,{variant:`outlined`,onClick:a,disabled:t,children:`Cancel`}),(0,K.jsx)(i,{variant:`primary`,onClick:()=>{l({threshold_usd:!0,amount_usd:!0,monthly_cap_usd:!0});let e={threshold_usd:li(o.threshold_usd),amount_usd:li(o.amount_usd),monthly_cap_usd:li(o.monthly_cap_usd)};s(e);let t=ui(e);if(Object.keys(t).length!==0)return;let n=e=>e===``?``:`${parseInt(e,10)}.00`;r({threshold_usd:n(e.threshold_usd),amount_usd:n(e.amount_usd),monthly_cap_usd:e.monthly_cap_usd===``?``:n(e.monthly_cap_usd)})},disabled:t,"data-testid":`auto-top-up-save-button`,children:`Save`})]})]})})}function pi(e){if(!e)return``;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function mi(e){if(!e)return`$0`;let t=parseFloat(e);if(!Number.isFinite(t))return`$0`;let n=Math.abs(t).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2}),r=n.endsWith(`.00`)?n.slice(0,-3):n;return t<0?`-$${r}`:`$${r}`}var hi={enabled:!1,threshold_usd:null,amount_usd:null,monthly_cap_usd:null,has_payment_method:!1,payment_method_brand:null,payment_method_last4:null,stripe_payment_method_updated_at:null,last_charge_at:null,last_failure_at:null,last_failure_reason:null,disabled_due_to_repeated_failures:!1,paused_until:null,current_month_credits_purchased_usd:`0.00`,current_month_charged_usd:`0.00`,next_trigger_amount_usd:null,stubbed:!1};function gi(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&typeof r[0]==`string`&&(t[n]=r[0]);return t}function _i(e){let{brand:t,last4:n}=e;return!t&&!n?null:n?`Charged to ${oi(t,n)}`:`Charged to ${ai(t??`card`)}`}function vi(){let e=c(),t=l(xe()),n=u(Ne()),r=u(Ae()),[a,o]=(0,G.useState)(`view`),[s,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1);if((0,G.useEffect)(()=>{m&&t.data?.has_payment_method&&h(!1)},[m,t.data?.has_payment_method]),t.isLoading)return(0,K.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,K.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Loading…`})});if(t.isError||!t.data)return(0,K.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,K.jsx)(F,{tone:`error`,children:`Failed to load auto top-up configuration.`})});let g=t.data,_=g.enabled===!0,v=g.disabled_due_to_repeated_failures===!0&&!_,y=()=>{n.reset(),r.reset(),o(`form`)},b=()=>{o(`view`),d(!1)},x=()=>{r.reset(),p(!1)},S=t=>{n.mutate({body:{enabled:!0,threshold_usd:t.threshold_usd,amount_usd:t.amount_usd,monthly_cap_usd:t.monthly_cap_usd===``?null:t.monthly_cap_usd}},{onSuccess:t=>{Te(e,void 0,e=>({...t,payment_method_brand:e?.payment_method_brand??null,payment_method_last4:e?.payment_method_last4??null})),e.invalidateQueries({queryKey:Me()}),b()}})},C=()=>{r.mutate({},{onSuccess:()=>{Te(e,void 0,e=>({...hi,has_payment_method:e?.has_payment_method??!1,payment_method_brand:e?.payment_method_brand??null,payment_method_last4:e?.payment_method_last4??null,stripe_payment_method_updated_at:e?.stripe_payment_method_updated_at??null})),p(!1),o(`view`),d(!1)}})},w=e=>{if(e&&!_){if(!g.has_payment_method||v){h(!0);return}h(!1),d(!0),y();return}if(!e&&!_&&s){b();return}!e&&_&&p(!0)},T=a===`form`,E=gi(n.error),D=n.isError&&Object.keys(E).length===0,O=_||s,k=_i({brand:g.payment_method_brand,last4:g.payment_method_last4});return(0,K.jsxs)(`div`,{"data-testid":`auto-top-up-card`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(z,{checked:O,onChange:w,label:`Enable Auto-Reload`}),_&&!T&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`text-right`,children:[(0,K.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-summary`,children:[`Add `,mi(g.amount_usd),` when the balance falls under `,mi(g.threshold_usd)]}),g.monthly_cap_usd!=null&&(0,K.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-cap-progress`,children:[mi(g.current_month_credits_purchased_usd),` of`,` `,mi(g.monthly_cap_usd),` this month`]})]}),(0,K.jsx)(i,{variant:`outlined`,onClick:y,"data-testid":`auto-top-up-edit-button`,children:`Adjust`})]})]}),v&&(0,K.jsx)(F,{tone:`warning`,className:`mt-3`,"data-testid":`auto-top-up-declined-cutoff`,children:`We paused automatic reloads after several declined payments. Add a new payment method below to turn auto-reload back on.`}),(0,K.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-in-out`,style:{gridTemplateRows:m&&!v?`1fr`:`0fr`},children:(0,K.jsx)(`div`,{className:`overflow-hidden`,children:(0,K.jsx)(F,{tone:`warning`,className:`mt-3`,children:`You must first add a Payment Method before you can enable automatic credit reloads.`})})}),D&&(0,K.jsx)(F,{tone:`error`,className:`mt-4`,"data-testid":`auto-top-up-update-error`,children:`Failed to save automatic top-ups. Please try again.`}),r.isError&&(0,K.jsx)(F,{tone:`error`,className:`mt-4`,"data-testid":`auto-top-up-disable-error`,children:`Failed to disable automatic top-ups. Please try again.`}),T&&(0,K.jsx)(fi,{initialValues:_?{threshold_usd:pi(g.threshold_usd),amount_usd:pi(g.amount_usd),monthly_cap_usd:pi(g.monthly_cap_usd)}:void 0,submitting:n.isPending,serverErrors:E,onCancel:b,onSave:S}),_&&!g.has_payment_method&&(0,K.jsx)(F,{tone:`warning`,className:`mt-3`,"data-testid":`auto-top-up-no-pm`,children:`You must add a Payment Method.`}),_&&g.has_payment_method&&(0,K.jsx)(`p`,{className:`mt-3 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-saved-pm`,children:k??`Charged to a saved card`}),(_||T)&&(0,K.jsx)(F,{tone:`info`,className:`mt-4`,children:`If you're too close to your monthly limit, the auto-reload will only top up to that limit.`}),(0,K.jsx)(si,{open:f,confirming:r.isPending,onCancel:x,onConfirm:C})]})}function yi(e){let t=parseFloat(e);return Number.isFinite(t)?`$${t.toFixed(2)}`:`$${e}`}function bi(e){if(e.trim()===``)return;let t=parseFloat(e);if(!Number.isFinite(t)||t<1||t>1e3)return`Must be between $1 and $1,000`;if(!/^\d+(\.\d{1,2})?$/.test(e.trim()))return`Use at most two decimal places`}function xi(){let e=c(),t=l(De()),n=u(Fe()),[r,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(!1);if(t.isLoading)return(0,K.jsx)(`div`,{"data-testid":`low-balance-alert-card`,children:(0,K.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Loading…`})});if(t.isError||!t.data)return(0,K.jsx)(`div`,{"data-testid":`low-balance-alert-card`,children:(0,K.jsx)(F,{tone:`error`,children:`Failed to load low-balance alert settings.`})});let d=t.data,f=r??d.threshold_usd??``,p=bi(f),m=e=>{a(e.target.value)},h=t=>{n.mutate({body:{threshold_usd:t}},{onSuccess:t=>{Ee(e,void 0,t),e.invalidateQueries({queryKey:Ge()}),a(null),s(!1)}})},g=()=>{if(s(!0),p)return;let e=f.trim();h(e===``?null:parseFloat(e).toFixed(2))},_=()=>{a(``),s(!1),h(null)},v=n.isError,y=o?p:void 0;return(0,K.jsxs)(`div`,{"data-testid":`low-balance-alert-card`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`min-w-[12rem] flex-1`,children:(0,K.jsx)(R,{type:`number`,step:`0.01`,label:`Alert me when my balance drops below`,helperText:`Default is ${yi(d.default_threshold_usd)} when unset`,placeholder:d.effective_threshold_usd,value:f,onChange:m,onBlur:()=>s(!0),errorText:y,"data-testid":`low-balance-alert-input`,fullWidth:!0})}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-[18px]`,children:[d.threshold_usd!=null&&(0,K.jsx)(i,{variant:`outlined`,onClick:_,disabled:n.isPending,"data-testid":`low-balance-alert-reset-button`,children:`Reset to default`}),(0,K.jsx)(i,{variant:`primary`,onClick:g,disabled:n.isPending,"data-testid":`low-balance-alert-save-button`,children:`Save`})]})]}),v&&(0,K.jsx)(F,{tone:`error`,className:`mt-4`,"data-testid":`low-balance-alert-update-error`,children:`Failed to save low-balance alert. Please try again.`})]})}var Si=2e3;function Ci(e){let t=parseFloat(e);if(Number.isNaN(t))return`0`;let n=Math.abs(t).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2}),r=n.endsWith(`.00`)?n.slice(0,-3):n;return t<0?`-${r}`:r}function wi(){let e=c(),{data:t,isLoading:n,isError:r}=l(Je()),a=t??null,[o,s]=(0,G.useState)(!1),u=(0,G.useRef)(0),d=(0,G.useRef)(null),m=Se({onSuccess:()=>{e.invalidateQueries({queryKey:ze()})},onError:()=>{u.current<3&&(d.current=setTimeout(()=>{m.reset()},Si))}});(0,G.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let h=m.mutate;(0,G.useEffect)(()=>{a&&a.settled_balance===`0.00`&&a.pending_compute===`0.00`&&a.effective_balance===`0.00`&&u.current<3&&!m.isPending&&!m.isError&&!m.isSuccess&&(u.current+=1,h({}))},[a,m.isPending,m.isError,m.isSuccess,h]);let g=(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(f,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Balance`}),(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`An overview of your credit balance and pending charges.`})]}),(0,K.jsx)(i,{variant:`primary`,onClick:()=>s(!0),disabled:n||!a,"data-testid":`add-credits-button`,children:`Add Credits`})]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(p,{padding:`md`,children:[g,n?(0,K.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`}),`Loading billing summary...`]}):r?(0,K.jsx)(`div`,{className:`mt-4`,children:(0,K.jsx)(F,{tone:`error`,children:`Failed to load billing summary. Please try again later.`})}):a?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`mt-4`,children:(()=>{if(!a)return null;let e=parseFloat(a.effective_balance)<0,t=parseFloat(a.settled_balance)<0,n=parseFloat(a.pending_compute)<0;return(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,K.jsx)(I,{icon:(0,K.jsx)(tt,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,K.jsx)(`span`,{"data-testid":`effective-balance`,children:Ci(a.effective_balance)}),label:`Balance`,tone:e?`negative`:`default`}),(0,K.jsx)(I,{icon:(0,K.jsx)(St,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,K.jsx)(`span`,{"data-testid":`settled-balance`,children:Ci(a.settled_balance)}),label:`Settled Balance`,tone:t?`negative`:`default`}),(0,K.jsx)(I,{icon:(0,K.jsx)(Ct,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,K.jsx)(`span`,{"data-testid":`pending-charges`,children:Ci(a.pending_compute)}),label:a.is_degraded?`Pending Usage (estimated)`:`Pending Usage`,tone:a.is_degraded?`muted`:n?`negative`:`default`})]})})()}),a.is_degraded&&(0,K.jsx)(`div`,{className:`mt-4`,children:(0,K.jsx)(F,{tone:`warning`,children:`Pending charges could not be calculated. The balance shown may be incomplete.`})})]}):(0,K.jsx)(`p`,{className:`mt-4 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No billing information available.`}),(0,K.jsx)(`div`,{className:`mt-6 border-t border-[var(--border-base)] pt-6`,children:(0,K.jsx)(vi,{})}),(0,K.jsx)(`div`,{className:`mt-6 border-t border-[var(--border-base)] pt-6`,children:(0,K.jsx)(xi,{})})]}),(0,K.jsx)(ht,{open:o,onOpenChange:s})]})}var Ti=1e3,Ei=15e3,Di=3e3,Oi=45e3,ki=`billing-portal-return`;function Ai(e,t){if(!e)return{kind:`info`,message:`Subscription updated.`};let n=e.cancel_at_period_end||!!e.cancel_at,r=t.cancel_at_period_end||!!t.cancel_at;return!n&&r?{kind:`info`,message:`Pro plan canceled. You'll have access until ${t.cancel_at?Lr(t.cancel_at):`the end of your billing period`}.`}:n&&!r?{kind:`success`,message:`Pro plan reactivated.`}:{kind:`info`,message:`Subscription updated.`}}function ji(){let[e]=o(),t=s(),n=c(),r=(0,G.useRef)(null);return(0,G.useEffect)(()=>()=>{r.current!==null&&(clearInterval(r.current),r.current=null)},[]),(0,G.useEffect)(()=>{if(e.get(`portal_return`)!==`true`)return;let i={current:!1},a=Pr(),o=He(),s=Le(),c=Date.now();async function l(){await n.invalidateQueries({queryKey:s});let e=await n.fetchQuery(o);return{cancel_at_period_end:e.cancel_at_period_end,cancel_at:e.cancel_at}}async function u(){let e=await l();for(;!i.current&&a&&e.cancel_at_period_end===a.cancel_at_period_end&&e.cancel_at===a.cancel_at&&Date.now()-c<Ei&&(await new Promise(e=>setTimeout(e,Ti)),!i.current);)e=await l();return e}return(async()=>{try{let e=await u();if(i.current)return;let{kind:t,message:n}=Ai(a,e);t===`success`?V.success(n,{id:ki}):V.info(n,{id:ki})}catch{if(i.current)return;V.info(`Subscription updated.`,{id:ki})}finally{if(!i.current){Fr(),t(U.settings.billing,{replace:!0});let e=Date.now();r.current!==null&&clearInterval(r.current),r.current=setInterval(()=>{if(Date.now()-e>=Oi){r.current!==null&&(clearInterval(r.current),r.current=null);return}l().catch(e=>{console.error(`billing poll error:`,e)})},Di)}}})(),()=>{i.current=!0}},[e,t,n]),null}var Mi=[7,30,90].map(e=>({value:`${e}`,label:`Last ${e} days`}));function Ni(e,t=W()){let{fromDate:n,toDate:r}=vt(e,t);return{from:n,to:r}}function Pi(e,t){let n=new Date(e),r=new Date(t);return Math.round((r.getTime()-n.getTime())/864e5)+1}function Fi({from:e,to:t}){let n=Pi(e,t);return n===7?7:n===90?90:30}function Ii({value:e,onChange:t}){let n=st(),r=(0,G.useMemo)(()=>`${Fi(e)}`,[e]);return(0,K.jsx)(H,{options:Mi,value:r,onChange:e=>{let r=Number(e);t(Ni(r,n),r)},"aria-label":`Date range`})}var Li={strokeDasharray:`3 3`,stroke:`var(--border-subtle)`,strokeOpacity:.4},Ri={fontSize:12,fill:`var(--content-tertiary)`},zi={stroke:`var(--border-subtle)`,strokeOpacity:.4},Bi=[`#3b82f6`,`#10b981`,`#f59e0b`,`#ef4444`,`#8b5cf6`,`#06b6d4`,`#ec4899`,`#84cc16`];function Vi({item:e}){return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5 text-[13px] text-[var(--content-default)]`,children:[(0,K.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,K.jsx)(`span`,{children:e.label}),(0,K.jsx)(`span`,{className:`ml-auto tabular-nums`,children:e.value})]})}function Hi({active:e,payload:t,hoveredKey:n,label:r,labelMap:i,colorMap:a,formatValue:o,showTotal:s,formatLabel:c}){if(!e||!t?.length)return null;let l=t.filter(e=>e.value!=null&&e.dataKey!=null).map(e=>({key:String(e.dataKey),label:i[String(e.dataKey)]??String(e.dataKey),value:o(Number(e.value)),color:a[String(e.dataKey)]??`#6b7280`,numericValue:Number(e.value)})).sort((e,t)=>e.numericValue===t.numericValue?e.label.localeCompare(t.label):t.numericValue-e.numericValue),u=n?l.find(e=>e.key===n):null,d=u?l.filter(e=>e.key!==n):l,f=l.reduce((e,t)=>e+t.numericValue,0);return(0,K.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-overlay)] px-3.5 py-2.5 shadow-[var(--shadow-popover)]`,children:[(0,K.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-[var(--content-secondary)]`,children:(c??_t)(String(r))}),u&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Vi,{item:u}),d.length>0&&(0,K.jsx)(`div`,{className:`my-1.5 border-t border-[var(--border-subtle)]`})]}),d.map(e=>(0,K.jsx)(Vi,{item:e},e.key)),s&&(0,K.jsx)(`div`,{className:`mt-1 flex items-center gap-2 border-t border-[var(--border-subtle)] pt-1.5 text-[13px] font-semibold text-[var(--content-default)]`,children:(0,K.jsxs)(`span`,{children:[`Total: `,o(f)]})})]})}function Ui(e,t){let[n,r]=e,[i,a]=t,o=r-n||1;return e=>i+(e-n)/o*(a-i)}function Wi(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t,r;return r=n<=1?1:n<=2?2:n<=2.5?2.5:n<=5?5:10,r*t}function Gi(e){if(e>=1)return+!Number.isInteger(e);let t=e/10**Math.floor(Math.log10(e)),n=Math.abs(t-2.5)<.01;return Math.ceil(-Math.log10(e))+ +!!n}function Ki(e,t){let n=Math.max(0,...e),r=t?.tickCount??5;return n===0?t?.integerOnly?r:1:t?.integerOnly?Math.max(1,Math.ceil(n/r))*r:Wi(n/r)*r}function qi(e,t){if(e===0)return[0];let n=e/t,r=10**(n>=1?0:Math.ceil(-Math.log10(n))+2),i=[];for(let e=0;e<=t;e++)i.push(Math.round(n*e*r)/r);return i}function Ji(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return[`M${e},${t+a}`,`A${a},${a} 0 0 1 ${e+a},${t}`,`H${e+n-a}`,`A${a},${a} 0 0 1 ${e+n},${t+a}`,`V${t+r}`,`H${e}`,`Z`].join(``)}function Yi(e,t){if(e<=0)return[];if(t)return e<=3?Array.from({length:e},(e,t)=>t):[0,Math.floor(e/2),e-1];let n=Math.max(1,Math.ceil(e/Math.min(e,12))),r=[];for(let t=0;t<e;t+=n)r.push(t);return r[r.length-1]!==e-1&&r.push(e-1),r}var Xi=40,Zi={fontSize:11,fill:`var(--content-tertiary)`},Qi={runtime_proxy_api:`#3b82f6`,oauth_proxy:`#f59e0b`};function $i(e,t){return Qi[e]??Bi[t%Bi.length]??`#6b7280`}function ea(e,t){let n=new Set,r={};for(let t of e)for(let e of t.groups)n.add(e.group_key),r[e.group_key]=e.group_label;return{data:e.map(e=>{let n={date:e.date};for(let r of e.groups)n[r.group_key]=t===`spend`?parseFloat(r.total_usd):r.event_count;return n}),stackKeys:Array.from(n),labelMap:r}}function ta({stackKeys:e,labelMap:t}){return(0,K.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-5 gap-y-1 pt-3 text-body-small-default`,children:e.map((e,n)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rounded-sm`,style:{backgroundColor:$i(e,n)}}),(0,K.jsx)(`span`,{className:`text-[var(--content-quiet)]`,children:t[e]??e})]},e))})}var na=350,ra={top:8,right:4,bottom:32,left:0},ia=.2,aa=5,oa=12,sa=200;function ca({buckets:e,metric:t,onBarClick:n}){let r=nt(),i=(0,G.useRef)(null),[a,o]=(0,G.useState)(0);(0,G.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&o(e.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]);let{data:s,stackKeys:c,labelMap:l}=(0,G.useMemo)(()=>ea(e,t),[e,t]),u=(0,G.useMemo)(()=>{let e={};for(let t=0;t<c.length;t++)e[c[t]]=$i(c[t],t);return e},[c]),d=(0,G.useCallback)(e=>t===`spend`?`$${e.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`:e.toLocaleString(`en-US`),[t]),[f,p]=(0,G.useState)(null),m=r?Xi:56,h=r?Zi:Ri,g=ra.left+m,_=Math.max(0,a-g-ra.right),v=ra.top,y=na-ra.top-ra.bottom,b=(0,G.useMemo)(()=>s.map(e=>c.reduce((t,n)=>t+(Number(e[n])||0),0)),[s,c]),x=t===`events`,S=(0,G.useMemo)(()=>Ki(b,{integerOnly:x,tickCount:aa}),[b,x]),C=(0,G.useMemo)(()=>qi(S,aa),[S]),w=(0,G.useCallback)(e=>{if(t===`spend`){if(e===0)return`$0`;let t=S/aa,n=Math.max(t<1?2:0,Gi(t));return`$${e.toLocaleString(`en-US`,{minimumFractionDigits:n,maximumFractionDigits:n})}`}return e.toLocaleString(`en-US`)},[t,S]),T=(0,G.useMemo)(()=>Ui([0,S],[v+y,v]),[S,v,y]),E=s.length,D=E>0?_/E:0,O=D*(1-ia),k=(D-O)/2,A=(0,G.useMemo)(()=>Yi(E,r),[E,r]),j=c.length===0,M=j?[]:s.map((e,t)=>{let n=g+t*D+k,r=0;return{di:t,x:n,segments:c.map((t,i)=>{let a=Number(e[t])||0,o=r;r+=a;let s=T(r),l=T(o)-s,u=i===c.length-1;return{key:t,val:a,x:n,y:s,h:l,color:$i(t,i),isLast:u}})}}),ee=(e,t,n)=>{let r=i.current?.getBoundingClientRect();r&&p({x:e.clientX-r.left,y:e.clientY-r.top,datumIndex:t,hoveredKey:n})},te=()=>p(null),N=e=>{n&&n(e)},P=f?c.filter(e=>(Number(s[f.datumIndex]?.[e])||0)>0).map(e=>({dataKey:e,value:Number(s[f.datumIndex]?.[e])||0})):[],ne={left:f?Math.max(0,Math.min(f.x+oa,a-sa)):0,top:f?f.y-oa:0,visibility:f?`visible`:`hidden`};return(0,K.jsxs)(`div`,{onMouseDown:e=>e.preventDefault(),children:[(0,K.jsx)(`div`,{ref:i,className:`relative w-full`,style:{height:na},children:j?(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center text-body-medium-lighter text-[var(--content-faint)]`,children:`No usage data for this period`}):a>0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`svg`,{width:a,height:na,className:`block`,children:[C.map(e=>(0,K.jsx)(`line`,{x1:g,x2:g+_,y1:T(e),y2:T(e),stroke:Li.stroke,strokeOpacity:Li.strokeOpacity,strokeDasharray:Li.strokeDasharray},e)),(0,K.jsx)(`line`,{x1:g,x2:g+_,y1:v+y,y2:v+y,stroke:zi.stroke,strokeOpacity:zi.strokeOpacity}),C.map(e=>(0,K.jsx)(`text`,{x:g-8,y:T(e),textAnchor:`end`,dominantBaseline:`middle`,fontSize:h.fontSize,fill:h.fill,children:w(e)},e)),A.map(e=>{let t=s[e];return t?(0,K.jsx)(`text`,{x:g+e*D+D/2,y:v+y+20,textAnchor:`middle`,fontSize:h.fontSize,fill:h.fill,children:_t(String(t.date))},e):null}),M.map(({di:e,segments:t})=>t.map(t=>{if(t.h<=0)return null;let r=f?.hoveredKey&&f.hoveredKey!==t.key?.4:1,i={key:`${e}-${t.key}`,fill:t.color,opacity:r,cursor:n?`pointer`:void 0,onMouseMove:n=>ee(n,e,t.key),onMouseLeave:te,onClick:()=>N(t.key)};return t.isLast?(0,K.jsx)(`path`,{...i,d:Ji(t.x,t.y,O,t.h,3)}):(0,K.jsx)(`rect`,{...i,x:t.x,y:t.y,width:O,height:t.h})}))]}),(0,K.jsx)(`div`,{className:`pointer-events-none absolute z-[1] max-w-[calc(100vw-32px)] -translate-y-full`,style:ne,children:(0,K.jsx)(Hi,{active:!!f,payload:P,hoveredKey:f?.hoveredKey??void 0,label:f?String(s[f.datumIndex]?.date):``,labelMap:l,colorMap:u,formatValue:d})})]}):null}),!j&&(0,K.jsx)(ta,{stackKeys:c,labelMap:l})]})}function la(e=W()){return Ni(30,e)}function ua(e){if(e)return e.usageSource===`oauth_proxy`?`oauth_provider`:Zt(e.llmDimension??`model`)}function da(e,t=W()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource,group_by:ua(e.drilldown)}:{}}}function fa(e,t=W()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource}:{}}}function pa(e,t,n){return e===`full`&&t!==`gated`&&n}function ma(e){let t=st(),n=pa(ft({platformHostedOnly:!0}),ft(),ct()),r=l({...Xe({query:da(e,t)}),enabled:n}),i=l({...Be({query:fa(e,t)}),enabled:n});return{series:r.data,totals:i.data,isLoading:r.isLoading||i.isLoading,isError:r.isError||i.isError}}var ha=[{value:`spend`,label:`Spend ($)`},{value:`events`,label:`Events`}];function ga(e){if(e===void 0)return`—`;let t=parseFloat(e);return Number.isNaN(t)?`$0.00`:`$${t.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function _a(e){return e===void 0?`—`:e.toLocaleString(`en-US`)}function va(){let e=st(),[t,n]=(0,G.useState)(30),[r,i]=(0,G.useState)(()=>la(e)),a=(0,G.useMemo)(()=>t===null?r:Ni(t,e),[t,r,e]),o=(e,t)=>{n(t),i(e)},[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(`spend`),{series:d,totals:m,isLoading:g,isError:_}=ma({dateRange:a,setDateRange:e=>{n(null),i(e)},drilldown:s,setDrilldown:c}),v=s?void 0:e=>{let t={runtime_proxy_api:`runtime_proxy`,oauth_proxy:`oauth_proxy`}[e];t&&c({usageSource:t,...t===`runtime_proxy`?{llmDimension:Kt}:{}})};return(0,K.jsx)(p,{padding:`md`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(f,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Usage`}),(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`Overview of your spending habits.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 [&_[role=combobox]]:h-8 [&_[role=radio]]:h-7`,children:[(0,K.jsx)(Ii,{value:a,onChange:o}),(0,K.jsx)(`div`,{className:`w-44`,children:(0,K.jsx)(ae,{items:ha,value:l,onChange:u,ariaLabel:`Chart metric`})})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[(0,K.jsx)(I,{icon:(0,K.jsx)(tt,{className:`h-4 w-4`,"aria-hidden":!0}),value:g?(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):ga(m?.total_usd),label:`Spend`}),(0,K.jsx)(I,{icon:(0,K.jsx)(Tt,{className:`h-4 w-4`,"aria-hidden":!0}),value:g?(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):_a(m?.event_count),label:`Events`})]}),s&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsx)(`div`,{children:(0,K.jsxs)(`button`,{className:`flex items-center gap-1.5 text-body-medium-lighter text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)]`,onClick:()=>c(null),children:[(0,K.jsx)(h,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:`Back to all usage`}),(0,K.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:`/`}),(0,K.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:s.usageSource===`runtime_proxy`?`LLM Spend`:`OAuth Spend`})]})}),s.usageSource===`runtime_proxy`&&(0,K.jsx)(`div`,{className:`w-56`,children:(0,K.jsx)(ae,{items:Jt,value:s.llmDimension??`model`,onChange:e=>c({usageSource:`runtime_proxy`,llmDimension:e}),ariaLabel:`LLM spend dimension`})})]}),g?(0,K.jsx)(`div`,{className:`flex h-[345px] items-center justify-center rounded-xl bg-[var(--surface-base)]`,children:(0,K.jsx)(j,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}):_?(0,K.jsx)(`div`,{className:`flex h-[345px] items-center justify-center rounded-xl bg-[var(--surface-base)] text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Failed to load usage data.`}):d?(0,K.jsx)(`div`,{className:`rounded-xl bg-[var(--surface-base)] p-3`,children:(0,K.jsx)(ca,{buckets:d.buckets,metric:l,onBarClick:v})}):null]})})}function ya(){let{data:e}=l(He()),t=zr((0,G.useMemo)(()=>Ir(e),[e]));if(!e||e.plan_id!==`pro`||e.status===`canceled`||!e.cancel_at_period_end&&!e.cancel_at)return null;let n=Rr(e);return n?(0,K.jsx)(F,{tone:`info`,title:`Your Pro plan will end on ${Lr(n)}.`,actions:(0,K.jsx)(i,{variant:`outlined`,size:`compact`,onClick:()=>t.mutate({}),disabled:t.isPending,leftIcon:t.isPending?(0,K.jsx)(j,{className:`animate-spin`}):void 0,"data-testid":`grace-period-reactivate-button`,children:`Reactivate`}),"data-testid":`grace-period-banner`,children:`You'll keep Pro features until then.`}):null}var ba=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),xa=t(((e,t)=>{var n=ba();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),X=e(t(((e,t)=>{t.exports=xa()()}))(),1);function Sa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ca(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Sa(Object(n),!0).forEach(function(t){Ta(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sa(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wa(e){"@babel/helpers - typeof";return wa=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},wa(e)}function Ta(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ea(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Da(e,t){if(e==null)return{};var n=Ea(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Oa(e,t){return ka(e)||Aa(e,t)||ja(e,t)||Na()}function ka(e){if(Array.isArray(e))return e}function Aa(e,t){var n=e&&(typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`]);if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function ja(e,t){if(e){if(typeof e==`string`)return Ma(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ma(e,t)}}function Ma(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Na(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
3
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Z=function(e,t,n){var r=!!n,i=G.useRef(n);G.useEffect(function(){i.current=n},[n]),G.useEffect(function(){if(!r||!e)return function(){};var n=function(){i.current&&i.current.apply(i,arguments)};return e.on(t,n),function(){e.off(t,n)}},[r,t,e,i])},Pa=function(e){var t=G.useRef(e);return G.useEffect(function(){t.current=e},[e]),t.current},Fa=function(e){return e!==null&&wa(e)===`object`},Ia=function(e){return Fa(e)&&typeof e.then==`function`},La=function(e){return Fa(e)&&typeof e.elements==`function`&&typeof e.createToken==`function`&&typeof e.createPaymentMethod==`function`&&typeof e.confirmCardPayment==`function`},Ra=`[object Object]`,za=function e(t,n){if(!Fa(t)||!Fa(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var i=Object.prototype.toString.call(t)===Ra;if(i!==(Object.prototype.toString.call(n)===Ra))return!1;if(!i&&!r)return t===n;var a=Object.keys(t),o=Object.keys(n);if(a.length!==o.length)return!1;for(var s={},c=0;c<a.length;c+=1)s[a[c]]=!0;for(var l=0;l<o.length;l+=1)s[o[l]]=!0;var u=Object.keys(s);if(u.length!==a.length)return!1;var d=t,f=n;return u.every(function(t){return e(d[t],f[t])})},Ba=function(e,t,n){return Fa(e)?Object.keys(e).reduce(function(r,i){var a=!Fa(t)||!za(e[i],t[i]);return n.includes(i)?(a&&console.warn(`Unsupported prop change: options.${i} is not a mutable property.`),r):a?Ca(Ca({},r||{}),{},Ta({},i,e[i])):r},null):null},Va="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",Ha=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Va;if(e===null||La(e))return e;throw Error(t)},Ua=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Va;if(Ia(e))return{tag:`async`,stripePromise:Promise.resolve(e).then(function(e){return Ha(e,t)})};var n=Ha(e,t);return n===null?{tag:`empty`}:{tag:`sync`,stripe:n}},Wa=function(e){!e||!e._registerWrapper||!e.registerAppInfo||(e._registerWrapper({name:`react-stripe-js`,version:`6.4.0`}),e.registerAppInfo({name:`react-stripe-js`,version:`6.4.0`,url:`https://stripe.com/docs/stripe-js/react`}))},Ga=G.createContext(null);Ga.displayName=`ElementsContext`;var Ka=function(e,t){if(!e)throw Error(`Could not find Elements context; You need to wrap the part of your app that ${t} in an <Elements> provider.`);return e},qa=function(e){var t=e.stripe,n=e.options,r=e.children,i=G.useMemo(function(){return Ua(t)},[t]),a=Oa(G.useState(function(){return{stripe:i.tag===`sync`?i.stripe:null,elements:i.tag===`sync`?i.stripe.elements(n):null}}),2),o=a[0],s=a[1];G.useEffect(function(){var e=!0,t=function(e){s(function(t){return t.stripe?t:{stripe:e,elements:e.elements(n)}})};return i.tag===`async`&&!o.stripe?i.stripePromise.then(function(n){n&&e&&t(n)}):i.tag===`sync`&&!o.stripe&&t(i.stripe),function(){e=!1}},[i,o,n]);var c=Pa(t);G.useEffect(function(){c!==null&&c!==t&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[c,t]);var l=Pa(n);return G.useEffect(function(){if(o.elements){var e=Ba(n,l,[`clientSecret`,`fonts`]);e&&o.elements.update(e)}},[n,l,o.elements]),G.useEffect(function(){Wa(o.stripe)},[o.stripe]),G.createElement(Ga.Provider,{value:o},r)};qa.propTypes={stripe:X.default.any,options:X.default.object};var Ja=function(e){return Ka(G.useContext(Ga),e)},Ya=function(e){var t=e.children;return t(Ja(`mounts <ElementsConsumer>`))};Ya.propTypes={children:X.default.func.isRequired};var Xa=G.createContext(null);Xa.displayName=`CheckoutContext`;var Za=function(e){var t=G.useContext(Xa),n=G.useContext(Ga);if(t){if(n)throw Error(`You cannot wrap the part of your app that ${e} in both a checkout provider and <Elements> provider.`);return t}else return Ka(n,e)},Qa=[`mode`],$a=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},Q=function(e,t,n){var r=`${$a(e)}Element`,i=t?function(e){Za(`mounts <${r}>`);var t=e.id,n=e.className;return G.createElement(`div`,{id:t,className:n})}:function(t){var n=t.id,i=t.className,a=t.options,o=a===void 0?{}:a,s=t.onBlur,c=t.onFocus,l=t.onReady,u=t.onChange,d=t.onEscape,f=t.onClick,p=t.onLoadError,m=t.onLoaderStart,h=t.onNetworksChange,g=t.onConfirm,_=t.onCancel,v=t.onShippingAddressChange,y=t.onShippingRateChange,b=t.onSavedPaymentMethodRemove,x=t.onSavedPaymentMethodUpdate,S=t.onAvailablePaymentMethodsChange,C=Za(`mounts <${r}>`),w=`elements`in C?C.elements:null,T=`checkoutState`in C?C.checkoutState:null,E=T?.type===`success`||T?.type===`loading`?T.sdk:null,D=Oa(G.useState(null),2),O=D[0],k=D[1],A=G.useRef(null),j=G.useRef(null);Z(O,`blur`,s),Z(O,`focus`,c),Z(O,`escape`,d),Z(O,`click`,f),Z(O,`loaderror`,p),Z(O,`loaderstart`,m),Z(O,`networkschange`,h),Z(O,`confirm`,g),Z(O,`cancel`,_),Z(O,`shippingaddresschange`,v),Z(O,`shippingratechange`,y),Z(O,`savedpaymentmethodremove`,b),Z(O,`savedpaymentmethodupdate`,x),Z(O,`availablepaymentmethodschange`,S),Z(O,`change`,u);var M;l&&(M=e===`expressCheckout`?l:function(){l(O)}),Z(O,`ready`,M),G.useLayoutEffect(function(){if(A.current===null&&j.current!==null&&(w||E)){var t=null;if(E){var n=E,i=E;switch(e){case`paymentForm`:t=i.createForm(o);break;case`payment`:t=n.createPaymentElement(o);break;case`address`:if(`mode`in o){var a=o.mode,s=Da(o,Qa);if(a===`shipping`)t=n.createShippingAddressElement(s);else if(a===`billing`)t=n.createBillingAddressElement(s);else throw Error(`Invalid options.mode. mode must be 'billing' or 'shipping'.`)}else throw Error(`You must supply options.mode. mode must be 'billing' or 'shipping'.`);break;case`expressCheckout`:t=n.createExpressCheckoutElement(o);break;case`currencySelector`:t=E.createCurrencySelectorElement();break;case`taxId`:t=n.createTaxIdElement(o);break;case`contactDetails`:t=n.createContactDetailsElement();break;default:throw Error(`<${r}> is not supported inside a checkout provider. Use an <Elements> provider instead.`)}}else w&&(t=w.create(e,o));A.current=t,k(t),t&&t.mount(j.current)}},[w,E,o]);var ee=Pa(o);return G.useEffect(function(){if(A.current){var e=Ba(o,ee,[`paymentRequest`]);e&&`update`in A.current&&A.current.update(e)}},[o,ee]),G.useLayoutEffect(function(){return function(){if(A.current&&typeof A.current.destroy==`function`)try{A.current.destroy(),A.current=null}catch{}}},[]),G.createElement(`div`,{id:n,className:i,ref:j})};return i.propTypes={id:X.default.string,className:X.default.string,onChange:X.default.func,onBlur:X.default.func,onFocus:X.default.func,onReady:X.default.func,onEscape:X.default.func,onClick:X.default.func,onLoadError:X.default.func,onLoaderStart:X.default.func,onNetworksChange:X.default.func,onConfirm:X.default.func,onCancel:X.default.func,onShippingAddressChange:X.default.func,onShippingRateChange:X.default.func,onSavedPaymentMethodRemove:X.default.func,onSavedPaymentMethodUpdate:X.default.func,onAvailablePaymentMethodsChange:X.default.func,options:X.default.object},i.displayName=r,i.__elementType=e,i},$=typeof window>`u`,eo=G.createContext(null);eo.displayName=`EmbeddedCheckoutProviderContext`,Q(`auBankAccount`,$),Q(`card`,$),Q(`cardNumber`,$),Q(`cardExpiry`,$),Q(`cardCvc`,$),Q(`iban`,$),Q(`payment`,$),Q(`expressCheckout`,$),Q(`paymentRequestButton`,$),Q(`linkAuthentication`,$),Q(`contactDetails`,$),Q(`address`,$),Q(`shippingAddress`,$),Q(`paymentMethodMessaging`,$),Q(`taxId`,$),Q(`issuingCardNumberDisplay`,$),Q(`issuingCardCvcDisplay`,$),Q(`issuingCardExpiryDisplay`,$),Q(`issuingCardPinDisplay`,$),Q(`issuingCardCopyButton`,$);var to=`dahlia`,no=`https://js.stripe.com`,ro=`${no}/${to}/stripe.js`,io=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,ao=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,oo=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,so=function(e){return io.test(e)||ao.test(e)},co=function(){for(var e=document.querySelectorAll(`script[src^="${no}"]`),t=0;t<e.length;t++){var n=e[t];if(so(n.src))return n}return null},lo=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${ro}${t}`;var r=document.head||document.body;if(!r)throw Error(`Expected document.body not to be null. Stripe.js requires a <body> element.`);return r.appendChild(n),n},uo=null,fo=null,po=null,mo=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},ho=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},go=function(e){return uo===null?(uo=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(oo),window.Stripe){t(window.Stripe);return}try{var r=co();if(r&&e)console.warn(oo);else if(!r)r=lo(e);else if(r&&po!==null&&fo!==null){var i;r.removeEventListener(`load`,po),r.removeEventListener(`error`,fo),(i=r.parentNode)==null||i.removeChild(r),r=lo(e)}po=ho(t,n),fo=mo(n),r.addEventListener(`load`,po),r.addEventListener(`error`,fo)}catch(e){n(e);return}}),uo.catch(function(e){return uo=null,Promise.reject(e)})):uo},_o,vo=!1,yo=function(){return _o||(_o=go(null).catch(function(e){return _o=null,Promise.reject(e)}),_o)};Promise.resolve().then(function(){return yo()}).catch(function(e){vo||console.warn(e)});function bo(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)?{theme:`night`}:{theme:`stripe`}}function xo({open:e,onClose:t,onSavedOptimistic:n}){let r=u(je()),{mutate:i,reset:a}=r;return(0,G.useEffect)(()=>{e||a()},[e,i,a]),(0,G.useMemo)(()=>bo(),[r.data?.client_secret??null]),(0,K.jsx)(B.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,K.jsxs)(B.Content,{size:`sm`,children:[(0,K.jsx)(B.Header,{children:(0,K.jsx)(B.Title,{children:`Save Payment Method`})}),(0,K.jsx)(B.Body,{className:`min-h-[260px]`,children:(0,K.jsx)(So,{})})]})})}function So(){return(0,G.useEffect)(()=>{console.warn(`[AutoTopUpPaymentMethodModal] VITE_STRIPE_PUBLISHABLE_KEY is not set; the payment-method modal cannot mount Stripe Elements.`)},[]),(0,K.jsx)(F,{tone:`error`,children:`Payment method setup is currently unavailable. Please try again later.`})}function Co(){return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(f,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Payment Method`}),(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`This is the payment method that will be used for automated credit reloads.`})]})}function wo(){let e=c(),t=l(xe()),[n,r]=(0,G.useState)(!1),[a,o]=(0,G.useState)(!1),s=u(et()),d=async()=>{let t=Date.now(),n=e=>e?.stripe_payment_method_updated_at??null,r=n(e.getQueryData(Me()));try{await e.invalidateQueries({queryKey:Me()})}catch{}for(;Date.now()-t<2e4;){try{let t=await e.fetchQuery(xe());if(t.has_payment_method&&n(t)!==r)return}catch{}await new Promise(e=>setTimeout(e,1500))}};if(t.isLoading)return(0,K.jsxs)(p,{padding:`md`,children:[(0,K.jsx)(Co,{}),(0,K.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`}),`Loading…`]})]});if(t.isError||!t.data)return(0,K.jsxs)(p,{padding:`md`,children:[(0,K.jsx)(Co,{}),(0,K.jsx)(`div`,{className:`mt-4`,children:(0,K.jsx)(F,{tone:`error`,children:`Failed to load payment method.`})})]});let m=t.data,h=ai(m.payment_method_brand??`card`),g=m.payment_method_last4;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(p,{padding:`md`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsx)(Co,{}),m.has_payment_method?(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] px-2 py-1.5`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,K.jsx)(C,{className:`h-3.5 w-3.5`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(f,{variant:`body-medium-default`,as:`span`,children:h}),g?(0,K.jsxs)(f,{variant:`body-small-default`,as:`div`,className:`text-[var(--content-tertiary)]`,children:[`Ending in `,g]}):null]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,K.jsx)(i,{variant:`ghost`,onClick:()=>r(!0),children:`Change`}),(0,K.jsx)(i,{variant:`ghost`,onClick:()=>o(!0),disabled:a||s.isPending,leftIcon:(0,K.jsx)(pt,{className:`h-3.5 w-3.5`}),children:`Remove`})]})]}):(0,K.jsx)(i,{className:`self-start`,onClick:()=>r(!0),children:`Add Card`})]})}),(0,K.jsx)(oe,{open:a,title:`Remove payment method?`,message:`Removing your payment method will disable automatic top-ups. You can re-enable them after adding a new payment method.`,confirmLabel:s.isPending?`Removing…`:`Remove`,cancelLabel:`Keep`,destructive:!0,onConfirm:()=>{s.isPending||s.mutate({},{onSuccess:()=>{Te(e,void 0,e=>e?{...e,enabled:!1,has_payment_method:!1,payment_method_brand:null,payment_method_last4:null}:hi),o(!1)},onError:()=>{V.error(`Failed to remove payment method. Please try again.`),o(!1)}})},onCancel:()=>{s.isPending||o(!1)}}),(0,K.jsx)(xo,{open:n,onClose:()=>r(!1),onSavedOptimistic:d})]})}var To={invoices:[]};function Eo(e){switch(e){case`paid`:return`positive`;case`open`:return`warning`;case`uncollectible`:return`negative`;default:return`neutral`}}function Do(e,t){let n=t.toUpperCase();try{let t=new Intl.NumberFormat(void 0,{style:`currency`,currency:n}),r=t.resolvedOptions().maximumFractionDigits??2;return t.format(e/10**r)}catch{return`${(e/100).toFixed(2)} ${n}`}}function Oo(e){return dt(new Date(e*1e3),{alwaysShowYear:!0})}function ko(e){let t=document.createElement(`a`);t.href=e,t.target=`_blank`,t.rel=`noopener noreferrer`,document.body.appendChild(t),t.click(),t.remove()}function Ao({open:e,onOpenChange:t}){let[r,o]=(0,G.useState)(!1),s=l({queryKey:we(),enabled:e,queryFn:async({signal:e})=>{let{data:t,response:n}=await ge({throwOnError:!1,signal:e});if(n?.status===404)return To;if(!n?.ok||!t)throw Error(`Failed to load invoices (${n?.status??`network error`})`);return t}}),c=s.data?.invoices??[],u=c.some(e=>e.invoice_pdf!=null);async function d(){o(!0);try{let{data:e,response:t}=await _e({throwOnError:!1,parseAs:`blob`});if(!t?.ok||!(e instanceof Blob))throw Error(`Failed to download invoices (${t?.status??`network error`})`);let{saveFile:n}=await a(async()=>{let{saveFile:e}=await import(`./native-file-CHp_Tbhe.js`).then(e=>e.t);return{saveFile:e}},__vite__mapDeps([0,1,2,3]));await n(e,`invoices.zip`)}catch(e){n(e,{context:`download_all_invoices`}),V.error(`Failed to download invoices.`)}finally{o(!1)}}return(0,K.jsx)(B.Root,{open:e,onOpenChange:t,children:(0,K.jsxs)(B.Content,{size:`lg`,children:[(0,K.jsxs)(B.Header,{children:[(0,K.jsx)(B.Title,{icon:O,children:`Invoices`}),(0,K.jsx)(B.Description,{children:`Your billing history. Open an invoice for full details or download it as a PDF.`})]}),(0,K.jsx)(B.Body,{children:s.isLoading?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-[var(--content-tertiary)]`,children:[(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`}),(0,K.jsx)(f,{as:`span`,variant:`body-small-default`,children:`Loading invoices...`})]}):s.isError?(0,K.jsx)(F,{tone:`error`,children:`Failed to load invoices.`}):c.length===0?(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`py-6 text-center text-[var(--content-tertiary)]`,"data-testid":`invoices-empty`,children:`No Invoices Found`}):(0,K.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:c.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center gap-3 py-3`,"data-testid":`invoice-row`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(f,{variant:`body-medium-default`,as:`span`,className:`text-[var(--content-default)]`,children:e.number??`Invoice`}),e.status&&(0,K.jsx)(L,{tone:Eo(e.status),children:e.status})]}),(0,K.jsxs)(f,{variant:`body-small-default`,as:`div`,className:`text-[var(--content-tertiary)]`,children:[Oo(e.created),` ·`,` `,Do(e.amount_due,e.currency)]})]}),e.hosted_invoice_url&&(0,K.jsx)(i,{asChild:!0,variant:`ghost`,size:`compact`,leftIcon:(0,K.jsx)(D,{}),children:(0,K.jsx)(`a`,{href:e.hosted_invoice_url,target:`_blank`,rel:`noopener noreferrer`,children:`View`})}),e.invoice_pdf&&(0,K.jsx)(i,{variant:`ghost`,size:`compact`,iconOnly:(0,K.jsx)(E,{}),"aria-label":`Download invoice PDF`,onClick:()=>ko(e.invoice_pdf)})]},e.id))})}),(0,K.jsxs)(B.Footer,{children:[u&&(0,K.jsx)(i,{variant:`outlined`,leftIcon:r?(0,K.jsx)(j,{className:`animate-spin`}):(0,K.jsx)(E,{}),disabled:r,onClick:d,children:`Download all`}),(0,K.jsx)(B.Close,{asChild:!0,children:(0,K.jsx)(i,{variant:`primary`,children:`Done`})})]})]})})}var jo={pro:{icon:w,actionLabel:`Manage`,actionVariant:`outlined`,actionTestId:`plan-card-manage-button`,showsRenewal:!0},base:{icon:Et,actionLabel:`Upgrade to Pro`,actionVariant:`primary`,actionTestId:`plan-card-upgrade-button`,showsRenewal:!1}},Mo=jo.base;function No(){return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(f,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Plan`}),(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`Manage which Vellum plan you're on.`})]})}function Po({onManage:e}){let[t,n]=(0,G.useState)(!1),r=l(He()),a=l(Pe());if(r.isLoading||a.isLoading)return(0,K.jsxs)(p,{padding:`md`,children:[(0,K.jsx)(No,{}),(0,K.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`}),(0,K.jsx)(f,{as:`span`,variant:`body-small-default`,children:`Loading plan...`})]})]});let o=r.data,s=a.data?.plans,c=s?.find(e=>e.id===o?.plan_id);if(r.isError||a.isError||!o||!s||!c)return(0,K.jsx)(F,{tone:`error`,children:`Failed to load plan.`});let u=jo[c.id]??Mo,d=u.icon,m=c.name??c.id,h=u.showsRenewal&&(o.cancel_at_period_end===!0||!!o.cancel_at),g=o.status===`canceled`,_=Rr(o),v=u.showsRenewal&&!h&&!g&&o.current_period_end,y=u.showsRenewal&&h&&!g&&_,b=c.id===`pro`?c:void 0,x=o.selected_credit_tier??null,S=x==null?void 0:b?.credit_tiers,C=S?.find(e=>e.tier===x),w=C?`${C.label} (${Y(C.price_cents)})`:S?.length?x:null;return(0,K.jsxs)(p,{padding:`lg`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsx)(No,{}),(0,K.jsx)(i,{variant:`outlined`,leftIcon:(0,K.jsx)(O,{}),onClick:()=>n(!0),"data-testid":`plan-card-invoices-button`,children:`Invoices`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)]`,children:(0,K.jsx)(d,{className:`h-4 w-4 text-[var(--content-default)]`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,K.jsx)(f,{variant:`body-medium-default`,as:`div`,"data-testid":`plan-card-name`,children:m}),(0,K.jsx)(f,{variant:`body-small-default`,as:`div`,className:`leading-snug text-[var(--content-tertiary)]`,children:(0,K.jsx)(ti,{features:c.included_features,variant:`inline`})})]}),(0,K.jsx)(i,{variant:u.actionVariant,onClick:e,"data-testid":u.actionTestId,children:u.actionLabel})]}),w&&(0,K.jsxs)(f,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`plan-card-credit-bundle`,children:[`Monthly credits: `,w]}),v&&(0,K.jsxs)(f,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`plan-card-renews`,children:[`Renews on `,Lr(o.current_period_end),`.`]}),y&&(0,K.jsxs)(f,{as:`p`,variant:`body-small-default`,className:`text-[var(--system-mid-strong)]`,"data-testid":`plan-card-cancels`,children:[`Your plan ends on `,Lr(_),`.`]})]}),(0,K.jsx)(Ao,{open:t,onOpenChange:n})]})}var Fo=`settings-referral-panel`;function Io(e){return e.replace(/\.00$/,``)}function Lo({cap:e}){return(0,K.jsx)(`ul`,{className:`!m-0 !list-none space-y-2 !p-0`,children:[`This promotion is available to new users who sign up through your referral link only.`,`Rewards are earned once your invitee completes the creation of their Vellum account.`,`You may earn up to ${e} free credits through the Referral Program. We may change this limit at any time.`,`We do not grant credits for disposable or high-risk email accounts.`,`Each new user can generate only one (1) reward. No stacking or loophole hunting.`,`Please avoid spamming or misusing your referral link. Our systems actively monitor referral engagement.`,`If we detect suspicious or non-compliant activity, we reserve the right to withhold rewards or deactivate your referral link.`,`We may update, pause, or discontinue this program at any time.`].map(e=>(0,K.jsxs)(`li`,{className:`flex items-start gap-2 text-body-small-default`,style:{color:`var(--content-secondary)`},children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5`,children:`•`}),(0,K.jsx)(`span`,{children:e})]},e))})}function Ro(){let{data:e,isLoading:t,isError:n}=l($e()),[r,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),c=(0,G.useCallback)(e=>{navigator.clipboard.writeText(e).then(()=>{a(!0),V.success(`Copied to clipboard!`),setTimeout(()=>a(!1),2e3)})},[]),u=e?.is_eligible_for_credits===!1,d=u?`Invite friends to Vellum. You'll start earning referral credits once you've purchased credits or upgraded to Pro.`:e?`Share Vellum with friends - you'll each earn ${Io(e.referrer_credit_amount)} credits when they sign up, up to ${Io(e.earning_cap)} total.`:`Share Vellum with friends and earn credits for every signup.`;return(0,K.jsx)(p,{padding:`md`,id:Fo,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(f,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Earn Free Credits`}),(0,K.jsx)(f,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:d})]}),u&&(0,K.jsx)(F,{tone:`info`,children:`You're not currently earning referral credits. Buy credits or upgrade to Pro to start earning — your invite link still works in the meantime.`}),t?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`}),`Loading...`]}):n||!e?(0,K.jsx)(F,{tone:`error`,children:`Failed to load referral information.`}):(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-[200px] flex-1 items-center gap-1.5 rounded-lg bg-[var(--surface-base)] px-2 py-1.5`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,K.jsx)(tt,{className:`h-3.5 w-3.5`})}),(0,K.jsxs)(`span`,{className:`flex items-baseline gap-1 text-body-medium-default`,children:[(0,K.jsx)(`span`,{children:Io(e.total_earned)}),(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Credits Earned`})]})]}),(0,K.jsxs)(`div`,{className:`flex min-w-[200px] flex-1 items-center gap-1.5 rounded-lg bg-[var(--surface-base)] px-2 py-1.5`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,K.jsx)(at,{className:`h-3.5 w-3.5`})}),(0,K.jsxs)(`span`,{className:`flex items-baseline gap-1 text-body-medium-default`,children:[(0,K.jsx)(`span`,{children:e.referred_count}),(0,K.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Friends Referred`})]})]}),(0,K.jsx)(i,{variant:`outlined`,onClick:()=>c(e.referral_url),leftIcon:r?(0,K.jsx)(g,{className:`h-3.5 w-3.5`}):(0,K.jsx)(x,{className:`h-3.5 w-3.5`}),"data-testid":`referral-copy-button`,children:r?`Copied!`:`Copy Share Link`})]}),e&&(0,K.jsxs)(`div`,{className:`border-t border-[var(--border-base)] pt-3`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,className:`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)]`,children:[(0,K.jsx)(_,{className:`h-3.5 w-3.5 transition-transform ${o?`rotate-180`:``}`}),o?`Hide Terms and Conditions`:`View Terms and Conditions`]}),o&&(0,K.jsx)(`div`,{className:`mt-3`,children:(0,K.jsx)(Lo,{cap:Io(e.earning_cap)})})]})]})})}function zo({icon:e,label:t,from:n,to:r}){return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,K.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`},children:(0,K.jsx)(e,{className:`h-4 w-4 text-[var(--system-positive-strong)]`})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:t}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)] line-through`,children:n}),(0,K.jsx)(it,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`}),(0,K.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:r})]})]})]})}function Bo({open:e,onClose:t}){let n=l({...Ke(),enabled:e}),r=l({...Ue(),enabled:e}),a=n.data,o=a?.machine_size||`small`,s=a?.provisioned_storage_gib??null,c=r.data?.max_machine_tier??null,u=r.data?.selected_storage_gib??null,d=M(c),f=d.length>0?d[d.length-1]:o,p=f!==o,m=u!=null&&(s==null||s<u),h=p||m,[g,_]=(0,G.useState)(null),v=Ze({onSuccess:()=>{V.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),_(null),t()},onError:e=>{_(ne(e,`Failed to resize assistant. Please try again.`))}}),y=v.isPending,b=n.isLoading||r.isLoading;return(0,K.jsx)(B.Root,{open:e,onOpenChange:e=>{e||(_(null),t())},children:(0,K.jsxs)(B.Content,{size:`sm`,children:[(0,K.jsxs)(B.Header,{children:[(0,K.jsx)(B.Title,{icon:ee,children:`Plan Updated`}),(0,K.jsx)(B.Description,{children:`Your new resources are ready. Apply them now to resize your assistant — it will briefly restart.`})]}),(0,K.jsxs)(B.Body,{children:[b?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,K.jsx)(j,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):h?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[p&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(zo,{icon:S,label:`Machine`,from:P[o],to:P[f]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-lg bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,K.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:`CPU`}),(0,K.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:N[f].split(`,`)[0].trim()})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-lg bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,K.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:`Memory`}),(0,K.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:N[f].split(`,`)[1].trim()})]})]})]}),m&&(0,K.jsx)(zo,{icon:k,label:`Storage`,from:s==null?`—`:`${s} GiB`,to:`${u} GiB`})]}):(0,K.jsx)(F,{tone:`neutral`,children:`Your assistant is already running at the maximum size for your plan.`}),g&&(0,K.jsx)(`div`,{className:`mt-3`,children:(0,K.jsx)(F,{tone:`error`,children:g})})]}),(0,K.jsxs)(B.Footer,{children:[(0,K.jsx)(i,{variant:`ghost`,onClick:()=>{_(null),t()},children:`Do Later`}),(0,K.jsx)(i,{disabled:b||!h||y||!a?.id,leftIcon:y?(0,K.jsx)(j,{className:`animate-spin`}):void 0,onClick:()=>{if(!a?.id)return;_(null);let e={};p&&(e.machine_size=f),m&&u!=null&&(e.storage_gib=u),v.mutate({path:{id:a.id},body:e})},children:g?`Retry`:`Apply & Restart`})]})]})})}function Vo(){let[e]=o(),t=s(),n=c();return(0,G.useEffect)(()=>{let r=e.get(`billing_status`);r&&(r===`success`?(V.success(`Payment received! Your credit balance will update shortly.`,{id:`billing-status`}),n.invalidateQueries({queryKey:Je().queryKey})):r===`cancel`&&V.info(`Checkout was cancelled. No credits were added.`,{id:`billing-status`}),t(U.settings.billing,{replace:!0}))},[e,t,n]),null}function Ho(){let e=ft({platformHostedOnly:!0}),t=ft(),n=ct(),r=ut(),[i,a]=o(),[s,c]=(0,G.useState)(!1),l=(0,G.useCallback)(()=>c(!0),[]),u=(0,G.useCallback)(()=>c(!1),[]),[d,f]=(0,G.useState)(!1),p=(0,G.useCallback)(()=>f(!0),[]);(0,G.useEffect)(()=>{i.has(`adjust_plan`)&&(c(!0),a(e=>{let t=new URLSearchParams(e);return t.delete(`adjust_plan`),t},{replace:!0}))},[i,a]);let m=i.has(`session_id`),h=(0,G.useCallback)(()=>{a(e=>{let t=new URLSearchParams(e);return t.delete(`session_id`),t},{replace:!0})},[a]);if(t===`disabled`)return(0,K.jsx)(`div`,{className:`space-y-4`,children:(0,K.jsx)(rt,{children:`Log in to the Vellum platform to manage billing and usage.`})});if(r)return(0,K.jsx)(`div`,{className:`space-y-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,K.jsx)(j,{className:`h-4 w-4 animate-spin`}),`Loading billing…`]})});let g=n;return!n&&e!==`gated`?(0,K.jsx)(`div`,{className:`space-y-4`,children:(0,K.jsx)(F,{tone:`warning`,children:`Billing isn't available for the current assistant state.`})}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(G.Suspense,{fallback:null,children:[(0,K.jsx)(Vo,{}),(0,K.jsx)(ji,{})]}),g&&(0,K.jsx)(ya,{}),g&&(0,K.jsx)(Po,{onManage:l}),g&&(0,K.jsx)(ri,{open:s,onClose:u,onTierUpgraded:p}),(0,K.jsx)(wo,{}),(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(wi,{})}),(0,K.jsx)(Ro,{}),g&&(0,K.jsx)(Ut,{open:m,onClose:h}),g&&(0,K.jsx)(Bo,{open:d,onClose:()=>f(!1)})]})}function Uo(){let e=mt(),t=ft({platformHostedOnly:!0}),n=ft();return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[t===`full`&&n!==`gated`&&(0,K.jsx)(va,{}),(0,K.jsx)(hr,{assistantId:e})]})}function Wo(){let e=ft()!==`gated`,[t,n]=o(),r=!e||t.get(`tab`)===`usage`?`usage`:`billing`;return(0,K.jsx)(`div`,{className:`space-y-6`,children:(0,K.jsxs)(b.Root,{value:r,onValueChange:e=>{let r=new URLSearchParams(t);e===`usage`?r.set(`tab`,`usage`):r.delete(`tab`),n(r,{replace:!0})},children:[(0,K.jsxs)(b.List,{children:[e&&(0,K.jsx)(b.Trigger,{value:`billing`,children:`Billing`}),(0,K.jsx)(b.Trigger,{value:`usage`,children:`Usage`})]}),e&&(0,K.jsx)(b.Panel,{value:`billing`,className:`pt-4`,children:(0,K.jsx)(Ho,{})}),(0,K.jsx)(b.Panel,{value:`usage`,className:`pt-4`,children:(0,K.jsx)(Uo,{})})]})})}export{Wo as BillingPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./button-BQVYX8n_.js";import{u as t}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./card-D8zyWtZh.js";import{t as i}from"./bookmark-CjHh36q4.js";import{t as a}from"./loader-circle-C9QrtO3C.js";import{t as o}from"./triangle-alert-CnjNKhNx.js";import{t as s}from"./x-BYcSiJRX.js";import{c}from"./routes-GPGveWZ8.js";import{Q as l,Xi as u,Z as d}from"./index-
|
|
1
|
+
import{t as e}from"./button-BQVYX8n_.js";import{u as t}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./card-D8zyWtZh.js";import{t as i}from"./bookmark-CjHh36q4.js";import{t as a}from"./loader-circle-C9QrtO3C.js";import{t as o}from"./triangle-alert-CnjNKhNx.js";import{t as s}from"./x-BYcSiJRX.js";import{c}from"./routes-GPGveWZ8.js";import{Q as l,Xi as u,Z as d}from"./index-CFQIPKjY.js";var f=n();function p(e){if(e==null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0})}function m(){return(0,f.jsx)(r,{children:(0,f.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,f.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,f.jsx)(i,{className:`h-6 w-6 text-[var(--content-disabled)] dark:text-[var(--content-default)]`})}),(0,f.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`No bookmarks`}),(0,f.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Hover any message and click the bookmark icon to save it here.`})]})})}function h({bookmark:t,isFirst:n,onOpen:r,onRemove:i}){let a=t.conversationTitle&&t.conversationTitle.trim().length>0?t.conversationTitle:`Untitled conversation`,o=t.messageRole!==`user`,c=p(t.createdAt);return(0,f.jsxs)(`div`,{className:`flex items-start gap-3 py-3 ${n?``:`border-t border-[var(--border-base)]`}`,children:[(0,f.jsx)(`span`,{"aria-hidden":!0,className:`mt-1 h-8 w-1 shrink-0 rounded-full`,style:{backgroundColor:o?`var(--content-default)`:`var(--content-tertiary)`}}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,f.jsx)(`div`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:a}),c?(0,f.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[var(--content-tertiary)]`,children:c}):null]}),t.messagePreview?(0,f.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-body-small-default text-[var(--content-tertiary)]`,children:t.messagePreview}):null]}),(0,f.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,f.jsx)(e,{variant:`outlined`,onClick:r,children:`Open`}),(0,f.jsx)(`button`,{type:`button`,onClick:i,title:`Remove bookmark`,"aria-label":`Remove bookmark`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-active)] hover:text-[var(--content-default)]`,children:(0,f.jsx)(s,{className:`h-4 w-4`})})]})]})}function g(){let n=t(),{bookmarks:i,isLoading:s,isError:p,refetch:g}=l(),_=d();return s?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(`div`,{className:`flex min-h-[400px] items-center justify-center`,children:(0,f.jsx)(a,{className:`h-6 w-6 animate-spin text-[var(--content-disabled)]`})})}):p?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(r,{children:(0,f.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,f.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--system-error-lighter)]`,children:(0,f.jsx)(o,{className:`h-6 w-6 text-[var(--system-error-default)]`})}),(0,f.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`Failed to load bookmarks`}),(0,f.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Something went wrong. Please try again.`}),(0,f.jsxs)(e,{variant:`outlined`,onClick:g,className:`mt-4`,children:[(0,f.jsx)(u,{className:`h-4 w-4`}),`Retry`]})]})})}):i.length===0?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(m,{})}):(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(r,{noPadding:!0,className:`px-4`,children:i.map((e,t)=>(0,f.jsx)(h,{bookmark:e,isFirst:t===0,onOpen:()=>{n(c.conversationAtMessage(e.conversationId,e.messageId))},onRemove:()=>{_(e.messageId,e.conversationId,!0)}},e.id))})})}export{g as BookmarksPage};
|