1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/firebase-functions-KROXWFe9.js","assets/firebase-auth-BWbhO1CC.js"])))=>i.map(i=>d[i]); 2import{z as T,j as t,x as Ce,y as we,B as Ie,L as Ne,D as Ee,H as Se,u as je,c as Le}from"./ui-vendor-XNsX7NFl.js";import{a as l,_ as Ae,u as V,T as le}from"./i18n-BCZ_8xSB.js";import{C as B,P as C,L as _e}from"./capacitor-DQeCf45c.js";import{u as de,B as ue,U as Re,f as me,b as Oe,d as Fe,e as Te,h as Ue,S as $e,W as ge,P as re,j as se}from"./index-Dg7geK91.js";import{redirectToCustomerPortal as Ye,createCheckoutSession as De}from"./stripeService-DOEUI5KA.js";import{S as ae}from"./stripeConfig-X3dkQhO0.js";import{b as fe,L as te,u as Me}from"./react-router-oAHNt2ka.js";import{C as ze}from"./CreditPackPicker-HS2lMtBb.js";import{h as Be,a as Ge}from"./packAvailability-CbMDVbWF.js";import{u as He}from"./usePlatform-jw2ahvaa.js";import{M as Z,g as Ve,a as Qe,P as We,b as qe}from"./planLimits-DIvMyDFL.js";import"./firebase-auth-BWbhO1CC.js";import"./firebase-db-Csu2kn54.js";import"./StateHeading-D9MlYpnP.js";const pe={},Je=pe?.VITE_REVENUECAT_APPLE_KEY??"",Xe=pe?.VITE_REVENUECAT_GOOGLE_KEY??"",xe=()=>{const r=B.getPlatform();return r==="ios"?Je:r==="android"?Xe:""};xe();const j={FAMILY:"family",PROFESSIONAL:"professional"},K={FAMILY_MONTHLY:{identifier:"family_monthly",tier:"Family",period:"monthly"},FAMILY_YEARLY:{identifier:"family_yearly",tier:"Family",period:"yearly"},PROFESSIONAL_MONTHLY:{identifier:"professional_monthly",tier:"Professional",period:"monthly"},PROFESSIONAL_YEARLY:{identifier:"professional_yearly",tier:"Professional",period:"yearly"}},Ze={[j.FAMILY]:"Family",[j.PROFESSIONAL]:"Professional"};class Ke{initialized=!1;customerInfo=null;offerings=null;onCustomerInfoUpdate=null;appUserId=null;async initialize(e=null){if(!B.isNativePlatform())return!1;if(this.initialized)return!0;const a=xe();if(!a)return console.warn("RevenueCat: No API key configured for this platform (set VITE_REVENUECAT_APPLE_KEY / VITE_REVENUECAT_GOOGLE_KEY)."),!1;try{await C.setLogLevel({level:_e.DEBUG}),await C.configure({apiKey:a,appUserID:e||null}),await C.addCustomerInfoUpdateListener(u=>{this.customerInfo=u.customerInfo,this.onCustomerInfoUpdate&&this.onCustomerInfoUpdate(u.customerInfo)});const{customerInfo:s}=await C.getCustomerInfo();this.customerInfo=s;const{offerings:d}=await C.getOfferings();return this.offerings=d,this.initialized=!0,this.appUserId=e||null,!0}catch(s){return console.error("RevenueCat: Failed to initialize",s),!1}}async login(e){if(!this.initialized)return await this.initialize(e),this.customerInfo;if(this.appUserId===e)return this.customerInfo;try{const{customerInfo:a}=await C.logIn({appUserID:e});return this.customerInfo=a,this.appUserId=e,a}catch(a){throw console.error("RevenueCat: Failed to log in",a),a}}async logout(){try{const{customerInfo:e}=await C.logOut();return this.customerInfo=e,this.appUserId=null,e}catch(e){throw console.error("RevenueCat: Failed to log out",e),e}}async getOfferings(){this.initialized||await this.initialize();try{const{offerings:e}=await C.getOfferings();return this.offerings=e,e}catch(e){throw console.error("RevenueCat: Failed to get offerings",e),e}}getCurrentOffering(){return this.offerings?.current||null}getPackages(){return this.offerings?.current?.availablePackages||[]}async purchasePackage(e){if(!this.initialized)throw new Error("RevenueCat not initialized");try{const{customerInfo:a}=await C.purchasePackage({aPackage:e});return this.customerInfo=a,{customerInfo:a,success:!0}}catch(a){if(a.code==="PURCHASE_CANCELLED")return{cancelled:!0,success:!1};throw console.error("RevenueCat: Purchase failed",a),a}}async purchaseProduct(e){const s=this.getPackages().find(d=>d.product?.identifier===e||d.identifier===e);if(!s)throw new Error(`Product not found: ${e}`);return this.purchasePackage(s)}async restorePurchases(){this.initialized||await this.initialize();try{const{customerInfo:e}=await C.restorePurchases();return this.customerInfo=e,e}catch(e){throw console.error("RevenueCat: Failed to restore purchases",e),e}}async getCustomerInfo(){this.initialized||await this.initialize();try{const{customerInfo:e}=await C.getCustomerInfo();return this.customerInfo=e,e}catch(e){throw console.error("RevenueCat: Failed to get customer info",e),e}}hasEntitlement(e){return this.customerInfo?!!this.customerInfo.entitlements?.active?.[e]:!1}hasPremiumAccess(){return this.hasEntitlement(j.FAMILY)||this.hasEntitlement(j.PROFESSIONAL)}getCurrentTier(){return this.customerInfo?this.hasEntitlement(j.PROFESSIONAL)?"Professional":this.hasEntitlement(j.FAMILY)?"Family":"Starter":"Starter"}getActiveSubscription(){if(!this.customerInfo)return null;const e=this.customerInfo.entitlements?.active;if(!e||Object.keys(e).length===0)return null;const a=e[j.PROFESSIONAL]||e[j.FAMILY];return a?{tier:Ze[a.identifier]||"Family",productIdentifier:a.productIdentifier,expirationDate:a.expirationDate,willRenew:a.willRenew,isActive:a.isActive}:null}setOnCustomerInfoUpdate(e){this.onCustomerInfoUpdate=e}}const y=new Ke,he=()=>{const{user:r}=de(),e=r?.id||null,[a,s]=l.useState(!1),[d,u]=l.useState(!0),[c,F]=l.useState([]),[U,g]=l.useState(!1),[$,Y]=l.useState(!1),[k,f]=l.useState(null),[P,w]=l.useState(null);l.useEffect(()=>{let o=!0;return(async()=>
2{if(!B.isNativePlatform()){u(!1);return}try{y.setOnCustomerInfoUpdate(M=>{o&&w(M)});const m=await y.initialize(e);if(!o||m&&e&&(await y.login(e),!o))return;s(m),m&&(F(y.getPackages()),w(y.customerInfo))}catch(m){if(!o)return;console.error("useIAP init error:",m),f(m.message)}finally{o&&u(!1)}})(),()=>{o=!1}},[e]);const h=l.useCallback(async()=>{if(e)try{const{getFunctions:o,httpsCallable:i}=await Ae(async()=>{const{getFunctions:z,httpsCallable:O}=await import("./firebase-functions-KROXWFe9.js").then(b=>b.i);return{getFunctions:z,httpsCallable:O}},__vite__mapDeps([0,1])),m=o();await i(m,"syncRevenueCatPurchase")()}catch(o){console.warn("Post-purchase sync failed (webhook will retry):",o)}},[e]),p=l.useCallback(async o=>{g(!0),f(null);try{const i=await y.purchasePackage(o);return i.customerInfo&&w(i.customerInfo),i.success&&h(),i}catch(i){throw f(i.message),i}finally{g(!1)}},[h]),N=l.useCallback(async o=>{g(!0),f(null);try{const i=await y.purchaseProduct(o);return i.customerInfo&&w(i.customerInfo),i.success&&h(),i}catch(i){throw f(i.message),i}finally{g(!1)}},[h]),D=l.useCallback(async()=>{Y(!0),f(null);try{const o=await y.restorePurchases();return w(o),F(y.getPackages()),h(),o}catch(o){throw f(o.message),o}finally{Y(!1)}},[h]),E=l.useCallback(o=>{const i=K[o];return i&&c.find(m=>m.product?.identifier===i.identifier||m.identifier===i.identifier)||null},[c]),L=l.useCallback(o=>E(o)?.product?.priceString||null,[E]),A=l.useCallback(o=>{const i=K[o];if(!i)return null;const m=E(o);return{key:o,...i,price:m?.product?.priceString||null,priceAmount:m?.product?.price||null,currency:m?.product?.currencyCode||null,available:!!m,package:m}},[E]),x=l.useCallback(()=>y.hasPremiumAccess(),[P]),_=l.useCallback(()=>y.getCurrentTier(),[P]),R=l.useCallback(()=>y.getActiveSubscription(),[P]),v=l.useCallback(()=>{f(null)},[]);return{isAvailable:a,isLoading:d,packages:c,purchasing:U,restoring:$,error:k,customerInfo:P,purchasePackage:p,purchaseProduct:N,restore:D,getPackageByKey:E,getProductPrice:L,getProductInfo:A,hasActiveSubscription:x,getCurrentTier:_,getActiveSubscription:R,clearError:v,PRODUCTS:K,ENTITLEMENTS:j}},ne="font-semibold text-sage-700 underline decoration-sage-300 underline-offset-2 hover:text-sage-800 focus:outline-none focus-visible:ring-2 focus-visible:ring-sage-500 rounded dark:text-sage-300 dark:decoration-sage-600 dark:hover:text-sage-200",et=()=>B.getPlatform()==="android"?"Google Play":"App Store",ie=r=>String(r||"").toLowerCase().includes("cancel"),tt="iap-purchase-failed";function rt({productKey:r,tier:e,variant:a="primary",size:s="md",className:d="",children:u,onSuccess:c,onError:F,showRenewalTerms:U=!1}){const{t:g}=V("pricing"),$=fe(),{purchaseProduct:Y,purchasing:k,getProductPrice:f,getProductInfo:P,isAvailable:w,isLoading:h,error:p,customerInfo:N,clearError:D,PRODUCTS:E}=he(),[L,A]=l.useState(!1),[x,_]=l.useState(!1),R=l.useRef(!1),v=P(r);l.useEffect(()=>{if(R.current&&N&&v?.available){const O=e?.toLowerCase();if(N.entitlements?.active?.[O]&&!x){_(!0);const Q=g(`common:plans.${String(e||"").toLowerCase()}`,{defaultValue:e});T.success(g("purchaseSuccess",{tier:Q})),c?.({tier:e,customerInfo:N}),$(`/upgrade-success?plan=${encodeURIComponent(e)}`)}}},[N,v,e,c,g,x,$]),l.useEffect(()=>{p&&(ie(p)||console.warn("In-app purchases:",p),D())},[p,D]);const o=async()=>{if(L||k)return;const O=E[r];if(!O){T.error(g("productNotFound"));return}A(!0),R.current=!0;try{const b=await Y(O.identifier);if(b.cancelled)return;b.success}catch(b){ie(b?.message)||(console.warn("In-app purchase failed:",b?.message||b),T.error(g("purchaseFailed"),{id:tt}),F?.(b))}finally{A(!1)}};if(!w||h||!v?.available)return null;const i=f(r),m=v?.period==="yearly"?g("perYear"):g("perMonth"),M=t.jsxs(t.Fragment,{children:[g("subscribe"),i&&` - ${i}${m}`]}),z=t.jsx(ue,{variant:a,size:s,className:d,onClick:o,loading:L||k,disabled:L||k,children:u||M});return!U||!i?z:t.jsxs("div",{className:"w-full",children:[z,t.jsx("p",{className:"mt-3 text-center text-xs leading-relaxed text-slate-600 dark:text-dim-text-secondary","data-testid":`iap-renewal-${r}`,children:t.jsx(le,{t:g,i18nKey:"iapRenewal",values:{price:i,period:m,store:et()},components:{terms:t.jsx(te,{to:"/terms",className:ne}),privacy:t.jsx(te,{to:"/privacy",className:ne})}})})]})}const H="credits",st="mx-auto mt-12 max-w-3xl rounded-3xl border border-sage-100 bg-white p-6 shadow-sm sm:p-8 dark:border-dim-border dark:bg-dim-elevated";function at({onSignIn:r,signInLabel:e}){const{t:a,i18n:s}=V("credits"),d=s?.language||"en",u=Ge();return t.jsxs("section",{id:H,"aria-labelledby":`${H}-title`,className:"scroll-mt-24",children:[t.jsx("h3",{id:`${H}-title`,className:"font-['Quicksand'] text-lg font-bold text-ink dark:text-dim-text",children:a("packs.title")}
2),t.jsx("p",{className:"mt-1 text-sm text-slate-600 dark:text-dim-text-secondary",children:a("packs.subtitle")}),t.jsx("ul",{className:`mt-4 grid gap-2 sm:gap-3 ${u.length===3?"grid-cols-3":"grid-cols-2"}`,children:u.map(c=>t.jsxs("li",{className:"flex min-h-[88px] flex-col items-center justify-center rounded-xl border-2 border-slate-200 bg-white px-1.5 py-3 text-center sm:px-2 dark:border-dim-border dark:bg-dim-surface",children:[t.jsx("span",{className:"text-sm font-bold tabular-nums text-ink sm:text-base dark:text-dim-text",children:a("unit",{count:c.credits})}),t.jsx("span",{className:"text-base font-semibold tabular-nums text-slate-700 dark:text-dim-text-secondary",children:me(c.priceUsd,d)}),t.jsx("span",{className:"mt-0.5 text-xs leading-tight text-slate-600 dark:text-dim-text-muted",children:a("packs.aboutStories",{count:Oe(c.credits)})})]},c.key))}),t.jsx("div",{className:"mt-4",children:t.jsx(ue,{variant:"outline",onClick:r,leftIcon:t.jsx(Ce,{className:"h-5 w-5","aria-hidden":"true"}),className:"w-full sm:w-auto",children:e})}),t.jsx("p",{className:"mt-3 text-xs text-slate-600 dark:text-dim-text-muted",children:a("packs.note")})]})}function nt({user:r,onSignIn:e,signInLabel:a}){const{isNative:s}=He();return s||!Be()||r?.tier===Re?null:t.jsx("div",{className:st,"data-testid":"pricing-credit-packs",children:r?t.jsx(ze,{user:r,returnTo:"pricing",id:H,headingLevel:3,className:"scroll-mt-24"}):t.jsx(at,{onSignIn:e,signInLabel:a})})}const it=["starter","family","professional"],ot=["monthly","yearly"],ct=(r="")=>{const e=new URLSearchParams(r),a=e.get("plan"),s=e.get("cycle");return{plan:it.includes(a)?a:null,cycle:ot.includes(s)?s:null}},lt="ring-4 ring-sage-300 ring-offset-2 ring-offset-cream dark:ring-sage-600 dark:ring-offset-dim-deep",dt={starter:je,family:Se,professional:Ee},ut={starter:"Starter",family:"Family",professional:"Professional"},be=["Family","Professional"],ye=["apple","google"],mt=r=>r&&Fe(r)?.interval==="year"?"yearly":"monthly",gt=r=>{if(!r)return"signup";if(!be.includes(r.tier))return"checkout";const e=r.subscriptionSource||null;return ye.includes(e)?"store":e==="stripe"||r.stripeSubscriptionId||!e?"portal":"elsewhere"},ft=r=>{if(typeof r!="function")return null;const e=["FAMILY","PROFESSIONAL"].map(s=>{const d=Number(r(`${s}_MONTHLY`)?.priceAmount),u=Number(r(`${s}_YEARLY`)?.priceAmount);return!(d>0)||!(u>0)?null:Math.floor((12*d-u)/(12*d)*100)}).filter(s=>s!==null);if(e.length===0)return null;const a=Math.min(...e);return a>=1?a:null},pt=(r,e)=>{const a=r==="Family"?ae.FAMILY:r==="Professional"?ae.PROFESSIONAL:null;return a&&(e==="yearly"?a.YEARLY:a.MONTHLY)||null},xt=({isNative:r,getProductInfo:e,t:a})=>{if(!r)return a("pricing.billing.saveUpTo");const s=ft(e);return s?a("pricing.billing.savePercent",{pct:s}):null},ht={family:"order-1",starter:"order-2",professional:"order-3"},bt=(r,e)=>e?r===e.toLowerCase()?"order-1":r==="starter"?"order-3":"order-2":ht[r],yt=(r,e)=>{const a=r===(e?e.toLowerCase():"family"),s=a?"border-2 border-sage-600 shadow-lg md:-translate-y-4 dark:border-sage-500":"border border-sage-100 shadow-sm dark:border-dim-border",d=a&&!e?" relative pt-8 sm:pt-10":"";return`${bt(r,e)} flex h-full flex-col rounded-3xl bg-white p-6 sm:p-8 md:order-none dark:bg-dim-elevated ${s}${d}`},ee=(r,e,a)=>({"aria-current":e?"true":void 0,"data-highlighted":a===r?"true":void 0,"data-plan":r}),oe="bg-sage-600 text-white shadow-md",ce="text-slate-600 hover:bg-sage-50 dark:text-dim-text-secondary dark:hover:bg-dim-elevated",kt=["monthly","yearly"],Pt=({billingCycle:r,onChange:e,yearlyNote:a,t:s})=>{const{getRadioProps:d}=Te({options:kt,value:r,onChange:e});return t.jsxs("div",{className:"mx-auto grid max-w-sm grid-cols-2 rounded-2xl border border-sage-200 bg-white p-1.5 shadow-inner dark:border-dim-border dark:bg-dim-surface",role:"radiogroup","aria-label":s("pricing.billing.label"),children:[t.jsx("button",{type:"button",...d("monthly",0),className:`min-h-[48px] rounded-xl px-3 text-sm font-bold transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-sage-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-dim-surface ${r==="monthly"?oe:ce}`,children:s("pricing.billing.monthly")}),t.jsxs("button",{type:"button",...d("yearly",1),className:`min-h-[48px] rounded-xl px-3 py-1 text-sm font-bold transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-sage-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-dim-surface ${r==="yearly"?oe:ce}`,children:[t.jsx("span",{className:"block",children:s("pricing.billing.yearly")}),a&&t.jsx("span",{className:`block text-xs font-semibold ${r==="yearly"?"text-white":"text-sage-700 dark:text-sage-300"}`,children:a})]})]})},vt=({t:r})=>{const e=[{key:"oneCredit",Icon:we,text:r("pricing.explainer.oneCredit")},{key:"storyRange",Icon:Ie,text:r("pricing.explainer.storyRange",{pages:Z.pages,min:Z.min,max:Z.max})},{key:"emojiFree",Icon:Ne,text:r("pricing.explainer.emojiFree")}];return t.jsx("ul",{"aria-label":r("pricing.explainer.label"),className:"mx-auto mb-8 grid max-w-4xl gap-2 text-left sm:grid-cols-3 sm:gap-3","data-testid":"pricing-explainer",children:e.map(a=>{const{key:s,Icon:d,text:u}=a;return t.jsxs("li",{className:"flex items-center gap-3 rounded-2xl border border-sage-100 bg-white px-4 py-3 text-sm font-semibold text-ink dark:border-dim-border dark:bg-dim-surface dark:text-dim-text",children:[t.jsx("span",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl bg-sage-100 text-sage-700 dark:bg-sage-900/40 dark:text-sage-300","aria-hidden":"true",children:t.jsx(d,{className:"h-5 w-5"})}),t.jsx("span",{children:u})]},s)})})},Ct=({isCurrent:r,t:e})=>r?t.jsx("p",{className:"mb-2 inline-flex rounded-full border border-sage-200 bg-sage-50 px-2.5 py-0.5 text-xs font-bold text-sage-800 dark:border-sage-700 dark:bg-sage-900/40 dark:text-sage-200",children:e("pricing.tiers.currentPlan")}):null,wt=({planKey:r,billingCycle:e,isNative:a,nativePrice:s,language:d,t:u})=>
2{if(r==="starter")return t.jsxs("div",{className:"mb-5","data-testid":"plan-price-starter",children:[t.jsx("p",{className:"text-4xl font-extrabold tabular-nums text-ink dark:text-dim-text",children:me(0,d)}),t.jsx("p",{className:"mt-1 text-sm text-slate-600 dark:text-dim-text-secondary",children:u("pricing.noCard")})]});if(a)return s?t.jsx("div",{className:"mb-5","data-testid":`plan-price-${r}`,children:t.jsxs("p",{className:"flex flex-wrap items-baseline gap-x-1",children:[t.jsx("span",{className:"text-4xl font-extrabold tabular-nums text-ink dark:text-dim-text",children:s}),t.jsx("span",{className:"text-slate-600 dark:text-dim-text-secondary",children:u(`pricing.priceSuffix.${e}`)})]})}):t.jsx("div",{className:"mb-5","data-testid":`plan-price-${r}`});const c=Ve(r,e,d);return t.jsxs("div",{className:"mb-5","data-testid":`plan-price-${r}`,children:[t.jsxs("p",{className:"flex flex-wrap items-baseline gap-x-1",children:[t.jsx("span",{className:"text-4xl font-extrabold tabular-nums text-ink dark:text-dim-text",children:c.price}),t.jsx("span",{className:"text-slate-600 dark:text-dim-text-secondary",children:u(`pricing.priceSuffix.${e}`)})]}),t.jsx("p",{className:"mt-1 text-sm text-slate-600 dark:text-dim-text-secondary",children:e==="yearly"?u("pricing.yearlyNote",{perMonth:c.perMonth}):u("pricing.yearlyAlt",{price:c.yearly})})]})},It=({planKey:r,t:e})=>{const[a,s]=Qe(r);return t.jsxs("div",{className:"mb-6 rounded-2xl border border-sage-100 bg-sage-50 px-4 py-3 dark:border-dim-border dark:bg-dim-surface","data-testid":`plan-credits-${r}`,children:[t.jsx("p",{className:"font-bold text-ink dark:text-dim-text",children:e(a,s)}),t.jsx("p",{className:"mt-0.5 text-sm text-slate-700 dark:text-dim-text-secondary",children:e(r==="starter"?"pricing.credits.welcomeNote":"pricing.credits.rollover")})]})},Nt=({planKey:r,t:e})=>{const a=We[r];return t.jsxs("div",{className:"mb-8 flex-grow",children:[a&&t.jsx("p",{className:"mb-3 text-sm font-bold text-slate-700 dark:text-dim-text-secondary",children:e("pricing.everythingIn",{plan:e(`pricing.tiers.${a}.name`)})}),t.jsx("ul",{className:"space-y-3",children:qe[r].map(s=>t.jsxs("li",{className:"flex items-start gap-3 text-sm text-slate-700 dark:text-dim-text-secondary",children:[t.jsx(Le,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-sage-600 dark:text-sage-400","aria-hidden":"true"}),t.jsx("span",{children:e(`pricing.features.${s}`)})]},s))})]})},Et=({planKey:r,isCurrent:e,t:a})=>{const s=dt[r];return t.jsxs("div",{className:"mb-5",children:[t.jsxs("div",{className:"mb-3 flex items-center gap-3",children:[t.jsx("span",{className:"flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-2xl bg-sage-100 text-sage-700 dark:bg-sage-900/40 dark:text-sage-300","aria-hidden":"true",children:t.jsx(s,{className:"h-6 w-6"})}),t.jsx("h3",{className:"font-['Quicksand'] text-2xl font-bold text-ink dark:text-dim-text",children:a(`pricing.tiers.${r}.name`)})]}),t.jsx(Ct,{isCurrent:e,t:a}),t.jsx("p",{className:"text-sm text-slate-600 dark:text-dim-text-secondary",children:a(`pricing.tiers.${r}.tagline`)})]})},St=({id:r="pricing",bgColor:e="bg-cream dark:bg-dim-deep",showHeader:a=!0})=>{const{t:s,i18n:d}=V("marketing"),u=d?.language||"en",{user:c}=de(),F=fe(),U=Me(),g=l.useMemo(()=>ct(U?.search),[U?.search]),[$,Y]=l.useState(()=>g.cycle),k=$||mt(c),[f,P]=l.useState(!1),[w,h]=l.useState(null),p=B.isNativePlatform(),{isAvailable:N,isLoading:D,restore:E,restoring:L,getProductInfo:A}=he(),x=c?.tier||"Starter",_=n=>!!c&&x===n,R=!!c&&be.includes(x),v=gt(c),o=ye.includes(c?.subscriptionSource)?c.subscriptionSource:null,i=n=>g.plan===n?lt:"",m=n=>`${n.toUpperCase()}_${k==="yearly"?"YEARLY":"MONTHLY"}`,M=n=>p&&A?.(m(n))?.price||null,z=async n=>{if(p)return;if(!c){F("/login",{state:{mode:"signup",intent:"plan",returnTo:`/pricing?plan=${n.toLowerCase()}&cycle=${k}`}});return}if(v==="store")return;if(v==="elsewhere"){T(s("pricing.managedElsewhere"));return}if(v==="portal"){try{P(!0),h(n.toLowerCase());const I=window.location.origin+"/pricing";await Ye(c.id,I)}catch(I){console.error("Error redirecting to portal:",I),T.error(s("pricing.errors.portalFailed")),P(!1),h(null)}return}const S=pt(n,k);if(!S){T(s("pricing.errors.notReady"));return}try{P(!0),h(n.toLowerCase());const I=`${window.location.origin}/upgrade-success?plan=${n}&session_id={CHECKOUT_SESSION_ID}`,G=`${window.location.origin}/pricing`;await De(c,S,I,G)}catch(I){console.error("Payment error:",I),T.error(s("pricing.errors.paymentFailed")),P(!1),h(null)}},O=n=>f&&w===n.toLowerCase()?s("pricing.processing"):x===n?c?.tierExpiresAt?s("pricing.tiers.renewPlan"):s("pricing.tiers.managePlan"):s(x==="Family"||x==="Professional"?"pricing.tiers.upgrade":`pricing.tiers.${n.toLowerCase()}.cta`),b=f||x==="Admin",Q=()=>{const n=B.getPlatform()==="ios"?"https://apps.apple.com/account/subscriptions":"https://play.google.com/store/account/subscriptions";window.open(n,"_blank")},W="flex min-h-[52px] w-full items-center justify-center rounded-2xl px-6 py-3 text-center font-bold transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-sage-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-dim-elevated",q="w-full rounded-2xl bg-slate-50 px-6 py-4 text-center text-sm text-slate-600 dar
2k:bg-dim-surface dark:text-dim-text-secondary",ke=n=>{if(!p){if(v==="store")return t.jsx("p",{className:q,"data-testid":`plan-store-note-${n.toLowerCase()}`,children:s(o==="apple"?"pricing.managedInAppStore":"pricing.managedInPlayStore")});const I=R&&x!==n;let G="bg-sage-600 text-white shadow-sm hover:bg-sage-700 hover:shadow-md";return b?G="cursor-not-allowed bg-slate-200 text-slate-600 dark:bg-dim-border dark:text-dim-text-muted":I&&(G="border-2 border-sage-600 bg-white text-sage-700 hover:bg-sage-50 dark:border-sage-400 dark:bg-dim-elevated dark:text-sage-200 dark:hover:bg-dim-surface"),t.jsx("button",{type:"button",onClick:()=>z(n),disabled:b,"aria-busy":f&&w===n.toLowerCase(),className:`${W} ${G}`,children:O(n)})}if(x===n)return c?.subscriptionSource==="apple"||c?.subscriptionSource==="google"?t.jsx("button",{type:"button",onClick:Q,className:`${W} bg-sage-600 text-white shadow-sm hover:bg-sage-700`,children:s("pricing.tiers.managePlan")}):t.jsx("p",{className:q,children:s("pricing.managedElsewhere")});const S=m(n);return N&&A(S)?.available?t.jsx(rt,{productKey:S,tier:n,variant:"primary",className:"w-full py-4 px-6 text-center font-bold rounded-2xl",showRenewalTerms:!0}):t.jsx("p",{className:q,children:s(D?"pricing.processing":"pricing.unavailableNative")})},Pe=()=>t.jsx(te,{to:"/create",className:`${W} bg-sage-50 text-sage-800 hover:bg-sage-100 dark:bg-sage-900/30 dark:text-sage-200 dark:hover:bg-sage-900/50`,children:s(c?"pricing.makeStory":"pricing.tiers.starter.cta")}),ve=xt({isNative:p,getProductInfo:A,t:s}),J=n=>`${yt(n,R?x:null)} ${i(n)}`.trim(),X=n=>{const S=ut[n];return t.jsxs(t.Fragment,{children:[t.jsx(Et,{planKey:n,isCurrent:_(S),t:s}),t.jsx(wt,{planKey:n,billingCycle:k,isNative:p,nativePrice:n==="starter"?null:M(S),language:u,t:s}),t.jsx(It,{planKey:n,t:s}),t.jsx(Nt,{planKey:n,t:s}),n==="starter"?Pe():ke(S)]})};return t.jsx("section",{id:r,className:`px-4 py-12 sm:px-6 sm:py-16 lg:px-8 ${e}`,children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"mb-8 text-center sm:mb-12",children:[a&&t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"mb-4 font-['Quicksand'] text-3xl font-bold text-balance text-ink sm:text-4xl dark:text-dim-text",children:s("pricing.title")}),t.jsx("p",{className:"mx-auto mb-8 max-w-xl text-slate-700 dark:text-dim-text-secondary",children:s("pricing.subtitle")})]}),t.jsx(vt,{t:s}),t.jsx(Pt,{billingCycle:k,onChange:Y,yearlyNote:ve,t:s})]}),t.jsxs("div",{className:"grid gap-6 md:grid-cols-3 md:gap-8",children:[t.jsx("div",{...ee("starter",_("Starter"),g.plan),className:J("starter"),children:X("starter")}),t.jsxs("div",{...ee("family",_("Family"),g.plan),className:J("family"),children:[!R&&t.jsx("p",{className:"absolute left-1/2 top-0 -translate-x-1/2 -translate-y-1/2 whitespace-nowrap rounded-full bg-sage-600 px-4 py-1 text-xs font-bold text-white",children:s("pricing.tiers.family.badge")}),X("family")]}),t.jsx("div",{...ee("professional",_("Professional"),g.plan),className:J("professional"),children:X("professional")})]}),p&&N&&t.jsx("div",{className:"mt-8 text-center",children:t.jsx("button",{type:"button",onClick:E,disabled:L,className:"min-h-[44px] rounded px-4 text-sm font-medium text-sage-700 underline hover:text-sage-800 focus:outline-none focus-visible:ring-2 focus-visible:ring-sage-500 focus-visible:ring-offset-2 disabled:opacity-50 dark:text-sage-300",children:s(L?"pricing.restoring":"pricing.restorePurchases")})}),!p&&t.jsx(nt,{user:c,onSignIn:()=>F("/login",{state:{mode:"signup",intent:"credits",returnTo:"/pricing#credits"}}),signInLabel:s("pricing.packs.signIn")}),t.jsx("p",{className:"mx-auto mt-12 max-w-3xl text-center text-sm leading-relaxed text-slate-600 dark:text-dim-text-secondary","data-testid":"pricing-fine-print",children:s("pricing.finePrint")})]})})};function jt(){return{"@context":"https://schema.org","@type":"Product",name:"SocialNarratives Subscription",description:"Personalized social stories, visual schedules and boards for parents, teachers and therapists. 1 credit = 1 new picture.",brand:{"@type":"Brand",name:"SocialNarratives"},offers:[{"@type":"Offer",name:"Free Plan",price:"0",priceCurrency:"USD",description:`${ge} welcome credits, free emoji schedules and boards`,availability:"https://schema.org/InStock"},{"@type":"Offer",name:"Family Plan",price:String(se.Family.monthly),priceCurrency:"USD",description:`${re.Family} picture credits each month; credits roll over and never expire`,availability:"https://schema.org/InStock",billingIncrement:"P1M"},{"@type":"Offer",name:"Professional Plan",price:String(se.Professional.monthly),priceCurrency:"USD",description:`${re.Professional} picture credits each month, white-label PDFs, prompt review`,availability:"https://schema.org/InStock",billingIncrement:"P1M"}]}}function Gt(){const{t:r}=V(["marketing","pricing"]);return Ue(),t.jsxs("div",{className:"min-h-screen bg-cream dark:bg-dim-deep font-['Nunito'] pt-20 transition-colors duration-200",children:[t.jsx($e,{title:r("pricing:meta.title"),description:r("pricing:meta.description",{count:ge}),canonicalPath:"/pricing",structuredData:jt()}),t.jsxs("div",{className:"text-center pt-8 pb-4 px-6",children:[t.jsx("h1",{className:"text-4xl md:text-5xl font-bold font-['Quicksand'] text-balance text-ink dark:text-dim-text mb-4",children:t.jsx(le,{i18nKey:"pricingPage.title",ns:"marketing",components:{highlight:t.jsx("span",{className:"text-sage-600 dar
2k:text-sage-300"})}})}),t.jsx("p",{className:"text-lg text-balance [word-break:keep-all] break-words text-slate-700 dark:text-dim-text-secondary max-w-2xl mx-auto",children:r("marketing:pricingPage.subtitle")})]}),t.jsx(St,{id:"pricing-page",bgColor:"bg-transparent",showHeader:!1})]})}export{Gt 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.