1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3781],{53781:(e,a,t)=>{t.d(a,{V:()=>Y});var r=t(21573),l=t(77665),s=t(662),n=t(14835),i=t(91623),o=t(75299),c=t(64748),d=t(65519),u=t(31508);t(34666);let m=async e=>await (0,d.FL)("/business/make-paystack-subscription","post",e),p=async(e,a)=>await (0,d.FL)(u.SCt,"post",{pricing_plan:e,subscription_interval:a}),x=async()=>await (0,d.FL)("/business/activate-starter-plan","post",{}),h=async e=>await (0,d.FL)(u.kO4,"post",e),v=async e=>await (0,d.FL)("/business/educator-subscription-checkout","post",e);var b=t(40134),y=t(79563),f=t(69934),g=t(37139),j=t(9346),w=t(63895),N=t(52149);function k(e){let{currentPlanInterval:a,provider:t,onChange:l}=e;return"paystack"===t?(0,r.jsx)("div",{className:"inline-flex max-w-full items-center bg-[color:var(--muted)] rounded-full p-1",children:[{key:"quarterly",label:"Quarterly"},{key:"semi_annually",label:"6 Months",badge:"Save 10%"},{key:"annually",label:"Annually",badge:"Save 20%"}].map(e=>(0,r.jsxs)("button",{onClick:()=>l(e.key),className:(0,N.cn)("relative rounded-full px-2.5 sm:px-5 py-1.5 sm:py-2 text-[13px] sm:text-sm font-medium transition-all flex items-center gap-1 sm:gap-2 whitespace-nowrap",a===e.key?"bg-white text-[color:var(--title)] shadow-sm dark:bg-[color:var(--mono)] dark:text-[color:var(--background)]":"text-[color:var(--body)] hover:text-[color:var(--title)]"),children:[e.label,e.badge&&a===e.key&&(0,r.jsx)("span",{className:"text-xs text-primary font-medium dark:text-[color:var(--background)] dark:opacity-70",children:e.badge})]},e.key))}):(0,r.jsx)("div",{className:"inline-flex items-center bg-[color:var(--muted)] rounded-full p-1",children:[{key:"monthly",label:"Monthly"},{key:"semi_annually",label:"6 Months",badge:"-15%"},{key:"annually",label:"Yearly",badge:"-25%"}].map(e=>(0,r.jsxs)("button",{onClick:()=>l(e.key),className:(0,N.cn)("relative rounded-full px-2.5 sm:px-4 py-1.5 sm:py-2 text-[13px] sm:text-sm font-medium transition-all flex items-center gap-1 sm:gap-1.5 whitespace-nowrap",a===e.key?"bg-white text-[color:var(--title)] shadow-sm dark:bg-[color:var(--mono)] dark:text-[color:var(--background)]":"text-[color:var(--body)] hover:text-[color:var(--title)]"),children:[e.label,e.badge&&(0,r.jsx)("span",{className:(0,N.cn)("text-xs font-medium",a===e.key?"text-primary dark:text-[color:var(--background)] dark:opacity-70":"text-primary/70"),children:e.badge})]},e.key))})}var _=t(23669),S=t(98069),C=t.n(S),A=t(49602),P=t(68945),F=t(97247),L=t(29888),D=t(23866);function T(e){var a;let{plan:t,onSelectTrial:l,onSelectPlan:s,onTalkToSales:n,loadingPlan:o,isLoading:c,price:d,clickedTrail:u,provider:m,isTrailLoading:p,currentPlanInterval:x}=e,{overview:h}=(0,w.ym)(),v=null==h?void 0:h.khaime_subscription,b={planType:(null==v?void 0:v.plan_type)?"business_".concat(v.plan_type):null,status:(null==v?void 0:v.status)||null,isTrialling:(null==v?void 0:v.status)==="trialing"},y="business_pro"===t.name,f="educator_standard"===t.name||"business_custom"===t.name||"custom"===t.name,g="starter"===t.name||"basic"===t.name,j=!f&&!g&&d<=0,k={starter:"For new Merchants who want to launch their first store",basic:"For new Merchants who want to launch their first store",business_standard:"For small businesses ready to take their presence online",standard:"For small businesses ready to take their presence online",business_pro:"For growing teams that need all powerful capabilities",pro:"For growing teams that need all powerful capabilities",educator_standard:"For marketplaces, large teams, and advanced workflows",business_custom:"For marketplaces, large teams, and advanced workflows",custom:"For marketplaces, large teams, and advanced workflows"},_=k[t.name]||k[null==t||null==(a=t.label)?void 0:a.toLowerCase()]||"",S=()=>{if(!b.planType)return!1;let e=b.planType===t.name,a="active"===b.status;return e&&a},C=function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD",t=D.VK.reduce((e,a)=>(e[a.currencyCode]=a.symbol,e),{});return(0,L.KP)(e.toFixed(2),{prefix:t[a],thousandSeparator:!0,decimalScale:2,fixedDecimalScale:!0})},A=o===t.name;return(0,r.jsx)("div",{className:"flex flex-col",children:(0,r.jsx)("div",{className:(0,N.cn)("relative border bg-[color:var(--card-bg)] transition-all duration-200 flex flex-col h-full overflow-hidden rounded-2xl",y?"border-primary border-[1.5px] shadow-card":"border-[color:var(--border)] hover:border-[color:var(--stroke)]"),children:(0,r.jsxs)("div",{className:"p-4 sm:p-5 flex flex-col h-full",children:[(0,r.jsxs)("div",{className:"mb-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-base font-semibold text-[color:var(--title)]",children:t.label}),y&&(0,r.jsx)("span",{className:"shrink-0 rounded-full bg-primary/12 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-primary",children:"Popular"})]}),(0,r.jsx)("p",{className:"text-xs text-[color:var(--body)] mt-1 leading-relaxed sm:min-h-[32px]",children:_})]}),(0,r.jsx)("div",{className:"mb-3 sm:mb-4 sm:min-h-[62px]",children:f?(0,r.jsxs)("div",{className:"flex items-baseline gap-1",children:[(0,r.jsx)("span",{className:"text-2xl font-semibold text-[color:var(--title)]",children:"Custom"}),(0,r.jsx)("span",{className:"text-sm text-[color:var(--body)]",children:"pricing"})]}):g?(0,r.jsx)("div",{className:"flex items-baseline gap-1",children:(0,r.jsx)("span",{className:"text-2xl font-semibold text-[color:var(--title)]",children:"Free"})}):j?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-1",children:[(0,r.jsx)("span",{className:"text-2xl font-semibold text-[color:var(--body)]",children:"â"}),(0,r.jsx)("span",{className:"text-sm text-[color:var(--body)]",children:"/month"})]}),(0,r.jsx)("p",{className:"text-xs text-[color:var(--body)] mt-1",children:"Pricing unavailable â please retry"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-1",children:[(0,r.jsx)("span",{className:(0,N.cn)("text-2xl font-semibold","text-[color:var(--title)]"),children:(()=>{let e="paystack"===m?"NGN":"USD";switch(x){case"quarterly":return C(d/3,e);case"semi_annually":return C(d/6,e);case"annually":return C(d/12,e);default:return C(d,e)}})()}),(0,r.jsx)("span",{className:"text-sm text-[color:var(--body)]",children:"/month"})]}),(0,r.jsx)("p",{className:"text-xs text-[color:var(--body)] mt-1",children:(()=>{let e="paystack"===m?"NGN":"USD";switch(x){case"quarterly":return"".concat(C(d,e)," billed quarterly");case"semi_annually":return"".concat(C(d,e)," billed every 6 months");case"annually":return"".concat(C(d,e)," billed yearly");default:return"Billed monthly"}})()})]})}),(0,r.jsxs)("div",{className:"mb-4 sm:mb-5",children:[(0,r.jsx)("button",{onClick:f?n:s,disabled:c||p||j||S()&&!f,className:(0,N.cn)("w-full rounded-full px-4 py-3 text-sm font-medium transition-all flex items-center justify-center gap-2",y?"bg-primary text-primary-foreground hover:opacity-90 disabled:opacity-50":S()?"bg-[color:var(--muted)] text-[color:var(--body)] curs
1or-default":"bg-[color:var(--card-bg)] border border-[color:var(--border)] text-[color:var(--title)] hover:bg-[color:var(--muted)] disabled:opacity-50"),children:A&&!f?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.A,{className:"h-4 w-4 animate-spin"}),"Processing..."]}):(0,r.jsxs)(r.Fragment,{children:[f?"Contact Us":S()?"Current Plan":(()=>{if(!b.planType)return!1;let e=b.planType===t.name,a=["expired","cancelled","past_due","unpaid"].includes(b.status||"");return e&&a})()?"Reactivate":y?"Get Pro":"Continue",!S()&&(0,r.jsx)(F.A,{className:"h-4 w-4"})]})}),!S()&&!("active"===b.status&&!b.isTrialling)&&!(b.planType&&["expired","cancelled","past_due","unpaid"].includes(b.status||""))&&!b.isTrialling&&!f&&!g&&d>0&&(0,r.jsx)("button",{onClick:l,disabled:p||c,className:(0,N.cn)("w-full mt-2 text-xs hover:underline disabled:opacity-50","text-primary"),children:u===t.name?(0,r.jsxs)("span",{className:"flex items-center justify-center gap-1",children:[(0,r.jsx)(i.A,{className:"h-3 w-3 animate-spin"}),"Starting trial..."]}):"Start 14-day free trial"})]}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("p",{className:"text-sm text-[color:var(--body)] mb-3",children:g?"Includes:":f?(0,r.jsxs)(r.Fragment,{children:["Includes all from ",(0,r.jsx)("span",{className:"font-semibold text-[color:var(--title)]",children:"PRO"}),", and:"]}):y?(0,r.jsxs)(r.Fragment,{children:["Includes all from ",(0,r.jsx)("span",{className:"font-semibold text-[color:var(--title)]",children:"STANDARD"}),", and:"]}):"Includes:"}),(0,r.jsx)("ul",{className:"space-y-3",children:t.features&&t.features.slice(0,7).map((e,a)=>(0,r.jsxs)("li",{className:"flex items-start gap-3 text-sm text-[color:var(--body)]",children:[(0,r.jsx)(P.A,{className:(0,N.cn)("w-5 h-5 shrink-0","text-primary"),strokeWidth:2}),(0,r.jsx)("span",{children:e})]},a))}),t.features&&t.features.length>6&&(0,r.jsx)("p",{className:(0,N.cn)("text-xs mt-3 font-medium","text-primary"),children:"And many more features..."})]})]})})})}var M=t(89882),E=t(86064),I=t(834),U=t(58768),q=t(52151);function O(e){let{plan:a,checkoutData:t,interval:l,price:n,provider:o,onBack:c,onSuccess:d}=e,u=(0,M.c)(t.publishable_key),{logout:m}=(0,f.useAuth)();return(0,r.jsxs)("div",{className:"w-full",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,r.jsxs)("button",{onClick:c,className:"flex items-center gap-2 text-[color:var(--body)] hover:text-[color:var(--title)] text-sm font-medium transition-colors",children:[(0,r.jsx)(s.A,{className:"w-4 h-4"}),"Back to plans"]}),(0,r.jsxs)("button",{onClick:()=>{m(),window.location.href="/login"},className:"flex items-center gap-2 text-[color:var(--body)] hover:text-red-500 text-sm font-medium transition-colors",children:[(0,r.jsx)(I.A,{className:"w-4 h-4"}),"Logout"]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[(0,r.jsx)("div",{className:"order-2 lg:order-1",children:(0,r.jsx)(B,{plan:a,interval:l,price:n,provider:o})}),(0,r.jsx)("div",{className:"order-1 lg:order-2",children:(0,r.jsxs)("div",{className:"bg-[color:var(--card-bg)] rounded-2xl border border-[color:var(--border)] p-6",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,r.jsx)(U.A,{className:"w-4 h-4 text-emerald-500"}),(0,r.jsx)("h3",{className:"font-semibold text-[color:var(--title)]",children:"Secure Payment"})]}),t.client_secret?(0,r.jsx)(E.S8,{stripe:u,options:{clientSecret:t.client_secret,appearance:{theme:"stripe",variables:{colorPrimary:"#3b82f6",borderRadius:"12px",fontFamily:"Inter, system-ui, sans-serif"}}},children:(0,r.jsx)(R,{onSuccess:d,planName:a.label})}):(0,r.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,r.jsx)(i.A,{className:"h-8 w-8 animate-spin text-primary"})}),(0,r.jsx)("div",{className:"mt-6 pt-4 border-t border-[color:var(--border)]",children:(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2 text-xs text-[color:var(--body)]",children:[(0,r.jsx)(q.A,{className:"w-4 h-4"}),(0,r.jsx)("span",{children:"Your payment is secured with 256-bit SSL encryption"})]})})]})})]})]})}function B(e){var a;let{plan:t,interval:l,price:s,provider:n}=e,i="business_pro"===t.name,o="educator_standard"===t.name,c=function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD",t=D.VK.reduce((e,a)=>(e[a.currencyCode]=a.symbol,e),{});return(0,L.KP)(e.toString(),{prefix:t[a],thousandSeparator:!0,decimalScale:2,fixedDecimalScale:!0})},d=e=>c(e,"paystack"===n?"NGN":"USD");return(0,r.jsxs)("div",{className:(0,N.cn)("rounded-2xl border-2 p-6",i?"border-[color:var(--wallet-purple)] bg-[
1color:var(--card-bg)]":o?"border-amber-500 bg-[color:var(--card-bg)]":"border-[color:var(--border)] bg-[color:var(--card-bg)]"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("div",{children:(0,r.jsx)("span",{className:(0,N.cn)("text-xs font-semibold px-3 py-1 rounded-full",i?"bg-[color:var(--wallet-purple)]/15 text-[color:var(--wallet-purple)]":o?"bg-amber-500/15 text-amber-500":"bg-[color:var(--muted)] text-[color:var(--title)]"),children:t.label})}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(P.A,{className:"w-4 h-4 text-emerald-500"}),(0,r.jsx)("span",{className:"text-xs text-emerald-500 font-medium",children:"Selected"})]})]}),(0,r.jsxs)("div",{className:"mb-6",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-1",children:[(0,r.jsx)("span",{className:(0,N.cn)("text-3xl font-semibold",i?"text-[color:var(--wallet-purple)]":o?"text-amber-500":"text-[color:var(--title)]"),children:d(s)}),(0,r.jsx)("span",{className:"text-[color:var(--body)] text-sm",children:(e=>{switch(e){case"quarterly":return"every 3 months";case"semi_annually":return"every 6 months";case"annually":return"every year";default:return"every month"}})(l)})]}),(0,r.jsxs)("div",{className:"mt-3 space-y-1.5",children:[(0,r.jsxs)("p",{className:"text-sm text-[color:var(--body)]",children:[(0,r.jsx)("span",{className:"text-[color:var(--title)] font-medium",children:d(s)})," due today"]}),(0,r.jsxs)("p",{className:"text-sm text-[color:var(--body)]",children:["Next billing: ",(0,r.jsx)("span",{className:"text-[color:var(--title)] font-medium",children:(e=>{let a=new Date;switch(e){case"quarterly":a.setMonth(a.getMonth()+3);break;case"semi_annually":a.setMonth(a.getMonth()+6);break;case"annually":a.setFullYear(a.getFullYear()+1);break;default:a.setMonth(a.getMonth()+1)}return a.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})})(l)})]})]})]}),(0,r.jsxs)("div",{className:"border-t border-[color:var(--border)] pt-4",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold text-[color:var(--title)] uppercase tracking-wide mb-3",children:"What's included"}),(0,r.jsx)("ul",{className:"space-y-2",children:null==(a=t.features)?void 0:a.slice(0,6).map((e,a)=>(0,r.jsxs)("li",{className:"flex items-start gap-2",children:[(0,r.jsx)("div",{className:(0,N.cn)("flex-shrink-0 w-4 h-4 rounded-full flex items-center justify-center mt-0.5",i?"bg-[color:var(--wallet-purple)]/15 text-[color:var(--wallet-purple)]":o?"bg-amber-500/15 text-amber-500":"bg-[color:var(--muted)] text-[color:var(--body)]"),children:(0,r.jsx)(P.A,{className:"w-2.5 h-2.5",strokeWidth:3})}),(0,r.jsx)("span",{className:"text-sm text-[color:var(--body)]",children:e})]},a))}),t.features&&t.features.length>6&&(0,r.jsxs)("p",{className:"text-xs text-[color:var(--body)] mt-2",children:["+",t.features.length-6," more features included"]})]})]})}function R(e){let{onSuccess:a,planName:t}=e,s=(0,E.HH)(),n=(0,E.t2)(),[o,c]=(0,l.useState)(!1),{revalidate:d}=(0,f.useAuth)(),u=async e=>{if(e.preventDefault(),n&&s){c(!0);try{let{error:e,setupIntent:r}=await n.confirmSetup({elements:s,confirmParams:{return_url:window.location.href},redirect:"if_required"});e?y.o.error(e.message||"Payment failed. Please try again."):(null==r?void 0:r.status)==="succeeded"&&(y.o.success("Successfully subscribed to ".concat(t,"!")),sessionStorage.setItem("subscription_just_paid",Date.now().toString()),d(),a(),setTimeout(()=>{window.location.reload()},3e3))}catch(e){y.o.error("An unexpected error occurred. Please try again.")}finally{c(!1)}}};return(0,r.jsxs)("form",{onSubmit:u,children:[(0,r.jsx)(E.He,{options:{layout:"tabs"}}),(0,r.jsx)("button",{type:"submit",disabled:!n||!s||o,className:(0,N.cn)("w-full mt-6 rounded-xl px-4 py-3.5 text-sm font-semibold transition-all flex items-center justify-center gap-2","bg-primary text-primary-foreground hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed"),children:o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.A,{className:"h-4 w-4 animate-spin"}),"Processing..."]}):(0,r.jsxs)(r.Fragment,{children:["Subscribe Now",(0,r.jsx)(F.A,{className:"h-4 w-4"})]})})]})}function Y(e){var a,t;let{isSubscriptionModalOpen:u}=e,[N,S]=(0,l.useState)(null),[P,F]=(0,l.useState)(!1),[L,M]=(0,l.useState)(null),[E,I]=(0,l.useState)(null),[U,q]=(0,l.useState)(!1),[B,R]=(0,l.useState)(!1),[Y,z]=(0,l.useState)(!1),{setIsSubscriptionModalOpen:W,revalidate:G,loggedInUser:K,mobileCheckoutData:H,setMobileCheckoutData:Z}=(0,f.useAuth)(),{currentPlanInterval:Q,setCurrentPlanInterval:V,chooseEducatorStandardPlan:J,chooseBusinessStandardPlan:X,chooseBusinessProPlan:$,pricings:ee,isLoading:ea,createSubscriptionCheckout:et,handleSelectTrial:er,handleActivateStarterPlan:el,isStartingFreeTrial:es,isActivatingStarter:en,hasPricingData:ei,retry:eo}=(()=>{var e;let{setIsSubscriptionModalOpen:a,revalidate:t,loggedInUser:r}=(0,f.useAuth)(),{mutate:s}=(0,w.IS)(),[n,i]=(0,l.useState)("monthly"),[o,u]=(0,l.useState)(!1),[v,N]=(0,l.useState)(null),k=(0,b.usePathname)(),_=(0,b.useSearchParams)(),{pages:S}=(0,j.s)(),{data:C,error:A,isLoading:P,mutate:F}=(0,c.Ay)("/business/country-subscription-plans",d.GO),L=(null==C?void 0:C.data)||null,D=null==L?void 0:L.provider,{data:T,isLoading:M}=(0,c.Ay)(L&&!L.pricing_plans?"/khaime/fetch-pricing-plan":null,d.GO),E=(null==L?void 0:L.pricing_plans)||(null==T||null==(e=T.data)?void 0:e.pricing_plans)||null;(0,l.useEffect)(()=>{D&&i("paystack"===D?"quarterly":"monthly")},[D]);let I=(e,a)=>{let t=e.find(e=>"monthly"===a?"month"===e.interval.interval&&1===e.interval.interval_count:"quarterly"===a?"month"===e.interval.interval&&3===e.interval.interval_count:"semi_annually"===a?"month"===e.interval.interval&&6===e.interval.interval_count:"annually"===a?"year"===e.interval.interval&&1===e.interval.interval_count:void 0);if(!t)return null;let r=t.amount;return"quarterly"===a?r=t.amount/3:"semi_annually"===a?r=t.amount/6:"annually"===a&&(r=t.amount/12),{...t,monthlyPrice:r}},U=L?I(L.educator_standard_prices,n):null,q=L?I(L.business_standard_prices,n):null,O=L?I(L.business_pro_prices,n):null,B=async(e,l,n,i)=>{u(!0);try{let c=null==r?void 0:r.khaime_subscription,d=(null==c?void 0:c.status)==="active"||(null==c?void 0:c.status)!=="trialing"&&(null==c?void 0:c.status)!=null,p=new URLSearchParams(_),x=new URLSearchParams(_);if((null==L?void 0:L.provider)!=="paystack"){console.warn("createSubscriptionCheckout called for non-Paystack provider"),u(!1);return}try{let r=d?await h({price_id:e,payment_by:"educator",pricing_plan:l,subscription_interval:n,amount:i,success_url:"".concat(window.location.origin).concat(k,"?").concat(p.toString(),"&isSubscribe=true")}):await m({priceId:e,payment_by:"educator",pricing_plan:l,subscription_interval:n,amount:i,success_url:"".concat(window.location.origin).concat(k,"?").concat(p.toString(),"&isSubscribe=true"),cancel_url:"".concat(window.location.origin).concat(k,"?").concat(x.toString())});if(r.status>=400){var o;y.o.error((null==(o=r.data)?void 0:o.message)||"Something went wrong");return}t(),s(),window.open(r.data.data.authorization_url,"_self"),setTimeout(()=>{a(!1)},2e3)}catch(e){console.error("Error creating subscription:",e),y.o.error("Failed to create subscription")}finally{u(!1)}}catch(e){console.error("Error creating subscription:",e),y.o.error("Failed to create subscription")}finally{u(!1)}};async function R(e,a){if(!e)return;N(e);let r=await p(e,a);
1if(200===r.status||201===r.status)S.length>0?await (0,g.hE)(S,"draft")&&t():t(),y.o.success("Free Trial Started Successfully"),window.location.reload();else{var l;y.o.error((null==(l=r.data)?void 0:l.message)||"Failed to start free trial"),N(null)}}let[Y,z]=(0,l.useState)(!1);async function W(){z(!0);try{let r=await x();if(200===r.status||201===r.status)S.length>0?await (0,g.hE)(S,"draft")&&t():t(),y.o.success("Starter plan activated successfully!"),a(!1),window.location.reload();else{var e;y.o.error((null==(e=r.data)?void 0:e.message)||"Failed to activate starter plan")}}catch(e){y.o.error((null==e?void 0:e.message)||"Failed to activate starter plan")}finally{z(!1)}}return{currentPlanInterval:n,setCurrentPlanInterval:i,chooseEducatorStandardPlan:U,chooseBusinessStandardPlan:q,chooseBusinessProPlan:O,pricings:L&&E?{pricing_plans:E,provider:L.provider||"stripe",currency:L.currency||"USD"}:null,hasPricingData:!!L,pricingDataError:A,isCreatingSub:o,isStartingFreeTrial:v,isActivatingStarter:Y,createSubscriptionCheckout:B,handleSelectTrial:R,handleActivateStarterPlan:W,retry:()=>{F()},isLoading:P||M}})(),{isTrialing:ec,daysLeft:ed,freeTrialEnded:eu}=(0,D.AR)(K);(0,l.useEffect)(()=>{let e=()=>{F(window.innerWidth<768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,l.useEffect)(()=>{u||(M(null),I(null),q(!1),R(!1),z(!1),Z(null))},[u,Z]),(0,l.useEffect)(()=>{if(H&&u&&!Y){let e={id:H.plan,name:H.plan,label:H.plan_label,features:[],amount:String(H.amount)},a={client_secret:H.client_secret,publishable_key:H.publishable_key,intent_type:H.intent_type||"setup_intent",customer_id:"",price_details:{amount:H.amount,currency:H.currency,interval:H.interval,plan_type:H.plan}};M({plan:e,planId:H.plan,price:H.amount}),I(a),V(H.interval)}},[H,u,Y,V]);let[em,ep]=(0,l.useState)(!1),ex=null==K?void 0:K.khaime_subscription,eh=(null==ex?void 0:ex.is_custom)||(null==ex?void 0:ex.plan_type)==="custom",ev=null==ex?void 0:ex.is_complimentary;(0,l.useEffect)(()=>{!u||L||E||H||!eh||ev||em||(null==ex?void 0:ex.status)!=="pending"&&(null==ex?void 0:ex.status)!=="trialing"||(async()=>{ep(!0),q(!0);try{let a=(null==ex?void 0:ex.amount_paid)||0,t=a/100;null==ex||ex.currency;let r=(null==ex?void 0:ex.interval)||"monthly",l=(null==ex?void 0:ex.plan_type)||"custom",s=(null==ex?void 0:ex.plan_label)||"Custom Plan",n={id:l,name:l,label:s,features:[],amount:String(t)},i=await v({pricing_plan:l,subscription_interval:r,price_id:"custom_plan",amount:a.toString(),is_custom_plan:!0});if(i.status>=400){var e;y.o.error((null==(e=i.data)?void 0:e.message)||"Failed to initiate checkout"),ep(!1);return}M({plan:n,planId:l,price:t}),I(i.data.data),V(r)}catch(e){console.error("Error initiating custom plan checkout:",e),y.o.error("Failed to initiate checkout. Please try again."),ep(!1)}finally{q(!1)}})()},[u,L,E,H,eh,ev,em,ex,V]),(0,l.useEffect)(()=>{u||ep(!1)},[u]);let eb=async(e,a)=>{try{await er(e,a)}catch(e){y.o.error("Error starting trial subscription"),S(null)}},ey=async(e,a,t)=>{if("starter"===e.name||"basic"===e.name){S(e.name),await el(),S(null);return}if(!t||t<=0||!a){y.o.error("Pricing is currently unavailable. Please try again."),eo();return}q(!0),S(e.name);try{let l=eN(t,Q);if((null==ee?void 0:ee.provider)==="paystack")return void await et(a,e.name,Q,l.toString());let s=await v({pricing_plan:e.name,subscription_interval:Q,price_id:a,amount:l.toString()});if(s.status>=400){var r;y.o.error((null==(r=s.data)?void 0:r.message)||"Failed to initiate checkout");return}M({plan:e,planId:a,price:t}),I(s.data.data)}catch(e){console.error("Error initiating checkout:",e),y.o.error("Failed to initiate checkout. Please try again.")}finally{q(!1),S(null)}},ef=()=>{if(H){Z(null),W(!1),window.location.href="khaime://subscription-cancel";return}M(null),I(null),R(!1)},eg=()=>{R(!0)},ej=null==ee?void 0:ee.pricing_plans,ew=(0,l.useMemo)(()=>Array.isArray(ej)?ej.map(e=>({...e,name:e.name,plan:e.name.toLowerCase()})):[],[ej]),eN=(e,a)=>{switch(a){case"quarterly":return Math.floor(e/3);case"semi_annually":return Math.floor(e/6);case"annually":return Math.floor(e/12);default:return e}};function ek(e){switch(e){case"educator_standard":return(null==J?void 0:J.id)||"";case"business_standard":return(null==X?void 0:X.id)||"";case"business_pro":return(null==$?void 0:$.id)||"";default:return""}}function e_(e){switch(e){case"educator_standard":return(null==J?void 0:J.amount)||0;case"business_standard":return(null==X?void 0:X.amount)||0;case"business_pro":return(null==$?void 0:$.amount)||0;default:return 0}}let eS=(null==E||null==(a=E.price_details)?void 0:a.interval)||Q,eC=L&&E&&(0,r.jsx)("div",{className:"w-full p-4",children:(0,r.jsx)(O,{plan:L.plan,checkoutData:E,interval:eS,price:L.price,provider:(null==ee?void 0:ee.provider)||"stripe",onBack:ef,onSuccess:()=>
1{if(H){z(!0),G();return}W(!1),M(null),I(null),G()}})}),eA=(0,r.jsxs)("div",{className:"w-full p-8 flex flex-col items-center justify-center min-h-[400px]",children:[(0,r.jsx)("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mb-6",children:(0,r.jsx)("svg",{className:"w-8 h-8 text-green-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),(0,r.jsx)("h2",{className:"text-2xl font-semibold text-[color:var(--title)] mb-2",children:"Payment Successful!"}),(0,r.jsx)("p",{className:"text-[color:var(--body)] text-center mb-8 max-w-md",children:"Your subscription has been activated. Would you like to return to the Khaime app?"}),(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3 w-full max-w-sm",children:[(0,r.jsx)(_.Button,{onClick:()=>{Z(null),z(!1),window.location.href="khaime://subscription-success"},className:"flex-1 bg-primary hover:bg-primary/90 text-white",size:"lg",children:"Return to App"}),(0,r.jsx)(_.Button,{onClick:()=>{Z(null),z(!1),W(!1),M(null),I(null)},variant:"outline",className:"flex-1",size:"lg",children:"Stay on Web"})]})]}),eP=(0,r.jsxs)("div",{className:"w-full p-4",onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,r.jsx)("button",{onClick:ef,className:"p-2 hover:bg-[color:var(--muted)] rounded-full transition-colors",children:(0,r.jsx)(s.A,{className:"h-5 w-5 text-[color:var(--body)]"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-xl font-semibold text-[color:var(--title)]",children:"Schedule a Call"}),(0,r.jsx)("p",{className:"text-sm text-[color:var(--body)]",children:"Book a time to discuss your enterprise needs with our team"})]})]}),(0,r.jsx)("div",{className:"w-full rounded-xl overflow-hidden border border-[color:var(--border)] bg-[color:var(--card-bg)]",style:{height:"600px"},onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,r.jsx)("iframe",{src:"https://calendar.google.com/calendar/appointments/schedules/AcZssZ3HDoSeMa9mDnQTXmIvOACULzWZ7kemcGAuuN8sTJulli-Y7AfISZmdijNTecxbK3TwkJfqaQmH?gv=true",style:{border:0,width:"100%",height:"100%"},frameBorder:"0",title:"Schedule a call with Khaime Sales"})})]}),eF=(0,r.jsxs)("div",{className:"space-y-6 w-full",children:[(ec||eu)&&(0,r.jsxs)("div",{className:"w-full px-4 py-3 rounded-xl flex items-center justify-center gap-3 ".concat(eu?"bg-[color:var(--card-bg)] text-[color:var(--title)] border border-[color:var(--border)]":"bg-gradient-to-r from-amber-500 to-orange-500 text-white"),children:[ec&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"bg-[color:var(--card-bg)] border border-[color:var(--border)] rounded-lg px-2.5 py-1 flex flex-col items-center min-w-[45px]",children:[(0,r.jsx)("span",{className:"text-lg font-semibold text-[color:var(--title)]",children:ed}),(0,r.jsx)("span",{className:"text-[10px] text-[color:var(--body)] font-medium",children:1===ed?"Day":"Days"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(n.A,{className:"w-4 h-4"}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Your free trial ends soon. Upgrade now to keep your access!"})]})]}),eu&&(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(n.A,{className:"w-4 h-4"}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Your free trial has ended. Choose a plan to continue."})]})]}),(0,r.jsxs)("div",{className:"sticky -top-4 z-10 -mx-4 flex flex-col items-center gap-2 px-4 pb-2.5 pt-2.5 sm:flex-row sm:items-center sm:justify-between sm:gap-4 sm:pb-4 sm:pt-4 border-b border-[color:var(--border)] bg-[color:var(--card-bg)]/98 backdrop-blur-sm",children:[(0,r.jsxs)("div",{className:"min-w-0 text-center sm:text-left",children:[(0,r.jsxs)("h2",{className:"font-semibold text-lg leading-tight sm:text-[26px] sm:leading-tight text-balance text-[color:var(--title)]",children:[(0,r.jsx)("span",{className:"sm:hidden",children:"Pick a plan"}),(0,r.jsxs)("span",{className:"hidden sm:inline",children:["Pick a plan that's right for ",(0,r.jsx)("span",{className:"text-primary",children:"YOU"})]})]}),ec||eu?(0,r.jsx)("p",{className:"ui-hint mt-0.5 sm:mt-1",children:"Select a plan to continue using all features."}):(0,r.jsx)("p",{className:"ui-hint mt-1 hidden sm:block",children:"Affordable and adaptable pricing to suit your goals"})]}),!ea&&ei&&ee&&(0,r.jsx)("div",{className:"flex shrink-0 justify-center",children:(0,r.jsx)(k,{provider:ee.provider,onCh
1ange:V,currentPlanInterval:Q})})]}),ea?(0,r.jsx)("div",{className:"flex justify-center py-12",children:(0,r.jsx)(i.A,{className:"h-8 w-8 animate-spin text-primary"})}):ee&&(null==ee||null==(t=ee.pricing_plans)?void 0:t.length)>0&&ei?(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 max-w-6xl mx-auto px-4",children:null==ew?void 0:ew.map(e=>(0,r.jsx)(T,{plan:e,planId:ek(e.name),provider:ee.provider,onSelectTrial:()=>eb("business_standard","monthly"),onSelectPlan:()=>ey(e,ek(e.name),e_(e.name)),onTalkToSales:eg,isLoading:U||en,isTrailLoading:null!==es,clickedTrail:es,loadingPlan:N,price:e_(null==e?void 0:e.name),currentPlanInterval:Q},e.name))}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center p-6 space-y-4 text-center bg-[color:var(--muted)] rounded-lg border border-[color:var(--border)]",children:[(0,r.jsx)("div",{className:"text-[color:var(--title)] text-lg font-semibold",children:"Unable to load pricing information"}),(0,r.jsxs)(_.Button,{onClick:eo,className:"flex items-center gap-2 px-4 py-2 bg-primary text-primary-foreground rounded-md hover:opacity-90 transition-opacity",children:[(0,r.jsx)(o.A,{size:16}),"Retry"]})]}),(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 pt-6 pb-2 border-t border-[color:var(--border)]",children:[(0,r.jsx)(C(),{href:"/",className:"text-sm text-primary hover:opacity-80 font-medium transition-opacity",children:"Compare all features"}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-[color:var(--body)]",children:[(0,r.jsx)("span",{className:"text-xs",children:"Secure payments by"}),(0,r.jsx)(A.F.Stripe,{className:"h-[16px] text-[color:var(--body)] opacity-70"})]})]})]}),eL=u&&!H&&eh&&!ev&&((null==ex?void 0:ex.status)==="pending"||(null==ex?void 0:ex.status)==="trialing")&&!L&&!E,eD=(0,r.jsxs)("div",{className:"w-full p-8 flex flex-col items-center justify-center min-h-[300px]",children:[(0,r.jsx)(i.A,{className:"h-10 w-10 animate-spin text-primary mb-4"}),(0,r.jsx)("h2",{className:"text-xl font-semibold text-[color:var(--title)] mb-2",children:"Preparing Your Plan"}),(0,r.jsx)("p",{className:"text-[color:var(--body)] text-center max-w-md",children:"Setting up your custom subscription..."})]}),eT=Y?eA:B?eP:L&&E?eC:eL?eD:eF,eM=Y||B||L&&E||eL;return P?(0,r.jsx)(_.ResponsiveModal,{isOpen:u,onClose:()=>{B||W(!1)},withCloseButton:!B,closeOnClickOutside:!1,radius:20,height:"90vh",contentClassName:"p-4",children:eT}):(0,r.jsx)(_.ResponsiveModal,{isOpen:u,onClose:()=>{B||W(!1)},withCloseButton:!B,closeOnClickOutside:!1,width:eM?"900px":"64rem",radius:20,isCenter:!0,contentClassName:"p-4",contentScrollable:!0,children:eT})}}}]);
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.