@vellumai/web 0.10.0-dev.202606221828.5af1324 → 0.10.0-dev.202606222007.e9d01e2
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-DgfY2U3m.js → account-page-d_dfygpV.js} +1 -1
- package/dist/assets/{add-credits-modal-BW2571lU.js → add-credits-modal-DDaRdeai.js} +1 -1
- package/dist/assets/{advanced-page-D1rUEVR9.js → advanced-page-Q1Rle9DD.js} +1 -1
- package/dist/assets/ai-page-Cb-AprBS.js +1 -0
- package/dist/assets/{api-key-screen-Drjh9-Ue.js → api-key-screen-Dxk17Qh-.js} +1 -1
- package/dist/assets/{archive-page-DnpO5q86.js → archive-page-vPrWcyyo.js} +1 -1
- package/dist/assets/billing-page-DML1e1ZW.js +3 -0
- package/dist/assets/{bookmarks-page-BBeMRnrE.js → bookmarks-page-DR2mwUfZ.js} +1 -1
- package/dist/assets/{command-palette-BaPa_J2o.js → command-palette-CNuWjgoF.js} +1 -1
- package/dist/assets/{command-palette-window-page-DzEgOdJj.js → command-palette-window-page-CrnFK6Dy.js} +1 -1
- package/dist/assets/{community-page-BMqBxnbi.js → community-page-BEo3TlGx.js} +1 -1
- package/dist/assets/contacts-page-route-BI_-RSuP.js +1 -0
- package/dist/assets/{debug-page-Yum6OyTG.js → debug-page-DpJeAhzJ.js} +1 -1
- package/dist/assets/{deploy-dialogs-BBGGpkb7.js → deploy-dialogs-B1Tv7x7V.js} +1 -1
- package/dist/assets/{developer-page-CFZ5Ylb_.js → developer-page-DIs4GhbT.js} +1 -1
- package/dist/assets/{devices-page-zxhhNiUU.js → devices-page-BQ7gQtSl.js} +1 -1
- package/dist/assets/dictation-overlay-page-BXFc4HeM.js +1 -0
- package/dist/assets/{document-viewer-page-B_rSFi3p.js → document-viewer-page-BJKx_VIr.js} +1 -1
- package/dist/assets/{earn-credits-modal-DrmqUMqt.js → earn-credits-modal-yfMs-qKD.js} +1 -1
- package/dist/assets/{emails-page-ChAsCuKk.js → emails-page-DrRhZ2c2.js} +1 -1
- package/dist/assets/{file-editor-DU7sPeqR.js → file-editor-Cn0h-2SR.js} +1 -1
- package/dist/assets/{funnel-events-tkEcNkUM.js → funnel-events-coIuxJNh.js} +1 -1
- package/dist/assets/{general-page-zikHlBOz.js → general-page-BMsDhwVI.js} +1 -1
- package/dist/assets/hatching-screen-DHQ9Lcm0.js +1 -0
- package/dist/assets/{home-page-route-CpSBMaOg.js → home-page-route-CydqGD2y.js} +1 -1
- package/dist/assets/{hosting-screen-C3OuowFx.js → hosting-screen-nWFsVfOS.js} +1 -1
- package/dist/assets/identity-page-route-Cl2m-LjW.js +1 -0
- package/dist/assets/{index-Bg3JafA7.js → index-DdZDYyvJ.js} +22 -22
- package/dist/assets/{index-mnpjKxyx.css → index-F52sXFty.css} +1 -1
- package/dist/assets/{inspect-page-BcrYVZTP.js → inspect-page-BIv__kdU.js} +3 -3
- package/dist/assets/{install-Ctcy2YKo.js → install-Dcb4hTVt.js} +1 -1
- package/dist/assets/integrations-page-P5Hrc81a.js +1 -0
- package/dist/assets/{intelligence-layout-DgKu2Wqh.js → intelligence-layout-DRavJyaC.js} +1 -1
- package/dist/assets/{keyboard-shortcuts-page-DUzynzde.js → keyboard-shortcuts-page-DAOKB1kf.js} +1 -1
- package/dist/assets/{library-detail-page-pVl6tnJs.js → library-detail-page-CXfiiGX6.js} +1 -1
- package/dist/assets/{library-page-BwPWo0yx.js → library-page-Uuq94zmn.js} +1 -1
- package/dist/assets/{login-page-DmV4ky2P.js → login-page-IGpJfWws.js} +1 -1
- package/dist/assets/{logout-page-C820AZuJ.js → logout-page-2qKRiQFg.js} +1 -1
- package/dist/assets/{logs-layout-DZ0E7RH1.js → logs-layout-In1NRLCq.js} +1 -1
- package/dist/assets/{mcp-page-CmREbJ58.js → mcp-page-DlnL5mXE.js} +1 -1
- package/dist/assets/{memory-router-playground-page-D6cVBUUW.js → memory-router-playground-page-BRT9IsmR.js} +1 -1
- package/dist/assets/{mobile-sidebar-drawer-BgX3etXv.js → mobile-sidebar-drawer-Ddp2qgwO.js} +1 -1
- package/dist/assets/{notifications-page-CXIE6a8R.js → notifications-page-DZdkK_SO.js} +1 -1
- package/dist/assets/{oauth-complete-page-4TvuLJ25.js → oauth-complete-page-CWE62f11.js} +1 -1
- package/dist/assets/{oauth-popup-complete-page-BnPLM-ku.js → oauth-popup-complete-page-C6UKFRIL.js} +1 -1
- package/dist/assets/{pairing-page-8qHlj7mC.js → pairing-page-CtsQYvlb.js} +1 -1
- package/dist/assets/plugin-detail-page-BC7rnJsO.js +1 -0
- package/dist/assets/{plugins-page-CeoyrByw.js → plugins-page-CWDp7o2R.js} +1 -1
- package/dist/assets/prechat-route-BGLWTB6Z.js +1 -0
- package/dist/assets/{privacy-page-8kDhusyk.js → privacy-page-KOlla_dL.js} +1 -1
- package/dist/assets/{privacy-screen-OLV45nO6.js → privacy-screen-CHCnyyb3.js} +1 -1
- package/dist/assets/{provider-callback-page-DR92Jk6w.js → provider-callback-page-8NFpaoP2.js} +1 -1
- package/dist/assets/{research-mock-page-CAkzEewW.js → research-mock-page-D3hh3QL_.js} +1 -1
- package/dist/assets/{research-onboarding-route-Dq_6wOKg.js → research-onboarding-route-DQpS3Gkr.js} +2 -2
- package/dist/assets/{review-terms-screen-D9b3UiDE.js → review-terms-screen-BUUJjR3w.js} +1 -1
- package/dist/assets/{select-assistant-screen-C-mdmAZe.js → select-assistant-screen-BQ5t4n8o.js} +1 -1
- package/dist/assets/{settings-layout-CdJGzvwB.js → settings-layout-6-t0_gKT.js} +1 -1
- package/dist/assets/{share-feedback-modal-CSQYBDoD.js → share-feedback-modal-BYUVlph2.js} +1 -1
- package/dist/assets/{sidebar-tree-DWgLGnug.js → sidebar-tree-DzeQ1ImF.js} +1 -1
- package/dist/assets/{signup-page-B69Ktz8i.js → signup-page-B88mAAni.js} +1 -1
- package/dist/assets/skills-page-CAF2oMkF.js +1 -0
- package/dist/assets/{sounds-page-tNpkIj03.js → sounds-page-DYf0m4CJ.js} +1 -1
- package/dist/assets/{subagent-detail-panel-DUBjwCL0.js → subagent-detail-panel-CyxdxaAO.js} +2 -2
- package/dist/assets/{system-events-page-B6zjuXAx.js → system-events-page-DqRQdTNs.js} +1 -1
- package/dist/assets/{tiptap-document-editor-C4Xp8QQV.js → tiptap-document-editor-CSAU6G-Q.js} +2 -2
- package/dist/assets/{tool-detail-panel-CEw59McY.js → tool-detail-panel-AEoa_OW9.js} +2 -2
- package/dist/assets/trace-page-D6leBpIJ.js +1 -0
- package/dist/assets/{upgrade-cancel-page-BYB-Pwe1.js → upgrade-cancel-page-JOUkutoe.js} +1 -1
- package/dist/assets/{upgrade-success-page-DLM2jTwP.js → upgrade-success-page-C-6slrsA.js} +1 -1
- package/dist/assets/{usage-page-B7oXp4At.js → usage-page-OdRiTuOF.js} +1 -1
- package/dist/assets/{voice-page-B3FWDL4Q.js → voice-page-DF0L5v2b.js} +1 -1
- package/dist/assets/{weather-forecast-display-CdcAh_Qa.js → weather-forecast-display-CNGjm5CB.js} +1 -1
- package/dist/assets/{welcome-screen-BU2SzOgS.js → welcome-screen-DM2poiq4.js} +1 -1
- package/dist/assets/{workflow-detail-panel-CETrvS7G.js → workflow-detail-panel-Dvbac2e4.js} +1 -1
- package/dist/assets/workspace-page-Bnj8_PsJ.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/ai-page-CGbz0RDC.js +0 -1
- package/dist/assets/billing-page-DcwQnEKV.js +0 -3
- package/dist/assets/contacts-page-route-CTlMMSZm.js +0 -1
- package/dist/assets/dictation-overlay-page-JP3Fdhpr.js +0 -1
- package/dist/assets/hatching-screen-TZyWOisj.js +0 -1
- package/dist/assets/identity-page-route-DBhYNymy.js +0 -1
- package/dist/assets/integrations-page-Ci7udN7P.js +0 -1
- package/dist/assets/plugin-detail-page-DIbrHsKa.js +0 -1
- package/dist/assets/prechat-route-BegtM-g0.js +0 -1
- package/dist/assets/skills-page-CZkis4HI.js +0 -1
- package/dist/assets/trace-page-CbjSKGYM.js +0 -1
- package/dist/assets/workspace-page-4Papyq5U.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{a as i,j as a,n as o,o as s}from"./auth-store-YSzSwQyO.js";import{a as c}from"./routes-DZiaa4kh.js";import{n as l,t as u}from"./login-flow-BSadWcAR.js";import{
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as r}from"./jsx-runtime-CVSDxk6A.js";import{a as i,j as a,n as o,o as s}from"./auth-store-YSzSwQyO.js";import{a as c}from"./routes-DZiaa4kh.js";import{n as l,t as u}from"./login-flow-BSadWcAR.js";import{Jr as d}from"./index-DdZDYyvJ.js";import{r as f,t as p}from"./account-shell-BcxVq5xW.js";var m=e(t(),1),h=r();function g(){let e=i(),t=s(),r=o.use.user(),g=o.use.logout(),[_,v]=(0,m.useState)(null),[y,b]=(0,m.useState)(!1),x=async()=>{v(null),b(!0);try{await a(l,u)}catch(e){console.error(`[account] auth flow failed:`,e),v(`Something went wrong. Please try again.`),b(!1)}};return t?(0,h.jsx)(p,{children:(0,h.jsx)(f,{title:`Loading...`})}):e?(0,h.jsxs)(p,{children:[(0,h.jsx)(f,{title:`Welcome${r?.username?`, ${r.username}`:``}!`,subtitle:`You are signed in.`}),(0,h.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,h.jsx)(n,{to:c.assistant,className:`inline-flex w-full items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] no-underline transition-colors hover:bg-[var(--primary-hover)]`,children:`Go to your assistant`}),(0,h.jsx)(`button`,{type:`button`,onClick:async()=>{await g(),d(c.account.login)},className:`cursor-pointer bg-transparent text-sm font-normal text-[var(--content-secondary)] transition-colors hover:text-[var(--content-default)]`,children:`Sign out`})]})]}):(0,h.jsxs)(p,{children:[(0,h.jsx)(f,{title:`Welcome to Vellum`,subtitle:`Sign in to get started.`}),_&&(0,h.jsx)(`p`,{className:`text-center text-sm text-[var(--system-negative-strong)]`,children:_}),(0,h.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,h.jsx)(`button`,{type:`button`,onClick:()=>void x(),disabled:y,className:`inline-flex w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)] disabled:opacity-50`,children:`Sign in`})})]})}export{g as AccountPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./chunk-jRWAZmH_.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-D7s2Q_uG.js";import{h as i,t as a,u as o}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./useQuery-B45lW1Kk.js";import{t as l}from"./useMutation-Lj4VunQV.js";import{t as u}from"./jsx-runtime-CVSDxk6A.js";import{t as d}from"./dropdown-yOV5eJnU.js";import{t as f}from"./modal-DX6UN7b0.js";import{t as p}from"./circle-alert-DDTljqKw.js";import{t as m}from"./credit-card-BDQQWUeD.js";import{t as h}from"./loader-circle-CQd2jpMq.js";import{St as g,_r as _,
|
|
1
|
+
import{o as e,r as t}from"./chunk-jRWAZmH_.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-D7s2Q_uG.js";import{h as i,t as a,u as o}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./useQuery-B45lW1Kk.js";import{t as l}from"./useMutation-Lj4VunQV.js";import{t as u}from"./jsx-runtime-CVSDxk6A.js";import{t as d}from"./dropdown-yOV5eJnU.js";import{t as f}from"./modal-DX6UN7b0.js";import{t as p}from"./circle-alert-DDTljqKw.js";import{t as m}from"./credit-card-BDQQWUeD.js";import{t as h}from"./loader-circle-CQd2jpMq.js";import{St as g,_r as _,xt as v,yr as y}from"./index-DdZDYyvJ.js";var b=t({AddCreditsModal:()=>E}),x=e(n(),1),S=u(),C=[`10.00`,`20.00`,`30.00`,`40.00`,`50.00`,`60.00`,`70.00`,`80.00`,`90.00`,`100.00`];function w(e){let t=parseFloat(e);if(Number.isNaN(t))return`0 credits`;let n=t.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2});return`${n.endsWith(`.00`)?n.slice(0,-3):n} credits`}function T(e){if(e&&typeof e==`object`){let t=e.amount;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0]}return`Failed to create checkout session. Please try again.`}function E({open:e,onOpenChange:t}){let n=s(),{pathname:u}=o(),[b]=i(),E=b.toString()?`${u}?${b.toString()}`:u,{data:D,isLoading:O}=c(_()),k=D?.allowed_top_up_amounts?.length?D.allowed_top_up_amounts:C,[A,j]=(0,x.useState)(null),M=A&&k.includes(A)?A:k[0]??C[0],N=l(y());return(0,x.useEffect)(()=>g(()=>{t(!1),n.invalidateQueries(_())}),[t,n]),(0,S.jsx)(f.Root,{open:e,onOpenChange:t,children:(0,S.jsxs)(f.Content,{size:`sm`,children:[(0,S.jsxs)(f.Header,{children:[(0,S.jsx)(f.Title,{icon:m,children:`Add Credits`}),(0,S.jsx)(f.Description,{children:`Purchase credits to continue using the assistant. You'll be redirected to Stripe to complete the payment.`})]}),(0,S.jsx)(f.Body,{children:(0,S.jsxs)(`div`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{htmlFor:`add-credits-amount`,className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Amount`}),(0,S.jsx)(d,{id:`add-credits-amount`,value:M,onChange:e=>{j(e),N.isError&&N.reset()},disabled:O||!D,options:k.map(e=>({value:e,label:w(e)}))})]}),N.isError&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,S.jsx)(p,{className:`h-3.5 w-3.5 shrink-0`}),T(N.error)]}),(0,S.jsx)(a,{to:`/assistant/settings/billing`,className:`text-body-small-default text-[var(--content-tertiary)] underline hover:text-[var(--content-secondary)]`,onClick:()=>t(!1),children:`Configure Automatic Top-Ups →`})]})}),(0,S.jsxs)(f.Footer,{children:[(0,S.jsx)(f.Close,{asChild:!0,children:(0,S.jsx)(r,{variant:`outlined`,children:`Cancel`})}),(0,S.jsx)(r,{variant:`primary`,leftIcon:N.isPending?(0,S.jsx)(h,{className:`animate-spin`}):void 0,onClick:()=>{N.isPending||N.mutate({body:{amount:M,return_path:E}},{onSuccess:e=>{v(e.checkout_url)}})},disabled:N.isPending||O||!D,children:`Add credits`})]})]})})}export{b as n,E as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-DZeS1sIw.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-D7s2Q_uG.js";import{n as i}from"./QueryClientProvider-DKhXIxGb.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./useMutation-Lj4VunQV.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./input-CwdmSRlD.js";import{t as l}from"./toggle-_vZlLDBV.js";import{n as u}from"./stat-square-B5tBfA4w.js";import{n as d}from"./toast-DLWkiWW6.js";import{t as f}from"./loader-circle-CQd2jpMq.js";import{c as p,kt as m,u as h}from"./react-query.gen-BU3Vskm6.js";import{X as g}from"./sdk.gen-DGVBsBOr.js";import{
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-DZeS1sIw.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-D7s2Q_uG.js";import{n as i}from"./QueryClientProvider-DKhXIxGb.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./useMutation-Lj4VunQV.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./input-CwdmSRlD.js";import{t as l}from"./toggle-_vZlLDBV.js";import{n as u}from"./stat-square-B5tBfA4w.js";import{n as d}from"./toast-DLWkiWW6.js";import{t as f}from"./loader-circle-CQd2jpMq.js";import{c as p,kt as m,u as h}from"./react-query.gen-BU3Vskm6.js";import{X as g}from"./sdk.gen-DGVBsBOr.js";import{S as _,Vt as v,Xn as y,Yn as b}from"./index-DdZDYyvJ.js";import{t as x}from"./use-active-assistant-id-BCNolO1R.js";import{t as S}from"./detail-card-a8sqBE1U.js";import{r as C}from"./assistant-status-panel-CiCTqfW3.js";var w=e(n(),1),T=s(),E=[[`Mon`,0],[`Tue`,1],[`Wed`,2],[`Thu`,3],[`Fri`,4],[`Sat`,5],[`Sun`,6]];function D(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),t,n));return`${i.getHours().toString().padStart(2,`0`)}:${i.getMinutes().toString().padStart(2,`0`)}`}function O(e){let[t,n]=e.split(`:`).map(Number),r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),t,n);return`${i.getUTCHours().toString().padStart(2,`0`)}:${i.getUTCMinutes().toString().padStart(2,`0`)}`}function k(){return Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value??``}function A(e){let t=e?.schedule?.window.start??`06:00`,n=e?.schedule?.window.end??`08:00`;return{enabled:e?.enabled??!0,timezone:`UTC`,frequency:e?.schedule?.frequency??`weekly`,daysOfWeek:e?.schedule?.days_of_week??[0],daysOfMonth:e?.schedule?.days_of_month??[],windowStart:D(t),windowEnd:D(n)}}function j({assistantId:e}){let t=i(),{data:n,isLoading:s,isError:p}=a(b({path:{id:e}})),m=(0,w.useMemo)(()=>A(n),[n]),[h,_]=(0,w.useState)(null),v=h??m,x=h!==null,S=(0,w.useMemo)(()=>k(),[]),[C,D]=(0,w.useState)(null),j=C??v.daysOfMonth.join(`, `),M=o({mutationFn:async t=>{let{data:n}=await g({path:{id:e},body:t,throwOnError:!0});return n}}),N=e=>{_(t=>({...t??m,...e}))},P=e=>{N({daysOfWeek:v.daysOfWeek.includes(e)?v.daysOfWeek.filter(t=>t!==e):[...v.daysOfWeek,e].sort((e,t)=>e-t)})},F=e=>e.split(`,`).map(e=>parseInt(e.trim(),10)).filter(e=>!isNaN(e)&&e>=1&&e<=31);return s?(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,T.jsx)(f,{className:`h-4 w-4 animate-spin`}),`Loading update window settings...`]}):p?(0,T.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--system-negative-strong)]`,children:`Failed to load update window policy. Refresh the page to try again.`}):(0,T.jsxs)(`div`,{className:`space-y-6`,children:[(0,T.jsx)(l,{checked:v.enabled,onChange:e=>N({enabled:e}),label:`Automatic updates`,helperText:`Update automatically during a configured time window`}),v.enabled&&(0,T.jsxs)(`div`,{className:`space-y-5`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Frequency`}),(0,T.jsx)(`div`,{className:`max-w-[400px]`,children:(0,T.jsx)(u,{ariaLabel:`Frequency`,value:v.frequency,onChange:e=>{e!==`monthly`&&D(null),N({frequency:e})},items:[{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}]})})]}),v.frequency===`weekly`&&(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:`Day(s) of week`}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:E.map(([e,t])=>(0,T.jsx)(r,{variant:`outlined`,size:`compact`,active:v.daysOfWeek.includes(t),onClick:()=>P(t),children:e},t))})]}),v.frequency===`monthly`&&(0,T.jsx)(c,{label:`Day(s) of month`,type:`text`,value:j,onChange:e=>D(e.target.value),onBlur:e=>{let t=F(e.target.value);N({daysOfMonth:t}),D(t.join(`, `))},placeholder:`e.g. 1, 15`,helperText:`Comma-separated day numbers (1–31)`,className:`w-48`}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-secondary)]`,children:[`Update window`,S?` (${S})`:``]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,T.jsx)(c,{type:`time`,value:v.windowStart,onChange:e=>N({windowStart:e.target.value})}),(0,T.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`to`}),(0,T.jsx)(c,{type:`time`,value:v.windowEnd,onChange:e=>N({windowEnd:e.target.value})})]})]})]}),(0,T.jsx)(r,{variant:`primary`,leftIcon:M.isPending?(0,T.jsx)(f,{className:`animate-spin`}):void 0,onClick:async()=>{let n=v.frequency===`monthly`&&C!==null?F(C):v.daysOfMonth;try{await M.mutateAsync({enabled:v.enabled,timezone:`UTC`,schedule:{frequency:v.frequency,days_of_week:v.frequency===`weekly`?v.daysOfWeek:[],days_of_month:v.frequency===`monthly`?n:[],window:{start:O(v.windowStart),end:O(v.windowEnd)}}}),d.success(`Auto-update policy saved.`),_(null),D(null),t.invalidateQueries({queryKey:y({path:{id:e}})})}catch{d.error(`Failed to save policy. Please try again.`)}},disabled:M.isPending||!x,children:`Save policy`})]})}function M(){let{assistant:e,healthz:n}=C(),r=v({platformHostedOnly:!0}),o=e?.is_local?null:e,s=x(),c=i(),u=n?.capabilities?.memoryOptOut===!0,{data:f}=a({...p({path:{assistant_id:s}}),staleTime:3e4,enabled:u}),g=m({onSuccess:e=>{h(c,{path:{assistant_id:s}},e)}}),y=f?.memory?.enabled!==!1,b=async e=>{try{await g.mutateAsync({path:{assistant_id:s},body:{memory:{enabled:e}}}),d.success(e?`Memory enabled.`:`Memory disabled.`)}catch(e){t(e,{context:`settings-memory-toggle`}),d.error(`Failed to update memory setting.`)}};return(0,T.jsxs)(`div`,{className:`space-y-4`,children:[r===`full`&&o&&(0,T.jsx)(S,{title:`Update Window`,subtitle:`Configure when automatic updates are applied.`,children:(0,T.jsx)(j,{assistantId:o.id})}),r===`disabled`&&(0,T.jsx)(S,{title:`Update Window`,subtitle:`Configure when automatic updates are applied.`,children:(0,T.jsx)(_,{children:`Log in to the Vellum platform to manage update window policy.`})}),u?(0,T.jsx)(S,{title:`Memory`,subtitle:`Let your assistant remember information from past conversations. Turning this off also pauses memory consolidation.`,accessory:(0,T.jsx)(l,{checked:y,onChange:e=>void b(e),"aria-label":`Enable memory`,disabled:g.isPending}),compactAccessory:!0}):null]})}export{M as AdvancedPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,r as n,s as r}from"./local-settings-lVNyIOJ_.js";import{r as i,t as a}from"./capture-error-DZeS1sIw.js";import{t as o}from"./react-DJZBPgpf.js";import{t as s}from"./button-D7s2Q_uG.js";import{d as c,h as l}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as u}from"./QueryClientProvider-DKhXIxGb.js";import{t as d}from"./useQuery-B45lW1Kk.js";import{t as f}from"./useMutation-Lj4VunQV.js";import{t as p}from"./jsx-runtime-CVSDxk6A.js";import{t as m}from"./typography-BscuIPxA.js";import{t as h}from"./dropdown-yOV5eJnU.js";import{t as g}from"./confirm-dialog-DbNUkFt6.js";import{t as _}from"./notice-G5Imd5pC.js";import{t as v}from"./tag-BadGF3FB.js";import{t as y}from"./input-CwdmSRlD.js";import{t as b}from"./toggle-_vZlLDBV.js";import{n as x}from"./stat-square-B5tBfA4w.js";import{t as S}from"./modal-DX6UN7b0.js";import{n as C}from"./toast-DLWkiWW6.js";import{t as w}from"./createLucideIcon-B4vraqUn.js";import{t as T}from"./circle-alert-DDTljqKw.js";import{t as E}from"./circle-check-B8Xk989s.js";import{n as D,t as O}from"./domain-field-C6WnRdqe.js";import{t as k}from"./external-link-oRvm6ohU.js";import{t as A}from"./info-CKGk-lqa.js";import{t as j}from"./loader-circle-CQd2jpMq.js";import{t as M}from"./triangle-alert-JYuV8dTb.js";import{Fn as N,Mt as P,in as F,jt as I,nt as L}from"./sdk.gen-Ds50lD_U.js";import{R as ee,c as R,d as z,ft as B,kt as V,l as H,u as U,wt as W,z as G}from"./react-query.gen-BU3Vskm6.js";import{s as K}from"./assistant-api-Ch5hLXF5.js";import{r as te}from"./api-errors-ChWAvbEQ.js";import{a as ne}from"./routes-DZiaa4kh.js";import{t as q}from"./use-is-org-ready-CcRdtKOo.js";import{t as re}from"./assistant-identity-store-BGlAP3cI.js";import{t as J}from"./assistant-feature-flag-store-bfqXf_GM.js";import{Ai as ie,An as ae,Ci as Y,Cn as oe,Di as X,Dn as se,Ei as ce,En as le,Fi as ue,Fn as de,Ii as fe,Ji as pe,Mi as me,Mn as he,Ni as ge,Oi as _e,On as ve,Pi as ye,Pn as be,S as xe,Si as Se,Sn as Ce,Ti as we,Tn as Te,Vt as Ee,_ as De,_i as Oe,b as ke,bi as Ae,ci as je,di as Me,fi as Ne,gi as Pe,hi as Fe,ji as Ie,jn as Le,ki as Re,kn as ze,li as Be,lo as Ve,mi as He,mr as Ue,oi as We,pi as Ge,pn as Ke,sa as qe,si as Je,ui as Ye,v as Xe,vi as Ze,vo as Qe,wi as $e,wn as et,x as tt,xi as nt,y as rt,yi as it}from"./index-DdZDYyvJ.js";import{t as at}from"./use-active-assistant-id-BCNolO1R.js";import{t as ot}from"./detail-card-a8sqBE1U.js";import{t as st}from"./environment-store-BHYCnW0P.js";var ct=w(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Z=e(o(),1),Q=p();function lt({mode:e,onChange:t}){return(0,Q.jsx)(`div`,{className:`max-w-[280px]`,children:(0,Q.jsx)(x,{ariaLabel:`Service mode`,value:e,onChange:t,items:[{value:`managed`,label:`Managed`},{value:`your-own`,label:`Your Own`}]})})}function ut({id:e,title:t,subtitle:n,mode:r,onModeChange:i,children:a}){return(0,Q.jsxs)(ot,{id:e,title:t,subtitle:n,accessory:(0,Q.jsx)(lt,{mode:r,onChange:i}),children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:a})]})}function $({onClick:e,disabled:t}){return(0,Q.jsx)(s,{onClick:e,disabled:t,children:`Save`})}function dt({onClick:e,filled:t=!1}){return(0,Q.jsx)(s,{variant:t?`danger`:`dangerGhost`,onClick:e,children:`Reset`})}function ft({id:e,title:t,subtitle:n,children:r}){return(0,Q.jsxs)(ot,{id:e,title:t,subtitle:n,children:[(0,Q.jsx)(`div`,{className:`h-px bg-[var(--surface-active)]`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:r})]})}function pt({guide:e}){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(A,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{children:e.description}),(0,Q.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[e.linkLabel,(0,Q.jsx)(k,{className:`h-3 w-3`})]})]})]})}function mt({status:e,message:t,isLoading:n}){return n?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,children:[(0,Q.jsx)(j,{className:`h-3 w-3 animate-spin`}),`Checking domain…`]}):e?e===`verified`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-positive-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-positive-strong)]`,title:`DNS records have been verified. Your domain is ready to send and receive email.`,children:[(0,Q.jsx)(Qe,{className:`h-3 w-3`}),`Domain verified`]}):e===`pending`||e===`not_started`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-mid-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-mid-strong)]`,title:`DNS records have been provisioned. Waiting for the email provider to verify them — this usually takes a few minutes.`,children:[(0,Q.jsx)(Ve,{className:`h-3 w-3`}),`Verifying domain…`]}):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--system-negative-weak)] px-2.5 py-0.5 text-body-small-default text-[var(--system-negative-strong)]`,title:`Domain verification failed. DNS records may not have propagated correctly. You could try releasing and re-registering the domain.`,children:[(0,Q.jsx)(T,{className:`h-3 w-3`}),`Verification failed`]}):(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-[var(--tag-bg-neutral)] px-2.5 py-0.5 text-body-small-default text-[var(--content-quiet)]`,title:`Unable to retrieve domain verification status.`,children:`Unknown status`})}var ht=`__custom__`;function gt(e){return e?!!(e.profile||e.provider||e.model):!1}function _t(e,t){let n=gt(e);return n===gt(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function vt({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,onDraftChange:o,onToggle:s}){let c=gt(i),l=!i||!c?``:i.provider||i.model?ht:i.profile??``,u=l===ht,d=me.find(e=>e===i?.provider)??me[0],f=ue(d).map(e=>({value:e.id,label:e.displayName})),p=!!i?.provider&&!i?.model;function m(t){if(t===`__custom__`){let t=me[0];o(e,{profile:null,provider:t,model:ye(t)??``})}else t===``?o(e,null):o(e,{profile:t,provider:null,model:null})}function g(t){let n=ye(t)??``;o(e,{...i??{},profile:null,provider:t,model:n})}function _(t){o(e,{...i??{},model:t})}return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,Q.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,Q.jsxs)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:[`· Default: `,r]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c&&(0,Q.jsx)(h,{value:l,onChange:m,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`end`}),(0,Q.jsx)(b,{checked:c,onChange:t=>s(e,t),"aria-label":`Override ${t}`})]})]}),c&&u&&(0,Q.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:d??``,onChange:g,options:me.map(e=>({value:e,label:ge[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:`Model`}),(0,Q.jsx)(h,{value:i?.model??``,onChange:_,options:f})]})]}),p&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:`Pick a model`})]})]})}function yt({isOpen:e,onClose:t,assistantId:n}){let r=(0,Z.useRef)(!1);return(0,Q.jsx)(S.Root,{open:e,onOpenChange:e=>{!e&&!r.current&&t()},children:e?(0,Q.jsx)(bt,{assistantId:n,onClose:t,onSavingChange:e=>{r.current=e}}):null})}function bt({assistantId:e,onClose:t,onSavingChange:n}){let r=u(),{data:i}=d({...R({path:{assistant_id:e}}),staleTime:3e4}),o=(0,Z.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),c=(0,Z.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),l=(0,Z.useMemo)(()=>i?.llm?.callSites??{},[i?.llm?.callSites]),f=(0,Z.useMemo)(()=>Ae(o,c),[o,c]),p=V({onSuccess:t=>{U(r,{path:{assistant_id:e}},t)}}),[m,h]=(0,Z.useState)(``),[_,v]=(0,Z.useState)({}),[b,x]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(!1),E=J.use.analyzeConversation(),{data:D,isLoading:O,isError:k,refetch:A}=d({...z({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),M=(0,Z.useMemo)(()=>{let e=(D?.callSites??[]).filter(e=>e.id!==`mainAgent`);return E||(e=e.filter(e=>e.id!==`analyzeConversation`)),e},[D,E]),N=!O&&!k&&!!D&&!!i,P=(0,Z.useMemo)(()=>M.map(e=>e.id),[M]),F=(0,Z.useMemo)(()=>{if(!N)return{};let e={};for(let t of P)if(t in _)e[t]=_[t];else{let n=l[t];e[t]=n?{...n}:{}}return e},[N,P,l,_]),I=(0,Z.useMemo)(()=>new Set(P),[P]),L=(0,Z.useMemo)(()=>Object.entries(l).some(([e,t])=>I.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[l,I]),ee=(0,Z.useMemo)(()=>{if(!N)return!1;for(let e of Object.keys(F))if(!_t(F[e],l[e]))return!0;return!1},[N,F,l]),B=(0,Z.useMemo)(()=>Object.values(F).some(e=>gt(e)&&!!e?.provider&&!e?.model),[F]),H=J.use.queryComplexityRouting(),W=(0,Z.useCallback)(e=>[...Xe(tt(f,[e]),H).map(e=>({value:e.name,label:rt(e)})),{value:ht,label:`Custom`}],[f,H]),G=(0,Z.useMemo)(()=>{if(!m.trim())return M;let e=m.toLowerCase();return M.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[M,m]),K=(0,Z.useMemo)(()=>{if(!D)return[];let e=D.domains.map(e=>e.id),t=new Map(D.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=G.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let r=new Set(e),i=G.filter(e=>!r.has(e.domain));return i.length>0&&n.push({domain:{id:`other`,displayName:`Other`},sites:i}),n},[D,G]),te=(0,Z.useCallback)((e,t)=>{v(n=>({...n,[e]:t}))},[]),ne=(0,Z.useCallback)((e,t)=>{if(!t){v(t=>({...t,[e]:null}));return}let n=ke(f,M.find(t=>t.id===e)?.defaultProfile,H);if(n)v(t=>({...t,[e]:{profile:n}}));else{let t=me[0],n=ye(t)??``;v(r=>({...r,[e]:{provider:t,model:n}}))}},[M,f,H]),q=(0,Z.useCallback)(async()=>{x(!0),n?.(!0);try{let n={};for(let e of Object.keys(F)){let t=F[e]??null;n[e]=gt(t)?{profile:t?.profile??null,provider:t?.provider??null,model:t?.model??null}:null}await p.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),C.success(`Overrides saved.`)}catch(e){C.error(`Failed to save overrides. Please try again.`),a(e,{context:`call_site_overrides_save`})}finally{x(!1),n?.(!1)}},[F,t,p,n,e]),re=(0,Z.useCallback)(async()=>{x(!0),n?.(!0);try{let n={};for(let e of Object.keys(F))n[e]=null;await p.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:n}}}),t(),C.success(`Overrides reset.`)}catch(e){C.error(`Failed to reset overrides. Please try again.`),a(e,{context:`call_site_overrides_reset`})}finally{x(!1),n?.(!1)}},[F,t,p,n,e]);return(0,Q.jsxs)(S.Content,{size:`lg`,hideCloseButton:!0,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Action Overrides`}),(0,Q.jsx)(S.Description,{children:`Customize which model profile specific actions should use. Uses your default profile if no override is set.`})]}),(0,Q.jsxs)(S.Body,{children:[(0,Q.jsx)(`div`,{className:`mb-4`,children:(0,Q.jsx)(y,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:`Search actions…`,leftIcon:(0,Q.jsx)(qe,{className:`h-4 w-4`}),fullWidth:!0})}),O&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(j,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}),k&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-default text-[var(--content-default)]`,children:`Couldn't load actions`}),(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Make sure your assistant is running`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>void A(),children:`Retry`})]}),!O&&!k&&D&&(0,Q.jsx)(`div`,{className:`space-y-4`,children:K.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No actions match your search.`}):K.map(({domain:e,sites:t})=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-body-small-default font-semibold uppercase tracking-wider text-[var(--content-tertiary)]`,children:e.displayName}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>{let t=(()=>{let t=F[e.id]??null;return!t||!gt(t)?``:t.provider||t.model?`__custom__`:t.profile??``})(),n=e.defaultProfile?f.find(t=>t.name===e.defaultProfile)?.label??e.defaultProfile:null;return(0,Q.jsx)(vt,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:n,draft:F[e.id]??null,profileOptions:W(t===``||t===`__custom__`?null:t),onDraftChange:te,onToggle:ne},e.id)})})]},e.id))})]}),(0,Q.jsxs)(S.Footer,{children:[L&&(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>T(!0),disabled:b||!N,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:`Reset to Defaults`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:t,disabled:b,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,onClick:()=>void q(),disabled:!ee||B||b,children:b?(0,Q.jsx)(j,{className:`h-4 w-4 animate-spin`}):`Save`})]}),(0,Q.jsx)(g,{open:w,title:`Reset to Defaults`,message:`Every task override will be reset and will follow your active profile. This cannot be undone.`,confirmLabel:`Reset to Defaults`,destructive:!0,onConfirm:()=>{T(!1),re()},onCancel:()=>T(!1)})]})}function xt({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:c}){let l=``;if(e){let t=e.label||e.name;l=e.isActive&&e.callSiteIds.length>0?`"${t}" is the active profile and is used by ${e.callSiteIds.length} call site(s). Pick a replacement profile.`:e.isActive?`"${t}" is the active profile. Pick a different active profile before deleting, or select a replacement below.`:`"${t}" is used by ${e.callSiteIds.length} call site(s). Select a replacement profile to reassign them before deleting.`}return(0,Q.jsx)(S.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,Q.jsxs)(S.Content,{size:`sm`,children:[(0,Q.jsx)(S.Header,{children:(0,Q.jsx)(S.Title,{children:`Can't Delete Profile`})}),(0,Q.jsxs)(S.Body,{className:`space-y-4`,children:[(0,Q.jsx)(m,{variant:`body-medium-default`,as:`p`,children:l}),e&&e.callSiteIds.length>0&&(0,Q.jsx)(`ul`,{className:`space-y-1 pl-1`,children:e.callSiteIds.map(e=>(0,Q.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,(0,Q.jsx)(`code`,{children:e})]},e))}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Replacement profile`}),(0,Q.jsx)(h,{"aria-label":`Replacement profile`,value:n,onChange:r,options:[{value:``,label:`Select a replacement…`},...t.map(e=>({value:e.name,label:e.label??e.name}))]})]}),i&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,Q.jsxs)(S.Footer,{children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:o,children:`Cancel`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:c,children:a?`Saving…`:`Reassign and Delete`})]})]})})}function St({profile:e,isDragging:t,dropTarget:n,isDeleting:r,deleteError:i,isToggling:a,onDragStart:o,onDragEnd:c,onDragOver:l,onDragLeave:u,onDrop:d,onEditClick:f,onDeleteClick:p,onStatusToggle:h}){let g=e.source===`managed`,_=e.status!==`disabled`,y=e.name===K;return(0,Q.jsxs)(`div`,{className:`relative`,children:[n?.name===e.name&&!n.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg pr-2 py-2${t?` opacity-50`:``}`,draggable:!g,onDragStart:o,onDragEnd:c,onDragOver:l,onDragLeave:u,onDrop:d,children:[(0,Q.jsx)(ct,{className:`h-4 w-4 shrink-0 ${g?`invisible`:`cursor-grab text-[var(--content-tertiary)]`}`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1${_?``:` opacity-55`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(m,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:e.label??e.name}),g&&e.name!==`auto`&&(0,Q.jsx)(v,{tone:`positive`,title:`Managed by Platform — auth is locked, but you can rename or disable this profile.`,children:`Platform`})]}),e.description?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:e.description}):null,e.model??e.provider?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:e.model??e.provider}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center`,title:_?`Active — toggle to hide from pickers`:`Disabled — toggle to show in pickers`,children:(0,Q.jsx)(b,{checked:_,onChange:e=>h(e),disabled:a,"aria-label":`${_?`Disable`:`Enable`} ${e.label??e.name}`})}),(0,Q.jsxs)(`div`,{className:`flex w-[92px] items-center justify-end gap-2${y?` invisible`:``}`,children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:f,children:g?`View`:`Edit`}),(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),"aria-label":`Delete ${e.label??e.name}`,disabled:g||r,title:g?`Managed profiles cannot be deleted`:void 0,onClick:p,tintColor:`var(--system-negative-strong)`})]})]})]}),n?.name===e.name&&n.after&&(0,Q.jsx)(`div`,{className:`mx-0 h-0.5 rounded-full bg-[var(--border-active)]`}),i?(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:i}):null,e.name===`auto`&&(0,Q.jsx)(`div`,{className:`mx-2 mt-1 border-b border-[var(--border-subtle)]`})]})}function Ct({isOpen:e,assistantId:t,onClose:n}){let r=u(),{data:i}=d({...R({path:{assistant_id:t}}),staleTime:3e4}),o=(0,Z.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),s=(0,Z.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),c=i?.llm?.activeProfile??null,l=i?.llm?.callSites??{},f=(0,Z.useMemo)(()=>Ae(o,s),[o,s]),p=V({onSuccess:e=>{U(r,{path:{assistant_id:t}},e)}}),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),{data:v}=d({...ee({path:{assistant_id:t}}),enabled:e}),y=v?.connections,b=Object.keys(o);async function x(e,n,r){let i=r?.mode??`replace`,c=!(e in o);if(i===`merge`&&!c){await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:n}}}}),h(!1),_(null);return}let l={profiles:{[e]:n}};if(c&&(l.profileOrder=s.includes(e)?s:[...s,e]),c)await p.mutateAsync({path:{assistant_id:t},body:{llm:l}});else{let n=o[e];await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:null}}}});try{await p.mutateAsync({path:{assistant_id:t},body:{llm:l}})}catch(r){throw a(r,{context:`settings-ai-profile-edit-recreate`}),n!=null&&await p.mutateAsync({path:{assistant_id:t},body:{llm:{profiles:{[e]:n}}}}).catch(()=>{}),r}}c&&C.success(`Profile "${n.label??e}" created`),h(!1),_(null)}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(S.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,Q.jsx)(wt,{assistantId:t,profiles:o,profileOrder:s,orderedProfiles:f,activeProfile:c,callSiteOverrides:l,onClose:n,onEditClick:e=>{_(e),h(!0)},onNewClick:()=>{_(null),h(!0)}}):null}),(0,Q.jsx)(We,{isOpen:m,mode:g?g.source===`managed`?`view`:`edit`:`create`,profileName:g?.name,initialValues:g??void 0,existingNames:b,connections:y,assistantId:t,onSave:x,onCancel:()=>{h(!1),_(null)}})]})}function wt({assistantId:e,profiles:t,profileOrder:n,orderedProfiles:r,activeProfile:i,callSiteOverrides:o,onClose:c,onEditClick:l,onNewClick:d}){let f=u(),p=V({onSuccess:t=>{U(f,{path:{assistant_id:e}},t)}}),[h,g]=(0,Z.useState)({}),[_,v]=(0,Z.useState)({}),[y,b]=(0,Z.useState)(new Set),[x,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(null),A=(0,Z.useRef)(null),j=(0,Z.useRef)(null),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(``),[ee,R]=(0,Z.useState)(!1),z=J.use.queryComplexityRouting(),B=(0,Z.useMemo)(()=>Xe(r,z),[r,z]);async function H(n,r){if(y.has(n.name))return!1;b(e=>new Set(e).add(n.name)),C(null);let i=r?`active`:`disabled`;if(!t[n.name])return b(e=>{let t=new Set(e);return t.delete(n.name),t}),!1;try{return await p.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[n.name]:{status:i}}}}}),!0}catch(e){return a(e,{context:`settings-ai-profile-toggle`}),C(`Couldn't update "${n.label??n.name}". Please try again.`),!1}finally{b(e=>{let t=new Set(e);return t.delete(n.name),t})}}async function W(t){v(e=>({...e,[t]:!0})),g(e=>{let n={...e};return delete n[t],n});try{let r=n.filter(e=>e!==t);await p.mutateAsync({path:{assistant_id:e},body:{llm:{profiles:{[t]:null},profileOrder:r}}})}catch(e){a(e,{context:`settings-ai-profile-delete`}),g(e=>({...e,[t]:`Failed to delete profile. Please try again.`}))}finally{v(e=>{let n={...e};return delete n[t],n})}}function G(e){let t=B.find(t=>t.name===e)?.label??e,n=e===i,r=Object.entries(o).filter(([t,n])=>t!==`mainAgent`&&n?.profile===e).map(([e])=>e);if(n||r.length>0){N({name:e,label:t,isActive:n,callSiteIds:r}),L(``),F(null);return}W(e)}async function K(){if(!M||!I)return;R(!0),F(null);let t={};if(M.isActive&&(t.activeProfile=I),M.callSiteIds.length>0){let e={};for(let t of M.callSiteIds)e[t]={profile:I};t.callSites=e}if(Object.keys(t).length>0)try{await p.mutateAsync({path:{assistant_id:e},body:{llm:t}})}catch(e){a(e,{context:`settings-ai-profile-reassign-delete`}),F(`Failed to reassign references. Please try again.`),R(!1);return}let n=M.name;N(null),R(!1),W(n)}async function te(t,r){if(t===r.name)return;k(null);let i=n.filter(e=>e!==t),o=i.indexOf(r.name);if(o===-1)return;r.after&&(o+=1);let s=[...i.slice(0,o),t,...i.slice(o)];try{await p.mutateAsync({path:{assistant_id:e},body:{llm:{profileOrder:s}}})}catch(e){a(e,{context:`settings-ai-profile-reorder`}),k(`Failed to reorder profiles. Please try again.`)}}let ne=B.filter(e=>e.name!==M?.name&&e.source!==`managed`),q=ne.length>0?ne:B.filter(e=>e.name!==M?.name);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(S.Content,{size:`md`,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Model Profiles`}),(0,Q.jsx)(S.Description,{children:`Bundle a provider and model into a named profile. Assign profiles to specific actions or swap between them when chatting.`})]}),(0,Q.jsxs)(S.Body,{children:[B.length===0?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No profiles yet. Create one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:B.map(e=>(0,Q.jsx)(St,{profile:e,isDragging:w===e.name,dropTarget:E,isDeleting:_[e.name]??!1,deleteError:h[e.name],isToggling:y.has(e.name),onDragStart:t=>{A.current=e.name,T(e.name),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{A.current=null,j.current=null,T(null),D(null)},onDragOver:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>n.top+n.height/2,i={name:e.name,after:r};j.current=i,D(i)},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||(j.current=null,D(t=>t?.name===e.name?null:t))},onDrop:e=>{e.preventDefault();let t=A.current,n=j.current;A.current=null,j.current=null,T(null),D(null),t&&n&&te(t,n)},onEditClick:()=>l(e),onDeleteClick:()=>G(e.name),onStatusToggle:t=>void H(e,t)},e.name))}),O&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:O}),x&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-2 text-(--system-negative-strong)`,children:x})]}),(0,Q.jsxs)(S.Footer,{className:`justify-between`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:d,children:`+ New Profile`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:c,children:`Done`})]})]}),(0,Q.jsx)(xt,{blocked:M,availableReplacements:q,replacement:I,onReplacementChange:L,error:P,saving:ee,onClose:()=>{N(null),F(null)},onConfirm:()=>void K()})]})}function Tt({mode:e,connection:t,assistantId:n,existingNames:r,onSave:i,onCancel:a}){let[o,c]=(0,Z.useState)(e),[l,d]=(0,Z.useState)(void 0),f=o===`managed-edit`,[p,g]=(0,Z.useState)(t?.label??``),[_,v]=(0,Z.useState)(t?.name??``),[b,x]=(0,Z.useState)(t?.provider??`anthropic`),[C,w]=(0,Z.useState)(()=>t?t.auth.type:`platform`),[T,E]=(0,Z.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[D,O]=(0,Z.useState)(t?.baseUrl??``),[k,A]=(0,Z.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[j,M]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(null),L=b===`openai-compatible`,ee=(0,Z.useMemo)(()=>b&&!Ne.includes(b)?[...Ne,b]:Ne,[b]),{handleLabelChange:R,resetDirty:z}=Be(o,g,v),[V,H]=(0,Z.useState)(``),[U,W]=(0,Z.useState)(!1),G=u(),K=(0,Z.useMemo)(()=>He(T),[T]),te=C===`api_key`&&K!==null,{hasStoredCredential:ne,isLoading:q}=Ze({assistantId:n,credentialKind:`credential`,credentialName:K?`${K.service}:${K.field}`:``,enabled:te}),{credentials:re}=je({assistantId:n,enabled:C===`api_key`});(0,Z.useEffect)(()=>{let e=t?.provider??`anthropic`;g(t?.label??``),v(t?.name??``),x(e),w(t?t.auth.type:`platform`),t?.auth.type===`api_key`?E(t.auth.credential):E(t?``:`credential/${e}/api_key`),z(),I(null),O(t?.baseUrl??``),A(t?.models?t.models.map(e=>e.id).join(`, `):``),H(``),W(!1)},[t,z]);function J(){c(`create`),d(b===`ollama`?`none`:`api_key`)}let ie=_.trim().length>0;async function ae(){if(ie){M(!0),I(null);try{let e;if(C===`api_key`){let t=T.trim()||`credential/${b}/api_key`,r=V.trim();if(r){W(!0);try{let e=He(t);await N({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:b,value:r},throwOnError:!0});let i=Oe(n,`credential`,e?`${e.service}:${e.field}`:``);G.setQueryData(i,!0),G.invalidateQueries({queryKey:B({path:{assistant_id:n}})})}catch{I(`Failed to save API key. Please try again.`);return}finally{W(!1)}}e={type:`api_key`,credential:t}}else if(C===`oauth_subscription`)if(t?.auth.type===`oauth_subscription`)e=t.auth;else{I(`Use the "Sign in with ChatGPT" button to connect your subscription.`);return}else if(C===`service_account`)if(t?.auth.type===`service_account`)e=t.auth;else{I(`Service account connections cannot be created through this form.`);return}else e=C===`none`?{type:`none`}:{type:`platform`};let r=p.trim()||null,a={auth:e,label:r,...L&&{base_url:D.trim()||null,models:k.trim()?k.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:o,response:s}=await P({path:{assistant_id:n,name:t?.name??_.trim()},body:a});if(!s?.ok){I(Ge(s?.status,_.trim()));return}if(!o){I(`Server returned an empty response. Please try again.`);return}i(o)}catch{I(`Failed to save connection. Please try again.`)}finally{M(!1)}}}let Y=re.filter(e=>e.service===b),oe=o!==`create`&&t?.auth.type===`api_key`,X=Y.length>0||oe,se=Ye(`Enter your API key`,ne);return o===`create`?(0,Q.jsx)(Je,{variant:`modal`,assistantId:n,existingNames:r,defaultProviderType:b,defaultAuthType:l,onCreated:i,onCancel:a},b):(0,Q.jsxs)(S.Content,{size:`md`,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Edit Connection`}),(0,Q.jsx)(S.Description,{children:f?`Managed by Vellum — auth is locked, but you can rename "${t?.name}".`:`Editing "${t?.name}".`})]}),(0,Q.jsxs)(S.Body,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[`Display Name`,` `,(0,Q.jsx)(`span`,{className:`text-[var(--content-disabled)]`,children:`(optional)`})]}),(0,Q.jsx)(y,{value:p,onChange:e=>R(e.target.value),placeholder:`e.g. My Anthropic Key`,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Key`}),(0,Q.jsx)(y,{value:_,placeholder:`e.g. anthropic-personal`,disabled:!0,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{"aria-label":`Provider`,value:b,onChange:x,disabled:!0,options:ee.map(e=>({value:e,label:ge[e]}))})]}),L&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Base URL`}),(0,Q.jsx)(y,{value:D,onChange:e=>O(e.target.value),placeholder:`https://api.example.com/v1`,disabled:f,fullWidth:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Models`}),(0,Q.jsx)(y,{value:k,onChange:e=>A(e.target.value),placeholder:`model-1, model-2`,disabled:f,fullWidth:!0}),(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:`Comma-separated model identifiers exposed by your endpoint.`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Auth Type`}),(0,Q.jsx)(h,{"aria-label":`Auth type`,value:C,onChange:e=>{w(e),I(null)},disabled:f||b===`ollama`,options:(()=>{let e;return e=b===`ollama`?[`none`]:fe(b)?[`api_key`,`platform`]:[`api_key`],C&&!e.includes(C)&&e.push(C),e.map(e=>({value:e,label:Me[e]}))})()})]}),C===`api_key`&&(0,Q.jsx)(Fe,{apiKeyValue:V,onApiKeyChange:H,credential:T,onCredentialChange:E,isAuthLocked:f,isLoadingCredential:q,apiKeyPlaceholder:se,provider:b,providerCredentials:Y,showAdvancedSection:X,onError:I}),C===`oauth_subscription`&&(0,Q.jsx)(Pe,{assistantId:n,onConnected:i}),F&&(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:F})]}),(0,Q.jsxs)(S.Footer,{children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:a,children:`Cancel`}),o===`managed-edit`&&(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:J,disabled:j||U,children:`Save as New`}),(0,Q.jsx)(s,{variant:`primary`,size:`compact`,disabled:!ie||j||U,onClick:()=>void ae(),children:j?`Saving…`:`Save`})]})]})}function Et(e){switch(e.type){case`api_key`:return`API key · ${e.credential}`;case`oauth_subscription`:return`ChatGPT Subscription`;case`platform`:return`Managed proxy`;case`none`:return`None (local)`;default:return e.type}}function Dt({isOpen:e,assistantId:t,onClose:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=u(),{data:c,isLoading:l,isError:f}=d({...ee({path:{assistant_id:t}}),enabled:e}),p=(0,Z.useMemo)(()=>c?.connections??[],[c]);function m(e){s.invalidateQueries({queryKey:G({path:{assistant_id:t}})}),i(!1),o(null)}let h=p.map(e=>e.name),g=()=>{i(!1),o(null)};return(0,Q.jsx)(S.Root,{open:e,onOpenChange:e=>{e||(r?g():n())},children:e?r?(0,Q.jsx)(Tt,{mode:a?a.isManaged?`managed-edit`:`edit`:`create`,connection:a??void 0,assistantId:t,existingNames:h,onSave:m,onCancel:g}):(0,Q.jsx)(Ot,{connections:p,loading:l,isError:f,assistantId:t,onClose:n,onEditClick:e=>{o(e),i(!0)},onNewClick:()=>{o(null),i(!0)},onConnectionDeleted:()=>{s.invalidateQueries({queryKey:G({path:{assistant_id:t}})})}}):null})}function Ot({connections:e,loading:t,isError:n,assistantId:r,onClose:i,onEditClick:a,onNewClick:o,onConnectionDeleted:c}){let[l,u]=(0,Z.useState)({}),[d,f]=(0,Z.useState)({});async function p(e){f(t=>({...t,[e]:!0})),u(t=>{let n={...t};return delete n[e],n});try{let{response:t}=await I({path:{assistant_id:r,name:e}});t?.ok||t?.status===404?c(e):t?.status===409?u(t=>({...t,[e]:`Connection is in use by one or more profiles. Remove those references first.`})):u(t=>({...t,[e]:`Failed to delete connection. Please try again.`}))}catch{u(t=>({...t,[e]:`Failed to delete connection. Please try again.`}))}finally{f(t=>{let n={...t};return delete n[e],n})}}return(0,Q.jsxs)(S.Content,{size:`md`,children:[(0,Q.jsxs)(S.Header,{children:[(0,Q.jsx)(S.Title,{children:`Provider Connections`}),(0,Q.jsx)(S.Description,{children:`Manage inference provider connections. Each connection binds a name to a provider and auth configuration.`})]}),(0,Q.jsx)(S.Body,{children:t?(0,Q.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`h-10 animate-pulse rounded-lg bg-[var(--surface-active)]`},e))}):n?(0,Q.jsx)(m,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:`Failed to load connections. Please try again.`}):e.length===0?(0,Q.jsx)(m,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:`No connections yet. Create one to get started.`}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>{let t=d[e.name]??!1,n=l[e.name],r=e.isManaged??!1;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg px-2 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(m,{variant:`body-medium-default`,as:`span`,className:`text-(--content-default)`,children:e.label??e.name}),r&&(0,Q.jsx)(v,{tone:`positive`,title:`Managed by Platform — auth is locked, but you can rename this connection.`,children:`Platform`})]}),(0,Q.jsxs)(m,{variant:`body-medium-lighter`,as:`p`,className:`mt-0.5 text-(--content-tertiary)`,children:[e.label?`${e.name} · `:``,ge[e.provider]??e.provider,` · `,Et(e.auth)]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,onClick:()=>a(e),children:`Edit`}),(0,Q.jsx)(s,{variant:`ghost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),"aria-label":`Delete ${e.name}`,disabled:r||t,title:r?`Managed connections cannot be deleted`:void 0,onClick:()=>void p(e.name),tintColor:`var(--system-negative-strong)`})]})]}),n?(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`px-2 pb-1 text-(--system-negative-strong)`,children:n}):null]},e.name)})})}),(0,Q.jsxs)(S.Footer,{className:`justify-between`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:o,children:`+ New Connection`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:i,children:`Done`})]})]})}function kt(e){let[t,n]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Z.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}function At(){let e=at(),t=u(),{data:n}=d({...R({path:{assistant_id:e}}),staleTime:3e4}),r=n?.llm?.activeProfile??null,i=n?.llm?.advisorProfile??null,o=n?.llm?.callSites??{},{profiles:c,profileOrder:l}=De(n?.llm,e),f=(0,Z.useMemo)(()=>Ae(c,l),[c,l]),p=V({onSuccess:n=>{U(t,{path:{assistant_id:e}},n)}}),[g,_]=kt(r),[v,y]=kt(i),[b,x]=(0,Z.useState)(!1),[S,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),D=J.use.queryComplexityRouting(),O=(0,Z.useMemo)(()=>Xe(tt(f,[g]),D),[f,g,D]),k=(0,Z.useMemo)(()=>Xe(tt(f,[v]),D),[f,v,D]),A=Object.entries(o).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length,M=A===1?`1 Override`:A>0?`${A} Overrides`:`Overrides`,N=g!==r,P=v!==i,F=(0,Z.useCallback)(async()=>{try{let t={};N&&(t.activeProfile=g),P&&(t.advisorProfile=v),await p.mutateAsync({path:{assistant_id:e},body:{llm:t}}),C.success(`Saved.`)}catch(e){C.error(`Failed to save. Please try again.`),a(e,{context:`settings-ai-language-model-save`})}},[N,P,g,v,p,e]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ft,{title:`Language Model`,subtitle:`Configure the LLMs that power your assistant`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Default Profile`}),(0,Q.jsx)(h,{value:g??``,onChange:e=>{_(e===``?null:e)},placeholder:`Select a default profile…`,options:O.map(e=>({value:e.name,label:e.name===`auto`?`Automatically switch between profiles`:rt(e)}))}),D&&g===`auto`&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2 rounded-lg bg-[var(--surface-warning-subtle)] px-3 py-2`,children:(0,Q.jsx)(`span`,{className:`text-body-small-default text-[var(--content-warning)]`,children:`Auto may use more powerful models when needed, which can increase costs.`})}),O.length===0?(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`No profiles yet. Click Profiles below to create one.`}):null]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Advisor Profile`}),(0,Q.jsx)(h,{value:v??``,onChange:e=>{y(e===``?null:e)},placeholder:`Select an advisor profile…`,options:k.map(e=>({value:e.name,label:e.name===`auto`?`Automatically switch between profiles`:rt(e)}))}),(0,Q.jsx)(m,{variant:`body-small-default`,as:`p`,className:`mt-1 text-(--content-tertiary)`,children:`Which model your assistant consults for a second opinion`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>E(!0),children:`Providers`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>x(!0),children:`Profiles`}),(0,Q.jsx)(s,{variant:`outlined`,size:`compact`,onClick:()=>w(!0),children:M})]}),(N||P)&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:F,disabled:p.isPending}),p.isPending&&(0,Q.jsx)(j,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]})}),e&&(0,Q.jsx)(Ct,{isOpen:b,assistantId:e,onClose:()=>x(!1)}),e&&(0,Q.jsx)(yt,{isOpen:S,onClose:()=>w(!1),assistantId:e}),e&&(0,Q.jsx)(Dt,{isOpen:T,assistantId:e,onClose:()=>E(!1)})]})}var jt=`vellum:ai:imageGenMode`,Mt=`vellum:ai:imageGenModel`,Nt=`vellum:ai:webSearchMode`,Pt=`vellum:ai:webSearchProvider`,Ft=`vellum:ai:webFetchProvider`,It=`vellum:ai:emailMode`,Lt=`vellum:ai:emailByoProvider`,Rt=`vellum:voice:ttsProvider`,zt=`vellum:voice:ttsApiKey:`,Bt=`vellum:voice:ttsVoiceId:`,Vt=`vellum:voice:sttProvider`,Ht=`vellum:voice:sttApiKey:`;function Ut(){let e=at();return(0,Z.useCallback)(async(t,n)=>{try{let{data:r}=await N({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});it(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?C.error(`Assistant not ready. Please try again.`):C.error(`Failed to save ${t} API key. Please try again.`),a(e,{context:`provision_provider_key`}),e}},[e])}function Wt(){let e=at(),i=u(),{data:o}=d({...R({path:{assistant_id:e}}),staleTime:3e4}),s=V({onSuccess:t=>{U(i,{path:{assistant_id:e}},t)}}),c=Ut(),{serverWebSearchMode:l,serverWebSearchProvider:f}=(0,Z.useMemo)(()=>{if(!o)return{serverWebSearchMode:Y(n(Nt,`your-own`),`your-own`),serverWebSearchProvider:n(Pt,`inference-provider-native`)};let e=o.services?.[`web-search`];return{serverWebSearchMode:Y(e?.mode??n(`vellum:ai:webSearchMode`,`your-own`),`your-own`),serverWebSearchProvider:e?.provider||n(`vellum:ai:webSearchProvider`,`inference-provider-native`)}},[o]),[p,m]=(0,Z.useState)(!1),[g,_]=kt(l),[v,b]=kt(f),[x,S]=(0,Z.useState)(``),w=$e.has(v),{hasStoredCredential:T}=Ze({assistantId:e,credentialKind:`api_key`,credentialName:v,enabled:w}),E=x.trim().length>0,D=p||g===`your-own`&&w&&!T&&!E||!(g!==l||(g===`managed`?`inference-provider-native`:v)!==f)&&!E,O=Ye(X[v]??`Enter your API key`,T),k=(0,Z.useCallback)(async()=>{m(!0);let t=x.trim(),n=g===`managed`?`inference-provider-native`:v,o=Se(n),l=g===`your-own`&&w&&t.length>0;try{l&&await c(n,t),await s.mutateAsync({path:{assistant_id:e},body:{services:{"web-search":{mode:g,provider:n}}}}).catch(e=>{throw C.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{m(!1);return}m(!1);try{if(r(Nt,g),r(Pt,n),l){o&&r(o,t);let n=Oe(e,`api_key`,v);i.setQueryData(n,!0),i.invalidateQueries({queryKey:n}),S(``)}C.success(`Web search settings saved.`)}catch(e){a(e,{context:`settings-ai-web-search-persist-local`}),C.error(`Saved, but local preferences could not be written.`)}},[w,s,c,i,e,x,g,v]),A=(0,Z.useCallback)(()=>{let e=Se(v);e&&t(e),S(``),b(`inference-provider-native`),r(Pt,`inference-provider-native`)},[v,b]);return(0,Q.jsx)(ut,{title:`Web Search`,subtitle:`Configure how your assistant should search the web`,mode:g,onModeChange:e=>_(e),children:g===`managed`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Web search is included with managed inference.`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:k,disabled:D}),p&&(0,Q.jsx)(j,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:v,onChange:b,options:ce.map(e=>({value:e,label:we[e]??e}))})]}),w&&(0,Q.jsx)(y,{label:`API Key`,type:`password`,value:x,onChange:e=>S(e.target.value),placeholder:O,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:k,disabled:D}),p&&(0,Q.jsx)(j,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),w&&(0,Q.jsx)(dt,{onClick:A,filled:!0})]})]})})}var Gt=`default`;function Kt(){let e=at(),i=u(),{data:o}=d({...R({path:{assistant_id:e}}),staleTime:3e4}),s=V({onSuccess:t=>{U(i,{path:{assistant_id:e}},t)}}),c=Ut(),l=(0,Z.useMemo)(()=>o?o.services?.[`web-fetch`]?.provider||n(`vellum:ai:webFetchProvider`,Gt):n(Ft,Gt),[o]),[f,p]=(0,Z.useState)(!1),[m,g]=kt(l),[_,v]=(0,Z.useState)(``),b=_e.has(m),{hasStoredCredential:x}=Ze({assistantId:e,credentialKind:`api_key`,credentialName:m,enabled:b}),S=_.trim().length>0,w=f||b&&!x&&!S||m===l&&!S,T=Ye(Ie[m]??`Enter your API key`,x),E=(0,Z.useCallback)(async()=>{p(!0);let t=_.trim(),n=b&&t.length>0;try{n&&await c(m,t),await s.mutateAsync({path:{assistant_id:e},body:{services:{"web-fetch":{provider:m}}}}).catch(e=>{throw C.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e})}catch{p(!1);return}p(!1);try{if(r(Ft,m),n){let n=nt(m);n&&r(n,t);let a=Oe(e,`api_key`,m);i.setQueryData(a,!0),i.invalidateQueries({queryKey:a}),v(``)}C.success(`Web fetch settings saved.`)}catch(e){a(e,{context:`settings-ai-web-fetch-persist-local`}),C.error(`Saved, but local preferences could not be written.`)}},[b,s,c,i,e,_,m]),D=(0,Z.useCallback)(()=>{let e=nt(m);e&&t(e),v(``),g(Gt),r(Ft,Gt)},[m,g]);return(0,Q.jsx)(ft,{id:`web-fetch`,title:`Web Fetch`,subtitle:`Configure how your assistant reads individual web pages`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:m,onChange:g,options:ie.map(e=>({value:e,label:Re[e]??e}))})]}),b&&(0,Q.jsx)(y,{label:`API Key`,type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:T,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:E,disabled:w}),f&&(0,Q.jsx)(j,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),b&&(0,Q.jsx)(dt,{onClick:D,filled:!0})]})]})})}var qt=[{id:`elevenlabs`,displayName:`ElevenLabs`,subtitle:`High-quality voice synthesis for conversations and read-aloud. Requires an ElevenLabs API key.`,supportsVoiceSelection:!0,apiKeyPlaceholder:`sk_…`,credentialsGuide:{description:`Sign in to ElevenLabs, go to your Profile, and copy your API key.`,url:`https://elevenlabs.io/app/settings/api-keys`,linkLabel:`Open ElevenLabs API Keys`}},{id:`fish-audio`,displayName:`Fish Audio`,subtitle:`Natural-sounding voice synthesis with custom voice cloning. Requires a Fish Audio API key and voice reference ID.`,supportsVoiceSelection:!0,apiKeyPlaceholder:`Enter your Fish Audio API key`,credentialsGuide:{description:`Sign in to Fish Audio, navigate to API Keys in your dashboard, and create a new key.`,url:`https://fish.audio/app/api-keys/`,linkLabel:`Open Fish Audio API Keys`}},{id:`deepgram`,displayName:`Deepgram`,subtitle:`Fast, accurate text-to-speech synthesis. Uses the same API key as Deepgram speech-to-text.`,supportsVoiceSelection:!1,apiKeyPlaceholder:`Enter your Deepgram API key`,credentialsGuide:{description:`Sign in to Deepgram, navigate to your API Keys page, and create or copy an existing key. This is the same key used for speech-to-text.`,url:`https://console.deepgram.com/`,linkLabel:`Open Deepgram Console`}},{id:`xai`,displayName:`xAI`,subtitle:`Text-to-speech from xAI with expressive voices (eve, ara, rex, sal, leo). Requires an xAI API key.`,supportsVoiceSelection:!1,apiKeyPlaceholder:`Enter your xAI API key`,credentialsGuide:{description:`Sign in to the xAI console, navigate to API Keys, and create a new key.`,url:`https://console.x.ai/`,linkLabel:`Open xAI Console`}}],Jt=[{id:`deepgram`,displayName:`Deepgram`,subtitle:`Fast, accurate speech-to-text transcription. Uses the same API key as Deepgram text-to-speech.`,apiKeyPlaceholder:`Enter your Deepgram API key`,credentialsGuide:{description:`Sign in to Deepgram, navigate to your API Keys page, and create or copy an existing key. This is the same key used for text-to-speech.`,url:`https://console.deepgram.com/`,linkLabel:`Open Deepgram Console`}},{id:`openai`,displayName:`OpenAI`,subtitle:`OpenAI Whisper transcription. Requires an OpenAI API key.`,apiKeyPlaceholder:`sk-…`,credentialsGuide:{description:`Sign in to the OpenAI platform, navigate to API Keys, and create a new secret key.`,url:`https://platform.openai.com/api-keys`,linkLabel:`Open OpenAI API Keys`}},{id:`macos-native`,displayName:`macOS Native Dictation`,subtitle:`Apple's on-device speech recognition, running locally through the macOS helper. Works offline and needs no API key.`,requiresNativeDictation:!0,setupWarning:`Requires macOS Dictation to be turned on: open System Settings → Keyboard, then enable Dictation. macOS downloads the on-device speech model the first time Dictation is enabled — without it, voice input produces no transcript.`}],Yt=[{id:`mailgun`,displayName:`Mailgun`,setupSkill:`mailgun-setup`,docsUrl:`https://www.mailgun.com/`},{id:`resend`,displayName:`Resend`,setupSkill:`resend-setup`,docsUrl:`https://resend.com/`}],Xt=[`gemini-3.1-flash-image-preview`,`gemini-3-pro-image-preview`],Zt={"gemini-3.1-flash-image-preview":`Nano Banana 2`,"gemini-3-pro-image-preview":`Nano Banana Pro`};function Qt({assistantId:e,assistantHandle:t,emailRootDomain:n}){let r=u(),i=c(),[o,p]=l(),[m,h]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{v||!t||m||(h(t),y(!0))},[t,v,m]);let I=d({...Ue(),enabled:!0}),L=I.data,ee=L?.entitlements,R=ee?.managed_email===!0,z=!!ee&&!R,B=!L&&I.isError&&!I.isFetching,V=d({...et({path:{assistant_id:e}}),enabled:!z}),H=d({...ze({path:{assistant_id:e}}),enabled:!z}),U=V.data?.results?.[0],W=H.data?.results?.[0],G=U?`${U.subdomain}.${n}`:null,K=d({...Le({path:{assistant_id:e,id:W?.id??``}}),enabled:!!W?.id,refetchOnWindowFocus:!1}),q=d({...le({path:{assistant_id:e,id:U?.id??``}}),enabled:!!U?.id,refetchInterval:e=>{let t=e.state.data?.status;return t===`verified`||t===`failed`?!1:1e4},refetchOnWindowFocus:!0});(0,Z.useEffect)(()=>{o.get(`release`)!==`1`||!U||W||(N(!0),p(e=>{let t=new URLSearchParams(e);return t.delete(`release`),t},{replace:!0}))},[W,U,o,p]);let re=f(Ce()),J=f(oe()),ie=f(se()),Y=f(ve()),X=(0,Z.useCallback)(()=>{let t={assistant_id:e};r.invalidateQueries({queryKey:Te({path:t})}),r.invalidateQueries({queryKey:ae({path:t})}),W?.id&&r.invalidateQueries({queryKey:he({path:{...t,id:W.id}})}),r.invalidateQueries({queryKey:de()})},[W?.id,e,r]),ce=(0,Z.useCallback)(async()=>{let t=m.trim().toLowerCase();if(!t){x(`Enter a subdomain.`);return}A(!1);try{await re.mutateAsync({path:{assistant_id:e},body:{subdomain:t}}),h(``),x(null),X(),C.success(`Domain ${t}.${n} registered.`)}catch(e){x(te(e,void 0,`Failed to register domain.`))}},[e,n,X,re,m]),ue=(0,Z.useCallback)(async()=>{let t=S.trim().toLowerCase();if(!t){E(`Enter an email username.`);return}try{await ie.mutateAsync({path:{assistant_id:e},body:{username:t}}),w(``),E(null),X(),C.success(`Email address created.`)}catch(e){E(te(e,void 0,`Failed to create email address.`))}},[e,X,ie,S]),fe=(0,Z.useCallback)(async()=>{if(W?.id){F(!1);try{await Y.mutateAsync({path:{assistant_id:e,id:W.id}}),X(),C.success(`Email address removed.`)}catch(e){a(e,{context:`email_address_delete`}),C.error(`Failed to remove email address.`)}}},[W?.id,e,Y,X]),me=(0,Z.useCallback)(async()=>{if(!U?.id)return;if(W){C.error(`Remove the email address first.`);return}N(!1);let t=U.subdomain;try{await J.mutateAsync({path:{assistant_id:e,id:U.id}}),h(t),X(),C.success(`Domain released.`)}catch(e){a(e,{context:`email_domain_release`}),C.error(`Failed to release domain.`)}},[W,e,J,U?.id,U?.subdomain,X]);if(I.isLoading)return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(j,{className:`h-4 w-4 animate-spin`}),`Checking subscription…`]});if(z)return(0,Q.jsxs)(_,{tone:`info`,icon:(0,Q.jsx)(D,{className:`h-4 w-4`,"aria-hidden":!0}),title:`Get a dedicated email address for your assistant`,actions:(0,Q.jsx)(s,{size:`compact`,onClick:()=>i(`${ne.settings.billing}?adjust_plan`),children:`Upgrade to Pro`}),children:[`Pro plans include a managed`,` `,`<your-subdomain>.${n}`,` inbox — no provider setup required. Or switch to `,(0,Q.jsx)(`strong`,{children:`Your Own`}),` to bring an existing provider.`]});let ge=B?(0,Q.jsx)(_,{tone:`warning`,title:`Couldn't verify subscription status`,actions:(0,Q.jsx)(s,{size:`compact`,variant:`outlined`,onClick:()=>I.refetch(),children:`Retry`}),children:`We couldn't reach the billing service. The form below assumes managed email is enabled for your org — if it isn't, registering a domain will fail.`}):null;return U?W?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[ge,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:W.address}),(0,Q.jsx)(mt,{status:q.data?.status,message:q.data?.message,isLoading:q.isLoading}),(0,Q.jsx)(s,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),onClick:()=>F(!0),disabled:Y.isPending,"aria-label":`Remove email address`})]}),(0,Q.jsx)(g,{open:P,title:`Remove Email Address`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to remove `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:W.address}),`? Your assistant will no longer be able to send or receive email at this address.`]}),confirmLabel:`Remove`,destructive:!0,onConfirm:fe,onCancel:()=>F(!1)})]}),K.data?.usage&&(0,Q.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[K.data.usage.sent_today,` /`,` `,K.data.usage.daily_limit,` sent today ·`,` `,K.data.usage.received_today,` received`]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[ge,(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Domain`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`font-mono text-body-small-default text-[var(--content-default)]`,children:[U.subdomain,`.`,n]}),(0,Q.jsx)(mt,{status:q.data?.status,message:q.data?.message,isLoading:q.isLoading}),(0,Q.jsx)(s,{variant:`dangerGhost`,size:`compact`,iconOnly:(0,Q.jsx)(pe,{}),onClick:()=>N(!0),disabled:J.isPending,"aria-label":`Release domain`})]}),(0,Q.jsx)(g,{open:M,title:`Release Domain`,message:(0,Q.jsxs)(Q.Fragment,{children:[`Are you sure you want to release `,(0,Q.jsxs)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:[U.subdomain,`.`,n]}),`? The subdomain will become available for others to claim.`]}),confirmLabel:`Release`,destructive:!0,onConfirm:me,onCancel:()=>N(!1)})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Email address`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex h-9 min-w-0 flex-1 items-center rounded-md border bg-[var(--field-bg)] text-body-medium-lighter transition-[border-color] duration-150 ${T?`border-[var(--system-negative-strong)]`:`border-[var(--field-border)] focus-within:border-[var(--border-active)]`}`,children:[(0,Q.jsx)(`input`,{value:S,onChange:e=>{w(e.target.value.toLowerCase()),T&&E(null)},placeholder:`hi`,"aria-label":`Email username`,"aria-invalid":!!T,className:`h-full min-w-0 flex-1 bg-transparent pl-3 pr-1 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`}),(0,Q.jsxs)(`span`,{className:`shrink-0 pr-3 font-mono text-[var(--content-secondary)]`,children:[`@`,G]})]}),(0,Q.jsx)(s,{onClick:ue,disabled:ie.isPending||!S.trim(),children:ie.isPending?`Creating…`:`Create`})]}),T&&(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:T})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[ge,(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Subdomain`}),(0,Q.jsx)(O,{subdomain:m,onSubdomainChange:e=>{h(e),b&&x(null)},domainSuffix:n,subdomainPlaceholder:`my-assistant`,error:b}),(0,Q.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Each assistant gets its own subdomain. Lowercase letters, numbers, and hyphens only.`}),(0,Q.jsx)(s,{onClick:()=>A(!0),disabled:re.isPending||!m.trim(),children:re.isPending?`Registering…`:`Register`}),(0,Q.jsx)(g,{open:k,title:`Set Subdomain`,message:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 font-mono text-[0.9em]`,children:m.trim().toLowerCase()||`subdomain`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),confirmLabel:`Confirm`,onConfirm:ce,onCancel:()=>A(!1)})]})}function $t(){let e=at(),t=q(),{data:o}=d({...be(),enabled:t}),s=o?.results?.[0]?.handle,c=st.use.emailRootDomain(),l=Ee(),[u,f]=(0,Z.useState)(()=>l===`gated`?`your-own`:Y(n(It,`managed`),`managed`)),[p,m]=(0,Z.useState)(()=>{let e=n(Lt,`resend`);return e===`mailgun`||e===`resend`?e:`resend`}),g=d({queryKey:[`byoEmailCredential`,e,p],queryFn:async()=>{let{data:t}=await L({path:{assistant_id:e},body:{service:p,field:`api_key`},throwOnError:!0});return t},enabled:u===`your-own`||l===`gated`,staleTime:6e4,retry:i,meta:{errorContext:`byo_email_credential_check`}});(0,Z.useEffect)(()=>{g.error&&a(g.error,{context:`byo_email_credential_check`,bestEffort:!0})},[g.error]);let _=g.data?.hasSecret===!0,v=(0,Z.useCallback)(e=>{f(e),r(It,e)},[]),y=(0,Z.useCallback)(()=>{r(Lt,p),C.success(`Email settings saved.`)},[p]),b=(0,Z.useMemo)(()=>Yt.find(e=>e.id===p)??Yt[0],[p]),x=(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(A,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{children:[`Configure `,b.displayName,` via the assistant CLI: ask the assistant to run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:b.setupSkill}),` `,`skill. It walks you through storing the API key, detecting the domain, and (optionally) wiring up an inbound webhook.`]}),(0,Q.jsxs)(`a`,{href:b.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,b.displayName,(0,Q.jsx)(k,{className:`h-3 w-3`})]})]})]}),S=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:p,onChange:e=>{(e===`mailgun`||e===`resend`)&&m(e)},options:Yt.map(e=>({value:e.id,label:e.displayName}))})]}),_?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--system-positive-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-default)]`,children:[(0,Q.jsx)(E,{className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,Q.jsxs)(`span`,{children:[b.displayName,` API key configured. To reconfigure, run the`,` `,(0,Q.jsx)(`code`,{className:`rounded bg-[var(--surface-active)] px-1 py-0.5 text-[12px]`,children:b.setupSkill}),` `,`skill.`]})]}),(0,Q.jsxs)(`a`,{href:b.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-body-small-default text-[var(--system-positive-strong)] underline hover:opacity-80`,children:[`Open `,b.displayName,(0,Q.jsx)(k,{className:`h-3 w-3`})]})]}):x,(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)($,{onClick:y,disabled:!1})})]});return l===`gated`?(0,Q.jsx)(ft,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,children:S}):(0,Q.jsx)(ut,{id:`email`,title:`Email`,subtitle:`Configure how your assistant sends and receives email`,mode:u,onModeChange:v,children:u===`managed`?(0,Q.jsx)(`div`,{className:`space-y-4`,children:l===`disabled`?(0,Q.jsx)(xe,{children:`Log in to the Vellum platform to manage email settings.`}):(0,Q.jsx)(Qt,{assistantId:e,assistantHandle:s,emailRootDomain:c})}):S})}function en(){let e=at(),t=u(),{data:i}=d({...R({path:{assistant_id:e}}),staleTime:3e4}),o=V({onSuccess:n=>{U(t,{path:{assistant_id:e}},n)}}),s=Ut(),[c,l]=kt((0,Z.useMemo)(()=>Y(i?i.services?.[`image-generation`]?.mode??n(`vellum:ai:imageGenMode`,`your-own`):n(jt,`your-own`),`your-own`),[i])),[f,p]=(0,Z.useState)(()=>n(Mt,`gemini-3.1-flash-image-preview`)),[m,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),b=(0,Z.useCallback)(async()=>{v(!0);let n=m.trim(),i=c===`your-own`&&n.length>0;try{i&&await s(`gemini`,n),await o.mutateAsync({path:{assistant_id:e},body:{services:{"image-generation":{mode:c}}}}).catch(e=>{throw C.error(`Failed to update assistant configuration. Please try again.`),a(e,{context:`patch_daemon_config`}),e});try{await F({path:{assistant_id:e},body:{modelId:f},throwOnError:!0})}catch(e){throw C.error(`Failed to update image generation model. Please try again.`),a(e,{context:`set_image_gen_model`}),e}finally{t.invalidateQueries({queryKey:H({path:{assistant_id:e}})})}}catch{v(!1);return}v(!1);try{r(jt,c),r(Mt,f),i&&g(``),C.success(`Image generation settings saved.`)}catch(e){a(e,{context:`settings-ai-image-gen-persist-local`}),C.error(`Saved, but local preferences could not be written.`)}},[m,c,f,e,o,s,t]),x=(0,Z.useCallback)(()=>{g(``),p(`gemini-3.1-flash-image-preview`),r(Mt,`gemini-3.1-flash-image-preview`)},[]);return(0,Q.jsx)(ut,{title:`Image Generation`,subtitle:`Configure which model your assistant uses to generate images`,mode:c,onModeChange:e=>l(e),children:c===`managed`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,Q.jsx)(h,{className:`flex-1`,value:f,onChange:p,options:Xt.map(e=>({value:e,label:Zt[e]??e}))}),(0,Q.jsx)($,{onClick:b,disabled:_}),_&&(0,Q.jsx)(j,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(y,{label:`API Key`,type:`password`,value:m,onChange:e=>g(e.target.value),placeholder:`Enter your Gemini API key`,fullWidth:!0}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Active Model`}),(0,Q.jsx)(h,{value:f,onChange:p,options:Xt.map(e=>({value:e,label:Zt[e]??e}))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:b,disabled:_}),_&&(0,Q.jsx)(j,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),(0,Q.jsx)(dt,{onClick:x})]})]})})}async function tn(e){let{provider:t,apiKey:n,voiceId:r,text:i}=e;if(n.trim().length===0)return{kind:`error`,message:`Save an API key for this provider first.`};try{return t===`elevenlabs`?await nn(n,r,i):t===`deepgram`?await rn(n,i):t===`fish-audio`?{kind:`unsupported`,message:`Fish Audio TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:t===`xai`?{kind:`unsupported`,message:`xAI TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:{kind:`unsupported`,message:`TTS testing for "${t}" is not supported from the browser yet.`}}catch(e){return{kind:`error`,message:e instanceof Error?e.message:`Failed to reach the TTS provider.`}}}async function nn(e,t,n){let r=t.trim();if(r.length===0)return{kind:`error`,message:`Enter and save a Voice ID before testing ElevenLabs.`};let i=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(r)}?output_format=mp3_44100_128`,{method:`POST`,headers:{"xi-api-key":e,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:n,model_id:`eleven_turbo_v2_5`})});return i.ok?{kind:`audio`,blob:await i.blob()}:{kind:`error`,message:await an(i,`ElevenLabs rejected the request.`)}}async function rn(e,t){let n=await fetch(`https://api.deepgram.com/v1/speak?model=aura-2-thalia-en`,{method:`POST`,headers:{Authorization:`Token ${e}`,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:t})});return n.ok?{kind:`audio`,blob:await n.blob()}:{kind:`error`,message:await an(n,`Deepgram rejected the request.`)}}async function an(e,t){try{let n=await e.text();if(n.length===0)return`${t} (HTTP ${e.status})`;try{let e=JSON.parse(n);if(e&&typeof e==`object`&&`detail`in e&&typeof e.detail==`string`)return e.detail;if(e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`)return e.message}catch{}return n.slice(0,200)}catch{return`${t} (HTTP ${e.status})`}}function on(){let e=at(),t=re.use.name()??`your assistant`,i=q(),{data:a}=d({...W({path:{assistant_id:e}}),enabled:i,staleTime:1/0}),o=a?.providers??qt,c=o[0]?.id??`elevenlabs`,[l,u]=(0,Z.useState)(()=>n(Rt,c)),[f,p]=(0,Z.useState)(l),[m,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(``),[S,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),D=(0,Z.useMemo)(()=>o.find(e=>e.id===l)??o[0],[l,o]),O=(0,Z.useCallback)(e=>{let t=n(zt+e,``),r=n(Bt+e,``);w(t.length>0),v(r),x(r),g(``)},[]);(0,Z.useEffect)(()=>{O(l)},[l,O]);let k=(0,Z.useMemo)(()=>{let e=l!==f,t=m.trim().length>0,n=_.trim()!==b;return e||t||n},[l,f,m,_,b]),A=(0,Z.useCallback)(()=>{r(Rt,l);let e=m.trim();e.length>0&&(r(zt+l,e),w(!0));let t=_.trim();r(Bt+l,t),p(l),x(t),g(``)},[l,m,_]),j=(0,Z.useCallback)(()=>{r(zt+l,``),w(!1),g(``)},[l]),M=(0,Z.useCallback)(async()=>{E(!0);try{let e=n(zt+l,``),r=m.trim(),i=r.length>0?r:e;if(i.length===0){C.error(`Save an API key for this provider before testing.`);return}let a=n(Bt+l,``),o=_.trim(),s=await tn({provider:l,apiKey:i,voiceId:o.length>0?o:a,text:`Hey! It's ${t}. How does this sound?`});if(s.kind!==`audio`){C.error(s.message);return}let c=URL.createObjectURL(s.blob);try{let e=new Audio(c);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(c)}}finally{E(!1)}},[t,m,l,_]),N=S?`•••••••• (Enter a new key to replace)`:D.apiKeyPlaceholder;return(0,Q.jsx)(ft,{title:`Text-to-Speech`,subtitle:D.subtitle,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:l,onChange:u,options:o.map(e=>({value:e.id,label:e.displayName})),"aria-label":`TTS provider`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(y,{type:`password`,value:m,onChange:e=>g(e.target.value),placeholder:N,fullWidth:!0})]}),D.supportsVoiceSelection&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Voice ID`}),(0,Q.jsx)(y,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:`Enter a voice ID`,fullWidth:!0})]}),(0,Q.jsx)(pt,{guide:D.credentialsGuide}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(s,{variant:`outlined`,onClick:M,disabled:T,children:T?`Testing…`:`Test`}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Q.jsx)($,{onClick:A,disabled:!k}),S&&(0,Q.jsx)(dt,{onClick:j})]})]})]})})}function sn(){let[e]=(0,Z.useState)(()=>Jt.filter(e=>!e.requiresNativeDictation||Ke())),t=e[0]?.id??`deepgram`,[i,a]=(0,Z.useState)(()=>{let r=n(Vt,t);return e.some(e=>e.id===r)?r:t}),[o,s]=(0,Z.useState)(i),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let i=n(Vt,t);i===`macos-native`&&!e.some(e=>e.id===i)&&r(Vt,t)},[e,t]);let f=(0,Z.useMemo)(()=>e.find(e=>e.id===i)??e[0],[e,i]),p=f.apiKeyPlaceholder!==void 0;(0,Z.useEffect)(()=>{d(n(Ht+i,``).length>0),l(``)},[i]);let m=(0,Z.useMemo)(()=>{let e=i!==o,t=c.trim().length>0;return e||t},[i,o,c]),g=(0,Z.useCallback)(()=>{r(Vt,i);let e=c.trim();e.length>0&&(r(Ht+i,e),d(!0)),s(i),l(``)},[i,c]),_=(0,Z.useCallback)(()=>{r(Ht+i,``),d(!1),l(``)},[i]),v=u?`•••••••• (Enter a new key to replace)`:f.apiKeyPlaceholder;return(0,Q.jsx)(ft,{title:`Speech-to-Text`,subtitle:f.subtitle,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,Q.jsx)(h,{value:i,onChange:a,options:e.map(e=>({value:e.id,label:e.displayName})),"aria-label":`STT provider`})]}),p&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:`API Key`}),(0,Q.jsx)(y,{type:`password`,value:c,onChange:e=>l(e.target.value),placeholder:v,fullWidth:!0})]}),f.setupWarning&&(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,Q.jsx)(M,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,Q.jsx)(`span`,{children:f.setupWarning})]}),f.credentialsGuide&&(0,Q.jsx)(pt,{guide:f.credentialsGuide}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Q.jsx)($,{onClick:g,disabled:!m}),u&&(0,Q.jsx)(dt,{onClick:_})]})]})})}function cn(){return(0,Z.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]),(0,Q.jsxs)(`div`,{className:`space-y-5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-4 py-2.5`,children:[(0,Q.jsx)(A,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,Q.jsxs)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:[`Managed services are metered and deducted from your Vellum account balance.`,` `,(0,Q.jsxs)(`a`,{href:`https://www.vellum.ai/docs/pricing`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[var(--primary-base)] hover:underline`,children:[`View pricing`,(0,Q.jsx)(k,{className:`h-3.5 w-3.5`})]})]})]}),(0,Q.jsx)(At,{}),(0,Q.jsx)(Wt,{}),(0,Q.jsx)(Kt,{}),(0,Q.jsx)($t,{}),(0,Q.jsx)(en,{}),(0,Q.jsx)(on,{}),(0,Q.jsx)(sn,{})]})}export{cn as AiPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D7s2Q_uG.js";import{d as r,h as i}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./dropdown-yOV5eJnU.js";import{t as s}from"./input-CwdmSRlD.js";import{t as c}from"./is-electron-Dk-hdKh_.js";import{a as l}from"./routes-DZiaa4kh.js";import{_t as u}from"./index-
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D7s2Q_uG.js";import{d as r,h as i}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./dropdown-yOV5eJnU.js";import{t as s}from"./input-CwdmSRlD.js";import{t as c}from"./is-electron-Dk-hdKh_.js";import{a as l}from"./routes-DZiaa4kh.js";import{_t as u}from"./index-DdZDYyvJ.js";import{n as d,r as f}from"./provider-key-D_NfTOtX.js";var p=e(t(),1),m=[{id:`anthropic`,displayName:`Anthropic`,apiKeyPlaceholder:`sk-ant-api03-...`,docsUrl:`https://console.anthropic.com/settings/keys`,requiresKey:!0},{id:`openai`,displayName:`OpenAI`,apiKeyPlaceholder:`sk-proj-...`,docsUrl:`https://platform.openai.com/api-keys`,requiresKey:!0},{id:`gemini`,displayName:`Google Gemini`,apiKeyPlaceholder:`AIza...`,docsUrl:`https://aistudio.google.com/apikey`,requiresKey:!0},{id:`ollama`,displayName:`Ollama`,apiKeyPlaceholder:null,docsUrl:`https://ollama.com/download`,requiresKey:!1},{id:`fireworks`,displayName:`Fireworks`,apiKeyPlaceholder:`fw_...`,docsUrl:`https://fireworks.ai/account/api-keys`,requiresKey:!0},{id:`openrouter`,displayName:`OpenRouter`,apiKeyPlaceholder:`sk-or-v1-...`,docsUrl:`https://openrouter.ai/keys`,requiresKey:!0},{id:`openai-compatible`,displayName:`OpenAI-compatible`,apiKeyPlaceholder:`Your provider's API key`,docsUrl:null,requiresKey:!0}],h=m[0];function g(e){return m.find(t=>t.id===e)}var _=a();function v(){let e=r(),[t]=i(),a=t.get(`hosting`),v=c(),[y,b]=(0,p.useState)(()=>d()?.provider??h.id),[x,S]=(0,p.useState)(()=>d()?.key??``),C=g(y)??h,w=C.requiresKey,T=!w||x.trim().length>0;return(0,_.jsx)(u,{children:(0,_.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${v?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`px-6 py-16`} text-[var(--content-default)]`,children:[(0,_.jsx)(`h1`,{className:v?`text-title-large`:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Connect a Model Provider`}),(0,_.jsx)(`p`,{className:`text-center text-body-medium-lighter text-[var(--content-tertiary)] ${v?`mt-3.5`:`mt-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Enter an API key to connect your model provider.`}),(0,_.jsxs)(`div`,{className:`flex w-full flex-col gap-4 ${v?`mt-8`:`mt-10`}`,style:{animation:`fadeInUp 0.5s ease-out 0.4s both`},children:[(0,_.jsxs)(`div`,{className:`flex flex-col ${v?`gap-2`:`gap-1`}`,children:[(0,_.jsx)(`label`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Provider`}),(0,_.jsx)(o,{"aria-label":`Provider`,value:y,onChange:e=>{let t=g(e);t&&(b(t.id),S(``))},options:m.map(e=>({value:e.id,label:e.displayName}))})]}),w&&(0,_.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,_.jsx)(s,{type:`password`,label:`${C.displayName} API Key`,placeholder:C.apiKeyPlaceholder??`Enter your API key`,value:x,onChange:e=>S(e.target.value),fullWidth:!0}),C.docsUrl&&(0,_.jsxs)(`p`,{className:`self-start text-body-medium-lighter text-[var(--content-tertiary)]`,children:[`Don't have it?`,` `,(0,_.jsx)(`a`,{href:C.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-[var(--content-default)] underline`,children:`Get an API key here`})]})]})]}),(0,_.jsxs)(`div`,{className:`mt-8 flex w-full flex-col ${v?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[(0,_.jsx)(n,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:!T,onClick:()=>{T&&(f({provider:y,key:w?x.trim():``}),e(a?`${l.onboarding.privacy}?hosting=${a}`:l.onboarding.privacy))},className:v?void 0:`h-11 text-base`,children:`Continue`}),(0,_.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,onClick:()=>{e(l.onboarding.hosting)},className:v?void 0:`h-11 text-base`,children:`Back`})]})]})})}export{v as ApiKeyScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-DZeS1sIw.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-D7s2Q_uG.js";import{n as i}from"./QueryClientProvider-DKhXIxGb.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./card-BibIM9x3.js";import"./src-DPHBRruq.js";import{n as s}from"./toast-DLWkiWW6.js";import{t as c}from"./archive-BbVZeIUr.js";import{t as l}from"./loader-circle-CQd2jpMq.js";import{t as u}from"./triangle-alert-JYuV8dTb.js";import{G as d}from"./sdk.gen-Ds50lD_U.js";import{t as f}from"./conversation-queries-gRQUugiL.js";import{
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-DZeS1sIw.js";import{t as n}from"./react-DJZBPgpf.js";import{t as r}from"./button-D7s2Q_uG.js";import{n as i}from"./QueryClientProvider-DKhXIxGb.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./card-BibIM9x3.js";import"./src-DPHBRruq.js";import{n as s}from"./toast-DLWkiWW6.js";import{t as c}from"./archive-BbVZeIUr.js";import{t as l}from"./loader-circle-CQd2jpMq.js";import{t as u}from"./triangle-alert-JYuV8dTb.js";import{G as d}from"./sdk.gen-Ds50lD_U.js";import{t as f}from"./conversation-queries-gRQUugiL.js";import{ua as p,zr as m}from"./index-DdZDYyvJ.js";import{t as h}from"./use-active-assistant-id-BCNolO1R.js";var g=e(n(),1),_=a();function v(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 y(){return(0,_.jsx)(o,{children:(0,_.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,_.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,_.jsx)(c,{className:`h-6 w-6 text-[var(--content-disabled)] dark:text-[var(--content-default)]`})}),(0,_.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`No archived conversations`}),(0,_.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Conversations you archive will appear here.`})]})})}function b({conversation:e,isFirst:t,onUnarchive:n,isPending:i}){let a=[v(e.createdAt),e.source??`vellum-assistant`].filter(Boolean).join(` · `),o=e.title&&e.title.trim().length>0?e.title:`Untitled conversation`;return(0,_.jsxs)(`div`,{className:`flex items-center gap-3 py-3 ${t?``:`border-t border-[var(--border-base)]`}`,children:[(0,_.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,_.jsx)(`div`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:o}),(0,_.jsx)(`p`,{className:`mt-0.5 truncate text-body-small-default text-[var(--content-tertiary)]`,children:a})]}),(0,_.jsx)(r,{variant:`outlined`,onClick:n,disabled:i,className:`shrink-0`,children:i?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(l,{className:`h-4 w-4 animate-spin`}),`Unarchiving`]}):`Unarchive`})]})}function x(){let e=i(),n=h(),{conversations:a,isLoading:c,isError:v,refetch:x}=f(n),[S,C]=(0,g.useState)(null),w=(0,g.useCallback)(async r=>{if(n){C(r);try{await d({path:{assistant_id:n,id:r},throwOnError:!0}),m(e,n)}catch(e){t(e,{context:`archive_settings_unarchive_conversation`}),s.error(`Failed to unarchive conversation.`)}finally{C(null)}}},[n,e]);return c?(0,_.jsx)(`div`,{className:`w-full`,children:(0,_.jsx)(`div`,{className:`flex min-h-[400px] items-center justify-center`,children:(0,_.jsx)(l,{className:`h-6 w-6 animate-spin text-[var(--content-disabled)]`})})}):v?(0,_.jsx)(`div`,{className:`w-full`,children:(0,_.jsx)(o,{children:(0,_.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,_.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--system-error-lighter)]`,children:(0,_.jsx)(u,{className:`h-6 w-6 text-[var(--system-error-default)]`})}),(0,_.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`Failed to load archived conversations`}),(0,_.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Something went wrong. Please try again.`}),(0,_.jsxs)(r,{variant:`outlined`,onClick:x,className:`mt-4`,children:[(0,_.jsx)(p,{className:`h-4 w-4`}),`Retry`]})]})})}):a.length===0?(0,_.jsx)(`div`,{className:`w-full`,children:(0,_.jsx)(y,{})}):(0,_.jsx)(`div`,{className:`w-full`,children:(0,_.jsx)(o,{noPadding:!0,className:`px-4`,children:a.map((e,t)=>(0,_.jsx)(b,{conversation:e,isFirst:t===0,onUnarchive:()=>{w(e.conversationId)},isPending:S===e.conversationId},e.conversationId))})})}export{x as ArchivePage};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/native-file-BUireD7W.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-BewR0kVT.js","assets/dist-Cz6xHevA.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e,t}from"./chunk-jRWAZmH_.js";import{t as n}from"./capture-error-DZeS1sIw.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-D7s2Q_uG.js";import{t as a}from"./preload-helper-BewR0kVT.js";import{d as o,h as s,r as c}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as l}from"./QueryClientProvider-DKhXIxGb.js";import{t as u}from"./useQuery-B45lW1Kk.js";import{t as d}from"./useMutation-Lj4VunQV.js";import{t as f}from"./jsx-runtime-CVSDxk6A.js";import{t as p}from"./typography-BscuIPxA.js";import{t as m}from"./card-BibIM9x3.js";import{t as h}from"./dropdown-yOV5eJnU.js";import{t as g}from"./confirm-dialog-DbNUkFt6.js";import{t as _}from"./notice-G5Imd5pC.js";import{t as v}from"./tag-BadGF3FB.js";import{t as y}from"./input-CwdmSRlD.js";import{t as b}from"./toggle-_vZlLDBV.js";import{n as x,t as S}from"./stat-square-B5tBfA4w.js";import{t as C}from"./modal-DX6UN7b0.js";import{n as w}from"./toast-DLWkiWW6.js";import{t as T}from"./createLucideIcon-B4vraqUn.js";import{t as E}from"./arrow-left-qoT7VLmC.js";import{t as D}from"./circle-alert-DDTljqKw.js";import{t as O}from"./circle-check-B8Xk989s.js";import{t as k}from"./cpu-CH8d3KT5.js";import{t as A}from"./credit-card-BDQQWUeD.js";import{n as j,t as M}from"./domain-field-C6WnRdqe.js";import{t as N}from"./dollar-sign-B4MWYH-Q.js";import{t as P}from"./external-link-oRvm6ohU.js";import{t as F}from"./hard-drive-Ci2ZXgVv.js";import{t as I}from"./info-CKGk-lqa.js";import{t as L}from"./loader-circle-CQd2jpMq.js";import{a as ee,c as te,i as ne,n as R,r as z,t as B}from"./resize-errors-mLlMjyQj.js";import{t as V}from"./triangle-alert-JYuV8dTb.js";import{ot as H,st as re}from"./sdk.gen-DGVBsBOr.js";import{a as U}from"./routes-DZiaa4kh.js";import{n as ie}from"./use-is-mobile-DsYMm_nj.js";import{t as ae}from"./effective-timezone-DyTKBg-v.js";import{$a as oe,$n as se,Aa as ce,Bt as le,Co as ue,Fn as de,Ht as fe,Ir as pe,Ji as me,Ka as he,Lr as ge,Pr as _e,Qn as ve,S as ye,St as be,Un as xe,Vt as Se,Wi as Ce,_r as W,ar as we,br as G,cr as Te,dr as Ee,er as De,fr as Oe,gr as ke,hr as Ae,ir as je,kr as Me,lr as Ne,mr as K,no as Pe,nr as Fe,or as Ie,pr as Le,rr as Re,sr as ze,to as Be,tr as Ve,ur as He,vo as Ue,vr as We,wn as Ge,xr as Ke,xt as qe,yn as Je,zt as Ye}from"./index-DdZDYyvJ.js";import{t as Xe}from"./add-credits-modal-DDaRdeai.js";import{t as Ze}from"./format-date-7PLUvplv.js";import{a as Qe,n as $e,t as et}from"./llm-dimension-DK0ysmoJ.js";import{r as tt,t as nt}from"./usage-window-CfMa7ilx.js";import{t as rt}from"./environment-store-BHYCnW0P.js";var it=T(`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`}]]),at=T(`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`}]]),ot=T(`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`}]]),st=T(`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`}]]),q=e(r(),1),J=f();function ct({onBack:e}){let t=o(),{data:n}=u(Je()),r=n?.name||`your assistant`;return(0,J.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,J.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,J.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,J.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,J.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,J.jsx)(at,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,J.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,J.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,J.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,J.jsxs)(i,{variant:`primary`,"data-testid":`onboarding-complete-return`,onClick:()=>t(U.assistant,{replace:!0}),children:[`Return to `,r]})}),(0,J.jsx)(`div`,{className:`absolute bottom-4 left-4`,children:(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-complete-back`,onClick:e,leftIcon:(0,J.jsx)(E,{className:`h-4 w-4`}),children:`Back`})})]})}function lt({current:e,total:t=2}){return(0,J.jsx)(`div`,{className:`flex items-center justify-center gap-1.5`,children:Array.from({length:t},(t,n)=>(0,J.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 ut({icon:e,tone:t=`positive`}){let n=t===`positive`?`--system-positive-strong`:t===`warning`?`--system-mid-strong`:`--system-negative-strong`;return(0,J.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,J.jsx)(e,{className:`h-5 w-5`,style:{color:`var(${n})`},"aria-hidden":`true`})})}var dt=1e3,ft=1e4;function pt(e){return ne[e]??ne.medium}var mt=[`machine_size`,`subdomain`,`non_field_errors`],ht={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 gt(e,t){if(e&&typeof e==`object`){let t=e;if(typeof t.error==`string`){let e=ht[t.error];if(e)return e}for(let e of mt){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 _t({onBack:e,onExit:t}){let n=l(),r=rt.use.emailRootDomain(),{data:a}=u(Je()),o=a?.id,{data:s}=u({...Ge({path:{assistant_id:o??``}}),enabled:!!o}),c=s?.results?.[0],[f,m]=(0,q.useState)(``),[h,g]=(0,q.useState)(`hi`),[v,y]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!v){if(c){m(c.subdomain),y(!0);return}!a?.handle||f||(m(a.handle),y(!0))}},[a?.handle,c,v,f]);let[b,x]=(0,q.useState)(null),[S,w]=(0,q.useState)(!1),T=d(Ee()),D=!!c||S,O=T.isPending||S;return(0,q.useEffect)(()=>{if(!S)return;let e=setTimeout(t,800);return()=>clearTimeout(e)},[S,t]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,J.jsx)(ut,{icon:ce}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Assistant email`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Set up an email address for your assistant.`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`body-small-default`,as:`label`,className:`text-[var(--content-secondary)]`,children:`Email address`}),(0,J.jsx)(M,{subdomain:f,autoFocus:!0,onSubdomainChange:e=>{m(e),b&&x(null)},domainSuffix:r,disabled:O,error:b,locked:D,lockedMessage:`This domain has been set and cannot be changed.`,prefix:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{value:h,onChange:e=>g(e.target.value.toLowerCase().trim()),disabled:O||D,readOnly:D,placeholder:`hi`,"aria-label":`Email username`,size:Math.max(h.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(h.length,2)+1.5}ch`}}),(0,J.jsx)(`span`,{className:`shrink-0 font-mono text-[var(--content-secondary)]`,children:`@`})]})})]}),!D&&(0,J.jsxs)(_,{tone:`info`,children:[(0,J.jsx)(`span`,{className:`font-mono`,children:f||`<subdomain>`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),S?(0,J.jsx)(_,{tone:`success`,children:`Domain set — redirecting…`}):null]}),(0,J.jsxs)(C.Footer,{className:`relative items-center justify-between`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-back`,disabled:O,onClick:e,leftIcon:(0,J.jsx)(E,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,J.jsx)(lt,{current:0})}),(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:D?(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-continue`,onClick:t,children:`Continue`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-skip`,disabled:O,onClick:()=>{O||T.mutate({body:{skipped:!0}},{onSuccess:t,onError:()=>t()})},children:`Do later`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-set`,disabled:!f||O,onClick:()=>{O||!f||T.mutate({body:{subdomain:f,...h?{email_username:h}:{}}},{onSuccess:()=>{x(null),w(!0),n.invalidateQueries({queryKey:de()})},onError:e=>{x(gt(e,`Couldn't register that subdomain. Try a different one.`))}})},children:`Set domain`})]})})]})]})}function vt({onGoToBilling:e}){return(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsx)(ut,{icon:D,tone:`negative`}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Couldn't reach billing`}),(0,J.jsx)(p,{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,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-go-to-billing`,onClick:e,children:`Go to billing`})]})}function yt({message:e,onRetry:t,onGoToBilling:n}){return(0,J.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsx)(ut,{icon:D,tone:`warning`}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Taking longer than expected`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:e})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,J.jsx)(i,{variant:`outlined`,"data-testid":`onboarding-go-to-billing`,onClick:n,children:`Go to billing`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-retry`,onClick:t,children:`Try again`})]})]})}function bt({title:e,body:t}){return(0,J.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsxs)(`div`,{className:`relative flex h-11 w-11 items-center justify-center`,children:[(0,J.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,J.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,J.jsx)(L,{className:`relative h-5 w-5 animate-spin text-[var(--system-positive-strong)]`,"aria-hidden":`true`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:e}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:t})]})]})}function xt({icon:e,label:t,from:n,fromDetail:r,to:i,toDetail:a}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,J.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,J.jsx)(e,{className:`h-4 w-4 text-[var(--system-positive-strong)]`})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:t}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)] line-through`,children:n}),r&&(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)] line-through`,children:r})]}),(0,J.jsx)(ue,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:i}),a&&(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:a})]})]})]})]})}function St({storageGib:e,maxTier:t,onBack:n,onAdvance:r,dotIndex:a,dotTotal:o}){let{data:s}=u(Je()),c=s?.machine_size||`small`,l=s?.provisioned_storage_gib??null,f=pt(t),m=f.length>0?f[f.length-1]:c,h=m!==c,g=e!=null&&(l==null||l<e),[v,y]=(0,q.useState)(null),b=d(xe());return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,J.jsx)(ut,{icon:k}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Your assistant's new resources`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Your assistant will go offline briefly while it resizes.`})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[h&&(0,J.jsx)(xt,{icon:k,label:`Machine`,from:z[c],fromDetail:R[c],to:z[m],toDetail:R[m]}),g&&(0,J.jsx)(xt,{icon:F,label:`Storage`,from:l==null?`—`:`${l} GiB`,to:`${e} GiB`}),!h&&!g&&(0,J.jsx)(_,{tone:`neutral`,children:`Your assistant is already running at the maximum size for your plan.`})]}),v?(0,J.jsx)(_,{tone:`error`,children:v}):null]}),(0,J.jsxs)(C.Footer,{className:`relative items-center justify-between`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-back`,disabled:b.isPending,onClick:n,leftIcon:(0,J.jsx)(E,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,J.jsx)(lt,{current:a,total:o})}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-skip`,disabled:b.isPending,onClick:r,children:`Do later`}),(0,J.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(gt(e,`Couldn't apply changes. Please try again.`))}})},children:`Apply & Restart`})]})]})]})}function Ct({onContinue:e,continueDisabled:t=!1}){return(0,J.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,J.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,J.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,J.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,J.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,J.jsx)(j,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,J.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,J.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,J.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-welcome-continue`,disabled:t,onClick:e,children:`Get started`})}),(0,J.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 wt({open:e,onClose:t}){let n=l(),[r,i]=(0,q.useState)(`confirm-pro`),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(0);(0,q.useEffect)(()=>{e&&(n.invalidateQueries({queryKey:Ae()}),n.invalidateQueries({queryKey:Le()}))},[e,n]);let d=(0,q.useCallback)(()=>{o(!1),c(e=>e+1),n.invalidateQueries({queryKey:Ae()})},[n]),f=u({...K(),refetchInterval:e=>e.state.data?.plan_id===`pro`||a?!1:dt,refetchIntervalInBackground:!1,enabled:e&&r===`confirm-pro`});(0,q.useEffect)(()=>{if(!e||r!==`confirm-pro`)return;let t=setTimeout(()=>o(!0),ft);return()=>clearTimeout(t)},[e,r,s]),(0,q.useEffect)(()=>{r===`confirm-pro`&&f.data?.plan_id===`pro`&&i(`welcome`)},[r,f.data?.plan_id]);let p=u({...Oe(),enabled:e&&r!==`confirm-pro`});u({...Je(),enabled:e});let m=p.data?.domain_setup_available,h=(0,q.useCallback)(()=>{i(m===!1?`setup`:`domain`)},[m]),g=(0,q.useCallback)(()=>{i(m===!1?`welcome`:`domain`)},[m]),_=r===`welcome`;return(0,J.jsx)(C.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,J.jsx)(C.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,J.jsx)(vt,{onGoToBilling:t}):a?(0,J.jsx)(yt,{message:`We're still confirming your upgrade.`,onRetry:d,onGoToBilling:t}):(0,J.jsx)(bt,{title:`Finalizing your upgrade…`,body:`This usually takes a few seconds.`});if(r===`welcome`)return p.isError?(0,J.jsx)(vt,{onGoToBilling:t}):(0,J.jsx)(Ct,{onContinue:h,continueDisabled:p.isPending||p.isFetching});if(r===`domain`)return(0,J.jsx)(_t,{onBack:()=>i(`welcome`),onExit:()=>i(`setup`)});if(r===`setup`){if(p.isError)return(0,J.jsx)(vt,{onGoToBilling:t});let e=p.data?.max_machine_tier??null,n=m!==!1;return(0,J.jsx)(St,{storageGib:p.data?.selected_storage_gib??null,maxTier:e,onBack:g,onAdvance:()=>i(`complete`),dotIndex:+!!n,dotTotal:n?2:1})}return r===`complete`?(0,J.jsx)(ct,{onBack:()=>i(`setup`)}):null}}var Tt=`billing-portal-return-snapshot`;function Et(e){try{sessionStorage.removeItem(Tt),sessionStorage.setItem(Tt,JSON.stringify(e))}catch{}}function Dt(){if(typeof sessionStorage>`u`)return null;try{let e=sessionStorage.getItem(Tt);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 Ot(){try{sessionStorage.removeItem(Tt)}catch{}}function kt(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 At(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function jt(e){return e?e.cancel_at??e.current_period_end??null:null}function Mt(e){let t=l();return(0,q.useEffect)(()=>be(()=>{t.invalidateQueries(K())}),[t]),pe({onSuccess:t=>{e&&Et(e),qe(t.portal_url)},onError:()=>{w.error(`Couldn't open the billing portal. Please try again.`,{id:`billing-portal-session-error`})}})}function Nt(e){let t=e/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}function Y(e){return`${Nt(e)}/mo`}function Pt(e){return`${e>0?`+`:`−`}${Nt(Math.abs(e))}/mo`}var Ft={medium:`Medium`,large:`Large`,xl:`XL`};function It(e){return e.disabled===!0}function Lt({machineTiers:e,storageTiers:t,selectedMachineTier:n,selectedStorageTier:r,onMachineTierChange:i,onStorageTierChange:a,currentMachinePriceCents:o,currentStoragePriceCents:s}){let c=(0,q.useMemo)(()=>e.map(e=>{let t=Ft[e.tier]??e.label,n=o==null?`+${Y(e.price_cents)}`:e.price_cents===o?`(${Y(e.price_cents)}, current)`:Pt(e.price_cents-o);return{value:e.tier,label:`${t} ${n}`,disabled:It(e)}}),[e,o]),l=(0,q.useMemo)(()=>t.map(e=>{let t=s==null?`+${Y(e.price_cents)}`:e.price_cents===s?`(${Y(e.price_cents)}, current)`:Pt(e.price_cents-s);return{value:e.tier,label:`${e.storage_gib} GiB ${t}`,disabled:It(e)}}),[t,s]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Machine`}),(0,J.jsx)(`span`,{title:`Determines the CPU and memory allocated to your assistant`,children:(0,J.jsx)(I,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(h,{"aria-label":`Machine tier`,placeholder:`Select a machine tier`,value:n??``,onChange:i,options:c})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Storage`}),(0,J.jsx)(`span`,{title:`Persistent disk space for your assistant's files and data`,children:(0,J.jsx)(I,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(h,{"aria-label":`Storage tier`,placeholder:`Select a storage tier`,value:r??``,onChange:a,options:l})]})]})}var Rt=new Set([`active`,`trialing`,`past_due`]),zt=[`target_plan_id`,`confirm`,`machine_tier`,`storage_tier`,`credit_tier`,`non_field_errors`];function Bt(e,t){if(e&&typeof e==`object`){for(let t of zt)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 Vt(e,t){let n=e.filter(e=>!It(e));return t!==null&&n.some(e=>e.tier===t)?t:n[0]?.tier??null}function Ht(e,t,n){return t===void 0?n:t!==null&&(t===n||e.some(e=>e.tier===t))?t:null}function Ut(e){return e.length?Math.min(...e.map(e=>e.price_cents)):0}function Wt({open:e,onCancel:t,onConfirm:n,confirming:r,lostFeatures:a}){return(0,J.jsx)(C.Root,{open:e,onOpenChange:e=>{!e&&!r&&t()},children:(0,J.jsxs)(C.Content,{size:`md`,hideCloseButton:!0,children:[(0,J.jsx)(C.Header,{children:(0,J.jsx)(C.Title,{icon:V,children:`Downgrade to Base?`})}),(0,J.jsxs)(C.Body,{children:[(0,J.jsx)(p,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,J.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:a.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,J.jsxs)(C.Footer,{children:[(0,J.jsx)(i,{variant:`outlined`,onClick:t,disabled:r,children:`Keep Pro`}),(0,J.jsx)(i,{variant:`danger`,onClick:n,disabled:r,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]})})}var Gt=`__none__`;function Kt(e){return`${e.label} — ${Y(e.price_cents)}`}function qt({creditTiers:e,selectedCreditTier:t,onCreditTierChange:n,disabled:r=!1}){let i=(0,q.useMemo)(()=>[{value:Gt,label:`No credit bundle — ${Y(0)}`},...e.map(e=>({value:e.tier,label:Kt(e)}))],[e]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Credit bundle`}),(0,J.jsx)(`span`,{title:`A monthly allotment of credits added to your Pro Plan subscription`,children:(0,J.jsx)(I,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(h,{"aria-label":`Credit bundle`,placeholder:`Select a credit bundle`,disabled:r,value:t??Gt,onChange:e=>n(e===Gt?null:e),options:i})]})}function Jt({features:e,variant:t,header:n,maxInline:r=3}){return t===`inline`?(0,J.jsx)(J.Fragment,{children:e.slice(0,r).join(`, `)}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n&&(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-secondary)]`,children:n}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,J.jsx)(O,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})]},e))})]})}function Yt({plan:e,isCurrent:t,onPro:n,cancelAtPeriodEnd:r,isCanceled:a,cancelDate:o,formatGraceDate:s,proTierChangeMode:c,creditTiersEnabled:l,creditTiers:u,displayCreditTier:d,onCreditTierChange:f,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:y,onStorageTierChange:b,machineTiersForPicker:x,storageTiersForPicker:S,currentMachinePrice:C,currentStoragePrice:w,currentCreditPriceUnknown:T,proCurrentTotalCents:E,proLiveTotalCents:D,proTotalDelta:O,onboardingLoading:k,tierChangePending:A,machineChanged:M,storageChanged:N,creditChanged:P,tierChangeError:F,upgradePending:ee,portalPending:te,onUpgrade:ne,onApplyTierChange:R,onDowngradeClick:z,onKeepPlan:B}){let V=e.id===`pro`,H=e.id===`base`,re=V&&n&&r&&!a,U=V&&(!t||t&&c),ie=V&&t&&c;return(0,J.jsxs)(m,{padding:`lg`,className:`flex flex-col bg-[var(--surface-base)]`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.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:V?(0,J.jsx)(j,{className:`h-5 w-5 text-[var(--content-default)]`}):(0,J.jsx)(st,{className:`h-5 w-5 text-[var(--content-default)]`})}),(0,J.jsxs)(`div`,{className:`flex min-h-6 items-center gap-2`,children:[(0,J.jsx)(p,{as:`h3`,variant:`title-small`,children:e.name}),t&&(0,J.jsx)(v,{tone:`positive`,children:`Current`})]}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`-mt-2 text-[var(--content-tertiary)]`,children:H?`All you need for a capable assistant`:`More features, more compute, more storage`}),re&&o&&(0,J.jsxs)(p,{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,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:H?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,children:`Free`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:`Forever`})]}):t&&!(U&&D!=null)&&(E==null||T)?k?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(L,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,J.jsx)(p,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-price-unavailable`,children:`Current plan pricing unavailable`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,"data-testid":`modal-pro-price`,children:U&&D!=null?(0,J.jsxs)(J.Fragment,{children:[Y(D),O!=null&&O!==0&&(0,J.jsxs)(`span`,{className:`ml-1 text-[var(--content-tertiary)]`,children:[`(`,Pt(O),`)`]})]}):E==null?e.id===`pro`?`From ${Y(e.base_price_cents+Ut(e.machine_tiers)+Ut(e.storage_tiers))}`:null:`Currently ${Y(E)}`}),U&&O!=null&&O!==0&&(0,J.jsx)(`span`,{title:`Your Pro Plan subscription will change from ${Y(E)} to ${Y(D)}.`,children:(0,J.jsx)(I,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),e.id===`pro`&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-base-fee`,children:[Nt(e.base_price_cents),` base fee`]})]})}),(0,J.jsx)(Jt,{features:e.included_features,variant:`checklist`}),V&&!l&&(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-credits-not-included`,children:`*Credits not included`})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex flex-1 flex-col justify-end gap-4`,children:[!t&&V&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,J.jsx)(qt,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:f,disabled:ee}),(0,J.jsx)(Lt,{machineTiers:x,storageTiers:S,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:y,onStorageTierChange:b}),(0,J.jsx)(i,{variant:`primary`,className:`w-full`,onClick:ne,disabled:ee||!h||!g,"data-testid":`modal-upgrade-to-pro-button`,children:`Upgrade to Pro`})]}),ie&&(k?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(L,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,J.jsx)(qt,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:f,disabled:A}),(0,J.jsx)(Lt,{machineTiers:x,storageTiers:S,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:y,onStorageTierChange:b,currentMachinePriceCents:C,currentStoragePriceCents:w}),F&&(0,J.jsx)(_,{tone:`error`,children:F}),(0,J.jsx)(i,{variant:`primary`,className:`w-full`,onClick:R,disabled:A||!M&&!N&&!P,"data-testid":`modal-change-tier-button`,children:`Update Plan`})]})),!t&&H&&n&&!r&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:z,disabled:te,"data-testid":`modal-downgrade-to-base-button`,children:`Downgrade to Base`})]}),re&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:B,disabled:te,"data-testid":`modal-keep-plan-button`,children:`Keep your Plan`})]})]})]})}function Xt({open:e,onClose:t,onTierUpgraded:n}){let r=l(),a=u(Ie()),o=u(K()),s=d(ke()),c=d(Ne()),f=d(He()),m=d(Te()),h=Mt(kt(o.data)),[g,v]=(0,q.useState)(`plans`),[y,b]=(0,q.useState)(!1),[x,S]=(0,q.useState)(null),[T,D]=(0,q.useState)(null),[O,k]=(0,q.useState)(void 0);(0,q.useEffect)(()=>be(()=>{r.invalidateQueries({queryKey:Ae()}),r.invalidateQueries({queryKey:ze()}),r.invalidateQueries({queryKey:Le()}),t()}),[r,t]);let A=o.data?.plan_id,j=A===`pro`,M=u({...Oe(),enabled:j}),N=M.data?.max_machine_tier??null,P=M.data?.selected_storage_tier??null,F=M.data?.selected_storage_gib??null,I=o.data?.cancel_at_period_end===!0||!!o.data?.cancel_at,ee=o.data?.status===`canceled`,te=jt(o.data),ne=o.data?.status,R=ne!=null&&Rt.has(ne),z=j&&R&&!I&&!ee,B=a.data?.plans.find(e=>e.id===`pro`),H=B?.credit_tiers??[],re=H.length>0,U=o.data?.selected_credit_tier??null,ie=e=>H.find(t=>t.tier===e)?.price_cents??0,ae=ie(U),oe=U!=null&&!H.some(e=>e.tier===U),se=O===void 0?U:O,ce=ie(se),le=B?.machine_tiers??[],ue=z&&F!=null?(B?.storage_tiers??[]).map(e=>e.storage_gib<F?{...e,disabled:!0}:e):B?.storage_tiers??[];(0,q.useEffect)(()=>{if(!e){S(null),D(null),k(void 0);return}if(B){if(z){if(N==null||P==null)return;S(e=>Vt(le,e??N)),D(e=>Vt(ue,e??P)),k(e=>Ht(H,e,U));return}S(e=>Vt(B.machine_tiers,e)),D(e=>Vt(B.storage_tiers,e)),k(e=>Ht(H,e,null))}},[e,B,z,N,P,U]);let de=a.data?.plans.find(e=>e.id===`base`),fe=new Set(de?.included_features??[]),pe=(B?.included_features??[]).filter(e=>!fe.has(e)),me=()=>{if(!s.isPending){if(!x||!T){w.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:T,credit_tier:se}},{onSuccess:e=>{if(e.checkout_url){qe(e.checkout_url);return}if(e.status===`no_op`){w.info(`You're already on Pro.`,{id:`pro-upgrade`}),t();return}w.error(e.message??`Failed to start upgrade. Please try again.`,{id:`pro-upgrade-error`})},onError:e=>{w.error(Bt(e,`Failed to start upgrade. Please try again.`),{id:`pro-upgrade-error`})}})}},he=()=>{h.isPending||(v(`plans`),h.mutate({}))},ge=()=>{r.invalidateQueries({queryKey:Ae()}),r.invalidateQueries({queryKey:Le()}),r.invalidateQueries({queryKey:ze()})},_e=c.isPending||f.isPending||m.isPending,ve=x!=null&&x!==N,ye=T!=null&&T!==P,xe=re&&O!==void 0&&O!==U,Se=e=>le.find(t=>t.tier===e)?.price_cents??null,Ce=e=>ue.find(t=>t.tier===e)?.price_cents??null,W=Se(x),we=Ce(T),G=Se(N),Ee=Ce(P),De=ve&&W!=null&&G!=null&&W<G,je=()=>{if(_e)return;let e=[];ve&&x&&e.push(new Promise(e=>{c.mutate({body:{machine_tier:x}},{onSuccess:()=>e({dimension:`machine`,ok:!0}),onError:t=>e({dimension:`machine`,ok:!1,error:t})})})),ye&&T&&e.push(new Promise(e=>{f.mutate({body:{storage_tier:T}},{onSuccess:()=>e({dimension:`storage`,ok:!0}),onError:t=>e({dimension:`storage`,ok:!1,error:t})})})),xe&&e.push(new Promise(e=>{m.mutate({body:{credit_tier:se}},{onSuccess:()=>e({dimension:`credit`,ok:!0}),onError:t=>e({dimension:`credit`,ok:!1,error:t})})})),Promise.all(e).then(e=>{ge();let r=e.some(e=>e.ok&&e.dimension===`storage`),i=e.some(e=>e.ok&&e.dimension===`machine`)&&!De,a=(r||i)&&!!n,o=e.filter(e=>!e.ok);if(o.length>0){let e=o.map(e=>Bt(e.error,`Failed to update ${e.dimension} tier.`)).join(` `);w.error(e,{id:`pro-tier-change-error`}),a&&(t(),n());return}a?(t(),n()):w.success(xe&&!ve&&!ye?`Credit bundle updated.`:`Plan updated.`,{id:`pro-tier-change`})})},Me=()=>{if(!_e){if(De){b(!0);return}je()}},Pe=()=>{b(!1),je()},Fe=e=>W!=null&&we!=null?e.base_price_cents+W+we+ce:null,Re=e=>G!=null&&Ee!=null?e.base_price_cents+G+Ee+ae:null,Be=c.isError||f.isError||m.isError?Bt(c.error??f.error??m.error,`Failed to update plan. Please try again.`):null,Ve=a.isLoading||o.isLoading,Ue=a.isError||o.isError||!a.data||!o.data;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(C.Root,{open:e,onOpenChange:e=>{e||(v(`plans`),t())},children:(0,J.jsx)(C.Content,{size:g===`plans`?`lg`:`md`,children:g===`downgrade-confirm`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(C.Header,{children:(0,J.jsx)(C.Title,{icon:V,children:`Downgrade to Base?`})}),(0,J.jsxs)(C.Body,{children:[(0,J.jsx)(p,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,J.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:pe.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,J.jsxs)(C.Footer,{children:[(0,J.jsx)(i,{variant:`ghost`,onClick:()=>v(`plans`),disabled:h.isPending,leftIcon:(0,J.jsx)(E,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(i,{variant:`danger`,onClick:he,disabled:h.isPending,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(C.Header,{children:(0,J.jsx)(C.Title,{className:`sr-only`,children:`Upgrade Plan`})}),(0,J.jsx)(C.Body,{children:Ve?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(L,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading plans...`})]}):Ue?(0,J.jsx)(_,{tone:`error`,children:`Failed to load plans. Please try again later.`}):(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`space-y-2 pb-2 pt-4 text-center`,children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,children:`Your Assistant, Your Way`}),(0,J.jsx)(p,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-secondary)]`,children:`Choose the plan that works best for you and your assistant.`})]}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:a.data.plans.map(e=>{let t=e.id===A,n=e.id===`pro`&&B?Fe(B):null,r=e.id===`pro`&&B?Re(B):null;return(0,J.jsx)(Yt,{plan:e,isCurrent:t,onPro:j,cancelAtPeriodEnd:I,isCanceled:ee,cancelDate:te,formatGraceDate:At,proTierChangeMode:z,creditTiersEnabled:re,creditTiers:H,displayCreditTier:se,onCreditTierChange:k,selectedMachineTier:x,selectedStorageTier:T,onMachineTierChange:S,onStorageTierChange:D,machineTiersForPicker:le,storageTiersForPicker:ue,currentMachinePrice:G,currentStoragePrice:Ee,currentCreditPriceUnknown:oe,proCurrentTotalCents:r,proLiveTotalCents:n,proTotalDelta:n!=null&&r!=null?n-r:null,onboardingLoading:M.isLoading,tierChangePending:_e,machineChanged:ve,storageChanged:ye,creditChanged:xe,tierChangeError:Be,upgradePending:s.isPending,portalPending:h.isPending,onUpgrade:me,onApplyTierChange:Me,onDowngradeClick:()=>v(`downgrade-confirm`),onKeepPlan:()=>h.mutate({})},e.id)})})]})}),(0,J.jsxs)(C.Footer,{className:`relative items-center`,children:[(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`pointer-events-none absolute inset-x-0 text-center text-[var(--content-tertiary)]`,children:(0,J.jsx)(`span`,{className:`pointer-events-auto`,children:`You can change or cancel your plan at any time from billing settings.`})}),(0,J.jsx)(`div`,{className:`ml-auto`,children:(0,J.jsx)(i,{variant:`outlined`,onClick:t,"data-testid":`modal-cancel-button`,children:`Cancel`})})]})]})})}),(0,J.jsx)(Wt,{open:y,onCancel:()=>b(!1),onConfirm:Pe,confirming:_e,lostFeatures:[`Reduced CPU and memory for your assistant — it will resize to the smaller compute profile.`]})]})}var Zt={visa:`Visa`,mastercard:`Mastercard`,amex:`Amex`,discover:`Discover`,diners:`Diners Club`,jcb:`JCB`,unionpay:`UnionPay`};function Qt(e){return Zt[e.toLowerCase()]??e}function $t(e,t){return`${Qt(e??`card`)} •••• ${t??`????`}`}function en({open:e,confirming:t,onCancel:n,onConfirm:r}){return(0,J.jsx)(g,{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 tn={threshold_usd:`100`,amount_usd:`10`,monthly_cap_usd:``};function nn(e){if(e===``||e===`-`)return e;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function rn(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 an(e,t,n,r){if(n[e])return n[e];if(r)return t[e]}function on({initialValues:e=tn,submitting:t,serverErrors:n,onSave:r,onCancel:a}){let[o,s]=(0,q.useState)(e),[c,l]=(0,q.useState)({threshold_usd:!1,amount_usd:!1,monthly_cap_usd:!1}),u=rn(o),d=e=>t=>{s(n=>({...n,[e]:t.target.value}))},f=e=>()=>{l(t=>({...t,[e]:!0})),s(t=>({...t,[e]:nn(t[e])}))},p=e=>an(e,u,n,c[e]);return(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(y,{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,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(y,{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,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(y,{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,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-[18px]`,children:[(0,J.jsx)(i,{variant:`outlined`,onClick:a,disabled:t,children:`Cancel`}),(0,J.jsx)(i,{variant:`primary`,onClick:()=>{l({threshold_usd:!0,amount_usd:!0,monthly_cap_usd:!0});let e={threshold_usd:nn(o.threshold_usd),amount_usd:nn(o.amount_usd),monthly_cap_usd:nn(o.monthly_cap_usd)};s(e);let t=rn(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 sn(e){if(!e)return``;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function cn(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 ln={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 un(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 dn(e){let{brand:t,last4:n}=e;return!t&&!n?null:n?`Charged to ${$t(t,n)}`:`Charged to ${Qt(t??`card`)}`}function fn(){let e=l(),t=u(De()),n=d(je()),r=d(ve()),[a,o]=(0,q.useState)(`view`),[s,c]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(!1);if((0,q.useEffect)(()=>{m&&t.data?.has_payment_method&&h(!1)},[m,t.data?.has_payment_method]),t.isLoading)return(0,J.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,J.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Loading…`})});if(t.isError||!t.data)return(0,J.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,J.jsx)(_,{tone:`error`,children:`Failed to load auto top-up configuration.`})});let g=t.data,v=g.enabled===!0,y=g.disabled_due_to_repeated_failures===!0&&!v,x=()=>{n.reset(),r.reset(),o(`form`)},S=()=>{o(`view`),c(!1)},C=()=>{r.reset(),p(!1)},w=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=>{Fe(e,void 0,e=>({...t,payment_method_brand:e?.payment_method_brand??null,payment_method_last4:e?.payment_method_last4??null})),e.invalidateQueries({queryKey:Ve()}),S()}})},T=()=>{r.mutate({},{onSuccess:()=>{Fe(e,void 0,e=>({...ln,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`),c(!1)}})},E=e=>{if(e&&!v){if(!g.has_payment_method||y){h(!0);return}h(!1),c(!0),x();return}if(!e&&!v&&s){S();return}!e&&v&&p(!0)},D=a===`form`,O=un(n.error),k=n.isError&&Object.keys(O).length===0,A=v||s,j=dn({brand:g.payment_method_brand,last4:g.payment_method_last4});return(0,J.jsxs)(`div`,{"data-testid":`auto-top-up-card`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsx)(b,{checked:A,onChange:E,label:`Enable Auto-Reload`}),v&&!D&&(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsxs)(`div`,{className:`text-right`,children:[(0,J.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-summary`,children:[`Add `,cn(g.amount_usd),` when the balance falls under `,cn(g.threshold_usd)]}),g.monthly_cap_usd!=null&&(0,J.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-cap-progress`,children:[cn(g.current_month_credits_purchased_usd),` of`,` `,cn(g.monthly_cap_usd),` this month`]})]}),(0,J.jsx)(i,{variant:`outlined`,onClick:x,"data-testid":`auto-top-up-edit-button`,children:`Adjust`})]})]}),y&&(0,J.jsx)(_,{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,J.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-in-out`,style:{gridTemplateRows:m&&!y?`1fr`:`0fr`},children:(0,J.jsx)(`div`,{className:`overflow-hidden`,children:(0,J.jsx)(_,{tone:`warning`,className:`mt-3`,children:`You must first add a Payment Method before you can enable automatic credit reloads.`})})}),k&&(0,J.jsx)(_,{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,J.jsx)(_,{tone:`error`,className:`mt-4`,"data-testid":`auto-top-up-disable-error`,children:`Failed to disable automatic top-ups. Please try again.`}),D&&(0,J.jsx)(on,{initialValues:v?{threshold_usd:sn(g.threshold_usd),amount_usd:sn(g.amount_usd),monthly_cap_usd:sn(g.monthly_cap_usd)}:void 0,submitting:n.isPending,serverErrors:O,onCancel:S,onSave:w}),v&&!g.has_payment_method&&(0,J.jsx)(_,{tone:`warning`,className:`mt-3`,"data-testid":`auto-top-up-no-pm`,children:`You must add a Payment Method.`}),v&&g.has_payment_method&&(0,J.jsx)(`p`,{className:`mt-3 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-saved-pm`,children:j??`Charged to a saved card`}),(v||D)&&(0,J.jsx)(_,{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,J.jsx)(en,{open:f,confirming:r.isPending,onCancel:C,onConfirm:T})]})}var pn=2e3;function mn(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 hn(){let e=l(),{data:t,isLoading:n,isError:r}=u(W()),a=t??null,[o,s]=(0,q.useState)(!1),c=(0,q.useRef)(0),d=(0,q.useRef)(null),f=ge({onSuccess:()=>{e.invalidateQueries({queryKey:We()})},onError:()=>{c.current<3&&(d.current=setTimeout(()=>{f.reset()},pn))}});(0,q.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let h=f.mutate;(0,q.useEffect)(()=>{a&&a.settled_balance===`0.00`&&a.pending_compute===`0.00`&&a.effective_balance===`0.00`&&c.current<3&&!f.isPending&&!f.isError&&!f.isSuccess&&(c.current+=1,h({}))},[a,f.isPending,f.isError,f.isSuccess,h]);let g=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Balance`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`An overview of your credit balance and pending charges.`})]}),(0,J.jsx)(i,{variant:`primary`,onClick:()=>s(!0),disabled:n||!a,"data-testid":`add-credits-button`,children:`Add Credits`})]});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(m,{padding:`md`,children:[g,n?(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(L,{className:`h-4 w-4 animate-spin`}),`Loading billing summary...`]}):r?(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(_,{tone:`error`,children:`Failed to load billing summary. Please try again later.`})}):a?(0,J.jsxs)(J.Fragment,{children:[(0,J.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,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,J.jsx)(S,{icon:(0,J.jsx)(Pe,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`effective-balance`,children:mn(a.effective_balance)}),label:`Balance`,tone:e?`negative`:`default`}),(0,J.jsx)(S,{icon:(0,J.jsx)(N,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`settled-balance`,children:mn(a.settled_balance)}),label:`Settled Balance`,tone:t?`negative`:`default`}),(0,J.jsx)(S,{icon:(0,J.jsx)(it,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`pending-charges`,children:mn(a.pending_compute)}),label:a.is_degraded?`Pending Usage (estimated)`:`Pending Usage`,tone:a.is_degraded?`muted`:n?`negative`:`default`})]})})()}),a.is_degraded&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(_,{tone:`warning`,children:`Pending charges could not be calculated. The balance shown may be incomplete.`})})]}):(0,J.jsx)(`p`,{className:`mt-4 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No billing information available.`}),(0,J.jsx)(`div`,{className:`mt-6 border-t border-[var(--border-base)] pt-6`,children:(0,J.jsx)(fn,{})})]}),(0,J.jsx)(Xe,{open:o,onOpenChange:s})]})}var gn=1e3,_n=15e3,vn=3e3,yn=45e3,bn=`billing-portal-return`;function xn(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?At(t.cancel_at):`the end of your billing period`}.`}:n&&!r?{kind:`success`,message:`Pro plan reactivated.`}:{kind:`info`,message:`Subscription updated.`}}function Sn(){let[e]=s(),t=o(),n=l(),r=(0,q.useRef)(null);return(0,q.useEffect)(()=>()=>{r.current!==null&&(clearInterval(r.current),r.current=null)},[]),(0,q.useEffect)(()=>{if(e.get(`portal_return`)!==`true`)return;let i={current:!1},a=Dt(),o=K(),s=Ae(),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<_n&&(await new Promise(e=>setTimeout(e,gn)),!i.current);)e=await l();return e}return(async()=>{try{let e=await u();if(i.current)return;let{kind:t,message:n}=xn(a,e);t===`success`?w.success(n,{id:bn}):w.info(n,{id:bn})}catch{if(i.current)return;w.info(`Subscription updated.`,{id:bn})}finally{if(!i.current){Ot(),t(U.settings.billing,{replace:!0});let e=Date.now();r.current!==null&&clearInterval(r.current),r.current=setInterval(()=>{if(Date.now()-e>=yn){r.current!==null&&(clearInterval(r.current),r.current=null);return}l().catch(e=>{console.error(`billing poll error:`,e)})},vn)}}})(),()=>{i.current=!0}},[e,t,n]),null}var Cn=[7,30,90].map(e=>({value:`${e}`,label:`Last ${e} days`}));function wn(e,t=ae()){let{fromDate:n,toDate:r}=nt(e,t);return{from:n,to:r}}function Tn(e,t){let n=new Date(e),r=new Date(t);return Math.round((r.getTime()-n.getTime())/864e5)+1}function En({from:e,to:t}){let n=Tn(e,t);return n===7?7:n===90?90:30}function Dn({value:e,onChange:t}){let n=fe(),r=(0,q.useMemo)(()=>`${En(e)}`,[e]);return(0,J.jsx)(h,{options:Cn,value:r,onChange:e=>{let r=Number(e);t(wn(r,n),r)},"aria-label":`Date range`})}var On={strokeDasharray:`3 3`,stroke:`var(--border-subtle)`,strokeOpacity:.4},kn={fontSize:12,fill:`var(--content-tertiary)`},An={stroke:`var(--border-subtle)`,strokeOpacity:.4},jn=[`#3b82f6`,`#10b981`,`#f59e0b`,`#ef4444`,`#8b5cf6`,`#06b6d4`,`#ec4899`,`#84cc16`];function Mn({item:e}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5 text-[13px] text-[var(--content-default)]`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,J.jsx)(`span`,{children:e.label}),(0,J.jsx)(`span`,{className:`ml-auto tabular-nums`,children:e.value})]})}function Nn({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,J.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,J.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-[var(--content-secondary)]`,children:(c??tt)(String(r))}),u&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Mn,{item:u}),d.length>0&&(0,J.jsx)(`div`,{className:`my-1.5 border-t border-[var(--border-subtle)]`})]}),d.map(e=>(0,J.jsx)(Mn,{item:e},e.key)),s&&(0,J.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,J.jsxs)(`span`,{children:[`Total: `,o(f)]})})]})}function Pn(e,t){let[n,r]=e,[i,a]=t,o=r-n||1;return e=>i+(e-n)/o*(a-i)}function Fn(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 In(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 Ln(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:Fn(n/r)*r}function Rn(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 zn(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 Bn(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 Vn=40,Hn={fontSize:11,fill:`var(--content-tertiary)`},Un={runtime_proxy_api:`#3b82f6`,oauth_proxy:`#f59e0b`};function Wn(e,t){return Un[e]??jn[t%jn.length]??`#6b7280`}function Gn(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 Kn({stackKeys:e,labelMap:t}){return(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rounded-sm`,style:{backgroundColor:Wn(e,n)}}),(0,J.jsx)(`span`,{className:`text-[var(--content-quiet)]`,children:t[e]??e})]},e))})}var qn=350,Jn={top:8,right:4,bottom:32,left:0},Yn=.2,Xn=5,Zn=12,Qn=200;function $n({buckets:e,metric:t,onBarClick:n}){let r=ie(),i=(0,q.useRef)(null),[a,o]=(0,q.useState)(0);(0,q.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,q.useMemo)(()=>Gn(e,t),[e,t]),u=(0,q.useMemo)(()=>{let e={};for(let t=0;t<c.length;t++)e[c[t]]=Wn(c[t],t);return e},[c]),d=(0,q.useCallback)(e=>t===`spend`?`$${e.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`:e.toLocaleString(`en-US`),[t]),[f,p]=(0,q.useState)(null),m=r?Vn:56,h=r?Hn:kn,g=Jn.left+m,_=Math.max(0,a-g-Jn.right),v=Jn.top,y=qn-Jn.top-Jn.bottom,b=(0,q.useMemo)(()=>s.map(e=>c.reduce((t,n)=>t+(Number(e[n])||0),0)),[s,c]),x=t===`events`,S=(0,q.useMemo)(()=>Ln(b,{integerOnly:x,tickCount:Xn}),[b,x]),C=(0,q.useMemo)(()=>Rn(S,Xn),[S]),w=(0,q.useCallback)(e=>{if(t===`spend`){if(e===0)return`$0`;let t=S/Xn,n=Math.max(t<1?2:0,In(t));return`$${e.toLocaleString(`en-US`,{minimumFractionDigits:n,maximumFractionDigits:n})}`}return e.toLocaleString(`en-US`)},[t,S]),T=(0,q.useMemo)(()=>Pn([0,S],[v+y,v]),[S,v,y]),E=s.length,D=E>0?_/E:0,O=D*(1-Yn),k=(D-O)/2,A=(0,q.useMemo)(()=>Bn(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:Wn(t,i),isLast:u}})}}),N=(e,t,n)=>{let r=i.current?.getBoundingClientRect();r&&p({x:e.clientX-r.left,y:e.clientY-r.top,datumIndex:t,hoveredKey:n})},P=()=>p(null),F=e=>{n&&n(e)},I=f?c.filter(e=>(Number(s[f.datumIndex]?.[e])||0)>0).map(e=>({dataKey:e,value:Number(s[f.datumIndex]?.[e])||0})):[],L={left:f?Math.max(0,Math.min(f.x+Zn,a-Qn)):0,top:f?f.y-Zn:0,visibility:f?`visible`:`hidden`};return(0,J.jsxs)(`div`,{onMouseDown:e=>e.preventDefault(),children:[(0,J.jsx)(`div`,{ref:i,className:`relative w-full`,style:{height:qn},children:j?(0,J.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,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`svg`,{width:a,height:qn,className:`block`,children:[C.map(e=>(0,J.jsx)(`line`,{x1:g,x2:g+_,y1:T(e),y2:T(e),stroke:On.stroke,strokeOpacity:On.strokeOpacity,strokeDasharray:On.strokeDasharray},e)),(0,J.jsx)(`line`,{x1:g,x2:g+_,y1:v+y,y2:v+y,stroke:An.stroke,strokeOpacity:An.strokeOpacity}),C.map(e=>(0,J.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,J.jsx)(`text`,{x:g+e*D+D/2,y:v+y+20,textAnchor:`middle`,fontSize:h.fontSize,fill:h.fill,children:tt(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=>N(n,e,t.key),onMouseLeave:P,onClick:()=>F(t.key)};return t.isLast?(0,J.jsx)(`path`,{...i,d:zn(t.x,t.y,O,t.h,3)}):(0,J.jsx)(`rect`,{...i,x:t.x,y:t.y,width:O,height:t.h})}))]}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute z-[1] max-w-[calc(100vw-32px)] -translate-y-full`,style:L,children:(0,J.jsx)(Nn,{active:!!f,payload:I,hoveredKey:f?.hoveredKey??void 0,label:f?String(s[f.datumIndex]?.date):``,labelMap:l,colorMap:u,formatValue:d})})]}):null}),!j&&(0,J.jsx)(Kn,{stackKeys:c,labelMap:l})]})}function er(e=ae()){return wn(30,e)}function tr(e){if(e)return e.usageSource===`oauth_proxy`?`oauth_provider`:Qe(e.llmDimension??`model`)}function nr(e,t=ae()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource,group_by:tr(e.drilldown)}:{}}}function rr(e,t=ae()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource}:{}}}function ir(e){let t=fe(),n=u(G({query:nr(e,t)})),r=u(Ke({query:rr(e,t)}));return{series:n.data,totals:r.data,isLoading:n.isLoading||r.isLoading,isError:n.isError||r.isError}}var ar=[{value:`spend`,label:`Spend ($)`},{value:`events`,label:`Events`}];function or(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 sr(e){return e===void 0?`—`:e.toLocaleString(`en-US`)}function cr(){let e=fe(),[t,n]=(0,q.useState)(30),[r,i]=(0,q.useState)(()=>er(e)),a=(0,q.useMemo)(()=>t===null?r:wn(t,e),[t,r,e]),o=(e,t)=>{n(t),i(e)},[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(`spend`),{series:d,totals:f,isLoading:h,isError:g}=ir({dateRange:a,setDateRange:e=>{n(null),i(e)},drilldown:s,setDrilldown:c}),_=s?void 0:e=>{let t={runtime_proxy_api:`runtime_proxy`,oauth_proxy:`oauth_proxy`}[e];t&&c({usageSource:t,...t===`runtime_proxy`?{llmDimension:et}:{}})};return(0,J.jsx)(m,{padding:`md`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Usage`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`Overview of your spending habits.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 [&_[role=combobox]]:h-8 [&_[role=radio]]:h-7`,children:[(0,J.jsx)(Dn,{value:a,onChange:o}),(0,J.jsx)(`div`,{className:`w-44`,children:(0,J.jsx)(x,{items:ar,value:l,onChange:u,ariaLabel:`Chart metric`})})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[(0,J.jsx)(S,{icon:(0,J.jsx)(Pe,{className:`h-4 w-4`,"aria-hidden":!0}),value:h?(0,J.jsx)(L,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):or(f?.total_usd),label:`Spend`}),(0,J.jsx)(S,{icon:(0,J.jsx)(ot,{className:`h-4 w-4`,"aria-hidden":!0}),value:h?(0,J.jsx)(L,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):sr(f?.event_count),label:`Events`})]}),s&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsx)(`div`,{children:(0,J.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,J.jsx)(E,{className:`h-3.5 w-3.5`}),(0,J.jsx)(`span`,{children:`Back to all usage`}),(0,J.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:`/`}),(0,J.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,J.jsx)(`div`,{className:`w-56`,children:(0,J.jsx)(x,{items:$e,value:s.llmDimension??`model`,onChange:e=>c({usageSource:`runtime_proxy`,llmDimension:e}),ariaLabel:`LLM spend dimension`})})]}),h?(0,J.jsx)(`div`,{className:`flex h-[345px] items-center justify-center rounded-xl bg-[var(--surface-base)]`,children:(0,J.jsx)(L,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}):g?(0,J.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,J.jsx)(`div`,{className:`rounded-xl bg-[var(--surface-base)] p-3`,children:(0,J.jsx)($n,{buckets:d.buckets,metric:l,onBarClick:_})}):null]})})}function lr(){let{data:e}=u(K()),t=Mt((0,q.useMemo)(()=>kt(e),[e]));if(!e||e.plan_id!==`pro`||e.status===`canceled`||!e.cancel_at_period_end&&!e.cancel_at)return null;let n=jt(e);return n?(0,J.jsx)(_,{tone:`info`,title:`Your Pro plan will end on ${At(n)}.`,actions:(0,J.jsx)(i,{variant:`outlined`,size:`compact`,onClick:()=>t.mutate({}),disabled:t.isPending,leftIcon:t.isPending?(0,J.jsx)(L,{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 ur=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),dr=t(((e,t)=>{var n=ur();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=dr()()}))(),1);function fr(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 pr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?fr(Object(n),!0).forEach(function(t){hr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function mr(e){"@babel/helpers - typeof";return mr=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},mr(e)}function hr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gr(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 _r(e,t){if(e==null)return{};var n=gr(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 vr(e,t){return yr(e)||br(e,t)||xr(e,t)||Cr()}function yr(e){if(Array.isArray(e))return e}function br(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 xr(e,t){if(e){if(typeof e==`string`)return Sr(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 Sr(e,t)}}function Sr(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 Cr(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
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=q.useRef(n);q.useEffect(function(){i.current=n},[n]),q.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])},wr=function(e){var t=q.useRef(e);return q.useEffect(function(){t.current=e},[e]),t.current},Tr=function(e){return e!==null&&mr(e)===`object`},Er=function(e){return Tr(e)&&typeof e.then==`function`},Dr=function(e){return Tr(e)&&typeof e.elements==`function`&&typeof e.createToken==`function`&&typeof e.createPaymentMethod==`function`&&typeof e.confirmCardPayment==`function`},Or=`[object Object]`,kr=function e(t,n){if(!Tr(t)||!Tr(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var i=Object.prototype.toString.call(t)===Or;if(i!==(Object.prototype.toString.call(n)===Or))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])})},Ar=function(e,t,n){return Tr(e)?Object.keys(e).reduce(function(r,i){var a=!Tr(t)||!kr(e[i],t[i]);return n.includes(i)?(a&&console.warn(`Unsupported prop change: options.${i} is not a mutable property.`),r):a?pr(pr({},r||{}),{},hr({},i,e[i])):r},null):null},jr="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.",Mr=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:jr;if(e===null||Dr(e))return e;throw Error(t)},Nr=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:jr;if(Er(e))return{tag:`async`,stripePromise:Promise.resolve(e).then(function(e){return Mr(e,t)})};var n=Mr(e,t);return n===null?{tag:`empty`}:{tag:`sync`,stripe:n}},Pr=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`}))},Fr=q.createContext(null);Fr.displayName=`ElementsContext`;var Ir=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},Lr=function(e){var t=e.stripe,n=e.options,r=e.children,i=q.useMemo(function(){return Nr(t)},[t]),a=vr(q.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];q.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=wr(t);q.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=wr(n);return q.useEffect(function(){if(o.elements){var e=Ar(n,l,[`clientSecret`,`fonts`]);e&&o.elements.update(e)}},[n,l,o.elements]),q.useEffect(function(){Pr(o.stripe)},[o.stripe]),q.createElement(Fr.Provider,{value:o},r)};Lr.propTypes={stripe:X.default.any,options:X.default.object};var Rr=function(e){return Ir(q.useContext(Fr),e)},zr=function(e){var t=e.children;return t(Rr(`mounts <ElementsConsumer>`))};zr.propTypes={children:X.default.func.isRequired};var Br=q.createContext(null);Br.displayName=`CheckoutContext`;var Vr=function(e){var t=q.useContext(Br),n=q.useContext(Fr);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 Ir(n,e)},Hr=[`mode`],Ur=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},Q=function(e,t,n){var r=`${Ur(e)}Element`,i=t?function(e){Vr(`mounts <${r}>`);var t=e.id,n=e.className;return q.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=Vr(`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=vr(q.useState(null),2),O=D[0],k=D[1],A=q.useRef(null),j=q.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),q.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=_r(o,Hr);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 N=wr(o);return q.useEffect(function(){if(A.current){var e=Ar(o,N,[`paymentRequest`]);e&&`update`in A.current&&A.current.update(e)}},[o,N]),q.useLayoutEffect(function(){return function(){if(A.current&&typeof A.current.destroy==`function`)try{A.current.destroy(),A.current=null}catch{}}},[]),q.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`,Wr=q.createContext(null);Wr.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 Gr=`dahlia`,Kr=`https://js.stripe.com`,qr=`${Kr}/${Gr}/stripe.js`,Jr=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Yr=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,Xr=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,Zr=function(e){return Jr.test(e)||Yr.test(e)},Qr=function(){for(var e=document.querySelectorAll(`script[src^="${Kr}"]`),t=0;t<e.length;t++){var n=e[t];if(Zr(n.src))return n}return null},$r=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${qr}${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},ei=null,ti=null,ni=null,ri=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},ii=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},ai=function(e){return ei===null?(ei=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(Xr),window.Stripe){t(window.Stripe);return}try{var r=Qr();if(r&&e)console.warn(Xr);else if(!r)r=$r(e);else if(r&&ni!==null&&ti!==null){var i;r.removeEventListener(`load`,ni),r.removeEventListener(`error`,ti),(i=r.parentNode)==null||i.removeChild(r),r=$r(e)}ni=ii(t,n),ti=ri(n),r.addEventListener(`load`,ni),r.addEventListener(`error`,ti)}catch(e){n(e);return}}),ei.catch(function(e){return ei=null,Promise.reject(e)})):ei},oi,si=!1,ci=function(){return oi||(oi=ai(null).catch(function(e){return oi=null,Promise.reject(e)}),oi)};Promise.resolve().then(function(){return ci()}).catch(function(e){si||console.warn(e)});function li(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)?{theme:`night`}:{theme:`stripe`}}function ui({open:e,onClose:t,onSavedOptimistic:n}){let r=d(Re()),{mutate:i,reset:a}=r;return(0,q.useEffect)(()=>{e||a()},[e,i,a]),(0,q.useMemo)(()=>li(),[r.data?.client_secret??null]),(0,J.jsx)(C.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,J.jsxs)(C.Content,{size:`sm`,children:[(0,J.jsx)(C.Header,{children:(0,J.jsx)(C.Title,{children:`Save Payment Method`})}),(0,J.jsx)(C.Body,{className:`min-h-[260px]`,children:(0,J.jsx)(di,{})})]})})}function di(){return(0,q.useEffect)(()=>{console.warn(`[AutoTopUpPaymentMethodModal] VITE_STRIPE_PUBLISHABLE_KEY is not set; the payment-method modal cannot mount Stripe Elements.`)},[]),(0,J.jsx)(_,{tone:`error`,children:`Payment method setup is currently unavailable. Please try again later.`})}function fi(){return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Payment Method`}),(0,J.jsx)(p,{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 pi(){let e=l(),t=u(De()),[n,r]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1),s=d(se()),c=async()=>{let t=Date.now(),n=e=>e?.stripe_payment_method_updated_at??null,r=n(e.getQueryData(Ve()));try{await e.invalidateQueries({queryKey:Ve()})}catch{}for(;Date.now()-t<2e4;){try{let t=await e.fetchQuery(De());if(t.has_payment_method&&n(t)!==r)return}catch{}await new Promise(e=>setTimeout(e,1500))}};if(t.isLoading)return(0,J.jsxs)(m,{padding:`md`,children:[(0,J.jsx)(fi,{}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(L,{className:`h-4 w-4 animate-spin`}),`Loading…`]})]});if(t.isError||!t.data)return(0,J.jsxs)(m,{padding:`md`,children:[(0,J.jsx)(fi,{}),(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(_,{tone:`error`,children:`Failed to load payment method.`})})]});let f=t.data,h=Qt(f.payment_method_brand??`card`),v=f.payment_method_last4;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(m,{padding:`md`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsx)(fi,{}),f.has_payment_method?(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] px-2 py-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,J.jsx)(A,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(p,{variant:`body-medium-default`,as:`span`,children:h}),v?(0,J.jsxs)(p,{variant:`body-small-default`,as:`div`,className:`text-[var(--content-tertiary)]`,children:[`Ending in `,v]}):null]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,J.jsx)(i,{variant:`ghost`,onClick:()=>r(!0),children:`Change`}),(0,J.jsx)(i,{variant:`ghost`,onClick:()=>o(!0),disabled:a||s.isPending,leftIcon:(0,J.jsx)(me,{className:`h-3.5 w-3.5`}),children:`Remove`})]})]}):(0,J.jsx)(i,{className:`self-start`,onClick:()=>r(!0),children:`Add Card`})]})}),(0,J.jsx)(g,{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:()=>{Fe(e,void 0,e=>e?{...e,enabled:!1,has_payment_method:!1,payment_method_brand:null,payment_method_last4:null}:ln),o(!1)},onError:()=>{w.error(`Failed to remove payment method. Please try again.`),o(!1)}})},onCancel:()=>{s.isPending||o(!1)}}),(0,J.jsx)(ui,{open:n,onClose:()=>r(!1),onSavedOptimistic:c})]})}var mi={invoices:[]};function hi(e){switch(e){case`paid`:return`positive`;case`open`:return`warning`;case`uncollectible`:return`negative`;default:return`neutral`}}function gi(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 _i(e){return Ze(new Date(e*1e3),{alwaysShowYear:!0})}function vi(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 yi({open:e,onOpenChange:t}){let[r,o]=(0,q.useState)(!1),s=u({queryKey:we(),enabled:e,queryFn:async({signal:e})=>{let{data:t,response:n}=await re({throwOnError:!1,signal:e});if(n?.status===404)return mi;if(!n?.ok||!t)throw Error(`Failed to load invoices (${n?.status??`network error`})`);return t}}),c=s.data?.invoices??[],l=c.some(e=>e.invoice_pdf!=null);async function d(){o(!0);try{let{data:e,response:t}=await H({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-BUireD7W.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`}),w.error(`Failed to download invoices.`)}finally{o(!1)}}return(0,J.jsx)(C.Root,{open:e,onOpenChange:t,children:(0,J.jsxs)(C.Content,{size:`lg`,children:[(0,J.jsxs)(C.Header,{children:[(0,J.jsx)(C.Title,{icon:he,children:`Invoices`}),(0,J.jsx)(C.Description,{children:`Your billing history. Open an invoice for full details or download it as a PDF.`})]}),(0,J.jsx)(C.Body,{children:s.isLoading?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(L,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-small-default`,children:`Loading invoices...`})]}):s.isError?(0,J.jsx)(_,{tone:`error`,children:`Failed to load invoices.`}):c.length===0?(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`py-6 text-center text-[var(--content-tertiary)]`,"data-testid":`invoices-empty`,children:`No Invoices Found`}):(0,J.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:c.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center gap-3 py-3`,"data-testid":`invoice-row`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(p,{variant:`body-medium-default`,as:`span`,className:`text-[var(--content-default)]`,children:e.number??`Invoice`}),e.status&&(0,J.jsx)(v,{tone:hi(e.status),children:e.status})]}),(0,J.jsxs)(p,{variant:`body-small-default`,as:`div`,className:`text-[var(--content-tertiary)]`,children:[_i(e.created),` ·`,` `,gi(e.amount_due,e.currency)]})]}),e.hosted_invoice_url&&(0,J.jsx)(i,{asChild:!0,variant:`ghost`,size:`compact`,leftIcon:(0,J.jsx)(P,{}),children:(0,J.jsx)(`a`,{href:e.hosted_invoice_url,target:`_blank`,rel:`noopener noreferrer`,children:`View`})}),e.invoice_pdf&&(0,J.jsx)(i,{variant:`ghost`,size:`compact`,iconOnly:(0,J.jsx)(oe,{}),"aria-label":`Download invoice PDF`,onClick:()=>vi(e.invoice_pdf)})]},e.id))})}),(0,J.jsxs)(C.Footer,{children:[l&&(0,J.jsx)(i,{variant:`outlined`,leftIcon:r?(0,J.jsx)(L,{className:`animate-spin`}):(0,J.jsx)(oe,{}),disabled:r,onClick:d,children:`Download all`}),(0,J.jsx)(C.Close,{asChild:!0,children:(0,J.jsx)(i,{variant:`primary`,children:`Done`})})]})]})})}var bi={pro:{icon:j,actionLabel:`Manage`,actionVariant:`outlined`,actionTestId:`plan-card-manage-button`,showsRenewal:!0},base:{icon:st,actionLabel:`Upgrade to Pro`,actionVariant:`primary`,actionTestId:`plan-card-upgrade-button`,showsRenewal:!1}},xi=bi.base;function Si(){return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Plan`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`Manage which Vellum plan you're on.`})]})}function Ci({onManage:e}){let[t,n]=(0,q.useState)(!1),r=u(K()),a=u(Ie());if(r.isLoading||a.isLoading)return(0,J.jsxs)(m,{padding:`md`,children:[(0,J.jsx)(Si,{}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(L,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{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,J.jsx)(_,{tone:`error`,children:`Failed to load plan.`});let l=bi[c.id]??xi,d=l.icon,f=c.name??c.id,h=l.showsRenewal&&(o.cancel_at_period_end===!0||!!o.cancel_at),g=o.status===`canceled`,v=jt(o),y=l.showsRenewal&&!h&&!g&&o.current_period_end,b=l.showsRenewal&&h&&!g&&v,x=c.id===`pro`?c:void 0,S=o.selected_credit_tier??null,C=S==null?void 0:x?.credit_tiers,w=C?.find(e=>e.tier===S),T=w?`${w.label} (${Y(w.price_cents)})`:C?.length?S:null;return(0,J.jsxs)(m,{padding:`lg`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,J.jsx)(Si,{}),(0,J.jsx)(i,{variant:`outlined`,leftIcon:(0,J.jsx)(he,{}),onClick:()=>n(!0),"data-testid":`plan-card-invoices-button`,children:`Invoices`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,J.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,J.jsx)(d,{className:`h-4 w-4 text-[var(--content-default)]`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,J.jsx)(p,{variant:`body-medium-default`,as:`div`,"data-testid":`plan-card-name`,children:f}),(0,J.jsx)(p,{variant:`body-small-default`,as:`div`,className:`leading-snug text-[var(--content-tertiary)]`,children:(0,J.jsx)(Jt,{features:c.included_features,variant:`inline`})})]}),(0,J.jsx)(i,{variant:l.actionVariant,onClick:e,"data-testid":l.actionTestId,children:l.actionLabel})]}),T&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`plan-card-credit-bundle`,children:[`Monthly credits: `,T]}),y&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`plan-card-renews`,children:[`Renews on `,At(o.current_period_end),`.`]}),b&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--system-mid-strong)]`,"data-testid":`plan-card-cancels`,children:[`Your plan ends on `,At(v),`.`]})]}),(0,J.jsx)(yi,{open:t,onOpenChange:n})]})}var wi=`settings-referral-panel`;function Ti(e){return e.replace(/\.00$/,``)}function Ei(){let{data:e,isLoading:t,isError:n}=u(Me()),[r,a]=(0,q.useState)(!1),o=(0,q.useCallback)(e=>{navigator.clipboard.writeText(e).then(()=>{a(!0),w.success(`Copied to clipboard!`),setTimeout(()=>a(!1),2e3)})},[]),s=e?`Share Vellum with friends - you'll each earn ${Ti(e.referrer_credit_amount)} credits when they sign up, up to ${Ti(e.earning_cap)} total.`:`Share Vellum with friends and earn credits for every signup.`;return(0,J.jsx)(m,{padding:`md`,id:wi,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Earn Free Credits`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:s})]}),t?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(L,{className:`h-4 w-4 animate-spin`}),`Loading...`]}):n||!e?(0,J.jsx)(_,{tone:`error`,children:`Failed to load referral information.`}):(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.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,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,J.jsx)(Pe,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`span`,{className:`flex items-baseline gap-1 text-body-medium-default`,children:[(0,J.jsx)(`span`,{children:Ti(e.total_earned)}),(0,J.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Credits Earned`})]})]}),(0,J.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,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,J.jsx)(Ce,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`span`,{className:`flex items-baseline gap-1 text-body-medium-default`,children:[(0,J.jsx)(`span`,{children:e.referred_count}),(0,J.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Friends Referred`})]})]}),(0,J.jsx)(i,{variant:`outlined`,onClick:()=>o(e.referral_url),leftIcon:r?(0,J.jsx)(Ue,{className:`h-3.5 w-3.5`}):(0,J.jsx)(Be,{className:`h-3.5 w-3.5`}),"data-testid":`referral-copy-button`,children:r?`Copied!`:`Copy Share Link`})]})]})})}function Di({icon:e,label:t,from:n,to:r}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,J.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,J.jsx)(e,{className:`h-4 w-4 text-[var(--system-positive-strong)]`})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:t}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)] line-through`,children:n}),(0,J.jsx)(ue,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`}),(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:r})]})]})]})}function Oi({open:e,onClose:t}){let n=u({...Je(),enabled:e}),r=u({...Oe(),enabled:e}),a=n.data,o=a?.machine_size||`small`,s=a?.provisioned_storage_gib??null,c=r.data?.max_machine_tier??null,l=r.data?.selected_storage_gib??null,d=ee(c),f=d.length>0?d[d.length-1]:o,p=f!==o,m=l!=null&&(s==null||s<l),h=p||m,[g,v]=(0,q.useState)(null),y=_e({onSuccess:()=>{w.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),v(null),t()},onError:e=>{v(B(e,`Failed to resize assistant. Please try again.`))}}),b=y.isPending,x=n.isLoading||r.isLoading;return(0,J.jsx)(C.Root,{open:e,onOpenChange:e=>{e||(v(null),t())},children:(0,J.jsxs)(C.Content,{size:`sm`,children:[(0,J.jsxs)(C.Header,{children:[(0,J.jsx)(C.Title,{icon:te,children:`Plan Updated`}),(0,J.jsx)(C.Description,{children:`Your new resources are ready. Apply them now to resize your assistant — it will briefly restart.`})]}),(0,J.jsxs)(C.Body,{children:[x?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,J.jsx)(L,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):h?(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[p&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Di,{icon:k,label:`Machine`,from:z[o],to:z[f]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-lg bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:`CPU`}),(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:R[f].split(`,`)[0].trim()})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-lg bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:`Memory`}),(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:R[f].split(`,`)[1].trim()})]})]})]}),m&&(0,J.jsx)(Di,{icon:F,label:`Storage`,from:s==null?`—`:`${s} GiB`,to:`${l} GiB`})]}):(0,J.jsx)(_,{tone:`neutral`,children:`Your assistant is already running at the maximum size for your plan.`}),g&&(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(_,{tone:`error`,children:g})})]}),(0,J.jsxs)(C.Footer,{children:[(0,J.jsx)(i,{variant:`ghost`,onClick:()=>{v(null),t()},children:`Do Later`}),(0,J.jsx)(i,{disabled:x||!h||b||!a?.id,leftIcon:b?(0,J.jsx)(L,{className:`animate-spin`}):void 0,onClick:()=>{if(!a?.id)return;v(null);let e={};p&&(e.machine_size=f),m&&l!=null&&(e.storage_gib=l),y.mutate({path:{id:a.id},body:e})},children:g?`Retry`:`Apply & Restart`})]})]})})}function ki(){let[e]=s(),t=o(),n=l();return(0,q.useEffect)(()=>{let r=e.get(`billing_status`);r&&(r===`success`?(w.success(`Payment received! Your credit balance will update shortly.`,{id:`billing-status`}),n.invalidateQueries({queryKey:W().queryKey})):r===`cancel`&&w.info(`Checkout was cancelled. No credits were added.`,{id:`billing-status`}),t(U.settings.billing,{replace:!0}))},[e,t,n]),null}function Ai(){let e=Se({platformHostedOnly:!0}),t=Se(),n=Ye(),r=le(),[i,a]=s(),[o,l]=(0,q.useState)(!1),u=(0,q.useCallback)(()=>l(!0),[]),d=(0,q.useCallback)(()=>l(!1),[]),[f,p]=(0,q.useState)(!1),m=(0,q.useCallback)(()=>p(!0),[]);(0,q.useEffect)(()=>{i.has(`adjust_plan`)&&(l(!0),a(e=>{let t=new URLSearchParams(e);return t.delete(`adjust_plan`),t},{replace:!0}))},[i,a]);let h=i.has(`session_id`),g=(0,q.useCallback)(()=>{a(e=>{let t=new URLSearchParams(e);return t.delete(`session_id`),t},{replace:!0})},[a]);if(t===`gated`)return(0,J.jsx)(c,{replace:!0,to:U.settings.general});if(t===`disabled`)return(0,J.jsx)(`div`,{className:`space-y-4`,children:(0,J.jsx)(ye,{children:`Log in to the Vellum platform to manage billing and usage.`})});if(r)return(0,J.jsx)(`div`,{className:`space-y-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,J.jsx)(L,{className:`h-4 w-4 animate-spin`}),`Loading billing…`]})});let v=n;return!n&&e!==`gated`?(0,J.jsx)(`div`,{className:`space-y-4`,children:(0,J.jsx)(_,{tone:`warning`,children:`Billing isn't available for the current assistant state.`})}):(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(q.Suspense,{fallback:null,children:[(0,J.jsx)(ki,{}),(0,J.jsx)(Sn,{})]}),v&&(0,J.jsx)(lr,{}),v&&(0,J.jsx)(Ci,{onManage:u}),v&&(0,J.jsx)(Xt,{open:o,onClose:d,onTierUpgraded:m}),(0,J.jsx)(pi,{}),(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(hn,{})}),(0,J.jsx)(Ei,{}),(0,J.jsx)(cr,{}),v&&(0,J.jsx)(wt,{open:h,onClose:g}),v&&(0,J.jsx)(Oi,{open:f,onClose:()=>p(!1)})]})}export{Ai as BillingPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./button-D7s2Q_uG.js";import{d as t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./card-BibIM9x3.js";import{t as i}from"./bookmark-CKGO6oO8.js";import{t as a}from"./loader-circle-CQd2jpMq.js";import{t as o}from"./triangle-alert-JYuV8dTb.js";import{t as s}from"./x-DBBHPJnd.js";import{a as c}from"./routes-DZiaa4kh.js";import{A as l,
|
|
1
|
+
import{t as e}from"./button-D7s2Q_uG.js";import{d as t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./card-BibIM9x3.js";import{t as i}from"./bookmark-CKGO6oO8.js";import{t as a}from"./loader-circle-CQd2jpMq.js";import{t as o}from"./triangle-alert-JYuV8dTb.js";import{t as s}from"./x-DBBHPJnd.js";import{a as c}from"./routes-DZiaa4kh.js";import{A as l,k as u,ua as d}from"./index-DdZDYyvJ.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(),_=u();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)(d,{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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{O as n,t as r}from"./button-D7s2Q_uG.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-BscuIPxA.js";import"./src-DPHBRruq.js";import{t as o}from"./panel-item-BFOUNXY1.js";import{t as s}from"./loader-circle-CQd2jpMq.js";import{t as c}from"./x-DBBHPJnd.js";import{n as l}from"./use-is-mobile-DsYMm_nj.js";import{
|
|
1
|
+
import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{O as n,t as r}from"./button-D7s2Q_uG.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-BscuIPxA.js";import"./src-DPHBRruq.js";import{t as o}from"./panel-item-BFOUNXY1.js";import{t as s}from"./loader-circle-CQd2jpMq.js";import{t as c}from"./x-DBBHPJnd.js";import{n as l}from"./use-is-mobile-DsYMm_nj.js";import{sa as u}from"./index-DdZDYyvJ.js";var d=e(t(),1),f=e(n(),1),p=i();function m({icon:e,title:t,subtitle:n,shortcutHint:r,isSelected:i,onClick:a,surface:s=`overlay`}){let c=e;return s===`window`?(0,p.jsxs)(`button`,{type:`button`,role:`option`,"aria-current":i?`page`:void 0,"aria-selected":i,onClick:a,className:[`flex h-10 w-full items-center gap-3 rounded-md px-3 text-left text-sm font-medium outline-none transition-colors`,i?`bg-[var(--surface-active)] text-[var(--content-default)]`:`text-[var(--content-secondary)] hover:bg-[var(--surface-overlay)] hover:text-[var(--content-default)]`].join(` `),children:[c?(0,p.jsx)(c,{size:16,"aria-hidden":!0,className:i?`shrink-0 text-[var(--content-default)]`:`shrink-0 text-[var(--content-tertiary)]`}):null,(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:t}),n?(0,p.jsx)(`span`,{className:`shrink-0 truncate text-xs text-[var(--content-tertiary)]`,children:n}):null,r?(0,p.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-[var(--content-tertiary)]`,children:r}):null]})]}):(0,p.jsx)(o,{icon:e,label:(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:t}),n?(0,p.jsx)(`span`,{className:`shrink-0 truncate text-[var(--content-tertiary)] text-body-small-default`,children:n}):null,r?(0,p.jsx)(`span`,{className:`ml-auto shrink-0 text-[var(--content-tertiary)] text-body-small-default`,children:r}):null]}),active:i,onSelect:a,className:`px-3 py-2`})}var h=({isOpen:e,onClose:t,query:n,onQueryChange:i,selectedIndex:o,sections:h,isSearching:g=!1,onItemSelect:_,onKeyDown:v,surface:y=`overlay`})=>{let b=l(),x=(0,d.useRef)(null),S=(0,d.useRef)(null),C=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(e){let e=requestAnimationFrame(()=>{S.current?.focus()});return()=>cancelAnimationFrame(e)}},[e]),(0,d.useEffect)(()=>{if(!e||!C.current)return;let t=C.current.querySelector(`[aria-current='page']`);t&&t.scrollIntoView({block:`nearest`})},[e,o]);let w=(0,d.useCallback)(e=>{e.target===x.current&&t()},[t]);if(!e)return null;let T=0,E=y===`window`,D=b&&!E,O=(0,p.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--border-base)] px-4 py-3`,children:[g?(0,p.jsx)(s,{size:16,"aria-hidden":!0,className:`shrink-0 animate-spin text-[var(--content-tertiary)]`}):(0,p.jsx)(u,{size:16,"aria-hidden":!0,className:`shrink-0 text-[var(--content-tertiary)]`}),(0,p.jsx)(`input`,{ref:S,type:`text`,value:n,onChange:e=>i(e.target.value),placeholder:`Search conversations, memories…`,className:E?`min-w-0 flex-1 bg-transparent text-sm font-medium text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`:`min-w-0 flex-1 bg-transparent text-body-medium-lighter text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`,"aria-label":`Search`}),n?D?(0,p.jsx)(`button`,{type:`button`,className:`shrink-0 text-body-medium-lighter text-[var(--content-tertiary)]`,onClick:()=>i(``),"aria-label":`Clear search`,children:`Clear`}):E?(0,p.jsx)(`button`,{type:`button`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-overlay)] hover:text-[var(--content-default)]`,"aria-label":`Clear search`,onClick:()=>i(``),children:(0,p.jsx)(c,{size:16,"aria-hidden":!0})}):(0,p.jsx)(r,{variant:`ghost`,size:`compact`,iconOnly:(0,p.jsx)(c,{}),"aria-label":`Clear search`,onClick:()=>i(``),tintColor:`var(--content-tertiary)`}):D?null:(0,p.jsx)(`kbd`,{className:E?`shrink-0 rounded-md border border-[var(--border-base)] bg-[var(--surface-active)] px-1.5 py-0.5 text-xs font-medium text-[var(--content-secondary)]`:`shrink-0 rounded-md border border-[var(--border-base)] bg-[var(--surface-active)] px-1.5 py-0.5 text-label-small-default text-[var(--content-tertiary)]`,children:`⌘K`}),D?(0,p.jsx)(r,{variant:`ghost`,size:`compact`,iconOnly:(0,p.jsx)(c,{}),expandOnMobile:!1,"aria-label":`Close search`,onClick:t,tintColor:`var(--content-tertiary)`}):null]}),k=(0,p.jsx)(`div`,{ref:C,className:D?`flex-1 overflow-y-auto overscroll-contain p-2`:`max-h-[360px] overflow-y-auto overscroll-contain p-2`,role:`listbox`,children:h.length===0?(0,p.jsx)(`div`,{className:`px-3 py-6 text-center`,children:(0,p.jsx)(a,{variant:`body-medium-lighter`,className:`text-[var(--content-tertiary)]`,children:g?`Searching…`:`No results`})}):h.map(e=>(0,p.jsxs)(`div`,{role:`group`,"aria-label":e.label,children:[(0,p.jsx)(a,{variant:`label-small-default`,as:`div`,className:E?`px-3 pb-1 pt-2 text-xs font-semibold text-[var(--content-tertiary)]`:`px-3 pb-1 pt-2 text-[var(--content-tertiary)]`,children:e.label}),e.items.map(e=>{let t=T++;return(0,p.jsx)(m,{icon:e.icon,title:e.title,subtitle:e.subtitle,shortcutHint:D?void 0:e.shortcutHint,isSelected:t===o,onClick:()=>_?.(e,t),surface:y},e.id)})]},e.id))});if(D)return(0,p.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-[var(--surface-lift)]`,role:`dialog`,"aria-modal":`true`,"aria-label":`Search`,onKeyDown:v,style:{paddingTop:`var(--safe-area-inset-top, env(safe-area-inset-top, 0px))`,paddingBottom:`var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))`,paddingLeft:`var(--safe-area-inset-left, env(safe-area-inset-left, 0px))`,paddingRight:`var(--safe-area-inset-right, env(safe-area-inset-right, 0px))`},children:[O,k]});let A=(0,p.jsx)(`div`,{ref:x,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:y===`window`?`flex h-full w-full items-start justify-center bg-transparent p-3`:`fixed inset-0 z-50 flex items-start justify-center bg-black/40 pt-[15vh]`,onClick:w,onKeyDown:v,children:(0,p.jsxs)(`div`,{className:`flex w-full max-w-[560px] flex-col overflow-hidden rounded-xl border border-[var(--border-base)] bg-[var(--surface-base)] shadow-xl`,children:[O,k]})});return y===`window`?A:(0,f.createPortal)(A,document.body)};export{h as CommandPalette};
|