import{r as y,a3 as I,a as P,bF as Y,b as U,bG as j,i as f,j as w,V as S}from"./index-Csef3-wA.js";const k={at:20,be:21,bg:20,cy:19,cz:21,de:19,dk:25,ee:22,el:24,gr:24,es:21,fi:24,fr:20,hr:25,hu:27,ie:23,it:22,lt:21,lu:17,lv:21,mt:18,nl:21,pl:23,pt:23,ro:19,se:25,si:22,sk:20},q={MONTHLY:"monthly",ANNUALLY:"annually",WEEKLY:"weekly"},B={COMPANY:"company",PRIVATE:"private"};function $(t){return t.name===q.ANNUALLY}function F(t,{country:e,accountType:a}={}){let o=0,s=0;if(!t.baseAmount)return{vatValue:o,vatPercent:s};const c=k[e],r=a===B.PRIVATE;return(e==="es"||c&&r)&&(s=k[e],o=s*t.baseAmount/100),{vatValue:o,vatPercent:s}}const W={EUR:"es",USD:"en"},_=["bif","clp","djf","gnf","jpy","kmf","krw","mga","pyg","rwf","ugx","vnd","vuv","xaf","xof","xpf"];function J({amount:t,currency:e,mainCurrency:a,fraction:o=2}){const s=o,c=_.includes(e)?t:parseInt(t,10)/100;e=e??"",a=e??a;const r=e.toUpperCase();if(Number.isNaN(c))throw new Error("price is NaN");const n=navigator.language||W[a.toUpperCase()]||"en";return new Intl.NumberFormat(n,{style:"currency",currency:r,minimumFractionDigits:s}).format(c)}function L(t,e){return e*t/100}function x(t,e){if(!e)return t;const a=L(t,e);return t-a}function O(t){var e;if(t!=null&&t.stripeCustomerCurrency)return t.stripeCustomerCurrency;if((e=t==null?void 0:t.subscriptionInfo)!=null&&e.forceEuro)return"eur"}function Q(t,e){return Math.round(t/e)}const z="x-user-country",R=[];let M=null;function G(t=!0){var v;const[e,a]=y.useState([]),[o,s]=y.useState(null),[c,r]=y.useState(!1),n=I(),i=P(l=>l.user.user),u=P(l=>l.user.currency),m=Y(),p=U(),d=O(i);y.useEffect(()=>{async function l(){var C,E;try{r(!0),M=M||j.getPrices({country:(C=i==null?void 0:i.billingData)==null?void 0:C.country,currency:m&&u||d});const{prices:g,headers:T}=await M;M=null;let A=t?g:g;const N=((E=i==null?void 0:i.billingData)==null?void 0:E.country)||(T.get(z)||"").toLowerCase()||p.locale;R.includes(N)&&(A=A.map(h=>{const{vatValue:D}=F(h,{country:N,accountType:"private"});return{...h,baseAmount:h.baseAmount+D,localBaseAmount:h.localBaseAmount+D}})),a([...A]),s(N)}catch(g){n.showError(g)}r(!1)}l()},[p.locale,((v=i==null?void 0:i.billingData)==null?void 0:v.country)||"",u]);const b=e.find(l=>l.name==="trial"&&l.active),V=e.find(l=>l.name==="monthly"&&l.active);return{loading:c,prices:e.filter(l=>l.name!=="trial"),userCountry:o,trialPlan:b,monthlyPlan:V}}function X(t){const e=G(t),a=P(s=>{var c,r;return(r=(c=s.user)==null?void 0:c.user)==null?void 0:r.discount}),o=y.useMemo(()=>{const s=e.prices.map(n=>({...n,siblings:e.prices.filter(i=>{var u,m;return(m=i.name)==null?void 0:m.match(`^${(u=n.name)==null?void 0:u.substr(0,5)}`)})})).filter(n=>n.active),c=a?s.map(n=>({...n,userDiscount:a,listPrice:n.baseAmount,discountAmount:L(n.baseAmount,a),baseAmount:x(n.baseAmount,a),localBaseAmount:x(n.localBaseAmount,a)})):s,r=c.find(n=>n.name==="quarterly");return c.sort((n,i)=>i.baseAmount-n.baseAmount).map(n=>{if(n.name==="annually"){const m=n.baseAmount/12,p=(r==null?void 0:r.baseAmount)/3,d=(r==null?void 0:r.localBaseAmount)/3,b=r?Math.round((1-m/p)*100):null;return{...n,listPrice:p*12,localListPrice:d*12,discount:b}}return n})},[e.prices]);return{...e,prices:o,allPrices:e.prices}}function Z(t="single"){const e=U(),a={name:e.formatMessage({id:"pricing.plans.biannual.name"}),shortName:e.formatMessage({id:"pricing.plans.biannual.shortName"}),periodicity:e.formatMessage({id:"pricing.plans.biannual.periodicity"}),months:6,visible:!0,order:2},o={name:e.formatMessage({id:"pricing.plans.annually.name"}),shortName:e.formatMessage({id:"pricing.plans.annually.shortName"}),periodicity:e.formatMessage({id:"pricing.plans.annually.periodicity"}),visible:!0,featured:!0,order:1,months:12},s={trial:e.formatMessage({id:"pricing.plans.trial.name"},{days:f.trialDays}),weekly:e.formatMessage({id:"pricing.plans.weekly.name"}),monthly:e.formatMessage({id:"pricing.plans.monthly.name"}),quarterly:e.formatMessage({id:"pricing.plans.quarterly.name"}),semiannual:a.name,biannual:a.name,yearly:o.name,annually:o.name},r={single:s,full:{trial:{name:s.trial,shortName:e.formatMessage({id:"pricing.plans.trial.shortName"},{days:f.trialDays}),periodicity:e.formatMessage({id:"pricing.plans.trial.periodicity"},{days:f.trialDays}),visible:!1},weekly:{name:s.weekly,shortName:e.formatMessage({id:"pricing.plans.weekly.shortName"}),periodicity:e.formatMessage({id:"pricing.plans.weekly.periodicity"})},monthly:{name:s.monthly,shortName:e.formatMessage({id:"pricing.plans.monthly.shortName"}),periodicity:e.formatMessage({id:"pricing.plans.monthly.periodicity"}),visible:!1,order:1,months:1},quarterly:{name:s.quarterly,shortName:e.formatMessage({id:"pricing.plans.quarterly.shortName"}),periodicity:e.formatMessage({id:"pricing.plans.quarterly.periodicity"}),visible:!0,order:3,months:3},semiannual:a,biannual:a,yearly:o,annually:o}}[t];return function(i){return r[i]||i}}function ee(t){return{vatMessage:R.includes(t)?w.jsx(S,{id:"pricing.vatIncluded",values:{days:f.trialDays}}):w.jsx(S,{id:"pricing.disclaimer1",values:{days:f.trialDays}})}}export{z as U,Z as a,Q as b,L as c,x as d,R as e,J as f,O as g,F as h,$ as i,X as j,ee as k,G as u};