1import{k as Y,R as E,O2 as F,O3 as X,O4 as I,O5 as y,O6 as J,O7 as j,O8 as V,O9 as L,Oa as Z,Ob as f,Oc as A,Od as $,Oe as ee,Of as N,Og as ae,Oh as se,Oi as te,Oj as re,Ok as ne,Ol as ie,Om as ce,On as de,Oo as le,Op as oe,Oq as me,Or as ue,Os as pe,Ot as be,Ou as v,Ov as z,Gu as he,r as d,m as e,Gy as u,Gz as p,a5 as b,GA as h,M7 as _e,GD as _,a3 as P,Ow as xe,O as T,xK as fe,Ox as ge,mS as g,Oy as ye,Oz as D,OA as je,OB as Ne,OC as Oe,OD as Ce,OE as ke,OF as ve,OG as Pe,OH as Te,OI as we,DC as Ee,OJ as Ie}from"./main-BVeaUmEJ.js";import{D as Le}from"./dashboard-layout-CHxiVnU7.js";import{d as Ae,f as S,a as ze,e as De}from"./billing-model-uylJWD-X.js";import{E as Se,a as Be,b as Re,c as Me}from"./empty-CAPKPhtk.js";import{B}from"./badge-jVzWArNv.js";import{T as Ge,a as qe,b as w,c as i,d as He,e as c}from"./table-D0Xxh5zF.js";import{I as Ke}from"./IconArrowRight-C3mkZMZZ.js";import{I as R}from"./IconCircleX-B9BKclBq.js";import{I as M}from"./IconCircleCheck-mRQv__4L.js";import{I as Qe}from"./IconReceipt-CkGpGqDC.js";import"./app.schema-B-SAvJF5.js";const Ue=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 8v4",key:"svg-1"}],["path",{d:"M12 16h.01",key:"svg-2"}]],We=Y("outline","alert-circle","AlertCircle",Ue),m=E.DashboardBilling;function Ye(a){return!a||!a.startsWith("/")||a.startsWith("//")?m:a==="/dashboard"||a.startsWith("/dashboard/")?a:m}function Fe(a){return a==="success"?F():a==="processing"?X():a==="timeout"?I():y()}function G(a,s){return a==="success"?J():a==="processing"?j():a==="timeout"?V():s?Z():L()}function Xe(a){return a==="success"?f():a==="processing"?A():a==="timeout"?I():y()}function Je(a){return a==="success"?{badgeClassName:"bg-accent-emerald-bg text-accent-emerald",iconClassName:"text-accent-emerald",panelClassName:"bg-accent-emerald-bg"}:a==="processing"?{badgeClassName:"bg-accent-sky-bg text-accent-sky",iconClassName:"text-accent-sky",panelClassName:"bg-accent-sky-bg"}:a==="timeout"?{badgeClassName:"bg-accent-orange-bg text-accent-orange",iconClassName:"text-accent-orange",panelClassName:"bg-accent-orange-bg"}:{badgeClassName:"bg-destructive/10 text-destructive",iconClassName:"text-destructive",panelClassName:"bg-destructive/10"}}function Ve(a){return a==="subscription"?$():ee()}function Ze(a){return a==="active"?ae():a==="trialing"?se():a==="completed"?te():a==="processing"?A():a==="canceled"?re():a==="failed"?ne():a==="incomplete"?ie():a==="incomplete_expired"?ce():a==="past_due"?de():a==="paused"?le():a==="refunded"?oe():a==="unpaid"?me():a}function $e(a){return a?a==="year"?ue():pe():null}function q(a){return a?a.split(/[-_\s]+/).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" "):N()}function ea(a,s){const t=!!s?.subscription;return[{key:"checkout",title:be(),description:s?.payment?.sessionId?j():L(),state:s?.payment?.sessionId?"completed":"failed"},{key:"verification",title:f(),description:G(a,!!s?.payment?.sessionId),state:a==="success"?"completed":a==="processing"||a==="timeout"?"current":"failed"},{key:"account-update",title:t?z():v(),description:t?f():v(),state:a==="success"?"completed":a==="failed"?"pending":"current"}]}const aa=ea,sa=2e3,ta=6e4;function ra({status:a}){switch(a){case"processing":return e.jsx(g,{className:"size-12 shrink-0 animate-spin text-accent-sky"});case"success":return e.jsx(M,{className:"size-12 shrink-0 text-accent-emerald"});case"failed":return e.jsx(R,{className:"size-12 shrink-0 text-destructive"});case"timeout":return e.jsx(We,{className:"size-12 shrink-0 text-accent-orange"});default:return e.jsx(g,{className:"size-12 shrink-0 text-muted-foreground animate-spin"})}}function H(a){return De(a)??N()}function na({completionStatus:a}){if(!a.payment)return e.jsx(Se,{className:"min-h-40 border border-dashed",children:e.jsxs(Be,{children:[e.jsx(Re,{variant:"icon",children:e.jsx(Qe,{className:"size-4"})}),e.jsx(Me,{children:y()})]})});const s=a.payment;return e.jsxs(Ge,{children:[e.jsx(qe,{children:e.jsxs(w,{children:[e.jsx(i,{children:ye()}),e.jsx(i,{children:D()}),e.jsx(i,{children:je()}),e.jsx(i,{children:Ne()}),e.jsx(i,{children:Oe()}),e.jsx(i,{children:Ce()}),e.jsx(i,{children:ke()}),e.jsx(i,{children:ve()})]})}),e.jsx(He,{children:e.jsxs(w,{children:[e.jsx(c,{children:Ve(s.type)}),e.jsx(c,{children:q(s.planName)}),e.jsx(c,{className:"tabular-nums",children:S(s.creditsAmount)}),e.jsx(c,{className:"font-medium tabular-nums",children:ze(s.amount,s.currency)}),e.jsx(c,{children:e.jsx(B,{className:b(s.paid?"bg-accent-emerald-bg text-accent-emerald":"bg-accent-sky-bg text-accent-sky"),variant:"outline",children:Ze(s.status)})}),e.jsx(c,{className:"max-w-48 truncate text-muted-foreground",children:s.priceId}),e.jsx(c,{className:"max-w-48 truncate text-muted-foreground",children:s.sessionId??N()}),e.jsx(c,{children:H(s.updatedAt)})]})})]})}function ia({completionStatus:a}){if(!a.subscription)return null;const s=a.subscription,t=$e(s.interval);return e.jsxs(u,{className:"shadow-sm",children:[e.jsx(p,{children:e.jsx(h,{children:z()})}),e.jsxs(_,{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg border bg-background p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:D()}),e.jsx("p",{className:"mt-2 text-2xl font-semibold",children:q(s.planName)}),t?e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:t}):null]}),e.jsxs("div",{className:"rounded-lg border bg-background p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:Pe()}),e.jsx("p",{className:"mt-2 text-2xl font-semibold tabular-nums",children:H(s.currentPeriodEnd)}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[Te(),":"," ",S(s.creditsPerPeriod)]})]})]})]})}function ca({completionStatus:a,status:s}){const t=aa(s,a);return e.jsxs(u,{className:"shadow-sm",children:[e.jsx(p,{children:e.jsx(h,{children:we()})}),e.jsx(_,{className:"grid grid-cols-1 gap-3",children:t.map(n=>{const r=n.state==="completed"?"bg-accent-emerald-bg text-accent-emerald":n.state==="current"?"bg-accent-sky-bg text-accent-sky":n.state==="failed"?"bg-destructive/10 text-destructive":"bg-muted text-muted-foreground";return e.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-3 rounded-lg border bg-background p-4",children:[e.jsx("div",{className:b("flex size-8 items-center justify-center rounded-full text-sm font-semibold",r),children:n.state==="completed"?e.jsx(M,{className:"size-4"}):n.state==="failed"?e.jsx(R,{className:"size-4"}):n.state==="current"?e.jsx(g,{className:"size-4 animate-spin"}):e.jsx("span",{children:"3"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:n.title}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:n.description})]})]},n.key)})})]})}function da({sessionId:a,callback:s=m}){const t=he(),n=Ye(s),[r,O]=d.useState(()=>
1a?"processing":"failed"),[x,K]=d.useState(null),l=d.useRef(!1),C=d.useRef(0);d.useEffect(()=>{if(!a||r!=="processing")return;l.current=!1,C.current=Date.now(),(async()=>{for(;!l.current&&Date.now()-C.current<ta;){try{const o=await Ae({data:{sessionId:a}});if(K(o),o?.isPaid){O("success"),l.current=!0;return}}catch{}await new Promise(o=>setTimeout(o,sa))}l.current||O("timeout")})()},[a,r]),d.useEffect(()=>{if(r!=="success")return;(async()=>(await t.invalidateQueries({queryKey:["currentPlan"]}),await t.invalidateQueries({queryKey:["dashboard","billing"]}),await t.invalidateQueries({queryKey:["dashboard","credits"]})))()},[r,t]);const Q=Fe(r),U=G(r,!!a),k=Je(r);return e.jsxs("div",{className:"flex flex-col gap-4 lg:gap-6",children:[e.jsxs(u,{className:"shadow-sm",children:[e.jsx(p,{className:"gap-4",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:b("flex size-16 shrink-0 items-center justify-center rounded-2xl",k.panelClassName),children:e.jsx(ra,{status:r})}),e.jsxs("div",{children:[e.jsx(h,{children:Q}),e.jsx(_e,{className:"mt-2",children:U})]})]}),e.jsx(B,{className:b(k.badgeClassName),variant:"outline",children:Xe(r)})]})}),e.jsxs(_,{className:"flex flex-wrap gap-2",children:[e.jsxs(P,{render:e.jsx(T,{to:n}),children:[xe(),e.jsx(Ke,{className:"size-4"})]}),e.jsx(P,{variant:"outline",render:e.jsx(T,{to:"/ai-image-generator"}),children:fe()})]})]}),e.jsxs(u,{className:"shadow-sm",children:[e.jsx(p,{children:e.jsx(h,{children:ge()})}),e.jsx(_,{children:e.jsx(na,{completionStatus:x??{isPaid:!1,payment:null,subscription:null}})})]}),e.jsx(ia,{completionStatus:x??{isPaid:!1,payment:null,subscription:null}}),e.jsx(ca,{completionStatus:x,status:r})]})}function ya(){const a=Ee({from:"/dashboard/payment"});return e.jsx(Le,{title:Ie(),description:j(),children:e.jsx(da,{sessionId:a.session_id,callback:a.callback??E.DashboardBilling})})}
1export{ya as component};
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.