@revenuecat/purchases-js 1.67.0 → 1.67.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 +1 -1
- package/dist/Purchases.umd.js +1 -1
- package/package.json +1 -1
package/dist/Purchases.es.js
CHANGED
|
@@ -25398,7 +25398,7 @@ function lI(r) {
|
|
|
25398
25398
|
}
|
|
25399
25399
|
return e;
|
|
25400
25400
|
}
|
|
25401
|
-
const Tm = "1.67.
|
|
25401
|
+
const Tm = "1.67.1", dI = "https://api.revenuecat.com", uI = "https://e.revenue.cat";
|
|
25402
25402
|
var ps;
|
|
25403
25403
|
(function(r) {
|
|
25404
25404
|
r[r.CONTINUE = 100] = "CONTINUE", r[r.SWITCHING_PROTOCOLS = 101] = "SWITCHING_PROTOCOLS", r[r.PROCESSING = 102] = "PROCESSING", r[r.EARLY_HINTS = 103] = "EARLY_HINTS", r[r.OK = 200] = "OK", r[r.CREATED = 201] = "CREATED", r[r.ACCEPTED = 202] = "ACCEPTED", r[r.NON_AUTHORITATIVE_INFORMATION = 203] = "NON_AUTHORITATIVE_INFORMATION", r[r.NO_CONTENT = 204] = "NO_CONTENT", r[r.RESET_CONTENT = 205] = "RESET_CONTENT", r[r.PARTIAL_CONTENT = 206] = "PARTIAL_CONTENT", r[r.MULTI_STATUS = 207] = "MULTI_STATUS", r[r.MULTIPLE_CHOICES = 300] = "MULTIPLE_CHOICES", r[r.MOVED_PERMANENTLY = 301] = "MOVED_PERMANENTLY", r[r.MOVED_TEMPORARILY = 302] = "MOVED_TEMPORARILY", r[r.SEE_OTHER = 303] = "SEE_OTHER", r[r.NOT_MODIFIED = 304] = "NOT_MODIFIED", r[r.USE_PROXY = 305] = "USE_PROXY", r[r.TEMPORARY_REDIRECT = 307] = "TEMPORARY_REDIRECT", r[r.PERMANENT_REDIRECT = 308] = "PERMANENT_REDIRECT", r[r.BAD_REQUEST = 400] = "BAD_REQUEST", r[r.UNAUTHORIZED = 401] = "UNAUTHORIZED", r[r.PAYMENT_REQUIRED = 402] = "PAYMENT_REQUIRED", r[r.FORBIDDEN = 403] = "FORBIDDEN", r[r.NOT_FOUND = 404] = "NOT_FOUND", r[r.METHOD_NOT_ALLOWED = 405] = "METHOD_NOT_ALLOWED", r[r.NOT_ACCEPTABLE = 406] = "NOT_ACCEPTABLE", r[r.PROXY_AUTHENTICATION_REQUIRED = 407] = "PROXY_AUTHENTICATION_REQUIRED", r[r.REQUEST_TIMEOUT = 408] = "REQUEST_TIMEOUT", r[r.CONFLICT = 409] = "CONFLICT", r[r.GONE = 410] = "GONE", r[r.LENGTH_REQUIRED = 411] = "LENGTH_REQUIRED", r[r.PRECONDITION_FAILED = 412] = "PRECONDITION_FAILED", r[r.REQUEST_TOO_LONG = 413] = "REQUEST_TOO_LONG", r[r.REQUEST_URI_TOO_LONG = 414] = "REQUEST_URI_TOO_LONG", r[r.UNSUPPORTED_MEDIA_TYPE = 415] = "UNSUPPORTED_MEDIA_TYPE", r[r.REQUESTED_RANGE_NOT_SATISFIABLE = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE", r[r.EXPECTATION_FAILED = 417] = "EXPECTATION_FAILED", r[r.IM_A_TEAPOT = 418] = "IM_A_TEAPOT", r[r.INSUFFICIENT_SPACE_ON_RESOURCE = 419] = "INSUFFICIENT_SPACE_ON_RESOURCE", r[r.METHOD_FAILURE = 420] = "METHOD_FAILURE", r[r.MISDIRECTED_REQUEST = 421] = "MISDIRECTED_REQUEST", r[r.UNPROCESSABLE_ENTITY = 422] = "UNPROCESSABLE_ENTITY", r[r.LOCKED = 423] = "LOCKED", r[r.FAILED_DEPENDENCY = 424] = "FAILED_DEPENDENCY", r[r.UPGRADE_REQUIRED = 426] = "UPGRADE_REQUIRED", r[r.PRECONDITION_REQUIRED = 428] = "PRECONDITION_REQUIRED", r[r.TOO_MANY_REQUESTS = 429] = "TOO_MANY_REQUESTS", r[r.REQUEST_HEADER_FIELDS_TOO_LARGE = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE", r[r.UNAVAILABLE_FOR_LEGAL_REASONS = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS", r[r.INTERNAL_SERVER_ERROR = 500] = "INTERNAL_SERVER_ERROR", r[r.NOT_IMPLEMENTED = 501] = "NOT_IMPLEMENTED", r[r.BAD_GATEWAY = 502] = "BAD_GATEWAY", r[r.SERVICE_UNAVAILABLE = 503] = "SERVICE_UNAVAILABLE", r[r.GATEWAY_TIMEOUT = 504] = "GATEWAY_TIMEOUT", r[r.HTTP_VERSION_NOT_SUPPORTED = 505] = "HTTP_VERSION_NOT_SUPPORTED", r[r.INSUFFICIENT_STORAGE = 507] = "INSUFFICIENT_STORAGE", r[r.NETWORK_AUTHENTICATION_REQUIRED = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
package/dist/Purchases.umd.js
CHANGED
|
@@ -461,7 +461,7 @@ but received
|
|
|
461
461
|
|
|
462
462
|
/* 991px is the breakpoint for the mobile layout in Stripe Checkout */
|
|
463
463
|
@media (min-width: 991px) {.stripe-checkout-wrapper.svelte-zapbpj {justify-content:center;align-items:center;}
|
|
464
|
-
}`};function ZC(r,e){he(e,!0),Se(r,XC);const t=()=>Be(l,"$brandingAppearanceStore",o),n=()=>Be(p,"$translator",o),[o,i]=Je(),s=X(e,"onClose",3,void 0),c=X(e,"hideBackButton",3,!1),l=Ve(Vn),d=g(()=>t()??void 0),u=g(()=>new ca(a(d)).pageStyleVars),_=g(()=>Rg(a(d)).background),p=Ve(Pr);var m=xe(),f=ue(m);{var v=h=>{Zl(h,{get brandingInfo(){return e.brandingInfo},get isInElement(){return e.isInElement},get isSandbox(){return e.isSandbox},get onClose(){return s()},navbarHeaderContent:C=>{{let x=g(()=>!e.isInElement&&!!s()&&!c());om(C,{get brandingInfo(){return e.brandingInfo},get onClose(){return s()},get showCloseButton(){return a(x)}})}},navbarBodyContent:C=>{$g(C,{get startData(){return e.subscriptionChangeStartData},unusedTimeAdjustmentVariant:"credit",unresolvedTaxCalculationStatus:"disabled"})},mainContent:C=>{Kg(C,{get startData(){return e.subscriptionChangeStartData},get confirming(){return e.isConfirmingProductChange},get confirmError(){return e.productChangeConfirmError},get brandingAppearance(){return a(d)},get brandingInfo(){return e.brandingInfo},get purchaseOption(){return e.purchaseOptionToUse},get onConfirm(){return e.onConfirmProductChange}})},$$slots:{navbarHeaderContent:!0,navbarBodyContent:!0,mainContent:!0}})},y=h=>{fm(h,{get brandingInfo(){return e.brandingInfo},get isInElement(){return e.isInElement},get isSandbox(){return e.isSandbox},mainContent:k=>{var w=xe(),C=ue(w);{var x=T=>{var E=xe(),F=ue(E);{var M=L=>{var I=HC(),A=D(I);WC(A,{get stripeBillingParams(){return e.stripeBillingParams},get onContinue(){return e.onContinue},get onError(){return e.onError}}),W(()=>De(I,`${a(u)??""}; background-color: ${a(_)??""}`)),P(L,I)};K(F,L=>{e.stripeBillingParams&&L(M)})}P(T,E)},S=T=>{var E=xe(),F=ue(E);{var M=I=>{var A=KC(),U=D(A);ci(U,{gap:"medium",align:"center",children:(j,z)=>{var O=GC(),Z=ue(O);Ss(Z,{color:"var(--rc-color-grey-text-dark)"});var G=Y(Z,2);{var B=N=>{var R=YC(),J=ue(R);ze(J,{size:"heading-md",children:(ee,ce)=>{var ve=qe();W(Ee=>ge(ve,Ee),[()=>n().translate(oe.LoadingPageProcessingPayment)]),P(ee,ve)},$$slots:{default:!0}});var ie=Y(J,2);ze(ie,{size:"body-small",children:(ee,ce)=>{var ve=qe();W(Ee=>ge(ve,Ee),[()=>n().translate(oe.LoadingPageKeepPageOpen)]),P(ee,ve)},$$slots:{default:!0}}),P(N,R)};K(G,N=>{e.currentPage==="purchasing"&&N(B)})}P(j,O)},$$slots:{default:!0}}),P(I,A)},L=I=>{var A=xe(),U=ue(A);{var j=O=>{js(O,{get onContinue(){return e.onContinue},fullWidth:!0})},z=O=>{var Z=xe(),G=ue(Z);{var B=N=>{{let R=g(()=>{var ie;return((ie=e.brandingInfo)==null?void 0:ie.support_email)??null}),J=g(()=>{var ie;return((ie=e.brandingInfo)==null?void 0:ie.app_name)??null});Fs(N,{get lastError(){return e.lastError},get productDetails(){return e.productDetails},get supportEmail(){return a(R)},get onDismiss(){return e.closeWithError},get appName(){return a(J)},get isSandbox(){return e.isSandbox},fullWidth:!0})}};K(G,N=>{e.currentPage==="error"&&N(B)},!0)}P(O,Z)};K(U,O=>{e.currentPage==="success"?O(j):O(z,!1)},!0)}P(I,A)};K(F,I=>{e.currentPage==="loading"||e.currentPage==="purchasing"?I(M):I(L,!1)},!0)}P(T,E)};K(C,T=>{e.currentPage==="stripe-checkout"?T(x):T(S,!1)})}P(k,w)},$$slots:{mainContent:!0}})};K(f,h=>{e.currentPage==="upgrade-confirm"&&e.subscriptionChangeStartData?h(v):h(y,!1)})}P(r,m),ye(),i()}function QC(r,e){var L;he(e,!0);const t=X(e,"customTranslations",19,()=>({})),n=X(e,"skipSuccessPage",3,!1),o=X(e,"onClose",3,void 0),i=X(e,"productChange",3,void 0),s=X(e,"onProductChangeFinished",3,void 0),c=X(e,"hideBackButton",3,!1);let l=e.rcPackage.product,d=new Nn(t(),e.selectedLocale,e.defaultLocale),u=Er(d);wr(Pr,u),wr(li,e.eventsTracker);const _=Er(((L=e.brandingInfo)==null?void 0:L.appearance)??null);wr(Vn,_);let p=ae(null),m=g(()=>a(p)??e.isSandbox),f=ae(null),v=ae(null),y=ae("loading"),h=ae(null),b=ae(null),k=ae(!1),w=ae(null);const C=async()=>{var I;if(!(!i()||a(k))){q(k,!0),q(w,null);try{const A=await e.purchaseOperationHelper.completeProductChange({subscriberToken:i().subscriberToken});(I=s())==null||I(A)}catch(A){const U=A instanceof fe?A:new fe(we.ErrorChargingPayment,"Failed to confirm product change.",A instanceof Error?A.message:String(A));q(w,U.message,!0)}finally{q(k,!1)}}},x=()=>{if(a(y)==="stripe-checkout"){q(y,"purchasing"),e.purchaseOperationHelper.pollCurrentPurchaseForCompletion().then(I=>{q(f,I,!0),n()?e.onFinished(I):q(y,"success")}).catch(I=>{S(Ns(I,"Failed to complete purchase"))});return}a(y)==="success"&&a(f)&&e.onFinished(a(f))},S=I=>{q(v,I,!0),q(y,"error")},T=()=>{e.onError(a(v)??new fe(we.UnknownError,"Unknown error without state set."))};let E=null,F=null,M=null;Fr(async()=>{var j;e.isInElement||(E=document.documentElement.style.height,F=document.documentElement.style.overflow,M=document.body.style.height,document.documentElement.style.height="100%",document.body.style.height="100%",document.documentElement.style.overflow="hidden");const I=l.identifier;if(!I){S(new fe(we.ErrorSettingUpPurchase,"Product ID was not set before purchase."));return}let A=e.customerEmail;(A?im(A):null)&&(A=void 0);try{const z=await e.purchaseOperationHelper.checkoutStart({appUserId:e.appUserId,productId:I,purchaseOption:e.purchaseOption,presentedOfferingContext:e.rcPackage.product.presentedOfferingContext,customerEmail:A,externalPurchaseTokenId:e.externalPurchaseTokenId,metadata:e.metadata,workflowPurchaseContext:e.workflowPurchaseContext,attributionMetadata:e.attributionMetadata,paywallId:e.paywallId,paywallSessionId:e.paywallSessionId,locale:e.selectedLocale,...e.appearanceOverride?{appearanceOverride:e.appearanceOverride}:{},productChange:i()?{productIdentifier:i().productIdentifier,subscriptionId:i().subscriptionId}:void 0,subscriberToken:(j=i())==null?void 0:j.subscriberToken});if(Nc(z)){q(b,z,!0),q(y,"upgrade-confirm");return}if(!("stripe_billing_params"in z)||!z.stripe_billing_params){S(new fe(we.ErrorSettingUpPurchase,"Missing Stripe Checkout parameters"));return}q(p,z.stripe_billing_params.environment.toLowerCase()==="sandbox"),q(h,z.stripe_billing_params,!0),q(y,"stripe-checkout")}catch(z){S(Ns(z,"Failed to start Stripe Checkout"))}}),Tt(()=>{if(!e.isInElement){const I=(A,U,j)=>{j===""?A.style.removeProperty(U):A.style.setProperty(U,j)};I(document.documentElement,"height",E),I(document.body,"height",M),I(document.documentElement,"overflow",F)}}),ZC(r,{get currentPage(){return a(y)},get brandingInfo(){return e.brandingInfo},get productDetails(){return l},get isSandbox(){return a(m)},get lastError(){return a(v)},get isInElement(){return e.isInElement},get stripeBillingParams(){return a(h)},get purchaseOptionToUse(){return e.purchaseOption},get subscriptionChangeStartData(){return a(b)},get isConfirmingProductChange(){return a(k)},get productChangeConfirmError(){return a(w)},onConfirmProductChange:C,onContinue:x,onError:S,get onClose(){return o()},get hideBackButton(){return c()},closeWithError:T}),ye()}function vm(r){return r==null?!0:new Date(r)>new Date}function JC(r,e,t,n){const o=e.product_identifier;if(o in t)return $C(r,e,t[o]);if(o in n)return eI(r,e,n[o]);throw new Xe(Ne.CustomerInfoError,"Could not find entitlement product in subscriptions or non-subscriptions.")}function $C(r,e,t){return{identifier:r,isActive:vm(e.expires_date),willRenew:bm(e.expires_date,t),store:(t==null?void 0:t.store)??"unknown",latestPurchaseDate:new Date(e.purchase_date),originalPurchaseDate:new Date(e.purchase_date),expirationDate:Gt(e.expires_date),productIdentifier:e.product_identifier,productPlanIdentifier:e.product_plan_identifier??null,unsubscribeDetectedAt:Gt(t==null?void 0:t.unsubscribe_detected_at),billingIssueDetectedAt:Gt(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 eI(r,e,t){return{identifier:r,isActive:!0,willRenew:!1,store:t.store,latestPurchaseDate:new Date(e.purchase_date),originalPurchaseDate:new Date(t.original_purchase_date),expirationDate:null,productIdentifier:e.product_identifier,productPlanIdentifier:null,unsubscribeDetectedAt:null,billingIssueDetectedAt:null,isSandbox:t.is_sandbox,periodType:"normal",ownershipType:"UNKNOWN"}}function rI(r,e,t){const n={},o={};for(const i in r){const s=JC(i,r[i],e,t);n[i]=s,s.isActive&&(o[i]=s)}return{all:n,active:o}}function Gt(r){return r==null?null:new Date(r)}function tI(r){if(!r)return null;const e=r.amount*1e6;return{amount:r.amount*100,amountMicros:e,currency:r.currency,formattedPrice:On(e,r.currency)}}function rd(r){const e=aI(r),t=r.subscriber,n=iI(t.non_subscriptions),o=Object.entries(r.subscriber.non_subscriptions).flatMap(([c,l])=>l.map(d=>({transactionIdentifier:d.id,productIdentifier:c,purchaseDate:new Date(d.purchase_date||d.original_purchase_date),storeTransactionId:d.store_transaction_id||null,store:d.store}))),i=new Date(r.request_date),s=Object.fromEntries(Object.entries(r.subscriber.subscriptions).map(([c,l])=>[c,{productIdentifier:c,productPlanIdentifier:l.product_plan_identifier??null,purchaseDate:new Date(l.purchase_date),originalPurchaseDate:Gt(l.original_purchase_date),expiresDate:Gt(l.expires_date),store:l.store,unsubscribeDetectedAt:Gt(l.unsubscribe_detected_at),isSandbox:l.is_sandbox,billingIssuesDetectedAt:Gt(l.billing_issues_detected_at),gracePeriodExpiresDate:Gt(l.grace_period_expires_date),ownershipType:l.ownership_type??"UNKNOWN",periodType:l.period_type,refundedAt:Gt(l.refunded_at),storeTransactionId:l.store_transaction_id||null,managementURL:l.management_url??null,isActive:vm(l.expires_date),willRenew:bm(l.expires_date,l),displayName:l.display_name??null,autoResumeDate:Gt(l.auto_resume_date),price:tI(l.price)}]));return{entitlements:rI(t.entitlements,t.subscriptions,n),allExpirationDatesByProduct:e,allPurchaseDatesByProduct:nI(r,n),activeSubscriptions:oI(e),managementURL:t.management_url,requestDate:i,firstSeenDate:new Date(t.first_seen),originalPurchaseDate:Gt(t.original_purchase_date),originalAppUserId:r.subscriber.original_app_user_id,nonSubscriptionTransactions:o,subscriptionsByProductIdentifier:s}}function bm(r,e){if(e==null)return!1;const t=e.store=="promotional",n=r==null,o=e.unsubscribe_detected_at!=null,i=e.billing_issues_detected_at!=null;return!(t||n||o||i)}function nI(r,e){const t={};for(const n in r.subscriber.subscriptions){const o=r.subscriber.subscriptions[n];t[n]=new Date(o.purchase_date)}for(const n in e){const o=e[n].purchase_date;o==null?t[n]=null:t[n]=new Date(o)}return t}function aI(r){const e={};for(const t in r.subscriber.subscriptions){const n=r.subscriber.subscriptions[t];n.expires_date==null?e[t]=null:e[t]=new Date(n.expires_date)}return e}function oI(r){const e=new Set,t=new Date;for(const n in r){const o=r[n];(o==null||o>t)&&e.add(n)}return e}function iI(r){const e={};for(const t in r){if(r[t].length===0)continue;const n=r[t].length;e[t]=r[t][n-1]}return e}const km="1.67.0",sI="https://api.revenuecat.com",cI="https://e.revenue.cat";var Bs;(function(r){r[r.CONTINUE=100]="CONTINUE",r[r.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",r[r.PROCESSING=102]="PROCESSING",r[r.EARLY_HINTS=103]="EARLY_HINTS",r[r.OK=200]="OK",r[r.CREATED=201]="CREATED",r[r.ACCEPTED=202]="ACCEPTED",r[r.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",r[r.NO_CONTENT=204]="NO_CONTENT",r[r.RESET_CONTENT=205]="RESET_CONTENT",r[r.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",r[r.MULTI_STATUS=207]="MULTI_STATUS",r[r.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",r[r.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",r[r.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",r[r.SEE_OTHER=303]="SEE_OTHER",r[r.NOT_MODIFIED=304]="NOT_MODIFIED",r[r.USE_PROXY=305]="USE_PROXY",r[r.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",r[r.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",r[r.BAD_REQUEST=400]="BAD_REQUEST",r[r.UNAUTHORIZED=401]="UNAUTHORIZED",r[r.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",r[r.FORBIDDEN=403]="FORBIDDEN",r[r.NOT_FOUND=404]="NOT_FOUND",r[r.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",r[r.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",r[r.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",r[r.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",r[r.CONFLICT=409]="CONFLICT",r[r.GONE=410]="GONE",r[r.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",r[r.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",r[r.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",r[r.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",r[r.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",r[r.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",r[r.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",r[r.IM_A_TEAPOT=418]="IM_A_TEAPOT",r[r.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",r[r.METHOD_FAILURE=420]="METHOD_FAILURE",r[r.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",r[r.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",r[r.LOCKED=423]="LOCKED",r[r.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",r[r.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",r[r.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",r[r.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",r[r.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",r[r.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",r[r.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",r[r.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",r[r.BAD_GATEWAY=502]="BAD_GATEWAY",r[r.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",r[r.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",r[r.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",r[r.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",r[r.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(Bs||(Bs={}));const lI=/^rcb_[a-zA-Z0-9_.-]+$/,dI=/^pdl_[a-zA-Z0-9_.-]+$/,uI=/^test_[a-zA-Z0-9_.-]+$/,pI=/^strp_[a-zA-Z0-9_.-]+$/,_I=/^amzn_[a-zA-Z0-9_.-]+$/;function Rs(r){return r?r.startsWith("rcb_sb_"):!1}function hi(r){return r?lI.test(r):!1}function Us(r){return r?dI.test(r):!1}function mo(r){return r?pI.test(r):!1}function Wn(r){return r?_I.test(r):!1}function gI(r){return r?r.startsWith("strp_sb_"):!1}function Hn(r){return r?uI.test(r):!1}async function kt(r,e,t){return(await wm(r,e,t)).data}async function wm(r,e,t){const{apiKey:n,body:o,headers:i,httpConfig:s}=e,l=`${(s==null?void 0:s.proxyURL)??sI}${r.urlPath()}`;try{const d=await fetch(l,{method:r.method,headers:Am(n,i,s==null?void 0:s.additionalHeaders),body:fI(o),signal:t});await mI(d,r);const u=d.status;return{data:await d.json(),statusCode:u}}catch(d){throw d instanceof TypeError?new Xe(Ne.NetworkError,ro.getPublicMessage(Ne.NetworkError),d.message):d}}async function mI(r,e){const t=r.status;if(t>=Bs.INTERNAL_SERVER_ERROR)td(e,t,await r.text());else if(t>=Bs.BAD_REQUEST){const n=await r.json(),o=n?JSON.stringify(n):null,i=n==null?void 0:n.code,s=n==null?void 0:n.message;if(i!=null){const c=ro.convertCodeToBackendErrorCode(i);if(c==null)td(e,t,o,i);else throw Xe.getForBackendError(c,s)}else td(e,t,o)}}function td(r,e,t,n){throw new Xe(Ne.UnknownBackendError,"Unknown backend error.",`Request: ${r.name}. Status code: ${e}. Body: ${t}.`,{statusCode:e,backendErrorCode:n})}function fI(r){return r==null?null:JSON.stringify(r)}const Pm="Authorization",xm="Content-Type",Sm="Accept",Em="X-Platform",Cm="X-Version",Im="X-Platform-Flavor",Tm="X-Platform-Flavor-Version",nd="X-Is-Sandbox",hI="X-RC-Subscriber-Token",yI=new Set([Pm,xm,Sm,Em,Cm,nd,Im,Tm,hI]);function Am(r,e,t){const n=Wn(r);let o={[Pm]:`Bearer ${r}`,[xm]:"application/json",[Sm]:"application/json",[Em]:n?"amazon":"web",[Cm]:km,...!n&&{[nd]:`${Rs(r)||Hn(r)}`}};const i=Ws.getPlatformInfo();if(i){const s={[Im]:i.flavor,[Tm]:i.version};o={...o,...s}}return e&&(o={...o,...e}),t&&(o={...t,...o}),n&&delete o[nd],o}const qa="/v1/subscribers",Ma="/rcbilling/v1";class vI{constructor(e){re(this,"appUserId");re(this,"method","GET");re(this,"name","getOfferings");this.appUserId=e}urlPath(){const e=encodeURIComponent(this.appUserId);return`${qa}/${e}/offerings`}}class Dm{constructor(e,t,n,o){re(this,"method","GET");re(this,"name","getProducts");re(this,"appUserId");re(this,"productIds");re(this,"currency");re(this,"discountCode");this.appUserId=e,this.productIds=t,this.currency=n,this.discountCode=o}urlPath(){const e=encodeURIComponent(this.appUserId),t=this.productIds.map(encodeURIComponent).join("&id="),n=this.currency?`¤cy=${this.currency}`:"",o=this.discountCode?`&discount_code=${encodeURIComponent(this.discountCode)}`:"";return`${Ma}/subscribers/${e}/products?id=${t}${n}${o}`}}class bI{constructor(e){re(this,"method","GET");re(this,"name","getCustomerInfo");re(this,"appUserId");this.appUserId=e}urlPath(){const e=encodeURIComponent(this.appUserId);return`${qa}/${e}`}}class kI{constructor(){re(this,"method","POST");re(this,"name","identify")}urlPath(){return`${qa}/identify`}}class wI{constructor(){re(this,"method","GET");re(this,"name","getBrandingInfo")}urlPath(){return`${Ma}/branding`}}class PI{constructor(){re(this,"method","POST");re(this,"name","postCheckoutPrepare")}urlPath(){return`${Ma}/checkout/prepare`}}class xI{constructor(){re(this,"method","POST");re(this,"name","postCheckoutStart")}urlPath(){return`${Ma}/checkout/start`}}class SI{constructor(e){re(this,"method","PATCH");re(this,"name","patchCheckoutRefreshPricing");re(this,"operationSessionId");this.operationSessionId=e}urlPath(){return`${Ma}/checkout/${this.operationSessionId}`}}class EI{constructor(e){re(this,"method","POST");re(this,"name","postCheckoutComplete");re(this,"operationSessionId");this.operationSessionId=e}urlPath(){return`${Ma}/checkout/${this.operationSessionId}/complete`}}class CI{constructor(e){re(this,"method","GET");re(this,"name","getCheckoutStatus");re(this,"operationSessionId");this.operationSessionId=e}urlPath(){return`${Ma}/checkout/${this.operationSessionId}`}}class II{constructor(e){re(this,"method","POST");re(this,"name","setAttributes");re(this,"appUserId");this.appUserId=e}urlPath(){const e=encodeURIComponent(this.appUserId);return`${qa}/${e}/attributes`}}class TI{constructor(){re(this,"method","POST");re(this,"name","postReceipt")}urlPath(){return"/v1/receipts"}}class AI{constructor(e){re(this,"method","GET");re(this,"name","getVirtualCurrencies");re(this,"appUserId");this.appUserId=e}urlPath(){const e=encodeURIComponent(this.appUserId);return`${qa}/${e}/virtual_currencies`}}class DI{constructor(e){re(this,"method","GET");re(this,"name","getWorkflows");re(this,"appUserId");this.appUserId=e}urlPath(){return`${qa}/${encodeURIComponent(this.appUserId)}/workflows?type=paywall`}}class zI{constructor(e,t){re(this,"method","GET");re(this,"name","getWorkflowData");re(this,"appUserId");re(this,"workflowId");this.appUserId=e,this.workflowId=t}urlPath(){return`${qa}/${encodeURIComponent(this.appUserId)}/workflows/${encodeURIComponent(this.workflowId)}`}}const ad={},qI=2e3;class MI{constructor(e,t=ad,n){re(this,"API_KEY");re(this,"httpConfig");re(this,"isSandbox");re(this,"purchasesContext");this.API_KEY=e,this.httpConfig=t,this.isSandbox=Rs(e),this.purchasesContext=n}getIsSandbox(){return this.isSandbox}async getOfferings(e){return await kt(new vI(e),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getCustomerInfo(e){return await kt(new bI(e),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async identify(e,t){const n={app_user_id:e,new_app_user_id:t},o=await wm(new kI,{apiKey:this.API_KEY,body:n,httpConfig:this.httpConfig}),i=o.statusCode===201;return{...o.data,was_created:i}}async getProducts(e,t,n,o){const i=Array.from(new Set(t)),s=this.batchProductIdsByUrlLength(e,i,n,o),c=[];for(const l of s){const d=await kt(new Dm(e,l,n,o),{apiKey:this.API_KEY,httpConfig:this.httpConfig});c.push(...d.product_details)}return{product_details:c}}batchProductIdsByUrlLength(e,t,n,o){const i=[];let s=[];for(const c of t){const l=[...s,c],d=new Dm(e,l,n,o).urlPath().length;s.length>0&&d>qI?(i.push(s),s=[c]):s=l}return s.length>0&&i.push(s),i}async getBrandingInfo(){return await kt(new wI,{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async postCheckoutPrepare(e,t){const n={product_id:e,price_id:t.priceId};return t.id!=="base_option"&&(n.offer_id=t.id),await kt(new PI,{apiKey:this.API_KEY,body:n,httpConfig:this.httpConfig})}async postCheckoutStart({appUserId:e,productId:t,purchaseOption:n,presentedOfferingContext:o,traceId:i,presentedStepId:s,urlParameters:c,paywallId:l,paywallSessionId:d,customerEmail:u,externalPurchaseTokenId:_,metadata:p,locale:m,attributionMetadata:f,appearanceOverride:v,productChange:y,subscriberToken:h,purchaseFlow:b}){var w,C;const k={app_user_id:e,product_id:t,email:u,price_id:n.priceId,presented_offering_identifier:o.offeringIdentifier,trace_id:i};return p&&(k.metadata=p),_&&(k.external_purchase_token_id=_),n.id!=="base_option"&&(k.offer_id=n.id),o.targetingContext&&(k.applied_targeting_rule={rule_id:o.targetingContext.ruleId,revision:o.targetingContext.revision}),o.placementIdentifier&&(k.presented_placement_identifier=o.placementIdentifier),(C=(w=this.purchasesContext)==null?void 0:w.workflowContext)!=null&&C.workflowIdentifier&&(k.presented_workflow_id=this.purchasesContext.workflowContext.workflowIdentifier),s&&(k.presented_step_id=s),c&&Object.keys(c).length>0&&(k.url_parameters=c),l&&(k.paywall={paywall_id:l,...d?{paywall_session_id:d}:{}}),m&&(k.locale=m),f&&(k.attribution_metadata=f),v&&(k.appearance_override=v),y&&(k.product_change={...y.subscriptionId?{subscription_id:y.subscriptionId}:{},...y.productIdentifier?{from_product_id:y.productIdentifier}:{}}),b&&(k.purchase_flow=b),await kt(new xI,{apiKey:this.API_KEY,body:k,headers:h?{"X-RC-Subscriber-Token":h}:void 0,httpConfig:this.httpConfig})}async patchCheckoutRefreshPricing(e,{countryCode:t,postalCode:n,state:o,city:i,addressLine1:s,addressLine2:c,discountCode:l,signal:d}={}){const u={country_code:t,postal_code:n,state:o,city:i,address_line1:s,address_line2:c,discount_code:l};return await kt(new SI(e),{apiKey:this.API_KEY,body:u,httpConfig:this.httpConfig},d)}async postCheckoutComplete(e,t={}){const n={};return t.email&&(n.email=t.email),t.locale&&(n.locale=t.locale),t.billingName&&(n.billing_name=t.billingName),t.billingAddress&&(n.billing_address={country_code:t.billingAddress.countryCode,postal_code:t.billingAddress.postalCode,state:t.billingAddress.state,city:t.billingAddress.city,address_line1:t.billingAddress.addressLine1,address_line2:t.billingAddress.addressLine2}),await kt(new EI(e),{apiKey:this.API_KEY,body:n,headers:t.subscriberToken?{"X-RC-Subscriber-Token":t.subscriberToken}:void 0,httpConfig:this.httpConfig})}async getCheckoutStatus(e){return await kt(new CI(e),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async setAttributes(e,t){const n=Date.now(),o={};for(const[s,c]of Object.entries(t))o[s]={value:c,updated_at_ms:n};const i={attributes:o};return await kt(new II(e),{apiKey:this.API_KEY,body:i,httpConfig:this.httpConfig})}async postReceipt(e,t,n,o,i,s,c,l,d,u){var m,f;let _=null;i!=null&&i.targetingContext&&(_={rule_id:i.targetingContext.ruleId,revision:i.targetingContext.revision});const p={fetch_token:o,product_id:t,currency:n,app_user_id:e,presented_offering_identifier:(i==null?void 0:i.offeringIdentifier)??null,presented_placement_identifier:(i==null?void 0:i.placementIdentifier)??null,presented_workflow_id:(f=(m=this.purchasesContext)==null?void 0:m.workflowContext)==null?void 0:f.workflowIdentifier,applied_targeting_rule:_,initiation_source:s,store_user_id:l,is_restore:d,price:u??null};return c&&(p.paywall={paywall_id:c}),await kt(new TI,{apiKey:this.API_KEY,body:p,httpConfig:this.httpConfig})}async getVirtualCurrencies(e){return await kt(new AI(e),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getWorkflows(e){return await kt(new DI(e),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getWorkflowById(e,t){const n=await kt(new zI(e,t),{apiKey:this.API_KEY,httpConfig:this.httpConfig});if(!("action"in n))return n;if(n.action==="inline")return n.data;if(n.action!=="use_cdn")throw new Error(`Unexpected workflow action: ${n.action}`);const o=await fetch(n.url);if(!o.ok)throw new Error(`Failed to fetch workflow from CDN: ${o.statusText}`);return await o.json()}}var zm=(r=>(r.PURCHASE="purchase",r.RESTORE="restore",r.UNSYNCED_ACTIVE_PURCHASES="unsynced_active_purchases",r))(zm||{});function FI(r){if(!(hi(r)||Hn(r)||Us(r)||mo(r)||Wn(r)))throw new Xe(Ne.InvalidCredentialsError,"Invalid API key. Use a valid API key obtained from the RevenueCat Dashboard.")}function od(r){if(!r||new Set(["no_user","null","none","nil","(null)","NaN","\\x00","","unidentified","undefined","unknown"]).has(r)||r.includes("/"))throw new Xe(Ne.InvalidAppUserIdError,'Provided user id: "'+(r??"[Not provided]")+'" is not valid. See https://www.revenuecat.com/docs/customers/user-ids#tips-for-setting-app-user-ids for more information.')}function jI(r){if(r!=null&&r.endsWith("/"))throw new Xe(Ne.ConfigurationError,"Invalid proxy URL. The proxy URL should not end with a trailing slash.")}function OI(r){if(r){for(const e in r)if(yI.has(e))throw new Xe(Ne.ConfigurationError,"Invalid additional headers. Some headers are reserved for internal use.")}}var Vs=(r=>(r.Current="current",r))(Vs||{});function id(r,e){async function t(...n){return await this.preload(),await r.call(this,...n)}return t}const NI=(r,e)=>{const t={...r.product,presentedOfferingContext:{...r.product.presentedOfferingContext,placementIdentifier:e}};return{...r,webBillingProduct:t,rcBillingProduct:t,product:t}},LI=(r,e)=>{const t=sd(e);return Mm(r,n=>{const o=t[n.product.identifier];if(o===void 0)return n;const i=up(o,n.product.presentedOfferingContext);return i===null?n:{...n,rcBillingProduct:i,webBillingProduct:i,product:i}})},BI=(r,e)=>{const t=r.offering_ids_by_placement??{};if(e in t){const n=t[e]??null;return{offeringIdForPlacement:n,fallbackOfferingId:n===null?null:r.fallback_offering_id}}return{offeringIdForPlacement:null,fallbackOfferingId:r.fallback_offering_id}},qm=(r,e)=>Mm(e,t=>NI(t,r)),Mm=(r,e)=>{const t=r.availablePackages.map(e),n=Object.fromEntries(t.map(i=>[i.identifier,i])),o=i=>i===null?null:n[i.identifier]??null;return{...r,packagesById:n,availablePackages:t,weekly:o(r.weekly),monthly:o(r.monthly),twoMonth:o(r.twoMonth),threeMonth:o(r.threeMonth),sixMonth:o(r.sixMonth),annual:o(r.annual),lifetime:o(r.lifetime)}};function sd(r){const e={};return r.product_details.forEach(t=>{e[t.identifier]=t}),e}function RI(r,e,t){const n=e.offerings.find(s=>s.identifier===r);if(!n)return null;const o=sd(t),i=n.identifier===e.current_offering_id;return pp(i,n,o,e.targeting,e.ui_config)}function UI(r,e){const t=sd(e),n={};r.offerings.forEach(i=>{const s=i.identifier===r.current_offering_id,c=pp(s,i,t,r.targeting,r.ui_config);c!=null&&(n[i.identifier]=c)});const o=r.current_offering_id?n[r.current_offering_id]??null:null;return Object.keys(n).length==0&&pe.debugLog("Empty offerings. Please make sure you've configured offerings correctly in the RevenueCat dashboard and that the products are properly configured."),{all:n,current:o}}const VI=1000001;function Fm(r,e={}){var o;if(e.translator)return Nm(r,e.translator);const t=((o=r.paywallComponents)==null?void 0:o.default_locale)||Br,n=new Nn(e.customTranslations??{},e.selectedLocale??t,e.fallbackLocale??t);return Nm(r,n)}function yi(r){var o;const e=r.product.price,t=jm(r),n=r.product.period||((o=t==null?void 0:t.base)==null?void 0:o.period);return!n||!n.number||n.number<=0?e.amountMicros:e.amountMicros*Vc(n).perMonth}function jm(r){return r.product.productType===Rr.Subscription?r.product.defaultSubscriptionOption:r.product.productType===Rr.NonConsumable||r.product.productType===Rr.Consumable?r.product.defaultNonSubscriptionOption:r.product.defaultPurchaseOption}function WI(r,e){return r===Rr.Subscription&&e!=null}function HI(r,e){return r!==Rr.Subscription&&e!=null}function Om(r,e,t,n=!1){return t.translate(oe.PaywallVariablesPricePerPeriod,{formattedPrice:r,period:e.base.period?e.base.period.number===1?t.translatePeriodUnit(e.base.period.unit,{noWhitespace:!0,short:!n}):t.translatePeriod(e.base.period.number,e.base.period.unit,{noWhitespace:!0,short:!n}):""})}function Nm(r,e){const t=r.availablePackages,n=t.filter(i=>i.product.productType===Rr.Subscription),o=n.length>0?n.reduce((i,s)=>{const c=yi(i),l=yi(s);return c>l?i:s}):null;return t.reduce((i,s)=>(i[s.identifier]=YI(s,o,e),i),{})}function YI(r,e,t){const n=r.product,o=n.price,i=t.formatPrice(o.amountMicros,o.currency),s=jm(r),c=n.productType,l={"product.store_product_name":n.title,"product.price":i,"product.price_per_period":"","product.price_per_period_abbreviated":"","product.price_per_day":"","product.price_per_week":"","product.price_per_month":"","product.price_per_year":"","product.period":"","product.period_abbreviated":"","product.periodly":"","product.period_in_days":"","product.period_in_weeks":"","product.period_in_months":"","product.period_in_years":"","product.period_with_unit":"","product.currency_code":o.currency,"product.currency_symbol":t.formatPrice(0,o.currency).replace("0",""),"product.offer_price":"","product.offer_price_per_day":"","product.offer_price_per_week":"","product.offer_price_per_month":"","product.offer_price_per_year":"","product.offer_price_with_zero":"","product.offer_price_with_zero_per_day":"","product.offer_price_with_zero_per_week":"","product.offer_price_with_zero_per_month":"","product.offer_price_with_zero_per_year":"","product.offer_period":"","product.offer_period_abbreviated":"","product.offer_period_in_days":"","product.offer_period_in_weeks":"","product.offer_period_in_months":"","product.offer_period_in_years":"","product.offer_period_with_unit":"","product.offer_end_date":"","product.secondary_offer_price":"","product.secondary_offer_period":"","product.secondary_offer_period_abbreviated":"","product.relative_discount":""};if(WI(c,s)){l["product.price_per_period_abbreviated"]=Om(i,s,t),l["product.price_per_period"]=Om(i,s,t,!0);const d=n.period||s.base.period,u=hm(o,d,t);if(l["product.price_per_day"]=u.pricePerDay,l["product.price_per_week"]=u.pricePerWeek,l["product.price_per_month"]=u.pricePerMonth,l["product.price_per_year"]=u.pricePerYear,d){const _=Ll(d,t);l["product.period"]=_.period,l["product.period_abbreviated"]=_.periodAbbreviated,l["product.period_with_unit"]=_.periodWithUnit,l["product.period_in_days"]=_.periodInDays,l["product.period_in_weeks"]=_.periodInWeeks,l["product.period_in_months"]=_.periodInMonths,l["product.period_in_years"]=_.periodInYears,l["product.periodly"]=t.translatePeriodFrequency(d.number,d.unit)||""}if(e){const _=yi(r),p=yi(e),m=(p-_)*100/p;l["product.relative_discount"]=m<1?"":t.translate(oe.PaywallVariablesSubRelativeDiscount,{discount:m.toFixed(0)})}xC(s,t,l)}return HI(c,s)&&(l["product.price"]=i,l["product.price_per_period"]=i,l["product.price_per_period_abbreviated"]=i,l["product.price_per_month"]=i,l["product.period_with_unit"]=t.translate(oe.PeriodsLifetime),l["product.period_in_months"]=t.translate(oe.PeriodsLifetime),l["product.periodly"]=t.translate(oe.PeriodsLifetime),l["product.price_per_week"]="",l["product.relative_discount"]="",l["product.period"]="",l["product.period_abbreviated"]="",SC(s,t,l)),l}var GI=/(%?)(%([sdijo]))/g;function KI(r,e){switch(e){case"s":return r;case"d":case"i":return Number(r);case"j":return JSON.stringify(r);case"o":{if(typeof r=="string")return r;const t=JSON.stringify(r);return t==="{}"||t==="[]"||/^\[object .+?\]$/.test(t)?r:t}}}function cd(r,...e){if(e.length===0)return r;let t=0,n=r.replace(GI,(o,i,s,c)=>{const l=e[t],d=KI(l,c);return i?o:(t++,d)});return t<e.length&&(n+=` ${e.slice(t).join(" ")}`),n=n.replace(/%{2,2}/g,"%"),n}var XI=2;function ZI(r){if(!r.stack)return;const e=r.stack.split(`
|
|
464
|
+
}`};function ZC(r,e){he(e,!0),Se(r,XC);const t=()=>Be(l,"$brandingAppearanceStore",o),n=()=>Be(p,"$translator",o),[o,i]=Je(),s=X(e,"onClose",3,void 0),c=X(e,"hideBackButton",3,!1),l=Ve(Vn),d=g(()=>t()??void 0),u=g(()=>new ca(a(d)).pageStyleVars),_=g(()=>Rg(a(d)).background),p=Ve(Pr);var m=xe(),f=ue(m);{var v=h=>{Zl(h,{get brandingInfo(){return e.brandingInfo},get isInElement(){return e.isInElement},get isSandbox(){return e.isSandbox},get onClose(){return s()},navbarHeaderContent:C=>{{let x=g(()=>!e.isInElement&&!!s()&&!c());om(C,{get brandingInfo(){return e.brandingInfo},get onClose(){return s()},get showCloseButton(){return a(x)}})}},navbarBodyContent:C=>{$g(C,{get startData(){return e.subscriptionChangeStartData},unusedTimeAdjustmentVariant:"credit",unresolvedTaxCalculationStatus:"disabled"})},mainContent:C=>{Kg(C,{get startData(){return e.subscriptionChangeStartData},get confirming(){return e.isConfirmingProductChange},get confirmError(){return e.productChangeConfirmError},get brandingAppearance(){return a(d)},get brandingInfo(){return e.brandingInfo},get purchaseOption(){return e.purchaseOptionToUse},get onConfirm(){return e.onConfirmProductChange}})},$$slots:{navbarHeaderContent:!0,navbarBodyContent:!0,mainContent:!0}})},y=h=>{fm(h,{get brandingInfo(){return e.brandingInfo},get isInElement(){return e.isInElement},get isSandbox(){return e.isSandbox},mainContent:k=>{var w=xe(),C=ue(w);{var x=T=>{var E=xe(),F=ue(E);{var M=L=>{var I=HC(),A=D(I);WC(A,{get stripeBillingParams(){return e.stripeBillingParams},get onContinue(){return e.onContinue},get onError(){return e.onError}}),W(()=>De(I,`${a(u)??""}; background-color: ${a(_)??""}`)),P(L,I)};K(F,L=>{e.stripeBillingParams&&L(M)})}P(T,E)},S=T=>{var E=xe(),F=ue(E);{var M=I=>{var A=KC(),U=D(A);ci(U,{gap:"medium",align:"center",children:(j,z)=>{var O=GC(),Z=ue(O);Ss(Z,{color:"var(--rc-color-grey-text-dark)"});var G=Y(Z,2);{var B=N=>{var R=YC(),J=ue(R);ze(J,{size:"heading-md",children:(ee,ce)=>{var ve=qe();W(Ee=>ge(ve,Ee),[()=>n().translate(oe.LoadingPageProcessingPayment)]),P(ee,ve)},$$slots:{default:!0}});var ie=Y(J,2);ze(ie,{size:"body-small",children:(ee,ce)=>{var ve=qe();W(Ee=>ge(ve,Ee),[()=>n().translate(oe.LoadingPageKeepPageOpen)]),P(ee,ve)},$$slots:{default:!0}}),P(N,R)};K(G,N=>{e.currentPage==="purchasing"&&N(B)})}P(j,O)},$$slots:{default:!0}}),P(I,A)},L=I=>{var A=xe(),U=ue(A);{var j=O=>{js(O,{get onContinue(){return e.onContinue},fullWidth:!0})},z=O=>{var Z=xe(),G=ue(Z);{var B=N=>{{let R=g(()=>{var ie;return((ie=e.brandingInfo)==null?void 0:ie.support_email)??null}),J=g(()=>{var ie;return((ie=e.brandingInfo)==null?void 0:ie.app_name)??null});Fs(N,{get lastError(){return e.lastError},get productDetails(){return e.productDetails},get supportEmail(){return a(R)},get onDismiss(){return e.closeWithError},get appName(){return a(J)},get isSandbox(){return e.isSandbox},fullWidth:!0})}};K(G,N=>{e.currentPage==="error"&&N(B)},!0)}P(O,Z)};K(U,O=>{e.currentPage==="success"?O(j):O(z,!1)},!0)}P(I,A)};K(F,I=>{e.currentPage==="loading"||e.currentPage==="purchasing"?I(M):I(L,!1)},!0)}P(T,E)};K(C,T=>{e.currentPage==="stripe-checkout"?T(x):T(S,!1)})}P(k,w)},$$slots:{mainContent:!0}})};K(f,h=>{e.currentPage==="upgrade-confirm"&&e.subscriptionChangeStartData?h(v):h(y,!1)})}P(r,m),ye(),i()}function QC(r,e){var L;he(e,!0);const t=X(e,"customTranslations",19,()=>({})),n=X(e,"skipSuccessPage",3,!1),o=X(e,"onClose",3,void 0),i=X(e,"productChange",3,void 0),s=X(e,"onProductChangeFinished",3,void 0),c=X(e,"hideBackButton",3,!1);let l=e.rcPackage.product,d=new Nn(t(),e.selectedLocale,e.defaultLocale),u=Er(d);wr(Pr,u),wr(li,e.eventsTracker);const _=Er(((L=e.brandingInfo)==null?void 0:L.appearance)??null);wr(Vn,_);let p=ae(null),m=g(()=>a(p)??e.isSandbox),f=ae(null),v=ae(null),y=ae("loading"),h=ae(null),b=ae(null),k=ae(!1),w=ae(null);const C=async()=>{var I;if(!(!i()||a(k))){q(k,!0),q(w,null);try{const A=await e.purchaseOperationHelper.completeProductChange({subscriberToken:i().subscriberToken});(I=s())==null||I(A)}catch(A){const U=A instanceof fe?A:new fe(we.ErrorChargingPayment,"Failed to confirm product change.",A instanceof Error?A.message:String(A));q(w,U.message,!0)}finally{q(k,!1)}}},x=()=>{if(a(y)==="stripe-checkout"){q(y,"purchasing"),e.purchaseOperationHelper.pollCurrentPurchaseForCompletion().then(I=>{q(f,I,!0),n()?e.onFinished(I):q(y,"success")}).catch(I=>{S(Ns(I,"Failed to complete purchase"))});return}a(y)==="success"&&a(f)&&e.onFinished(a(f))},S=I=>{q(v,I,!0),q(y,"error")},T=()=>{e.onError(a(v)??new fe(we.UnknownError,"Unknown error without state set."))};let E=null,F=null,M=null;Fr(async()=>{var j;e.isInElement||(E=document.documentElement.style.height,F=document.documentElement.style.overflow,M=document.body.style.height,document.documentElement.style.height="100%",document.body.style.height="100%",document.documentElement.style.overflow="hidden");const I=l.identifier;if(!I){S(new fe(we.ErrorSettingUpPurchase,"Product ID was not set before purchase."));return}let A=e.customerEmail;(A?im(A):null)&&(A=void 0);try{const z=await e.purchaseOperationHelper.checkoutStart({appUserId:e.appUserId,productId:I,purchaseOption:e.purchaseOption,presentedOfferingContext:e.rcPackage.product.presentedOfferingContext,customerEmail:A,externalPurchaseTokenId:e.externalPurchaseTokenId,metadata:e.metadata,workflowPurchaseContext:e.workflowPurchaseContext,attributionMetadata:e.attributionMetadata,paywallId:e.paywallId,paywallSessionId:e.paywallSessionId,locale:e.selectedLocale,...e.appearanceOverride?{appearanceOverride:e.appearanceOverride}:{},productChange:i()?{productIdentifier:i().productIdentifier,subscriptionId:i().subscriptionId}:void 0,subscriberToken:(j=i())==null?void 0:j.subscriberToken});if(Nc(z)){q(b,z,!0),q(y,"upgrade-confirm");return}if(!("stripe_billing_params"in z)||!z.stripe_billing_params){S(new fe(we.ErrorSettingUpPurchase,"Missing Stripe Checkout parameters"));return}q(p,z.stripe_billing_params.environment.toLowerCase()==="sandbox"),q(h,z.stripe_billing_params,!0),q(y,"stripe-checkout")}catch(z){S(Ns(z,"Failed to start Stripe Checkout"))}}),Tt(()=>{if(!e.isInElement){const I=(A,U,j)=>{j===""?A.style.removeProperty(U):A.style.setProperty(U,j)};I(document.documentElement,"height",E),I(document.body,"height",M),I(document.documentElement,"overflow",F)}}),ZC(r,{get currentPage(){return a(y)},get brandingInfo(){return e.brandingInfo},get productDetails(){return l},get isSandbox(){return a(m)},get lastError(){return a(v)},get isInElement(){return e.isInElement},get stripeBillingParams(){return a(h)},get purchaseOptionToUse(){return e.purchaseOption},get subscriptionChangeStartData(){return a(b)},get isConfirmingProductChange(){return a(k)},get productChangeConfirmError(){return a(w)},onConfirmProductChange:C,onContinue:x,onError:S,get onClose(){return o()},get hideBackButton(){return c()},closeWithError:T}),ye()}function vm(r){return r==null?!0:new Date(r)>new Date}function JC(r,e,t,n){const o=e.product_identifier;if(o in t)return $C(r,e,t[o]);if(o in n)return eI(r,e,n[o]);throw new Xe(Ne.CustomerInfoError,"Could not find entitlement product in subscriptions or non-subscriptions.")}function $C(r,e,t){return{identifier:r,isActive:vm(e.expires_date),willRenew:bm(e.expires_date,t),store:(t==null?void 0:t.store)??"unknown",latestPurchaseDate:new Date(e.purchase_date),originalPurchaseDate:new Date(e.purchase_date),expirationDate:Gt(e.expires_date),productIdentifier:e.product_identifier,productPlanIdentifier:e.product_plan_identifier??null,unsubscribeDetectedAt:Gt(t==null?void 0:t.unsubscribe_detected_at),billingIssueDetectedAt:Gt(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 eI(r,e,t){return{identifier:r,isActive:!0,willRenew:!1,store:t.store,latestPurchaseDate:new Date(e.purchase_date),originalPurchaseDate:new Date(t.original_purchase_date),expirationDate:null,productIdentifier:e.product_identifier,productPlanIdentifier:null,unsubscribeDetectedAt:null,billingIssueDetectedAt:null,isSandbox:t.is_sandbox,periodType:"normal",ownershipType:"UNKNOWN"}}function rI(r,e,t){const n={},o={};for(const i in r){const s=JC(i,r[i],e,t);n[i]=s,s.isActive&&(o[i]=s)}return{all:n,active:o}}function Gt(r){return r==null?null:new Date(r)}function tI(r){if(!r)return null;const e=r.amount*1e6;return{amount:r.amount*100,amountMicros:e,currency:r.currency,formattedPrice:On(e,r.currency)}}function rd(r){const e=aI(r),t=r.subscriber,n=iI(t.non_subscriptions),o=Object.entries(r.subscriber.non_subscriptions).flatMap(([c,l])=>l.map(d=>({transactionIdentifier:d.id,productIdentifier:c,purchaseDate:new Date(d.purchase_date||d.original_purchase_date),storeTransactionId:d.store_transaction_id||null,store:d.store}))),i=new Date(r.request_date),s=Object.fromEntries(Object.entries(r.subscriber.subscriptions).map(([c,l])=>[c,{productIdentifier:c,productPlanIdentifier:l.product_plan_identifier??null,purchaseDate:new Date(l.purchase_date),originalPurchaseDate:Gt(l.original_purchase_date),expiresDate:Gt(l.expires_date),store:l.store,unsubscribeDetectedAt:Gt(l.unsubscribe_detected_at),isSandbox:l.is_sandbox,billingIssuesDetectedAt:Gt(l.billing_issues_detected_at),gracePeriodExpiresDate:Gt(l.grace_period_expires_date),ownershipType:l.ownership_type??"UNKNOWN",periodType:l.period_type,refundedAt:Gt(l.refunded_at),storeTransactionId:l.store_transaction_id||null,managementURL:l.management_url??null,isActive:vm(l.expires_date),willRenew:bm(l.expires_date,l),displayName:l.display_name??null,autoResumeDate:Gt(l.auto_resume_date),price:tI(l.price)}]));return{entitlements:rI(t.entitlements,t.subscriptions,n),allExpirationDatesByProduct:e,allPurchaseDatesByProduct:nI(r,n),activeSubscriptions:oI(e),managementURL:t.management_url,requestDate:i,firstSeenDate:new Date(t.first_seen),originalPurchaseDate:Gt(t.original_purchase_date),originalAppUserId:r.subscriber.original_app_user_id,nonSubscriptionTransactions:o,subscriptionsByProductIdentifier:s}}function bm(r,e){if(e==null)return!1;const t=e.store=="promotional",n=r==null,o=e.unsubscribe_detected_at!=null,i=e.billing_issues_detected_at!=null;return!(t||n||o||i)}function nI(r,e){const t={};for(const n in r.subscriber.subscriptions){const o=r.subscriber.subscriptions[n];t[n]=new Date(o.purchase_date)}for(const n in e){const o=e[n].purchase_date;o==null?t[n]=null:t[n]=new Date(o)}return t}function aI(r){const e={};for(const t in r.subscriber.subscriptions){const n=r.subscriber.subscriptions[t];n.expires_date==null?e[t]=null:e[t]=new Date(n.expires_date)}return e}function oI(r){const e=new Set,t=new Date;for(const n in r){const o=r[n];(o==null||o>t)&&e.add(n)}return e}function iI(r){const e={};for(const t in r){if(r[t].length===0)continue;const n=r[t].length;e[t]=r[t][n-1]}return e}const km="1.67.1",sI="https://api.revenuecat.com",cI="https://e.revenue.cat";var Bs;(function(r){r[r.CONTINUE=100]="CONTINUE",r[r.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",r[r.PROCESSING=102]="PROCESSING",r[r.EARLY_HINTS=103]="EARLY_HINTS",r[r.OK=200]="OK",r[r.CREATED=201]="CREATED",r[r.ACCEPTED=202]="ACCEPTED",r[r.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",r[r.NO_CONTENT=204]="NO_CONTENT",r[r.RESET_CONTENT=205]="RESET_CONTENT",r[r.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",r[r.MULTI_STATUS=207]="MULTI_STATUS",r[r.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",r[r.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",r[r.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",r[r.SEE_OTHER=303]="SEE_OTHER",r[r.NOT_MODIFIED=304]="NOT_MODIFIED",r[r.USE_PROXY=305]="USE_PROXY",r[r.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",r[r.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",r[r.BAD_REQUEST=400]="BAD_REQUEST",r[r.UNAUTHORIZED=401]="UNAUTHORIZED",r[r.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",r[r.FORBIDDEN=403]="FORBIDDEN",r[r.NOT_FOUND=404]="NOT_FOUND",r[r.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",r[r.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",r[r.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",r[r.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",r[r.CONFLICT=409]="CONFLICT",r[r.GONE=410]="GONE",r[r.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",r[r.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",r[r.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",r[r.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",r[r.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",r[r.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",r[r.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",r[r.IM_A_TEAPOT=418]="IM_A_TEAPOT",r[r.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",r[r.METHOD_FAILURE=420]="METHOD_FAILURE",r[r.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",r[r.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",r[r.LOCKED=423]="LOCKED",r[r.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",r[r.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",r[r.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",r[r.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",r[r.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",r[r.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",r[r.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",r[r.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",r[r.BAD_GATEWAY=502]="BAD_GATEWAY",r[r.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",r[r.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",r[r.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",r[r.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",r[r.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(Bs||(Bs={}));const lI=/^rcb_[a-zA-Z0-9_.-]+$/,dI=/^pdl_[a-zA-Z0-9_.-]+$/,uI=/^test_[a-zA-Z0-9_.-]+$/,pI=/^strp_[a-zA-Z0-9_.-]+$/,_I=/^amzn_[a-zA-Z0-9_.-]+$/;function Rs(r){return r?r.startsWith("rcb_sb_"):!1}function hi(r){return r?lI.test(r):!1}function Us(r){return r?dI.test(r):!1}function mo(r){return r?pI.test(r):!1}function Wn(r){return r?_I.test(r):!1}function gI(r){return r?r.startsWith("strp_sb_"):!1}function Hn(r){return r?uI.test(r):!1}async function kt(r,e,t){return(await wm(r,e,t)).data}async function wm(r,e,t){const{apiKey:n,body:o,headers:i,httpConfig:s}=e,l=`${(s==null?void 0:s.proxyURL)??sI}${r.urlPath()}`;try{const d=await fetch(l,{method:r.method,headers:Am(n,i,s==null?void 0:s.additionalHeaders),body:fI(o),signal:t});await mI(d,r);const u=d.status;return{data:await d.json(),statusCode:u}}catch(d){throw d instanceof TypeError?new Xe(Ne.NetworkError,ro.getPublicMessage(Ne.NetworkError),d.message):d}}async function mI(r,e){const t=r.status;if(t>=Bs.INTERNAL_SERVER_ERROR)td(e,t,await r.text());else if(t>=Bs.BAD_REQUEST){const n=await r.json(),o=n?JSON.stringify(n):null,i=n==null?void 0:n.code,s=n==null?void 0:n.message;if(i!=null){const c=ro.convertCodeToBackendErrorCode(i);if(c==null)td(e,t,o,i);else throw Xe.getForBackendError(c,s)}else td(e,t,o)}}function td(r,e,t,n){throw new Xe(Ne.UnknownBackendError,"Unknown backend error.",`Request: ${r.name}. Status code: ${e}. Body: ${t}.`,{statusCode:e,backendErrorCode:n})}function fI(r){return r==null?null:JSON.stringify(r)}const Pm="Authorization",xm="Content-Type",Sm="Accept",Em="X-Platform",Cm="X-Version",Im="X-Platform-Flavor",Tm="X-Platform-Flavor-Version",nd="X-Is-Sandbox",hI="X-RC-Subscriber-Token",yI=new Set([Pm,xm,Sm,Em,Cm,nd,Im,Tm,hI]);function Am(r,e,t){const n=Wn(r);let o={[Pm]:`Bearer ${r}`,[xm]:"application/json",[Sm]:"application/json",[Em]:n?"amazon":"web",[Cm]:km,...!n&&{[nd]:`${Rs(r)||Hn(r)}`}};const i=Ws.getPlatformInfo();if(i){const s={[Im]:i.flavor,[Tm]:i.version};o={...o,...s}}return e&&(o={...o,...e}),t&&(o={...t,...o}),n&&delete o[nd],o}const qa="/v1/subscribers",Ma="/rcbilling/v1";class vI{constructor(e){re(this,"appUserId");re(this,"method","GET");re(this,"name","getOfferings");this.appUserId=e}urlPath(){const e=encodeURIComponent(this.appUserId);return`${qa}/${e}/offerings`}}class Dm{constructor(e,t,n,o){re(this,"method","GET");re(this,"name","getProducts");re(this,"appUserId");re(this,"productIds");re(this,"currency");re(this,"discountCode");this.appUserId=e,this.productIds=t,this.currency=n,this.discountCode=o}urlPath(){const e=encodeURIComponent(this.appUserId),t=this.productIds.map(encodeURIComponent).join("&id="),n=this.currency?`¤cy=${this.currency}`:"",o=this.discountCode?`&discount_code=${encodeURIComponent(this.discountCode)}`:"";return`${Ma}/subscribers/${e}/products?id=${t}${n}${o}`}}class bI{constructor(e){re(this,"method","GET");re(this,"name","getCustomerInfo");re(this,"appUserId");this.appUserId=e}urlPath(){const e=encodeURIComponent(this.appUserId);return`${qa}/${e}`}}class kI{constructor(){re(this,"method","POST");re(this,"name","identify")}urlPath(){return`${qa}/identify`}}class wI{constructor(){re(this,"method","GET");re(this,"name","getBrandingInfo")}urlPath(){return`${Ma}/branding`}}class PI{constructor(){re(this,"method","POST");re(this,"name","postCheckoutPrepare")}urlPath(){return`${Ma}/checkout/prepare`}}class xI{constructor(){re(this,"method","POST");re(this,"name","postCheckoutStart")}urlPath(){return`${Ma}/checkout/start`}}class SI{constructor(e){re(this,"method","PATCH");re(this,"name","patchCheckoutRefreshPricing");re(this,"operationSessionId");this.operationSessionId=e}urlPath(){return`${Ma}/checkout/${this.operationSessionId}`}}class EI{constructor(e){re(this,"method","POST");re(this,"name","postCheckoutComplete");re(this,"operationSessionId");this.operationSessionId=e}urlPath(){return`${Ma}/checkout/${this.operationSessionId}/complete`}}class CI{constructor(e){re(this,"method","GET");re(this,"name","getCheckoutStatus");re(this,"operationSessionId");this.operationSessionId=e}urlPath(){return`${Ma}/checkout/${this.operationSessionId}`}}class II{constructor(e){re(this,"method","POST");re(this,"name","setAttributes");re(this,"appUserId");this.appUserId=e}urlPath(){const e=encodeURIComponent(this.appUserId);return`${qa}/${e}/attributes`}}class TI{constructor(){re(this,"method","POST");re(this,"name","postReceipt")}urlPath(){return"/v1/receipts"}}class AI{constructor(e){re(this,"method","GET");re(this,"name","getVirtualCurrencies");re(this,"appUserId");this.appUserId=e}urlPath(){const e=encodeURIComponent(this.appUserId);return`${qa}/${e}/virtual_currencies`}}class DI{constructor(e){re(this,"method","GET");re(this,"name","getWorkflows");re(this,"appUserId");this.appUserId=e}urlPath(){return`${qa}/${encodeURIComponent(this.appUserId)}/workflows?type=paywall`}}class zI{constructor(e,t){re(this,"method","GET");re(this,"name","getWorkflowData");re(this,"appUserId");re(this,"workflowId");this.appUserId=e,this.workflowId=t}urlPath(){return`${qa}/${encodeURIComponent(this.appUserId)}/workflows/${encodeURIComponent(this.workflowId)}`}}const ad={},qI=2e3;class MI{constructor(e,t=ad,n){re(this,"API_KEY");re(this,"httpConfig");re(this,"isSandbox");re(this,"purchasesContext");this.API_KEY=e,this.httpConfig=t,this.isSandbox=Rs(e),this.purchasesContext=n}getIsSandbox(){return this.isSandbox}async getOfferings(e){return await kt(new vI(e),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getCustomerInfo(e){return await kt(new bI(e),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async identify(e,t){const n={app_user_id:e,new_app_user_id:t},o=await wm(new kI,{apiKey:this.API_KEY,body:n,httpConfig:this.httpConfig}),i=o.statusCode===201;return{...o.data,was_created:i}}async getProducts(e,t,n,o){const i=Array.from(new Set(t)),s=this.batchProductIdsByUrlLength(e,i,n,o),c=[];for(const l of s){const d=await kt(new Dm(e,l,n,o),{apiKey:this.API_KEY,httpConfig:this.httpConfig});c.push(...d.product_details)}return{product_details:c}}batchProductIdsByUrlLength(e,t,n,o){const i=[];let s=[];for(const c of t){const l=[...s,c],d=new Dm(e,l,n,o).urlPath().length;s.length>0&&d>qI?(i.push(s),s=[c]):s=l}return s.length>0&&i.push(s),i}async getBrandingInfo(){return await kt(new wI,{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async postCheckoutPrepare(e,t){const n={product_id:e,price_id:t.priceId};return t.id!=="base_option"&&(n.offer_id=t.id),await kt(new PI,{apiKey:this.API_KEY,body:n,httpConfig:this.httpConfig})}async postCheckoutStart({appUserId:e,productId:t,purchaseOption:n,presentedOfferingContext:o,traceId:i,presentedStepId:s,urlParameters:c,paywallId:l,paywallSessionId:d,customerEmail:u,externalPurchaseTokenId:_,metadata:p,locale:m,attributionMetadata:f,appearanceOverride:v,productChange:y,subscriberToken:h,purchaseFlow:b}){var w,C;const k={app_user_id:e,product_id:t,email:u,price_id:n.priceId,presented_offering_identifier:o.offeringIdentifier,trace_id:i};return p&&(k.metadata=p),_&&(k.external_purchase_token_id=_),n.id!=="base_option"&&(k.offer_id=n.id),o.targetingContext&&(k.applied_targeting_rule={rule_id:o.targetingContext.ruleId,revision:o.targetingContext.revision}),o.placementIdentifier&&(k.presented_placement_identifier=o.placementIdentifier),(C=(w=this.purchasesContext)==null?void 0:w.workflowContext)!=null&&C.workflowIdentifier&&(k.presented_workflow_id=this.purchasesContext.workflowContext.workflowIdentifier),s&&(k.presented_step_id=s),c&&Object.keys(c).length>0&&(k.url_parameters=c),l&&(k.paywall={paywall_id:l,...d?{paywall_session_id:d}:{}}),m&&(k.locale=m),f&&(k.attribution_metadata=f),v&&(k.appearance_override=v),y&&(k.product_change={...y.subscriptionId?{subscription_id:y.subscriptionId}:{},...y.productIdentifier?{from_product_id:y.productIdentifier}:{}}),b&&(k.purchase_flow=b),await kt(new xI,{apiKey:this.API_KEY,body:k,headers:h?{"X-RC-Subscriber-Token":h}:void 0,httpConfig:this.httpConfig})}async patchCheckoutRefreshPricing(e,{countryCode:t,postalCode:n,state:o,city:i,addressLine1:s,addressLine2:c,discountCode:l,signal:d}={}){const u={country_code:t,postal_code:n,state:o,city:i,address_line1:s,address_line2:c,discount_code:l};return await kt(new SI(e),{apiKey:this.API_KEY,body:u,httpConfig:this.httpConfig},d)}async postCheckoutComplete(e,t={}){const n={};return t.email&&(n.email=t.email),t.locale&&(n.locale=t.locale),t.billingName&&(n.billing_name=t.billingName),t.billingAddress&&(n.billing_address={country_code:t.billingAddress.countryCode,postal_code:t.billingAddress.postalCode,state:t.billingAddress.state,city:t.billingAddress.city,address_line1:t.billingAddress.addressLine1,address_line2:t.billingAddress.addressLine2}),await kt(new EI(e),{apiKey:this.API_KEY,body:n,headers:t.subscriberToken?{"X-RC-Subscriber-Token":t.subscriberToken}:void 0,httpConfig:this.httpConfig})}async getCheckoutStatus(e){return await kt(new CI(e),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async setAttributes(e,t){const n=Date.now(),o={};for(const[s,c]of Object.entries(t))o[s]={value:c,updated_at_ms:n};const i={attributes:o};return await kt(new II(e),{apiKey:this.API_KEY,body:i,httpConfig:this.httpConfig})}async postReceipt(e,t,n,o,i,s,c,l,d,u){var m,f;let _=null;i!=null&&i.targetingContext&&(_={rule_id:i.targetingContext.ruleId,revision:i.targetingContext.revision});const p={fetch_token:o,product_id:t,currency:n,app_user_id:e,presented_offering_identifier:(i==null?void 0:i.offeringIdentifier)??null,presented_placement_identifier:(i==null?void 0:i.placementIdentifier)??null,presented_workflow_id:(f=(m=this.purchasesContext)==null?void 0:m.workflowContext)==null?void 0:f.workflowIdentifier,applied_targeting_rule:_,initiation_source:s,store_user_id:l,is_restore:d,price:u??null};return c&&(p.paywall={paywall_id:c}),await kt(new TI,{apiKey:this.API_KEY,body:p,httpConfig:this.httpConfig})}async getVirtualCurrencies(e){return await kt(new AI(e),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getWorkflows(e){return await kt(new DI(e),{apiKey:this.API_KEY,httpConfig:this.httpConfig})}async getWorkflowById(e,t){const n=await kt(new zI(e,t),{apiKey:this.API_KEY,httpConfig:this.httpConfig});if(!("action"in n))return n;if(n.action==="inline")return n.data;if(n.action!=="use_cdn")throw new Error(`Unexpected workflow action: ${n.action}`);const o=await fetch(n.url);if(!o.ok)throw new Error(`Failed to fetch workflow from CDN: ${o.statusText}`);return await o.json()}}var zm=(r=>(r.PURCHASE="purchase",r.RESTORE="restore",r.UNSYNCED_ACTIVE_PURCHASES="unsynced_active_purchases",r))(zm||{});function FI(r){if(!(hi(r)||Hn(r)||Us(r)||mo(r)||Wn(r)))throw new Xe(Ne.InvalidCredentialsError,"Invalid API key. Use a valid API key obtained from the RevenueCat Dashboard.")}function od(r){if(!r||new Set(["no_user","null","none","nil","(null)","NaN","\\x00","","unidentified","undefined","unknown"]).has(r)||r.includes("/"))throw new Xe(Ne.InvalidAppUserIdError,'Provided user id: "'+(r??"[Not provided]")+'" is not valid. See https://www.revenuecat.com/docs/customers/user-ids#tips-for-setting-app-user-ids for more information.')}function jI(r){if(r!=null&&r.endsWith("/"))throw new Xe(Ne.ConfigurationError,"Invalid proxy URL. The proxy URL should not end with a trailing slash.")}function OI(r){if(r){for(const e in r)if(yI.has(e))throw new Xe(Ne.ConfigurationError,"Invalid additional headers. Some headers are reserved for internal use.")}}var Vs=(r=>(r.Current="current",r))(Vs||{});function id(r,e){async function t(...n){return await this.preload(),await r.call(this,...n)}return t}const NI=(r,e)=>{const t={...r.product,presentedOfferingContext:{...r.product.presentedOfferingContext,placementIdentifier:e}};return{...r,webBillingProduct:t,rcBillingProduct:t,product:t}},LI=(r,e)=>{const t=sd(e);return Mm(r,n=>{const o=t[n.product.identifier];if(o===void 0)return n;const i=up(o,n.product.presentedOfferingContext);return i===null?n:{...n,rcBillingProduct:i,webBillingProduct:i,product:i}})},BI=(r,e)=>{const t=r.offering_ids_by_placement??{};if(e in t){const n=t[e]??null;return{offeringIdForPlacement:n,fallbackOfferingId:n===null?null:r.fallback_offering_id}}return{offeringIdForPlacement:null,fallbackOfferingId:r.fallback_offering_id}},qm=(r,e)=>Mm(e,t=>NI(t,r)),Mm=(r,e)=>{const t=r.availablePackages.map(e),n=Object.fromEntries(t.map(i=>[i.identifier,i])),o=i=>i===null?null:n[i.identifier]??null;return{...r,packagesById:n,availablePackages:t,weekly:o(r.weekly),monthly:o(r.monthly),twoMonth:o(r.twoMonth),threeMonth:o(r.threeMonth),sixMonth:o(r.sixMonth),annual:o(r.annual),lifetime:o(r.lifetime)}};function sd(r){const e={};return r.product_details.forEach(t=>{e[t.identifier]=t}),e}function RI(r,e,t){const n=e.offerings.find(s=>s.identifier===r);if(!n)return null;const o=sd(t),i=n.identifier===e.current_offering_id;return pp(i,n,o,e.targeting,e.ui_config)}function UI(r,e){const t=sd(e),n={};r.offerings.forEach(i=>{const s=i.identifier===r.current_offering_id,c=pp(s,i,t,r.targeting,r.ui_config);c!=null&&(n[i.identifier]=c)});const o=r.current_offering_id?n[r.current_offering_id]??null:null;return Object.keys(n).length==0&&pe.debugLog("Empty offerings. Please make sure you've configured offerings correctly in the RevenueCat dashboard and that the products are properly configured."),{all:n,current:o}}const VI=1000001;function Fm(r,e={}){var o;if(e.translator)return Nm(r,e.translator);const t=((o=r.paywallComponents)==null?void 0:o.default_locale)||Br,n=new Nn(e.customTranslations??{},e.selectedLocale??t,e.fallbackLocale??t);return Nm(r,n)}function yi(r){var o;const e=r.product.price,t=jm(r),n=r.product.period||((o=t==null?void 0:t.base)==null?void 0:o.period);return!n||!n.number||n.number<=0?e.amountMicros:e.amountMicros*Vc(n).perMonth}function jm(r){return r.product.productType===Rr.Subscription?r.product.defaultSubscriptionOption:r.product.productType===Rr.NonConsumable||r.product.productType===Rr.Consumable?r.product.defaultNonSubscriptionOption:r.product.defaultPurchaseOption}function WI(r,e){return r===Rr.Subscription&&e!=null}function HI(r,e){return r!==Rr.Subscription&&e!=null}function Om(r,e,t,n=!1){return t.translate(oe.PaywallVariablesPricePerPeriod,{formattedPrice:r,period:e.base.period?e.base.period.number===1?t.translatePeriodUnit(e.base.period.unit,{noWhitespace:!0,short:!n}):t.translatePeriod(e.base.period.number,e.base.period.unit,{noWhitespace:!0,short:!n}):""})}function Nm(r,e){const t=r.availablePackages,n=t.filter(i=>i.product.productType===Rr.Subscription),o=n.length>0?n.reduce((i,s)=>{const c=yi(i),l=yi(s);return c>l?i:s}):null;return t.reduce((i,s)=>(i[s.identifier]=YI(s,o,e),i),{})}function YI(r,e,t){const n=r.product,o=n.price,i=t.formatPrice(o.amountMicros,o.currency),s=jm(r),c=n.productType,l={"product.store_product_name":n.title,"product.price":i,"product.price_per_period":"","product.price_per_period_abbreviated":"","product.price_per_day":"","product.price_per_week":"","product.price_per_month":"","product.price_per_year":"","product.period":"","product.period_abbreviated":"","product.periodly":"","product.period_in_days":"","product.period_in_weeks":"","product.period_in_months":"","product.period_in_years":"","product.period_with_unit":"","product.currency_code":o.currency,"product.currency_symbol":t.formatPrice(0,o.currency).replace("0",""),"product.offer_price":"","product.offer_price_per_day":"","product.offer_price_per_week":"","product.offer_price_per_month":"","product.offer_price_per_year":"","product.offer_price_with_zero":"","product.offer_price_with_zero_per_day":"","product.offer_price_with_zero_per_week":"","product.offer_price_with_zero_per_month":"","product.offer_price_with_zero_per_year":"","product.offer_period":"","product.offer_period_abbreviated":"","product.offer_period_in_days":"","product.offer_period_in_weeks":"","product.offer_period_in_months":"","product.offer_period_in_years":"","product.offer_period_with_unit":"","product.offer_end_date":"","product.secondary_offer_price":"","product.secondary_offer_period":"","product.secondary_offer_period_abbreviated":"","product.relative_discount":""};if(WI(c,s)){l["product.price_per_period_abbreviated"]=Om(i,s,t),l["product.price_per_period"]=Om(i,s,t,!0);const d=n.period||s.base.period,u=hm(o,d,t);if(l["product.price_per_day"]=u.pricePerDay,l["product.price_per_week"]=u.pricePerWeek,l["product.price_per_month"]=u.pricePerMonth,l["product.price_per_year"]=u.pricePerYear,d){const _=Ll(d,t);l["product.period"]=_.period,l["product.period_abbreviated"]=_.periodAbbreviated,l["product.period_with_unit"]=_.periodWithUnit,l["product.period_in_days"]=_.periodInDays,l["product.period_in_weeks"]=_.periodInWeeks,l["product.period_in_months"]=_.periodInMonths,l["product.period_in_years"]=_.periodInYears,l["product.periodly"]=t.translatePeriodFrequency(d.number,d.unit)||""}if(e){const _=yi(r),p=yi(e),m=(p-_)*100/p;l["product.relative_discount"]=m<1?"":t.translate(oe.PaywallVariablesSubRelativeDiscount,{discount:m.toFixed(0)})}xC(s,t,l)}return HI(c,s)&&(l["product.price"]=i,l["product.price_per_period"]=i,l["product.price_per_period_abbreviated"]=i,l["product.price_per_month"]=i,l["product.period_with_unit"]=t.translate(oe.PeriodsLifetime),l["product.period_in_months"]=t.translate(oe.PeriodsLifetime),l["product.periodly"]=t.translate(oe.PeriodsLifetime),l["product.price_per_week"]="",l["product.relative_discount"]="",l["product.period"]="",l["product.period_abbreviated"]="",SC(s,t,l)),l}var GI=/(%?)(%([sdijo]))/g;function KI(r,e){switch(e){case"s":return r;case"d":case"i":return Number(r);case"j":return JSON.stringify(r);case"o":{if(typeof r=="string")return r;const t=JSON.stringify(r);return t==="{}"||t==="[]"||/^\[object .+?\]$/.test(t)?r:t}}}function cd(r,...e){if(e.length===0)return r;let t=0,n=r.replace(GI,(o,i,s,c)=>{const l=e[t],d=KI(l,c);return i?o:(t++,d)});return t<e.length&&(n+=` ${e.slice(t).join(" ")}`),n=n.replace(/%{2,2}/g,"%"),n}var XI=2;function ZI(r){if(!r.stack)return;const e=r.stack.split(`
|
|
465
465
|
`);e.splice(1,XI),r.stack=e.join(`
|
|
466
466
|
`)}var QI=class extends Error{constructor(r,...e){super(r),this.message=r,this.name="Invariant Violation",this.message=cd(r,...e),ZI(this)}},Lm=(r,e,...t)=>{if(!r)throw new QI(e,...t)};Lm.as=(r,e,t,...n)=>{if(!e){const o=n.length===0?t:cd(t,...n);let i;try{i=Reflect.construct(r,[o])}catch{i=r(o)}throw i}};const JI="[MSW]";function ld(r,...e){const t=cd(r,...e);return`${JI} ${t}`}function $I(r,...e){console.warn(ld(r,...e))}function eT(r,...e){console.error(ld(r,...e))}const rT={formatMessage:ld,warn:$I,error:eT};function tT(){Lm(typeof URL<"u",rT.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 Bm=(r=>(r.HEAD="HEAD",r.GET="GET",r.POST="POST",r.PUT="PUT",r.PATCH="PATCH",r.OPTIONS="OPTIONS",r.DELETE="DELETE",r))(Bm||{});tT();class nT{constructor(e,t,n,o){re(this,"initialDelay");re(this,"maxDelay");re(this,"jitterPercent");re(this,"callback");re(this,"currentDelay");re(this,"timeoutId");re(this,"executingCallback",!1);re(this,"stopped",!1);re(this,"currentFlushPromise",null);this.initialDelay=e,this.currentDelay=e,this.maxDelay=t,this.jitterPercent=n,this.callback=o}tryFlush(){if(!this.stopped){if(this.backingOff()){pe.debugLog("Backing off, not flushing");return}this.clearTimeout(),this.executeCallbackWithRetries().catch(()=>{})}}start(){this.stopped=!1,this.currentDelay=this.initialDelay}stop(){this.stopped=!0,this.clearTimeout()}flushImmediately(e){return this.clearTimeout(),this.executeCallbackWithRetries(e)}async flushUntilDrain(e){const t=this.currentFlushPromise;if(t)try{await t}catch{}this.stop();try{let n=!1;for(;!n;)n=await this.flushImmediately(e)}finally{this.start()}}schedule(e){if(this.stopped||this.timeoutId!==void 0)return;const t=this.addJitter(e||this.currentDelay);this.timeoutId=setTimeout(()=>{this.timeoutId=void 0,this.executeCallbackWithRetries().catch(()=>{})},t)}backoff(){const e=this.currentDelay,t=Math.min(this.currentDelay*2,this.maxDelay);pe.debugLog(`Backing next off to ${e}ms delay`),this.clearTimeout(),this.currentDelay=t,this.schedule(e)}reset(){this.currentDelay!==this.initialDelay&&(this.clearTimeout(),this.currentDelay=this.initialDelay)}async executeCallbackWithRetries(e){if(this.executingCallback)return pe.debugLog("Callback already running, rescheduling"),this.schedule(),!0;this.executingCallback=!0;let t;try{t=Promise.resolve(this.callback(e))}catch(n){t=Promise.reject(n)}this.currentFlushPromise=t.then(()=>{},()=>{});try{const n=await t;return this.reset(),n}catch{return this.backoff(),!0}finally{this.executingCallback=!1,this.currentFlushPromise=null}}backingOff(){return this.currentDelay>this.initialDelay}clearTimeout(){clearTimeout(this.timeoutId),this.timeoutId=void 0}addJitter(e){const t=e*this.jitterPercent,n=e-t,o=e+t;return Math.floor(Math.random()*(o-n+1)+n)}}const aT=Object.entries({componentType:"component_type",componentName:"component_name",componentValue:"component_value",componentURL:"component_url",originIndex:"origin_index",destinationIndex:"destination_index",originContextName:"origin_context_name",destinationContextName:"destination_context_name",defaultIndex:"default_index",originPackageId:"origin_package_id",destinationPackageId:"destination_package_id",defaultPackageId:"default_package_id",originProductId:"origin_product_id",destinationProductId:"destination_product_id",defaultProductId:"default_product_id",currentPackageId:"current_package_id",resultingPackageId:"resulting_package_id",currentProductId:"current_product_id",resultingProductId:"resulting_product_id"}),dd=r=>r.displayMode===void 0?{}:{display_mode:r.displayMode,dark_mode:r.darkMode??!1,locale:r.locale??"en_US"},Rm=r=>{const e={};for(const[t,n]of aT){const o=r[t];o!==void 0&&Object.assign(e,{[n]:o})}return e};function oT(r){return!r||!r.placementIdentifier&&!r.targetingContext?null:{...r.placementIdentifier?{placement_identifier:r.placementIdentifier}:{},...r.targetingContext?{targeting_revision:r.targetingContext.revision,targeting_rule_id:r.targetingContext.ruleId}:{}}}const iT=(r,e,t)=>{const n={version:1,id:e,app_user_id:r.appUserId,session_id:r.sessionId,offering_id:r.offeringId,paywall_revision:r.paywallRevision,timestamp:t,paywall_rc_public_id:r.paywallRcPublicId},o=oT(r.presentedOfferingContext);return o&&(n.presented_offering_context=o),n},sT=(r,e=Date.now())=>({timestamp:e,session_id:r.sessionId,offering_id:r.offeringId,...r.paywallRcPublicId?{paywall_id:r.paywallRcPublicId}:{},paywall_revision:r.paywallRevision,...dd(r),...Rm(r)});class Um{constructor(e){re(this,"id");re(this,"timestamp");re(this,"data");this.id=mn(),this.timestamp=Date.now(),this.data=e}toJSON(){const e=iT(this.data,this.id,this.timestamp);switch(this.data.type){case"paywall_impression":return{type:this.data.type,...e,...dd(this.data)};case"paywall_close":case"paywall_cancel":return{type:this.data.type,...e};case"paywall_component_interacted":return{type:this.data.type,...e,...dd(this.data),...Rm(this.data)}}}}class Vm{constructor(e,t,n){re(this,"id");re(this,"timestamp");re(this,"data");re(this,"appUserId");re(this,"appSessionId");this.id=mn(),this.timestamp=Date.now(),this.data=e,this.appUserId=t,this.appSessionId=n}toJSON(){const e=this.data.placementIdentifier!==void 0||this.data.targetingRevision!==void 0||this.data.targetingRuleId!==void 0?{...this.data.placementIdentifier!==void 0?{placement_identifier:this.data.placementIdentifier}:{},...this.data.targetingRevision!==void 0?{targeting_revision:this.data.targetingRevision}:{},...this.data.targetingRuleId!==void 0?{targeting_rule_id:this.data.targetingRuleId}:{}}:void 0;return{id:this.id,version:1,type:"custom_paywall_impression",app_user_id:this.appUserId,...this.appSessionId!==void 0?{app_session_id:this.appSessionId}:{},timestamp:this.timestamp,...this.data.paywallId!==void 0?{paywall_id:this.data.paywallId}:{},...this.data.offeringId!==void 0?{offering_id:this.data.offeringId}:{},...e!==void 0?{presented_offering_context:e}:{}}}}function Yn(){if(typeof window<"u")return window;throw new Xe(Ne.UnsupportedError,"window is not available. This SDK requires a browser environment for this operation.")}function vi(){if(typeof window<"u")return window}function ud(){if(typeof document<"u")return document;throw new Xe(Ne.UnsupportedError,"document is not available. This SDK requires a browser environment for this operation.")}function pd(){if(typeof document<"u")return document}function cT(r,e){const t=vi(),n=t!=null&&t.location?new URLSearchParams(t.location.search):new URLSearchParams;let o=null,i=null;typeof screen<"u"&&screen&&(o=screen.width,i=screen.height);const s=pd(),c=(s==null?void 0:s.referrer)??null,l=(s==null?void 0:s.title)??null;return{libraryName:"purchases-js",libraryVersion:km,locale:navigator.language,userAgent:navigator.userAgent,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:o,screenHeight:i,utmSource:n.get("utm_source")??null,utmMedium:n.get("utm_medium")??null,utmCampaign:n.get("utm_campaign")??null,utmContent:n.get("utm_content")??null,utmTerm:n.get("utm_term")??null,pageReferrer:c,pageUrl:t!=null&&t.location?`${t.location.origin}${t.location.pathname}`:"",pageTitle:l,source:r,rcSource:e}}const lT=2e3,dT=5*6e4,uT=.1,Wm=50*1024,Zs=class Zs{constructor(e){re(this,"apiKey");re(this,"eventsQueue",[]);re(this,"eventsUrl");re(this,"flushManager");re(this,"traceId");re(this,"appUserId");re(this,"isSilent");re(this,"rcSource");re(this,"workflowContext");re(this,"isDisposed",!1);var t;this.apiKey=e.apiKey,this.eventsUrl=`${((t=e.httpConfig)==null?void 0:t.eventsURL)??cI}/v1/events`,this.appUserId=e.appUserId,this.isSilent=e.silent||!1,this.rcSource=e.rcSource,this.workflowContext=e.workflowContext,this.traceId=e.trace_id||mn(),this.flushManager=new nT(lT,dT,uT,this.doFlush.bind(this))}async updateUser(e){this.appUserId=e}getTraceId(){return this.traceId}trackSDKEvent(e){this.trackEvent({...e,source:"sdk"})}trackExternalEvent(e){this.trackEvent({...e})}trackPaywallEvent(e){if(this.isSilent){pe.verboseLog("Skipping event tracking, the EventsTracker is silent");return}try{const t=new Um(e);pe.debugLog(`[PaywallEvent] Queuing ${e.type} (queue size: ${this.eventsQueue.length+1}, url: ${this.eventsUrl})`),pe.debugLog(`[PaywallEvent] Payload: ${JSON.stringify(t.toJSON())}`),this.eventsQueue.push(t),this.flushManager.tryFlush()}catch(t){pe.errorLog(`Error while tracking paywall event ${e.type}: ${t}`)}}trackCustomPaywallImpression(e){if(this.isSilent){pe.verboseLog("Skipping event tracking, the EventsTracker is silent");return}try{const t=new Vm({...e},this.appUserId,Zs.appSessionId);pe.debugLog(`[CustomPaywallImpressionEvent] Queuing event (queue size: ${this.eventsQueue.length+1}, url: ${this.eventsUrl})`),pe.debugLog(`[CustomPaywallImpressionEvent] Payload: ${JSON.stringify(t.toJSON())}`),this.eventsQueue.push(t),this.flushManager.tryFlush()}catch(t){pe.errorLog(`Error while tracking custom paywall impression: ${t}`)}}trackEvent(e){var t;if(this.isSilent){pe.verboseLog("Skipping event tracking, the EventsTracker is silent");return}try{const n=new vx({eventName:e.eventName,traceId:this.traceId,appUserId:this.appUserId,context:cT(e.source,this.rcSource),workflowIdentifier:(t=this.workflowContext)==null?void 0:t.workflowIdentifier,properties:e.properties||{mode:mt}});this.eventsQueue.push(n),this.flushManager.tryFlush()}catch(n){pe.errorLog(`Error while tracking event ${e.eventName}: ${n}`)}}dispose(){this.isDisposed||(this.flushManager.stop(),this.eventsQueue.length>0&&this.flushManager.flushUntilDrain({ignoreDisposed:!0}).catch(e=>{pe.debugLog(`Failed to flush events on dispose: ${e}`)}),this.isDisposed=!0)}async flushAllEvents(){this.isDisposed||(await this.flushManager.flushUntilDrain(),!this.isDisposed&&this.eventsQueue.length>0&&this.flushManager.schedule())}estimateSingleEventSize(e){try{return JSON.stringify(e).length}catch{return Wm}}batchEventsForKeepalive(){const e=[];let t=16;for(const n of this.eventsQueue){const o=this.estimateSingleEventSize(n),i=e.length>0?1:0,s=t+o+i;if(s<=Wm)e.push(n),t=s;else if(e.length===0){const c=n instanceof Vm?"custom_paywall_impression":n instanceof Um?n.data.type:n.data.eventName;return pe.warnLog(`Event exceeds keepalive size limit (${o} bytes): ${c}`),this.eventsQueue.shift(),null}else break}return e}doFlush(e){if(!(e!=null&&e.ignoreDisposed)&&this.isDisposed||this.eventsQueue.length===0)return Promise.resolve(!0);const t=this.batchEventsForKeepalive();if(!t)return Promise.resolve(this.eventsQueue.length===0);const n=JSON.stringify({events:t});return pe.debugLog(`[EventsTracker] Flushing ${t.length} event(s) to ${this.eventsUrl}`),pe.debugLog(`[EventsTracker] Body: ${n}`),fetch(this.eventsUrl,{method:Bm.POST,headers:Am(this.apiKey),body:n,keepalive:!0}).then(o=>{if(pe.debugLog(`[EventsTracker] Flush response: ${o.status}`),o.status===200||o.status===201)return this.eventsQueue.splice(0,t.length),this.eventsQueue.length>0&&this.flushManager.schedule(),this.eventsQueue.length===0;throw pe.debugLog("Events failed to flush due to server error"),new Error("Events failed to flush due to server error")}).catch(o=>{throw pe.debugLog(`[EventsTracker] Flush error: ${o}`),o})}};re(Zs,"appSessionId",mn());let _d=Zs;const bi=()=>{const r=vi(),e=r!=null&&r.location?new URLSearchParams(r.location.search):new URLSearchParams,t=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],n={};return t.forEach(o=>{const i=e.get(o);i!==null&&(n[o]=i)}),n},pT=["app","embedded"],gd={autoCollectUTMAsMetadata:!0,collectAnalyticsEvents:!0,storeLoadTime:"configuration"};var _T=H('<p class="svelte-17914yi"><strong>Free Trial:</strong> </p>'),gT=H('<p class="svelte-17914yi"><strong>Intro Price:</strong> </p>'),mT=H('<p class="svelte-17914yi"><strong>Discount Price:</strong> </p>'),fT=H('<div class="rc-simulated-store-modal-overlay svelte-17914yi"><div class="rc-simulated-store-modal svelte-17914yi"><div class="rc-simulated-store-modal-content svelte-17914yi"><h2 class="rc-simulated-store-modal-title svelte-17914yi">Test Store Purchase</h2> <div class="rc-simulated-store-modal-details svelte-17914yi"><div><p class="svelte-17914yi"><strong>Product:</strong> </p> <p class="svelte-17914yi"><strong>Type:</strong> </p> <p class="svelte-17914yi"><strong>Price:</strong> </p> <!> <!> <!></div></div> <div class="rc-simulated-store-modal-buttons svelte-17914yi"><button type="button" class="rc-simulated-store-modal-button rc-simulated-store-modal-button-primary svelte-17914yi">Test valid purchase</button> <button type="button" class="rc-simulated-store-modal-button rc-simulated-store-modal-button-secondary svelte-17914yi">Test failed purchase</button> <button type="button" class="rc-simulated-store-modal-button rc-simulated-store-modal-button-cancel svelte-17914yi">Cancel</button></div></div></div></div>');const hT={hash:"svelte-17914yi",code:`.rc-simulated-store-modal-overlay.svelte-17914yi {position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0, 0, 0, 0.5);display:flex;justify-content:center;align-items:center;font-family:-apple-system,
|
|
467
467
|
BlinkMacSystemFont,
|