1import{j as e,a as s}from"./vendor-core.DkahmlU8.js";import{B as r,R as E,F as ge,h as He,d as oe,I as wt,b as fe,bl as jt,a as On,dY as xt,c as ve,aH as V,b6 as q,b7 as X,b8 as ee,K as gt,n as U,ae as ht,bZ as Ln,aZ as Zt,c0 as Qt,c1 as Jt,Q as Ut,o as te,bf as Ct,eu as ft,ev as gn,bY as Ye,bb as Oe,bi as zt,P as g,ba as nt,bh as Pt,C as kn,aG as Cn,a_ as Nt,au as Un,bj as Bn,ew as Gn,g as Fn,bH as Mn,aA as Wn,X as yn,av as bn,aX as qt,aV as $n,bX as Vn,ex as zn,ey as Hn,as as en,z as vn,aF as Yn,u as Kn,A as Xn,q as Zn,y as Qn,ez as Jn,b9 as tn,d0 as qn,aN as er,S as Tn,k as tr,a0 as nr,W as rr}from"./bootstrap.KUFis_Od.js";import{ad as ar,ae as sr,aW as Rn,aX as _n,aY as or,aZ as ir,a_ as lr,a$ as nn,b0 as cr,b1 as dr,b2 as rt,b3 as ur,f as pr,_ as mr,G as Mt,b4 as rn,b5 as Yt,b6 as xr,m as an,b7 as It,b8 as Kt,b9 as At,ba as En,bb as hr,bc as fr,bd as gr,be as Cr,bf as yr,bg as br,bh as vr,bi as Tr,bj as Rr,bk as _r,bl as Er,bm as Sr,bn as wr,bo as jr,bp as Dr,bq as Pr,br as Nr,aj as Ir,ak as Ar,al as Or,$ as Lr,bs as kr,bt as Ur,bu as Br,L as Gr}from"./App.C7HhiLEI.js";import{y as h,x as yt,a7 as Le,aJ as O,c as Bt,aN as Dt,aO as Sn,ac as wn,ae as Fr,a6 as sn,aX as Mr,aY as on}from"./vendor-mui-x.BZ8Y4adA.js";import{c as Wr}from"./contentTabs.7calTxRZ.js";import{I as $r}from"./InworldDataGrid.Do2SGnGK.js";import{A as Vr}from"./AccountZeroDataRetentionSection.D6_LTzMh.js";import{R as zr,a as ln}from"./RadioGroup.Bojetmf7.js";import"./vendor-firebase.dbYXL2Q0.js";import"./table.CshLM3h1.js";const Hr={display:"flex",alignItems:"flex-start",gap:1,py:.75,borderBottom:"1px dashed",borderColor:"divider","&:last-of-type":{borderBottom:"none"}},cn={display:"block",textAlign:"left",fontSize:ge.xs,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",px:2.5,py:.75},Yr={included:jt.faCheck,excluded:jt.faXmark,inherited:jt.faPlus},Kr=({title:t,subtitle:n,subtitleLearnMore:a,priceLine:o,originalPriceLine:l,rateRows:i,features:p,featuresIntro:R,discountBadge:x,badge:y,trackBadge:u,ctaText:b,ctaIntent:S,ctaDisabled:M,ctaDisabledTooltip:N,ctaLoading:j=!1,onCtaClick:z,ctaHref:D,ctaStartIcon:pe,dimmed:B=!1,className:ie})=>e.jsxs(r,{component:"div",className:["PlanCard",ie].filter(Boolean).join(" "),sx:{display:"flex",flexDirection:"column",flex:1,minHeight:0,height:"100%",width:"100%",...B&&{opacity:.45}},children:[e.jsxs(r,{component:"div",sx:{position:"relative"},children:[(u||y)&&e.jsxs(r,{component:"div",sx:{position:"absolute",bottom:"100%",left:0,right:0,zIndex:1,display:"flex",flexDirection:"column"},children:[u&&e.jsx(r,{component:"span",sx:{...cn,backgroundColor:"text.primary",color:"background.default",borderTopLeftRadius:E.md,borderTopRightRadius:E.md},children:u}),y&&e.jsx(r,{component:"span",sx:{...cn,backgroundColor:"primary.main",color:"primary.contrastText",...!u&&{borderTopLeftRadius:E.md,borderTopRightRadius:E.md}},children:y})]}),e.jsx(ar,{elevation:0,sx:f=>({display:"flex",flexDirection:"column",position:"relative",borderRadius:u||y?`0 0 ${E.md} ${E.md}`:E.md,boxShadow:"none",transition:"all 300ms ease",border:`1px solid ${f.palette.divider}`,backgroundColor:f.palette.background.surface.main,overflow:"hidden"}),children:e.jsxs(sr,{sx:{p:2.5,"&:last-child":{pb:2.5},display:"flex",flexDirection:"column",flex:1,position:"relative",zIndex:1},children:[e.jsx(h,{variant:"display2",component:"h5",sx:{fontWeight:500,color:"text.primary"},children:t}),e.jsxs(h,{variant:"caption",component:"div",sx:{color:"text.secondary",lineHeight:1.4,mt:.25,whiteSpace:a?"normal":"nowrap"},children:[n,a&&e.jsxs(e.Fragment,{children:[" ",e.jsx(He,{href:a.href,target:"_blank",rel:"noopener noreferrer","aria-label":a.label,className:"PlanCard-subtitleLearnMore",onClick:f=>f.stopPropagation(),sx:{color:"inherit",fontSize:"inherit",fontWeight:600,textDecoration:"underline",textUnderlineOffset:"2px","&:hover":{opacity:.85}},children:a.label})]})]}),e.jsxs(r,{component:"div",sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap",mt:1,minHeight:"1.5rem"},children:[l&&e.jsx(h,{variant:"body2",component:"span",sx:{textDecoration:"line-through",color:"text.disabled"},children:l}),o&&e.jsx(h,{variant:"body2",component:"span",sx:{color:"text.secondary"},children:o}),x&&e.jsx(h,{variant:"badge",component:"span",sx:f=>
1({pl:1,borderLeft:"2px solid",borderColor:yt(f.palette.primary.main,.4),color:"text.accent",whiteSpace:"nowrap"}),children:x})]}),i.length>0&&e.jsx(r,{component:"div",sx:{mt:1.5,pt:1.5,borderTop:"1px solid",borderColor:"divider"},children:i.map((f,G)=>{var L;return e.jsxs(r,{component:"div",sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:1,py:.25},children:[e.jsx(h,{variant:"caption",component:"span",sx:{color:"text.primary",flex:"1 1 auto",minWidth:0,whiteSpace:"normal",pr:.5},children:f.label}),e.jsx(Le,{title:(L=f.tooltip)!=null?L:"",placement:"top",arrow:!0,enterTouchDelay:0,children:e.jsxs(r,{component:"span",sx:{flexShrink:0,display:"flex",alignItems:"baseline",gap:1},children:[f.originalValue&&e.jsx(h,{variant:"caption",component:"span",sx:{textDecoration:"line-through",color:"text.disabled"},children:f.originalValue}),f.valueHref?e.jsx(He,{href:f.valueHref,target:"_blank",rel:"noopener noreferrer","aria-label":`${f.label}: ${f.value} (opens in new tab)`,sx:{fontSize:ge.sm,color:"text.secondary"},children:f.value}):e.jsx(h,{variant:"caption",component:"span",sx:{color:"text.secondary"},children:f.value})]})})]},`${f.label}-${G}`)})}),i.length===0&&e.jsx(r,{component:"div",sx:{flex:1}}),e.jsxs(r,{component:"div",sx:{mt:"auto",pt:2,position:"relative"},children:[j&&e.jsx(r,{component:"span",role:"status","aria-live":"polite",sx:{position:"absolute",width:1,height:1,p:0,m:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:"Loading checkout"}),e.jsx(Le,{title:N!=null?N:"",placement:"top",arrow:!0,children:e.jsx(r,{component:"span",sx:{display:"block"},children:e.jsx(oe,{"aria-label":b,intent:S,onClick:z,disabled:M,loading:j,startIcon:pe,fullWidth:!0,...D&&{href:D,target:"_blank",rel:"noopener noreferrer"},sx:f=>({textTransform:"uppercase",fontWeight:700,fontSize:ge.sm,letterSpacing:"0.06em",py:1,...S==="secondary"&&{borderColor:f.palette.divider,color:f.palette.text.primary,"&:hover":{borderColor:f.palette.text.accent,backgroundColor:f.palette.success.light}},"&.Mui-disabled":{backgroundColor:f.palette.background.surface.light,color:f.palette.text.disabled,borderColor:"transparent"}}),children:b})})})]})]})})]}),e.jsxs(r,{component:"div",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",pt:2},children:[R&&e.jsx(h,{variant:"body2",sx:{fontWeight:600,mb:.5,color:"text.primary"},children:R}),e.jsx(r,{component:"ul",sx:{m:0,p:0,listStyle:"none"},children:p.map((f,G)=>{var w;const L=(w=f.kind)!=null?w:"included",I=L!=="included";return e.jsxs(r,{component:"li",sx:{...Hr,fontSize:ge.sm,color:I?"text.disabled":"text.secondary",...f.bold&&{fontWeight:700}},children:[e.jsx(r,{component:"span",sx:{display:"inline-flex",flexShrink:0,marginTop:"0.3em",color:I?"text.disabled":"text.accent",[On]:wt.xs},children:e.jsx(fe,{icon:Yr[L]})}),f.text]},G)})})]})]}),Wt=({text:t,isWarning:n=!0})=>{const a=n?"error":"success";return e.jsx(r,{component:"div",sx:{width:"100%",backgroundColor:o=>o.palette[a].light,padding:"1rem",borderRadius:E.lg,mb:"1.5rem",border:o=>`1px solid ${yt(o.palette[a].main,.4)}`,overflow:"hidden"},children:e.jsx(h,{sx:{width:"100%",textAlign:"center",color:o=>o.palette[a].dark,overflowWrap:"break-word",wordBreak:"break-word"},children:t})})},Xr=220,jn="Free credits are provided by Inworld for evaluation and are not refundable or redeemable for cash. They are consumed by eligible usage and may expire or be limited by plan and model access.",Zr="These credits were voided due to a refund or other account-related adjustments. If you believe this is an error, please contact support.",Qr="Credits have a limited validity period. These credits expired on their scheduled date or may have been ended early based on account eligibility.",Jr=Array.from({length:5},(t,n)=>({id:`skeleton-${n}`,effectiveDate:new Date,category:"",amount:0,expiresAt:null,transaction:""})),qr=({row:t})=>{if(t.transaction===or.CREDIT_VOIDED)return e.jsx(Le,{title:Zr,arrow:!0,placement:"top",children:e.jsx(r,{component:"span",tabIndex:0,sx:{color:"error.main"},children:"Voided"})});const n=t.category===_n.PROMOTIONAL,a=p=>n?e.jsx(Le,{title:jn,arrow:!0,placement:"top",children:p}):p;if(!t.expiresAt)return a(e.jsx(r,{component:"span",tabIndex:0,sx:{color:"text.secondary"},children:"Active"}));const o=new Date(t.expiresAt),l=o<new Date,i=new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric"}
1).format(o);return l?e.jsx(Le,{title:Qr,arrow:!0,placement:"top",children:e.jsxs(r,{component:"span",tabIndex:0,sx:{color:"error.main"},children:["Expired on ",i]})}):a(e.jsxs(r,{component:"span",tabIndex:0,sx:{color:"text.secondary"},children:["Expires on ",i]}))},ea=({row:t})=>{const n=Rn(t);return t.category!==_n.PROMOTIONAL?n:e.jsxs(r,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.5},children:[n,e.jsx(Le,{title:jn,arrow:!0,placement:"top",children:e.jsx(r,{component:"span",tabIndex:0,"aria-label":"Free credits information",sx:{display:"inline-flex",cursor:"help"},children:e.jsx(fe,{icon:ve.faInfoCircle,style:{fontSize:ge.sm},color:"text.secondary"})})})]})},ta=({transactions:t=[],isLoading:n,action:a})=>{const o=s.useMemo(()=>[{field:"effectiveDate",headerName:"Effective Date",flex:2,minWidth:120,renderCell:l=>{if(n)return e.jsx(O,{width:"60%"});const p={year:"numeric",month:"short",day:"numeric",...l.colDef.computedWidth>=Xr&&{hour:"2-digit",minute:"2-digit",second:"2-digit"}};return new Intl.DateTimeFormat(void 0,p).format(l.value)}},{field:"category",headerName:"Type",flex:1.5,minWidth:120,valueGetter:(l,i)=>n?"":Rn(i),renderCell:l=>n?e.jsx(O,{width:"50%"}):e.jsx(ea,{row:l.row})},{field:"amount",headerName:"Amount",flex:2,minWidth:100,renderCell:l=>{if(n)return e.jsx(O,{width:"4rem"});const i=xt({value:l.value/100,maxNumDigits:2});return e.jsx(r,{component:"span",sx:{color:"text.primary",fontWeight:500},children:i})}},{field:"expiresAt",headerName:"Status",flex:2.5,minWidth:180,renderCell:l=>n?e.jsx(O,{width:"70%"}):e.jsx(qr,{row:l.row})}],[n]);return e.jsxs(r,{component:"div",sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(r,{component:"div",sx:{display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(h,{variant:"body1",sx:{fontWeight:600},children:"Credit transactions"}),a]}),e.jsx($r,{autoHeight:!0,variant:"data",tableDensity:"compact",hideFooter:n||t.length<=20,initialState:{sorting:{sortModel:[{field:"effectiveDate",sort:"desc"}]}},rows:n?Jr:t,columns:o,getRowId:l=>l.id,emptyTitle:"No transactions yet"},n?"loading":t.length===0?"empty":"data")]})},Dn=({billingAccountId:t,checkoutSource:n,sourceTier:a,onLoadingChange:o})=>{const l=ir(),i=s.useRef(!1);return s.useEffect(()=>{o==null||o(l.isLoading)},[o,l.isLoading]),s.useEffect(()=>()=>o==null?void 0:o(!1),[o]),{startCheckout:s.useCallback(async(R,x)=>{if(!t){V("Billing account is not loaded yet.");return}if(i.current)return;i.current=!0;const y=lr({actionLabel:x!=null?x:"your Inworld plan change"});try{const u=await l.mutateAsync({billingAccountId:t,pricingTier:R});if(u!=null&&u.error){y==null||y.close(),V(nn(u.error),{duration:1e4});return}const b=cr(u);if(b){q(X.BILLING_PLAN_CHANGE_CHECKOUT_REDIRECTED,ee.Billing,{targetTier:R,checkout_source:n!=null?n:"billing-page",...a!=null?{sourceTier:a}:{}}),dr(y,b);return}y==null||y.close(),V("No checkout link was returned. Please try again or contact support.",{duration:1e4})}catch(u){y==null||y.close(),V(nn(u),{duration:1e4})}finally{i.current=!1}},[t,n,l,a]),isLoading:l.isLoading,pendingTier:l.isLoading&&l.variables?l.variables.pricingTier:void 0}},na={tts2:rt.TTS_2,tts2Flash:rt.TTS_2_FLASH,stt:rt.STT},ra={originalTts2:rt.TTS_2,originalTts2Flash:rt.TTS_2_FLASH,originalStt:rt.STT},aa=t=>({"on-demand":"onDemand",creator:"creator",builder:"builder",developer:"developer",growth:"growth"})[t.toLowerCase()],sa=(t,n)=>t.map(a=>{let o=a;for(const[l,i]of Object.entries(na)){const p=n[l];typeof p=="string"&&a.label===i&&(o={...o,value:p})}for(const[l,i]of Object.entries(ra)){const p=n[l];typeof p=="string"&&a.label===i&&(o={...o,originalValue:p})}return o}),oa=t=>{if(t)try{const n=JSON.parse(t);return typeof n!="object"||n===null?void 0:n}catch(n){return}},ia=(t,n,a)=>!n&&!a?t:t.map(o=>{const l=aa(o.title);if(!l)return o;const i=n==null?void 0:n[l],p=a==null?void 0:a[l];return!i&&p===void 0?o:{...o,...i?{rateRows:sa(o.rateRows,i)}:{},...typeof p=="string"?{discountBadge:p}:{}}}),Pn=s.createContext(void 0),la=({children:t})=>{var o;const n=gt(U.STUDIO_V2_PRICING_RATE_OVERRIDES),a=s.useMemo(()=>{var l;return oa((l=n.payload)==null?void 0:l.value)},[(o=n.payload)==null?void 0:o.value]);return e.jsx(Pn.Provider,{value:a,children:t})},ca=()=>s.useContext(Pn),Nn=(t,n)=>{const a=ca();return s.useMemo(()=>
1{if(!a)return t;const o=n==="founder"?a.founder:a.standard;return ia(t,o,a.discountBadges)},[t,a,n])},da=({open:t,onClose:n,onUpdate:a,onPurchase:o,currentSettings:l,currentBalance:i,hasPaymentMethod:p,isPurchaseLoading:R=!1,isUpdating:x=!1})=>{const y=s.useId(),[u,b]=s.useState("");s.useEffect(()=>{t&&b("")},[t]);const S=Bt(),{minThreshold:M,maxThreshold:N,maxReloadAmount:j,reloadOffset:z}=ur(),D=R||x,{control:pe,watch:B,handleSubmit:ie,reset:f,trigger:G,formState:{isValid:L}}=pr({defaultValues:{enabled:!0,threshold:l.threshold?l.threshold.toString():"5",reloadAmount:l.reloadAmount?l.reloadAmount.toString():"15"},mode:"onChange"}),I=B("enabled"),w=B("threshold"),W=B("reloadAmount"),Z=s.useMemo(()=>parseInt(w)||0,[w]),ne=s.useMemo(()=>Math.max(Z+z,M+z),[Z,z,M]),Q=s.useMemo(()=>I&&L&&Z>0&&i<=Z,[I,L,Z,i]),re=s.useRef(!1);s.useEffect(()=>{t&&!re.current&&f({enabled:!0,threshold:l.threshold?l.threshold.toString():"5",reloadAmount:l.reloadAmount?l.reloadAmount.toString():"15"}),re.current=t},[t,f,l]),s.useEffect(()=>{G(["threshold","reloadAmount"])},[Z,I,G]);const _=s.useMemo(()=>Q&&!p,[Q,p]),H=s.useMemo(()=>{const C=parseInt(W)||0;return Math.max(C-i,0)},[W,i]),le=async C=>{if(D)return;b("");const v={enabled:C.enabled,threshold:parseInt(C.threshold)||0,reloadAmount:parseInt(C.reloadAmount)||0};if(!v.enabled&&!p&&!l.enabled){n();return}const J=Q&&H>0,_e={enabled:v.enabled,threshold:v.threshold,reloadAmount:v.reloadAmount,currentBalance:i};if(J&&o){const Ae={enabled:v.enabled,threshold:{currency:"USD",value:Math.floor(v.threshold*100).toString()},reloadAmount:{currency:"USD",value:Math.floor(v.reloadAmount*100).toString()}};o(H,Ae)}else{q(X.AUTO_RELOAD_SETTINGS_SAVED,ee.Billing,_e);try{await a(v)}catch(Ae){b("Could not save auto-reload settings. Your entries are kept; please try again.")}}};return e.jsxs(ht,{controlled:!0,open:t,onClose:D?Ln:n,dismissible:!D,title:"Auto-reload settings",size:"md",customActions:e.jsxs(r,{component:"div",sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},alignItems:{xs:"stretch",sm:"center"},width:"100%",gap:1,p:"0.25rem"},children:[I&&p&&e.jsx(h,{variant:"caption",sx:{color:"text.secondary",flex:1,minWidth:0},children:"The card you have on file will be charged on a recurring basis when your balance reaches the amount indicated. To cancel, turn off auto-reload."}),e.jsxs(r,{component:"div",sx:{display:"flex",flexShrink:0,gap:1,width:{xs:"100%",sm:"auto"},justifyContent:{xs:"stretch",sm:"flex-end"},ml:{sm:"auto"}},children:[e.jsx(oe,{intent:"secondary","aria-label":"Cancel",onClick:n,disabled:D,disableFocusRipple:!0,sx:{display:{xs:"none",sm:"inline-flex"},minHeight:"unset",height:"2.5rem",borderRadius:E.md,borderColor:C=>C.palette.divider,whiteSpace:"nowrap"},children:"Cancel"}),e.jsx(oe,{"aria-label":"Save auto-reload settings",onClick:ie(le),disabled:!L||D,disableFocusRipple:!0,loading:D,sx:{flex:{xs:1,sm:"unset"},minHeight:"unset",height:"2.5rem",borderRadius:E.md,whiteSpace:"nowrap"},children:Q?"Update and purchase":"Save"})]})]}),children:[u&&e.jsx(mr,{severity:"error",sx:{mb:2},children:u}),e.jsx(Mt,{name:"enabled",control:pe,render:({field:C})=>e.jsxs(r,{component:"div",sx:{mt:.5,mb:3},children:[e.jsx(Dt,{control:e.jsx(Sn,{checked:C.value,onChange:v=>{C.onChange(v.target.checked),q(X.AUTO_RELOAD_TOGGLED,ee.Billing,{enabled:v.target.checked})},size:"small",sx:{color:S.palette.text.secondary,"&.Mui-checked":{color:S.palette.primary.main}}}),label:e.jsx(h,{variant:"body1",sx:{fontWeight:600},children:"Auto-reload credits"}),sx:{mx:0,ml:-1}}),e.jsx(h,{variant:"caption",sx:{color:"text.secondary",display:"block"},children:"Avoid service disruptions by auto-reloading credits when your balance reaches a specified minimum"})]})}),e.jsxs(r,{component:"div",sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:2},children:[e.jsx(Zt,{htmlFor:`${y}-threshold`,label:"When credit balance reaches:",labelSize:"large",sx:{"& .MuiFormLabel-root":{color:"text.primary"}},children:e.jsx(Mt,{name:"threshold",control:pe,rules:{validate:C=>{if(!I)return!0;if(!C)return`Enter an amount above $${M}`;const v=parseInt(C,10);return isNaN(v)||v<M?`Enter an amount above $${M}`:v>
1N?`Enter an amount below $${N.toLocaleString()}`:!0}},render:({field:C,fieldState:v})=>{var J;return e.jsx(e.Fragment,{children:e.jsx(rn,{id:`${y}-${C.name}`,inputRef:C.ref,onBlur:C.onBlur,value:C.value,onChange:_e=>C.onChange(Jt(_e)),onKeyDown:Qt,placeholder:"",error:!!v.error,disabled:!I,helperText:(J=v.error)==null?void 0:J.message})})}})}),e.jsx(Zt,{label:"Bring credit balance back up to:",htmlFor:`${y}-reloadAmount`,labelSize:"large",sx:{"& .MuiFormLabel-root":{color:"text.primary"}},children:e.jsx(Mt,{name:"reloadAmount",control:pe,rules:{validate:C=>{if(!I)return!0;if(!C)return`Min: $${ne.toLocaleString()}. Amount must be at least $10 more than minimum balance`;const v=parseInt(C,10);return isNaN(v)||v<ne?`Min: $${ne.toLocaleString()}. Amount must be at least $10 more than minimum balance`:v>j?`Amount cannot exceed $${j.toLocaleString()}`:!0}},render:({field:C,fieldState:v})=>{var J;return e.jsx(e.Fragment,{children:e.jsx(rn,{id:`${y}-${C.name}`,inputRef:C.ref,onBlur:C.onBlur,value:C.value,onChange:_e=>C.onChange(Jt(_e)),onKeyDown:Qt,placeholder:"",error:!!v.error,disabled:!I,helperText:(J=v.error)==null?void 0:J.message})})}})}),Q&&e.jsxs(r,{component:"div",sx:{gridColumn:"1 / -1",display:"flex",gap:1.5,p:2,borderRadius:E.md,backgroundColor:S.palette.background.surface.main,border:`1px solid ${S.palette.divider}`},children:[e.jsx(fe,{icon:ve.faInfoCircle,style:{flexShrink:0,fontSize:ge.base,marginTop:"2px"},color:S.palette.text.secondary}),e.jsxs(r,{component:"div",children:[e.jsx(h,{variant:"body2",sx:{fontWeight:600,mb:.25},children:_?"Payment required":`Amount to reach target balance: ${xt({value:H})}`}),e.jsx(h,{variant:"body2",sx:{color:"text.secondary"},children:_?`Your credit balance is below the recharge threshold. You'll be redirected to checkout to purchase $${H.toLocaleString()} in credits.`:"You will be directed to checkout and save auto-reload settings."})]})]})]})]})},ua=(t,n)=>t&&n,pa=({isRedesignEnabled:t,isOnDemandPlan:n,isMobile:a,isAutoReloadActive:o})=>({showAddCreditsSection:!t||!n||a,showInlineAutoReloadAction:!t||o&&!n,showCreditBalanceAutoReloadAction:t&&n&&o}),ma="N/A",dn=(t,n,a)=>t?ma:n===void 0?"":a(n),xa=t=>"Pre-purchased credits are not applicable to your account. Billing is managed per your Enterprise agreement.",Ht="Other",ha=["Don't have enough usage","TTS not high enough quality","Can't find a good voice","Missing / poor language support","Missing features I need","Too expensive",Ht],un={flex:{xs:1,md:"unset"},minHeight:"unset",height:"2.5rem",borderRadius:E.md,borderColor:t=>t.palette.divider,color:"text.primary",whiteSpace:"nowrap"},fa=({open:t,onClose:n,initialCancelConfirmOpen:a=!1,isEnterprise:o=!1,isAdminAssigned:l=!1,pricingTier:i,onUpgrade:p,currentBalance:R,billingAccountId:x,hasPaymentMethod:y=!1,cancellationStatus:u,periodEndDate:b,nextBillingDate:S})=>{var Qe,Me,Ue;const M=Bt(),N=wn(M.breakpoints.down("sm")),{firebaseUserIdentity:j}=Ut(),z=j==null?void 0:j.creationTime,D=Yt(),pe=te(U.STUDIO_V2_SUBSCRIPTION_CANCEL),B=te(U.STUDIO_V2_SUBSCRIPTION_DOWNGRADE),ie=te(U.STUDIO_V2_SHOW_BUILDER_PLANS),[f,G]=s.useState(!1),[L,I]=s.useState(!1),[w,W]=s.useState(new Set),[Z,ne]=s.useState(""),[Q,re]=s.useState(!1),[_,H]=s.useState(void 0),le=s.useMemo(()=>xr(i,Ct(z,D,i)),[i,z,D]),C=m=>{W(Y=>{const ce=new Set(Y);return ce.has(m)?ce.delete(m):ce.add(m),ce})},v=s.useCallback(()=>{W(new Set),ne("")},[]);s.useEffect(()=>{if(!t){G(!1),W(new Set),ne(""),re(!1),H(void 0);return}G(a)},[t,a]);const J=u===ft.CANCELLATION_STATUS_PENDING_AT_PERIOD_END,_e=m=>m instanceof Error?m.message:typeof m=="string"&&m?m:"",{mutate:Ae,isLoading:Ce}=gn(x!=null?x:void 0,{onError:m=>{const Y=_e(m);q(X.BILLING_CANCELLATION_RPC_FAILED,ee.Billing,{...i!=null?{currentTier:i}:{},message:Y||String(m)}),V(`Unable to update subscription: ${Y||"Please try again."}`)}}),ae=s.useCallback(()=>{Ce||(v(),re(!1),H(void 0),G(!1),a&&n())},[a,Ce,n,v]);an({open:t,onClose:n}),an({open:t&&f,onClose:ae});const me=()=>{if(!x)return;const m=Array.from(w);q(X.BILLING_CONFIRMED_CANCEL_PLAN,ee.Billing,{...i!=null?{currentTier:i}:{},cancellationReasons:m,...w.has(Ht)&&Z.trim()?{otherReason:Z.trim()}:{}}),Ae({targetStatus:ft.CANCELLATION_STATUS_PENDING_AT_PERIOD_END,targetTier:_},{onSuccess:()=>{const Y=b?` on ${b}`:" at the end of the current billing period";Nt(_!==void 0?`Your plan will switch to ${Ye(_)}${Y}.`:b?`Your subscription will end on ${b}. You can resume anytime before then.`:"Your subscription will end at the end of the current billing period."),v(),re
1(!1),H(void 0),G(!1),n()}})},ke=()=>{x&&(q(X.BILLING_CLICKED_RESUME_SUBSCRIPTION,ee.Billing,i!=null?{currentTier:i}:{}),Ae({targetStatus:ft.CANCELLATION_STATUS_NONE},{onSuccess:()=>{Nt("Subscription resumed."),n()}}))},Ee=async()=>{if(x){I(!0);try{const m=await Cn(x);m?window.open(m,"_blank","noopener,noreferrer"):V("Unable to open billing portal. Please try again.")}catch(m){V("Unable to open billing portal. Please try again.")}I(!1)}},$=s.useMemo(()=>It(i,z,D),[i,z,D]),Se=Ye(i),P=Oe(i),Fe=zt(i),ye=s.useMemo(()=>{var c,K;if(o||l||!i)return null;if(i===g.PRICING_TIER_GROWTH||i===g.PRICING_TIER_FOUNDER_GROWTH)return{label:"Contact sales for Enterprise",href:nt.CONTACT_SALES};const m=Ct(z,D,i),Y=Kt(z,D,i).map(T=>At(T,ie)),ce=ie?Y:Y.filter(T=>!Pt(T.tier)),xe=En(i,m,ce);if(!xe)return null;if(xe===g.PRICING_TIER_ENTERPRISE)return{label:"Contact sales for Enterprise",href:nt.CONTACT_SALES};const A=It(xe,z,D),We=(K=((c=A==null?void 0:A.discountBadge)!=null?c:"").match(/(\d+%)/))==null?void 0:K[1];return{label:We?`Upgrade to ${A==null?void 0:A.title} for up to ${We} off`:`Upgrade to ${A==null?void 0:A.title}`,targetTier:xe}},[i,o,l,z,D,ie]),Ke=s.useRef(!1);s.useEffect(()=>{t&&!a&&!Ke.current&&q(X.BILLING_OPENED_MANAGE_SUBSCRIPTION,ee.Billing,i!=null?{currentTier:i}:{}),Ke.current=t},[a,t,i]);const at=o?[{label:"Current plan",value:Se},{label:"Credit balance",value:"Custom"},{label:"Next payment",value:"Custom"},{label:"Billing cadence",value:"Custom"}]:P||l?[{label:"Current plan",value:Se},{label:"Credit balance",value:R!=null?R:"â"}]:J?[{label:"Current plan",value:Se},{label:"Credit balance",value:R!=null?R:"â"},{label:"Cancels on",value:b||"End of current period"}]:[{label:"Current plan",value:Se},{label:"Credit balance",value:R!=null?R:"â"},{label:"Next payment",value:Fe?(Qe=hr(i))!=null?Qe:"â":(Ue=(Me=$==null?void 0:$.priceLine)==null?void 0:Me.replace("/mo",""))!=null?Ue:"â"},{label:"Next billing date",value:S!=null?S:"â"},{label:"Billing cadence",value:Fe?"Annual":"Monthly"}];return e.jsxs(e.Fragment,{children:[e.jsx(ht,{controlled:!0,open:t&&!f,onClose:n,title:"Manage Subscription",size:"xs",fullScreen:N,customActions:e.jsxs(r,{component:"div",className:"ManageSubscriptionDialog-actions",sx:{display:"flex",flexDirection:{xs:"column",md:"row"},flexWrap:"wrap",alignItems:{xs:"stretch",md:"center"},justifyContent:"space-between",width:"100%",boxSizing:"border-box",gap:1,py:.5,px:1},children:[!P&&!o&&!l&&pe&&J&&e.jsx(oe,{"aria-label":"Resume subscription",type:"button",disabled:Ce||!x,onClick:ke,disableFocusRipple:!0,sx:{width:"100%",minHeight:"unset",height:"2.5rem",borderRadius:E.md,textTransform:"none"},children:Ce?"Resumingâ¦":"Resume subscription"}),!P&&!o&&!l&&!J&&e.jsx(oe,{intent:"secondary","aria-label":"Cancel plan",type:"button",onClick:()=>{q(X.BILLING_CLICKED_CANCEL_PLAN,ee.Billing,i!=null?{currentTier:i}:{}),G(!0)},disableFocusRipple:!0,sx:un,children:"Cancel plan"}),ye&&!J&&e.jsx(oe,{"aria-label":ye.label,disableFocusRipple:!0,...ye.href?{href:ye.href,target:"_blank",component:"a",onClick:()=>{q(X.BILLING_CLICKED_CONTACT_SALES,ee.Billing,{source:"manageDialog",...i!=null?{sourceTier:i}:{}})}}:{onClick:()=>{q(X.BILLING_CLICKED_UPGRADE_CTA,ee.Billing,ye.targetTier!=null?{promotedTier:ye.targetTier}:{}),ye.targetTier&&p&&p(ye.targetTier),n()}},sx:{flex:1,minHeight:"unset",height:"2.5rem",borderRadius:E.md,whiteSpace:"nowrap",textTransform:"none"},children:ye.label})]}),children:e.jsxs(r,{component:"div",className:"ManageSubscriptionDialog",sx:{display:"flex",flexDirection:"column",gap:0},children:[e.jsxs(r,{component:"div",sx:{pb:0,mb:1.5},children:[e.jsx(h,{variant:"h4",sx:{fontWeight:600,color:"text.primary",mb:.5},children:Se}),!P&&!o&&($==null?void 0:$.priceLine)&&e.jsx(h,{variant:"body2",sx:{color:"text.secondary"},children:$.priceLine}),P&&e.jsx(h,{variant:"body2",sx:{color:"text.secondary"},children:"Top up credits as needed"})]}),e.jsx(r,{component:"div",sx:{display:"flex",flexDirection:"column",pb:1,mb:1.5},children:at.filter(m=>m.label!=="Current plan").map(m=>
1e.jsxs(r,{component:"div",sx:{display:"flex",justifyContent:"space-between",alignItems:"center",py:.75},children:[e.jsx(h,{variant:"body2",sx:{color:"text.secondary"},children:m.label}),e.jsx(h,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:m.value})]},m.label))}),y&&e.jsx(oe,{intent:"secondary","aria-label":"View invoices and manage billing",size:"small",disabled:L||!x,onClick:Ee,children:L?"Opening...":"View invoices & manage billing information"}),o&&e.jsxs(h,{variant:"caption",sx:{color:"text.secondary",mt:2},children:["Terms are custom per your enterprise agreement. For any questions, please contact your account manager or"," ",e.jsx(h,{component:"a",variant:"caption",href:"mailto:[email protected]","aria-label":"Email [email protected]",sx:{color:"primary.main",textDecoration:"none","&:hover":{textDecoration:"underline"}},children:"[email protected]"}),"."]})]})}),pe?e.jsx(ht,{controlled:!0,open:t&&f,onClose:ae,title:"Cancel subscription",size:"xs",fullScreen:N,customActions:e.jsxs(r,{component:"div",className:"ManageSubscriptionDialog-cancel-actions",sx:{display:"flex",flexDirection:{xs:"column-reverse",md:"row"},justifyContent:"flex-end",gap:1,width:"100%",py:.5,px:1},children:[e.jsx(oe,{intent:"secondary","aria-label":"Keep subscription",type:"button",disabled:Ce,onClick:ae,sx:un,children:"Keep subscription"}),e.jsx(oe,{"aria-label":_!==void 0?`Confirm switch to ${Ye(_)}`:"Confirm cancel subscription",type:"button",disabled:Ce||!x,onClick:me,sx:{flex:{xs:1,md:"unset"},minHeight:"unset",height:"2.5rem",borderRadius:E.md,whiteSpace:"nowrap",textTransform:"none"},children:Ce?_!==void 0?"Switchingâ¦":"Cancellingâ¦":_!==void 0?`Switch to ${Ye(_)}`:"Cancel subscription"})]}),children:e.jsxs(r,{component:"div",sx:{pt:.5,pb:1},children:[e.jsxs(h,{variant:"body2",sx:{color:"text.secondary",mb:2},children:["Your ",Se," plan will end",b?` on ${b}`:" at the end of the current billing period",". Until then you keep all paid-tier features and your remaining credits keep their original 3-month expiry. You can resume anytime before then."]}),B&&le.length>0&&e.jsxs(r,{component:"div",sx:{mb:2},children:[e.jsxs(r,{component:"button",type:"button","aria-expanded":Q,"aria-label":"Switch to a lower plan instead",onClick:()=>re(m=>!m),sx:{display:"flex",alignItems:"center",gap:.5,p:0,background:"none",border:"none",cursor:"pointer",color:"text.secondary"},children:[e.jsx(h,{variant:"body2",sx:{color:"text.secondary"},children:"Switch to a lower plan instead"}),e.jsx(fe,{icon:ve.faChevronDown,size:"xs",style:{transition:"transform 0.2s ease",transform:Q?"rotate(180deg)":"rotate(0deg)"},color:M.palette.text.secondary})]}),e.jsx(kn,{in:Q,children:e.jsxs(zr,{value:_!=null?_:"",onChange:m=>H(m.target.value?m.target.value:void 0),sx:{mt:1,pl:.5},children:[e.jsx(Dt,{value:"",control:e.jsx(ln,{size:"small"}),label:"Cancel to On-Demand",sx:{"& .MuiFormControlLabel-label":{fontSize:ge.md}}}),le.map(m=>e.jsx(Dt,{value:m,control:e.jsx(ln,{size:"small"}),label:`Downgrade to ${Ye(m)}`,sx:{"& .MuiFormControlLabel-label":{fontSize:ge.md}}},m))]})})]}),e.jsx(h,{variant:"body2",sx:{fontWeight:600,color:"text.primary",mb:1},children:"Why are you cancelling?"}),e.jsxs(r,{component:"div",sx:{display:"flex",flexDirection:"column",gap:0},children:[ha.map(m=>e.jsx(Dt,{control:e.jsx(Sn,{checked:w.has(m),onChange:()=>C(m),size:"small"}),label:m,sx:{"& .MuiFormControlLabel-label":{fontSize:ge.md}}},m)),w.has(Ht)&&e.jsx(r,{component:"div",sx:{pl:4,mt:1},children:e.jsx(Fr,{className:"inworld-text-field","aria-label":"Other cancellation reason",placeholder:"Please tell us more...",size:"small",fullWidth:!0,multiline:!0,minRows:2,maxRows:4,value:Z,onChange:m=>ne(m.target.value)})})]})]})}):e.jsx(ht,{controlled:!0,open:t&&f,onClose:ae,title:"Cancel subscription",size:"xs",fullScreen:N,children:e.jsxs(h,{variant:"body2",sx:{color:"text.secondary",pt:.5,pb:1},children:["To cancel your plan, please reach out to"," ",e.jsx(h,{component:"a",variant:"body2",href:"mailto:[email protected]",sx:{color:"primary.main",textDecoration:"none","&:hover":{textDecoration:"underline"}},children:"[email protected]"}),"."]})})]})},pn=({cycle:t,isActive:n,isDisabled:a=!1,disabledTooltip:o,onSelect:l})=>{const i=e.jsx(r,{component:"button",type:"button",role:"tab","aria-label":t==="yearly"?"Yearly billing":"Monthly billing","aria-selected":n,"aria-disabled":a||void 0,tabIndex:n?0:-1,onClick:()=>{a||l(t)},sx:p=>({display:"inline-flex",alignItems:"center",gap:.5,height:28,px:1.5,border:"none",borderRadius:E.full,fontFamily:Fn.functional,fontWeight:500,fontSize:ge.sm,lineHeight:1,whiteSpace:"nowrap",cursor:a?"not-allowed":"pointer",opacity:a?.5:1,transition:"background-color 150ms ease, color 150ms ease",backgroundColor:n?p.palette.text.primary:"transparent",color:n?p.palette.background.default:"text.secondary",...n?{}:!a&&{"&:hover":{color:"text.primary"}},"& .PlanCards-cycleToggle-discount":{marginLeft:"0.25rem",fontWeight:600,color:n?"inherit":p.palette.primary.main,transition:"color 150ms ease"}}),children:t==="yearly"?e.jsxs(e.Fragment,{children:["Yearly",e.jsx(r,{component:"span",className:"PlanCards-cycleToggle-discount",children:"· 2 months free"})]}):"Monthly"});return a&&o?e.jsx(Le,{title:o,placement:"top",arrow:!0,children:e.jsx(r,{component:"span",sx:{dis
1play:"inline-flex"},children:i})}):i},mn=(t,n)=>n!==void 0&&n!==g.PRICING_TIER_UNSPECIFIED&&t===n,$t=296,ga=t=>t.map(n=>({...n,tooltip:Pr(n.value)})),Ca=t=>t.map(n=>{const a=wr(n);return{text:a,kind:Dr(n)?"excluded":a.startsWith("Everything in ")?"inherited":"included",bold:jr(n)||a.includes("in credits per month")}}),ya=t=>t==="founder"?g.PRICING_TIER_FOUNDER_CREATOR:g.PRICING_TIER_CREATOR,xn=(t,n,a)=>{if(!n||n===g.PRICING_TIER_UNSPECIFIED)return!1;const o=a.indexOf(t),l=a.indexOf(n);return o<0||l<0?!1:o<l},hn=({pricingTier:t,billingAccountId:n,focusRequest:a,checkoutRequest:o,checkoutSource:l,onAddCredits:i,addCreditsDisabled:p=!1,onPlanChangeLoadingChange:R,fitToContent:x=!1})=>{var We;const{firebaseUserIdentity:y}=Ut(),u=y==null?void 0:y.creationTime,b=Yt(),{flagsReady:S}=Un(),M=te(U.STUDIO_ORG_MANAGEMENT),N=te(U.STUDIO_V2_SHOW_ANNUAL_PLANS),j=te(U.STUDIO_V2_SHOW_BUILDER_PLANS),z=te(U.STUDIO_V2_FOUNDER_DEVELOPER_PROMO),D=te(U.STUDIO_V2_UPGRADE_CREDIT_PROMO),pe=te(U.STUDIO_V2_BILLING_CREDITS_UI),B=gt(U.STUDIO_V2_UPGRADE_CREDIT_PROMO),ie=te(U.STUDIO_V2_GATE_AUDIO_DOWNLOAD),f=S&&M,G=S&&ie,L=S&&z,I=S&&D?((We=B.payload)==null?void 0:We.value)||"June only: 2x credits first month":void 0,w=Ct(u,b,t),W=Bn(t,w),Z=Kt(u,b,t),ne=Nn(Z,w),Q=j?ne:ne.f
1ilter(c=>!Pt(c.tier)),re=Q.length*280+(Q.length-1)*16,_=fr(w),H=gr(),le=zt(t),C=Gn(t),[v,J]=s.useState(!1),_e=N&&w!=="founder"&&t!==g.PRICING_TIER_ENTERPRISE,Ae=gt(U.STUDIO_V2_BILLING_DEFAULT_CADENCE_AB),Ce=Ae.enabled&&Ae.name==="annual",[ae,me]=s.useState(le||Ce?"yearly":"monthly");s.useEffect(()=>{Ce&&me("yearly")},[Ce]),s.useEffect(()=>{le&&ae!=="yearly"&&me("yearly")},[le,ae]);const ke=!t||t===g.PRICING_TIER_UNSPECIFIED||Oe(t),Ee=ke?ya(w):void 0,$=s.useRef(null),Se=s.useRef(null),P=s.useRef(new Map),Fe=s.useRef(!1),ye=s.useRef(null),[Ke,at]=s.useState(!1),[Qe,Me]=s.useState(!1),{startCheckout:Ue,isLoading:m,pendingTier:Y}=Dn({billingAccountId:n,checkoutSource:l,sourceTier:t,onLoadingChange:R}),ce=s.useCallback(c=>{if(w==="founder")switch(c){case g.PRICING_TIER_STARTER:return g.PRICING_TIER_STANDARD;case g.PRICING_TIER_CREATOR:return g.PRICING_TIER_FOUNDER_CREATOR;case g.PRICING_TIER_DEVELOPER:return g.PRICING_TIER_FOUNDER_DEVELOPER;case g.PRICING_TIER_GROWTH:return g.PRICING_TIER_FOUNDER_GROWTH;default:return c}return c===g.PRICING_TIER_STANDARD?g.PRICING_TIER_STARTER:c},[w]),xe=s.useCallback(()=>{const c=$.current;if(!c)return;const{scrollLeft:K,scrollWidth:T,clientWidth:de}=c,se=2;at(K>se),Me(K<T-de-se)},[]);s.useEffect(()=>{const c=$.current;if(c)return xe(),c.addEventListener("scroll",xe,{passive:!0}),window.addEventListener("resize",xe),()=>{c.removeEventListener("scroll",xe),window.removeEventListener("resize",xe)}},[xe,t]),s.useEffect(()=>{if(Fe.current||!$.current)return;Fe.current=!0;const c=$.current,T=c.clientWidth<$t*2&&Ee?P.current.get(ce(Ee)):void 0,de=T!=null?T:Se.current;de&&c.scrollTo({left:de.offsetLeft-c.offsetLeft,behavior:"smooth"})},[ke,Ee,t,ce]),s.useEffect(()=>{if(!(a!=null&&a.tier)||!$.current)return;const c=setTimeout(()=>{const K=P.current.get(ce(a.tier));if(!K||!$.current)return;const T=$.current;T.scrollIntoView({behavior:"smooth",block:"center"}),requestAnimationFrame(()=>{T.scrollTo({left:K.offsetLeft-T.offsetLeft,behavior:"smooth"})})},350);return()=>clearTimeout(c)},[a,ce]),s.useEffect(()=>{if(!(o!=null&&o.tier)||ye.current===o.ts||t===void 0)return;ye.current=o.ts;const c=ce(o.tier);if(t===g.PRICING_TIER_ENTERPRISE){V("Enterprise plans cannot be changed via this link. Please contact sales.",{duration:1e4});return}if(C){V(C,{duration:1e4});return}if(_.indexOf(c)<0){V("This plan is not available for self-serve purchase. Please contact sales.",{duration:1e4});return}if(!j&&Pt(c)){V("This plan is not available for self-serve purchase. Please contact sales.",{duration:1e4});return}if(mn(c,t)){V("You are already on this plan.");return}if(xn(c,t,_)){V("Cannot switch to a lower plan via this link. Please manage your subscription from the billing page.",{duration:1e4});return}Ue(c)},[_,o,Ue,C,t,ce,j]);const A=s.useCallback(c=>{var K;(K=$.current)==null||K.scrollBy({left:c==="left"?-$t:$t,behavior:"smooth"})},[]),Je={flexShrink:0,color:"text.secondary",border:"1px solid",borderColor:"divider","&.Mui-disabled":{opacity:.35}};return e.jsxs(r,{component:"div",className:"PlanCards",sx:{display:"flex",flexDirection:"column",gap:1,width:"100%",minWidth:0,maxWidth:x?`${re}px`:void 0,mx:x?"auto":void 0},children:[e.jsxs(r,{component:"div",children:[e.jsxs(r,{component:"div",sx:{display:"flex",justifyContent:"space-between",flexWrap:"wrap",alignItems:"center",gap:1,mb:.5},children:[e.jsx(h,{variant:"body1",sx:{fontWeight:600},children:"Subscribe"}),e.jsxs(r,{component:"div",sx:{display:"flex",flexWrap:"wrap",minWidth:0,alignItems:"center",gap:1},children:[_e&&e.jsxs(r,{role:"tablist","aria-label":"Billing cycle",className:"PlanCards-cycleToggle",sx:c=>({display:"inline-flex",maxWidth:"100%",flexWrap:"wrap",alignItems:"center",p:"2px",borderRadius:E.full,border:"1px solid",borderColor:c.palette.divider,backgroundColor:"transparent"}),children:[e.jsx(pn,{cycle:"monthly",isActive:ae==="monthly",isDisabled:le,disabledTooltip:"Annual subscriptions cannot switch to monthly.",onSelect:me}),e.jsx(pn,{cycle:"yearly",isActive:ae==="yearly",onSelect:me})]}),e.jsx(sn,{"aria-label":"Scroll plans left",size:"small",disabled:!Ke,onClick:()=>A("left"),sx:Je,children:e.jsx(fe,{icon:ve.faChevronLeft})}),e.jsx(sn,{"aria-label":"Scroll plans right",size:"small",disabled:!Qe,onClick:()=>A("right"),sx:Je,children:e.jsx(fe,{icon:ve.faChevronRight})})]})]}),e.jsxs(h,{variant:"body2",sx:{color:"text.secondary"},children:["Subscribe to a plan and get a monthly credit grant, volume discounts, higher limits, and more."," ",e.jsx(He,{href:w==="founder"?nt.FOUNDER_PRICING_COMPARE:nt.PRICING_COMPARE,target:"_blank",rel:"noopener noreferrer","aria-label":"Compare all plans (opens in new tab)",sx:{fontSize:"inherit",color:"text.secondary"},children:"Compare all plans."})]})]}),e.jsx(r,{ref:$,component:"div",className:"PlanCards-scroll",sx:{dis
1play:"flex",flexWrap:"nowrap",gap:2,alignItems:"stretch",justifyContent:{xs:"flex-start",md:re<=1560?"center":"flex-start"},width:"100%",minWidth:0,overflowX:"auto",scrollSnapType:"x mandatory",WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none","&::-webkit-scrollbar":{display:"none"},pt:4},children:Q.map(c=>{var Et,ut,pt;const K=c.tier===g.PRICING_TIER_ENTERPRISE,T=Oe(c.tier),de=ae==="yearly"&&!!c.annual,se=de?c.annual.tier:c.tier,st=ae==="yearly"&&W&&!zt(W)&&(Et=Cr(W))!=null?Et:W,ot=ae==="yearly"?H:_,we=mn(se,W)||T&&(!t||t===g.PRICING_TIER_UNSPECIFIED||Oe(t)),Gt=ua(pe,we&&T)&&!!i,bt=At(we&&t&&(ut=It(t,u,b))!=null?ut:c,j),Te=t&&Oe(c.tier)&&(w==="founder"&&yr(t)||t===g.PRICING_TIER_ENTERPRISE)?{...bt,subtitle:br(),subtitleLearnMore:void 0}:bt,Xe=w==="founder"&&Oe(c.tier)&&!b.showFounderPlans?vr():Te.rateRows,vt=L&&w==="new"&&!de,$e=vt&&c.tier===g.PRICING_TIER_DEVELOPER,Ve=vt&&c.tier===g.PRICING_TIER_GROWTH,Tt=!!I&&!de&&(c.tier===g.PRICING_TIER_CREATOR||c.tier===g.PRICING_TIER_BUILDER||c.tier===g.PRICING_TIER_DEVELOPER),Rt=Tr(),it=$e&&Rt?At(Rt,j):void 0,Ft=Ve?Rr():void 0,je=it!=null?it:Ft,De=t&&Oe(t)&&c.tier===W?t:c.tier,Re=$e?g.PRICING_TIER_FOUNDER_DEVELOPER:Ve?g.PRICING_TIER_FOUNDER_GROWTH:se,qe=de?c.annual.priceLine:(pt=je==null?void 0:je.priceLine)!=null?pt:Te.priceLine,Be=de&&!we?c.annual.originalPriceLine:void 0,_t=je?je.discountBadge:Te.discountBadge;let he,Pe="outlined",Ge=!1,Ne,et,lt,tt=!1;const ct=e.jsx(fe,{icon:jt.faCheck,style:{fontSize:ge.md}}),ze=xn(se,st,ot);Gt?(he="Add credits",Pe="contained",Ge=p||m,Ne=i):we?(he="Current plan",Pe="outlined",Ge=!0,lt=ct):ze?(he=c.title.replace("Founder | ",""),Pe="outlined",Ge=!0,lt=ct):K?(he="Contact Sales",Pe="contained",et=nt.CONTACT_SALES,Ne=()=>{q(X.BILLING_CLICKED_CONTACT_SALES,ee.Billing,{source:"planCard",...t!=null?{sourceTier:t}:{}})}):T?(tt=!0,he="Add credits",Pe="contained",Ge=m||!n,Ne=()=>void Ue(De,"adding credits to your Inworld account")):le?(he="Upgrade",Pe="contained",Ne=()=>J(!0)):(tt=!0,he="Upgrade",Pe="contained",Ge=m||!n,Ne=()=>void Ue(Re,`upgrading to the ${Te.title} plan`));const dt=tt?C:void 0;return dt&&(Ge=!0,Ne=void 0),e.jsx(r,{ref:Ze=>{we&&(Se.current=Ze),Ze?P.current.set(c.tier,Ze):P.current.delete(c.tier)},component:"div",sx:{display:"flex",flexDirection:"column",flex:"0 0 280px",width:280,minHeight:0,alignSelf:"stretch",scrollSnapAlign:"start"},children:e.jsx(Kr,{title:Te.title,subtitle:Te.subtitle,subtitleLearnMore:Te.subtitleLearnMore,priceLine:qe,originalPriceLine:Be,rateRows:ga(je?je.rateRows:Xe),features:Ca(_r(Er(je?je.features:Te.features,f),G)),featuresIntro:Te.featuresIntro,discountBadge:_t,badge:ze||we||$e||Ve||Tt&&!we&&!ze||w==="founder"&&!K&&!T?void 0:Te.badge,trackBadge:$e||Ve?"Special Offer â Ends June 30":Tt&&!we&&!ze?I:w==="founder"&&!K&&!T?"Founder Plan":void 0,ctaText:he,ctaIntent:Pe==="contained"?"primary":"secondary",ctaDisabled:Ge,ctaDisabledTooltip:dt,ctaLoading:T?Y===De:Y===Re,onCtaClick:Ne,ctaHref:et,ctaStartIcon:lt,dimmed:ze})},c.tier)})}),e.jsx(Sr,{open:v,onClose:()=>J(!1)})]})},ba=({pricingTier:t})=>{var R;const n=te(U.STUDIO_V2_REFERRALS),{inworldUser:a}=Ut(),{freeCreditsInDollars:o}=Nr(),l=30,i=s.useMemo(()=>{var u,b,S;const x=(S=(b=(u=Wn)==null?void 0:u.currentUser)==null?void 0:b.metadata)==null?void 0:S.creationTime;if(!x)return null;const y=new Date(x);return y.setDate(y.getDate()+l),y},[]);if(!n||!((R=a==null?void 0:a.referralInfo)!=null&&R.redeemedReferralCode)||!Oe(t)||!i||i<new Date)return null;const p=i.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"});return e.jsxs(r,{component:"div",className:"ReferralBanner",sx:{width:"100%",backgroundColor:x=>x.palette.success.light,padding:"1rem",borderRadius:E.lg,mb:"1.5rem",border:x=>`1px solid ${yt(x.palette.success.main,.4)}`,display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(fe,{icon:Mn.faGift,style:{flexShrink:0,width:"1.25rem",height:"1.25rem"}}),e.jsx(h,{sx:{color:x=>x.palette.success.dark},children:`You've redeemed a referral code! Subscribe to a plan by ${p} and after your first month, you'll both receive $${o} in credits.`})]})},In="credits-summary",va=560,Ta=280,Ra=16,_a=32,Vt=`@container ${In} (max-width: ${va-1}px)`,An="action",Ot="cancel-subscription",Lt="cancel-subscirbtion",kt="resume-subscription",Ea="add-credits",Sa=t=>
1{const n=t.get(An);return n||(t.has(Ot)?Ot:t.has(Lt)?Lt:t.has(kt)?kt:null)},fn=t=>{switch(t==null?void 0:t.trim().toLowerCase()){case"starter":case"standard":case"on-demand":case"on_demand":case"ondemand":return g.PRICING_TIER_STARTER;case"creator":return g.PRICING_TIER_CREATOR;case"developer":return g.PRICING_TIER_DEVELOPER;case"growth":return g.PRICING_TIER_GROWTH;case"scale":return g.PRICING_TIER_SCALE;case"enterprise":return g.PRICING_TIER_ENTERPRISE;default:return}},wa=t=>{if(!t)return{};try{return JSON.parse(t)}catch(n){return{}}},ja=({billingInfo:t,billingAccountId:n,hasPaymentMethod:a,isPaymentProcessing:o,isReadOnly:l,hideCreditBalance:i=!1,showZeroDataRetentionSection:p})=>{var ut,pt,Ze;const R=Bt(),x=wn(R.breakpoints.down("sm")),{firebaseUserIdentity:y}=Ut(),u=y==null?void 0:y.creationTime,b=Yt(),{workspace:S}=yn(),M=S?`/workspaces/${S}/settings/usage`:void 0,N=gt(U.STUDIO_V2_BILLING_ADD_CREDITS_VARIANTS),j=gt(U.STUDIO_V2_AUTO_RELOAD_CHECKBOX_TEST),z=(j==null?void 0:j.name)==="default-on",D=Ir(t),pe=te(U.STUDIO_V2_BILLING_CREDITS_UI),B=te(U.STUDIO_V2_SUBSCRIPTION_CANCEL),ie=te(U.STUDIO_V2_SHOW_BUILDER_PLANS),[f,G]=s.useState(!1),[L,I]=s.useState(!1),[w,W]=s.useState(!1),[Z,ne]=s.useState(!1),[Q,re]=s.useState(!1),[_,H]=s.useState(!1),[le,C]=s.useState(null),[v,J]=s.useState(null),[_e,Ae]=s.useState(null),[Ce,ae]=s.useState(null),[me,ke]=bn(),Ee=s.useRef(null),$=s.useMemo(()=>{var d;return wa((d=N==null?void 0:N.payload)==null?void 0:d.value)},[(ut=N==null?void 0:N.payload)==null?void 0:ut.value]),Se=s.useMemo(()=>{if(!Array.isArray($.presets))return;const d=$.presets.map(Number).filter(k=>Number.isFinite(k)&&k>0);return d.length>0?d:void 0},[$.presets]);s.useEffect(()=>{const d=me.get("focus_plan"),k=me.get("checkout_plan"),F=me.get("checkout_source");if(!d&&!k&&!F)return;if(d){const Ie=fn(d);Ie&&C({tier:Ie,ts:Date.now()})}if(k){const Ie=fn(k);Ie&&Ae({tier:Ie,ts:Date.now()})}F&&ae(F);const be=new URLSearchParams(me);be.delete("focus_plan"),be.delete("checkout_plan"),be.delete("checkout_source"),ke(be,{replace:!0})},[me,ke]);const{autoTopUpSettings:P,isLoading:Fe,isUpdating:ye,updateSettings:Ke}=Ar(n!=null?n:"",{staleTime:0}),at=s.useCallback(async d=>{try{await Ke(d)}catch(k){throw V(`Failed to update auto-reload settings: ${qt(k)}`),k}I(!1)},[Ke]),{mutate:Qe,isLoading:Me}=Or(n!=null?n:"",{onSuccess:d=>{d!=null&&d.paymentUrl&&(window.location.href=d.paymentUrl)},onError:d=>{G(!1),V(`Error creating payment link: ${qt(d)}`)}}),{startCheckout:Ue,isLoading:m}=Dn({billingAccountId:n,checkoutSource:"billing-add-credits-nudge",sourceTier:t==null?void 0:t.pricingTier}),Y=Me||m||_||!t||!n,ce=(d,k)=>{Qe({amount:d,topUpConfig:k})},xe=()=>{Y||(G(!0),q(X.CLICKED_ADD_CREDITS,ee.Billing))},A=s.useMemo(()=>$n(t),[t]),Je=A!==void 0&&A<0,We=te(U.STUDIO_V2_REFERRALS),{data:c}=Lr(n!=null?n:null),K=s.useMemo(()=>{var Ie,mt;if(!We||!(c!=null&&c.creditGrants))return null;const d=["Referral Reward Credits","Referral Bonus Credits"],k=Date.now();let F=0,be=null;for(const ue of c.creditGrants){if(!ue.name||!d.includes(ue.name))continue;const St=ue.effectiveAt?new Date(ue.effectiveAt):null;if(!St||St.getTime()<=k)continue;const Xt=ue.voidedAt?new Date(ue.voidedAt):null;Xt!==null&&Xt.getTime()>0&&ue.voidedAt!=="1970-01-01T00:00:00Z"||(F+=parseInt((mt=(Ie=ue.amount)==null?void 0:Ie.value)!=null?mt:"0",10),(!be||St<be)&&(be=St))}return F===0||!be?null:{totalCents:F,availableDate:be}},[We,c]),T=(t==null?void 0:t.pricingTier)===g.PRICING_TIER_ENTERPRISE,de=Vn(t==null?void 0:t.pricingTier),se=!(t!=null&&t.pricingTier)||t.pricingTier===g.PRICING_TIER_UNSPECIFIED||Oe(t.pricingTier),st=pa({isRedesignEnabled:pe,isOnDemandPlan:se,isMobile:x,isAutoReloadActive:P.enabled}),ot=x&&se,we=se&&!a&&!T&&!de&&A!==void 0&&A>0,Gt=we?"Free credits remaining":"Credit balance",bt=s.useMemo(()=>Ct(u,b,t==null?void 0:t.pricingTier),[u,b,t==null?void 0:t.pricingTier]),Te=s.useMemo(()=>{const k=Kt(u,b,t==null?void 0:t.pricingTier).map(F=>At(F,ie));return ie?k:k.filter(F=>!Pt(F.tier))},[u,t==null?void 0:t.pricingTier,b,ie]),Xe=Nn(Te,bt),vt=s.useMemo(()=>{const d=Xe.length;return d*Ta+Math.max(d-1,0)*Ra+_a},[Xe.length]),$e=s.useMemo(()=>
1{if(T)return;const d=t!=null&&t.pricingTier&&t.pricingTier!==g.PRICING_TIER_UNSPECIFIED?t.pricingTier:g.PRICING_TIER_STARTER,k=Ct(u,b,d);return En(d,k,Xe)},[u,t==null?void 0:t.pricingTier,b,T,Xe]),Ve=!a&&!T&&!de&&!!$e,Tt=we?e.jsxs("span",{children:["Free credits are provided by Inworld for evaluation and are not refundable or redeemable for cash. They are consumed by eligible usage and may expire or be limited by plan and model access.",M&&e.jsxs(e.Fragment,{children:[" ",e.jsx(He,{"aria-label":"View usage",component:en,to:M,sx:{color:"inherit",textDecoration:"underline"},children:"View usage"})]})]}):i?xa():e.jsxs("span",{children:["Your credit balance will be consumed with API and Playground usage.",M&&e.jsxs(e.Fragment,{children:[" ",e.jsx(He,{"aria-label":"View usage",component:en,to:M,sx:{color:"inherit",textDecoration:"underline"},children:"View usage"})]})]}),Rt=()=>{if(Ve&&$e){ae("billing-summary"),J({tier:$e,ts:Date.now()}),re(!0);return}W(!0)},it=(d,k="billing-manage-subscription")=>{ae(k),J({tier:d,ts:Date.now()}),re(!0)},Ft=()=>{re(!1),ae(null)},je=Ye(t==null?void 0:t.pricingTier),De=(t==null?void 0:t.cancellationStatus)===ft.CANCELLATION_STATUS_PENDING_AT_PERIOD_END,Re=zn((pt=t==null?void 0:t.billingCycle)==null?void 0:pt.nextBillingDate),qe=Re,Be=It(t==null?void 0:t.pricingTier,u,b),_t=Be!=null&&Be.title?`Cancel ${Be.title} plan`:"Cancel plan",he=t==null?void 0:t.scheduledTargetTier,Pe=he!==void 0&&he!==g.PRICING_TIER_UNSPECIFIED&&!Oe(he)&&he!==g.PRICING_TIER_ENTERPRISE,{mutate:Ge,isLoading:Ne}=gn(n!=null?n:void 0,{onSuccess:()=>{Nt("Subscription resumed.")},onError:d=>{V(`Unable to resume subscription: ${d instanceof Error?d.message:"Please try again."}`)}}),et=s.useCallback(()=>{q(X.BILLING_CLICKED_CANCEL_PLAN,ee.Billing,(t==null?void 0:t.pricingTier)!=null?{currentTier:t.pricingTier}:{}),ne(!0)},[t==null?void 0:t.pricingTier]),lt=()=>{!n||Ne||(q(X.BILLING_CLICKED_RESUME_SUBSCRIPTION,ee.Billing,(t==null?void 0:t.pricingTier)!=null?{currentTier:t.pricingTier}:{}),Ge({targetStatus:ft.CANCELLATION_STATUS_NONE}))};s.useEffect(()=>{const d=Sa(me);if(!d){Ee.current=null;return}if(Ee.current===d||!t||o)return;const k=()=>{const ue=new URLSearchParams(me);ue.delete(An),ue.delete(Ot),ue.delete(Lt),ue.delete(kt),ke(ue,{replace:!0})},F=ue=>{V(ue),Ee.current=d,k()};if(d===Ea){if(l){F("Only billing account owners can add credits.");return}if(T){F("Enterprise credits are managed through your account team.");return}if(Y)return;Ee.current=d,k(),G(!0),q(X.CLICKED_ADD_CREDITS,ee.Billing);return}const be=d===Ot||d===Lt,Ie=d===kt;if(!be&&!Ie)return;if(!n){F("Unable to load billing account.");return}if(l){F("Only billing account owners can change subscription status.");return}if(!B){F("Self-serve subscription changes are not available.");return}if(T){F("Enterprise subscriptions are managed through your account team.");return}const mt=Hn(t==null?void 0:t.pricingTier);if(mt){F(mt);return}if(se){F("On-Demand plans cannot be cancelled or resumed.");return}if(be&&De){F("Your subscription is already scheduled to cancel.");return}if(Ie&&!De){F("Your subscription is not currently scheduled to cancel.");return}if(Ee.current=d,k(),be){et();return}W(!0)},[n,t,et,Y,T,se,o,De,l,B,me,ke]);const tt=D&&(Fe?e.jsx(O,{width:180,height:32,sx:{borderRadius:E.sm}}):e.jsx(oe,{intent:P.enabled?"primary":"secondary","aria-label":P.enabled?"Modify auto-reload settings":"Enable auto-reload",size:"small",onClick:()=>{q(P.enabled?X.CLICKED_AUTO_RELOAD_MODIFY:X.CLICKED_AUTO_RELOAD_TURN_ON,ee.Billing,{currentlyEnabled:P.enabled,threshold:P.threshold,reloadAmount:P.reloadAmount}),I(!0)},startIcon:e.jsx(fe,{icon:P.enabled?ve.faCircleCheck:ve.faArrowsRotate,style:{fontSize:ge.sm}}),children:P.enabled?`Auto-reload · Bring to $${P.reloadAmount.toLocaleString()} when balance is $${P.threshold.toLocaleString()}`:"Enable auto-reload"})),ct=!T&&e.jsxs(r,{component:"div",sx:{display:"flex",flexDirection:"column",gap:1.5},children:[e.jsx(h,{variant:"body1",sx:{fontWeight:600},children:"Add credits"}),e.jsx(h,{variant:"body2",sx:{color:"text.secondary"},children:se?"Add credits or enable auto-reload to avoid service disruptions. Usage is billed at your plan rates.":"Add credits anytime or enable auto-reload to avoid service disruptions. Usage beyond included monthly credits is billed at your plan rates."}
1),e.jsxs(r,{component:"div",sx:{display:"flex",flexWrap:"wrap",gap:1.5},children:[e.jsx(oe,{intent:"secondary","aria-label":"Add credits",size:"small",onClick:xe,disabled:Y,startIcon:e.jsx(fe,{icon:ve.faPlus,style:{fontSize:ge.sm}}),children:"Add credits"}),st.showInlineAutoReloadAction&&tt]})]}),ze=D&&!T&&!Fe&&!P.enabled&&e.jsxs(r,{component:"div",sx:d=>({display:"flex",flexDirection:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",gap:2,p:2.5,borderRadius:E.md,backgroundColor:d.palette.error.light,border:`1px solid ${yt(d.palette.error.main,.4)}`}),children:[e.jsxs(r,{component:"div",sx:{display:"flex",alignItems:"flex-start",gap:1.5,flex:1,minWidth:0},children:[e.jsx(fe,{icon:ve.faTriangleExclamation,style:{fontSize:wt.base,flexShrink:0,marginTop:"2px"},color:"warning.main"}),e.jsxs(r,{component:"div",children:[e.jsx(h,{variant:"body2",sx:{fontWeight:600,color:"text.primary",mb:.25},children:"Auto-reload is off"}),e.jsx(h,{variant:"body2",sx:{color:"text.secondary"},children:"Avoid service disruptions by automatically reloading credits when your balance runs low."})]})]}),e.jsx(oe,{"aria-label":"Enable auto-reload",size:"small",onClick:()=>{q(X.CLICKED_AUTO_RELOAD_TURN_ON,ee.Billing,{currentlyEnabled:!1,threshold:P.threshold,reloadAmount:P.reloadAmount}),I(!0)},sx:{flexShrink:0,width:{xs:"100%",sm:"auto"},boxShadow:"none","&:hover":{boxShadow:"none"}},children:"Enable auto-reload"})]}),dt=de?null:e.jsx(r,{id:"billing-plan-cards",component:"div",sx:{display:"flex",flexDirection:"column",gap:1,scrollMarginTop:"1rem",mt:1,minWidth:0},children:!o&&e.jsxs(e.Fragment,{children:[e.jsx(ba,{pricingTier:t==null?void 0:t.pricingTier}),e.jsx(hn,{pricingTier:t==null?void 0:t.pricingTier,billingAccountId:n,onAddCredits:xe,addCreditsDisabled:Y,onPlanChangeLoadingChange:H,focusRequest:le,checkoutRequest:_e,checkoutSource:Ce})]})}),Et=!l&&B&&!se&&!T&&!de;return e.jsxs(r,{component:"div",className:"CreditsRow",sx:{display:"flex",flexDirection:"column",gap:{xs:1.5,sm:3},mb:{xs:1.5,sm:3},minWidth:0},children:[e.jsx(r,{component:"div",sx:{containerType:"inline-size",containerName:In,width:"100%"},children:e.jsxs(r,{component:"div",sx:{display:"grid",gridTemplateColumns:ot?"1fr":"1fr 1fr",alignItems:"start",[Vt]:{gridTemplateColumns:"1fr"}},children:[e.jsxs(r,{component:"div",sx:d=>({display:"flex",flexDirection:"column",gap:1,minHeight:0,[Vt]:{pb:ot?0:2}}),children:[e.jsxs(r,{component:"div",sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(h,{variant:"body1",sx:{fontWeight:600,color:"text.primary",whiteSpace:"nowrap"},children:Gt}),e.jsx(Le,{title:Tt,placement:"bottom-start",arrow:!0,enterTouchDelay:0,leaveTouchDelay:3e3,children:e.jsx("span",{style:{display:"inline-flex",cursor:"help"},children:e.jsx(fe,{icon:ve.faInfoCircle,style:{fontSize:wt.base},color:"text.secondary"})})})]}),e.jsxs(r,{component:"div",sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5},children:[e.jsx(h,{variant:"h2",sx:{fontWeight:500,mb:Je?.5:0,minHeight:"2.5rem",color:i?"text.disabled":"text.primary"},children:dn(i,A,d=>xt({value:d,maxNumDigits:2}))}),!l&&!T&&!se&&e.jsx(oe,{intent:"secondary","aria-label":"Add credits",size:"small",onClick:xe,disabled:Y,startIcon:e.jsx(fe,{icon:ve.faPlus,style:{fontSize:ge.sm}}),sx:{display:{xs:"inline-flex",sm:"none"}},children:"Add credits"})]}),st.showCreditBalanceAutoReloadAction&&e.jsx(r,{component:"div",sx:{display:"flex",mt:.5},children:tt}),K&&e.jsxs(r,{component:"div",sx:d=>({display:"inline-flex",alignItems:"center",alignSelf:"flex-start",gap:1,mt:.5,py:"4px",px:1.5,borderRadius:E.full,backgroundColor:d.palette.warning.light,boxShadow:`inset 0 0 0 0.5px ${yt(d.palette.warning.main,.18)}`}),children:[e.jsx(fe,{icon:ve.faClock,style:{fontSize:ge.sm}}),e.jsxs(h,{variant:"body2",sx:d=>({color:d.palette.warning.dark}),children:[e.jsxs("strong",{children:["+",xt({value:K.totalCents/100,maxNumDigits:2})]})," pending ",e.jsx(He,{component:"button","aria-label":"View referral rewards",onClick:()=>{window.dispatchEvent(new CustomEvent("open-referral-dialog",{detail:{tab:1}})),q(X.REFERRAL_DIALOG_OPENED,ee.Billing,{source:"pending_credits_pill"})},sx:{color:"inherit",fontSize:"inherit",verticalAlign:"baseline",textDecoration:"underline","&:hover":{textDecoration:"none"}},children:"referral"})," credit"]})]}),Je&&e.jsx(Le,{title:e.jsxs("span",{children:["You may temporarily exceed your credit balance due to billing delays. This will show as a negative balance and will be subtracted from your next credit purchase."," ",e.jsx(He,{"aria-label":"Learn more about negative balance",href:"https://docs.inworld.ai/portal/billing",target:"_blank",rel:"noopener noreferrer",sx:{color:"inherit",textDecoration:"underline"},children:"Learn more"})]}),placement:"bottom-start",arrow:!0,enterTouchDelay:0,leaveTouchDelay:3e3,children:e.jsx("span",{style:{display:"block",width:"fit-content",curs
1or:"help"},children:e.jsx(h,{variant:"body2",sx:{color:"text.secondary"},children:"Why is my balance negative?"})})})]}),!ot&&e.jsxs(r,{component:"div",sx:{display:"flex",flexDirection:"column",gap:1,minHeight:0,pt:0,pl:2,[Vt]:{pt:2,pl:0}},children:[e.jsxs(r,{component:"div",sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(h,{variant:"body1",sx:{fontWeight:600,color:"text.primary"},children:"Current plan"}),e.jsx(Le,{title:e.jsxs("span",{children:["Your plan determines your monthly credit grant, TTS & STT rates, and usage limits.",e.jsx("br",{}),e.jsx(He,{href:nt.PRICING,target:"_blank",rel:"noopener noreferrer","aria-label":"View full pricing",sx:{color:"inherit",textDecoration:"underline"},children:"View full pricing"})]}),placement:"bottom-start",arrow:!0,enterTouchDelay:0,leaveTouchDelay:3e3,children:e.jsx("span",{style:{display:"inline-flex",cursor:"help"},children:e.jsx(fe,{icon:ve.faInfoCircle,style:{fontSize:wt.base},color:"text.secondary"})})})]}),e.jsxs(r,{component:"div",sx:{display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(h,{variant:"h2",sx:{fontWeight:500,minHeight:"2.5rem",color:"text.primary"},children:je}),!l&&e.jsx(oe,{intent:"secondary","aria-label":Ve?"Upgrade":"Manage plan",size:"small",disabled:!t,onClick:Rt,children:Ve?"Upgrade":"Manage plan"})]}),De&&Re&&e.jsx(h,{variant:"body2",sx:{color:"text.secondary"},"aria-label":Pe?`Plan downgrades to ${Ye(he)} on ${Re}`:`Plan cancels on ${Re}`,children:Pe?`Downgrading to ${Ye(he)} on ${Re}`:`Cancels on ${Re}`}),!se&&!De&&qe&&e.jsxs(h,{variant:"body2",sx:{color:"text.secondary"},"aria-label":`Plan renews on ${qe}`,children:["Renews on ",qe]})]})]})}),!l&&(se?e.jsxs(e.Fragment,{children:[dt,st.showAddCreditsSection&&ct,ze]}):e.jsxs(e.Fragment,{children:[ct,ze,dt]})),p&&e.jsx(Vr,{}),Et&&e.jsxs(r,{component:"div",className:"BillingCancellationSection",sx:{display:"flex",flexDirection:"column",gap:1.5},children:[e.jsx(h,{variant:"body1",sx:{fontWeight:600},children:"Cancellation"}),e.jsxs(r,{component:"div",sx:d=>({display:"flex",flexDirection:{xs:"column",sm:"row"},alignItems:{xs:"stretch",sm:"center"},justifyContent:"space-between",gap:2,p:2.5,borderRadius:E.md,border:`1px solid ${d.palette.divider}`}),children:[e.jsxs(r,{component:"div",sx:{minWidth:0},children:[e.jsx(h,{variant:"body2",sx:{color:"text.primary",mb:.25},children:De?`${(Ze=Be==null?void 0:Be.title)!=null?Ze:"Subscription"} plan cancellation scheduled`:_t}),De&&e.jsx(h,{variant:"body2",sx:{color:"text.secondary"},children:Re?`Cancels on ${Re}.`:"Cancels at the end of the current billing period."})]}),De?e.jsx(oe,{"aria-label":"Resume subscription",size:"small",disabled:Ne||!n,onClick:lt,sx:{alignSelf:{xs:"stretch",sm:"center"},flexShrink:0,boxShadow:"none","&:hover":{boxShadow:"none"}},children:Ne?"Resumingâ¦":"Resume"}):e.jsx(oe,{"aria-label":_t,size:"small",onClick:et,intent:"secondary",sx:{alignSelf:{xs:"stretch",sm:"center"},flexShrink:0,boxShadow:"none","&:hover":{boxShadow:"none"}},children:"Cancel"})]})]}),e.jsx(kr,{open:f,onClose:()=>G(!1),onPurchase:ce,currentBalance:A!=null?A:0,isLoading:Me||m,autoReloadActive:!D||P.enabled,defaultAutoReloadEnabled:z,presets:Se,pricingTier:t==null?void 0:t.pricingTier,billingAccountId:n,planDefinitions:Xe,enablePurchaseNudges:pe,onUpgradePlan:d=>{G(!1),Ue(d,"upgrading your Inworld subscription")}}),D&&!T&&e.jsx(da,{open:L,onClose:()=>I(!1),onUpdate:at,onPurchase:ce,currentSettings:P,currentBalance:A!=null?A:0,hasPaymentMethod:a,isPurchaseLoading:Me,isUpdating:ye}),e.jsx(fa,{open:w||Z,onClose:()=>{W(!1),ne(!1)},initialCancelConfirmOpen:Z,isEnterprise:T,isAdminAssigned:de,pricingTier:t==null?void 0:t.pricingTier,onUpgrade:it,currentBalance:!i&&A===void 0?void 0:dn(i,A,d=>xt({value:d,maxNumDigits:2})),billingAccountId:n,hasPaymentMethod:a,cancellationStatus:t==null?void 0:t.cancellationStatus,periodEndDate:Re,nextBillingDate:qe}),e.jsx(ht,{controlled:!0,open:Q,onClose:Ft,title:"Upgrade plan",maxWidth:!1,fullScreen:x,slotProps:{paper:{sx:{width:{xs:"100%",sm:`min(${vt}px, calc(100vw - 24px))`},maxWidth:{xs:"100vw",sm:"calc(100vw - 24px)"},height:{xs:"100%",sm:"auto"},maxHeight:{xs:"100%",sm:"90vh"},m:{xs:0,sm:2},borderRadius:{xs:0,sm:E.md},display:"flex",flexDirection:"column",overflow:"hidden","& .MuiDialogContent-root":{px:{xs:1.5,sm:2},pb:2,flex:1,minHeight:0,overflowY:"auto",overflowX:"hidden"}}}},children:e.jsx(r,{component:"div",className:"CreditsRow-upgradePlansDialog",sx:{minWidth:0}
1,children:e.jsx(hn,{pricingTier:t==null?void 0:t.pricingTier,billingAccountId:n,focusRequest:v,checkoutSource:Ce,fitToContent:!0})})})]})},Da=5,Pa=()=>{const t=Bt(),n=t.palette.background.paper,a=`1px solid ${t.palette.divider}`;return e.jsxs(Tn,{spacing:3,children:[e.jsxs(r,{component:"div",sx:{display:"flex",flexDirection:"column",gap:1.5},children:[e.jsx(O,{variant:"text",width:80,height:24}),e.jsxs(r,{component:"div",sx:{backgroundColor:n,borderRadius:E.md,border:a,p:2,display:"grid",gridTemplateColumns:"1fr 1fr",gap:0},children:[e.jsxs(r,{component:"div",sx:{display:"flex",flexDirection:"column",gap:1,pr:2,borderRight:a},children:[e.jsx(O,{variant:"text",width:120,height:20}),e.jsx(O,{variant:"text",width:140,height:40}),e.jsx(O,{variant:"rectangular",width:100,height:36,sx:{borderRadius:E.sm}})]}),e.jsxs(r,{component:"div",sx:{display:"flex",flexDirection:"column",gap:1,pl:2},children:[e.jsx(O,{variant:"text",width:80,height:20}),e.jsx(O,{variant:"text",width:100,height:40}),e.jsx(O,{variant:"rectangular",width:80,height:36,sx:{borderRadius:E.sm}})]})]})]}),e.jsxs(r,{component:"div",sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(r,{component:"div",sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(O,{variant:"text",width:50,height:24}),e.jsxs(r,{component:"div",sx:{display:"flex",gap:.5},children:[e.jsx(O,{variant:"circular",width:28,height:28}),e.jsx(O,{variant:"circular",width:28,height:28})]})]}),e.jsx(r,{component:"div",sx:{display:"flex",gap:2,overflow:"hidden"},children:Array.from({length:Da}).map((o,l)=>e.jsxs(r,{component:"div",sx:{flex:"0 0 280px",display:"flex",flexDirection:"column",gap:2},children:[e.jsxs(r,{component:"div",sx:{backgroundColor:n,borderRadius:E.md,border:a,p:2.5,display:"flex",flexDirection:"column",gap:1},children:[e.jsx(O,{variant:"text",width:"50%",height:24}),e.jsx(O,{variant:"text",width:"80%",height:16}),e.jsx(O,{variant:"text",width:"40%",height:18,sx:{mt:.5}}),e.jsxs(r,{component:"div",sx:{mt:1,display:"flex",flexDirection:"column",gap:.5},children:[e.jsx(O,{variant:"text",width:"100%",height:16}),e.jsx(O,{variant:"text",width:"100%",height:16}),e.jsx(O,{variant:"text",width:"100%",height:16})]}),e.jsx(O,{variant:"rectangular",width:"100%",height:40,sx:{borderRadius:E.sm,mt:1}})]}),e.jsx(r,{component:"div",sx:{display:"flex",flexDirection:"column",gap:.75},children:Array.from({length:5}).map((i,p)=>e.jsx(O,{variant:"text",width:`${60+p%3*15}%`,height:16},p))})]},l))})]}),e.jsxs(r,{component:"div",sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsx(O,{variant:"text",width:150,height:24}),e.jsxs(r,{component:"div",sx:{backgroundColor:n,borderRadius:E.md,border:a,overflow:"hidden"},children:[e.jsx(r,{component:"div",sx:{display:"flex",gap:2,p:"0.75rem 1rem",borderBottom:a,backgroundColor:t.palette.action.hover},children:[120,100,100,120].map((o,l)=>e.jsx(O,{variant:"text",width:o,height:22,sx:{flex:1}},l))}),Array.from({length:4}).map((o,l)=>e.jsx(r,{component:"div",sx:{display:"flex",gap:2,p:"0.75rem 1rem",borderBottom:l<3?a:"none"},children:[100,80,70,110].map((i,p)=>e.jsx(O,{variant:"text",width:i,height:18,sx:{flex:1}},p))},l))]})]})]})},Na=({activeTab:t,billingInfo:n,creditTransactions:a,isCreditTransactionsLoading:o,hideCreditHistory:l,isPaymentProcessing:i,billingAccountId:p,hasPaymentMethod:R,isReadOnly:x})=>{const[y,u]=s.useState(!1),{currentOrg:b}=vn(),M=!(te(U.STUDIO_ORG_MANAGEMENT)&&(b==null?void 0:b.type)==="TEAM"),N=async()=>{if(p){u(!0);try{const j=await Cn(p);j?window.open(j,"_blank","noopener,noreferrer"):V("Unable to open billing portal. Please try again.")}catch(j){V("Unable to open billing portal. Please try again.")}u(!1)}};return e.jsx(la,{children:e.jsxs(Tn,{spacing:0,children:[t===0&&e.jsx(e.Fragment,{children:e.jsx(ja,{billingInfo:n,billingAccountId:p,hasPaymentMethod:R,isPaymentProcessing:i,isReadOnly:x,hideCreditBalance:l,showZeroDataRetentionSection:!x&&M})}),t===1&&e.jsx(ta,{transactions:a,isLoading:o!=null?o:!1,action:!x&&R?e.jsx(oe,{intent:"secondary","aria-label":"View invoices in Stripe",size:"small",disabled:y||!p,onClick:N,children:y?"Opening...":"
1View invoices"}):void 0})]})})},$a=()=>{var re;const[t,n]=s.useState(0),{currentOrg:a}=vn(),o=!a||a.currentUserRole===Yn.BILLING_ACCOUNT_MEMBER_ROLE_OWNER,[l,i]=s.useState(!1),[p,R]=bn(),[x,y]=s.useState(()=>p.get("payment")==="success"),{billingAccountId:u}=Kn(),b=Xn(),{data:S,isLoading:M}=Ur(u!=null?u:""),{data:N,refetch:j,isLoading:z,error:D}=Zn(u!=null?u:"",{staleTime:0}),pe=(N==null?void 0:N.pricingTier)===g.PRICING_TIER_ENTERPRISE,{workspace:B}=yn(),ie=s.useRef(!1),f=te(U.BILLING_MANAGER_ENABLE_INSTANT_TOP_UP_CHARGING),G=te(U.STUDIO_V2_ENTERPRISE_CREDITS_VISIBILITY),{data:L}=Qn(["billingPageWorkspace",B],()=>tr(rr.GetWorkspace,{name:nr(B)}),{enabled:!!B});s.useEffect(()=>{if(!x)return;const _=setTimeout(async()=>{await j(),y(!1)},Jn);return()=>clearTimeout(_)},[x,j]),s.useEffect(()=>{const _=p.get("payment");if(_==="success"){if(!u||ie.current)return;ie.current=!0,y(!0),Nt("Payment successful! Your credits have been added.",{duration:5e3}),(async()=>{if(f){const C=p.get("top_up_config");if(C)try{const v=JSON.parse(C);await er(u,v),b.invalidateQueries(["topUpConfig",u])}catch(v){console.error("Failed to parse or save top_up_config from redirect URL:",C),V("Failed to save auto top-up settings.")}}})();const le=new URLSearchParams(p);le.delete("payment"),le.delete("top_up_config"),R(le,{replace:!0})}else if(_==="cancelled"){const H=new URLSearchParams(p);H.delete("payment"),R(H,{replace:!0})}},[p,R,j,u,f,b]);const{transactions:I,isLoading:w,error:W}=Br(u!=null?u:null,{staleTime:0});s.useEffect(()=>{W&&V("Failed to load transaction history. Please try again later.")},[W]);const Z=s.useMemo(()=>!L||!B?null:`Note: Billing information is only shown for workspaces you own. You are currently in a shared workspace, ${L.displayName} (${B}), and billing for this workspace is only visible to ${L.billingAccountEmail}.`,[L,B]);s.useEffect(()=>{if(B&&L){const _=L.billingAccount&&u&&tn(L.billingAccount)!==tn(u);i(!!_)}else i(!1)},[B,L,u]);const ne=pe&&!G,Q=ne?0:t;return e.jsx(Gr,{EnhancedPageHeaderProps:{title:"Billing",description:"View your plan, payment method, and billing history."},disableHorizontalPadding:!0,children:e.jsxs(r,{component:"div",sx:{maxWidth:qn.page,mx:"auto",width:"100%",px:{xs:2,sm:3}},children:[!ne&&e.jsxs(Mr,{sx:[Wr,{mb:3}],value:Q,onChange:(_,H)=>n(H),children:[e.jsx(on,{value:0,label:"Overview"}),e.jsx(on,{value:1,label:"History"})]}),M||z||!u?e.jsx(Pa,{}):e.jsxs(e.Fragment,{children:[!o&&e.jsx(Wt,{isWarning:!0,text:"Only billing account owners can change billing information."}),l&&Z&&e.jsx(Wt,{isWarning:!0,text:Z}),D&&e.jsx(Wt,{isWarning:!0,text:"Unable to load billing information. Please refresh the page or try again later."}),e.jsx(Na,{activeTab:Q,billingInfo:x?void 0:N,isPaymentProcessing:x,creditTransactions:x?[]:I!=null?I:[],isCreditTransactionsLoading:x||w,hideCreditHistory:ne,billingAccountId:u,hasPaymentMethod:(re=S==null?void 0:S.hasStripe)!=null?re:!1,isReadOnly:!o})]})]})})};export{$a as PortalSettingsBilling};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.