1import{r as E,j as e}from"./react-core-DSyq8rG5.js";import{u as K,t as m,a as j,C as U,m as D,j as G,U as O}from"./index-BPNuzlhq.js";import{C as Z}from"./crown-BsGmwHD8.js";import{C as I}from"./clock-Bi4UFwR1.js";import{C as $}from"./circle-check-Cvaezx5B.js";import{A as _}from"./arrow-up-right-CMJK3jeI.js";import{I as R}from"./info-ddtZfLuo.js";import{Z as H}from"./zap-DJY2JjIo.js";import{S as Q}from"./star-4UPK1eze.js";import"./data-vendor-UZRBCbS7.js";import"./ui-vendor-DvpBQNUS.js";function W(v){switch(v){case"active":return{label:"Active",badgeClassName:"bg-emerald-500/20 text-emerald-400 border-emerald-500/20",isActive:!0};case"past_due":return{label:"Payment needs attention",badgeClassName:"bg-amber-500/10 text-amber-300 border-amber-500/20",isActive:!1};case"cancelled":return{label:"Cancelled",badgeClassName:"bg-navy-700 text-muted-foreground border-navy-600",isActive:!1};case"paused":return{label:"Paused",badgeClassName:"bg-navy-700 text-muted-foreground border-navy-600",isActive:!1};case"trialing":return{label:"Payment pending",badgeClassName:"bg-amber-500/10 text-amber-300 border-amber-500/20",isActive:!1};default:return{label:"Not activated",badgeClassName:"bg-amber-500/10 text-amber-300 border-amber-500/20",isActive:!1}}}const Y={monthly:"monthly","6month":"biannual",annual:"annual"},q=[{id:"seed",name:"Starter",description:"For entrepreneurs just beginning their Kingdom business journey.",features:["Authenticated core Kingdom Coach workspace","Business Evaluation Tool","PA Command Centre","Getting Started checklist","1 business profile"],comingSoon:[],popular:!1,color:"text-blue-400",bg:"bg-blue-500/10",border:"border-blue-500/20"},{id:"growth",name:"Growth",description:"For entrepreneurs ready to scale with specialist coaching support.",features:["Everything in Starter","Verified access to specialist AI advisors","Evidence-aware business reflection tools","Private AI-assisted working drafts","SME Intake Wizard","Package-gated Coaching Room options"],comingSoon:["Live video sessions (Daily.co)","Google Calendar sync","WhatsApp coaching nudges"],popular:!0,color:"text-gold-400",bg:"bg-gold-500/10",border:"border-gold-500/20"},{id:"kingdom",name:"Kingdom",description:"For entrepreneurs who want the full Kingdom business transformation experience.",features:["Everything in Growth","Verified access to optional AI avatar sessions when the provider is available"],comingSoon:["White-label coaching reports","VIP retreat access","Marketplace listing","Priority support arrangements","Quarterly strategy review arrangements","Kingdom Business Certification path"],popular:!1,color:"text-purple-400",bg:"bg-purple-500/10",border:"border-purple-500/20"}],J=[{id:"coach_starter",name:"Solo Coach",description:"For independent coaches building their practice.",features:["Client invitations and relationship management","Client invite system (PIN, magic link, access code)","Session history & notes","Core private coaching workspace","Kingdom Coach AI for your own development"],comingSoon:["Live video sessions","Session recording"],popular:!1,color:"text-blue-400",bg:"bg-blue-500/10",border:"border-blue-500/20"},{id:"coach_pro",name:"Pro Coach",description:"For established coaches scaling their impact.",features:["Verified cohort management access","Verified specialist AI advisor access","Client progress tracking","Evidence-grounded client reports with client consent"],comingSoon:["White-label client portal","Automated session reports","Google Calendar sync"],popular:!0,color:"text-gold-400",bg:"bg-gold-500/10",border:"border-gold-500/20"}];function ce(){const{user:v}=K(),[C,F]=E.useState("monthly"),[x,k]=E.useState("overview"),f=v?.role==="coach",y=f?J:q,{data:l}=m.billing.getSubscription.useQuery(),{data:V}=m.billing.getAccess.useQuery(),{data:d,isLoading:z,isError:B,refetch:M}=m.billing.getPaymentReadiness.useQuery(),P=m.useUtils(),w=m.billing.updatePlan.useMutation({onSuccess:()=>{j.success("Plan preference saved. It does not activate paid access or create a charge."),P.billing.getSubscription.invalidate(),P.billing.getAccess.invalidate()},onError:t=>j.error(t.message)}),S=m.billing.createPayfastCheckout.useMutation({onSuccess:({actionUrl:t,fields:a})=>{const r=document.createElement("form");r.method="POST",r.action=t,r.style.display="none",Object.entries(a).forEac
1h(([s,u])=>{const i=document.createElement("input");i.type="hidden",i.name=s,i.value=u,r.appendChild(i)}),document.body.appendChild(r),r.submit()},onError:t=>j.error(t.message)}),N=l?.plan,n=y.find(t=>t.id===N)??y[0],b=W(l?.status),p=V?.hasVerifiedPackage??b.isActive,A=b.label,T=l?.billingCycle==="biannual"?"Six months":l?.billingCycle==="annual"?"Annual":"Monthly",o=Y[C],c=t=>t===void 0?"â":`R ${(t/100).toLocaleString("en-ZA",{minimumFractionDigits:0,maximumFractionDigits:2})}`,h=(t,a)=>d?.plans?.[t]?.[a],L=(t,a)=>{if(a==="monthly")return null;const r=h(t,"monthly"),s=h(t,a);if(r===void 0||s===void 0)return null;const i=r*(a==="biannual"?6:12)-s;return i<=0?null:`Save ${c(i)} ${a==="biannual"?"over six months":"per year"}`};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-serif text-2xl font-bold text-foreground",children:"Billing & Subscription"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Manage your plan preference and, when enabled, continue to secure hosted checkout."})]}),e.jsx("div",{className:"flex gap-1 p-1 bg-navy-900 border border-navy-700 rounded-xl w-fit",children:[{id:"overview",label:"Overview"},{id:"plans",label:"Change Plan"},{id:"history",label:"Invoice History"}].map(t=>e.jsx("button",{onClick:()=>k(t.id),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${x===t.id?"bg-gold-500 text-navy-950":"text-muted-foreground hover:text-foreground"}`,children:t.label},t.id))}),x==="overview"&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:`p-5 rounded-xl border ${n.border} ${n.bg}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Z,{size:16,className:n.color}),e.jsx("span",{className:`text-sm font-bold ${n.color}`,children:p?`${n.name} Package`:N?`${n.name} Plan Preference`:"No Package Activated"}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full border ${b.badgeClassName}`,children:A})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n.description})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"font-bold text-foreground",children:c(h(n.id,"monthly"))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"/month"})]})]}),!p&&e.jsx("p",{className:"mb-4 rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs leading-relaxed text-amber-100",children:"Your account is authenticated, but paid package access is not active. A saved plan preference, plan label, checkout return, or browser state never unlocks premium capabilities. Access starts only after a verified provider payment confirmation."}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-4",children:[{label:"Next billing",value:l?.currentPeriodEnd?new Date(l.currentPeriodEnd).toLocaleDateString("en-ZA"):"Not scheduled",icon:U},{label:"Payment method",value:l?.paymentProvider==="payfast"&&b.isActive?"PayFast":"Not collected",icon:D},{label:"Billing cycle",value:T,icon:I},{label:"Status",value:A,icon:$}].map(t=>{const a=t.icon;return e.jsxs("div",{className:"p-3 bg-navy-900/50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx(a,{size:12,className:"text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.label})]}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:t.value})]},t.label)})}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:()=>k("plans"),className:"flex items-center gap-1.5 px-4 py-2 rounded-lg text-sm font-medium border border-navy-600 text-muted-foreground hover:text-foreground hover:border-navy-500 transition-all",children:[e.jsx(_,{size:14})," Review plan options"]})})]}),e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-navy-900 border border-navy-700 rounded-xl",children:[e.jsx(R,{size:16,className:"text-gold-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gold-400",children:d?.checkoutEnabled?"Secure PayFast checkout available":"Secure checkout pending merchant activation"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:d?.checkoutEnabled?"Payment details are entered only on the PayFast-hosted page. BOSCH does not collect or store card details.":"Your plan preference can be saved now. Payment c
1ollection remains unavailable until the PayFast merchant account verification and signed ITN callback are active."})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[{label:"AI usage",value:"Not available",detail:"Measured usage is not available in Billing yet.",icon:H,color:"text-gold-400"},{label:"Strategy briefings",value:"Not available",detail:"No verified billing usage total is shown.",icon:G,color:"text-emerald-400"},{label:"Client activity",value:f?"View Clients":"Not applicable",detail:f?"Use Clients for relationship information.":"This measure does not apply to this workspace.",icon:O,color:"text-blue-400"}].map(t=>{const a=t.icon;return e.jsxs("div",{className:"p-4 bg-navy-900 border border-navy-700 rounded-xl",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(a,{size:14,className:t.color}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.label})]}),e.jsx("p",{className:"text-base font-semibold text-foreground",children:t.value}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:t.detail})]},t.label)})})]}),x==="plans"&&e.jsxs("div",{className:"space-y-5",children:[B&&e.jsxs("div",{role:"alert",className:"flex items-center justify-between gap-3 p-3 bg-red-500/10 border border-red-500/30 rounded-xl text-sm text-red-200",children:[e.jsx("span",{children:"Verified plan pricing could not be loaded. No plan change or checkout can be started until it is available."}),e.jsx("button",{type:"button",onClick:()=>void M(),className:"shrink-0 text-xs font-semibold text-red-100 underline underline-offset-4 hover:text-white",children:"Retry"})]}),e.jsx("div",{className:"flex items-center gap-2 p-1 bg-navy-900 border border-navy-700 rounded-xl w-fit",children:["monthly","6month","annual"].map(t=>e.jsxs("button",{onClick:()=>F(t),className:`px-4 py-2 rounded-lg text-sm font-medium transition-all ${C===t?"bg-gold-500 text-navy-950":"text-muted-foreground hover:text-foreground"}`,children:[t==="monthly"?"Monthly":t==="6month"?"6 Months":"Annual",t!=="monthly"&&e.jsx("span",{className:"ml-1.5 text-xs",children:t==="6month"?"â10%":"â20%"})]},t))}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:y.map(t=>{const a=p&&t.id===n.id,r=!p&&t.id===N,s=h(t.id,o),u=L(t.id,o),i=o==="biannual"?6:o==="annual"?12:1;return e.jsxs("div",{className:`p-5 rounded-xl border transition-all ${t.popular?`${t.border} ${t.bg} ring-2 ring-offset-2 ring-offset-navy-950 ring-gold-500/30`:"border-navy-700 bg-navy-900"}`,children:[t.popular&&e.jsxs("div",{className:"flex items-center gap-1 mb-3",children:[e.jsx(Q,{size:12,className:"text-gold-400"}),e.jsx("span",{className:"text-xs font-bold text-gold-400",children:"Kingdom Choice"})]}),e.jsx("p",{className:"font-bold text-foreground mb-1",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:t.description}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("p",{className:"text-2xl font-bold text-foreground",children:[c(s),e.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:o==="monthly"?"/month":o==="biannual"?"/6 months":"/year"})]}),u&&e.jsx("p",{className:"text-xs text-emerald-400 mt-0.5",children:u}),o!=="monthly"&&s!==void 0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[c(s/i)," effective per month. ",d?.checkoutEnabled?`Checkout total: ${c(s)}.`:`Package price shown: ${c(s)}. No payment is due while checkout is unavailable.`]})]}),e.jsxs("div",{className:"space-y-2 mb-4",children:[t.features.map(g=>e.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-foreground",children:[e.jsx($,{size:11,className:"text-emerald-400 mt-0.5 shrink-0"}),g]},g)),t.comingSoon&&t.comingSoon.map(g=>e.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-muted-foreground",children:[e.jsx(I,{size:11,className:"text-muted-foreground mt-0.5 shrink-0"}),g," ",e.jsx("span",{className:"text-xs text-muted-foreground/50",children:"(roadmap)"})]},g))]}),a?e.jsx("div",{className:"w-full py-2 text-center text-xs font-medium text-muted-foreground border border-navy-600 rounded-lg",children:"Active verified package"}):e.jsx("button",{onClick:()=>{d?.checkoutEnabled?S.mutate({plan:t.id,billingCycle:o}):w.mutate({plan:t.id,billingCycle:o})},disabled:w.isPending||S.isPending||z||s===void 0,className:`w-full py-2 rounded-lg text-xs font-bold transition-all disabled:opacity-60 ${t.popular?"bg-gold-500 text-navy-950 hover:bg-gold-400":"border border-navy-600 text-foreground hover:border-navy-500"}`,children:s===void 0?"Verified pricing unavailable":d?.checkoutEnabled?"Continue to secure checkout":r?"Update "+t.name+" preference":t.popular?"Choose "+t.
1name:"Save "+t.name+" preference"})]},t.id)})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"All totals are calculated by the server in South African Rand (ZAR). VAT treatment is confirmed at checkout. Plan cancellation is governed by the plan terms shown before payment."})]}),x==="history"&&e.jsxs("div",{className:"p-5 bg-navy-900 border border-navy-700 rounded-xl space-y-4",children:[e.jsx("h2",{className:"font-semibold text-foreground",children:"Invoice History"}),e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-navy-800 border border-navy-700 rounded-lg",children:[e.jsx(R,{size:13,className:"text-muted-foreground mt-0.5 shrink-0"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Payment history is not available until a verified payment gateway, checkout flow, and provider webhooks are activated. This portal will show only confirmed provider payment records once that work is complete."})]})]})]})}export{ce 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.