vendor: 4,706 bytes, lines 1-8
1import{r as pe}from"./rolldown-runtime.C1f3BsDW.js";import{r as oe}from"./inertia.BE4YqsTM.js";import"./http.DWpeO7Ui.js";import{Cr as Te,I as Ue,Pt as Le,Qr as Fe,Xt as $,fn as Ae,hr as Ie,i as Re,p as Me,r as Ye,u as Be,vr as xe,wr as he}from"./icons.ChOq_Y4q.js";import{t as De}from"./react-core.CAMe6Z4j.js";import"./utils.CgzVjNgC.js";import"./state.L8kQliOB.js";import{Tt as Z,b as Ve,d as q,h as H,i as fe,jt as I,k as M,mt as K,st as We,vt as O}from"./entry-client.DX3aUoe5.js";import{a as qe,c as Oe,i as Ge,s as be}from"./trial.B9u_I_11.js";import{n as ie,t as ye}from"./pricing.C9qFCzuG.js";import{t as Je}from"./useTrialActions.DV-1SdK9.js";var l=pe(Fe(),1);function R(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?R=function(t){return typeof t}:R=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},R(r)}var ge="clover",Xe=function(t){return t===3?"v3":t},ve="https://js.stripe.com",Ke="".concat(ve,"/").concat(ge,"/stripe.js"),ze=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Qe=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,le="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",Ze=function(t){return ze.test(t)||Qe.test(t)},He=function(){for(var t=document.querySelectorAll('script[src^="'.concat(ve,'"]')),a=0;a<t.length;a++){var s=t[a];if(Ze(s.src))return s}return null},ce=function(t){var a=t&&!t.advancedFraudSignals?"?advancedFraudSignals=false":"",s=document.createElement("script");s.src="".concat(Ke).concat(a);var n=document.head||document.body;if(!n)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return n.appendChild(s),s},et=function(t,a){!t||!t._registerWrapper||t._registerWrapper({name:"stripe-js",version:"8.11.0",startTime:a})},A=null,G=null,J=null,tt=function(t){return function(a){t(new Error("Failed to load Stripe.js",{cause:a}))}},rt=function(t,a){return function(){window.Stripe?t(window.Stripe):a(new Error("Stripe.js not available"))}},st=function(t){return A!==null?A:(A=new Promise(function(a,s){if(typeof window>"u"||typeof document>"u"){a(null);return}if(window.Stripe&&t&&console.warn(le),window.Stripe){a(window.Stripe);return}try{var n=He();if(n&&t)console.warn(le);else if(!n)n=ce(t);else if(n&&J!==null&&G!==null){var i;n.removeEventListener("load",J),n.removeEventListener("error",G),(i=n.parentNode)===null||i===void 0||i.removeChild(n),n=ce(t)}J=rt(a,s),G=tt(s),n.addEventListener("load",J),n.addEventListener("error",G)}catch(c){s(c);return}}),A.catch(function(a){return A=null,Promise.reject(a)}))},at=function(t,a,s){if(t===null)return null;var n=a[0];if(typeof n!="string")throw new Error("Expected publishable key to be of type string, got type ".concat(R(n)," instead."));var i=n.match(/^pk_test/),c=Xe(t.version),p=ge;i&&c!==p&&console.warn("Stripe.js@".concat(c," was loaded on the page, but @stripe/stripe-js@").concat("8.11.0"," expected Stripe.js@").concat(p,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var x=t.apply(void 0,a);return et(x,s),x},de=function(t){var a=`invalid load parameters; expected object of shape 2 3 {advancedFraudSignals: boolean} 4 5but received 6 7 `.concat(JSON.stringify(t),` 8`);if(t===null||R(t)!=="object")throw new Error(a);if(Object.keys(t).length===1&&typeof t.advancedFraudSignals=="boolean")return t;throw new Error(a)},X,ee=!1,nt=function(){for(var t=arguments.length,a=new Array(t),s=0;s<t;s++)a[s]=arguments[s];ee=!0;var n=Date.now();return st(X).then(function(i){return at(i,a,n)})};nt.setLoadParameters=function(r){if(ee&&X){var t=de(r);if(Object.keys(t).reduce(function(a,s){var n;return a&&r[s]===((n=X)===null||n===void 0?void 0:n[s])},!0))return}if(ee)throw new Error("You cannot change load parameters after calling loadStripe");X=de(r)};var ue=null;function ot(){return ue||(console.error("VITE_STRIPE_KEY is not set"),Promise.resolve(null))}var e=pe(De(),1),me={"generate-image":{title:"Draw this storyboard",description:"Draw the storyboard picture for any shot in your film."},"generate-video":{title:"Generate video clips",description:"Turn your shots into video clips with sound."},"generate-voice":{title:"Add a voice",description:"Choose a voice to tell your film's story."},"generate-sfx":{title:"Add sound effects",description:"Add sound effects to any moment in your film."},"generate-music":{title:"Add more music",description:"Make more music for your film."},export:{title:"Export your film",description:"Export your film as a video file."}
8,"upload-image":{title:"Bring in your own pictures",description:"Use your own picture as the storyboard picture for any shot."},"upload-video":{title:"Bring in your own footage",description:"Use your own video clips in your film."},"create-project":{title:"Start your film",description:"Pick a plan to begin."},"film-limit":{title:"Your films are all in use",description:"A film counts once its shots are written."},"start-trial":{title:"Start your film",description:"Pick the plan to try. A small charge today starts the trial."},default:{title:"Keep going",description:"Choose a plan to keep making your film."}},it=["Your story and shots","Storyboards in preview quality","Scene audio, music and sound effects"],lt=r=>{const t=r/100;return[{icon:Ae,label:"Shots",value:`${Math.floor(t/.03)}+`},{icon:Me,label:"Scenes",value:`${Math.floor(t/.25)}+`},{icon:Le,label:"Voiceovers",value:"Unlimited"},{icon:Ue,label:"Scripts",value:"Unlimited"}]},ct=[1e3,2500,5e3,1e4],dt=({onClose:r,feature:t,initialAmountCents:a,upgrade:s,message:n})=>{const{checkAuth:i,user:c}=fe(),[p,x]=(0,l.useState)("select"),f=!!c&&!c.has_subscription&&!c.wallet_balance_cents,[b,y]=(0,l.useState)(null),g=b??(s?"upgrade":f?"plans":"topup"),[v,j]=(0,l.useState)(!1),[E,m]=(0,l.useState)(null),[Y,u]=(0,l.useState)(a??5e3),[w,B]=(0,l.useState)(a&&![1e3,2500,5e3,1e4].includes(a)?String(a/100):""),[D,je]=(0,l.useState)([]),[T,z]=(0,l.useState)(null),[te,re]=(0,l.useState)(null),[we,_e]=(0,l.useState)(null),[Ne,_]=(0,l.useState)(null),[Se,se]=(0,l.useState)(!1),[ke,Ee]=(0,l.useState)(!1);(0,l.useEffect)(()=>{let d=!1;return f?(O.getBalance().then(L=>{d||re(L.data.data?.total_cents??0)}).catch(()=>{}),()=>{d=!0}):(se(!0),Promise.all([We.list(),O.getBalance()]).then(([L,W])=>{if(d)return;const S=L.data.data?.payment_methods||[];je(S);const o=S.find(P=>P.is_default);o?z(o.id):S.length>0&&z(S[0].id),re(W.data.data?.total_cents??0)}).catch(()=>{d||_("Could not load your payment details. Try again.")}).finally(()=>{d||se(!1)}),()=>{d=!0})},[f]);const h=w?Math.round(parseFloat(w)*100):Y,Q=h>=1e3&&h<=5e4,Ce=(0,l.useCallback)(async()=>{if(Q){_(null),x("processing");try{if(!T||D.length===0){const P=window.location.pathname+window.location.search,F=await O.topUp(h,P),k=F.data.data?.tracking,ne=F.data.data?.checkout_url;if(ne){k?.event_id&&(q("InitiateCheckout",{value:k.value,currency:k.currency,content_category:"wallet",content_name:"Wallet Top-Up",content_ids:[`wallet-topup-${h}`],content_type:"product"},k.event_id),H("initiate_checkout",{event_id:k.event_id,ecommerce:{currency:k.currency??"USD",value:k.value??h/100}})),window.location.href=ne;return}_("Could not open checkout. Try again."),x("select");return}const{status:d,new_balance_cents:L,client_secret:W,return_url:S,tracking:o}=(await O.charge(h,T)).data.data;if(o?.initiate_checkout_event_id&&q("InitiateCheckout",{value:o.value,currency:o.currency,content_category:"wallet",content_name:"Wallet Top-Up",content_ids:[`wallet-topup-${h}`],content_type:"product"},o.initiate_checkout_event_id),d==="succeeded"){o?.purchase_event_id&&(q("Purchase",{value:o.value,currency:o.currency,content_category:"wallet",content_name:"Wallet Top-Up",content_ids:[o.purchase_event_id],content_type:"product"},o.purchase_event_id),H("purchase",{event_id:o.purchase_event_id,ecommerce:{transaction_id:o.purchase_event_id,value:o.value,currency:o.currency,items:[{item_id:"wallet_topup",item_name:"Wallet Top-Up",item_category:"wallet",price:o.value,quantity:1}]}})),_e(L),x("success"),Z.success(`$${(h/100).toFixed(2)} added to your wallet.`),i(),setTimeout(()=>{r()},2e3);return}if(d==="requires_action"&&W&&S){const P=await ot();if(!P){_("Could not load the payment form. Try again."),x("select");return}const F=await P.confirmCardPayment(W,{return_url:S});if(F.error){_(F.error.message||"Could not confirm the payment. Try again."),x("select");return}x("success"),Z.success(`$${(h/100).toFixed(2)} added to your wallet.`),i(),o?.purchase_event_id&&(q("Purchase",{value:o.value,currency:o.currency,content_category:"wallet",content_name:"Wallet Top-Up",content_ids:[o.purchase_event_id],content_type:"product"},o.purchase_event_id),H("purchase",{event_id:o.purchase_event_id,ecommerce:{transaction_id:o.purchase_event_id,value:o.value,currency:o.currency}})),setTimeout(()=>{r()},2e3);return}_("Could not take the payment. Try again."),x("select")}catch(d){_(d.response?.data?.message||"Could not take the payment. Try again."),x("select")}}},[Q,T,D.length,h,i,r]),Pe=(0,l.useCallback)(async()=>
8{if(s){m(null),j(!0);try{const d=await K.switchPlan(s.plan);Z.success(d.data?.message||`Upgraded to ${s.plan_name}.`),await i(),r()}catch(d){m(d.response?.data?.message||"Could not switch your plan. Try again.")}finally{j(!1)}}},[s,i,r]),ae=me[t||"default"]||me.default,N=g==="upgrade"&&!!s&&p==="select",C=g==="plans"&&p==="select"&&(c?.free_tier?.on_trial??!1),U=g==="plans"&&p==="select"&&!C,V=t==="film-limit"&&!s&&!f&&b===null&&p==="select",$e=D.find(d=>d.id===T);return(0,e.jsx)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm pointer-events-auto",onClick:r,children:(0,e.jsxs)("div",{className:I("w-full max-w-md rounded-2xl overflow-hidden","bg-card","border border-border shadow-2xl","animate-scale-in"),onClick:d=>d.stopPropagation(),children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 px-5 pt-5 pb-0",children:[(0,e.jsx)("div",{className:"w-9 h-9 rounded-lg bg-primary/10 border border-primary/20 flex items-center justify-center shrink-0",children:N||U||C||V?(0,e.jsx)(xe,{className:"h-4 w-4 text-primary","aria-hidden":"true"}):(0,e.jsx)(Be,{className:"h-4 w-4 text-primary","aria-hidden":"true"})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("h2",{className:"text-base font-semibold leading-tight",children:N?`You've hit your ${s.current_plan_name} limit`:ae.title}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:N?`${s.current_plan_name} · ${ye(s.current_limit,s.limit_unit,s.resource_label)}${s.per_month===!1?"":"/mo"}`:ae.description})]}),(0,e.jsx)("button",{onClick:r,className:"p-1.5 -mr-1 rounded-lg hover:bg-surface-hover transition-colors text-muted-foreground hover:text-foreground shrink-0","aria-label":"Close",type:"button",children:(0,e.jsx)(Re,{className:"h-4 w-4","aria-hidden":"true"})})]}),p==="select"&&!N&&!U&&!C&&!V&&(0,e.jsxs)("div",{className:"mx-5 mt-4 mb-1 px-4 py-3 rounded-xl bg-secondary/40 border border-border/50",children:[(0,e.jsxs)("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-3",children:["What $",(h/100).toFixed(0)," gets you"]}),(0,e.jsx)("div",{className:"grid grid-cols-4 gap-3",children:lt(h).map(d=>(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)(d.icon,{className:"h-4 w-4 mx-auto mb-1.5 text-primary","aria-hidden":"true"}),(0,e.jsx)("p",{className:"text-xs font-semibold leading-tight",children:d.value}),(0,e.jsx)("p",{className:"text-[10px] text-muted-foreground leading-tight mt-0.5",children:d.label})]},d.label))})]}),(0,e.jsxs)("div",{className:"p-5 pt-4",children:[N&&(0,e.jsx)(xt,{upgrade:s,message:n,upgrading:v,error:E,onUpgrade:Pe,onChooseTopUp:()=>{m(null),y("topup")}}),C&&(0,e.jsx)(mt,{message:n,planType:c?.free_tier?.trial_plan_type??null,endsAt:c?.free_tier?.trial_ends_at??null,onClose:r}),U&&(0,e.jsx)(ut,{feature:t,message:n,onChooseTopUp:te!==null?()=>y("topup"):void 0}),p==="select"&&!N&&!U&&!C&&s&&(0,e.jsxs)("button",{type:"button",onClick:()=>y("upgrade"),className:"mb-3 text-xs text-muted-foreground hover:text-foreground transition-colors",children:["â Back to ",s.plan_name," upgrade"]}),V&&(0,e.jsx)(pt,{message:n,onClose:r}),p==="select"&&!N&&!U&&!C&&!V&&(0,e.jsx)(ht,{walletBalance:te,loading:Se,paymentMethods:D,selectedPaymentMethod:T,selectedMethod:$e,selectedAmount:Y,customAmount:w,effectiveAmountCents:h,isValidAmount:Q,error:Ne,dropdownOpen:ke,setSelectedAmount:u,setCustomAmount:B,setSelectedPaymentMethod:z,setDropdownOpen:Ee,onCharge:Ce}),p==="processing"&&(0,e.jsx)(ft,{}),p==="success"&&(0,e.jsx)(bt,{amountCents:h,newBalance:we})]})]})})},ut=({feature:r,message:t,onChooseTopUp:a})=>{const s=fe(u=>u.user?.free_tier),n=s?.projects_limit===0,i=s?.trial_required??!1,c=i&&(s?.trial_available??!1),p=be(s?.trial_price_cents??100),x=Oe(s?.trial_days??1),[f,b]=(0,l.useState)([]),[y,g]=(0,l.useState)(!0),[v,j]=(0,l.useState)(null),[E,m]=(0,l.useState)(null);(0,l.useEffect)(()=>{let u=!1;return K.plans().then(w=>{u||b(w.data?.data??[])}).catch(()=>{u||b([])}).finally(()=>{u||g(!1)}),()=>{u=!0}},[]);const Y=(0,l.useCallback)(async u=>{j(u),m(null);try{const w=`${window.location.pathname}${window.location.search}`,B=(await K.create(u,"monthly",w,{trial:c})).data?.data?.checkout_url;if(!B)throw new Error("No checkout URL returned");window.location.href=B}catch(w){m(w?.response?.data?.message||"Could not open checkout. Try again."),j(null)}},[c]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:t??(c?`Pick the plan to try. ${p} today makes your whole storyboard â story, shots, voices and music. The plan starts in ${x} unless you cancel.`:r==="create-project"?n?"Pick a plan to start your first film.":i?"Your trial film is made. Pick a plan to start the next one.":"Your free film is made. Pick a plan to start the next one.":"Your story and shots are saved. Choose a plan to generate storyboards, video clips and export your film.")}),!n&&(0,e.jsxs)("div",{className:"mb-4 px-4 py-3 rounded-xl bg-secondary/40 border border-border/50",children:[(0,e.jsx)("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-2",children:c?`Included in the ${p} trial`:i?"Yours already":"Yours already, free"}),(0,e.jsx)("ul",{className:"space-y-1.5",children:it.map(u=>(0,e.jsxs)("li",{className:"flex items-center gap-2 text-sm",children:[(0,e.jsx)(he,{className:"h-3.5 w-3.5 text-primary shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:u})]},u))})]}),E&&(0,e.jsx)("div",{className:"mb-3 px-3 py-2 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:E}),y?(0,e.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,e.jsx)($,{className:"h-5 w-5 animate-spin text-muted-foreground","aria-hidden":"true"})}):(0,e.jsxs)("div",{className:"space-y-2",children:[f.map(u=>(0,e.jsxs)("button",{type:"button",onClick:()=>void Y(u.type),disabled:v!==null,className:I("w-full flex items-center justify-between gap-3 px-4 h-12 rounded-lg border transition-all text-left disabled:opacity-50",u.is_popular?"border-primary/40 bg-primary/5 hover:border-primary":"border-border hover:border-border-strong hover:bg-secondary/50"),children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 min-w-0",children:[(0,e.jsx)("span",{className:"text-sm font-semibold truncate",children:u.name}),u.is_popular&&(0,e.jsx)("span",{className:"text-[10px] font-medium uppercase tracking-wider text-primary shrink-0",children:"Popular"})]}),(0,e.jsx)("span",{className:"text-sm font-semibold tabular-nums shrink-0 text-right",children:v===u.type?(0,e.jsx)($,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):c?(0,e.jsxs)(e.Fragment,{children:[p," today",(0,e.jsxs)("span",{className:"block text-[10px] font-normal text-muted-foreground",children:["then $",(u.price_cents/100).toFixed(0),"/mo"]})]}):(0,e.jsxs)(e.Fragment,{children:["$",(u.price_cents/100).toFixed(0),(0,e.jsx)("span",{className:"text-xs font-normal text-muted-foreground",children:"/mo"})]})})]},u.type)),(0,e.jsx)("a",{href:"/pricing",className:"block w-full h-9 leading-9 rounded-lg text-center text-sm font-medium text-muted-foreground hover:text-foreground border border-border hover:border-border-strong hover:bg-secondary/50 transition-all",children:"Compare plans"}),(0,e.jsxs)("a",{href:"/experience?from=upgrade-modal",onClick:()=>Ve("upgrade-modal"),className:"flex items-center justify-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[(0,e.jsx)(Ie,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Not sure yet? Watch the 3-minute film"]}),a&&(0,e.jsx)("button",{type:"button",onClick:a,disabled:v!==null,className:"w-full h-9 rounded-lg text-sm font-medium text-muted-foreground hover:text-foreground border border-border hover:border-border-strong hover:bg-secondary/50 transition-all disabled:opacity-50",children:"Add credits instead"}),(0,e.jsx)("p",{className:"text-[11px] text-center text-muted-foreground",children:c?`Cancel before the ${x}
8 are up and your card is not charged again. Your film stays yours.`:"Cancel any time. Your film stays yours."})]})]})},mt=({message:r,planType:t,endsAt:a,onClose:s})=>{const{startNow:n,starting:i}=Je(),c=qe(t),p=Ge(a),[x,f]=(0,l.useState)(null);(0,l.useEffect)(()=>{let y=!1;return K.plans().then(g=>{const v=(g.data?.data??[]).find(j=>j.type===t);!y&&v?.price_cents&&f(v.price_cents)}).catch(()=>{}),()=>{y=!0}},[t]);const b=(0,l.useCallback)(async()=>{await n()&&s()},[n,s]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:r??"Your trial covers your story, shots and sound. Starting your plan unlocks the rest."}),(0,e.jsxs)("div",{className:"mb-4 px-4 py-3 rounded-xl bg-secondary/40 border border-border/50",children:[(0,e.jsx)("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-2",children:"Your plan starts by itself"}),(0,e.jsxs)("p",{className:"text-sm",children:[(0,e.jsx)("span",{className:"font-semibold",children:c})," ",(0,e.jsx)("span",{className:"text-muted-foreground",children:p?`starts ${p}. Start it now and video clips, sound and export unlock today.`:"starts when the trial ends. Start it now and video clips, sound and export unlock today."})]})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)(M,{className:"w-full h-11 gap-2",onClick:()=>void b(),disabled:i,children:[i?(0,e.jsx)($,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):(0,e.jsx)(Ye,{className:"h-4 w-4","aria-hidden":"true"}),"Start ",c," now"]}),(0,e.jsx)("button",{type:"button",onClick:s,disabled:i,className:"w-full h-9 rounded-lg text-sm font-medium text-muted-foreground hover:text-foreground border border-border hover:border-border-strong hover:bg-secondary/50 transition-all disabled:opacity-50",children:"Keep the trial for now"}),(0,e.jsxs)("p",{className:"text-xs text-center text-muted-foreground",children:[x?`Starting now charges your card ${be(x)} today and ends the trial.`:"Starting now bills the plan today and ends the trial."," ",(0,e.jsx)("a",{href:"/dashboard/settings?tab=billing",className:"underline hover:text-foreground",children:"Manage or cancel in billing"}),"."]})]})]})},pt=({message:r,onClose:t})=>(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:r??"Every film your plan holds already has shots. Delete one you no longer need to make room."}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(M,{onClick:()=>{t(),oe.visit("/dashboard")},className:"w-full h-10 text-sm font-semibold",children:"Open my films"}),(0,e.jsx)(M,{variant:"outline",onClick:()=>{t(),oe.visit("/pricing")},className:"w-full",children:"See plans"})]})]}),xt=({upgrade:r,message:t,upgrading:a,error:s,onUpgrade:n,onChooseTopUp:i})=>(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:t??`You've used all ${ye(r.current_limit,r.limit_unit,r.resource_label)} on ${r.current_plan_name} this month.`}),(0,e.jsxs)("div",{className:"mb-4 px-4 py-3 rounded-xl bg-secondary/40 border border-border/50",children:[(0,e.jsxs)("div",{className:"flex items-baseline justify-between mb-3",children:[(0,e.jsx)("p",{className:"text-sm font-semibold",children:r.plan_name}),(0,e.jsxs)("p",{className:"text-sm font-semibold",children:["$",(r.price_monthly_cents/100).toFixed(0),(0,e.jsx)("span",{className:"text-xs font-normal text-muted-foreground",children:"/mo"})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,e.jsx)("span",{className:"text-muted-foreground line-through tabular-nums",children:r.limit_unit==="currency_cents"?ie(r.current_limit):r.current_limit.toLocaleString()}),(0,e.jsx)(xe,{className:"h-3.5 w-3.5 text-primary shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{className:"font-semibold tabular-nums",children:r.new_limit===null?"Unlimited":r.limit_unit==="currency_cents"?ie(r.new_limit):r.new_limit.toLocaleString()}),(0,e.jsx)("span",{className:"text-muted-foreground",children:r.limit_unit==="currency_cents"?"of generation/mo":`${r.resource_label}${r.per_month===!1?"":"/mo"}`})]})]}),s&&(0,e.jsx)("div",{className:"mb-3 px-3 py-2 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:s}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(M,{onClick:n,disabled:a,className:"w-full h-10 text-sm font-semibold",children:a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)($,{className:"h-4 w-4 animate-spin mr-2","aria-hidden":"true"}),"Upgradingâ¦"]}):`Upgrade to ${r.plan_name}`}),r.wallet_usable&&(0,e.jsx)("button",{type:"button",onClick:i,disabled:a,className:"w-full h-9 rounded-lg text-sm font-medium text-muted-foreground hover:text-foreground border border-border hover:border-border-strong hover:bg-secondary/50 transition-all disabled:opacity-50",children:"Add credits instead"}),(0,e.jsx)("p",{className:"text-[11px] text-center text-muted-foreground",children:"Prorated against your current plan. Takes effect immediately."})]})]}),ht=({walletBalance:r,loading:t,paymentMethods:a,selectedPaymentMethod:s,selectedMethod:n,selectedAmount:i,customAmount:c,effectiveAmountCents:p,isValidAmount:x,error:f,dropdownOpen:b,setSelectedAmount:y,setCustomAmount:g,setSelectedPaymentMethod:v,setDropdownOpen:j,onCharge:E})=>t?(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 gap-3",children:[(0,e.jsx)($,{className:"h-6 w-6 animate-spin text-primary","aria-hidden":"true"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mb-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-2.5",children:[(0,e.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Amount"}),r!==null&&(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Balance:"," ",(0,e.jsxs)("span",{className:"font-medium text-foreground",children:["$",(r/100).toFixed(2)]})]})]}),(0,e.jsx)("div",{className:"grid grid-cols-4 gap-1.5 mb-2.5",children:ct.map(m=>(0,e.jsxs)("button",{type:"button",onClick:()=>{y(m),g("")},className:I("h-9 rounded-lg text-sm font-medium transition-all border",!c&&i===m?"bg-primary/15 border-primary/40 text-primary":"bg-secondary/50 border-border hover:border-border-strong hover:bg-surface-hover"),children:["$",m/100]},m))}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,e.jsx)("input",{type:"number",min:"10",max:"500",step:"1",placeholder:"Custom amount (10â500)",value:c,onChange:m=>{g(m.target.value)},className:"w-full pl-7 pr-3 py-2 text-sm rounded-lg border border-border bg-background focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary/50"})]})]}),a.length>0&&(0,e.jsxs)("div",{className:"mb-4",children:[(0,e.jsx)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:"Payment method"}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>j(!b),className:"w-full flex items-center justify-between px-3 py-2 rounded-lg border border-border bg-background hover:bg-secondary/50 transition-colors text-left",children:[n?(0,e.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,e.jsx)("div",{className:"w-8 h-5 bg-secondary rounded flex items-center justify-center text-[10px] font-bold uppercase",children:n.brand}),(0,e.jsxs)("span",{className:"text-sm",children:["···· ",n.last4,n.is_default&&(0,e.jsx)("span",{className:"ml-1.5 text-xs text-muted-foreground",children:"(Default)"})]})]}):(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"Select a card"}),(0,e.jsx)(Te,{className:I("h-4 w-4 text-muted-foreground transition-transform",b&&"rotate-180")}
8)]}),b&&(0,e.jsx)("div",{className:"absolute left-0 right-0 top-full mt-1 z-10 bg-card border border-border rounded-lg shadow-lg overflow-hidden",children:a.map(m=>(0,e.jsxs)("button",{type:"button",onClick:()=>{v(m.id),j(!1)},className:I("w-full flex items-center gap-2.5 px-3 py-2 text-left hover:bg-secondary/50 transition-colors",m.id===s&&"bg-primary/5"),children:[(0,e.jsx)("div",{className:"w-8 h-5 bg-secondary rounded flex items-center justify-center text-[10px] font-bold uppercase",children:m.brand}),(0,e.jsxs)("span",{className:"text-sm flex-1",children:["···· ",m.last4,m.is_default&&(0,e.jsx)("span",{className:"ml-1.5 text-xs text-muted-foreground",children:"(Default)"})]}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[m.exp_month,"/",m.exp_year]})]},m.id))})]})]}),f&&(0,e.jsx)("div",{className:"mb-3 px-3 py-2 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive text-sm",children:f}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)(M,{onClick:E,disabled:!x,className:"w-full h-10 text-sm font-semibold",children:["Pay $",(p/100).toFixed(2)]}),(0,e.jsx)("button",{type:"button",onClick:()=>{window.open("/demo","_blank")},className:"w-full h-9 rounded-lg text-sm font-medium text-muted-foreground hover:text-foreground border border-border hover:border-border-strong hover:bg-secondary/50 transition-all",children:"No, show me examples"}),(0,e.jsx)("div",{className:"text-center",children:(0,e.jsx)("button",{type:"button",onClick:()=>{window.location.href="/dashboard/settings?tab=billing"},className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Manage payment methods"})})]})]}),ft=()=>(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 gap-3",children:[(0,e.jsx)($,{className:"h-6 w-6 animate-spin text-primary","aria-hidden":"true"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Processing paymentâ¦"})]}),bt=({amountCents:r,newBalance:t})=>(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[(0,e.jsx)("div",{className:"w-10 h-10 rounded-full bg-success/15 flex items-center justify-center",children:(0,e.jsx)(he,{className:"h-5 w-5 text-success"})}),(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)("h3",{className:"text-base font-semibold mb-0.5",children:"Credits Added"}),(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:["$",(r/100).toFixed(2)," added to your wallet",t!==null&&(0,e.jsxs)("span",{className:"text-success font-medium",children:[" ","· $",(t/100).toFixed(2)," total"]})]})]})]}),Pt=dt;export{Pt as default};
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.