1import{j as e}from"./vendor-query-DoHIXVj8.js";import{r as o,h as Y,f as $,L as k}from"./vendor-react-B1CyA2bu.js";import{c as H,u as _,B as m,s as g,f as R,C as S,a as T,b as M,d as A,e as I,t as E,F as v}from"./index-Cn6nJhWG.js";import{A as z,a as O}from"./alert-DkhFZhUN.js";import{P as V}from"./PaymentMethodSelector-Ds-3b_L4.js";import{u as W}from"./useSubscription-BnXf106d.js";import{A as G}from"./AppleIAPButton-BAuFBP8D.js";import{a as J}from"./ga4-DvLWDuxV.js";import{a as K}from"./PromoRibbon-rXo-btpJ.js";import{I as Z}from"./input-DAbNkcMA.js";import{L as b}from"./loader-circle-Lrf5ROOc.js";import{A as Q}from"./arrow-left-BDHFhLAh.js";import{H as X}from"./heart-CEw_tAcA.js";import{C as ee}from"./credit-card-C4-R7HIg.js";import{C as se}from"./check-CEjPdstu.js";import{I as te}from"./info-CPwtjmVp.js";import{E as U}from"./external-link-D6FwjmNX.js";import"./vendor-supabase-Bxjw3GPQ.js";import"./vendor-ui-Dv9JeOyV.js";import"./badge-BQ5YkzSG.js";import"./platformPayments-CbC8KN8d.js";import"./platformDetection-D69HpErv.js";import"./smartphone-CaApHHC_.js";import"./wallet-C1nSr9sE.js";typeof globalThis.require!="function"&&(globalThis.require=function(){return null},window.require=globalThis.require);/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const re=H("Ticket",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]),ie=({onRedeemed:i})=>{const[n,y]=o.useState(""),[u,c]=o.useState(!1),{toast:p}=_(),h=async()=>{const l=n.trim();if(l){c(!0);try{const{data:f}=await g.auth.getSession();if(!f.session){p({title:"Sign in required",description:"Please sign in or create an account to redeem a coupon.",variant:"destructive"});return}const{data:s,error:r}=await g.functions.invoke("redeem-coupon",{body:{code:l}});if(r||!(s!=null&&s.success)){const d=(s==null?void 0:s.error)||(r==null?void 0:r.message)||"That coupon code isn't valid";p({title:"Coupon not applied",description:d,variant:"destructive"});return}p({title:"Coupon applied!",description:`Your ${s.tier} membership is now active. Enjoy YogiCurious!`}),y(""),i==null||i(s.tier)}catch(f){p({title:"Something went wrong",description:f instanceof Error?f.message:"Please try again.",variant:"destructive"})}finally{c(!1)}}};return e.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(re,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Have a coupon code?"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Z,{value:n,onChange:l=>y(l.target.value.toUpperCase()),placeholder:"Enter coupon code","aria-label":"Coupon code",disabled:u,onKeyDown:l=>{l.key==="Enter"&&h()}}),e.jsx(m,{onClick:h,disabled:u||!n.trim(),variant:"secondary",children:u?e.jsx(b,{className:"h-4 w-4 animate-spin"}):"Apply"})]})]})},L=()=>{var i;try{const n=window.Capacitor;return((i=n==null?void 0:n.isNativePlatform)==null?void 0:i.call(n))??!1}catch{return!1}},Ae=()=>{const[i,n]=o.useState(null),[y,u]=o.useState(!0),[c,p]=o.useState(null),[h,l]=o.useState(!1),[f]=Y(),s=f.get("tier")||"mindful",r=$(),{toast:d}=_(),{createPayment:q,loading:N}=W(i),P=o.useRef(!1),w=o.useRef(!1);o.useEffect(()=>{const t=setTimeout(()=>{l(L())},0);return()=>clearTimeout(t)},[]),o.useEffect(()=>{s!=="mindful"&&R("checkout_started",{tier:s})},[s]);const a={mindful:{id:"mindful",name:"Mindful",subscriptionTitle:"Mindful Free Membership",price:"Free",pricePerUnit:"Free forever",period:"",length:"",description:"Perfect for yoga beginners and local connections",features:["Match with local yogis","Mindful profile features","Message your matches","Find nearby studios","Book first dates"]},premium:{id:"premium",name:"Premium",subscriptionTitle:"Premium Monthly Subscription",price:"$9.99",pricePerUnit:"$9.99 per month",period:"month",length:"1 Month",description:"Enhanced features for serious practitioners",features:["Everything in Mindful","Video chat features","Cross-city matching (9 cities)","Premium events feed ($50+)","Priority customer support","Advanced matching filters","Unlimited studio access"]},wanderlust:{id:"wanderlust",name:"Wanderlust",subscriptionTitle:"Wanderlust Monthly Subscription",price:"$29.99",pricePerUnit:"$29.99 per month",period:"month",length:"1 Month",description:"Ultimate global yoga and travel experiences",features:["Everything in Premium","Global retreat access","Travel companion matching","International studio network","Concierge planning service","VIP retreat experiences"]}}[s];o.useEffect(()=>{(async()=>{const{data:{session:x}}=await g.auth.getSession();if(!x){const j=setTimeout(()=>{L()?u(!1):r(`/anonymous-purchase?tier=${s}`)},0);return()=>clearTimeout(j)}n(x.user),u(!1)})()},[r,s]);const B=t=>{p(t),t&&s!=="mindful"&&!P.current&&(P.current=!0,E("AddPaymentInfo",{value:v(s),currency:"USD",content_name:(t==null?void 0:t.provider)||(t==null?void 0:t.id)||"unknown",content_category:"subscription"}))},D=async()=>
6{if(!c||!i){d({title:"Payment method required",description:"Please select a payment method to continue.",variant:"destructive"});return}try{s!=="mindful"&&!w.current&&(w.current=!0,E("InitiateCheckout",{value:v(s),currency:"USD",content_name:s,content_category:"subscription",content_ids:[s],num_items:1},{capi:!0,userId:i==null?void 0:i.id}),J("begin_checkout",{value:v(s),currency:"USD",tier:s,items:[{item_id:s,item_name:s,quantity:1}]})),await q(s,c.provider);const t=sessionStorage.getItem("pendingConfirmation");if(t){const{userId:x,email:j,displayName:C,tier:F}=JSON.parse(t);await g.functions.invoke("send-signup-confirmation",{body:{userId:x,email:j,displayName:C,tier:F,isPromoCode:!1}}),sessionStorage.removeItem("pendingConfirmation"),d({title:"Payment successful!",description:"Please check your email to confirm your account. Once confirmed, you can start exploring studios!"})}else d({title:"Payment initiated",description:"You'll be redirected to complete payment. After payment, you'll find studios near you!"})}catch(t){console.error("Payment error:",t),d({title:"Payment failed",description:"There was an issue processing your payment. Please try again.",variant:"destructive"})}};return y?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-primary/5 via-background to-secondary/5 flex items-center justify-center",children:e.jsx(b,{className:"h-8 w-8 animate-spin text-primary"})}):a?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-primary/5 via-background to-secondary/5 flex items-center justify-center p-4 safe-area-top pt-8",children:e.jsxs("div",{className:"w-full max-w-2xl",children:[e.jsxs(m,{variant:"ghost",size:"sm",onClick:()=>window.history.length>1?r(-1):r("/"),className:"mb-4 -ml-2","aria-label":"Go back",children:[e.jsx(Q,{className:"h-4 w-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"text-center mb-8",children:[e.jsx(K,{}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"bg-gradient-primary rounded-full p-2",children:e.jsx(X,{className:"h-6 w-6 text-primary-foreground"})}),e.jsx("h1",{className:"text-3xl font-bold",children:"YogiCurious"})]}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Complete your subscription to start finding yoga partners"})]}),e.jsxs(S,{className:"mb-6",children:[e.jsxs(T,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ee,{className:"h-5 w-5 text-primary"}),e.jsxs(M,{children:["Complete Your ",a.name," Subscription"]})]}),e.jsx(A,{children:h?"Purchase subscription through our website":"Choose your payment method to unlock all features"})]}),e.jsxs(I,{className:"space-y-6",children:[e.jsxs("div",{className:"bg-muted/30 rounded-lg p-6",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("h3",{className:"text-xl font-semibold",children:a.name}),e.jsx("p",{className:"text-xs text-primary font-medium",children:a.subscriptionTitle}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:a.description}),e.jsxs("div",{className:"mt-2 flex flex-col items-center",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-3xl font-bold",children:a.price}
6),a.period&&e.jsxs("span",{className:"text-muted-foreground",children:["/",a.period]})]}),a.length&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[a.pricePerUnit," ⢠",a.length," subscription"]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:a.features.map((t,x)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-4 w-4 text-primary flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:t})]},x))})]}),i&&e.jsx(ie,{onRedeemed:()=>{r("/dashboard")}}),h?e.jsxs("div",{className:"space-y-4",children:[e.jsxs(z,{className:"border-primary/30 bg-primary/5",children:[e.jsx(te,{className:"h-4 w-4 text-primary"}),e.jsxs(O,{children:[e.jsx("strong",{children:"No account required to purchase!"})," You can subscribe instantly. Creating an account is optional but recommended to sync your subscription across devices."]})]}),e.jsx(G,{tier:s,onSuccess:()=>{d({title:"Purchase Successful!",description:"Your subscription is now active. Create an account anytime to sync across devices."}),r("/post-purchase-setup")},onError:t=>{console.warn("IAP error (suppressed from UI):",t)}}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Want to sync across devices?"}),e.jsx(m,{variant:"outline",size:"sm",onClick:()=>r("/auth?tab=signup"),children:"Create Account (Optional)"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-4",children:"Select Payment Method"}),e.jsx(V,{onMethodSelect:B,selectedMethod:c==null?void 0:c.id})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(m,{variant:"outline",onClick:()=>r("/auth"),className:"flex-1",children:"Back to Sign Up"}),e.jsxs(m,{onClick:D,disabled:!c||N,className:"flex-1",children:[N?e.jsx(b,{className:"h-4 w-4 animate-spin mr-2"}):null,"Complete Payment"]})]}),e.jsxs("div",{className:"text-center text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"Secure payment processing ⢠Cancel anytime"}),e.jsx("p",{children:"After payment, you'll be redirected to find yoga studios near you!"}),e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Auto-Renewable Subscription:"})," Automatically renews unless cancelled 24+ hours before period end."]}),e.jsxs("p",{children:["By subscribing, you agree to our"," ",e.jsxs(k,{to:"/terms-of-service",className:"underline hover:text-primary inline-flex items-center gap-1",children:["Terms of Service (EULA) ",e.jsx(U,{className:"h-3 w-3"})]})," ","and"," ",e.jsxs(k,{to:"/privacy-policy",className:"underline hover:text-primary inline-flex items-center gap-1",children:["Privacy Policy ",e.jsx(U,{className:"h-3 w-3"})]}),"."]})]})]})]}),h&&e.jsx(m,{variant:"outline",onClick:()=>r("/"),className:"w-full",children:"Back to Home"})]})]})]})}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-primary/5 via-background to-secondary/5 flex items-center justify-center p-4",children:e.jsxs(S,{className:"max-w-md",children:[e.jsxs(T,{children:[e.jsx(M,{children:"Invalid Plan"}),e.jsx(A,{children:"The selected plan is not available."})]}),e.jsx(I,{children:e.jsx(m,{onClick:()=>r("/auth"),className:"w-full",children:"Return to Sign Up"})})]})})};export{Ae 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.