1import{a as L,u as z,r as w,j as e,B as N,t as k,s as K}from"./index-CaSTYgGV.js";import{u as A}from"./useQuery-0u8iV2uu.js";import{P as H}from"./plans-DDyIlJia.js";import{getPlanPriceId as E}from"./stripe-prices-DuVsPdrk.js";import{u as W}from"./usePlan-Cu1uFZ86.js";import{u as D}from"./useServerFn-DpeGoucF.js";import{D as q,b as O,c as M,d as T,e as U,f as _}from"./dialog-eKkod3VD.js";import{createCheckoutSession as G,createPortalSession as J,getCurrentSubscription as V}from"./stripe.functions-Bn_oQE4l.js";import{C as F}from"./check-IRFaGtS-.js";import{L as R}from"./loader-circle-pcNy7nb_.js";import{D as X}from"./DfyServicesSection-Be4j4eOS.js";import{A as Z}from"./arrow-right-DGwIXPvV.js";import"./x-C1CGEgbI.js";import"./auth-middleware-YdgUZbL3.js";const ee="[email protected]";function te({plan:s,annual:a,priceId:o,open:n,onOpenChange:i}){const{user:m}=L(),l=z(),v=D(G),[p,g]=w.useState(!1),c=s.id==="enterprise",f=o??E(s.id,a?"annual":"monthly"),b=s.features.slice(0,4),u=a&&s.annualPrice>0?(s.annualPrice/12).toFixed(2):null;async function P(){if(c){window.location.href=`mailto:${ee}?subject=${encodeURIComponent("Qatalog Enterprise enquiry")}`;return}if(!f){k.error("This plan can't be purchased right now.");return}if(!m){try{localStorage.setItem("qatalog:pendingPlanPrice",f)}catch{}l({to:"/signup"});return}g(!0);try{const{url:r}=await v({data:{priceId:f}});window.location.href=r}catch(r){k.error(r?.message??"Could not start checkout. Please try again."),g(!1)}}return e.jsx(q,{open:n,onOpenChange:r=>{p||i(r)},children:e.jsxs(O,{className:"max-w-md",children:[e.jsxs(M,{children:[e.jsx(T,{children:c?`${s.name}`:`Upgrade to ${s.name}`}),e.jsx(U,{children:c?"Custom pricing for larger teams.":a?e.jsxs(e.Fragment,{children:["â¬",s.annualPrice,"/year",u?` · â¬${u}/mo billed annually`:""]}):e.jsxs(e.Fragment,{children:["â¬",s.monthlyPrice,"/month"]})})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsx("ul",{className:"space-y-1.5 text-sm",children:b.map(r=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx(F,{className:"w-4 h-4 text-teal shrink-0 mt-0.5"})," ",r]},r))}),!c&&e.jsxs("div",{className:"rounded-lg bg-muted/50 border border-border p-3 text-xs text-muted-foreground",children:["You'll be redirected to Stripe's secure checkout to complete payment. Your plan activates instantly after payment.",a?" Annual plans include 2 months free.":""]}),e.jsx(_,{children:e.jsx(N,{onClick:P,disabled:p,className:"w-full bg-navy hover:bg-navy-light min-h-[44px]",children:p?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 mr-2 animate-spin"})," Redirectingâ¦"]}):c?"Let's talk":"Continue to payment"})})]})]})})}function se({open:s,onOpenChange:a}){const o=D(J),[n,i]=w.useState(!1);async function m(){i(!0);try{const{url:l}=await o({});window.location.href=l}catch(l){k.error(l?.message??"Could not open the billing portal."),i(!1)}}return e.jsx(q,{open:s,onOpenChange:l=>{n||a(l)},children:e.jsxs(O,{className:"max-w-md",children:[e.jsxs(M,{children:[e.jsx(T,{children:"Downgrade to Free"}),e.jsx(U,{children:"Cancel your subscription in the Stripe billing portal â your account drops to Free at the end of the current period."})]}),e.jsx("div",{className:"rounded-xl bg-teal/10 border border-teal/30 p-4 text-sm",children:"You'll keep all paid features until your current billing period ends. After that, your plan automatically switches to Free."}),e.jsxs(_,{children:[e.jsx(N,{variant:"outline",onClick:()=>a(!1),className:"min-h-[44px]",disabled:n,children:"Cancel"}),e.jsx(N,{onClick:m,disabled:n,className:"min-h-[44px] bg-navy hover:bg-navy-light",children:n?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 mr-2 animate-spin"})," Openingâ¦"]}):"Manage subscription"})]})]})})}const ae="[email protected]";function je(){const[s,a]=w.useState(!1),{plan:o}=W(),{user:n}=L(),[i,m]=w.useState(null),[l,v]=w.useState(!1),{data:p}=A({queryKey:["biz-billing",n?.id],enabled:!!n,queryFn:async()=>{const{data:t}=await K.from("businesses").select("stripe_subscription_id").maybeSingle();return t}}),g=!!p?.stripe_subscription_id,c=D(V),{data:f}=A({queryKey:["current-subscription",n?.id],enabled:!!n&&g,queryFn:()=>c({})}),b=f?.period??"monthly",u=o.id!=="free",P=H.filter(t=>t.id!=="enterprise"&&t.id!=="agency");
1function r(t){const x=s?"annual":"monthly";if(t.id===o.id&&(t.id==="free"||b===x))return;if(t.id==="free"){u&&v(!0);return}const j=E(t.id,x);j&&m({plan:t,priceId:j})}return e.jsxs("div",{className:"max-w-6xl",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Upgrade your plan"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Unlock more catalogs, items, and features."}),e.jsx(ne,{annual:s,setAnnual:a})]}),u&&e.jsxs("div",{className:"mb-6 rounded-xl border border-teal/30 bg-teal/10 px-4 py-3 text-sm",children:["You are currently on the ",e.jsx("strong",{children:o.name})," plan. Selecting a new plan will change your subscription instantly via Stripe."]}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-4 gap-5",children:P.map(t=>{const x=s?"annual":"monthly",d=t.id==="free",j=o.id===t.id,h=j&&(d||b===x),Y=j&&!d&&b!==x,S=h||t.highlighted,C=s&&!d&&t.annualPrice>0,B=C?`â¬${t.annualPrice}`:`â¬${t.monthlyPrice}`,Q=d?"":C?"/year":"/mo",I=C?`â¬${(t.annualPrice/12).toFixed(2)}/mo billed annually`:null;let y=t.cta;return h?y="Current plan":Y?y=x==="annual"?"Switch to annual":"Switch to monthly":d&&u?y="Downgrade to Free":!d&&g&&(y="Change plan"),e.jsxs("div",{className:`relative p-6 rounded-2xl border-2 bg-card flex flex-col ${S?"border-teal":"border-border"}`,children:[h?e.jsx("div",{className:"absolute -top-3 left-1/2 -translate-x-1/2 bg-teal text-white text-xs font-bold px-3 py-1 rounded-full uppercase whitespace-nowrap",children:"Current plan"}):t.badge?e.jsx("div",{className:"absolute -top-3 left-1/2 -translate-x-1/2 bg-gradient-teal text-navy text-xs font-bold px-3 py-1 rounded-full uppercase whitespace-nowrap",children:t.badge}):null,e.jsx("h3",{className:"font-bold",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.subtitle}),e.jsxs("div",{className:"mt-3 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-3xl font-bold",children:B}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Q})]}),I&&e.jsxs("p",{className:"mt-1 text-xs text-teal font-medium",children:[I," · 2 months free"]}),e.jsx("ul",{className:"mt-5 space-y-2 text-sm flex-1",children:t.features.map($=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx(F,{className:"w-4 h-4 text-teal shrink-0 mt-0.5"}),$]},$))}),e.jsx(N,{className:`w-full mt-6 min-h-[44px] ${S&&!h?"bg-navy hover:bg-navy-light":""}`,variant:S&&!h?"default":"outline",disabled:h,onClick:()=>r(t),children:y})]},t.id)})}),e.jsx("div",{className:"mt-12 p-8 md:p-10 rounded-2xl bg-navy text-white",children:e.jsxs("div",{className:"grid md:grid-cols-[1.4fr_1fr] gap-8 items-center",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl md:text-3xl font-extrabold",children:"Multiple locations or brands?"}),e.jsx("p",{className:"mt-3 text-white/75 max-w-xl",children:"If you're running several venues or a multi-brand group, we'll build a plan around your footprint â with white-label options and a dedicated manager."}),e.jsx("div",{className:"mt-5 grid sm:grid-cols-2 gap-2 text-sm",children:["Unlimited catalogs","White-label options","Dedicated manager","Onboarding & SLA"].map(t=>e.jsxs("span",{className:"inline-flex items-center gap-2 text-white/85",children:[e.jsx(F,{className:"w-4 h-4 text-teal"})," ",t]},t))})]}),e.jsx("div",{className:"flex md:justify-end",children:e.jsx("a",{href:`mailto:${ae}?subject=Qatalog%20Enterprise%20enquiry`,children:e.jsxs(N,{className:"h-12 px-6 font-semibold text-white bg-teal hover:bg-teal/90",children:["Let's talk ",e.jsx(Z,{className:"ml-1 w-4 h-4"})]})})})]})}),e.jsx("div",{className:"mt-16",children:e.jsx(X,{})}),i&&e.jsx(te,{plan:i.plan,priceId:i.priceId,annual:s,open:!!i,onOpenChange:t=>{t||m(null)}}),e.jsx(se,{open:l,onOpenChange:v})]})}function ne({annual:s,setAnnual:a}){return e.jsxs("div",{className:"inline-flex bg-secondary rounded-full p-1 mt-6 items-center",children:[e.jsx("button",{onClick:()=>a(!1),className:`px-4 py-1.5 text-sm rounded-full transition ${s?"text-muted-foreground":"bg-white shadow font-semibold text-navy"}`,children:"Monthly"}),e.jsxs("button",{onClick:()=>a(!0),className:`px-4 py-1.5 text-sm rounded-full inline-flex items-center gap-2 transition ${s?"bg-white shadow font-semibold text-navy":"text-muted-foreground"}`,children:["Annual",e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wide bg-teal text-white px-1.5 py-0.5 rounded-full",children:"2 months free"})]})]})}export{je as component};
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.