@revenuecat/purchases-js 1.4.0 → 1.4.1
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.
- package/dist/Purchases.es.js +3 -3
- package/dist/Purchases.umd.js +2 -2
- package/package.json +1 -1
package/dist/Purchases.es.js
CHANGED
|
@@ -9381,13 +9381,13 @@ function qp(e, r) {
|
|
|
9381
9381
|
F(S, R(q)), F(h, R(Q)), await ge();
|
|
9382
9382
|
}
|
|
9383
9383
|
async function ye() {
|
|
9384
|
-
d(S)
|
|
9384
|
+
d(S) !== "card" || !d(f) || !d(E) || d(k) || d(s) === "disabled" || (d(s) !== "loading" && (F(G, R(d(s))), F(s, "loading")), await lr(async (q) => {
|
|
9385
9385
|
await cr().then(() => q.throwIfAborted()).then(() => He(q)).then(() => q.throwIfAborted()).catch((Q) => {
|
|
9386
9386
|
q.aborted || Je(Q);
|
|
9387
9387
|
}).finally(() => {
|
|
9388
9388
|
d(s) === "loading" && !q.aborted && F(s, R(d(G)));
|
|
9389
9389
|
});
|
|
9390
|
-
}))
|
|
9390
|
+
}));
|
|
9391
9391
|
}
|
|
9392
9392
|
async function xe() {
|
|
9393
9393
|
return await lr(async (q) => {
|
|
@@ -11440,7 +11440,7 @@ function Vg(e) {
|
|
|
11440
11440
|
}
|
|
11441
11441
|
return r;
|
|
11442
11442
|
}
|
|
11443
|
-
const ji = "1.4.
|
|
11443
|
+
const ji = "1.4.1", Hg = "https://api.revenuecat.com", Wg = "https://e.revenue.cat";
|
|
11444
11444
|
var na;
|
|
11445
11445
|
(function(e) {
|
|
11446
11446
|
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";
|
package/dist/Purchases.umd.js
CHANGED
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
@container layout-query-container (width >= 768px) {.rc-checkout-secure-container.svelte-dg9m6p {margin-top:var(--rc-spacing-gapXLarge-desktop);}.rc-checkout-container.svelte-dg9m6p {gap:var(--rc-spacing-gapXLarge-desktop);}.rc-checkout-pay-container.svelte-dg9m6p {margin-top:var(--rc-spacing-gapXLarge-desktop);}.rc-checkout-price-update-info-container.svelte-dg9m6p {margin-top:var(--rc-spacing-gapXLarge-desktop);}
|
|
244
|
-
}form.svelte-dg9m6p {display:flex;flex-direction:column;flex-grow:1;}`};function kp(e,r){var ns,os,is;V(r,!0),B(e,vp);const t=Le(),a=()=>Oe(o,"$translator",t),n=Ce(bn),o=Ce(He),i=(ns=r.productDetails.subscriptionOptions)==null?void 0:ns[r.purchaseOption.id];let s=J(U(((os=r.defaultPriceBreakdown)==null?void 0:os.taxCalculationStatus)??((is=r.brandingInfo)!=null&&is.gateway_tax_collection_enabled?"unavailable":"disabled"))),l=J(null),c=J(null),u=J(U(r.productDetails.currentPrice.amountMicros)),p=J(U(r.productDetails.currentPrice.amountMicros)),_=E(()=>r.defaultPriceBreakdown??{currency:r.productDetails.currentPrice.currency,totalAmountInMicros:d(p),totalExcludingTaxInMicros:d(u),taxCalculationStatus:d(s),taxAmountInMicros:d(l),taxBreakdown:d(c)}),g=J(U(r.gatewayParams.elements_configuration)),m=J(null),f=J(null),v=J(null),h=J(U(r.customerEmail??void 0)),y=J(U(!!r.customerEmail)),P=J(!0),T=J(!1),S=J(void 0),z=J(void 0),W=J(void 0),k=J(!1),w=J(null),A=E(()=>d(P)||d(k)?"loading":d(z)?"error":"form"),Z=J("unavailable"),G=E(()=>!d(k)&&d(T)&&d(y)&&(d(s)==="disabled"||d(s)==="calculated"||d(s)==="miss-match"));tt(()=>{r.onPriceBreakdownUpdated(d(_))}),Ve(()=>{n.trackSDKEvent({eventName:Ge.CheckoutPaymentFormImpression})}),Ve(async()=>{d(s)==="unavailable"&&await le(null).catch(br)}),Ft(()=>{d(w)&&(d(w).abort(),F(w,null))});async function le(q,ae){await r.purchaseOperationHelper.checkoutCalculateTax(q==null?void 0:q.countryCode,q==null?void 0:q.postalCode,ae).then(me=>{ae==null||ae.throwIfAborted(),me.failed_reason?!q&&me.failed_reason===ci.invalid_tax_location?F(s,"pending"):F(s,"disabled"):F(s,"calculated"),F(l,U(me.tax_amount_in_micros)),F(u,U(me.total_excluding_tax_in_micros)),F(p,U(me.total_amount_in_micros)),F(c,U(me.pricing_phases.base.tax_breakdown)),F(g,U(me.gateway_params.elements_configuration)),F(m,U(q))})}function $(){F(P,!1)}async function oe(q,ae){F(h,U(ae)),F(y,U(q)),await we()}async function fe({complete:q,paymentMethod:ae}){F(S,U(ae)),F(T,U(q)),await we()}async function he(q){if(q==null||q.preventDefault(),d(k))return;const ae=hu({selectedPaymentMethod:d(S)??null});n.trackSDKEvent(ae),F(k,!0),await Fe()?r.onContinue():F(k,!1)}async function _e(q,ae){F(S,U(q)),F(h,U(ae)),await he()}async function we(){d(S)==="card"&&(!d(y)||!d(T)||d(k)||(d(s)!=="loading"&&(F(Z,U(d(s))),F(s,"loading")),await Er(async q=>{await Tr().then(()=>q.throwIfAborted()).then(()=>or(q)).then(()=>q.throwIfAborted()).catch(ae=>{q.aborted||br(ae)}).finally(()=>{d(s)==="loading"&&!q.aborted&&F(s,U(d(Z)))})})))}async function Fe(){return await Er(async q=>{const ae=d(p);let me;return await Tr().then(()=>q.throwIfAborted()).then(()=>or(q)).then(mt=>{me=mt}).then(()=>q.throwIfAborted()).then(ir(ae)).then(()=>q.throwIfAborted()).then(Lr).then(()=>q.throwIfAborted()).then(()=>yr(me)).then(()=>q.throwIfAborted()).then(()=>!0).catch(mt=>(q.aborted||br(mt),!1))})}async function Er(q){d(w)&&d(w).abort(),F(w,U(new AbortController));const ae=d(w).signal;try{return await q(ae)}catch(me){if(me instanceof DOMException&&me.name==="AbortError")return Promise.resolve(void 0);throw me}}async function Tr(){d(v)&&await De.submitElements(d(v))}async function or(q){var ft,Xt;if(d(s)==="unavailable"||d(s)==="disabled"||!d(v)||!d(f))return;const{customerDetails:ae,confirmationTokenId:me}=await De.extractTaxCustomerDetails(d(v),d(f));return q==null||q.throwIfAborted(),ae.postalCode===((ft=d(m))==null?void 0:ft.postalCode)&&ae.countryCode===((Xt=d(m))==null?void 0:Xt.countryCode)||await le(ae,q),me&&d(S)!=="card"?me:void 0}function ir(q){return()=>{if(d(p)!==q)throw new Pi}}async function Lr(){var me;const q=await r.purchaseOperationHelper.checkoutComplete(d(h)),ae=(me=q==null?void 0:q.gateway_params)==null?void 0:me.client_secret;ae&&F(W,U(ae))}async function yr(q){!d(f)||!d(v)||!d(W)||await De.confirmElements(d(f),d(v),d(W),q)}async function br(q){if(q instanceof Pi)F(s,"miss-match");else if(q instanceof ge){const ae=gu({errorCode:q.errorCode.toString(),errorMessage:q.message});n.trackSDKEvent(ae),q.errorCode===ue.MissingEmailError?F(z,U(a().translate(L.ErrorPageErrorMessageInvalidEmailError,{email:d(h)}))):r.onError(q)}else if(q instanceof qa)await hr(q);else throw q}async function hr(q){const ae=vu({errorCode:q.gatewayErrorCode??"",errorMessage:q.message??""});n.trackSDKEvent(ae),q.code===Pn.HandledFormError||(q.code===Pn.UnhandledFormError?F(z,U(q.message)):r.onError(new ge(ue.ErrorSettingUpPurchase,"Failed to initialize payment form",q.message)))}const Wt=()=>{F(z,void 0)};var Yt=hp(),Br=x(Yt);{var ja=q=>{var ae=bp(),me=x(ae);li(me),b(q,ae)};N(Br,q=>{d(A)==="loading"&&q(ja)})}var Gt=O(Br,2);{var jn=q=>{var ae=E(()=>a().translate(L.ErrorButtonTryAgain));yn(q,{title:null,type:"error",get closeButtonTitle(){return d(ae)},onDismiss:Wt,icon:ft=>{Wo(ft)},message:ft=>{var Xt=de();D(()=>ne(Xt,d(z))),b(ft,Xt)},$$slots:{icon:!0,message:!0}})};N(Gt,q=>{d(A)==="error"&&q(jn)})}var Ma=O(Gt,2),Na=x(Ma),gt=x(Na),Mn=x(gt),Kr=E(()=>!!r.customerEmail),zm=E(()=>d(s)!=="disabled");dp(Mn,{get stripeAccountId(){return r.gatewayParams.stripe_account_id},get publishableApiKey(){return r.gatewayParams.publishable_api_key},get elementsConfiguration(){return d(g)},get brandingInfo(){return r.brandingInfo},get skipEmail(){return d(Kr)},get billingAddressRequired(){return d(zm)},onLoadingComplete:$,onError:hr,onEmailChange:oe,onPaymentInfoChange:fe,onExpressCheckoutElementSubmit:_e,get stripe(){return d(f)},set stripe(q){F(f,U(q))},get elements(){return d(v)},set elements(q){F(v,U(q))}});var Nn=O(gt,2),Am=x(Nn);yp(Am,{subscriptionOption:i});var ts=O(Nn,2),as=x(ts),Fm=E(()=>!d(G)),jm=E(()=>{var q;return(q=r.brandingInfo)!=null&&q.gateway_tax_collection_enabled?d(_):void 0});Tu(as,{get disabled(){return d(Fm)},subscriptionOption:i,get priceBreakdown(){return d(jm)}});var Mm=O(as,2),Nm=x(Mm);pu(Nm,{get brandingInfo(){return r.brandingInfo},subscriptionOption:i}),D(()=>{kr(Na,"invisible",d(A)!=="form"),kr(Nn,"fully-hidden",d(s)!=="miss-match"||d(A)!=="form"),kr(ts,"fully-hidden",d(A)!=="form")}),ot("submit",Ma,he),b(e,Yt),H()}function wp(e){return e!=null}var Si=(e=>(e.Unknown="unknown",e.Custom="custom",e.Lifetime="$rc_lifetime",e.Annual="$rc_annual",e.SixMonth="$rc_six_month",e.ThreeMonth="$rc_three_month",e.TwoMonth="$rc_two_month",e.Monthly="$rc_monthly",e.Weekly="$rc_weekly",e))(Si||{}),Or=(e=>(e.Subscription="subscription",e.Consumable="consumable",e.NonConsumable="non_consumable",e))(Or||{});const Ei=e=>({amount:e.amount_micros/1e4,amountMicros:e.amount_micros,currency:e.currency,formattedPrice:Cr(e.amount_micros,e.currency)}),Ti=e=>{const r=e.period_duration,t=e.price?Ei(e.price):null,a=r?Uo(r):null;let n=null,o=null,i=null;if(t!==null&&a!==null){const s=xp(a),l=1e4,c=Math.round(t.amountMicros*s.toWeek);n={amount:c/l,amountMicros:c,currency:t.currency,formattedPrice:Cr(c,t.currency)};const u=Math.round(t.amountMicros*s.toMonth);o={amount:u/l,amountMicros:u,currency:t.currency,formattedPrice:Cr(u,t.currency)};const p=Math.round(t.amountMicros*s.toYear);i={amount:p/l,amountMicros:p,currency:t.currency,formattedPrice:Cr(p,t.currency)}}return{periodDuration:r,period:a,cycleCount:e.cycle_count,price:t,pricePerWeek:n,pricePerMonth:o,pricePerYear:i}};function xp(e){const{number:r,unit:t}=e,a=7,n=30,o=365;let i;switch(t){case We.Day:i=r;break;case We.Week:i=r*a;break;case We.Month:i=r*n;break;case We.Year:i=r*o;break;default:i=0,Q.errorLog(`Unknown period unit: ${t}`)}const s=i>0?a/i:0,l=i>0?n/i:0,c=i>0?o/i:0;return{toWeek:s,toMonth:l,toYear:c}}const Pp=e=>e.base==null?(Q.debugLog("Missing base phase for subscription option. Ignoring."),null):{id:e.id,priceId:e.price_id,base:Ti(e.base),trial:e.trial?Ti(e.trial):null},Sp=e=>e.base_price==null?(Q.debugLog("Missing base price for non-subscription option. Ignoring."),null):{id:e.id,priceId:e.price_id,basePrice:Ei(e.base_price)},Ep=(e,r)=>{const t=e.product_type;return t==="subscription"?Ip(e,r,t):Tp(e,r,t)},Tp=(e,r,t)=>{const a={};if(Object.entries(e.purchase_options).forEach(([i,s])=>{const l=Sp(s);l!=null&&(a[i]=l)}),Object.keys(a).length===0)return Q.debugLog(`Product ${e.identifier} has no purchase options. Ignoring.`),null;const n=e.default_purchase_option_id,o=n&&n in e.purchase_options?a[n]:null;return o==null?(Q.debugLog(`Product ${e.identifier} has no default purchase option. Ignoring.`),null):{identifier:e.identifier,displayName:e.title,title:e.title,description:e.description,productType:t,currentPrice:o.basePrice,normalPeriodDuration:null,presentedOfferingIdentifier:r.offeringIdentifier,presentedOfferingContext:r,defaultPurchaseOption:o,defaultSubscriptionOption:null,subscriptionOptions:{},defaultNonSubscriptionOption:o}},Ip=(e,r,t)=>{const a={};if(Object.entries(e.purchase_options).forEach(([s,l])=>{const c=Pp(l);c!=null&&(a[s]=c)}),Object.keys(a).length===0)return Q.debugLog(`Product ${e.identifier} has no subscription options. Ignoring.`),null;const n=e.default_purchase_option_id,o=n&&n in a?a[n]:null;if(o==null)return Q.debugLog(`Product ${e.identifier} has no default subscription option. Ignoring.`),null;const i=o.base.price;return i==null?(Q.debugLog(`Product ${e.identifier} default option has no base price. Ignoring.`),null):{identifier:e.identifier,displayName:e.title,title:e.title,description:e.description,productType:t,currentPrice:i,normalPeriodDuration:o.base.periodDuration,presentedOfferingIdentifier:r.offeringIdentifier,presentedOfferingContext:r,defaultPurchaseOption:o,defaultSubscriptionOption:o,subscriptionOptions:a,defaultNonSubscriptionOption:null}},qp=(e,r,t)=>{const a=t[r.platform_product_identifier];if(a===void 0)return null;const n=Ep(a,e);return n===null?null:{identifier:r.identifier,rcBillingProduct:n,webBillingProduct:n,packageType:zp(r.identifier)}},Dp=(e,r,t,a)=>{const n={offeringIdentifier:r.identifier,targetingContext:e&&a?{ruleId:a.rule_id,revision:a.revision}:null,placementIdentifier:null},o=r.packages.map(s=>qp(n,s,t)).filter(wp),i={};for(const s of o)s!=null&&(i[s.identifier]=s);return o.length==0?null:{identifier:r.identifier,serverDescription:r.description,metadata:r.metadata,packagesById:i,availablePackages:o,lifetime:i.$rc_lifetime??null,annual:i.$rc_annual??null,sixMonth:i.$rc_six_month??null,threeMonth:i.$rc_three_month??null,twoMonth:i.$rc_two_month??null,monthly:i.$rc_monthly??null,weekly:i.$rc_weekly??null,paywall_components:r.paywall_components?r.paywall_components:null}};function zp(e){switch(e){case"$rc_lifetime":return"$rc_lifetime";case"$rc_annual":return"$rc_annual";case"$rc_six_month":return"$rc_six_month";case"$rc_three_month":return"$rc_three_month";case"$rc_two_month":return"$rc_two_month";case"$rc_monthly":return"$rc_monthly";case"$rc_weekly":return"$rc_weekly";default:return e.startsWith("$rc_")?"unknown":"custom"}}var Ap=dr('<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.94 5.72656L8 8.7799L11.06 5.72656L12 6.66656L8 10.6666L4 6.66656L4.94 5.72656Z" class="arrow-fill svelte-1qexsu3" fill-opacity="0.7"></path></svg>');const Fp={hash:"svelte-1qexsu3",code:".arrow.svelte-1qexsu3 {transition:transform 0.3s ease;}.arrow-fill.svelte-1qexsu3 {fill:var(--rc-color-grey-text-dark);}.arrow.left.svelte-1qexsu3 {transform:rotate(90deg);}.arrow.up.svelte-1qexsu3 {transform:rotate(180deg);}.arrow.right.svelte-1qexsu3 {transform:rotate(-90deg);}.arrow.down.svelte-1qexsu3 {transform:rotate(0deg);}"};function Da(e,r){B(e,Fp);let t=R(r,"direction",8);var a=Ap();D(()=>ml(a,`arrow ${t()??""} svelte-1qexsu3`)),b(e,a)}var jp=dr('<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="arrow"><path d="M15.41 7.41L14 6L8 12L14 18L15.41 16.59L10.83 12L15.41 7.41Z" class="arrow-fill svelte-r0zny8" fill-opacity="0.7"></path></svg>');const Mp={hash:"svelte-r0zny8",code:".arrow-fill.svelte-r0zny8 {fill:var(--rc-color-grey-text-dark);}"};function Np(e){B(e,Mp);var r=jp();b(e,r)}const Cp=`<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"
|
|
244
|
+
}form.svelte-dg9m6p {display:flex;flex-direction:column;flex-grow:1;}`};function kp(e,r){var ns,os,is;V(r,!0),B(e,vp);const t=Le(),a=()=>Oe(o,"$translator",t),n=Ce(bn),o=Ce(He),i=(ns=r.productDetails.subscriptionOptions)==null?void 0:ns[r.purchaseOption.id];let s=J(U(((os=r.defaultPriceBreakdown)==null?void 0:os.taxCalculationStatus)??((is=r.brandingInfo)!=null&&is.gateway_tax_collection_enabled?"unavailable":"disabled"))),l=J(null),c=J(null),u=J(U(r.productDetails.currentPrice.amountMicros)),p=J(U(r.productDetails.currentPrice.amountMicros)),_=E(()=>r.defaultPriceBreakdown??{currency:r.productDetails.currentPrice.currency,totalAmountInMicros:d(p),totalExcludingTaxInMicros:d(u),taxCalculationStatus:d(s),taxAmountInMicros:d(l),taxBreakdown:d(c)}),g=J(U(r.gatewayParams.elements_configuration)),m=J(null),f=J(null),v=J(null),h=J(U(r.customerEmail??void 0)),y=J(U(!!r.customerEmail)),P=J(!0),T=J(!1),S=J(void 0),z=J(void 0),W=J(void 0),k=J(!1),w=J(null),A=E(()=>d(P)||d(k)?"loading":d(z)?"error":"form"),Z=J("unavailable"),G=E(()=>!d(k)&&d(T)&&d(y)&&(d(s)==="disabled"||d(s)==="calculated"||d(s)==="miss-match"));tt(()=>{r.onPriceBreakdownUpdated(d(_))}),Ve(()=>{n.trackSDKEvent({eventName:Ge.CheckoutPaymentFormImpression})}),Ve(async()=>{d(s)==="unavailable"&&await le(null).catch(br)}),Ft(()=>{d(w)&&(d(w).abort(),F(w,null))});async function le(q,ae){await r.purchaseOperationHelper.checkoutCalculateTax(q==null?void 0:q.countryCode,q==null?void 0:q.postalCode,ae).then(me=>{ae==null||ae.throwIfAborted(),me.failed_reason?!q&&me.failed_reason===ci.invalid_tax_location?F(s,"pending"):F(s,"disabled"):F(s,"calculated"),F(l,U(me.tax_amount_in_micros)),F(u,U(me.total_excluding_tax_in_micros)),F(p,U(me.total_amount_in_micros)),F(c,U(me.pricing_phases.base.tax_breakdown)),F(g,U(me.gateway_params.elements_configuration)),F(m,U(q))})}function $(){F(P,!1)}async function oe(q,ae){F(h,U(ae)),F(y,U(q)),await we()}async function fe({complete:q,paymentMethod:ae}){F(S,U(ae)),F(T,U(q)),await we()}async function he(q){if(q==null||q.preventDefault(),d(k))return;const ae=hu({selectedPaymentMethod:d(S)??null});n.trackSDKEvent(ae),F(k,!0),await Fe()?r.onContinue():F(k,!1)}async function _e(q,ae){F(S,U(q)),F(h,U(ae)),await he()}async function we(){d(S)!=="card"||!d(y)||!d(T)||d(k)||d(s)==="disabled"||(d(s)!=="loading"&&(F(Z,U(d(s))),F(s,"loading")),await Er(async q=>{await Tr().then(()=>q.throwIfAborted()).then(()=>or(q)).then(()=>q.throwIfAborted()).catch(ae=>{q.aborted||br(ae)}).finally(()=>{d(s)==="loading"&&!q.aborted&&F(s,U(d(Z)))})}))}async function Fe(){return await Er(async q=>{const ae=d(p);let me;return await Tr().then(()=>q.throwIfAborted()).then(()=>or(q)).then(mt=>{me=mt}).then(()=>q.throwIfAborted()).then(ir(ae)).then(()=>q.throwIfAborted()).then(Lr).then(()=>q.throwIfAborted()).then(()=>yr(me)).then(()=>q.throwIfAborted()).then(()=>!0).catch(mt=>(q.aborted||br(mt),!1))})}async function Er(q){d(w)&&d(w).abort(),F(w,U(new AbortController));const ae=d(w).signal;try{return await q(ae)}catch(me){if(me instanceof DOMException&&me.name==="AbortError")return Promise.resolve(void 0);throw me}}async function Tr(){d(v)&&await De.submitElements(d(v))}async function or(q){var ft,Xt;if(d(s)==="unavailable"||d(s)==="disabled"||!d(v)||!d(f))return;const{customerDetails:ae,confirmationTokenId:me}=await De.extractTaxCustomerDetails(d(v),d(f));return q==null||q.throwIfAborted(),ae.postalCode===((ft=d(m))==null?void 0:ft.postalCode)&&ae.countryCode===((Xt=d(m))==null?void 0:Xt.countryCode)||await le(ae,q),me&&d(S)!=="card"?me:void 0}function ir(q){return()=>{if(d(p)!==q)throw new Pi}}async function Lr(){var me;const q=await r.purchaseOperationHelper.checkoutComplete(d(h)),ae=(me=q==null?void 0:q.gateway_params)==null?void 0:me.client_secret;ae&&F(W,U(ae))}async function yr(q){!d(f)||!d(v)||!d(W)||await De.confirmElements(d(f),d(v),d(W),q)}async function br(q){if(q instanceof Pi)F(s,"miss-match");else if(q instanceof ge){const ae=gu({errorCode:q.errorCode.toString(),errorMessage:q.message});n.trackSDKEvent(ae),q.errorCode===ue.MissingEmailError?F(z,U(a().translate(L.ErrorPageErrorMessageInvalidEmailError,{email:d(h)}))):r.onError(q)}else if(q instanceof qa)await hr(q);else throw q}async function hr(q){const ae=vu({errorCode:q.gatewayErrorCode??"",errorMessage:q.message??""});n.trackSDKEvent(ae),q.code===Pn.HandledFormError||(q.code===Pn.UnhandledFormError?F(z,U(q.message)):r.onError(new ge(ue.ErrorSettingUpPurchase,"Failed to initialize payment form",q.message)))}const Wt=()=>{F(z,void 0)};var Yt=hp(),Br=x(Yt);{var ja=q=>{var ae=bp(),me=x(ae);li(me),b(q,ae)};N(Br,q=>{d(A)==="loading"&&q(ja)})}var Gt=O(Br,2);{var jn=q=>{var ae=E(()=>a().translate(L.ErrorButtonTryAgain));yn(q,{title:null,type:"error",get closeButtonTitle(){return d(ae)},onDismiss:Wt,icon:ft=>{Wo(ft)},message:ft=>{var Xt=de();D(()=>ne(Xt,d(z))),b(ft,Xt)},$$slots:{icon:!0,message:!0}})};N(Gt,q=>{d(A)==="error"&&q(jn)})}var Ma=O(Gt,2),Na=x(Ma),gt=x(Na),Mn=x(gt),Kr=E(()=>!!r.customerEmail),zm=E(()=>d(s)!=="disabled");dp(Mn,{get stripeAccountId(){return r.gatewayParams.stripe_account_id},get publishableApiKey(){return r.gatewayParams.publishable_api_key},get elementsConfiguration(){return d(g)},get brandingInfo(){return r.brandingInfo},get skipEmail(){return d(Kr)},get billingAddressRequired(){return d(zm)},onLoadingComplete:$,onError:hr,onEmailChange:oe,onPaymentInfoChange:fe,onExpressCheckoutElementSubmit:_e,get stripe(){return d(f)},set stripe(q){F(f,U(q))},get elements(){return d(v)},set elements(q){F(v,U(q))}});var Nn=O(gt,2),Am=x(Nn);yp(Am,{subscriptionOption:i});var ts=O(Nn,2),as=x(ts),Fm=E(()=>!d(G)),jm=E(()=>{var q;return(q=r.brandingInfo)!=null&&q.gateway_tax_collection_enabled?d(_):void 0});Tu(as,{get disabled(){return d(Fm)},subscriptionOption:i,get priceBreakdown(){return d(jm)}});var Mm=O(as,2),Nm=x(Mm);pu(Nm,{get brandingInfo(){return r.brandingInfo},subscriptionOption:i}),D(()=>{kr(Na,"invisible",d(A)!=="form"),kr(Nn,"fully-hidden",d(s)!=="miss-match"||d(A)!=="form"),kr(ts,"fully-hidden",d(A)!=="form")}),ot("submit",Ma,he),b(e,Yt),H()}function wp(e){return e!=null}var Si=(e=>(e.Unknown="unknown",e.Custom="custom",e.Lifetime="$rc_lifetime",e.Annual="$rc_annual",e.SixMonth="$rc_six_month",e.ThreeMonth="$rc_three_month",e.TwoMonth="$rc_two_month",e.Monthly="$rc_monthly",e.Weekly="$rc_weekly",e))(Si||{}),Or=(e=>(e.Subscription="subscription",e.Consumable="consumable",e.NonConsumable="non_consumable",e))(Or||{});const Ei=e=>({amount:e.amount_micros/1e4,amountMicros:e.amount_micros,currency:e.currency,formattedPrice:Cr(e.amount_micros,e.currency)}),Ti=e=>{const r=e.period_duration,t=e.price?Ei(e.price):null,a=r?Uo(r):null;let n=null,o=null,i=null;if(t!==null&&a!==null){const s=xp(a),l=1e4,c=Math.round(t.amountMicros*s.toWeek);n={amount:c/l,amountMicros:c,currency:t.currency,formattedPrice:Cr(c,t.currency)};const u=Math.round(t.amountMicros*s.toMonth);o={amount:u/l,amountMicros:u,currency:t.currency,formattedPrice:Cr(u,t.currency)};const p=Math.round(t.amountMicros*s.toYear);i={amount:p/l,amountMicros:p,currency:t.currency,formattedPrice:Cr(p,t.currency)}}return{periodDuration:r,period:a,cycleCount:e.cycle_count,price:t,pricePerWeek:n,pricePerMonth:o,pricePerYear:i}};function xp(e){const{number:r,unit:t}=e,a=7,n=30,o=365;let i;switch(t){case We.Day:i=r;break;case We.Week:i=r*a;break;case We.Month:i=r*n;break;case We.Year:i=r*o;break;default:i=0,Q.errorLog(`Unknown period unit: ${t}`)}const s=i>0?a/i:0,l=i>0?n/i:0,c=i>0?o/i:0;return{toWeek:s,toMonth:l,toYear:c}}const Pp=e=>e.base==null?(Q.debugLog("Missing base phase for subscription option. Ignoring."),null):{id:e.id,priceId:e.price_id,base:Ti(e.base),trial:e.trial?Ti(e.trial):null},Sp=e=>e.base_price==null?(Q.debugLog("Missing base price for non-subscription option. Ignoring."),null):{id:e.id,priceId:e.price_id,basePrice:Ei(e.base_price)},Ep=(e,r)=>{const t=e.product_type;return t==="subscription"?Ip(e,r,t):Tp(e,r,t)},Tp=(e,r,t)=>{const a={};if(Object.entries(e.purchase_options).forEach(([i,s])=>{const l=Sp(s);l!=null&&(a[i]=l)}),Object.keys(a).length===0)return Q.debugLog(`Product ${e.identifier} has no purchase options. Ignoring.`),null;const n=e.default_purchase_option_id,o=n&&n in e.purchase_options?a[n]:null;return o==null?(Q.debugLog(`Product ${e.identifier} has no default purchase option. Ignoring.`),null):{identifier:e.identifier,displayName:e.title,title:e.title,description:e.description,productType:t,currentPrice:o.basePrice,normalPeriodDuration:null,presentedOfferingIdentifier:r.offeringIdentifier,presentedOfferingContext:r,defaultPurchaseOption:o,defaultSubscriptionOption:null,subscriptionOptions:{},defaultNonSubscriptionOption:o}},Ip=(e,r,t)=>{const a={};if(Object.entries(e.purchase_options).forEach(([s,l])=>{const c=Pp(l);c!=null&&(a[s]=c)}),Object.keys(a).length===0)return Q.debugLog(`Product ${e.identifier} has no subscription options. Ignoring.`),null;const n=e.default_purchase_option_id,o=n&&n in a?a[n]:null;if(o==null)return Q.debugLog(`Product ${e.identifier} has no default subscription option. Ignoring.`),null;const i=o.base.price;return i==null?(Q.debugLog(`Product ${e.identifier} default option has no base price. Ignoring.`),null):{identifier:e.identifier,displayName:e.title,title:e.title,description:e.description,productType:t,currentPrice:i,normalPeriodDuration:o.base.periodDuration,presentedOfferingIdentifier:r.offeringIdentifier,presentedOfferingContext:r,defaultPurchaseOption:o,defaultSubscriptionOption:o,subscriptionOptions:a,defaultNonSubscriptionOption:null}},qp=(e,r,t)=>{const a=t[r.platform_product_identifier];if(a===void 0)return null;const n=Ep(a,e);return n===null?null:{identifier:r.identifier,rcBillingProduct:n,webBillingProduct:n,packageType:zp(r.identifier)}},Dp=(e,r,t,a)=>{const n={offeringIdentifier:r.identifier,targetingContext:e&&a?{ruleId:a.rule_id,revision:a.revision}:null,placementIdentifier:null},o=r.packages.map(s=>qp(n,s,t)).filter(wp),i={};for(const s of o)s!=null&&(i[s.identifier]=s);return o.length==0?null:{identifier:r.identifier,serverDescription:r.description,metadata:r.metadata,packagesById:i,availablePackages:o,lifetime:i.$rc_lifetime??null,annual:i.$rc_annual??null,sixMonth:i.$rc_six_month??null,threeMonth:i.$rc_three_month??null,twoMonth:i.$rc_two_month??null,monthly:i.$rc_monthly??null,weekly:i.$rc_weekly??null,paywall_components:r.paywall_components?r.paywall_components:null}};function zp(e){switch(e){case"$rc_lifetime":return"$rc_lifetime";case"$rc_annual":return"$rc_annual";case"$rc_six_month":return"$rc_six_month";case"$rc_three_month":return"$rc_three_month";case"$rc_two_month":return"$rc_two_month";case"$rc_monthly":return"$rc_monthly";case"$rc_weekly":return"$rc_weekly";default:return e.startsWith("$rc_")?"unknown":"custom"}}var Ap=dr('<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.94 5.72656L8 8.7799L11.06 5.72656L12 6.66656L8 10.6666L4 6.66656L4.94 5.72656Z" class="arrow-fill svelte-1qexsu3" fill-opacity="0.7"></path></svg>');const Fp={hash:"svelte-1qexsu3",code:".arrow.svelte-1qexsu3 {transition:transform 0.3s ease;}.arrow-fill.svelte-1qexsu3 {fill:var(--rc-color-grey-text-dark);}.arrow.left.svelte-1qexsu3 {transform:rotate(90deg);}.arrow.up.svelte-1qexsu3 {transform:rotate(180deg);}.arrow.right.svelte-1qexsu3 {transform:rotate(-90deg);}.arrow.down.svelte-1qexsu3 {transform:rotate(0deg);}"};function Da(e,r){B(e,Fp);let t=R(r,"direction",8);var a=Ap();D(()=>ml(a,`arrow ${t()??""} svelte-1qexsu3`)),b(e,a)}var jp=dr('<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="arrow"><path d="M15.41 7.41L14 6L8 12L14 18L15.41 16.59L10.83 12L15.41 7.41Z" class="arrow-fill svelte-r0zny8" fill-opacity="0.7"></path></svg>');const Mp={hash:"svelte-r0zny8",code:".arrow-fill.svelte-r0zny8 {fill:var(--rc-color-grey-text-dark);}"};function Np(e){B(e,Mp);var r=jp();b(e,r)}const Cp=`<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"
|
|
245
245
|
xmlns="http://www.w3.org/2000/svg">
|
|
246
246
|
<g opacity="0.5" clip-path="url(#clip0_344_3390)">
|
|
247
247
|
<path d="M7 18C5.9 18 5.01 18.9 5.01 20C5.01 21.1 5.9 22 7 22C8.1 22 9 21.1 9 20C9 18.9 8.1 18 7 18ZM1 2V4H3L6.6 11.59L5.25 14.04C5.09 14.32 5 14.65 5 15C5 16.1 5.9 17 7 17H19V15H7.42C7.28 15 7.17 14.89 7.17 14.75L7.2 14.63L8.1 13H15.55C16.3 13 16.96 12.59 17.3 11.97L20.88 5.48C20.96 5.34 21 5.17 21 5C21 4.45 20.55 4 20 4H5.21L4.27 2H1ZM17 18C15.9 18 15.01 18.9 15.01 20C15.01 21.1 15.9 22 17 22C18.1 22 19 21.1 19 20C19 18.9 18.1 18 17 18Z"
|
|
@@ -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 vg(e,r){V(r,!0),B(e,hg);const t=k=>k==null||k==null||k==""?null:k,a=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_icon)}),n=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_icon_webp)}),o=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_wordmark)}),i=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_wordmark_webp)}),s=E(()=>d(a)?Ht(d(a)):null),l=E(()=>d(n)?Ht(d(n)):null),c=E(()=>d(o)?Ht(d(o)):null),u=E(()=>d(i)?Ht(d(i)):null),p=()=>{r.onClose&&r.onClose()};var _=bg(),g=x(_);{var m=k=>{var w=fg(),A=x(w);ug(A,{$$events:{click:p}}),b(k,w)};N(g,k=>{r.showCloseButton&&k(m)})}var f=O(g,2),v=x(f),h=x(v);{var y=k=>{mg(k,{get src(){return d(c)},get srcWebp(){return d(u)}})},P=k=>{var w=te(),A=Y(w);{var Z=G=>{lg(G,{get src(){return d(s)},get srcWebp(){return d(l)}})};N(A,G=>{d(s)!==null&&d(l)!==null&&G(Z)},!0)}b(k,w)};N(h,k=>{d(c)!==null?k(y):k(P,!1)})}var T=O(h,2);{var S=k=>{se(k,{size:"body-base",children:(w,A)=>{var Z=de();D(()=>{var G;return ne(Z,(G=r.brandingInfo)==null?void 0:G.app_name)}),b(w,Z)},$$slots:{default:!0}})};N(T,k=>{d(c)===null&&k(S)})}var z=O(f,2);{var W=k=>{var w=yg(),A=x(w);zi(A,{$$events:{click:p}}),b(k,w)};N(z,k=>{r.showCloseButton&&k(W)})}D(()=>kr(_,"rcb-with-close-button",r.showCloseButton)),b(e,_),H()}var kg=I("<!> <!> <!> <!>",1);function wg(e,r){V(r,!0);const t=R(r,"onClose",3,void 0);let a=J(U(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=>{F(a,U(o))};ag(e,{get brandingInfo(){return r.brandingInfo},get isInElement(){return r.isInElement},get isSandbox(){return r.isSandbox},get onClose(){return t()},navbarHeaderContent:l=>{var c=E(()=>!r.isInElement&&!!t());vg(l,{get brandingInfo(){return r.brandingInfo},get onClose(){return t()},get showCloseButton(){return d(c)}})},navbarBodyContent:l=>{var c=E(()=>{var u,p;return((p=(u=r.brandingInfo)==null?void 0:u.appearance)==null?void 0:p.show_product_description)??!1});I_(l,{get productDetails(){return r.productDetails},get purchaseOption(){return r.purchaseOptionToUse},get showProductDescription(){return d(c)},get priceBreakdown(){return d(a)}})},mainContent:l=>{var c=kg(),u=Y(c);{var p=y=>{t_(y)};N(u,y=>{r.currentPage==="payment-entry-loading"&&y(p)})}var _=O(u,2);{var g=y=>{kp(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 customerEmail(){return r.customerEmail},get defaultPriceBreakdown(){return r.defaultPriceBreakdown},get onContinue(){return r.onContinue},get onError(){return r.onError},onPriceBreakdownUpdated:n})};N(_,y=>{r.currentPage==="payment-entry"&&y(g)})}var m=O(_,2);{var f=y=>{var P=E(()=>{var S;return((S=r.brandingInfo)==null?void 0:S.support_email)??null}),T=E(()=>{var S;return((S=r.brandingInfo)==null?void 0:S.app_name)??null});e_(y,{get lastError(){return r.lastError},get productDetails(){return r.productDetails},get supportEmail(){return d(P)},get onDismiss(){return r.closeWithError},get appName(){return d(T)}})};N(m,y=>{r.currentPage==="error"&&y(f)})}var v=O(m,2);{var h=y=>{r_(y,{get onContinue(){return r.onContinue}})};N(v,y=>{r.currentPage==="success"&&y(h)})}b(l,c)},$$slots:{navbarHeaderContent:!0,navbarBodyContent:!0,mainContent:!0}}),H()}function xg(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 Pg(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 ve(Se.ConfigurationError,r)}}function Sg(e,r){V(r,!0);const t=R(r,"customTranslations",19,()=>({})),a=r.customerEmail?xg(r.customerEmail):null;let n=J(U(a?void 0:r.customerEmail)),o=r.rcPackage.webBillingProduct,i=J(null);const s=r.rcPackage.webBillingProduct.identifier??null;let l=J("payment-entry-loading"),c=J(null),u=J(null),p=J(U({})),_=new ya(t(),r.selectedLocale,r.defaultLocale);var g=Go(_);vo(He,g),Ve(()=>{r.isInElement||(document.documentElement.style.height="100%",document.body.style.height="100%",document.documentElement.style.overflow="hidden")}),Ft(()=>{r.isInElement||(document.documentElement.style.height="auto",document.body.style.height="auto",document.documentElement.style.overflow="auto")}),vo(bn,r.eventsTracker),Ve(async()=>{if(s===null){f(new ge(ue.ErrorSettingUpPurchase,"Product ID was not set before purchase."));return}r.purchaseOperationHelper.checkoutStart(r.appUserId,s,r.purchaseOption,r.rcPackage.webBillingProduct.presentedOfferingContext,d(n),r.metadata).then(P=>{F(i,null),F(l,"payment-entry"),F(p,U(P.gateway_params))}).catch(P=>{if(P.errorCode===ue.MissingEmailError)return F(n,void 0),r.purchaseOperationHelper.checkoutStart(r.appUserId,s,r.purchaseOption,r.rcPackage.webBillingProduct.presentedOfferingContext,d(n),r.metadata).then(T=>{F(i,null),F(l,"payment-entry"),F(p,U(T.gateway_params))}).catch(T=>{f(T)});f(P)})});const m=()=>{if(d(l)==="payment-entry"){r.purchaseOperationHelper.pollCurrentPurchaseForCompletion().then(P=>{F(l,"success"),F(c,U(P.redemptionInfo)),F(u,U(P.operationSessionId))}).catch(P=>{f(P)});return}if(d(l)==="success"||d(l)==="error"){r.onFinished(d(u),d(c));return}F(l,"success")},f=P=>{const T=_u({errorCode:P.getErrorCode().toString(),errorMessage:P.message});r.eventsTracker.trackSDKEvent(T),F(i,U(P)),F(l,"error")},v=()=>{r.onError(d(i)??new ge(ue.UnknownError,"Unknown error without state set."))};var h=E(()=>r.purchases.isSandbox()),y=E(()=>d(n)??null);wg(e,{get isSandbox(){return d(h)},get currentPage(){return d(l)},get brandingInfo(){return r.brandingInfo},productDetails:o,get purchaseOptionToUse(){return r.purchaseOption},get lastError(){return d(i)},get gatewayParams(){return d(p)},get purchaseOperationHelper(){return r.purchaseOperationHelper},get isInElement(){return r.isInElement},get customerEmail(){return d(y)},closeWithError:v,onContinue:m,onError:f,get onClose(){return r.onClose}}),H()}function Ai(e){return e==null?!0:new Date(e)>new Date}function Eg(e,r,t,a){const n=r.product_identifier;if(n in t)return Tg(e,r,t[n]);if(n in a)return Ig(e,r,a[n]);throw new ve(Se.CustomerInfoError,"Could not find entitlement product in subscriptions or non-subscriptions.")}function Tg(e,r,t){return{identifier:e,isActive:Ai(r.expires_date),willRenew:Fi(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:fr(r.expires_date),productIdentifier:r.product_identifier,productPlanIdentifier:r.product_plan_identifier??null,unsubscribeDetectedAt:fr(t==null?void 0:t.unsubscribe_detected_at),billingIssueDetectedAt:fr(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 Ig(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 qg(e,r,t){const a={},n={};for(const o in e){const i=Eg(o,e[o],r,t);a[o]=i,i.isActive&&(n[o]=i)}return{all:a,active:n}}function fr(e){return e==null?null:new Date(e)}function Dg(e){const r=Ag(e),t=e.subscriber,a=jg(t.non_subscriptions),n=Object.entries(e.subscriber.non_subscriptions).flatMap(([s,l])=>l.map(c=>({transactionIdentifier:c.id,productIdentifier:s,purchaseDate:new Date(c.purchase_date||c.original_purchase_date),storeTransactionId:c.store_transaction_id||null,store:c.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:fr(l.original_purchase_date),expiresDate:fr(l.expires_date),store:l.store,unsubscribeDetectedAt:fr(l.unsubscribe_detected_at),isSandbox:l.is_sandbox,billingIssuesDetectedAt:fr(l.billing_issues_detected_at),gracePeriodExpiresDate:fr(l.grace_period_expires_date),ownershipType:l.ownership_type??"UNKNOWN",periodType:l.period_type,refundedAt:fr(l.refunded_at),storeTransactionId:l.store_transaction_id||null,isActive:Ai(l.expires_date),willRenew:Fi(l.expires_date,l)}]));return{entitlements:qg(t.entitlements,t.subscriptions,a),allExpirationDatesByProduct:r,allPurchaseDatesByProduct:zg(e,a),activeSubscriptions:Fg(r),managementURL:t.management_url,requestDate:o,firstSeenDate:new Date(t.first_seen),originalPurchaseDate:fr(t.original_purchase_date),originalAppUserId:e.subscriber.original_app_user_id,nonSubscriptionTransactions:n,subscriptionsByProductIdentifier:i}}function Fi(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 zg(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 Ag(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 Fg(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 jg(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.4.0",Mg="https://api.revenuecat.com",Ng="https://e.revenue.cat";var za;(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"})(za||(za={}));function Aa(e){return e?e.startsWith("rcb_sb_"):!1}async function Sr(e,r,t){const{apiKey:a,body:n,headers:o,httpConfig:i}=r,l=`${(i==null?void 0:i.proxyURL)??Mg}${e.urlPath()}`;try{const c=await fetch(l,{method:e.method,headers:Vi(a,o,i==null?void 0:i.additionalHeaders),body:Og(n),signal:t});return await Cg(c,e),await c.json()}catch(c){throw c instanceof TypeError?new ve(Se.NetworkError,jt.getPublicMessage(Se.NetworkError),c.message):c}}async function Cg(e,r){const t=e.status;if(t>=za.INTERNAL_SERVER_ERROR)Sn(r,t,await e.text());else if(t>=za.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=jt.convertCodeToBackendErrorCode(o);if(s==null)Sn(r,t,n,o);else throw ve.getForBackendError(s,i)}else Sn(r,t,n)}}function Sn(e,r,t,a){throw new ve(Se.UnknownBackendError,"Unknown backend error.",`Request: ${e.name}. Status code: ${r}. Body: ${t}.`,{backendErrorCode:a})}function Og(e){return e==null?null:JSON.stringify(e)}const Mi="Authorization",Ni="Content-Type",Ci="Accept",Oi="X-Platform",Li="X-Version",Bi="X-Platform-Flavor",Ri="X-Platform-Flavor-Version",Ui="X-Is-Sandbox",Lg=new Set([Mi,Ni,Ci,Oi,Li,Ui,Bi,Ri]);function Vi(e,r,t){let a={[Mi]:`Bearer ${e}`,[Ni]:"application/json",[Ci]:"application/json",[Oi]:"web",[Li]:ji,[Ui]:`${Aa(e)}`};const n=Fa.getPlatformInfo();if(n){const o={[Bi]:n.flavor,[Ri]:n.version};a={...a,...o}}return r&&(a={...a,...r}),t&&(a={...t,...a}),a}const En="/v1/subscribers",_t="/rcbilling/v1";class Bg{constructor(r){j(this,"appUserId");j(this,"method","GET");j(this,"name","getOfferings");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${En}/${r}/offerings`}}class Rg{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?`¤cy=${this.currency}`:"";return`${_t}/subscribers/${r}/products?id=${t}${a}`}}class Ug{constructor(r){j(this,"method","GET");j(this,"name","getCustomerInfo");j(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${En}/${r}`}}class Vg{constructor(){j(this,"method","GET");j(this,"name","getBrandingInfo")}urlPath(){return`${_t}/branding`}}class Hg{constructor(){j(this,"method","POST");j(this,"name","postCheckoutStart")}urlPath(){return`${_t}/checkout/start`}}class Wg{constructor(r){j(this,"method","POST");j(this,"name","postCheckoutCalculateTax");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${_t}/checkout/${this.operationSessionId}/calculate_taxes`}}class Yg{constructor(r){j(this,"method","POST");j(this,"name","postCheckoutComplete");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${_t}/checkout/${this.operationSessionId}/complete`}}class Gg{constructor(r){j(this,"method","GET");j(this,"name","getCheckoutStatus");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${_t}/checkout/${this.operationSessionId}`}}class Xg{constructor(r){j(this,"method","POST");j(this,"name","setAttributes");j(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${En}/${r}/attributes`}}const Tn={};class Zg{constructor(r,t=Tn){j(this,"API_KEY");j(this,"httpConfig");j(this,"isSandbox");this.API_KEY=r,this.httpConfig=t,this.isSandbox=Aa(r)}getIsSandbox(){return this.isSandbox}async getOfferings(r){return await Sr(new Bg(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getCustomerInfo(r){return await Sr(new Ug(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getProducts(r,t,a){return await Sr(new Rg(r,t,a),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getBrandingInfo(){return await Sr(new Vg,{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 Sr(new Hg,{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 Sr(new Wg(r),{apiKey:this.API_KEY,body:o,httpConfig:this.httpConfig},n)}async postCheckoutComplete(r,t){const a={email:t};return await Sr(new Yg(r),{apiKey:this.API_KEY,body:a,httpConfig:this.httpConfig})}async getCheckoutStatus(r){return await Sr(new Gg(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 Sr(new Xg(r),{apiKey:this.API_KEY,body:o,httpConfig:this.httpConfig})}}function Kg(e){if(!/^rcb_[a-zA-Z0-9_.-]+$/.test(e))throw new ve(Se.InvalidCredentialsError,"Invalid API key. Use your Web Billing API key.")}function Hi(e){if(!e||new Set(["no_user","null","none","nil","(null)","NaN","\\x00","","unidentified","undefined","unknown"]).has(e)||e.includes("/"))throw new ve(Se.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 Jg(e){if(e!=null&&e.endsWith("/"))throw new ve(Se.ConfigurationError,"Invalid proxy URL. The proxy URL should not end with a trailing slash.")}function Qg(e){if(e){for(const r in e)if(Lg.has(r))throw new ve(Se.ConfigurationError,"Invalid additional headers. Some headers are reserved for internal use.")}}var In=(e=>(e.Current="current",e))(In||{});function $g(e,r){async function t(...a){return await this.preload(),await e.call(this,...a)}return t}const Wi=(e,r)=>{const t={...e.webBillingProduct,presentedOfferingContext:{...e.webBillingProduct.presentedOfferingContext,placementIdentifier:r}};return{...e,webBillingProduct:t,rcBillingProduct:t}},Zr=(e,r)=>e==null?null:Wi(e,r),em=(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,Wi(l,t)]));return{...o,packagesById:i,availablePackages:Object.values(i),weekly:Zr(o.weekly,t),monthly:Zr(o.monthly,t),twoMonth:Zr(o.twoMonth,t),threeMonth:Zr(o.threeMonth,t),sixMonth:Zr(o.sixMonth,t),annual:Zr(o.annual,t),lifetime:Zr(o.lifetime,t)}};function rm(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=Dp(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 tm=1000001;function am(e){return e.webBillingProduct.defaultPurchaseOption}function Yi(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 nm(e,r){return e.unit==="year"?r.translatePeriod(e.number*12,We.Month):r.translatePeriod(e.number,e.unit)}function om({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 im({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 Gi({price:e,period:r,full:t=!1,translator:a}){if(!r||!r.number||r.unit===We.Month&&r.number==1)return a.formatPrice(e.amountMicros,e.currency);let n="";switch(r.unit){case We.Year:n=a.formatPrice(e.amountMicros/12,e.currency);break;case We.Month:n=a.formatPrice(e.amountMicros/r.number,e.currency);break;case We.Week:n=a.formatPrice(e.amountMicros*4/r.number,e.currency);break;case We.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(We.Month,{noWhitespace:!0,short:!t})})}function sm(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]=lm(o,a,r),n),{})}function lm(e,r,t){const a=e.webBillingProduct,n=t.formatPrice(a.currentPrice.amountMicros,a.currentPrice.currency),o=am(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===Or.Subscription&&o){s.price_per_period=Yi(n,o,t),s.price_per_period_full=Yi(n,o,t,!0);const l=o.base.period;s.total_price_and_per_month=Gi({price:a.currentPrice,period:l,translator:t}),s.total_price_and_per_month_full=Gi({price:a.currentPrice,period:l,full:!0,translator:t}),s.sub_price_per_month=im({price:a.currentPrice,period:l,translator:t}),s.sub_price_per_week=om({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=nm(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 c=a.currentPrice.amountMicros,u=r.webBillingProduct.currentPrice.amountMicros,p=((u-c)*100/u).toFixed(0);s.sub_relative_discount=c===u?"":t.translate(L.PaywallVariablesSubRelativeDiscount,{discount:p})}return(i===Or.NonConsumable||i===Or.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 Ee=[];for(let e=0;e<256;++e)Ee.push((e+256).toString(16).slice(1));function cm(e,r=0){return(Ee[e[r+0]]+Ee[e[r+1]]+Ee[e[r+2]]+Ee[e[r+3]]+"-"+Ee[e[r+4]]+Ee[e[r+5]]+"-"+Ee[e[r+6]]+Ee[e[r+7]]+"-"+Ee[e[r+8]]+Ee[e[r+9]]+"-"+Ee[e[r+10]]+Ee[e[r+11]]+Ee[e[r+12]]+Ee[e[r+13]]+Ee[e[r+14]]+Ee[e[r+15]]).toLowerCase()}let qn;const dm=new Uint8Array(16);function um(){if(!qn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");qn=crypto.getRandomValues.bind(crypto)}return qn(dm)}const Xi={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Zi(e,r,t){var n;if(Xi.randomUUID&&!e)return Xi.randomUUID();e=e||{};const a=e.random??((n=e.rng)==null?void 0:n.call(e))??um();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,cm(a)}var pm=/(%?)(%([sdijo]))/g;function _m(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 Dn(e,...r){if(r.length===0)return e;let t=0,a=e.replace(pm,(n,o,i,s)=>{const l=r[t],c=_m(l,s);return o?n:(t++,c)});return t<r.length&&(a+=` ${r.slice(t).join(" ")}`),a=a.replace(/%{2,2}/g,"%"),a}var gm=2;function mm(e){if(!e.stack)return;const r=e.stack.split(`
|
|
337
|
+
}`};function vg(e,r){V(r,!0),B(e,hg);const t=k=>k==null||k==null||k==""?null:k,a=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_icon)}),n=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_icon_webp)}),o=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_wordmark)}),i=E(()=>{var k;return t((k=r.brandingInfo)==null?void 0:k.app_wordmark_webp)}),s=E(()=>d(a)?Ht(d(a)):null),l=E(()=>d(n)?Ht(d(n)):null),c=E(()=>d(o)?Ht(d(o)):null),u=E(()=>d(i)?Ht(d(i)):null),p=()=>{r.onClose&&r.onClose()};var _=bg(),g=x(_);{var m=k=>{var w=fg(),A=x(w);ug(A,{$$events:{click:p}}),b(k,w)};N(g,k=>{r.showCloseButton&&k(m)})}var f=O(g,2),v=x(f),h=x(v);{var y=k=>{mg(k,{get src(){return d(c)},get srcWebp(){return d(u)}})},P=k=>{var w=te(),A=Y(w);{var Z=G=>{lg(G,{get src(){return d(s)},get srcWebp(){return d(l)}})};N(A,G=>{d(s)!==null&&d(l)!==null&&G(Z)},!0)}b(k,w)};N(h,k=>{d(c)!==null?k(y):k(P,!1)})}var T=O(h,2);{var S=k=>{se(k,{size:"body-base",children:(w,A)=>{var Z=de();D(()=>{var G;return ne(Z,(G=r.brandingInfo)==null?void 0:G.app_name)}),b(w,Z)},$$slots:{default:!0}})};N(T,k=>{d(c)===null&&k(S)})}var z=O(f,2);{var W=k=>{var w=yg(),A=x(w);zi(A,{$$events:{click:p}}),b(k,w)};N(z,k=>{r.showCloseButton&&k(W)})}D(()=>kr(_,"rcb-with-close-button",r.showCloseButton)),b(e,_),H()}var kg=I("<!> <!> <!> <!>",1);function wg(e,r){V(r,!0);const t=R(r,"onClose",3,void 0);let a=J(U(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=>{F(a,U(o))};ag(e,{get brandingInfo(){return r.brandingInfo},get isInElement(){return r.isInElement},get isSandbox(){return r.isSandbox},get onClose(){return t()},navbarHeaderContent:l=>{var c=E(()=>!r.isInElement&&!!t());vg(l,{get brandingInfo(){return r.brandingInfo},get onClose(){return t()},get showCloseButton(){return d(c)}})},navbarBodyContent:l=>{var c=E(()=>{var u,p;return((p=(u=r.brandingInfo)==null?void 0:u.appearance)==null?void 0:p.show_product_description)??!1});I_(l,{get productDetails(){return r.productDetails},get purchaseOption(){return r.purchaseOptionToUse},get showProductDescription(){return d(c)},get priceBreakdown(){return d(a)}})},mainContent:l=>{var c=kg(),u=Y(c);{var p=y=>{t_(y)};N(u,y=>{r.currentPage==="payment-entry-loading"&&y(p)})}var _=O(u,2);{var g=y=>{kp(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 customerEmail(){return r.customerEmail},get defaultPriceBreakdown(){return r.defaultPriceBreakdown},get onContinue(){return r.onContinue},get onError(){return r.onError},onPriceBreakdownUpdated:n})};N(_,y=>{r.currentPage==="payment-entry"&&y(g)})}var m=O(_,2);{var f=y=>{var P=E(()=>{var S;return((S=r.brandingInfo)==null?void 0:S.support_email)??null}),T=E(()=>{var S;return((S=r.brandingInfo)==null?void 0:S.app_name)??null});e_(y,{get lastError(){return r.lastError},get productDetails(){return r.productDetails},get supportEmail(){return d(P)},get onDismiss(){return r.closeWithError},get appName(){return d(T)}})};N(m,y=>{r.currentPage==="error"&&y(f)})}var v=O(m,2);{var h=y=>{r_(y,{get onContinue(){return r.onContinue}})};N(v,y=>{r.currentPage==="success"&&y(h)})}b(l,c)},$$slots:{navbarHeaderContent:!0,navbarBodyContent:!0,mainContent:!0}}),H()}function xg(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 Pg(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 ve(Se.ConfigurationError,r)}}function Sg(e,r){V(r,!0);const t=R(r,"customTranslations",19,()=>({})),a=r.customerEmail?xg(r.customerEmail):null;let n=J(U(a?void 0:r.customerEmail)),o=r.rcPackage.webBillingProduct,i=J(null);const s=r.rcPackage.webBillingProduct.identifier??null;let l=J("payment-entry-loading"),c=J(null),u=J(null),p=J(U({})),_=new ya(t(),r.selectedLocale,r.defaultLocale);var g=Go(_);vo(He,g),Ve(()=>{r.isInElement||(document.documentElement.style.height="100%",document.body.style.height="100%",document.documentElement.style.overflow="hidden")}),Ft(()=>{r.isInElement||(document.documentElement.style.height="auto",document.body.style.height="auto",document.documentElement.style.overflow="auto")}),vo(bn,r.eventsTracker),Ve(async()=>{if(s===null){f(new ge(ue.ErrorSettingUpPurchase,"Product ID was not set before purchase."));return}r.purchaseOperationHelper.checkoutStart(r.appUserId,s,r.purchaseOption,r.rcPackage.webBillingProduct.presentedOfferingContext,d(n),r.metadata).then(P=>{F(i,null),F(l,"payment-entry"),F(p,U(P.gateway_params))}).catch(P=>{if(P.errorCode===ue.MissingEmailError)return F(n,void 0),r.purchaseOperationHelper.checkoutStart(r.appUserId,s,r.purchaseOption,r.rcPackage.webBillingProduct.presentedOfferingContext,d(n),r.metadata).then(T=>{F(i,null),F(l,"payment-entry"),F(p,U(T.gateway_params))}).catch(T=>{f(T)});f(P)})});const m=()=>{if(d(l)==="payment-entry"){r.purchaseOperationHelper.pollCurrentPurchaseForCompletion().then(P=>{F(l,"success"),F(c,U(P.redemptionInfo)),F(u,U(P.operationSessionId))}).catch(P=>{f(P)});return}if(d(l)==="success"||d(l)==="error"){r.onFinished(d(u),d(c));return}F(l,"success")},f=P=>{const T=_u({errorCode:P.getErrorCode().toString(),errorMessage:P.message});r.eventsTracker.trackSDKEvent(T),F(i,U(P)),F(l,"error")},v=()=>{r.onError(d(i)??new ge(ue.UnknownError,"Unknown error without state set."))};var h=E(()=>r.purchases.isSandbox()),y=E(()=>d(n)??null);wg(e,{get isSandbox(){return d(h)},get currentPage(){return d(l)},get brandingInfo(){return r.brandingInfo},productDetails:o,get purchaseOptionToUse(){return r.purchaseOption},get lastError(){return d(i)},get gatewayParams(){return d(p)},get purchaseOperationHelper(){return r.purchaseOperationHelper},get isInElement(){return r.isInElement},get customerEmail(){return d(y)},closeWithError:v,onContinue:m,onError:f,get onClose(){return r.onClose}}),H()}function Ai(e){return e==null?!0:new Date(e)>new Date}function Eg(e,r,t,a){const n=r.product_identifier;if(n in t)return Tg(e,r,t[n]);if(n in a)return Ig(e,r,a[n]);throw new ve(Se.CustomerInfoError,"Could not find entitlement product in subscriptions or non-subscriptions.")}function Tg(e,r,t){return{identifier:e,isActive:Ai(r.expires_date),willRenew:Fi(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:fr(r.expires_date),productIdentifier:r.product_identifier,productPlanIdentifier:r.product_plan_identifier??null,unsubscribeDetectedAt:fr(t==null?void 0:t.unsubscribe_detected_at),billingIssueDetectedAt:fr(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 Ig(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 qg(e,r,t){const a={},n={};for(const o in e){const i=Eg(o,e[o],r,t);a[o]=i,i.isActive&&(n[o]=i)}return{all:a,active:n}}function fr(e){return e==null?null:new Date(e)}function Dg(e){const r=Ag(e),t=e.subscriber,a=jg(t.non_subscriptions),n=Object.entries(e.subscriber.non_subscriptions).flatMap(([s,l])=>l.map(c=>({transactionIdentifier:c.id,productIdentifier:s,purchaseDate:new Date(c.purchase_date||c.original_purchase_date),storeTransactionId:c.store_transaction_id||null,store:c.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:fr(l.original_purchase_date),expiresDate:fr(l.expires_date),store:l.store,unsubscribeDetectedAt:fr(l.unsubscribe_detected_at),isSandbox:l.is_sandbox,billingIssuesDetectedAt:fr(l.billing_issues_detected_at),gracePeriodExpiresDate:fr(l.grace_period_expires_date),ownershipType:l.ownership_type??"UNKNOWN",periodType:l.period_type,refundedAt:fr(l.refunded_at),storeTransactionId:l.store_transaction_id||null,isActive:Ai(l.expires_date),willRenew:Fi(l.expires_date,l)}]));return{entitlements:qg(t.entitlements,t.subscriptions,a),allExpirationDatesByProduct:r,allPurchaseDatesByProduct:zg(e,a),activeSubscriptions:Fg(r),managementURL:t.management_url,requestDate:o,firstSeenDate:new Date(t.first_seen),originalPurchaseDate:fr(t.original_purchase_date),originalAppUserId:e.subscriber.original_app_user_id,nonSubscriptionTransactions:n,subscriptionsByProductIdentifier:i}}function Fi(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 zg(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 Ag(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 Fg(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 jg(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.4.1",Mg="https://api.revenuecat.com",Ng="https://e.revenue.cat";var za;(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"})(za||(za={}));function Aa(e){return e?e.startsWith("rcb_sb_"):!1}async function Sr(e,r,t){const{apiKey:a,body:n,headers:o,httpConfig:i}=r,l=`${(i==null?void 0:i.proxyURL)??Mg}${e.urlPath()}`;try{const c=await fetch(l,{method:e.method,headers:Vi(a,o,i==null?void 0:i.additionalHeaders),body:Og(n),signal:t});return await Cg(c,e),await c.json()}catch(c){throw c instanceof TypeError?new ve(Se.NetworkError,jt.getPublicMessage(Se.NetworkError),c.message):c}}async function Cg(e,r){const t=e.status;if(t>=za.INTERNAL_SERVER_ERROR)Sn(r,t,await e.text());else if(t>=za.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=jt.convertCodeToBackendErrorCode(o);if(s==null)Sn(r,t,n,o);else throw ve.getForBackendError(s,i)}else Sn(r,t,n)}}function Sn(e,r,t,a){throw new ve(Se.UnknownBackendError,"Unknown backend error.",`Request: ${e.name}. Status code: ${r}. Body: ${t}.`,{backendErrorCode:a})}function Og(e){return e==null?null:JSON.stringify(e)}const Mi="Authorization",Ni="Content-Type",Ci="Accept",Oi="X-Platform",Li="X-Version",Bi="X-Platform-Flavor",Ri="X-Platform-Flavor-Version",Ui="X-Is-Sandbox",Lg=new Set([Mi,Ni,Ci,Oi,Li,Ui,Bi,Ri]);function Vi(e,r,t){let a={[Mi]:`Bearer ${e}`,[Ni]:"application/json",[Ci]:"application/json",[Oi]:"web",[Li]:ji,[Ui]:`${Aa(e)}`};const n=Fa.getPlatformInfo();if(n){const o={[Bi]:n.flavor,[Ri]:n.version};a={...a,...o}}return r&&(a={...a,...r}),t&&(a={...t,...a}),a}const En="/v1/subscribers",_t="/rcbilling/v1";class Bg{constructor(r){j(this,"appUserId");j(this,"method","GET");j(this,"name","getOfferings");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${En}/${r}/offerings`}}class Rg{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?`¤cy=${this.currency}`:"";return`${_t}/subscribers/${r}/products?id=${t}${a}`}}class Ug{constructor(r){j(this,"method","GET");j(this,"name","getCustomerInfo");j(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${En}/${r}`}}class Vg{constructor(){j(this,"method","GET");j(this,"name","getBrandingInfo")}urlPath(){return`${_t}/branding`}}class Hg{constructor(){j(this,"method","POST");j(this,"name","postCheckoutStart")}urlPath(){return`${_t}/checkout/start`}}class Wg{constructor(r){j(this,"method","POST");j(this,"name","postCheckoutCalculateTax");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${_t}/checkout/${this.operationSessionId}/calculate_taxes`}}class Yg{constructor(r){j(this,"method","POST");j(this,"name","postCheckoutComplete");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${_t}/checkout/${this.operationSessionId}/complete`}}class Gg{constructor(r){j(this,"method","GET");j(this,"name","getCheckoutStatus");j(this,"operationSessionId");this.operationSessionId=r}urlPath(){return`${_t}/checkout/${this.operationSessionId}`}}class Xg{constructor(r){j(this,"method","POST");j(this,"name","setAttributes");j(this,"appUserId");this.appUserId=r}urlPath(){const r=encodeURIComponent(this.appUserId);return`${En}/${r}/attributes`}}const Tn={};class Zg{constructor(r,t=Tn){j(this,"API_KEY");j(this,"httpConfig");j(this,"isSandbox");this.API_KEY=r,this.httpConfig=t,this.isSandbox=Aa(r)}getIsSandbox(){return this.isSandbox}async getOfferings(r){return await Sr(new Bg(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getCustomerInfo(r){return await Sr(new Ug(r),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getProducts(r,t,a){return await Sr(new Rg(r,t,a),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getBrandingInfo(){return await Sr(new Vg,{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 Sr(new Hg,{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 Sr(new Wg(r),{apiKey:this.API_KEY,body:o,httpConfig:this.httpConfig},n)}async postCheckoutComplete(r,t){const a={email:t};return await Sr(new Yg(r),{apiKey:this.API_KEY,body:a,httpConfig:this.httpConfig})}async getCheckoutStatus(r){return await Sr(new Gg(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 Sr(new Xg(r),{apiKey:this.API_KEY,body:o,httpConfig:this.httpConfig})}}function Kg(e){if(!/^rcb_[a-zA-Z0-9_.-]+$/.test(e))throw new ve(Se.InvalidCredentialsError,"Invalid API key. Use your Web Billing API key.")}function Hi(e){if(!e||new Set(["no_user","null","none","nil","(null)","NaN","\\x00","","unidentified","undefined","unknown"]).has(e)||e.includes("/"))throw new ve(Se.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 Jg(e){if(e!=null&&e.endsWith("/"))throw new ve(Se.ConfigurationError,"Invalid proxy URL. The proxy URL should not end with a trailing slash.")}function Qg(e){if(e){for(const r in e)if(Lg.has(r))throw new ve(Se.ConfigurationError,"Invalid additional headers. Some headers are reserved for internal use.")}}var In=(e=>(e.Current="current",e))(In||{});function $g(e,r){async function t(...a){return await this.preload(),await e.call(this,...a)}return t}const Wi=(e,r)=>{const t={...e.webBillingProduct,presentedOfferingContext:{...e.webBillingProduct.presentedOfferingContext,placementIdentifier:r}};return{...e,webBillingProduct:t,rcBillingProduct:t}},Zr=(e,r)=>e==null?null:Wi(e,r),em=(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,Wi(l,t)]));return{...o,packagesById:i,availablePackages:Object.values(i),weekly:Zr(o.weekly,t),monthly:Zr(o.monthly,t),twoMonth:Zr(o.twoMonth,t),threeMonth:Zr(o.threeMonth,t),sixMonth:Zr(o.sixMonth,t),annual:Zr(o.annual,t),lifetime:Zr(o.lifetime,t)}};function rm(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=Dp(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 tm=1000001;function am(e){return e.webBillingProduct.defaultPurchaseOption}function Yi(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 nm(e,r){return e.unit==="year"?r.translatePeriod(e.number*12,We.Month):r.translatePeriod(e.number,e.unit)}function om({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 im({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 Gi({price:e,period:r,full:t=!1,translator:a}){if(!r||!r.number||r.unit===We.Month&&r.number==1)return a.formatPrice(e.amountMicros,e.currency);let n="";switch(r.unit){case We.Year:n=a.formatPrice(e.amountMicros/12,e.currency);break;case We.Month:n=a.formatPrice(e.amountMicros/r.number,e.currency);break;case We.Week:n=a.formatPrice(e.amountMicros*4/r.number,e.currency);break;case We.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(We.Month,{noWhitespace:!0,short:!t})})}function sm(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]=lm(o,a,r),n),{})}function lm(e,r,t){const a=e.webBillingProduct,n=t.formatPrice(a.currentPrice.amountMicros,a.currentPrice.currency),o=am(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===Or.Subscription&&o){s.price_per_period=Yi(n,o,t),s.price_per_period_full=Yi(n,o,t,!0);const l=o.base.period;s.total_price_and_per_month=Gi({price:a.currentPrice,period:l,translator:t}),s.total_price_and_per_month_full=Gi({price:a.currentPrice,period:l,full:!0,translator:t}),s.sub_price_per_month=im({price:a.currentPrice,period:l,translator:t}),s.sub_price_per_week=om({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=nm(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 c=a.currentPrice.amountMicros,u=r.webBillingProduct.currentPrice.amountMicros,p=((u-c)*100/u).toFixed(0);s.sub_relative_discount=c===u?"":t.translate(L.PaywallVariablesSubRelativeDiscount,{discount:p})}return(i===Or.NonConsumable||i===Or.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 Ee=[];for(let e=0;e<256;++e)Ee.push((e+256).toString(16).slice(1));function cm(e,r=0){return(Ee[e[r+0]]+Ee[e[r+1]]+Ee[e[r+2]]+Ee[e[r+3]]+"-"+Ee[e[r+4]]+Ee[e[r+5]]+"-"+Ee[e[r+6]]+Ee[e[r+7]]+"-"+Ee[e[r+8]]+Ee[e[r+9]]+"-"+Ee[e[r+10]]+Ee[e[r+11]]+Ee[e[r+12]]+Ee[e[r+13]]+Ee[e[r+14]]+Ee[e[r+15]]).toLowerCase()}let qn;const dm=new Uint8Array(16);function um(){if(!qn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");qn=crypto.getRandomValues.bind(crypto)}return qn(dm)}const Xi={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Zi(e,r,t){var n;if(Xi.randomUUID&&!e)return Xi.randomUUID();e=e||{};const a=e.random??((n=e.rng)==null?void 0:n.call(e))??um();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,cm(a)}var pm=/(%?)(%([sdijo]))/g;function _m(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 Dn(e,...r){if(r.length===0)return e;let t=0,a=e.replace(pm,(n,o,i,s)=>{const l=r[t],c=_m(l,s);return o?n:(t++,c)});return t<r.length&&(a+=` ${r.slice(t).join(" ")}`),a=a.replace(/%{2,2}/g,"%"),a}var gm=2;function mm(e){if(!e.stack)return;const r=e.stack.split(`
|
|
338
338
|
`);r.splice(1,gm),e.stack=r.join(`
|
|
339
339
|
`)}var fm=class extends Error{constructor(e,...r){super(e),this.message=e,this.name="Invariant Violation",this.message=Dn(e,...r),mm(this)}},Ki=(e,r,...t)=>{if(!e)throw new fm(r,...t)};Ki.as=(e,r,t,...a)=>{if(!r){const n=a.length===0?t:Dn(t,...a);let o;try{o=Reflect.construct(e,[n])}catch{o=e(n)}throw o}};const ym="[MSW]";function zn(e,...r){const t=Dn(e,...r);return`${ym} ${t}`}function bm(e,...r){console.warn(zn(e,...r))}function hm(e,...r){console.error(zn(e,...r))}const vm={formatMessage:zn,warn:bm,error:hm};function km(){Ki(typeof URL<"u",vm.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 Ji=(e=>(e.HEAD="HEAD",e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.OPTIONS="OPTIONS",e.DELETE="DELETE",e))(Ji||{});km();class wm{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 Qi(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]=Qi(n):r[a]=n}return r}class xm{constructor(r){j(this,"EVENT_TYPE","web_billing");j(this,"id");j(this,"timestampMs");j(this,"data");this.id=Zi(),this.timestampMs=Date.now(),this.data=r}toJSON(){return Qi({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 Pm(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 Sm=2e3,Em=5*6e4,Tm=.1;class Im{constructor(r){j(this,"apiKey");j(this,"eventsQueue",[]);j(this,"eventsUrl");j(this,"flushManager");j(this,"traceId",Zi());j(this,"appUserId");j(this,"isSilent");j(this,"rcSource");this.apiKey=r.apiKey,this.eventsUrl=`${Ng}/v1/events`,this.appUserId=r.appUserId,this.isSilent=r.silent||!1,this.rcSource=r.rcSource,this.flushManager=new wm(Sm,Em,Tm,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 xm({eventName:r.eventName,traceId:this.traceId,appUserId:this.appUserId,context:Pm(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:Ji.POST,headers:Vi(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 qm=()=>{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},An={autoCollectUTMAsMetadata:!0,collectAnalyticsEvents:!0};function Dm(){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 $i=(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))($i||{});const es="$RCAnonymousID:";rs=[$g];const Te=class Te{constructor(r,t,a=Tn,n=An){gs(Fn,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={...An,...n},Aa(r)&&Q.debugLog("Initializing Purchases SDK with sandbox API Key"),this.eventsTracker=new Im({apiKey:this._API_KEY,appUserId:this._appUserId,silent:!this._flags.collectAnalyticsEvents,rcSource:this._flags.rcSource??null}),this.backend=new Zg(this._API_KEY,a),this.purchaseOperationHelper=new Tl(this.backend,this.eventsTracker),this.eventsTracker.trackSDKEvent({eventName:Ge.SDKInitialized})}static setLogLevel(r){Q.setLogLevel(r)}static setPlatformInfo(r){Te._platformInfo=r}static getPlatformInfo(){return Te._platformInfo}static getSharedInstance(){if(Te.isConfigured())return Te.instance;throw new Ro}static isConfigured(){return Te.instance!==void 0}static configure(r,t,a=Tn,n=An){return Te.instance!==void 0&&Q.warnLog("Purchases is already initialized. You normally should only configure Purchases once. Creating and returning new instance."),Kg(r),Hi(t),Jg(a.proxyURL),Qg(a.additionalHeaders),Te.instance=new Te(r,t,a,n),Te.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 ve&&(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=`${tm}`,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 ya({},i,o.paywall_components.default_locale),l=g=>{var f;const m=o.availablePackages.find(v=>v.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)||dt})},c=g=>{var m;if(r.onNavigateToUrl){r.onNavigateToUrl(g);return}(m=window.open(g,"_blank"))==null||m.focus()},u=()=>{},p=()=>{if(r.onVisitCustomerCenter){r.onVisitCustomerCenter();return}},_=sm(o,s);return new Promise((g,m)=>{So(Qc,{target:n,props:{paywallData:o.paywall_components,selectedLocale:i,onNavigateToUrlClicked:c,onVisitCustomerCenterClicked:p,onBackClicked:()=>{if(r.onBack){r.onBack();return}n.innerHTML="",Q.debugLog("Purchase cancelled by user"),m(new ve(Se.UserCancelledError))},onRestorePurchasesClicked:u,onPurchaseClicked:f=>{l(f).then(v=>{g(v)}).catch(v=>m(v))},onError:f=>m(f),variablesPerPackage:_}})})}async getOfferings(r){Pg(r==null?void 0:r.currency);const t=this._appUserId,a=await this.backend.getOfferings(t),n=(r==null?void 0:r.offeringIdentifier)===In.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:em(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),rm(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 P;const{rcPackage:t,purchaseOption:a,htmlTarget:n,customerEmail:o,selectedLocale:i=dt,defaultLocale:s=dt}=r;let l=n??document.getElementById("rcb-ui-root");if(l===null){const T=document.createElement("div");T.className="rcb-ui-root",document.body.appendChild(T),l=T}if(l===null)throw new Error("Could not generate a mount point for the billing widget");const c=l,u=this._appUserId;Q.debugLog(`Presenting purchase form for package ${t.identifier}`);const p=i||s,_=a??t.webBillingProduct.defaultPurchaseOption,g=mu({appearance:(P=this._brandingInfo)==null?void 0:P.appearance,rcPackage:t,purchaseOptionToUse:_,customerEmail:o});this.eventsTracker.trackSDKEvent(g);const f={...this._flags.autoCollectUTMAsMetadata?qm():{},...r.metadata||{}};let v=null;const h=this._brandingInfo;h&&r.brandingAppearanceOverride&&(h.appearance=r.brandingAppearanceOverride);const y=n!==void 0;return new Promise((T,S)=>{y||window.history.pushState({checkoutOpen:!0},"");const z=this._flags.rcSource==="app"?void 0:()=>{const w=yu();this.eventsTracker.trackSDKEvent(w),window.removeEventListener("popstate",z),v&&on(v),c.innerHTML="",Q.debugLog("Purchase cancelled by user"),S(new ve(Se.UserCancelledError))};!y&&z&&window.addEventListener("popstate",z),v=So(Sg,{target:c,props:{isInElement:y,appUserId:u,rcPackage:t,purchaseOption:_,customerEmail:o,onFinished:async(w,A)=>{const Z=fu({redemptionInfo:A});this.eventsTracker.trackSDKEvent(Z),Q.debugLog("Purchase finished"),v&&on(v),c.innerHTML="";const G={customerInfo:await this._getCustomerInfoForUserId(u),redemptionInfo:A,operationSessionId:w};T(G)},onClose:z,onError:w=>{var Z;const A=bu({errorCode:(Z=w.errorCode)==null?void 0:Z.toString(),errorMessage:w.message});this.eventsTracker.trackSDKEvent(A),v&&on(v),c.innerHTML="",S(ve.getForPurchasesFlowError(w))},purchases:this,eventsTracker:this.eventsTracker,brandingInfo:this._brandingInfo,purchaseOperationHelper:this.purchaseOperationHelper,selectedLocale:p,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 Hi(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()}.
|