1import{j as e}from"./vendor-markdown-DIW4cXdl.js";import{r as o,d as C,L as Y,m as J}from"./vendor-react-DISSCkJ-.js";import{ab as Q,ah as X,a as ee,y as N,ai as te,aj as D,ak as K,al as $,g as b,am as B,h as I,u as se,t as P,an as M,v as Z,j as ae,ao as re,l as ne,ap as le,a1 as ie}from"./index-C1i21spu.js";import{I as O,m as ce}from"./SpinnerGap.es-C0U5IjJ1.js";import{a as oe}from"./addons-oAkdH_Cg.js";import{g as de}from"./subscriptionHelpers-MZe8RIPJ.js";import{u as z}from"./useSubscriptionTransactions-C_dHZ6xA.js";import{s as xe}from"./ArrowRight.es-Cu74OTW4.js";import{s as _}from"./paymentGateways-Ce2RuokT.js";import{u as me,s as V,g as pe}from"./pricing-Di7We3sV.js";import{u as h}from"./vendor-i18n-B3RrgeHp.js";import{u as G}from"./useStripePaymentMethods-BA0y0BLa.js";import"./vendor-redux-BUAhM-cm.js";import"./vendor-clerk-BTxT0tL0.js";import"./vendor-socket-DElUTK9t.js";import"./subscriptions-BsPvLMit.js";const ge=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M228,144v64a12,12,0,0,1-12,12H40a12,12,0,0,1-12-12V144a12,12,0,0,1,24,0v52H204V144a12,12,0,0,1,24,0Zm-108.49,8.49a12,12,0,0,0,17,0l40-40a12,12,0,0,0-17-17L140,115V32a12,12,0,0,0-24,0v83L96.49,95.51a12,12,0,0,0-17,17Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M216,48V208H40V48A16,16,0,0,1,56,32H200A16,16,0,0,1,216,48Z",opacity:"0.2"}),o.createElement("path",{d:"M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40A8,8,0,0,0,168,96H136V32a8,8,0,0,0-16,0V96H88a8,8,0,0,0-5.66,13.66Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M222,144v64a6,6,0,0,1-6,6H40a6,6,0,0,1-6-6V144a6,6,0,0,1,12,0v58H210V144a6,6,0,0,1,12,0Zm-98.24,4.24a6,6,0,0,0,8.48,0l40-40a6,6,0,0,0-8.48-8.48L134,129.51V32a6,6,0,0,0-12,0v97.51L92.24,99.76a6,6,0,0,0-8.48,8.48Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M220,144v64a4,4,0,0,1-4,4H40a4,4,0,0,1-4-4V144a4,4,0,0,1,8,0v60H212V144a4,4,0,0,1,8,0Zm-94.83,2.83a4,4,0,0,0,5.66,0l40-40a4,4,0,1,0-5.66-5.66L132,134.34V32a4,4,0,0,0-8,0V134.34L90.83,101.17a4,4,0,0,0-5.66,5.66Z"}))]]),W=o.forwardRef((t,a)=>o.createElement(Q,{ref:a,...t,weights:ge}));W.displayName="DownloadSimpleIcon";const ue=W;function he(t,a,l={}){let s,r,i,x;const{leading:d=!1,trailing:g=!0}=l,n=()=>{x=t.apply(i,r),r=i=void 0},m=function(...c){r=c,i=this;const u=d&&!s;return clearTimeout(s),s=setTimeout(()=>{s=null,g&&!u&&n()},a),u&&n(),x};return m.cancel=()=>{clearTimeout(s),s=r=i=null},m}function be(t,a=300,l={}){const s=o.useRef(t);s.current=t;const r=o.useMemo(()=>he((...d)=>s.current(...d),a,l),[a,JSON.stringify(l)]);return o.useEffect(()=>()=>{r&&typeof r.cancel=="function"&&r.cancel()},[r]),r}function fe(){const[t,a]=o.useState(null),[l,s]=o.useState(null),[r,i]=o.useState(!1),[x,d]=o.useState(null);return o.useEffect(()=>{const n=new URLSearchParams(window.location.search).get("session_id");if(!n)return;X("stripe_session_id",n),(async()=>{i(!0),d(null);try{const c=await ee.get("/api/v1/payments/stripe/subscriptions",{params:{session_id:n}}),u=c?.data?.data||c?.data||{};s(u),a(u.payment_status||u.status),u.payment_status==="paid"||u.status==="complete"?N.success("Payment successful! Updating your account..."):u.payment_status==="unpaid"?N.warning("Payment incomplete. Please retry checkout."):u.status==="expired"&&N.info("Checkout session expired. Please try again.")}catch(c){console.error("Error fetching Stripe session:",c),d("Failed to verify payment status."),N.error("Unable to check payment status. Please try again.")}finally{i(!1);const c=new URL(window.location.href);c.searchParams.delete("session_id"),window.history.replaceState({},"",c.toString())}})()},[]),{status:t,meta:l,loading:r,error:x}}const R=[{Icon:D,labelKey:"billing.emptyFeatureWebsites",label:"Managed website hosting"},{Icon:O,labelKey:"billing.emptyFeatureImages",label:"AI image generation"},{Icon:K,labelKey:"billing.emptyFeatureBlogs",label:"AI blog writing"},{Icon:$,labelKey:"billing.emptyFeatureLogos",label:"AI logo creation"}];function q(){const{t}=h(),a=C(),{currency:l,gateway:s}=me(),{data:r=[]}=te(),i=o.useMemo(()=>r.filter(n=>n.tier!=="free"&&!n.isCustom&&n.interval==="monthly"&&n.pricing?.length>0).map(n=>({plan:n,pricing:V(n.pricing,{currency:l,gateway:s,interval:"monthly"})})).filter(n=>n.pricing?.amount!=null).sort((n,m)=>n.pricing.amount-m.pricing.amount)[0]??null,[r,l,s]),x=()=>
1{if(!i){a("/pricing");return}const n=V(i.plan.pricing,{currency:l,gateway:s,interval:"monthly",strict:s===_.STRIPE}),m=pe(s,{plan:i.plan,pricing:n,currency:l}),c=s===_.STRIPE&&!n?.gatewayPriceId;if(!m||c){N.error("Pricing unavailable. Please select a plan manually."),a("/pricing");return}a(m)},d=i?.pricing?.amount??null,g=i?.pricing?.currency??l;return e.jsxs("div",{className:"glass-card card-entrance overflow-hidden",children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsxs("div",{className:"border-b border-[var(--color-glass-border)] px-5 py-5",style:{backgroundColor:"color-mix(in srgb, var(--color-primary) 8%, transparent)"},children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.08em] text-[var(--color-primary)] mb-1.5",children:t("billing.noActivePlan","No active plan")}),e.jsx("h2",{className:"text-[20px] font-extrabold tracking-tight text-[var(--color-text-primary)] leading-tight",children:t("billing.emptyHeadline","Unlock the full platform")}),e.jsx("p",{className:"text-[12px] text-[var(--color-text-secondary)] mt-1.5",children:t("billing.emptySubtitle","Websites, AI content, and managed hosting in one plan.")})]}),e.jsx("div",{className:"border-b border-[var(--color-glass-border)] px-5 py-3 grid grid-cols-2 gap-2",children:R.map(n=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n.Icon,{size:13,weight:"fill",className:"text-[var(--color-primary)] flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-[var(--color-text-secondary)]",children:t(n.labelKey,n.label)})]},n.labelKey))}),e.jsxs("div",{className:"px-5 py-4 flex gap-3",children:[e.jsxs(b,{type:"primary",mt:"",onClick:x,children:[t("billing.getStarted","Get started"),e.jsx(xe,{size:14})]}),e.jsx(b,{mt:"",onClick:()=>a("/pricing"),children:t("billing.viewPlans","View Plans")})]})]}),e.jsxs("div",{className:"hidden sm:grid sm:grid-cols-[1fr_185px] lg:grid-cols-[1fr_230px]",children:[e.jsxs("div",{className:"border-r border-[var(--color-glass-border)] px-6 py-5 lg:px-8 lg:py-7 flex flex-col justify-between",style:{backgroundColor:"color-mix(in srgb, var(--color-primary) 8%, transparent)"},children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.08em] text-[var(--color-primary)] mb-2",children:t("billing.noActivePlan","No active plan")}),e.jsx("h2",{className:"text-[22px] lg:text-[28px] font-extrabold tracking-tight text-[var(--color-text-primary)] leading-tight",children:t("billing.emptyHeadline","Unlock the full platform")}),e.jsx("p",{className:"text-[11px] lg:text-[12px] text-[var(--color-text-secondary)] mt-1.5",children:t("billing.emptySubtitle","Websites, AI content, and managed hosting in one plan.")})]}),e.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2.5 mt-5 lg:mt-6",children:R.map(n=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n.Icon,{size:13,weight:"fill",className:"text-[var(--color-primary)] flex-shrink-0"}),e.jsx("span",{className:"text-[11px] lg:text-[12px] text-[var(--color-text-secondary)]",children:t(n.labelKey,n.label)})]},n.labelKey))})]}),e.jsxs("div",{className:"px-5 py-5 lg:px-7 lg:py-7 flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-[var(--color-text-secondary)] uppercase tracking-[0.06em] font-medium mb-1",children:t("billing.startingFrom","Starting from")}),e.jsx("p",{className:"text-[30px] lg:text-[38px] font-extrabold tracking-tight text-[var(--color-text-primary)] leading-none",children:d!=null?B(d,g):"â"}),e.jsx("p",{className:"text-[11px] lg:text-[12px] text-[var(--color-text-secondary)] mt-1.5",children:t("billing.perMonth","/ month")})]}),e.jsxs("div",{className:"flex flex-col gap-2 lg:gap-2.5 mt-5",children:[e.jsx(b,{type:"primary",mt:"",onClick:x,children:t("billing.getStarted","Get started")}),e.jsx(b,{mt:"",onClick:()=>a("/pricing"),children:t("billing.viewPlans","View Plans")})]})]})]})]})}const ye={active:"bg-green-500/10 text-green-600",trialing:"bg-blue-500/10 text-blue-600",past_due:"bg-yellow-500/10 text-yellow-600",canceled:"bg-red-500/10 text-red-600",expired:"bg-red-500/10 text-red-600",paused:"bg-gray-500/10 text-gray-500",incomplete:"bg-orange-500/10 text-orange-600",upgraded:"bg-teal-500/10 text-teal-600",downgraded:"bg-teal-500/10 text-teal-600"};function y({children:t}){return e.jsx("p",{className:"text-[9px] sm:text-[10px] font-medium uppercase tracking-[0.06em] text-[var(--color-text-secondary)] mb-1",children:t})}function v({children:t}){return e.jsx("p",{className:"text-[12px] sm:text-[13px] lg:text-[14px] font-semibold text-[var(--color-text-primary)]",children:t})}function ve(){const{t}=h(),a=C(),{data:l}=I(),s=l?.currentSubscription??null,{data:r=[]}=z(s?._id||null),{data:i=[]}=se({queryKey:["myAddons"],queryFn:oe});if(!s)return e.jsx(q,{});const x=r[0]??null,{fields:d,title:g,warning:n,interval:m}=de(t,s,x),c={};d.forEach(p=>{p.label===t("billing.plan")?c.plan=p.value:p.label===t("billing.status")?c.status=p.value:p.label===t("billing.price")?c.price=p.value:p.label===t("billing.renewalDate")?c.renewal=p.value:p.label===t("billing.paymentGateway")?c.gateway=p.value:p.label===t("billing.subscribedOn")&&(c.subscribedOn=p.value)});const u=(s?.status??"active").toLowerCase(),A=ye[u]||"bg-neutral-500/10 text-neutral-500",w=i.filter(p=>p.addOnId&&(!p.expiresAt||new Date(p.expiresAt)>new Date)),E=g||c.plan||t("billing.activeSubscription"),L=m==="yearly"?t("billing.perYear","/ year"):t("billing.perMonth","/ month");return e.jsxs("div",{className:"glass-card card-entrance overflow-hidden",children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsxs("div",{className:"border-b border-[var(--color-glass-border)] px-5 py-4 flex items-start justify-between gap-3",style:{backgroundColor:"color-mix(in srgb, var(--color-primary) 8%, transparent)"},children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 flex-wrap",children:[e.jsx("h2",{className:"text-[20px] font-extrabold tracking-tight text-[var(--color-text-primary)] leading-none",children:E}),e.jsx("span",{className:`text-[10px] font-semibold px-2 py-0.5 rounded-full leading-none flex-shrink-0 ${A}`,children:P(u)})]}),e.jsxs("p",{className:"text-[11px] text-[var(--color-text-secondary)]",children:[t("billing.via","via")," ",c.gateway," · ",c.subscribedOn]}),n&&e.jsx("p",{className:"text-[12px] font-medium text-yellow-500 mt-1.5",children:n})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsx("p",{className:"text-[24px] font-extrabold tracking-tight text-[var(--color-text-primary)] leading-none",children:c.price}),M(m)&&e.jsx("p",{className:"text-[11px] text-[var(--color-text-secondary)] mt-1",children:L})]})]}),e.jsx("div",{className:"border-b border-[var(--color-glass-border)] px-5 py-3",children:e.jsxs("div",{className:"flex",children:[e.jsxs("div",{className:"flex-1 pr-3 border-r border-[var(--color-glass-border)]",children:[e.jsx(y,{children:"Renews"}),e.jsx(v,{children:c.renewal})]}),e.jsxs("div",{className:"flex-1 px-3 border-r border-[var(--color-glass-border)]",children:[e.jsx(y,{children:"Gateway"}),e.jsx(v,{children:c.gateway})]}),e.jsxs("div",{className:"flex-1 pl-3",children:[e.jsx(y,{children:"Add-ons"}),e.jsxs(v,{children:[w.length," active"]})]})]})}),e.jsxs("div",{className:"px-5 py-4 flex gap-3",children:[e.jsx(b,{type:"primary",mt:"",onClick:()=>a("/billing/manage"),children:t("billing.manage","Manage")}),e.jsx(b,{mt:"",onClick:()=>a("/addons"),children:t("billing.addons","Add-ons")})]})]}),e.jsxs("div",{className:"hidden sm:grid sm:grid-cols-[1fr_185px] lg:grid-cols-[1fr_230px]",children:[e.jsxs("div",{className:"border-r border-[var(--color-glass-border)] px-6 py-5 lg:px-8 lg:py-
17 flex flex-col justify-between",style:{backgroundColor:"color-mix(in srgb, var(--color-primary) 8%, transparent)"},children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsx("h2",{className:"text-[22px] lg:text-[28px] font-extrabold tracking-tight text-[var(--color-text-primary)] leading-none",children:E}),e.jsx("span",{className:`text-[10px] font-semibold px-2.5 py-0.5 rounded-full leading-none flex-shrink-0 ${A}`,children:P(u)})]}),e.jsxs("p",{className:"text-[11px] lg:text-[12px] text-[var(--color-text-secondary)]",children:[t("billing.via","via")," ",c.gateway," · ",t("billing.subscribedOn")," ",c.subscribedOn]}),n&&e.jsx("p",{className:"text-[12px] font-medium text-yellow-500 mt-2",children:n})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-5 lg:gap-8 mt-5 lg:mt-6",children:[e.jsxs("div",{children:[e.jsx(y,{children:t("billing.renewalDate")}),e.jsx(v,{children:c.renewal})]}),e.jsxs("div",{children:[e.jsx(y,{children:t("billing.paymentGateway")}),e.jsx(v,{children:c.gateway})]}),e.jsxs("div",{children:[e.jsx(y,{children:t("billing.activeAddons")}),e.jsxs(v,{children:[w.length," active"]})]})]}),w.length>0&&e.jsx("div",{className:"hidden lg:flex flex-wrap gap-1.5 mt-3",children:w.map(p=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] text-[var(--color-text-secondary)] bg-[var(--color-glass-bg)] border border-[var(--color-glass-border)] rounded-md px-2.5 py-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 flex-shrink-0"}),p.addOnId?.name,p.expiresAt&&e.jsxs("span",{className:"opacity-60",children:["· Exp. ",Z(p.expiresAt,"short")]})]},p._id||p.addOnId?._id))})]})]}),e.jsxs("div",{className:"px-5 py-5 lg:px-7 lg:py-7 flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[30px] lg:text-[38px] font-extrabold tracking-tight text-[var(--color-text-primary)] leading-none",children:c.price}),M(m)&&e.jsx("p",{className:"text-[11px] lg:text-[12px] text-[var(--color-text-secondary)] mt-1.5",children:L})]}),e.jsxs("div",{className:"flex flex-col gap-2 lg:gap-2.5 mt-5",children:[e.jsxs(b,{type:"primary",mt:"",onClick:()=>a("/billing/manage"),children:[e.jsx("span",{className:"lg:hidden",children:t("billing.manage","Manage")}),e.jsx("span",{className:"hidden lg:inline",children:t("billing.manageSubscription")})]}),e.jsx(b,{mt:"",onClick:()=>a("/addons"),children:t("billing.browseAddons")})]})]})]})]})}function je(t={}){if(!t||typeof t!="object")return"";const{line1:a="",line2:l="",city:s="",state:r="",postal_code:i="",country:x=""}=t,d=[],g=[a.trim(),l.trim()].filter(Boolean).join(", ");if(g&&d.push(g),s||r||i){let c="";s&&(c+=s.trim()),r&&(c+=(s?", ":"")+r.trim()),i&&(c+=(s||r?" ":"")+i.trim()),c&&d.push(c)}let m=(x||"").trim();if(m){try{typeof Intl<"u"&&Intl.DisplayNames?m=new Intl.DisplayNames(["en"],{type:"region"}).of(m)||m:m={US:"United States",CA:"Canada",GB:"United Kingdom"}[m.toUpperCase()]||m}catch{}d.push(m)}return d.join(` <br /> 2`)}function k({title:t,children:a,className:l=""}){return e.jsxs("div",{className:`glass-card card-entrance p-6 ${l}`,children:[t&&e.jsx("h2",{className:"text-[16px] font-semibold text-[var(--color-text-primary)] mb-4",children:t}),a]})}function Ne(){const{t}=h(),{data:a,isLoading:l}=G();if(!a||!a.length)return null;const s=a.find(r=>r.default)||a[0];return l||!s||!s.address?null:e.jsxs(k,{title:t("billing.billingAddress"),className:"flex flex-col",children:[e.jsx("p",{className:"text-sm text-[var(--color-text-secondary)]",dangerouslySetInnerHTML:{__html:je(s.address)}}),e.jsx("p",{className:"mt-2 text-xs text-[var(--color-text-secondary)] italic",children:t("billing.addressInfo")})]})}function we(){const{t}=h(),a=ae(),{data:l}=I(),s=l?.currentSubscription?._id,{data:r=[],isLoading:i}=z(s);if(i||r.length===0)return null;const x=r.find(c=>c.transactionType==="subscription"),d=x?.metadata?.invoiceId||"N/A",g=x?.metadata?.invoiceLink||"#",n=a(x?.createdAt,"short"),m=B(x?.amount,x?.currency);return e.jsxs(k,{title:t("billing.latestInvoice"),className:"flex flex-col",children:[e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsxs("p",{className:"font-medium text-[var(--color-text-primary)]",children:[t("billing.invoice")," #",d]}),e.jsxs("p",{className:"text-[var(--color-text-secondary)] mt-1",children:[t("billing.issued")," ",n]}),e.jsx("p",{className:"text-[var(--color-text-secondary)]",children:m})]}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-[13px] font-medium text-[var(--color-primary)] hover:underline active:scale-[0.97] transition-transform duration-100",children:[e.jsx(ue,{size:14,weight:"bold"})," ",t("billing.download")]})})]})}function H(){const{t}=h();return e.jsxs("div",{className:"glass-card card-entrance p-6 flex items-start gap-4",children:[e.jsx(re,{size:22,weight:"fill",className:"text-[var(--color-primary)] flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-[15px] font-semibold text-[var(--color-text-primary)]",children:t("billing.needHelp")}),e.jsx("p",{className:"text-[13px] text-[var(--color-text-secondary)] mt-0.5",children:t("billing.helpInfo")}),e.jsxs(Y,{to:"/help",className:"mt-2 inline-block text-[13px] font-medium text-[var(--color-primary)] hover:underline",children:[t("billing.goToSupport")," â"]})]})]})}function T({theme:t="dark"}){const a=t==="dark",l=a?"bg-[linear-gradient(135deg,#0b0e14,#11161f)]":"bg-[linear-gradient(135deg,#292929,#7c7c
27c)]",s=a?"bg-gray-700/60":"bg-gray-300/60";return e.jsxs("div",{className:`relative rounded-2xl overflow-hidden animate-pulse ${l} 3 text-white p-6 aspect-[1.58/1] flex flex-col justify-between shadow-lg`,children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("div",{className:`h-6 w-12 ${s} rounded`}),e.jsx("div",{className:`h-6 w-6 ${s} rounded`})]}),e.jsx("div",{className:"mt-6",children:e.jsx("div",{className:`h-6 w-3/4 ${s} rounded`})}),e.jsxs("div",{className:"flex justify-between items-center mt-6",children:[e.jsx("div",{className:`h-4 w-24 ${s} rounded`}),e.jsx("div",{className:`h-4 w-10 ${s} rounded`})]})]})}function ke(){const{t}=h(),a=C();return e.jsxs("button",{onClick:()=>a("/billing/add-payment-method"),className:"rounded-2xl border border-dashed border-[var(--color-glass-border)] p-6 text-sm text-[var(--color-text-secondary)] hover:bg-[var(--color-glass-bg)] transition flex items-center justify-center aspect-[1.58/1] cursor-pointer hover:opacity-90",children:["+ ",t("billing.addPaymentMethod")]})}const Se={visa:"/logos/visa.svg",mastercard:"/logos/mastercard.svg",amex:"/logos/amex.svg",discover:"/logos/discover.svg",paypal:"/logos/paypal.svg",applepay:"/logos/applepay.svg",amazonpay:"/logos/amazonpay.svg",bitcoin:"/logos/bitcoin.svg",bitpay:"/logos/bitpay.svg",diners:"/logos/diners.svg",jcb:"/logos/jcb.svg",maestro:"/logos/maestro.svg",mir:"/logos/mir.svg",rupay:"/logos/rupay.svg",unionpay:"/logos/unionpay.svg"};function Ce(t){const a=t?.toLowerCase()||"";return Se[a]||"/logos/unknown.svg"}function Ie({card:t,theme:a}){const{t:l}=h(),s=Ce(t.brand),r=a==="dark"?"bg-[linear-gradient(135deg,#0b0e14,#11161f)]":"bg-[linear-gradient(135deg,#292929,#7c7c7c)]";return e.jsxs("div",{className:`relative rounded-2xl overflow-hidden text-white ${r} p-6 aspect-[1.58/1] flex flex-col justify-between shadow-lg`,children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("div",{className:"bg-white rounded px-2 py-1",children:e.jsx("img",{src:s,alt:t.brand,className:"h-5 w-auto object-contain"})}),e.jsx(ne,{size:24,className:"opacity-80 text-white"})]}),e.jsxs("p",{className:"tracking-widest text-xl font-mono mt-6 text-white",children:["**** **** **** ",t.last4]}),e.jsxs("div",{className:"flex justify-between items-center text-sm opacity-90 mt-6 text-white",children:[e.jsx("span",{children:t.name?.toUpperCase()||l("billing.cardHolderName")}),e.jsxs("span",{children:[t.exp_month,"/",t.exp_year]})]})]})}function Ae(){const{t}=h(),{getAppliedTheme:a}=o.useContext(le),l=a(),[s]=J(),r=s.get("session_id"),{data:i,isLoading:x,refetch:d}=G({sessionId:r});if(x)return e.jsx(k,{title:t("billing.paymentMethods"),children:e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(T,{theme:l}),e.jsx(T,{theme:l})]})});if(!i||!i.length)return null;const g=i.find(n=>n?.default===!0)||i[0];return e.jsx(k,{title:t("billing.paymentMethods"),children:e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(Ie,{card:g,theme:l}),e.jsx(ke,{onSuccess:d})]})})}const Ee={websites:"#247fc3",images:"#8b5cf6",blogs:"#10b981",logos:"#f59e0b"},Le=[{key:"websites",labelKey:"billing.websites",Icon:D},{key:"images",labelKey:"billing.aiImages",Icon:O},{key:"blogs",labelKey:"billing.aiBlogs",Icon:K},{key:"logos",labelKey:"billing.aiLogos",Icon:$}],f=90,S=34,j=f/2,U=2*Math.PI*S,F=6;function Pe({used:t,limit:a,color:l,Icon:s}){const r=a>0?Math.min(t/a,1):0,i=r>=.9?"#ef4444":l,[x,d]=o.useState(0);o.useEffect(()=>{const n=requestAnimationFrame(()=>d(r));return()=>cancelAnimationFrame(n)},[r]);const g=U*(1-x);return e.jsxs("div",{className:"relative",style:{width:f,height:f},children:[e.jsxs("svg",{width:f,height:f,viewBox:`0 0 ${f} ${f}`,"aria-hidden":"true",children:[e.jsx("circle",{cx:j,cy:j,r:S,fill:"none",stroke:"var(--color-glass-border)",strokeWidth:F}),e.jsx("circle",{cx:j,cy:j,r:S,fill:"none",stroke:i,strokeWidth:F,strokeLinecap:"round",strokeDasharray:U,strokeDashoffset:g,transform:`rotate(-90 ${j} ${j})`,style:{transition:"stroke-dashoffset 700ms cubic-bezier(0.22, 1, 0.36, 1)"}})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(s,{size:20,weight:"fill",style:{color:i}})})]})}function Me({metricKey:t,labelKey:a,Icon:l,used:s,limit:r}){const{t:i}=h(),x=Ee[t],d=g=>g>0?g:"â";return e.jsxs("div",{className:"flex flex-col items-center gap-2.5",children:[e.jsx(Pe,{used:s,limit:r,color:x,Icon:l}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.06em] text-[var(--color-text-secondary)] mb-0.5",children:i(a)}),e.jsxs("p",{className:"text-[15px] font-bold text-[var(--color-text-primary)] leading-none",children:[s,e.jsxs("span",{className:"text-[11px] font-normal text-[var(--color-text-secondary)]",children:[" ","/ ",d(r)]})]})]})]})}function _e(){const{t}=h(),{data:a}=ie(),l=a?.usage??{},s=a?.subscription,r=s?.nextUsageResetAt??s?.currentPeriodEnd;return e.jsxs("div",{className:"glass-card card-entrance p-6",children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-6",children:[e.jsx("h2",{className:"text-[15px] font-semibold text-[var(--color-text-primary)]",children:t("billing.usageSummary")}
3),r&&e.jsxs("p",{className:"text-[11px] text-[var(--color-text-secondary)]",children:[t("billing.creditsResetOn","Resets on")," ",Z(r,"short")]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:Le.map(({key:i,labelKey:x,Icon:d})=>e.jsx(Me,{metricKey:i,labelKey:x,Icon:d,used:l[i]?.used??0,limit:l[i]?.limit??0},i))})]})}function Ye(){const{t}=h(),{status:a,loading:l,error:s}=fe(),{data:r,refetch:i}=I(),x=be(()=>i(),800),d=o.useRef(null);if(o.useEffect(()=>{(a==="paid"||a==="complete")&&x()},[a,x]),o.useEffect(()=>{s&&s!==d.current&&(d.current=s,N.error(s)),s||(d.current=null)},[s]),l)return e.jsxs("div",{className:"max-w-[900px] mx-auto p-6 flex flex-col items-center justify-center min-h-[200px]",children:[e.jsx(ce,{className:"animate-spin text-[var(--color-primary)]",size:40}),e.jsx("p",{className:"mt-4 text-[var(--color-text-secondary)]",children:"Verifying your payment..."})]});const g=!!r?.currentSubscription;return e.jsxs("div",{className:"max-w-[900px] mx-auto p-6",children:[e.jsx("h1",{className:"text-[24px] font-bold leading-[36px] tracking-tight text-[var(--color-text-primary)]",children:t("billing.title")}),e.jsx("p",{className:"text-[16px] leading-[22px] text-[var(--color-text-secondary)] mt-1",children:t("billing.subtitle")}),g?e.jsxs("div",{className:"mt-6 space-y-6",children:[e.jsx(ve,{}),e.jsx(_e,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(we,{}),e.jsx(Ne,{})]}),e.jsx(Ae,{}),e.jsx(H,{})]}):e.jsxs("div",{className:"mt-6 space-y-6",children:[e.jsx(q,{}),e.jsx(H,{})]})]})}export{Ye 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.