1import{w as N,r as d,j as e}from"./index-rerlcPiF.js";const m="https://www.testflows.ai",g={sandbox:{clientToken:"test_e51945b7b6db451f34300fb992e",environment:"sandbox",successUrl:`${m}/checkout/success`,cancelUrl:`${m}/checkout/cancel`,displayMode:"inline",variant:"one-page",theme:"light",frameInitialHeight:"500",frameStyle:"width: 100%; min-width: 312px; background-color: transparent; border: none;"},production:{clientToken:"live_5800edea3ced694662f9f46232e",environment:"live",successUrl:`${m}/checkout/success`,cancelUrl:`${m}/checkout/cancel`,displayMode:"inline",variant:"one-page",theme:"light",frameInitialHeight:"500",frameStyle:"width: 100%; min-width: 312px; background-color: transparent; border: none;"}};function I(i){return i==="production"?g.production:g.sandbox}function j(i){const o=i.split(".");if(o.length<2)throw new Error("Invalid token format");const l=o[1].replace(/-/g,"+").replace(/_/g,"/"),n=atob(l);return JSON.parse(n)}const h="checkout-container";function E(){const[i]=N(),o=i.get("token"),[l,n]=d.useState("loading"),[f,c]=d.useState(null),u=d.useRef(!1);if(d.useEffect(()=>{if(!o){c("Missing checkout token."),n("error");return}let t;try{if(t=j(o),!t.userId||!t.email||!t.priceId)throw new Error("Token missing required fields: userId, email, priceId");console.log("[Checkout] Decoded token, userId=",t.userId,"environment=",t.environment)}catch(r){const s=r instanceof Error?r.message:"Invalid token.";c(s),n("error"),console.error("[Checkout] Error:",r);return}const a=I(t.environment),p=a.clientToken;if(!p){const r=t.environment==="production"?"LIVE":"SANDBOX";c(`Checkout is not configured. Set VITE_AIEASYAPPLY_CHECKOUT_PADDLE_CLIENT_TOKEN_${r} in your environment and rebuild.`),n("error");return}const b=a.successUrl,v=void 0,x=()=>{const r=window.Paddle;if(!r)return!1;try{const s=a.environment==="live"?"production":"sandbox";r.Environment.set(s),r.Initialize({token:p}),console.log("[Checkout] Paddle initialized",s);const k={displayMode:a.displayMode,variant:a.variant,theme:a.theme,successUrl:b,frameTarget:h,frameInitialHeight:a.frameInitialHeight,frameStyle:a.frameStyle};return r.Checkout.open({items:[{priceId:t.priceId,quantity:1}],customer:{email:t.email},customData:{userId:t.userId},settings:k}),console.log("[Checkout] Opening checkout"),u.current=!0,n("opened"),!0}catch(s){return console.error("[Checkout] Error:",s),u.current=!0,c(s instanceof Error?s.message:"Failed to open checkout."),n("error"),!0}};if(window.Paddle)x();else{const r=setInterval(()=>{window.Paddle&&(clearInterval(r),x())},100),s=setTimeout(()=>{clearInterval(r),u.current||(c("Checkout could not load. Please try again."),n("error"))},1e4);return()=>{clearInterval(r),clearTimeout(s)}}},[o]),l==="error")return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 p-4",children:e.jsxs("div",{className:"max-w-md w-full text-center",children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Checkout error"}),e.jsx("p",{className:"text-gray-600",children:f})]})});const y=["100 credits per month","AI contact discovery","Unlimited AI email regeneration","Priority processing","Future Gmail sending","Premium support"];return e.jsx("div",{className:"min-h-screen bg-gray-50 p-4",children:e.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[e.jsxs("section",{className:"rounded-xl border border-gray-200 bg-white p-6 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("img",{src:"/checkout-logo-aieasyapply.svg",alt:"aiEasyApply",className:"h-10 w-10 shrink-0"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900",children:"aiEasyApply.co"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Secure checkout"})]})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[e.jsx("span",{className:"inline-block rounded-full bg-primary/10 px-2.5 py-0.5 text-xs font-medium text-primary mb-2",children:"Most Popular"}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-2xl font-bold text-gray-900",children:"Pro"}),e.jsx("span",{className:"text-xl font-semibold text-gray-700",children:"$9.99"}),e.jsx("span",{className:"text-sm text-gray-500",children:"/ month"})]}),e.jsx("ul",{className:"mt-3 space-y-1.5 text-sm text-gray-600",children:y.map(t=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-primary"}),t]},t))})]})]}),l==="loading"&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-t-2 border-b-2 border-primary"})}),e.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-4 shadow-sm",children:[e.jsx("h2",{className:"text-sm font-medium text-gray-700 mb-3",children:"Payment details"}),e.jsx("div",{id:h,className:`${h} min-h-[500px]`,style:{minWidth:312}})]})]})})}export{E 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.