1import{d as R,C as U,i as l,s as $,j as O,p as C,o as h,c as I,a,t as T,n as w,F as G,r as V,u as S,L as q,b as z,e as K}from"./index.be450d7f.js";import{_ as Y}from"./PlanCard.01e85fa8.js";import{a as H}from"./firestoreCache.990f7c83.js";import{P as J,a as Q,f as W}from"./planCatalog.a9575b70.js";import{j as _,g as X}from"./revenueCat.c57cdc52.js";function Z(g){if(_.isConfigured()){const r=_.getSharedInstance();if(r.getAppUserId()===g)return r}return _.configure(X(),g)}const ee={class:"max-w-3xl mx-auto px-4 py-8"},te={class:"text-center mb-6"},ae={class:"text-2xl font-black text-gray-900"},se=a("p",{class:"text-sm text-gray-500 mt-1"}," Every plan includes a personal Player Locker. ",-1),ne={class:"flex items-center justify-center gap-3 mb-6"},oe=["checked"],ce=K(" Annual "),le=a("span",{class:"badge badge-warning badge-sm ml-1"},"2 months free",-1),re=[ce,le],ie={class:"grid grid-cols-1 sm:grid-cols-3 gap-4"},ue={class:"mt-8 text-center"},de=["disabled"],fe=a("p",{class:"text-xs text-gray-500 mt-3"}," Secure checkout. Cancel anytime from your billing page. ",-1),ve=R({__name:"UserPlans",setup(g){const r="custom_design",A=["basic","pro","elite"],B=["monthly","annual"],F=U(),i=l(null),v=l(""),u=l("pro"),s=l("annual"),m=l("Pick your plan"),y=l({}),L=$(()=>!!i.value),D=e=>{var n;return(n=y.value[Q(e,s.value)])!=null?n:W(e,s.value)};function N(e){s.value=e.target.checked?"annual":"monthly"}function j(){!i.value||F.push({path:"/auth/purchase-process",query:{plan:u.value,interval:s.value,userId:i.value,email:v.value}})}async function M(e){var f,b,p,x;i.value=e.uid,v.value=(f=e.email)!=null?f:"";const t=(b=(await H(C.firestore().collection("users").doc(e.uid))).data())!=null?b:{},o=t.intendedPlan;o&&A.includes(o)&&(u.value=o);const c=t.intendedInterval;c&&B.includes(c)&&(s.value=c);const d=q(t);if(d==="trial_expired")m.value="Your trial has ended \u2014 pick a plan";else if(d==="trial"){const k=(x=(p=t.trialEndsAt)==null?void 0:p.toMillis)==null?void 0:x.call(p);if(k){const P=Math.max(0,Math.ceil((k-Date.now())/864e5));m.value=`${P} day${P===1?"":"s"} left on your trial \u2014 pick your plan`}}}async function E(e){try{const o=(await Z(e).getOfferings()).all[r];if(!o)return;const c={};for(const[d,f]of Object.entries(o.packagesById))c[d]=f.webBillingProduct.currentPrice.formattedPrice;y.value=c}catch(n){console.warn("[UserPlans] offerings unavailable, using fallback prices",n)}}return O(()=>{C.auth().onAuthStateChanged(async e=>{!e||(await M(e),await E(e.uid))})}),(e,n)=>(h(),I("div",ee,[a("header",te,[a("h1",ae,T(m.value),1),se]),a("div",ne,[a("span",{class:w(["text-sm font-semibold",s.value==="monthly"?"text-gray-900":"text-gray-400"])}," Monthly ",2),a("input",{type:"checkbox",class:"toggle toggle-primary",checked:s.value==="annual","aria-label":"Bill annually",onChange:N},null,40,oe),a("span",{class:w(["text-sm font-semibold",s.value==="annual"?"text-gray-900":"text-gray-400"])},re,2)]),a("div",ie,[(h(!0),I(G,null,V(S(J),t=>(h(),z(Y,{key:t.id,name:t.name,price:D(t.id),"price-suffix":s.value==="annual"?"/yr":"/mo",badge:t.badge,selected:u.value===t.id,features:t.features,onSelect:o=>u.value=t.id},null,8,["name","price","price-suffix","badge","selected","features","onSelect"]))),128))]),a("div",ue,[a("button",{type:"button",class:"btn btn-primary btn-wide",disabled:!S(L),onClick:j}," Continue to checkout \u2192 ",8,de),fe])]))}});export{ve 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.