@revenuecat/purchases-js 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9430,7 +9430,7 @@ const $r = class $r {
9430
9430
  const i = $r.microsToMinimumAmountPrice(
9431
9431
  t.totalAmountInMicros,
9432
9432
  t.currency
9433
- ), s = a.trial, l = (_ = a.trial) == null ? void 0 : _.period, c = a.base.period, p = s && l ? $r.nextDateForPeriod(l, /* @__PURE__ */ new Date()) : /* @__PURE__ */ new Date(), u = c ? $r.applePayPeriod(c) : {};
9433
+ ), s = a.trial, l = (_ = a.trial) == null ? void 0 : _.period, c = a.base.period, p = s && l ? $r.nextDateForPeriod(l, /* @__PURE__ */ new Date()) : void 0, u = c ? $r.applePayPeriod(c) : {};
9434
9434
  return {
9435
9435
  applePay: {
9436
9436
  recurringPaymentRequest: {
@@ -11879,7 +11879,7 @@ function ym(e) {
11879
11879
  }
11880
11880
  return r;
11881
11881
  }
11882
- const Gi = "1.5.2", bm = "https://api.revenuecat.com", hm = "https://e.revenue.cat";
11882
+ const Gi = "1.5.3", bm = "https://api.revenuecat.com", hm = "https://e.revenue.cat";
11883
11883
  var da;
11884
11884
  (function(e) {
11885
11885
  e[e.CONTINUE = 100] = "CONTINUE", e[e.SWITCHING_PROTOCOLS = 101] = "SWITCHING_PROTOCOLS", e[e.PROCESSING = 102] = "PROCESSING", e[e.EARLY_HINTS = 103] = "EARLY_HINTS", e[e.OK = 200] = "OK", e[e.CREATED = 201] = "CREATED", e[e.ACCEPTED = 202] = "ACCEPTED", e[e.NON_AUTHORITATIVE_INFORMATION = 203] = "NON_AUTHORITATIVE_INFORMATION", e[e.NO_CONTENT = 204] = "NO_CONTENT", e[e.RESET_CONTENT = 205] = "RESET_CONTENT", e[e.PARTIAL_CONTENT = 206] = "PARTIAL_CONTENT", e[e.MULTI_STATUS = 207] = "MULTI_STATUS", e[e.MULTIPLE_CHOICES = 300] = "MULTIPLE_CHOICES", e[e.MOVED_PERMANENTLY = 301] = "MOVED_PERMANENTLY", e[e.MOVED_TEMPORARILY = 302] = "MOVED_TEMPORARILY", e[e.SEE_OTHER = 303] = "SEE_OTHER", e[e.NOT_MODIFIED = 304] = "NOT_MODIFIED", e[e.USE_PROXY = 305] = "USE_PROXY", e[e.TEMPORARY_REDIRECT = 307] = "TEMPORARY_REDIRECT", e[e.PERMANENT_REDIRECT = 308] = "PERMANENT_REDIRECT", e[e.BAD_REQUEST = 400] = "BAD_REQUEST", e[e.UNAUTHORIZED = 401] = "UNAUTHORIZED", e[e.PAYMENT_REQUIRED = 402] = "PAYMENT_REQUIRED", e[e.FORBIDDEN = 403] = "FORBIDDEN", e[e.NOT_FOUND = 404] = "NOT_FOUND", e[e.METHOD_NOT_ALLOWED = 405] = "METHOD_NOT_ALLOWED", e[e.NOT_ACCEPTABLE = 406] = "NOT_ACCEPTABLE", e[e.PROXY_AUTHENTICATION_REQUIRED = 407] = "PROXY_AUTHENTICATION_REQUIRED", e[e.REQUEST_TIMEOUT = 408] = "REQUEST_TIMEOUT", e[e.CONFLICT = 409] = "CONFLICT", e[e.GONE = 410] = "GONE", e[e.LENGTH_REQUIRED = 411] = "LENGTH_REQUIRED", e[e.PRECONDITION_FAILED = 412] = "PRECONDITION_FAILED", e[e.REQUEST_TOO_LONG = 413] = "REQUEST_TOO_LONG", e[e.REQUEST_URI_TOO_LONG = 414] = "REQUEST_URI_TOO_LONG", e[e.UNSUPPORTED_MEDIA_TYPE = 415] = "UNSUPPORTED_MEDIA_TYPE", e[e.REQUESTED_RANGE_NOT_SATISFIABLE = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE", e[e.EXPECTATION_FAILED = 417] = "EXPECTATION_FAILED", e[e.IM_A_TEAPOT = 418] = "IM_A_TEAPOT", e[e.INSUFFICIENT_SPACE_ON_RESOURCE = 419] = "INSUFFICIENT_SPACE_ON_RESOURCE", e[e.METHOD_FAILURE = 420] = "METHOD_FAILURE", e[e.MISDIRECTED_REQUEST = 421] = "MISDIRECTED_REQUEST", e[e.UNPROCESSABLE_ENTITY = 422] = "UNPROCESSABLE_ENTITY", e[e.LOCKED = 423] = "LOCKED", e[e.FAILED_DEPENDENCY = 424] = "FAILED_DEPENDENCY", e[e.UPGRADE_REQUIRED = 426] = "UPGRADE_REQUIRED", e[e.PRECONDITION_REQUIRED = 428] = "PRECONDITION_REQUIRED", e[e.TOO_MANY_REQUESTS = 429] = "TOO_MANY_REQUESTS", e[e.REQUEST_HEADER_FIELDS_TOO_LARGE = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE", e[e.UNAVAILABLE_FOR_LEGAL_REASONS = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS", e[e.INTERNAL_SERVER_ERROR = 500] = "INTERNAL_SERVER_ERROR", e[e.NOT_IMPLEMENTED = 501] = "NOT_IMPLEMENTED", e[e.BAD_GATEWAY = 502] = "BAD_GATEWAY", e[e.SERVICE_UNAVAILABLE = 503] = "SERVICE_UNAVAILABLE", e[e.GATEWAY_TIMEOUT = 504] = "GATEWAY_TIMEOUT", e[e.HTTP_VERSION_NOT_SUPPORTED = 505] = "HTTP_VERSION_NOT_SUPPORTED", e[e.INSUFFICIENT_STORAGE = 507] = "INSUFFICIENT_STORAGE", e[e.NETWORK_AUTHENTICATION_REQUIRED = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
@@ -222,7 +222,7 @@
222
222
  animation: svelte-1sxpw7o-rotating 2s ease-in-out infinite;}`};function gp(e){U(e,_p);var r=pp(),t=P(r);et(t,()=>up),b(e,r)}var mp=T('<div class="rcb-modal-loader svelte-102edf4"><!></div>');const fp={hash:"svelte-102edf4",code:`.rcb-modal-loader.svelte-102edf4 {width:100%;flex-grow:1;display:flex;justify-content:center;align-items:center;}
223
223
 
224
224
  @container layout-query-container (width >= 768px) {.rcb-modal-loader.svelte-102edf4 {align-items:flex-start;margin-top:calc(var(--rc-spacing-gapXXLarge-desktop) * 6);}
225
- }`};function Fi(e){U(e,fp);var r=mp(),t=P(r);gp(t),b(e,r)}function yp(e,r){var d,u;H(r,!0);const t=Re(),a=()=>Be(n,"$translator",t),n=Ae(Ye),o=Ae(An),i=S(()=>r.priceBreakdown?a().formatPrice(r.priceBreakdown.totalAmountInMicros,r.priceBreakdown.currency):null),s=(u=(d=r.subscriptionOption)==null?void 0:d.trial)==null?void 0:u.period,l=S(()=>s?a().translatePeriod(s.number,s.unit):null);Ti(e,{get disabled(){return r.disabled},testId:"PayButton",brandingAppearance:o,children:(_,p)=>{var g=te(),m=Y(g);{var f=v=>{var y=S(()=>({trialPeriodLabel:c(l)}));br(v,{get key(){return L.PaymentEntryPageButtonStartTrial},get variables(){return c(y)}})},k=v=>{var y=te(),x=Y(y);{var I=q=>{var R=S(()=>({formattedPrice:c(i)}));br(q,{get key(){return L.PaymentEntryPageButtonWithPrice},get variables(){return c(R)}})},E=q=>{br(q,{get key(){return L.PaymentEntryPageButtonPay}})};C(x,q=>{c(i)?q(I):q(E,!1)},!0)}b(v,y)};C(m,v=>{var y;(y=r.subscriptionOption)!=null&&y.trial?v(f):v(k,!1)})}b(_,g)},$$slots:{default:!0}}),W()}const bp={error:"#B0171F",warning:"#f4e971",focus:"#1148B8",accent:"#767676",primary:"#576CDB","primary-hover":"rgba(87, 108, 219, .8)","primary-pressed":"rgba(87, 108, 219, .9)","primary-text":"#ffffff",white:"#ffffff","grey-text-dark":"rgba(0,0,0,1)","grey-text-light":"rgba(0,0,0,0.7)","grey-ui-dark":"rgba(0,0,0,0.3)","grey-ui-light":"rgba(0,0,0,0.1)","input-background":"white",background:"white"},hp={error:"#B0171F",warning:"#f4e971",focus:"#1148B8",accent:"#767676",primary:"#576CDB","primary-hover":"rgba(87, 108, 219, .8)","primary-pressed":"rgba(87, 108, 219, .9)","primary-text":"#ffffff",white:"#ffffff","grey-text-dark":"rgba(0,0,0,1)","grey-text-light":"rgba(0,0,0,0.7)","grey-ui-dark":"rgba(0,0,0,0.3)","grey-ui-light":"rgba(0,0,0,0.1)","input-background":"white",background:"#EFF3FA"},zi={error:"color_error",focus:"color_accent",accent:"color_accent",primary:"color_buttons_primary"},vp={...zi,"input-background":"color_form_bg",background:"color_form_bg"},kp={...zi,"input-background":"color_product_info_bg",background:"color_product_info_bg"},Di={"input-border-radius":"4px","input-button-border-radius":"8px"},wp={"input-border-radius":"0px","input-button-border-radius":"0px"},xp={"input-border-radius":"12px","input-button-border-radius":"9999px"},Ai=Di,Aa="-apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif",ji="BrandCustomFont",Mi=`${ji}, ${Aa}`,hr={regular:"400",medium:"500",semibold:"600"},tr={10:"10px",12:"12px",14:"14px",16:"16px",18:"18px",20:"20px",24:"24px",28:"28px",32:"32px",36:"36px",40:"40px"},vr={120:"120%",130:"130%",140:"140%"},kr={tight:"0.20%",regular:"0",loose:"0.20%"},ke={heading2xl:{fontSize:tr[28],lineHeight:vr[130],fontWeight:hr.semibold,letterSpacing:kr.loose},headingXl:{fontSize:tr[24],lineHeight:vr[130],fontWeight:hr.semibold,letterSpacing:kr.loose},headingLg:{fontSize:"20px",lineHeight:vr[130],fontWeight:hr.semibold,letterSpacing:kr.loose},headingMd:{fontSize:"16px",lineHeight:vr[140],fontWeight:hr.medium,letterSpacing:kr.regular},bodyBase:{fontSize:tr[16],lineHeight:vr[140],fontWeight:hr.regular,letterSpacing:kr.regular},bodySmall:{fontSize:tr[14],lineHeight:vr[140],fontWeight:hr.regular,letterSpacing:kr.regular},labelButton:{fontSize:tr[16],lineHeight:vr[140],fontWeight:hr.semibold,letterSpacing:kr.tight},labelDefault:{fontSize:tr[14],lineHeight:vr[140],fontWeight:hr.regular,letterSpacing:kr.tight},captionDefault:{fontSize:tr[12],lineHeight:vr[140],fontWeight:hr.regular,letterSpacing:kr.regular},captionLink:{fontSize:tr[12],lineHeight:vr[140],fontWeight:hr.regular,letterSpacing:kr.regular}},wr={heading2xl:{...ke.heading2xl,fontSize:tr[36]},headingXl:{...ke.headingXl,fontSize:tr[32]},headingLg:{...ke.headingLg,fontSize:tr[24]},headingMd:{...ke.headingMd,fontSize:tr[18]},bodyBase:{...ke.bodyBase},bodySmall:{...ke.bodySmall},labelButton:{...ke.labelButton},labelDefault:{...ke.labelDefault},captionDefault:{...ke.captionDefault},captionLink:{...ke.captionLink}},Nn={heading2xl:{mobile:ke.heading2xl,desktop:wr.heading2xl},headingXl:{desktop:wr.headingXl,mobile:ke.headingXl},headingLg:{desktop:wr.headingLg,mobile:ke.headingLg},headingMd:{desktop:wr.headingMd,mobile:ke.headingMd},bodyBase:{desktop:wr.bodyBase,mobile:ke.bodyBase},bodySmall:{desktop:wr.bodySmall,mobile:ke.bodySmall},labelButton:{desktop:wr.labelButton,mobile:ke.labelButton},labelDefault:{desktop:wr.labelDefault,mobile:ke.labelDefault},captionDefault:{desktop:wr.captionDefault,mobile:ke.captionDefault},captionLink:{desktop:wr.captionLink,mobile:ke.captionLink}},Xt=e=>e.length==7?{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16)}:e.length==4?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null,Cn=({r:e,g:r,b:t,luminanceThreshold:a})=>{const n=i=>(i=i/255,i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4));return .2126*n(e)+.7152*n(r)+.0722*n(t)>a},On=.37,Pp=(e,r=On)=>{const t=Cn({...e,luminanceThreshold:r})?"0,0,0":"255,255,255";return{"grey-text-dark":`rgb(${t})`,"grey-text-light":`rgba(${t},0.70)`,"grey-ui-dark":`rgba(${t},0.3)`,"grey-ui-light":`rgba(${t},0.1)`}};function Sp(e,r,t){const a=Xt(e)||{r:0,g:0,b:0},n=Xt(r)||{r:255,g:255,b:255},o=Math.round(n.r*t+a.r*(1-t)),i=Math.round(n.g*t+a.g*(1-t)),s=Math.round(n.b*t+a.b*(1-t));return`#${Ln(o)}${Ln(i)}${Ln(s)}`}function Ni(e,r){const t={r:255,g:255,b:255},a=Math.max(0,Math.min(1,r));let n=e,o=Xt(e)||t;(isNaN(o.r)||isNaN(o.g)||isNaN(o.b))&&(o=t,n="#FFFFFF");const s=Cn({...o,luminanceThreshold:On})?"#000000":"#FFFFFF";return Sp(n,s,a)}function Ln(e){return e.toString(16).padStart(2,"0").toUpperCase()}const Ep=(e,r,t,a=On)=>{const n={"grey-text-dark":t["grey-text-dark"],"grey-text-light":t["grey-text-light"],"grey-ui-dark":t["grey-ui-dark"],"grey-ui-light":t["grey-ui-light"],"primary-text":t["primary-text"]};if(e!=null&&e.startsWith("#")){const o=Xt(e);o!==null&&Object.assign(n,Pp(o))}if(r!=null&&r.startsWith("#")){const o=Xt(r);o!==null&&(n["primary-text"]=Cn({...o,luminanceThreshold:a})?"black":"white")}return n},Tp=e=>({"primary-hover":Ni(e,.1),"primary-pressed":Ni(e,.15)}),Ip=(e,r)=>e||r,qp=(e,r,t)=>{const a=Object.entries(e).map(([n,o])=>[n,Ip(t?t[o]:null,r[n])]);return Object.fromEntries(a)},Ci=(e,r,t)=>{const a=qp(e,r,t);return t?{...r,...a,...Ep(a.background,a.primary,r),...Tp(a.primary)}:{...r}},Fp=e=>Ci(kp,hp,e),Oi=e=>Ci(vp,bp,e),Bn=e=>{if(!e)return Ai;switch(e.shapes){case"rounded":return Di;case"rectangle":return wp;case"pill":return xp;default:return Ai}},ja=(e="",r)=>r.map(([t,a])=>`--rc-${e}-${t}: ${a}`).join("; "),Li=e=>{const r=ja("color",Object.entries(Fp(e))),t=ja("shape",Object.entries(Bn(e)));return[r,t].join("; ")},zp=e=>{const r=ja("color",Object.entries(Oi(e))),t=ja("shape",Object.entries(Bn(e)));return[r,t].join("; ")},Dp=(e="",r,t)=>Object.entries(r).flatMap(([a,{desktop:n,mobile:o}])=>{const i=`normal normal ${n.fontWeight} ${n.fontSize}/${n.lineHeight} ${Aa}`,s=`normal normal ${o.fontWeight} ${o.fontSize}/${o.lineHeight} ${Aa}`,l=`normal normal ${t==null?void 0:t.desktop.font_weight} ${t==null?void 0:t.desktop.font_size} ${Mi}`,d=`normal normal ${t==null?void 0:t.mobile.font_weight} ${t==null?void 0:t.mobile.font_size} ${Mi}`;return[`--rc-${e}-${a}-desktop: ${i}`,`--rc-${e}-${a}-mobile: ${s}`,`--rc-${e}-${a}-branded-desktop: ${t?l:i}`,`--rc-${e}-${a}-branded-mobile: ${t?d:s}`,`--rc-${e}-${a}-desktop-font-size: ${n.fontSize}`,`--rc-${e}-${a}-mobile-font-size: ${o.fontSize}`]}).join("; "),Ap=(e="",r)=>Object.entries(r).map(([t,{mobile:a,desktop:n}])=>`--rc-${e}-${t}-mobile: ${a}; --rc-${e}-${t}-desktop: ${n};`).join(" "),jp={outerPaddingTop:{mobile:"0.25rem",desktop:"clamp(1rem, 8.44vw, 7.5rem)"},outerPadding:{mobile:"clamp(1.3125rem, 5.6vw, 1.5rem)",desktop:"clamp(3rem, 6.44vw, 4.5rem)"},gapSmall:{mobile:"0.25rem",desktop:"0.5rem"},gapMedium:{mobile:"0.5rem",desktop:"0.75rem"},gapLarge:{mobile:"0.75rem",desktop:"1rem"},gapXLarge:{mobile:"1rem",desktop:"2rem"},gapXXLarge:{mobile:"1.25rem",desktop:"2.25rem"},gapXXXLarge:{mobile:"2.25rem",desktop:"5rem"},inputHeight:{mobile:"3rem",desktop:"3rem"}};class Zt{constructor(r){j(this,"brandingAppearance");r?this.brandingAppearance=r:this.brandingAppearance=void 0}get shape(){return Bn(this.brandingAppearance)}get formColors(){return Oi(this.brandingAppearance)}get formStyleVars(){return zp(this.brandingAppearance)}get productInfoStyleVars(){return Li(this.brandingAppearance)}get spacing(){return jp}get textStyles(){return Nn}getTextStyleVars(r){return Dp("text",this.textStyles,r)}get spacingStyleVars(){return Ap("spacing",this.spacing)}}var Rn=(e=>(e[e.ErrorLoadingStripe=0]="ErrorLoadingStripe",e[e.HandledFormError=1]="HandledFormError",e[e.UnhandledFormError=2]="UnhandledFormError",e))(Rn||{});class Ma{constructor(r,t,a){this.code=r,this.gatewayErrorCode=t,this.message=a}}const wt=class wt{static getStripeLocale(r){if(["ca","hi","uk"].includes(r))return"auto";const a={zh_Hans:"zh",zh_Hant:"zh"};return Object.keys(a).includes(r)?a[r]:r}static async initializeStripe(r,t,a,n,o,i,s){const{loadStripe:l}=await Promise.resolve().then(()=>Ef);if(!t||!r||!a)throw{code:0,gatewayErrorCode:void 0,message:"Stripe configuration is missing"};const d=await l(t,{stripeAccount:r}).catch(k=>{throw this.mapInitializationError(k)});if(!d)throw{code:0,gatewayErrorCode:void 0,message:"Stripe client not found"};const u=new Zt(n==null?void 0:n.appearance),_=u.shape,p=u.formColors,g=u.textStyles,m=Nn.bodyBase[s].fontSize||Nn.bodyBase.mobile.fontSize;let f;try{f=d.elements({mode:a.mode,paymentMethodTypes:a.payment_method_types,setupFutureUsage:a.setup_future_usage,amount:a.amount,currency:a.currency,loader:"always",locale:o,appearance:{theme:"stripe",labels:"floating",variables:{borderRadius:_["input-border-radius"],focusBoxShadow:"none",colorDanger:p.error,colorTextPlaceholder:p["grey-text-light"],colorText:p["grey-text-dark"],colorTextSecondary:p["grey-text-light"],fontSizeBase:m,...i},rules:{".Input":{boxShadow:"none",paddingTop:"6px",paddingBottom:"6px",fontSize:m,border:`1px solid ${p["grey-ui-dark"]}`,backgroundColor:p["input-background"],color:p["grey-text-dark"]},".Input:focus":{border:`1px solid ${p.focus}`,outline:"none"},".Label":{fontWeight:g.labelDefault[s].fontWeight,lineHeight:"22px",color:p["grey-text-dark"]},".Label--floating":{opacity:"1"},".Input--invalid":{boxShadow:"none"}}}})}catch(k){throw this.mapInitializationError(k)}return{stripe:d,elements:f}}static async updateElementsConfiguration(r,t){r.update({mode:t.mode,paymentMethodTypes:t.payment_method_types,setupFutureUsage:t.setup_future_usage,amount:t.amount,currency:t.currency})}static isStripeHandledFormError(r){const t=r.type==="validation_error",a=r.type==="card_error"&&r.code&&this.FORM_VALIDATED_CARD_ERROR_CODES.includes(r.code);return t||a}static createPaymentElement(r,t){return r.create("payment",{business:t?{name:t}:void 0,layout:{type:"tabs"},terms:{applePay:"never",auBecsDebit:"never",bancontact:"never",card:"never",cashapp:"never",googlePay:"never",ideal:"never",paypal:"never",sepaDebit:"never",sofort:"never",usBankAccount:"never"}})}static createExpressCheckoutElement(r,t,a){const n={billingAddressRequired:t,emailRequired:!0,...a||{}};return r.create("expressCheckout",n)}static createLinkAuthenticationElement(r,t){return r.create("linkAuthentication",{defaultValues:{email:t??""}})}static async submitElements(r){const{error:t}=await r.submit();if(t)throw this.mapError(t)}static mapInitializationError(r){return new Ma(0,r.code,r.message)}static mapError(r){return this.isStripeHandledFormError(r)?new Ma(1,r.code,r.message):new Ma(2,r.code,r.message)}static async confirmElements(r,t,a,n){const o={clientSecret:a,redirect:"if_required"},i=n?{...o,confirmParams:{confirmation_token:n}}:{...o,elements:t},s=a.startsWith("seti_");let l;if(s?l=await r.confirmSetup(i):l=await r.confirmPayment(i),l!=null&&l.error)throw this.mapError(l.error)}static async extractTaxCustomerDetails(r,t){var i,s;const{error:a,confirmationToken:n}=await t.createConfirmationToken({elements:r});if(a)throw this.mapError(a);const o=(s=(i=n.payment_method_preview)==null?void 0:i.billing_details)==null?void 0:s.address;return{customerDetails:{countryCode:(o==null?void 0:o.country)??void 0,postalCode:(o==null?void 0:o.postal_code)??void 0},confirmationTokenId:n.id}}static nextDateForPeriod(r,t){return r.unit===xe.Year?(t.setFullYear(t.getFullYear()+r.number),t):r.unit===xe.Month?(t.setMonth(t.getMonth()+r.number),t):r.unit===xe.Week?(t.setDate(t.getDate()+r.number*7),t):(r.unit===xe.Day&&t.setDate(t.getDate()+r.number),t)}static applePayPeriod(r){return r.unit===xe.Week?{recurringPaymentIntervalUnit:"day",recurringPaymentIntervalCount:r.number*7}:{recurringPaymentIntervalUnit:r.unit,recurringPaymentIntervalCount:r.number}}static microsToMinimumAmountPrice(r,t){return["BIF","CLP","DJF","GNF","JPY","KMF","KRW","MGA","PYG","RWF","UGX","VND","VUV","XAF","XOF","XPF"].includes(t)?Math.floor(r/1e6):Math.floor(r/1e4)}static buildStripeExpressCheckoutOptionsForSubscription(r,t,a,n,o){var p;const i=wt.microsToMinimumAmountPrice(t.totalAmountInMicros,t.currency),s=a.trial,l=(p=a.trial)==null?void 0:p.period,d=a.base.period,u=s&&l?wt.nextDateForPeriod(l,new Date):new Date,_=d?wt.applePayPeriod(d):{};return{applePay:{recurringPaymentRequest:{paymentDescription:r.title,managementURL:o,trialBilling:s?{label:n.translate(L.ApplePayFreeTrial),amount:0}:void 0,regularBilling:{label:r.title,amount:i,recurringPaymentStartDate:u,..._}}}}}};j(wt,"FORM_VALIDATED_CARD_ERROR_CODES",["card_declined","expired_card","incorrect_cvc","incorrect_number"]);let Pe=wt;var Mp=T("<div></div>");function Np(e,r){H(r,!0);let t=null;const a="payment-element",n=async i=>{await r.onError(Pe.mapInitializationError(i.error))};Qe(()=>{var i;try{t=Pe.createPaymentElement(r.elements,(i=r.brandingInfo)==null?void 0:i.app_name),t.mount(`#${a}`),t.on("ready",r.onReady),t.on("change",r.onChange),t.on("loaderror",n)}catch(s){r.onError(Pe.mapInitializationError(s))}}),Rt(()=>{t==null||t.destroy(),t=null});var o=Mp();N(o,"id",a),b(e,o),W()}var Cp=T("<div></div>");function Op(e,r){H(r,!0);let t=null;const a="link-authentication-element",n=async i=>{await r.onError(Pe.mapInitializationError(i.error))};Qe(()=>{try{t=Pe.createLinkAuthenticationElement(r.elements,r.email),t.mount(`#${a}`),t.on("ready",r.onReady),t.on("change",r.onChange),t.on("loaderror",n)}catch(i){r.onError(Pe.mapInitializationError(i))}}),Rt(()=>{t==null||t.destroy(),t=null});var o=Cp();N(o,"id",a),b(e,o),W()}var Lp=T('<div class="text-separator svelte-ch0h61"><hr class="line svelte-ch0h61"> <span class="text svelte-ch0h61"><!></span> <hr class="line svelte-ch0h61"></div>');const Bp={hash:"svelte-ch0h61",code:`.text-separator.svelte-ch0h61 {display:flex;align-items:center;justify-content:center;gap:var(--rc-spacing-gapSmall-mobile);}
225
+ }`};function Fi(e){U(e,fp);var r=mp(),t=P(r);gp(t),b(e,r)}function yp(e,r){var d,u;H(r,!0);const t=Re(),a=()=>Be(n,"$translator",t),n=Ae(Ye),o=Ae(An),i=S(()=>r.priceBreakdown?a().formatPrice(r.priceBreakdown.totalAmountInMicros,r.priceBreakdown.currency):null),s=(u=(d=r.subscriptionOption)==null?void 0:d.trial)==null?void 0:u.period,l=S(()=>s?a().translatePeriod(s.number,s.unit):null);Ti(e,{get disabled(){return r.disabled},testId:"PayButton",brandingAppearance:o,children:(_,p)=>{var g=te(),m=Y(g);{var f=v=>{var y=S(()=>({trialPeriodLabel:c(l)}));br(v,{get key(){return L.PaymentEntryPageButtonStartTrial},get variables(){return c(y)}})},k=v=>{var y=te(),x=Y(y);{var I=q=>{var R=S(()=>({formattedPrice:c(i)}));br(q,{get key(){return L.PaymentEntryPageButtonWithPrice},get variables(){return c(R)}})},E=q=>{br(q,{get key(){return L.PaymentEntryPageButtonPay}})};C(x,q=>{c(i)?q(I):q(E,!1)},!0)}b(v,y)};C(m,v=>{var y;(y=r.subscriptionOption)!=null&&y.trial?v(f):v(k,!1)})}b(_,g)},$$slots:{default:!0}}),W()}const bp={error:"#B0171F",warning:"#f4e971",focus:"#1148B8",accent:"#767676",primary:"#576CDB","primary-hover":"rgba(87, 108, 219, .8)","primary-pressed":"rgba(87, 108, 219, .9)","primary-text":"#ffffff",white:"#ffffff","grey-text-dark":"rgba(0,0,0,1)","grey-text-light":"rgba(0,0,0,0.7)","grey-ui-dark":"rgba(0,0,0,0.3)","grey-ui-light":"rgba(0,0,0,0.1)","input-background":"white",background:"white"},hp={error:"#B0171F",warning:"#f4e971",focus:"#1148B8",accent:"#767676",primary:"#576CDB","primary-hover":"rgba(87, 108, 219, .8)","primary-pressed":"rgba(87, 108, 219, .9)","primary-text":"#ffffff",white:"#ffffff","grey-text-dark":"rgba(0,0,0,1)","grey-text-light":"rgba(0,0,0,0.7)","grey-ui-dark":"rgba(0,0,0,0.3)","grey-ui-light":"rgba(0,0,0,0.1)","input-background":"white",background:"#EFF3FA"},zi={error:"color_error",focus:"color_accent",accent:"color_accent",primary:"color_buttons_primary"},vp={...zi,"input-background":"color_form_bg",background:"color_form_bg"},kp={...zi,"input-background":"color_product_info_bg",background:"color_product_info_bg"},Di={"input-border-radius":"4px","input-button-border-radius":"8px"},wp={"input-border-radius":"0px","input-button-border-radius":"0px"},xp={"input-border-radius":"12px","input-button-border-radius":"9999px"},Ai=Di,Aa="-apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif",ji="BrandCustomFont",Mi=`${ji}, ${Aa}`,hr={regular:"400",medium:"500",semibold:"600"},tr={10:"10px",12:"12px",14:"14px",16:"16px",18:"18px",20:"20px",24:"24px",28:"28px",32:"32px",36:"36px",40:"40px"},vr={120:"120%",130:"130%",140:"140%"},kr={tight:"0.20%",regular:"0",loose:"0.20%"},ke={heading2xl:{fontSize:tr[28],lineHeight:vr[130],fontWeight:hr.semibold,letterSpacing:kr.loose},headingXl:{fontSize:tr[24],lineHeight:vr[130],fontWeight:hr.semibold,letterSpacing:kr.loose},headingLg:{fontSize:"20px",lineHeight:vr[130],fontWeight:hr.semibold,letterSpacing:kr.loose},headingMd:{fontSize:"16px",lineHeight:vr[140],fontWeight:hr.medium,letterSpacing:kr.regular},bodyBase:{fontSize:tr[16],lineHeight:vr[140],fontWeight:hr.regular,letterSpacing:kr.regular},bodySmall:{fontSize:tr[14],lineHeight:vr[140],fontWeight:hr.regular,letterSpacing:kr.regular},labelButton:{fontSize:tr[16],lineHeight:vr[140],fontWeight:hr.semibold,letterSpacing:kr.tight},labelDefault:{fontSize:tr[14],lineHeight:vr[140],fontWeight:hr.regular,letterSpacing:kr.tight},captionDefault:{fontSize:tr[12],lineHeight:vr[140],fontWeight:hr.regular,letterSpacing:kr.regular},captionLink:{fontSize:tr[12],lineHeight:vr[140],fontWeight:hr.regular,letterSpacing:kr.regular}},wr={heading2xl:{...ke.heading2xl,fontSize:tr[36]},headingXl:{...ke.headingXl,fontSize:tr[32]},headingLg:{...ke.headingLg,fontSize:tr[24]},headingMd:{...ke.headingMd,fontSize:tr[18]},bodyBase:{...ke.bodyBase},bodySmall:{...ke.bodySmall},labelButton:{...ke.labelButton},labelDefault:{...ke.labelDefault},captionDefault:{...ke.captionDefault},captionLink:{...ke.captionLink}},Nn={heading2xl:{mobile:ke.heading2xl,desktop:wr.heading2xl},headingXl:{desktop:wr.headingXl,mobile:ke.headingXl},headingLg:{desktop:wr.headingLg,mobile:ke.headingLg},headingMd:{desktop:wr.headingMd,mobile:ke.headingMd},bodyBase:{desktop:wr.bodyBase,mobile:ke.bodyBase},bodySmall:{desktop:wr.bodySmall,mobile:ke.bodySmall},labelButton:{desktop:wr.labelButton,mobile:ke.labelButton},labelDefault:{desktop:wr.labelDefault,mobile:ke.labelDefault},captionDefault:{desktop:wr.captionDefault,mobile:ke.captionDefault},captionLink:{desktop:wr.captionLink,mobile:ke.captionLink}},Xt=e=>e.length==7?{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16)}:e.length==4?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null,Cn=({r:e,g:r,b:t,luminanceThreshold:a})=>{const n=i=>(i=i/255,i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4));return .2126*n(e)+.7152*n(r)+.0722*n(t)>a},On=.37,Pp=(e,r=On)=>{const t=Cn({...e,luminanceThreshold:r})?"0,0,0":"255,255,255";return{"grey-text-dark":`rgb(${t})`,"grey-text-light":`rgba(${t},0.70)`,"grey-ui-dark":`rgba(${t},0.3)`,"grey-ui-light":`rgba(${t},0.1)`}};function Sp(e,r,t){const a=Xt(e)||{r:0,g:0,b:0},n=Xt(r)||{r:255,g:255,b:255},o=Math.round(n.r*t+a.r*(1-t)),i=Math.round(n.g*t+a.g*(1-t)),s=Math.round(n.b*t+a.b*(1-t));return`#${Ln(o)}${Ln(i)}${Ln(s)}`}function Ni(e,r){const t={r:255,g:255,b:255},a=Math.max(0,Math.min(1,r));let n=e,o=Xt(e)||t;(isNaN(o.r)||isNaN(o.g)||isNaN(o.b))&&(o=t,n="#FFFFFF");const s=Cn({...o,luminanceThreshold:On})?"#000000":"#FFFFFF";return Sp(n,s,a)}function Ln(e){return e.toString(16).padStart(2,"0").toUpperCase()}const Ep=(e,r,t,a=On)=>{const n={"grey-text-dark":t["grey-text-dark"],"grey-text-light":t["grey-text-light"],"grey-ui-dark":t["grey-ui-dark"],"grey-ui-light":t["grey-ui-light"],"primary-text":t["primary-text"]};if(e!=null&&e.startsWith("#")){const o=Xt(e);o!==null&&Object.assign(n,Pp(o))}if(r!=null&&r.startsWith("#")){const o=Xt(r);o!==null&&(n["primary-text"]=Cn({...o,luminanceThreshold:a})?"black":"white")}return n},Tp=e=>({"primary-hover":Ni(e,.1),"primary-pressed":Ni(e,.15)}),Ip=(e,r)=>e||r,qp=(e,r,t)=>{const a=Object.entries(e).map(([n,o])=>[n,Ip(t?t[o]:null,r[n])]);return Object.fromEntries(a)},Ci=(e,r,t)=>{const a=qp(e,r,t);return t?{...r,...a,...Ep(a.background,a.primary,r),...Tp(a.primary)}:{...r}},Fp=e=>Ci(kp,hp,e),Oi=e=>Ci(vp,bp,e),Bn=e=>{if(!e)return Ai;switch(e.shapes){case"rounded":return Di;case"rectangle":return wp;case"pill":return xp;default:return Ai}},ja=(e="",r)=>r.map(([t,a])=>`--rc-${e}-${t}: ${a}`).join("; "),Li=e=>{const r=ja("color",Object.entries(Fp(e))),t=ja("shape",Object.entries(Bn(e)));return[r,t].join("; ")},zp=e=>{const r=ja("color",Object.entries(Oi(e))),t=ja("shape",Object.entries(Bn(e)));return[r,t].join("; ")},Dp=(e="",r,t)=>Object.entries(r).flatMap(([a,{desktop:n,mobile:o}])=>{const i=`normal normal ${n.fontWeight} ${n.fontSize}/${n.lineHeight} ${Aa}`,s=`normal normal ${o.fontWeight} ${o.fontSize}/${o.lineHeight} ${Aa}`,l=`normal normal ${t==null?void 0:t.desktop.font_weight} ${t==null?void 0:t.desktop.font_size} ${Mi}`,d=`normal normal ${t==null?void 0:t.mobile.font_weight} ${t==null?void 0:t.mobile.font_size} ${Mi}`;return[`--rc-${e}-${a}-desktop: ${i}`,`--rc-${e}-${a}-mobile: ${s}`,`--rc-${e}-${a}-branded-desktop: ${t?l:i}`,`--rc-${e}-${a}-branded-mobile: ${t?d:s}`,`--rc-${e}-${a}-desktop-font-size: ${n.fontSize}`,`--rc-${e}-${a}-mobile-font-size: ${o.fontSize}`]}).join("; "),Ap=(e="",r)=>Object.entries(r).map(([t,{mobile:a,desktop:n}])=>`--rc-${e}-${t}-mobile: ${a}; --rc-${e}-${t}-desktop: ${n};`).join(" "),jp={outerPaddingTop:{mobile:"0.25rem",desktop:"clamp(1rem, 8.44vw, 7.5rem)"},outerPadding:{mobile:"clamp(1.3125rem, 5.6vw, 1.5rem)",desktop:"clamp(3rem, 6.44vw, 4.5rem)"},gapSmall:{mobile:"0.25rem",desktop:"0.5rem"},gapMedium:{mobile:"0.5rem",desktop:"0.75rem"},gapLarge:{mobile:"0.75rem",desktop:"1rem"},gapXLarge:{mobile:"1rem",desktop:"2rem"},gapXXLarge:{mobile:"1.25rem",desktop:"2.25rem"},gapXXXLarge:{mobile:"2.25rem",desktop:"5rem"},inputHeight:{mobile:"3rem",desktop:"3rem"}};class Zt{constructor(r){j(this,"brandingAppearance");r?this.brandingAppearance=r:this.brandingAppearance=void 0}get shape(){return Bn(this.brandingAppearance)}get formColors(){return Oi(this.brandingAppearance)}get formStyleVars(){return zp(this.brandingAppearance)}get productInfoStyleVars(){return Li(this.brandingAppearance)}get spacing(){return jp}get textStyles(){return Nn}getTextStyleVars(r){return Dp("text",this.textStyles,r)}get spacingStyleVars(){return Ap("spacing",this.spacing)}}var Rn=(e=>(e[e.ErrorLoadingStripe=0]="ErrorLoadingStripe",e[e.HandledFormError=1]="HandledFormError",e[e.UnhandledFormError=2]="UnhandledFormError",e))(Rn||{});class Ma{constructor(r,t,a){this.code=r,this.gatewayErrorCode=t,this.message=a}}const wt=class wt{static getStripeLocale(r){if(["ca","hi","uk"].includes(r))return"auto";const a={zh_Hans:"zh",zh_Hant:"zh"};return Object.keys(a).includes(r)?a[r]:r}static async initializeStripe(r,t,a,n,o,i,s){const{loadStripe:l}=await Promise.resolve().then(()=>Ef);if(!t||!r||!a)throw{code:0,gatewayErrorCode:void 0,message:"Stripe configuration is missing"};const d=await l(t,{stripeAccount:r}).catch(k=>{throw this.mapInitializationError(k)});if(!d)throw{code:0,gatewayErrorCode:void 0,message:"Stripe client not found"};const u=new Zt(n==null?void 0:n.appearance),_=u.shape,p=u.formColors,g=u.textStyles,m=Nn.bodyBase[s].fontSize||Nn.bodyBase.mobile.fontSize;let f;try{f=d.elements({mode:a.mode,paymentMethodTypes:a.payment_method_types,setupFutureUsage:a.setup_future_usage,amount:a.amount,currency:a.currency,loader:"always",locale:o,appearance:{theme:"stripe",labels:"floating",variables:{borderRadius:_["input-border-radius"],focusBoxShadow:"none",colorDanger:p.error,colorTextPlaceholder:p["grey-text-light"],colorText:p["grey-text-dark"],colorTextSecondary:p["grey-text-light"],fontSizeBase:m,...i},rules:{".Input":{boxShadow:"none",paddingTop:"6px",paddingBottom:"6px",fontSize:m,border:`1px solid ${p["grey-ui-dark"]}`,backgroundColor:p["input-background"],color:p["grey-text-dark"]},".Input:focus":{border:`1px solid ${p.focus}`,outline:"none"},".Label":{fontWeight:g.labelDefault[s].fontWeight,lineHeight:"22px",color:p["grey-text-dark"]},".Label--floating":{opacity:"1"},".Input--invalid":{boxShadow:"none"}}}})}catch(k){throw this.mapInitializationError(k)}return{stripe:d,elements:f}}static async updateElementsConfiguration(r,t){r.update({mode:t.mode,paymentMethodTypes:t.payment_method_types,setupFutureUsage:t.setup_future_usage,amount:t.amount,currency:t.currency})}static isStripeHandledFormError(r){const t=r.type==="validation_error",a=r.type==="card_error"&&r.code&&this.FORM_VALIDATED_CARD_ERROR_CODES.includes(r.code);return t||a}static createPaymentElement(r,t){return r.create("payment",{business:t?{name:t}:void 0,layout:{type:"tabs"},terms:{applePay:"never",auBecsDebit:"never",bancontact:"never",card:"never",cashapp:"never",googlePay:"never",ideal:"never",paypal:"never",sepaDebit:"never",sofort:"never",usBankAccount:"never"}})}static createExpressCheckoutElement(r,t,a){const n={billingAddressRequired:t,emailRequired:!0,...a||{}};return r.create("expressCheckout",n)}static createLinkAuthenticationElement(r,t){return r.create("linkAuthentication",{defaultValues:{email:t??""}})}static async submitElements(r){const{error:t}=await r.submit();if(t)throw this.mapError(t)}static mapInitializationError(r){return new Ma(0,r.code,r.message)}static mapError(r){return this.isStripeHandledFormError(r)?new Ma(1,r.code,r.message):new Ma(2,r.code,r.message)}static async confirmElements(r,t,a,n){const o={clientSecret:a,redirect:"if_required"},i=n?{...o,confirmParams:{confirmation_token:n}}:{...o,elements:t},s=a.startsWith("seti_");let l;if(s?l=await r.confirmSetup(i):l=await r.confirmPayment(i),l!=null&&l.error)throw this.mapError(l.error)}static async extractTaxCustomerDetails(r,t){var i,s;const{error:a,confirmationToken:n}=await t.createConfirmationToken({elements:r});if(a)throw this.mapError(a);const o=(s=(i=n.payment_method_preview)==null?void 0:i.billing_details)==null?void 0:s.address;return{customerDetails:{countryCode:(o==null?void 0:o.country)??void 0,postalCode:(o==null?void 0:o.postal_code)??void 0},confirmationTokenId:n.id}}static nextDateForPeriod(r,t){return r.unit===xe.Year?(t.setFullYear(t.getFullYear()+r.number),t):r.unit===xe.Month?(t.setMonth(t.getMonth()+r.number),t):r.unit===xe.Week?(t.setDate(t.getDate()+r.number*7),t):(r.unit===xe.Day&&t.setDate(t.getDate()+r.number),t)}static applePayPeriod(r){return r.unit===xe.Week?{recurringPaymentIntervalUnit:"day",recurringPaymentIntervalCount:r.number*7}:{recurringPaymentIntervalUnit:r.unit,recurringPaymentIntervalCount:r.number}}static microsToMinimumAmountPrice(r,t){return["BIF","CLP","DJF","GNF","JPY","KMF","KRW","MGA","PYG","RWF","UGX","VND","VUV","XAF","XOF","XPF"].includes(t)?Math.floor(r/1e6):Math.floor(r/1e4)}static buildStripeExpressCheckoutOptionsForSubscription(r,t,a,n,o){var p;const i=wt.microsToMinimumAmountPrice(t.totalAmountInMicros,t.currency),s=a.trial,l=(p=a.trial)==null?void 0:p.period,d=a.base.period,u=s&&l?wt.nextDateForPeriod(l,new Date):void 0,_=d?wt.applePayPeriod(d):{};return{applePay:{recurringPaymentRequest:{paymentDescription:r.title,managementURL:o,trialBilling:s?{label:n.translate(L.ApplePayFreeTrial),amount:0}:void 0,regularBilling:{label:r.title,amount:i,recurringPaymentStartDate:u,..._}}}}}};j(wt,"FORM_VALIDATED_CARD_ERROR_CODES",["card_declined","expired_card","incorrect_cvc","incorrect_number"]);let Pe=wt;var Mp=T("<div></div>");function Np(e,r){H(r,!0);let t=null;const a="payment-element",n=async i=>{await r.onError(Pe.mapInitializationError(i.error))};Qe(()=>{var i;try{t=Pe.createPaymentElement(r.elements,(i=r.brandingInfo)==null?void 0:i.app_name),t.mount(`#${a}`),t.on("ready",r.onReady),t.on("change",r.onChange),t.on("loaderror",n)}catch(s){r.onError(Pe.mapInitializationError(s))}}),Rt(()=>{t==null||t.destroy(),t=null});var o=Mp();N(o,"id",a),b(e,o),W()}var Cp=T("<div></div>");function Op(e,r){H(r,!0);let t=null;const a="link-authentication-element",n=async i=>{await r.onError(Pe.mapInitializationError(i.error))};Qe(()=>{try{t=Pe.createLinkAuthenticationElement(r.elements,r.email),t.mount(`#${a}`),t.on("ready",r.onReady),t.on("change",r.onChange),t.on("loaderror",n)}catch(i){r.onError(Pe.mapInitializationError(i))}}),Rt(()=>{t==null||t.destroy(),t=null});var o=Cp();N(o,"id",a),b(e,o),W()}var Lp=T('<div class="text-separator svelte-ch0h61"><hr class="line svelte-ch0h61"> <span class="text svelte-ch0h61"><!></span> <hr class="line svelte-ch0h61"></div>');const Bp={hash:"svelte-ch0h61",code:`.text-separator.svelte-ch0h61 {display:flex;align-items:center;justify-content:center;gap:var(--rc-spacing-gapSmall-mobile);}
226
226
 
227
227
  @container layout-query-container (width >= 768px) {.text-separator.svelte-ch0h61 {gap:var(--rc-spacing-gapSmall-desktop);}
228
228
  }.line.svelte-ch0h61 {flex:1;height:1px;background-color:var(--rc-color-grey-ui-dark);border:none;}.text.svelte-ch0h61 {color:var(--rc-color-grey-text-light);text-transform:uppercase;white-space:nowrap;}`};function Rp(e,r){U(e,Bp);let t=V(r,"text",8);var a=Lp(),n=O(P(a),2),o=P(n);de(o,{size:"caption-default",children:(i,s)=>{var l=le();A(()=>ne(l,t())),b(i,l)},$$slots:{default:!0}}),b(e,a)}var Up=T("<div></div> <!>",1);function Vp(e,r){H(r,!0);const t=Re(),a=()=>Be(n,"$translator",t),n=Ae(Ye);let o=null,i=K(!1);const s="express-checkout-element",l=async f=>{const k={...r.expressCheckoutOptions?r.expressCheckoutOptions:{}};f.resolve(k)},d=async f=>{await r.onError(Pe.mapInitializationError(f.error))},u=async f=>{var k;r.onSubmit(f.expressPaymentType,((k=f.billingDetails)==null?void 0:k.email)??"")},_=async f=>{z(i,!f.availablePaymentMethods),r.onReady()};Qe(()=>{try{o=Pe.createExpressCheckoutElement(r.elements,r.billingAddressRequired,r.expressCheckoutOptions),o.mount(`#${s}`),o.on("ready",_),o.on("confirm",u),o.on("loaderror",d),o.on("click",l)}catch(f){r.onError(Pe.mapInitializationError(f))}}),Rt(()=>{o==null||o.destroy(),o=null});var p=te(),g=Y(p);{var m=f=>{var k=Up(),v=Y(k);N(v,"id",s);var y=O(v,2),x=S(()=>a().translate(L.PaymentEntryPageExpressCheckoutDivider));Rp(y,{get text(){return c(x)}}),b(f,k)};C(g,f=>{c(i)||f(m)})}b(e,p),W()}var Hp=T('<div class="rc-elements svelte-6qa1vy"><!> <!> <!></div>');const Wp={hash:"svelte-6qa1vy",code:`.rc-elements.svelte-6qa1vy {display:flex;flex-direction:column;gap:var(--rc-spacing-gapXLarge-mobile);}
@@ -334,7 +334,7 @@
334
334
  }
335
335
 
336
336
  @container layout-query-container (width >= 768px) {.rcb-close-wrapper.svelte-11zapuq {display:none;}.rcb-back-wrapper.svelte-11zapuq {position:absolute;left:-48px;margin-left:0;}
337
- }`};function tm(e,r){H(r,!0),U(e,rm);const t=h=>h==null||h==null||h==""?null:h,a=S(()=>{var h;return t((h=r.brandingInfo)==null?void 0:h.app_icon)}),n=S(()=>{var h;return t((h=r.brandingInfo)==null?void 0:h.app_icon_webp)}),o=S(()=>{var h;return t((h=r.brandingInfo)==null?void 0:h.app_wordmark)}),i=S(()=>{var h;return t((h=r.brandingInfo)==null?void 0:h.app_wordmark_webp)}),s=S(()=>c(a)?Jt(c(a)):null),l=S(()=>c(n)?Jt(c(n)):null),d=S(()=>c(o)?Jt(c(o)):null),u=S(()=>c(i)?Jt(c(i)):null),_=()=>{r.onClose&&r.onClose()};var p=em(),g=P(p);{var m=h=>{var w=Qg(),D=P(w);Gg(D,{$$events:{click:_}}),b(h,w)};C(g,h=>{r.showCloseButton&&h(m)})}var f=O(g,2),k=P(f),v=P(k);{var y=h=>{Jg(h,{get src(){return c(d)},get srcWebp(){return c(u)}})},x=h=>{var w=te(),D=Y(w);{var G=X=>{Hg(X,{get src(){return c(s)},get srcWebp(){return c(l)}})};C(D,X=>{c(s)!==null&&c(l)!==null&&X(G)},!0)}b(h,w)};C(v,h=>{c(d)!==null?h(y):h(x,!1)})}var I=O(v,2);{var E=h=>{de(h,{size:"body-base",children:(w,D)=>{var G=le();A(()=>{var X;return ne(G,(X=r.brandingInfo)==null?void 0:X.app_name)}),b(w,G)},$$slots:{default:!0}})};C(I,h=>{c(d)===null&&h(E)})}var q=O(f,2);{var R=h=>{var w=$g(),D=P(w);Xi(D,{$$events:{click:_}}),b(h,w)};C(q,h=>{r.showCloseButton&&h(R)})}A(()=>Er(p,"rcb-with-close-button",r.showCloseButton)),b(e,p),W()}var am=T("<!> <!> <!> <!>",1);function nm(e,r){H(r,!0);const t=V(r,"onClose",3,void 0);let a=K(B(r.defaultPriceBreakdown??{currency:r.productDetails.currentPrice.currency,totalAmountInMicros:r.productDetails.currentPrice.amountMicros,totalExcludingTaxInMicros:r.productDetails.currentPrice.amountMicros,taxCalculationStatus:"unavailable",taxAmountInMicros:null,taxBreakdown:null}));const n=o=>{z(a,B(o))};Lg(e,{get brandingInfo(){return r.brandingInfo},get isInElement(){return r.isInElement},get isSandbox(){return r.isSandbox},get onClose(){return t()},navbarHeaderContent:l=>{var d=S(()=>!r.isInElement&&!!t());tm(l,{get brandingInfo(){return r.brandingInfo},get onClose(){return t()},get showCloseButton(){return c(d)}})},navbarBodyContent:l=>{var d=S(()=>{var u,_;return((_=(u=r.brandingInfo)==null?void 0:u.appearance)==null?void 0:_.show_product_description)??!1});dg(l,{get productDetails(){return r.productDetails},get purchaseOption(){return r.purchaseOptionToUse},get showProductDescription(){return c(d)},get priceBreakdown(){return c(a)}})},mainContent:l=>{var d=am(),u=Y(d);{var _=y=>{O_(y)};C(u,y=>{r.currentPage==="payment-entry-loading"&&y(_)})}var p=O(u,2);{var g=y=>{a_(y,{get productDetails(){return r.productDetails},get purchaseOption(){return r.purchaseOptionToUse},get brandingInfo(){return r.brandingInfo},get purchaseOperationHelper(){return r.purchaseOperationHelper},get gatewayParams(){return r.gatewayParams},get managementUrl(){return r.managementUrl},get customerEmail(){return r.customerEmail},get defaultPriceBreakdown(){return r.defaultPriceBreakdown},get onContinue(){return r.onContinue},get onError(){return r.onError},onPriceBreakdownUpdated:n})};C(p,y=>{r.currentPage==="payment-entry"&&y(g)})}var m=O(p,2);{var f=y=>{var x=S(()=>{var E;return((E=r.brandingInfo)==null?void 0:E.support_email)??null}),I=S(()=>{var E;return((E=r.brandingInfo)==null?void 0:E.app_name)??null});N_(y,{get lastError(){return r.lastError},get productDetails(){return r.productDetails},get supportEmail(){return c(x)},get onDismiss(){return r.closeWithError},get appName(){return c(I)}})};C(m,y=>{r.currentPage==="error"&&y(f)})}var k=O(m,2);{var v=y=>{C_(y,{get onContinue(){return r.onContinue}})};C(k,y=>{r.currentPage==="success"&&y(v)})}b(l,d)},$$slots:{navbarHeaderContent:!0,navbarBodyContent:!0,mainContent:!0}}),W()}function om(e){return e.trim()===""?"You need to provide your email address to continue.":e.match(/^[^@]+@[^@]+\.[^@]+$/)?null:"Email is not valid. Please provide a valid email address."}function im(e){if(e&&!e.match(/^[A-Z]{3}$/)){const r=`Currency code ${e} is not valid. Please provide a valid ISO 4217 currency code.`;throw Q.errorLog(r),new he(Te.ConfigurationError,r)}}function sm(e,r){var R;H(r,!0);const t=V(r,"customTranslations",19,()=>({})),a=r.customerEmail?om(r.customerEmail):null;let n=K(B(a?void 0:r.customerEmail)),o=r.rcPackage.webBillingProduct,i=K(null);const s=r.rcPackage.webBillingProduct.identifier??null;let l=K("payment-entry-loading"),d=K(null),u=K(null),_=K(B({})),p=K(null),g=K(null),m=K(null),f=K(null),k=new Pa(t(),r.selectedLocale,r.defaultLocale);var v=li(k);un(Ye,v),un(An,(R=r.brandingInfo)==null?void 0:R.appearance),Qe(()=>{r.isInElement||(z(g,B(document.documentElement.style.height)),z(m,B(document.documentElement.style.overflow)),z(f,B(document.body.style.height)),document.documentElement.style.height="100%",document.body.style.height="100%",document.documentElement.style.overflow="hidden")}),Rt(()=>{if(!r.isInElement){const h=(w,D,G)=>{G===""?w.style.removeProperty(D):w.style.setProperty(D,G)};h(document.documentElement,"height",c(g)),h(document.body,"height",c(f)),h(document.documentElement,"overflow",c(m))}}),un(Dn,r.eventsTracker),Qe(async()=>{if(s===null){x(new ge(ce.ErrorSettingUpPurchase,"Product ID was not set before purchase."));return}r.purchaseOperationHelper.checkoutStart(r.appUserId,s,r.purchaseOption,r.rcPackage.webBillingProduct.presentedOfferingContext,c(n),r.metadata).then(h=>{z(i,null),z(l,"payment-entry"),z(_,B(h.gateway_params)),z(p,B(h.management_url))}).catch(h=>{if(h.errorCode===ce.MissingEmailError)return z(n,void 0),r.purchaseOperationHelper.checkoutStart(r.appUserId,s,r.purchaseOption,r.rcPackage.webBillingProduct.presentedOfferingContext,c(n),r.metadata).then(w=>{z(i,null),z(l,"payment-entry"),z(_,B(w.gateway_params)),z(p,B(w.management_url))}).catch(w=>{x(w)});x(h)})});const y=()=>{if(c(l)==="payment-entry"){r.purchaseOperationHelper.pollCurrentPurchaseForCompletion().then(h=>{z(l,"success"),z(d,B(h.redemptionInfo)),z(u,B(h.operationSessionId))}).catch(h=>{x(h)});return}if(c(l)==="success"||c(l)==="error"){r.onFinished(c(u),c(d));return}z(l,"success")},x=h=>{const w=tp({errorCode:h.getErrorCode().toString(),errorMessage:h.message});r.eventsTracker.trackSDKEvent(w),z(i,B(h)),z(l,"error")},I=()=>{r.onError(c(i)??new ge(ce.UnknownError,"Unknown error without state set."))};var E=S(()=>r.purchases.isSandbox()),q=S(()=>c(n)??null);nm(e,{get isSandbox(){return c(E)},get currentPage(){return c(l)},get brandingInfo(){return r.brandingInfo},productDetails:o,get purchaseOptionToUse(){return r.purchaseOption},get lastError(){return c(i)},get gatewayParams(){return c(_)},get managementUrl(){return c(p)},get purchaseOperationHelper(){return r.purchaseOperationHelper},get isInElement(){return r.isInElement},get customerEmail(){return c(q)},closeWithError:I,onContinue:y,onError:x,get onClose(){return r.onClose}}),W()}function Zi(e){return e==null?!0:new Date(e)>new Date}function lm(e,r,t,a){const n=r.product_identifier;if(n in t)return cm(e,r,t[n]);if(n in a)return dm(e,r,a[n]);throw new he(Te.CustomerInfoError,"Could not find entitlement product in subscriptions or non-subscriptions.")}function cm(e,r,t){return{identifier:e,isActive:Zi(r.expires_date),willRenew:Ki(r.expires_date,t),store:(t==null?void 0:t.store)??"unknown",latestPurchaseDate:new Date(r.purchase_date),originalPurchaseDate:new Date(r.purchase_date),expirationDate:xr(r.expires_date),productIdentifier:r.product_identifier,productPlanIdentifier:r.product_plan_identifier??null,unsubscribeDetectedAt:xr(t==null?void 0:t.unsubscribe_detected_at),billingIssueDetectedAt:xr(t==null?void 0:t.billing_issues_detected_at),isSandbox:(t==null?void 0:t.is_sandbox)??!1,periodType:(t==null?void 0:t.period_type)??"normal",ownershipType:(t==null?void 0:t.ownership_type)??"UNKNOWN"}}function dm(e,r,t){return{identifier:e,isActive:!0,willRenew:!1,store:t.store,latestPurchaseDate:new Date(r.purchase_date),originalPurchaseDate:new Date(t.original_purchase_date),expirationDate:null,productIdentifier:r.product_identifier,productPlanIdentifier:null,unsubscribeDetectedAt:null,billingIssueDetectedAt:null,isSandbox:t.is_sandbox,periodType:"normal",ownershipType:"UNKNOWN"}}function um(e,r,t){const a={},n={};for(const o in e){const i=lm(o,e[o],r,t);a[o]=i,i.isActive&&(n[o]=i)}return{all:a,active:n}}function xr(e){return e==null?null:new Date(e)}function pm(e){const r=gm(e),t=e.subscriber,a=fm(t.non_subscriptions),n=Object.entries(e.subscriber.non_subscriptions).flatMap(([s,l])=>l.map(d=>({transactionIdentifier:d.id,productIdentifier:s,purchaseDate:new Date(d.purchase_date||d.original_purchase_date),storeTransactionId:d.store_transaction_id||null,store:d.store}))),o=new Date(e.request_date),i=Object.fromEntries(Object.entries(e.subscriber.subscriptions).map(([s,l])=>[s,{productIdentifier:s,purchaseDate:new Date(l.purchase_date),originalPurchaseDate:xr(l.original_purchase_date),expiresDate:xr(l.expires_date),store:l.store,unsubscribeDetectedAt:xr(l.unsubscribe_detected_at),isSandbox:l.is_sandbox,billingIssuesDetectedAt:xr(l.billing_issues_detected_at),gracePeriodExpiresDate:xr(l.grace_period_expires_date),ownershipType:l.ownership_type??"UNKNOWN",periodType:l.period_type,refundedAt:xr(l.refunded_at),storeTransactionId:l.store_transaction_id||null,isActive:Zi(l.expires_date),willRenew:Ki(l.expires_date,l)}]));return{entitlements:um(t.entitlements,t.subscriptions,a),allExpirationDatesByProduct:r,allPurchaseDatesByProduct:_m(e,a),activeSubscriptions:mm(r),managementURL:t.management_url,requestDate:o,firstSeenDate:new Date(t.first_seen),originalPurchaseDate:xr(t.original_purchase_date),originalAppUserId:e.subscriber.original_app_user_id,nonSubscriptionTransactions:n,subscriptionsByProductIdentifier:i}}function Ki(e,r){if(r==null)return!1;const t=r.store=="promotional",a=e==null,n=r.unsubscribe_detected_at!=null,o=r.billing_issues_detected_at!=null;return!(t||a||n||o)}function _m(e,r){const t={};for(const a in e.subscriber.subscriptions){const n=e.subscriber.subscriptions[a];t[a]=new Date(n.purchase_date)}for(const a in r){const n=r[a].purchase_date;n==null?t[a]=null:t[a]=new Date(n)}return t}function gm(e){const r={};for(const t in e.subscriber.subscriptions){const a=e.subscriber.subscriptions[t];a.expires_date==null?r[t]=null:r[t]=new Date(a.expires_date)}return r}function mm(e){const r=new Set,t=new Date;for(const a in e){const n=e[a];(n==null||n>t)&&r.add(a)}return r}function fm(e){const r={};for(const t in e){if(e[t].length===0)continue;const a=e[t].length;r[t]=e[t][a-1]}return r}const Ji="1.5.2",ym="https://api.revenuecat.com",bm="https://e.revenue.cat";var Ca;(function(e){e[e.CONTINUE=100]="CONTINUE",e[e.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",e[e.PROCESSING=102]="PROCESSING",e[e.EARLY_HINTS=103]="EARLY_HINTS",e[e.OK=200]="OK",e[e.CREATED=201]="CREATED",e[e.ACCEPTED=202]="ACCEPTED",e[e.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",e[e.NO_CONTENT=204]="NO_CONTENT",e[e.RESET_CONTENT=205]="RESET_CONTENT",e[e.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",e[e.MULTI_STATUS=207]="MULTI_STATUS",e[e.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",e[e.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",e[e.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",e[e.SEE_OTHER=303]="SEE_OTHER",e[e.NOT_MODIFIED=304]="NOT_MODIFIED",e[e.USE_PROXY=305]="USE_PROXY",e[e.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",e[e.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",e[e.BAD_REQUEST=400]="BAD_REQUEST",e[e.UNAUTHORIZED=401]="UNAUTHORIZED",e[e.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",e[e.FORBIDDEN=403]="FORBIDDEN",e[e.NOT_FOUND=404]="NOT_FOUND",e[e.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",e[e.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",e[e.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",e[e.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",e[e.CONFLICT=409]="CONFLICT",e[e.GONE=410]="GONE",e[e.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",e[e.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",e[e.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",e[e.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",e[e.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",e[e.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",e[e.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",e[e.IM_A_TEAPOT=418]="IM_A_TEAPOT",e[e.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",e[e.METHOD_FAILURE=420]="METHOD_FAILURE",e[e.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",e[e.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",e[e.LOCKED=423]="LOCKED",e[e.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",e[e.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",e[e.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",e[e.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",e[e.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",e[e.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",e[e.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",e[e.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",e[e.BAD_GATEWAY=502]="BAD_GATEWAY",e[e.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",e[e.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",e[e.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",e[e.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",e[e.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(Ca||(Ca={}));function Oa(e){return e?e.startsWith("rcb_sb_"):!1}async function Fr(e,r,t){const{apiKey:a,body:n,headers:o,httpConfig:i}=r,l=`${(i==null?void 0:i.proxyURL)??ym}${e.urlPath()}`;try{const d=await fetch(l,{method:e.method,headers:is(a,o,i==null?void 0:i.additionalHeaders),body:vm(n),signal:t});return await hm(d,e),await d.json()}catch(d){throw d instanceof TypeError?new he(Te.NetworkError,Ut.getPublicMessage(Te.NetworkError),d.message):d}}async function hm(e,r){const t=e.status;if(t>=Ca.INTERNAL_SERVER_ERROR)Un(r,t,await e.text());else if(t>=Ca.BAD_REQUEST){const a=await e.json(),n=a?JSON.stringify(a):null,o=a==null?void 0:a.code,i=a==null?void 0:a.message;if(o!=null){const s=Ut.convertCodeToBackendErrorCode(o);if(s==null)Un(r,t,n,o);else throw he.getForBackendError(s,i)}else Un(r,t,n)}}function Un(e,r,t,a){throw new he(Te.UnknownBackendError,"Unknown backend error.",`Request: ${e.name}. Status code: ${r}. Body: ${t}.`,{backendErrorCode:a})}function vm(e){return e==null?null:JSON.stringify(e)}const Qi="Authorization",$i="Content-Type",es="Accept",rs="X-Platform",ts="X-Version",as="X-Platform-Flavor",ns="X-Platform-Flavor-Version",os="X-Is-Sandbox",km=new Set([Qi,$i,es,rs,ts,os,as,ns]);function is(e,r,t){let a={[Qi]:`Bearer ${e}`,[$i]:"application/json",[es]:"application/json",[rs]:"web",[ts]:Ji,[os]:`${Oa(e)}`};const n=La.getPlatformInfo();if(n){const o={[as]:n.flavor,[ns]:n.version};a={...a,...o}}return r&&(a={...a,...r}),t&&(a={...t,...a}),a}const Vn="/v1/subscribers",kt="/rcbilling/v1";class wm{constructor(r){j(this,"appUserId");j(this,"method","GET");j(this,"name","getOfferings");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Vn}/${r}/offerings`}}class xm{constructor(r,t,a){j(this,"method","GET");j(this,"name","getProducts");j(this,"appUserId");j(this,"productIds");j(this,"currency");this.appUserId=r,this.productIds=t,this.currency=a}urlPath(){const r=encodeURIComponent(this.appUserId),t=this.productIds.map(encodeURIComponent).join("&id="),a=this.currency?`&currency=${this.currency}`:"";return`${kt}/subscribers/${r}/products?id=${t}${a}`}}class Pm{constructor(r){j(this,"method","GET");j(this,"name","getCustomerInfo");j(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Vn}/${r}`}}class Sm{constructor(){j(this,"method","GET");j(this,"name","getBrandingInfo")}urlPath(){return`${kt}/branding`}}class Em{constructor(){j(this,"method","POST");j(this,"name","postCheckoutStart")}urlPath(){return`${kt}/checkout/start`}}class Tm{constructor(r){j(this,"method","POST");j(this,"name","postCheckoutCalculateTax");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${kt}/checkout/${this.operationSessionId}/calculate_taxes`}}class Im{constructor(r){j(this,"method","POST");j(this,"name","postCheckoutComplete");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${kt}/checkout/${this.operationSessionId}/complete`}}class qm{constructor(r){j(this,"method","GET");j(this,"name","getCheckoutStatus");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${kt}/checkout/${this.operationSessionId}`}}class Fm{constructor(r){j(this,"method","POST");j(this,"name","setAttributes");j(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Vn}/${r}/attributes`}}const Hn={};class zm{constructor(r,t=Hn){j(this,"API_KEY");j(this,"httpConfig");j(this,"isSandbox");this.API_KEY=r,this.httpConfig=t,this.isSandbox=Oa(r)}getIsSandbox(){return this.isSandbox}async getOfferings(r){return await Fr(new wm(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getCustomerInfo(r){return await Fr(new Pm(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getProducts(r,t,a){return await Fr(new xm(r,t,a),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getBrandingInfo(){return await Fr(new Sm,{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async postCheckoutStart(r,t,a,n,o,i,s=void 0){const l={app_user_id:r,product_id:t,email:i,price_id:n.priceId,presented_offering_identifier:a.offeringIdentifier,trace_id:o};return s&&(l.metadata=s),n.id!=="base_option"&&(l.offer_id=n.id),a.targetingContext&&(l.applied_targeting_rule={rule_id:a.targetingContext.ruleId,revision:a.targetingContext.revision}),a.placementIdentifier&&(l.presented_placement_identifier=a.placementIdentifier),await Fr(new Em,{apiKey:this.API_KEY,body:l,httpConfig:this.httpConfig})}async postCheckoutCalculateTax(r,t,a,n){const o={country_code:t,postal_code:a};return await Fr(new Tm(r),{apiKey:this.API_KEY,body:o,httpConfig:this.httpConfig},n)}async postCheckoutComplete(r,t){const a={email:t};return await Fr(new Im(r),{apiKey:this.API_KEY,body:a,httpConfig:this.httpConfig})}async getCheckoutStatus(r){return await Fr(new qm(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async setAttributes(r,t){const a=Date.now(),n={};for(const[i,s]of Object.entries(t))n[i]={value:s,updated_at_ms:a};const o={attributes:n};return await Fr(new Fm(r),{apiKey:this.API_KEY,body:o,httpConfig:this.httpConfig})}}function Dm(e){const r=/^rcb_[a-zA-Z0-9_.-]+$/,t=/^pdl_[a-zA-Z0-9_.-]+$/;if(!r.test(e)&&!t.test(e))throw new he(Te.InvalidCredentialsError,"Invalid API key. Use your Web Billing or Paddle API key.")}function ss(e){if(!e||new Set(["no_user","null","none","nil","(null)","NaN","\\x00","","unidentified","undefined","unknown"]).has(e)||e.includes("/"))throw new he(Te.InvalidAppUserIdError,'Provided user id: "'+(e??"[Not provided]")+'" is not valid. See https://www.revenuecat.com/docs/customers/user-ids#tips-for-setting-app-user-ids for more information.')}function Am(e){if(e!=null&&e.endsWith("/"))throw new he(Te.ConfigurationError,"Invalid proxy URL. The proxy URL should not end with a trailing slash.")}function jm(e){if(e){for(const r in e)if(km.has(r))throw new he(Te.ConfigurationError,"Invalid additional headers. Some headers are reserved for internal use.")}}var Wn=(e=>(e.Current="current",e))(Wn||{});function Mm(e,r){async function t(...a){return await this.preload(),await e.call(this,...a)}return t}const ls=(e,r)=>{const t={...e.webBillingProduct,presentedOfferingContext:{...e.webBillingProduct.presentedOfferingContext,placementIdentifier:r}};return{...e,webBillingProduct:t,rcBillingProduct:t}},rt=(e,r)=>e==null?null:ls(e,r),Nm=(e,r,t)=>{const a=e.offering_ids_by_placement??null;if(a==null)return null;const n=e.fallback_offering_id??null;let o;if(t in a){const s=a[t]??null;if(s==null)return null;o=r[s],o==null&&(o=r[n])}else o=r[n];if(o==null)return null;const i=Object.fromEntries(Object.entries(o.packagesById).map(([s,l])=>[s,ls(l,t)]));return{...o,packagesById:i,availablePackages:Object.values(i),weekly:rt(o.weekly,t),monthly:rt(o.monthly,t),twoMonth:rt(o.twoMonth,t),threeMonth:rt(o.threeMonth,t),sixMonth:rt(o.sixMonth,t),annual:rt(o.annual,t),lifetime:rt(o.lifetime,t)}};function Cm(e,r){const t={};r.product_details.forEach(o=>{t[o.identifier]=o});const a={};e.offerings.forEach(o=>{const i=o.identifier===e.current_offering_id,s=p_(i,o,t,e.targeting);s!=null&&(a[o.identifier]=s)});const n=e.current_offering_id?a[e.current_offering_id]??null:null;return Object.keys(a).length==0&&Q.debugLog("Empty offerings. Please make sure you've configured offerings correctly in the RevenueCat dashboard and that the products are properly configured."),{all:a,current:n}}const Om=1000001;function Lm(e){return e.webBillingProduct.defaultPurchaseOption}function cs(e,r,t,a=!1){return t.translate(L.PaywallVariablesPricePerPeriod,{formattedPrice:e,period:r.base.period?t.translatePeriod(r.base.period.number,r.base.period.unit,{noWhitespace:!0,short:!a}):""})}function Bm(e,r){return e.unit==="year"?r.translatePeriod(e.number*12,xe.Month):r.translatePeriod(e.number,e.unit)}function Rm({price:e,period:r,translator:t}){const a=t.formatPrice(e.amountMicros,e.currency);return r?r.unit==="year"?t.formatPrice(e.amountMicros/12/4,e.currency):r.unit==="month"||r.unit==="week"&&r.number>1?t.formatPrice(e.amountMicros/r.number,e.currency):r.unit==="day"?t.formatPrice(e.amountMicros*7/r.number,e.currency):a:a}function Um({price:e,period:r,translator:t}){const a=t.formatPrice(e.amountMicros,e.currency);return!r||!r.number?a:r.unit==="year"?t.formatPrice(e.amountMicros/12,e.currency):r.unit==="month"&&r.number>1?t.formatPrice(e.amountMicros/r.number,e.currency):r.unit==="week"?t.formatPrice(e.amountMicros*4/r.number,e.currency):r.unit==="day"?t.formatPrice(e.amountMicros*30/r.number,e.currency):a}function ds({price:e,period:r,full:t=!1,translator:a}){if(!r||!r.number||r.unit===xe.Month&&r.number==1)return a.formatPrice(e.amountMicros,e.currency);let n="";switch(r.unit){case xe.Year:n=a.formatPrice(e.amountMicros/12,e.currency);break;case xe.Month:n=a.formatPrice(e.amountMicros/r.number,e.currency);break;case xe.Week:n=a.formatPrice(e.amountMicros*4/r.number,e.currency);break;case xe.Day:n=a.formatPrice(e.amountMicros*30/r.number,e.currency);break}return a.translate(L.PaywallVariablesTotalPriceAndPerMonth,{formattedPrice:a.formatPrice(e.amountMicros,e.currency),period:a.translatePeriod(r.number,r.unit,{noWhitespace:!0,short:!t}),formattedPricePerMonth:n,monthPeriod:a.translatePeriodUnit(xe.Month,{noWhitespace:!0,short:!t})})}function Vm(e,r){const t=e.availablePackages,a=t.reduce((n,o)=>n.webBillingProduct.currentPrice.amountMicros>o.webBillingProduct.currentPrice.amountMicros?n:o);return t.reduce((n,o)=>(n[o.identifier]=Hm(o,a,r),n),{})}function Hm(e,r,t){const a=e.webBillingProduct,n=t.formatPrice(a.currentPrice.amountMicros,a.currentPrice.currency),o=Lm(e),i=a.productType,s={product_name:a.title,price:n,price_per_period:"",price_per_period_full:"",total_price_and_per_month:"",total_price_and_per_month_full:"",sub_price_per_month:"",sub_price_per_week:"",sub_duration:"",sub_duration_in_months:"",sub_period:"",sub_period_length:"",sub_period_abbreviated:"",sub_offer_duration:void 0,sub_offer_duration_2:void 0,sub_offer_price:void 0,sub_offer_price_2:void 0,sub_relative_discount:""};if(i===Ur.Subscription&&o){s.price_per_period=cs(n,o,t),s.price_per_period_full=cs(n,o,t,!0);const l=o.base.period;s.total_price_and_per_month=ds({price:a.currentPrice,period:l,translator:t}),s.total_price_and_per_month_full=ds({price:a.currentPrice,period:l,full:!0,translator:t}),s.sub_price_per_month=Um({price:a.currentPrice,period:l,translator:t}),s.sub_price_per_week=Rm({price:a.currentPrice,period:l,translator:t}),s.sub_duration=t.translatePeriod(l==null?void 0:l.number,l==null?void 0:l.unit),s.sub_duration_in_months=Bm(l,t),s.sub_period=t.translatePeriodFrequency(l==null?void 0:l.number,l==null?void 0:l.unit),s.sub_period_length=l?t.translatePeriodUnit(l.unit,{noWhitespace:!0}):void 0,s.sub_period_abbreviated=l?t.translatePeriodUnit(l.unit,{noWhitespace:!0,short:!0}):void 0;const d=a.currentPrice.amountMicros,u=r.webBillingProduct.currentPrice.amountMicros,_=((u-d)*100/u).toFixed(0);s.sub_relative_discount=d===u?"":t.translate(L.PaywallVariablesSubRelativeDiscount,{discount:_})}return(i===Ur.NonConsumable||i===Ur.Consumable)&&o&&(s.price=n,s.price_per_period=n,s.price_per_period_full=n,s.total_price_and_per_month=n,s.sub_price_per_month=n,s.sub_duration=t.translate(L.PeriodsLifetime),s.sub_duration_in_months=t.translate(L.PeriodsLifetime),s.sub_period=t.translate(L.PeriodsLifetime),s.sub_price_per_week=void 0,s.sub_relative_discount=void 0,s.price_per_period_full=n,s.total_price_and_per_month_full=n,s.sub_period_length=void 0,s.sub_period_abbreviated=void 0),s}const Ie=[];for(let e=0;e<256;++e)Ie.push((e+256).toString(16).slice(1));function Wm(e,r=0){return(Ie[e[r+0]]+Ie[e[r+1]]+Ie[e[r+2]]+Ie[e[r+3]]+"-"+Ie[e[r+4]]+Ie[e[r+5]]+"-"+Ie[e[r+6]]+Ie[e[r+7]]+"-"+Ie[e[r+8]]+Ie[e[r+9]]+"-"+Ie[e[r+10]]+Ie[e[r+11]]+Ie[e[r+12]]+Ie[e[r+13]]+Ie[e[r+14]]+Ie[e[r+15]]).toLowerCase()}let Yn;const Ym=new Uint8Array(16);function Gm(){if(!Yn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Yn=crypto.getRandomValues.bind(crypto)}return Yn(Ym)}const us={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ps(e,r,t){var n;if(us.randomUUID&&!e)return us.randomUUID();e=e||{};const a=e.random??((n=e.rng)==null?void 0:n.call(e))??Gm();if(a.length<16)throw new Error("Random bytes length must be >= 16");return a[6]=a[6]&15|64,a[8]=a[8]&63|128,Wm(a)}var Xm=/(%?)(%([sdijo]))/g;function Zm(e,r){switch(r){case"s":return e;case"d":case"i":return Number(e);case"j":return JSON.stringify(e);case"o":{if(typeof e=="string")return e;const t=JSON.stringify(e);return t==="{}"||t==="[]"||/^\[object .+?\]$/.test(t)?e:t}}}function Gn(e,...r){if(r.length===0)return e;let t=0,a=e.replace(Xm,(n,o,i,s)=>{const l=r[t],d=Zm(l,s);return o?n:(t++,d)});return t<r.length&&(a+=` ${r.slice(t).join(" ")}`),a=a.replace(/%{2,2}/g,"%"),a}var Km=2;function Jm(e){if(!e.stack)return;const r=e.stack.split(`
337
+ }`};function tm(e,r){H(r,!0),U(e,rm);const t=h=>h==null||h==null||h==""?null:h,a=S(()=>{var h;return t((h=r.brandingInfo)==null?void 0:h.app_icon)}),n=S(()=>{var h;return t((h=r.brandingInfo)==null?void 0:h.app_icon_webp)}),o=S(()=>{var h;return t((h=r.brandingInfo)==null?void 0:h.app_wordmark)}),i=S(()=>{var h;return t((h=r.brandingInfo)==null?void 0:h.app_wordmark_webp)}),s=S(()=>c(a)?Jt(c(a)):null),l=S(()=>c(n)?Jt(c(n)):null),d=S(()=>c(o)?Jt(c(o)):null),u=S(()=>c(i)?Jt(c(i)):null),_=()=>{r.onClose&&r.onClose()};var p=em(),g=P(p);{var m=h=>{var w=Qg(),D=P(w);Gg(D,{$$events:{click:_}}),b(h,w)};C(g,h=>{r.showCloseButton&&h(m)})}var f=O(g,2),k=P(f),v=P(k);{var y=h=>{Jg(h,{get src(){return c(d)},get srcWebp(){return c(u)}})},x=h=>{var w=te(),D=Y(w);{var G=X=>{Hg(X,{get src(){return c(s)},get srcWebp(){return c(l)}})};C(D,X=>{c(s)!==null&&c(l)!==null&&X(G)},!0)}b(h,w)};C(v,h=>{c(d)!==null?h(y):h(x,!1)})}var I=O(v,2);{var E=h=>{de(h,{size:"body-base",children:(w,D)=>{var G=le();A(()=>{var X;return ne(G,(X=r.brandingInfo)==null?void 0:X.app_name)}),b(w,G)},$$slots:{default:!0}})};C(I,h=>{c(d)===null&&h(E)})}var q=O(f,2);{var R=h=>{var w=$g(),D=P(w);Xi(D,{$$events:{click:_}}),b(h,w)};C(q,h=>{r.showCloseButton&&h(R)})}A(()=>Er(p,"rcb-with-close-button",r.showCloseButton)),b(e,p),W()}var am=T("<!> <!> <!> <!>",1);function nm(e,r){H(r,!0);const t=V(r,"onClose",3,void 0);let a=K(B(r.defaultPriceBreakdown??{currency:r.productDetails.currentPrice.currency,totalAmountInMicros:r.productDetails.currentPrice.amountMicros,totalExcludingTaxInMicros:r.productDetails.currentPrice.amountMicros,taxCalculationStatus:"unavailable",taxAmountInMicros:null,taxBreakdown:null}));const n=o=>{z(a,B(o))};Lg(e,{get brandingInfo(){return r.brandingInfo},get isInElement(){return r.isInElement},get isSandbox(){return r.isSandbox},get onClose(){return t()},navbarHeaderContent:l=>{var d=S(()=>!r.isInElement&&!!t());tm(l,{get brandingInfo(){return r.brandingInfo},get onClose(){return t()},get showCloseButton(){return c(d)}})},navbarBodyContent:l=>{var d=S(()=>{var u,_;return((_=(u=r.brandingInfo)==null?void 0:u.appearance)==null?void 0:_.show_product_description)??!1});dg(l,{get productDetails(){return r.productDetails},get purchaseOption(){return r.purchaseOptionToUse},get showProductDescription(){return c(d)},get priceBreakdown(){return c(a)}})},mainContent:l=>{var d=am(),u=Y(d);{var _=y=>{O_(y)};C(u,y=>{r.currentPage==="payment-entry-loading"&&y(_)})}var p=O(u,2);{var g=y=>{a_(y,{get productDetails(){return r.productDetails},get purchaseOption(){return r.purchaseOptionToUse},get brandingInfo(){return r.brandingInfo},get purchaseOperationHelper(){return r.purchaseOperationHelper},get gatewayParams(){return r.gatewayParams},get managementUrl(){return r.managementUrl},get customerEmail(){return r.customerEmail},get defaultPriceBreakdown(){return r.defaultPriceBreakdown},get onContinue(){return r.onContinue},get onError(){return r.onError},onPriceBreakdownUpdated:n})};C(p,y=>{r.currentPage==="payment-entry"&&y(g)})}var m=O(p,2);{var f=y=>{var x=S(()=>{var E;return((E=r.brandingInfo)==null?void 0:E.support_email)??null}),I=S(()=>{var E;return((E=r.brandingInfo)==null?void 0:E.app_name)??null});N_(y,{get lastError(){return r.lastError},get productDetails(){return r.productDetails},get supportEmail(){return c(x)},get onDismiss(){return r.closeWithError},get appName(){return c(I)}})};C(m,y=>{r.currentPage==="error"&&y(f)})}var k=O(m,2);{var v=y=>{C_(y,{get onContinue(){return r.onContinue}})};C(k,y=>{r.currentPage==="success"&&y(v)})}b(l,d)},$$slots:{navbarHeaderContent:!0,navbarBodyContent:!0,mainContent:!0}}),W()}function om(e){return e.trim()===""?"You need to provide your email address to continue.":e.match(/^[^@]+@[^@]+\.[^@]+$/)?null:"Email is not valid. Please provide a valid email address."}function im(e){if(e&&!e.match(/^[A-Z]{3}$/)){const r=`Currency code ${e} is not valid. Please provide a valid ISO 4217 currency code.`;throw Q.errorLog(r),new he(Te.ConfigurationError,r)}}function sm(e,r){var R;H(r,!0);const t=V(r,"customTranslations",19,()=>({})),a=r.customerEmail?om(r.customerEmail):null;let n=K(B(a?void 0:r.customerEmail)),o=r.rcPackage.webBillingProduct,i=K(null);const s=r.rcPackage.webBillingProduct.identifier??null;let l=K("payment-entry-loading"),d=K(null),u=K(null),_=K(B({})),p=K(null),g=K(null),m=K(null),f=K(null),k=new Pa(t(),r.selectedLocale,r.defaultLocale);var v=li(k);un(Ye,v),un(An,(R=r.brandingInfo)==null?void 0:R.appearance),Qe(()=>{r.isInElement||(z(g,B(document.documentElement.style.height)),z(m,B(document.documentElement.style.overflow)),z(f,B(document.body.style.height)),document.documentElement.style.height="100%",document.body.style.height="100%",document.documentElement.style.overflow="hidden")}),Rt(()=>{if(!r.isInElement){const h=(w,D,G)=>{G===""?w.style.removeProperty(D):w.style.setProperty(D,G)};h(document.documentElement,"height",c(g)),h(document.body,"height",c(f)),h(document.documentElement,"overflow",c(m))}}),un(Dn,r.eventsTracker),Qe(async()=>{if(s===null){x(new ge(ce.ErrorSettingUpPurchase,"Product ID was not set before purchase."));return}r.purchaseOperationHelper.checkoutStart(r.appUserId,s,r.purchaseOption,r.rcPackage.webBillingProduct.presentedOfferingContext,c(n),r.metadata).then(h=>{z(i,null),z(l,"payment-entry"),z(_,B(h.gateway_params)),z(p,B(h.management_url))}).catch(h=>{if(h.errorCode===ce.MissingEmailError)return z(n,void 0),r.purchaseOperationHelper.checkoutStart(r.appUserId,s,r.purchaseOption,r.rcPackage.webBillingProduct.presentedOfferingContext,c(n),r.metadata).then(w=>{z(i,null),z(l,"payment-entry"),z(_,B(w.gateway_params)),z(p,B(w.management_url))}).catch(w=>{x(w)});x(h)})});const y=()=>{if(c(l)==="payment-entry"){r.purchaseOperationHelper.pollCurrentPurchaseForCompletion().then(h=>{z(l,"success"),z(d,B(h.redemptionInfo)),z(u,B(h.operationSessionId))}).catch(h=>{x(h)});return}if(c(l)==="success"||c(l)==="error"){r.onFinished(c(u),c(d));return}z(l,"success")},x=h=>{const w=tp({errorCode:h.getErrorCode().toString(),errorMessage:h.message});r.eventsTracker.trackSDKEvent(w),z(i,B(h)),z(l,"error")},I=()=>{r.onError(c(i)??new ge(ce.UnknownError,"Unknown error without state set."))};var E=S(()=>r.purchases.isSandbox()),q=S(()=>c(n)??null);nm(e,{get isSandbox(){return c(E)},get currentPage(){return c(l)},get brandingInfo(){return r.brandingInfo},productDetails:o,get purchaseOptionToUse(){return r.purchaseOption},get lastError(){return c(i)},get gatewayParams(){return c(_)},get managementUrl(){return c(p)},get purchaseOperationHelper(){return r.purchaseOperationHelper},get isInElement(){return r.isInElement},get customerEmail(){return c(q)},closeWithError:I,onContinue:y,onError:x,get onClose(){return r.onClose}}),W()}function Zi(e){return e==null?!0:new Date(e)>new Date}function lm(e,r,t,a){const n=r.product_identifier;if(n in t)return cm(e,r,t[n]);if(n in a)return dm(e,r,a[n]);throw new he(Te.CustomerInfoError,"Could not find entitlement product in subscriptions or non-subscriptions.")}function cm(e,r,t){return{identifier:e,isActive:Zi(r.expires_date),willRenew:Ki(r.expires_date,t),store:(t==null?void 0:t.store)??"unknown",latestPurchaseDate:new Date(r.purchase_date),originalPurchaseDate:new Date(r.purchase_date),expirationDate:xr(r.expires_date),productIdentifier:r.product_identifier,productPlanIdentifier:r.product_plan_identifier??null,unsubscribeDetectedAt:xr(t==null?void 0:t.unsubscribe_detected_at),billingIssueDetectedAt:xr(t==null?void 0:t.billing_issues_detected_at),isSandbox:(t==null?void 0:t.is_sandbox)??!1,periodType:(t==null?void 0:t.period_type)??"normal",ownershipType:(t==null?void 0:t.ownership_type)??"UNKNOWN"}}function dm(e,r,t){return{identifier:e,isActive:!0,willRenew:!1,store:t.store,latestPurchaseDate:new Date(r.purchase_date),originalPurchaseDate:new Date(t.original_purchase_date),expirationDate:null,productIdentifier:r.product_identifier,productPlanIdentifier:null,unsubscribeDetectedAt:null,billingIssueDetectedAt:null,isSandbox:t.is_sandbox,periodType:"normal",ownershipType:"UNKNOWN"}}function um(e,r,t){const a={},n={};for(const o in e){const i=lm(o,e[o],r,t);a[o]=i,i.isActive&&(n[o]=i)}return{all:a,active:n}}function xr(e){return e==null?null:new Date(e)}function pm(e){const r=gm(e),t=e.subscriber,a=fm(t.non_subscriptions),n=Object.entries(e.subscriber.non_subscriptions).flatMap(([s,l])=>l.map(d=>({transactionIdentifier:d.id,productIdentifier:s,purchaseDate:new Date(d.purchase_date||d.original_purchase_date),storeTransactionId:d.store_transaction_id||null,store:d.store}))),o=new Date(e.request_date),i=Object.fromEntries(Object.entries(e.subscriber.subscriptions).map(([s,l])=>[s,{productIdentifier:s,purchaseDate:new Date(l.purchase_date),originalPurchaseDate:xr(l.original_purchase_date),expiresDate:xr(l.expires_date),store:l.store,unsubscribeDetectedAt:xr(l.unsubscribe_detected_at),isSandbox:l.is_sandbox,billingIssuesDetectedAt:xr(l.billing_issues_detected_at),gracePeriodExpiresDate:xr(l.grace_period_expires_date),ownershipType:l.ownership_type??"UNKNOWN",periodType:l.period_type,refundedAt:xr(l.refunded_at),storeTransactionId:l.store_transaction_id||null,isActive:Zi(l.expires_date),willRenew:Ki(l.expires_date,l)}]));return{entitlements:um(t.entitlements,t.subscriptions,a),allExpirationDatesByProduct:r,allPurchaseDatesByProduct:_m(e,a),activeSubscriptions:mm(r),managementURL:t.management_url,requestDate:o,firstSeenDate:new Date(t.first_seen),originalPurchaseDate:xr(t.original_purchase_date),originalAppUserId:e.subscriber.original_app_user_id,nonSubscriptionTransactions:n,subscriptionsByProductIdentifier:i}}function Ki(e,r){if(r==null)return!1;const t=r.store=="promotional",a=e==null,n=r.unsubscribe_detected_at!=null,o=r.billing_issues_detected_at!=null;return!(t||a||n||o)}function _m(e,r){const t={};for(const a in e.subscriber.subscriptions){const n=e.subscriber.subscriptions[a];t[a]=new Date(n.purchase_date)}for(const a in r){const n=r[a].purchase_date;n==null?t[a]=null:t[a]=new Date(n)}return t}function gm(e){const r={};for(const t in e.subscriber.subscriptions){const a=e.subscriber.subscriptions[t];a.expires_date==null?r[t]=null:r[t]=new Date(a.expires_date)}return r}function mm(e){const r=new Set,t=new Date;for(const a in e){const n=e[a];(n==null||n>t)&&r.add(a)}return r}function fm(e){const r={};for(const t in e){if(e[t].length===0)continue;const a=e[t].length;r[t]=e[t][a-1]}return r}const Ji="1.5.3",ym="https://api.revenuecat.com",bm="https://e.revenue.cat";var Ca;(function(e){e[e.CONTINUE=100]="CONTINUE",e[e.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",e[e.PROCESSING=102]="PROCESSING",e[e.EARLY_HINTS=103]="EARLY_HINTS",e[e.OK=200]="OK",e[e.CREATED=201]="CREATED",e[e.ACCEPTED=202]="ACCEPTED",e[e.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",e[e.NO_CONTENT=204]="NO_CONTENT",e[e.RESET_CONTENT=205]="RESET_CONTENT",e[e.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",e[e.MULTI_STATUS=207]="MULTI_STATUS",e[e.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",e[e.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",e[e.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",e[e.SEE_OTHER=303]="SEE_OTHER",e[e.NOT_MODIFIED=304]="NOT_MODIFIED",e[e.USE_PROXY=305]="USE_PROXY",e[e.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",e[e.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",e[e.BAD_REQUEST=400]="BAD_REQUEST",e[e.UNAUTHORIZED=401]="UNAUTHORIZED",e[e.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",e[e.FORBIDDEN=403]="FORBIDDEN",e[e.NOT_FOUND=404]="NOT_FOUND",e[e.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",e[e.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",e[e.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",e[e.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",e[e.CONFLICT=409]="CONFLICT",e[e.GONE=410]="GONE",e[e.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",e[e.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",e[e.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",e[e.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",e[e.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",e[e.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",e[e.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",e[e.IM_A_TEAPOT=418]="IM_A_TEAPOT",e[e.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",e[e.METHOD_FAILURE=420]="METHOD_FAILURE",e[e.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",e[e.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",e[e.LOCKED=423]="LOCKED",e[e.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",e[e.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",e[e.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",e[e.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",e[e.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",e[e.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",e[e.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",e[e.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",e[e.BAD_GATEWAY=502]="BAD_GATEWAY",e[e.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",e[e.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",e[e.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",e[e.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",e[e.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(Ca||(Ca={}));function Oa(e){return e?e.startsWith("rcb_sb_"):!1}async function Fr(e,r,t){const{apiKey:a,body:n,headers:o,httpConfig:i}=r,l=`${(i==null?void 0:i.proxyURL)??ym}${e.urlPath()}`;try{const d=await fetch(l,{method:e.method,headers:is(a,o,i==null?void 0:i.additionalHeaders),body:vm(n),signal:t});return await hm(d,e),await d.json()}catch(d){throw d instanceof TypeError?new he(Te.NetworkError,Ut.getPublicMessage(Te.NetworkError),d.message):d}}async function hm(e,r){const t=e.status;if(t>=Ca.INTERNAL_SERVER_ERROR)Un(r,t,await e.text());else if(t>=Ca.BAD_REQUEST){const a=await e.json(),n=a?JSON.stringify(a):null,o=a==null?void 0:a.code,i=a==null?void 0:a.message;if(o!=null){const s=Ut.convertCodeToBackendErrorCode(o);if(s==null)Un(r,t,n,o);else throw he.getForBackendError(s,i)}else Un(r,t,n)}}function Un(e,r,t,a){throw new he(Te.UnknownBackendError,"Unknown backend error.",`Request: ${e.name}. Status code: ${r}. Body: ${t}.`,{backendErrorCode:a})}function vm(e){return e==null?null:JSON.stringify(e)}const Qi="Authorization",$i="Content-Type",es="Accept",rs="X-Platform",ts="X-Version",as="X-Platform-Flavor",ns="X-Platform-Flavor-Version",os="X-Is-Sandbox",km=new Set([Qi,$i,es,rs,ts,os,as,ns]);function is(e,r,t){let a={[Qi]:`Bearer ${e}`,[$i]:"application/json",[es]:"application/json",[rs]:"web",[ts]:Ji,[os]:`${Oa(e)}`};const n=La.getPlatformInfo();if(n){const o={[as]:n.flavor,[ns]:n.version};a={...a,...o}}return r&&(a={...a,...r}),t&&(a={...t,...a}),a}const Vn="/v1/subscribers",kt="/rcbilling/v1";class wm{constructor(r){j(this,"appUserId");j(this,"method","GET");j(this,"name","getOfferings");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Vn}/${r}/offerings`}}class xm{constructor(r,t,a){j(this,"method","GET");j(this,"name","getProducts");j(this,"appUserId");j(this,"productIds");j(this,"currency");this.appUserId=r,this.productIds=t,this.currency=a}urlPath(){const r=encodeURIComponent(this.appUserId),t=this.productIds.map(encodeURIComponent).join("&id="),a=this.currency?`&currency=${this.currency}`:"";return`${kt}/subscribers/${r}/products?id=${t}${a}`}}class Pm{constructor(r){j(this,"method","GET");j(this,"name","getCustomerInfo");j(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Vn}/${r}`}}class Sm{constructor(){j(this,"method","GET");j(this,"name","getBrandingInfo")}urlPath(){return`${kt}/branding`}}class Em{constructor(){j(this,"method","POST");j(this,"name","postCheckoutStart")}urlPath(){return`${kt}/checkout/start`}}class Tm{constructor(r){j(this,"method","POST");j(this,"name","postCheckoutCalculateTax");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${kt}/checkout/${this.operationSessionId}/calculate_taxes`}}class Im{constructor(r){j(this,"method","POST");j(this,"name","postCheckoutComplete");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${kt}/checkout/${this.operationSessionId}/complete`}}class qm{constructor(r){j(this,"method","GET");j(this,"name","getCheckoutStatus");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${kt}/checkout/${this.operationSessionId}`}}class Fm{constructor(r){j(this,"method","POST");j(this,"name","setAttributes");j(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${Vn}/${r}/attributes`}}const Hn={};class zm{constructor(r,t=Hn){j(this,"API_KEY");j(this,"httpConfig");j(this,"isSandbox");this.API_KEY=r,this.httpConfig=t,this.isSandbox=Oa(r)}getIsSandbox(){return this.isSandbox}async getOfferings(r){return await Fr(new wm(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getCustomerInfo(r){return await Fr(new Pm(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getProducts(r,t,a){return await Fr(new xm(r,t,a),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getBrandingInfo(){return await Fr(new Sm,{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async postCheckoutStart(r,t,a,n,o,i,s=void 0){const l={app_user_id:r,product_id:t,email:i,price_id:n.priceId,presented_offering_identifier:a.offeringIdentifier,trace_id:o};return s&&(l.metadata=s),n.id!=="base_option"&&(l.offer_id=n.id),a.targetingContext&&(l.applied_targeting_rule={rule_id:a.targetingContext.ruleId,revision:a.targetingContext.revision}),a.placementIdentifier&&(l.presented_placement_identifier=a.placementIdentifier),await Fr(new Em,{apiKey:this.API_KEY,body:l,httpConfig:this.httpConfig})}async postCheckoutCalculateTax(r,t,a,n){const o={country_code:t,postal_code:a};return await Fr(new Tm(r),{apiKey:this.API_KEY,body:o,httpConfig:this.httpConfig},n)}async postCheckoutComplete(r,t){const a={email:t};return await Fr(new Im(r),{apiKey:this.API_KEY,body:a,httpConfig:this.httpConfig})}async getCheckoutStatus(r){return await Fr(new qm(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async setAttributes(r,t){const a=Date.now(),n={};for(const[i,s]of Object.entries(t))n[i]={value:s,updated_at_ms:a};const o={attributes:n};return await Fr(new Fm(r),{apiKey:this.API_KEY,body:o,httpConfig:this.httpConfig})}}function Dm(e){const r=/^rcb_[a-zA-Z0-9_.-]+$/,t=/^pdl_[a-zA-Z0-9_.-]+$/;if(!r.test(e)&&!t.test(e))throw new he(Te.InvalidCredentialsError,"Invalid API key. Use your Web Billing or Paddle API key.")}function ss(e){if(!e||new Set(["no_user","null","none","nil","(null)","NaN","\\x00","","unidentified","undefined","unknown"]).has(e)||e.includes("/"))throw new he(Te.InvalidAppUserIdError,'Provided user id: "'+(e??"[Not provided]")+'" is not valid. See https://www.revenuecat.com/docs/customers/user-ids#tips-for-setting-app-user-ids for more information.')}function Am(e){if(e!=null&&e.endsWith("/"))throw new he(Te.ConfigurationError,"Invalid proxy URL. The proxy URL should not end with a trailing slash.")}function jm(e){if(e){for(const r in e)if(km.has(r))throw new he(Te.ConfigurationError,"Invalid additional headers. Some headers are reserved for internal use.")}}var Wn=(e=>(e.Current="current",e))(Wn||{});function Mm(e,r){async function t(...a){return await this.preload(),await e.call(this,...a)}return t}const ls=(e,r)=>{const t={...e.webBillingProduct,presentedOfferingContext:{...e.webBillingProduct.presentedOfferingContext,placementIdentifier:r}};return{...e,webBillingProduct:t,rcBillingProduct:t}},rt=(e,r)=>e==null?null:ls(e,r),Nm=(e,r,t)=>{const a=e.offering_ids_by_placement??null;if(a==null)return null;const n=e.fallback_offering_id??null;let o;if(t in a){const s=a[t]??null;if(s==null)return null;o=r[s],o==null&&(o=r[n])}else o=r[n];if(o==null)return null;const i=Object.fromEntries(Object.entries(o.packagesById).map(([s,l])=>[s,ls(l,t)]));return{...o,packagesById:i,availablePackages:Object.values(i),weekly:rt(o.weekly,t),monthly:rt(o.monthly,t),twoMonth:rt(o.twoMonth,t),threeMonth:rt(o.threeMonth,t),sixMonth:rt(o.sixMonth,t),annual:rt(o.annual,t),lifetime:rt(o.lifetime,t)}};function Cm(e,r){const t={};r.product_details.forEach(o=>{t[o.identifier]=o});const a={};e.offerings.forEach(o=>{const i=o.identifier===e.current_offering_id,s=p_(i,o,t,e.targeting);s!=null&&(a[o.identifier]=s)});const n=e.current_offering_id?a[e.current_offering_id]??null:null;return Object.keys(a).length==0&&Q.debugLog("Empty offerings. Please make sure you've configured offerings correctly in the RevenueCat dashboard and that the products are properly configured."),{all:a,current:n}}const Om=1000001;function Lm(e){return e.webBillingProduct.defaultPurchaseOption}function cs(e,r,t,a=!1){return t.translate(L.PaywallVariablesPricePerPeriod,{formattedPrice:e,period:r.base.period?t.translatePeriod(r.base.period.number,r.base.period.unit,{noWhitespace:!0,short:!a}):""})}function Bm(e,r){return e.unit==="year"?r.translatePeriod(e.number*12,xe.Month):r.translatePeriod(e.number,e.unit)}function Rm({price:e,period:r,translator:t}){const a=t.formatPrice(e.amountMicros,e.currency);return r?r.unit==="year"?t.formatPrice(e.amountMicros/12/4,e.currency):r.unit==="month"||r.unit==="week"&&r.number>1?t.formatPrice(e.amountMicros/r.number,e.currency):r.unit==="day"?t.formatPrice(e.amountMicros*7/r.number,e.currency):a:a}function Um({price:e,period:r,translator:t}){const a=t.formatPrice(e.amountMicros,e.currency);return!r||!r.number?a:r.unit==="year"?t.formatPrice(e.amountMicros/12,e.currency):r.unit==="month"&&r.number>1?t.formatPrice(e.amountMicros/r.number,e.currency):r.unit==="week"?t.formatPrice(e.amountMicros*4/r.number,e.currency):r.unit==="day"?t.formatPrice(e.amountMicros*30/r.number,e.currency):a}function ds({price:e,period:r,full:t=!1,translator:a}){if(!r||!r.number||r.unit===xe.Month&&r.number==1)return a.formatPrice(e.amountMicros,e.currency);let n="";switch(r.unit){case xe.Year:n=a.formatPrice(e.amountMicros/12,e.currency);break;case xe.Month:n=a.formatPrice(e.amountMicros/r.number,e.currency);break;case xe.Week:n=a.formatPrice(e.amountMicros*4/r.number,e.currency);break;case xe.Day:n=a.formatPrice(e.amountMicros*30/r.number,e.currency);break}return a.translate(L.PaywallVariablesTotalPriceAndPerMonth,{formattedPrice:a.formatPrice(e.amountMicros,e.currency),period:a.translatePeriod(r.number,r.unit,{noWhitespace:!0,short:!t}),formattedPricePerMonth:n,monthPeriod:a.translatePeriodUnit(xe.Month,{noWhitespace:!0,short:!t})})}function Vm(e,r){const t=e.availablePackages,a=t.reduce((n,o)=>n.webBillingProduct.currentPrice.amountMicros>o.webBillingProduct.currentPrice.amountMicros?n:o);return t.reduce((n,o)=>(n[o.identifier]=Hm(o,a,r),n),{})}function Hm(e,r,t){const a=e.webBillingProduct,n=t.formatPrice(a.currentPrice.amountMicros,a.currentPrice.currency),o=Lm(e),i=a.productType,s={product_name:a.title,price:n,price_per_period:"",price_per_period_full:"",total_price_and_per_month:"",total_price_and_per_month_full:"",sub_price_per_month:"",sub_price_per_week:"",sub_duration:"",sub_duration_in_months:"",sub_period:"",sub_period_length:"",sub_period_abbreviated:"",sub_offer_duration:void 0,sub_offer_duration_2:void 0,sub_offer_price:void 0,sub_offer_price_2:void 0,sub_relative_discount:""};if(i===Ur.Subscription&&o){s.price_per_period=cs(n,o,t),s.price_per_period_full=cs(n,o,t,!0);const l=o.base.period;s.total_price_and_per_month=ds({price:a.currentPrice,period:l,translator:t}),s.total_price_and_per_month_full=ds({price:a.currentPrice,period:l,full:!0,translator:t}),s.sub_price_per_month=Um({price:a.currentPrice,period:l,translator:t}),s.sub_price_per_week=Rm({price:a.currentPrice,period:l,translator:t}),s.sub_duration=t.translatePeriod(l==null?void 0:l.number,l==null?void 0:l.unit),s.sub_duration_in_months=Bm(l,t),s.sub_period=t.translatePeriodFrequency(l==null?void 0:l.number,l==null?void 0:l.unit),s.sub_period_length=l?t.translatePeriodUnit(l.unit,{noWhitespace:!0}):void 0,s.sub_period_abbreviated=l?t.translatePeriodUnit(l.unit,{noWhitespace:!0,short:!0}):void 0;const d=a.currentPrice.amountMicros,u=r.webBillingProduct.currentPrice.amountMicros,_=((u-d)*100/u).toFixed(0);s.sub_relative_discount=d===u?"":t.translate(L.PaywallVariablesSubRelativeDiscount,{discount:_})}return(i===Ur.NonConsumable||i===Ur.Consumable)&&o&&(s.price=n,s.price_per_period=n,s.price_per_period_full=n,s.total_price_and_per_month=n,s.sub_price_per_month=n,s.sub_duration=t.translate(L.PeriodsLifetime),s.sub_duration_in_months=t.translate(L.PeriodsLifetime),s.sub_period=t.translate(L.PeriodsLifetime),s.sub_price_per_week=void 0,s.sub_relative_discount=void 0,s.price_per_period_full=n,s.total_price_and_per_month_full=n,s.sub_period_length=void 0,s.sub_period_abbreviated=void 0),s}const Ie=[];for(let e=0;e<256;++e)Ie.push((e+256).toString(16).slice(1));function Wm(e,r=0){return(Ie[e[r+0]]+Ie[e[r+1]]+Ie[e[r+2]]+Ie[e[r+3]]+"-"+Ie[e[r+4]]+Ie[e[r+5]]+"-"+Ie[e[r+6]]+Ie[e[r+7]]+"-"+Ie[e[r+8]]+Ie[e[r+9]]+"-"+Ie[e[r+10]]+Ie[e[r+11]]+Ie[e[r+12]]+Ie[e[r+13]]+Ie[e[r+14]]+Ie[e[r+15]]).toLowerCase()}let Yn;const Ym=new Uint8Array(16);function Gm(){if(!Yn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Yn=crypto.getRandomValues.bind(crypto)}return Yn(Ym)}const us={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ps(e,r,t){var n;if(us.randomUUID&&!e)return us.randomUUID();e=e||{};const a=e.random??((n=e.rng)==null?void 0:n.call(e))??Gm();if(a.length<16)throw new Error("Random bytes length must be >= 16");return a[6]=a[6]&15|64,a[8]=a[8]&63|128,Wm(a)}var Xm=/(%?)(%([sdijo]))/g;function Zm(e,r){switch(r){case"s":return e;case"d":case"i":return Number(e);case"j":return JSON.stringify(e);case"o":{if(typeof e=="string")return e;const t=JSON.stringify(e);return t==="{}"||t==="[]"||/^\[object .+?\]$/.test(t)?e:t}}}function Gn(e,...r){if(r.length===0)return e;let t=0,a=e.replace(Xm,(n,o,i,s)=>{const l=r[t],d=Zm(l,s);return o?n:(t++,d)});return t<r.length&&(a+=` ${r.slice(t).join(" ")}`),a=a.replace(/%{2,2}/g,"%"),a}var Km=2;function Jm(e){if(!e.stack)return;const r=e.stack.split(`
338
338
  `);r.splice(1,Km),e.stack=r.join(`
339
339
  `)}var Qm=class extends Error{constructor(e,...r){super(e),this.message=e,this.name="Invariant Violation",this.message=Gn(e,...r),Jm(this)}},_s=(e,r,...t)=>{if(!e)throw new Qm(r,...t)};_s.as=(e,r,t,...a)=>{if(!r){const n=a.length===0?t:Gn(t,...a);let o;try{o=Reflect.construct(e,[n])}catch{o=e(n)}throw o}};const $m="[MSW]";function Xn(e,...r){const t=Gn(e,...r);return`${$m} ${t}`}function ef(e,...r){console.warn(Xn(e,...r))}function rf(e,...r){console.error(Xn(e,...r))}const tf={formatMessage:Xn,warn:ef,error:rf};function af(){_s(typeof URL<"u",tf.formatMessage(`Global "URL" class is not defined. This likely means that you're running MSW in an environment that doesn't support all Node.js standard API (e.g. React Native). If that's the case, please use an appropriate polyfill for the "URL" class, like "react-native-url-polyfill".`))}var gs=(e=>(e.HEAD="HEAD",e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.DELETE="DELETE",e))(gs||{});af();class nf{constructor(r,t,a,n){j(this,"initialDelay");j(this,"maxDelay");j(this,"jitterPercent");j(this,"callback");j(this,"currentDelay");j(this,"timeoutId");j(this,"executingCallback",!1);this.initialDelay=r,this.currentDelay=r,this.maxDelay=t,this.jitterPercent=a,this.callback=n}tryFlush(){if(this.backingOff()){Q.debugLog("Backing off, not flushing");return}this.clearTimeout(),this.executeCallbackWithRetries()}stop(){this.clearTimeout()}schedule(r){if(this.timeoutId!==void 0)return;const t=this.addJitter(r||this.currentDelay);this.timeoutId=setTimeout(()=>{this.timeoutId=void 0,this.executeCallbackWithRetries()},t)}backoff(){const r=this.currentDelay,t=Math.min(this.currentDelay*2,this.maxDelay);Q.debugLog(`Backing next off to ${r}ms delay`),this.clearTimeout(),this.currentDelay=t,this.schedule(r)}reset(){this.currentDelay!==this.initialDelay&&(this.clearTimeout(),this.currentDelay=this.initialDelay)}async executeCallbackWithRetries(){if(this.executingCallback){Q.debugLog("Callback already running, rescheduling"),this.schedule();return}this.executingCallback=!0;try{await this.callback(),this.reset()}catch{this.backoff()}finally{this.executingCallback=!1}}backingOff(){return this.currentDelay>this.initialDelay}clearTimeout(){clearTimeout(this.timeoutId),this.timeoutId=void 0}addJitter(r){const t=r*this.jitterPercent,a=r-t,n=r+t;return Math.floor(Math.random()*(n-a+1)+a)}}function ms(e){const r={};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const a=t.replace(/([A-Z])/g,"_$1").toLowerCase(),n=e[t];n&&typeof n=="object"&&!Array.isArray(n)?r[a]=ms(n):r[a]=n}return r}class of{constructor(r){j(this,"EVENT_TYPE","web_billing");j(this,"id");j(this,"timestampMs");j(this,"data");this.id=ps(),this.timestampMs=Date.now(),this.data=r}toJSON(){return ms({id:this.id,timestampMs:this.timestampMs,type:this.EVENT_TYPE,eventName:this.data.eventName,appUserId:this.data.appUserId,context:{...this.data.context},properties:{...this.data.properties,traceId:this.data.traceId}})}}function sf(e,r){const t=new URLSearchParams(window.location.search);return{libraryName:"purchases-js",libraryVersion:Ji,locale:navigator.language,userAgent:navigator.userAgent,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,utmSource:t.get("utm_source")??null,utmMedium:t.get("utm_medium")??null,utmCampaign:t.get("utm_campaign")??null,utmContent:t.get("utm_content")??null,utmTerm:t.get("utm_term")??null,pageReferrer:document.referrer,pageUrl:`${window.location.origin}${window.location.pathname}`,pageTitle:document.title,source:e,rcSource:r}}const lf=2e3,cf=5*6e4,df=.1;class uf{constructor(r){j(this,"apiKey");j(this,"eventsQueue",[]);j(this,"eventsUrl");j(this,"flushManager");j(this,"traceId",ps());j(this,"appUserId");j(this,"isSilent");j(this,"rcSource");this.apiKey=r.apiKey,this.eventsUrl=`${bm}/v1/events`,this.appUserId=r.appUserId,this.isSilent=r.silent||!1,this.rcSource=r.rcSource,this.flushManager=new nf(lf,cf,df,this.flushEvents.bind(this))}async updateUser(r){this.appUserId=r}getTraceId(){return this.traceId}trackSDKEvent(r){this.trackEvent({...r,source:"sdk"})}trackExternalEvent(r){this.trackEvent({...r})}trackEvent(r){if(this.isSilent){Q.verboseLog("Skipping event tracking, the EventsTracker is silent");return}try{const t=new of({eventName:r.eventName,traceId:this.traceId,appUserId:this.appUserId,context:sf(r.source,this.rcSource),properties:r.properties||{}});this.eventsQueue.push(t),this.flushManager.tryFlush()}catch{Q.errorLog(`Error while tracking event ${r.eventName}`)}}dispose(){this.flushManager.stop()}flushEvents(){if(this.eventsQueue.length===0)return Promise.resolve();const r=[...this.eventsQueue];return fetch(this.eventsUrl,{method:gs.POST,headers:is(this.apiKey),body:JSON.stringify({events:r})}).then(t=>{if(t.status===200||t.status===201){this.eventsQueue.splice(0,r.length);return}else throw Q.debugLog("Events failed to flush due to server error"),new Error("Events failed to flush due to server error")}).catch(t=>{throw Q.debugLog("Error while flushing events"),t})}}const pf=()=>{const e=new URLSearchParams(window.location.search),r=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],t={};return r.forEach(a=>{const n=e.get(a);n!==null&&(t[a]=n)}),t},Zn={autoCollectUTMAsMetadata:!0,collectAnalyticsEvents:!0};function _f(){if(crypto&&crypto.randomUUID)return crypto.randomUUID();const e=new Uint8Array(16);if(crypto&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;const r=Array.from(e).map(t=>t.toString(16).padStart(2,"0"));return[r.slice(0,4).join(""),r.slice(4,6).join(""),r.slice(6,8).join(""),r.slice(8,10).join(""),r.slice(10,16).join("")].join("-")}var fs=(e=>(e.DisplayName="$displayName",e.Email="$email",e.PhoneNumber="$phoneNumber",e.IDFA="$idfa",e.IDFV="$idfv",e.GPSAdId="$gpsAdId",e.AndroidId="$androidId",e.AmazonAdId="$amazonAdId",e.IP="$ip",e.AdjustId="$adjustId",e.AmplitudeDeviceId="$amplitudeDeviceId",e.AmplitudeUserId="$amplitudeUserId",e.AppsflyerId="$appsflyerId",e.AppsflyerSharingFilter="$appsflyerSharingFilter",e.BranchId="$branchId",e.BrazeAliasName="$brazeAliasName",e.BrazeAliasLabel="$brazeAliasLabel",e.ClevertapId="$clevertapId",e.FbAnonId="$fbAnonId",e.MparticleId="$mparticleId",e.OnesignalId="$onesignalId",e.OnesignalUserId="$onesignalUserId",e.IntercomContactId="$intercomContactId",e.MediaSource="$mediaSource",e.Campaign="$campaign",e.AdGroup="$adGroup",e.AdId="$ad",e.Keyword="$keyword",e.Creative="$creative",e.APNSTokens="$apnsTokens",e.FCMTokens="$fcmTokens",e.AirshipChannelId="$airshipChannelId",e.SegmentId="$segmentId",e.IterableUserId="$iterableUserId",e.IterableCampaignId="$iterableCampaignId",e.IterableTemplateId="$iterableTemplateId",e.FirebaseAppInstanceId="$firebaseAppInstanceId",e.MixpanelDistinctId="$mixpanelDistinctId",e.ATTConsentStatus="$attConsentStatus",e.KochavaDeviceId="$kochavaDeviceId",e.DeviceVersion="$deviceVersion",e.PosthogUserId="$posthogUserId",e.TelemetryDeckUserId="$telemetryDeckUserId",e.TelemetryDeckAppId="$telemetryDeckAppId",e.AppleRefundHandlingPreference="$appleRefundHandlingPreference",e.CustomerioId="$customerioId",e.TenjinId="$tenjinId",e))(fs||{});const ys="$RCAnonymousID:";xs=[Mm];const qe=class qe{constructor(r,t,a=Hn,n=Zn){Ns(Kn,5,this);j(this,"_API_KEY");j(this,"_appUserId");j(this,"_brandingInfo",null);j(this,"_loadingResourcesPromise",null);j(this,"_flags");j(this,"backend");j(this,"purchaseOperationHelper");j(this,"eventsTracker");this._API_KEY=r,this._appUserId=t,this._flags={...Zn,...n},Oa(r)&&Q.debugLog("Initializing Purchases SDK with sandbox API Key"),this.eventsTracker=new uf({apiKey:this._API_KEY,appUserId:this._appUserId,silent:!this._flags.collectAnalyticsEvents,rcSource:this._flags.rcSource??null}),this.backend=new zm(this._API_KEY,a),this.purchaseOperationHelper=new Kl(this.backend,this.eventsTracker),this.eventsTracker.trackSDKEvent({eventName:Ve.SDKInitialized})}static setLogLevel(r){Q.setLogLevel(r)}static setPlatformInfo(r){qe._platformInfo=r}static getPlatformInfo(){return qe._platformInfo}static getSharedInstance(){if(qe.isConfigured())return qe.instance;throw new ti}static isConfigured(){return qe.instance!==void 0}static configure(r,t,a=Hn,n=Zn){return qe.instance!==void 0&&Q.warnLog("Purchases is already initialized. You normally should only configure Purchases once. Creating and returning new instance."),Dm(r),ss(t),Am(a.proxyURL),jm(a.additionalHeaders),qe.instance=new qe(r,t,a,n),qe.getSharedInstance()}async preload(){if(this.hasLoadedResources()){Q.verboseLog("Purchases resources are loaded. Skipping.");return}if(this._loadingResourcesPromise!==null){Q.verboseLog("Purchases resources are loading. Waiting."),await this._loadingResourcesPromise;return}return this._loadingResourcesPromise=this.fetchAndCacheBrandingInfo().catch(r=>{let t=`${r}`;r instanceof he&&(t=`${r.message}. ${r.underlyingErrorMessage?`Underlying error: ${r.underlyingErrorMessage}`:""}`),Q.errorLog(`Error fetching branding info: ${t}`)}).finally(()=>{this._loadingResourcesPromise=null}),this._loadingResourcesPromise}fetchAndCacheBrandingInfo(){return this.backend.getBrandingInfo().then(r=>{this._brandingInfo=r})}hasLoadedResources(){return this._brandingInfo!==null}async renderPaywall(r){console.warn("This method is @experimental, Paywalls are not generally available but they will come soon!");let a=r.htmlTarget??document.getElementById("rcb-ui-pw-root");if(a===null){const g=document.createElement("div");g.id="rcb-ui-pw-root",g.className="rcb-ui-pw-root",g.style.zIndex=`${Om}`,document.body.appendChild(g),a=g}if(a===null)throw new Error("Could not generate a mount point for the billing widget");const n=a;n.innerHTML="";const o=r.offering;if(!o.paywall_components)throw new Error("You cannot use paywalls yet, they are coming soon!");const i=r.selectedLocale||navigator.language,s=new Pa({},i,o.paywall_components.default_locale),l=g=>{var f;const m=o.availablePackages.find(k=>k.identifier===g);if(m===void 0)throw new Error(`No package found for ${g}`);return this.purchase({rcPackage:m,htmlTarget:r.purchaseHtmlTarget,customerEmail:r.customerEmail,selectedLocale:i,defaultLocale:((f=o.paywall_components)==null?void 0:f.default_locale)||bt})},d=g=>{var m;if(r.onNavigateToUrl){r.onNavigateToUrl(g);return}(m=window.open(g,"_blank"))==null||m.focus()},u=()=>{},_=()=>{if(r.onVisitCustomerCenter){r.onVisitCustomerCenter();return}},p=Vm(o,s);return new Promise((g,m)=>{Bo(kd,{target:n,props:{paywallData:o.paywall_components,selectedLocale:i,onNavigateToUrlClicked:d,onVisitCustomerCenterClicked:_,onBackClicked:()=>{if(r.onBack){r.onBack();return}n.innerHTML="",Q.debugLog("Purchase cancelled by user"),m(new he(Te.UserCancelledError))},onRestorePurchasesClicked:u,onPurchaseClicked:f=>{l(f).then(k=>{g(k)}).catch(k=>m(k))},onError:f=>m(f),variablesPerPackage:p}})})}async getOfferings(r){im(r==null?void 0:r.currency);const t=this._appUserId,a=await this.backend.getOfferings(t),n=(r==null?void 0:r.offeringIdentifier)===Wn.Current?a.current_offering_id:r==null?void 0:r.offeringIdentifier;return n&&(a.offerings=a.offerings.filter(o=>o.identifier===n)),await this.getAllOfferings(a,t,r)}async getCurrentOfferingForPlacement(r,t){const a=this._appUserId,n=await this.backend.getOfferings(a),o=await this.getAllOfferings(n,a,t),i=n.placements??null;return i==null?null:Nm(i,o.all,r)}async getAllOfferings(r,t,a){const n=r.offerings.flatMap(i=>i.packages).map(i=>i.platform_product_identifier),o=await this.backend.getProducts(t,n,a==null?void 0:a.currency);return this.logMissingProductIds(n,o.product_details),Cm(r,o)}async isEntitledTo(r){const t=await this.getCustomerInfo();return r in t.entitlements.active}purchasePackage(r,t,a){return this.purchase({rcPackage:r,customerEmail:t,htmlTarget:a})}purchase(r){var x;const{rcPackage:t,purchaseOption:a,htmlTarget:n,customerEmail:o,selectedLocale:i=bt,defaultLocale:s=bt}=r;let l=n??document.getElementById("rcb-ui-root");if(l===null){const I=document.createElement("div");I.className="rcb-ui-root",document.body.appendChild(I),l=I}if(l===null)throw new Error("Could not generate a mount point for the billing widget");const d=l,u=this._appUserId;Q.debugLog(`Presenting purchase form for package ${t.identifier}`);const _=i||s,p=a??t.webBillingProduct.defaultPurchaseOption,g=np({appearance:(x=this._brandingInfo)==null?void 0:x.appearance,rcPackage:t,purchaseOptionToUse:p,customerEmail:o});this.eventsTracker.trackSDKEvent(g);const f={...this._flags.autoCollectUTMAsMetadata?pf():{},...r.metadata||{}};let k=null;const v=this._brandingInfo;v&&r.brandingAppearanceOverride&&(v.appearance=r.brandingAppearanceOverride);const y=n!==void 0;return new Promise((I,E)=>{y||window.history.pushState({checkoutOpen:!0},"");const q=this._flags.rcSource==="app"?void 0:()=>{const w=ip();this.eventsTracker.trackSDKEvent(w),window.removeEventListener("popstate",q),k&&yn(k),d.innerHTML="",Q.debugLog("Purchase cancelled by user"),E(new he(Te.UserCancelledError))};!y&&q&&window.addEventListener("popstate",q),k=Bo(sm,{target:d,props:{isInElement:y,appUserId:u,rcPackage:t,purchaseOption:p,customerEmail:o,onFinished:async(w,D)=>{const G=op({redemptionInfo:D});this.eventsTracker.trackSDKEvent(G),Q.debugLog("Purchase finished"),k&&yn(k),d.innerHTML="";const X={customerInfo:await this._getCustomerInfoForUserId(u),redemptionInfo:D,operationSessionId:w};I(X)},onClose:q,onError:w=>{var G;const D=sp({errorCode:(G=w.errorCode)==null?void 0:G.toString(),errorMessage:w.message});this.eventsTracker.trackSDKEvent(D),k&&yn(k),d.innerHTML="",E(he.getForPurchasesFlowError(w))},purchases:this,eventsTracker:this.eventsTracker,brandingInfo:this._brandingInfo,purchaseOperationHelper:this.purchaseOperationHelper,selectedLocale:_,metadata:f,defaultLocale:s,customTranslations:r.labelsOverride}})})}async getCustomerInfo(){return await this._getCustomerInfoForUserId(this._appUserId)}getAppUserId(){return this._appUserId}async setAttributes(r){return await this.getCustomerInfo(),await this.backend.setAttributes(this._appUserId,r)}async changeUser(r){return ss(r),this._appUserId=r,this.eventsTracker.updateUser(r),await this.getCustomerInfo()}logMissingProductIds(r,t){const a={};t.forEach(o=>a[o.identifier]=o);const n=[];r.forEach(o=>{a[o]===void 0&&n.push(o)}),n.length>0&&Q.debugLog(`Could not find product data for product ids:
340
340
  ${n.join()}.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@revenuecat/purchases-js",
3
3
  "description": "Web subscriptions made easy. Powered by RevenueCat",
4
4
  "private": false,
5
- "version": "1.5.2",
5
+ "version": "1.5.3",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"