@revenuecat/purchases-js 0.2.0 → 0.2.2

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.
@@ -3944,7 +3944,7 @@ class Wi extends Error {
3944
3944
  super("Purchases must be configured before calling getInstance");
3945
3945
  }
3946
3946
  }
3947
- const zi = "0.2.0", fe = "https://api.revenuecat.com";
3947
+ const zi = "0.2.2", fe = "https://api.revenuecat.com";
3948
3948
  var Ue;
3949
3949
  (function(t) {
3950
3950
  t[t.CONTINUE = 100] = "CONTINUE", t[t.SWITCHING_PROTOCOLS = 101] = "SWITCHING_PROTOCOLS", t[t.PROCESSING = 102] = "PROCESSING", t[t.EARLY_HINTS = 103] = "EARLY_HINTS", t[t.OK = 200] = "OK", t[t.CREATED = 201] = "CREATED", t[t.ACCEPTED = 202] = "ACCEPTED", t[t.NON_AUTHORITATIVE_INFORMATION = 203] = "NON_AUTHORITATIVE_INFORMATION", t[t.NO_CONTENT = 204] = "NO_CONTENT", t[t.RESET_CONTENT = 205] = "RESET_CONTENT", t[t.PARTIAL_CONTENT = 206] = "PARTIAL_CONTENT", t[t.MULTI_STATUS = 207] = "MULTI_STATUS", t[t.MULTIPLE_CHOICES = 300] = "MULTIPLE_CHOICES", t[t.MOVED_PERMANENTLY = 301] = "MOVED_PERMANENTLY", t[t.MOVED_TEMPORARILY = 302] = "MOVED_TEMPORARILY", t[t.SEE_OTHER = 303] = "SEE_OTHER", t[t.NOT_MODIFIED = 304] = "NOT_MODIFIED", t[t.USE_PROXY = 305] = "USE_PROXY", t[t.TEMPORARY_REDIRECT = 307] = "TEMPORARY_REDIRECT", t[t.PERMANENT_REDIRECT = 308] = "PERMANENT_REDIRECT", t[t.BAD_REQUEST = 400] = "BAD_REQUEST", t[t.UNAUTHORIZED = 401] = "UNAUTHORIZED", t[t.PAYMENT_REQUIRED = 402] = "PAYMENT_REQUIRED", t[t.FORBIDDEN = 403] = "FORBIDDEN", t[t.NOT_FOUND = 404] = "NOT_FOUND", t[t.METHOD_NOT_ALLOWED = 405] = "METHOD_NOT_ALLOWED", t[t.NOT_ACCEPTABLE = 406] = "NOT_ACCEPTABLE", t[t.PROXY_AUTHENTICATION_REQUIRED = 407] = "PROXY_AUTHENTICATION_REQUIRED", t[t.REQUEST_TIMEOUT = 408] = "REQUEST_TIMEOUT", t[t.CONFLICT = 409] = "CONFLICT", t[t.GONE = 410] = "GONE", t[t.LENGTH_REQUIRED = 411] = "LENGTH_REQUIRED", t[t.PRECONDITION_FAILED = 412] = "PRECONDITION_FAILED", t[t.REQUEST_TOO_LONG = 413] = "REQUEST_TOO_LONG", t[t.REQUEST_URI_TOO_LONG = 414] = "REQUEST_URI_TOO_LONG", t[t.UNSUPPORTED_MEDIA_TYPE = 415] = "UNSUPPORTED_MEDIA_TYPE", t[t.REQUESTED_RANGE_NOT_SATISFIABLE = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE", t[t.EXPECTATION_FAILED = 417] = "EXPECTATION_FAILED", t[t.IM_A_TEAPOT = 418] = "IM_A_TEAPOT", t[t.INSUFFICIENT_SPACE_ON_RESOURCE = 419] = "INSUFFICIENT_SPACE_ON_RESOURCE", t[t.METHOD_FAILURE = 420] = "METHOD_FAILURE", t[t.MISDIRECTED_REQUEST = 421] = "MISDIRECTED_REQUEST", t[t.UNPROCESSABLE_ENTITY = 422] = "UNPROCESSABLE_ENTITY", t[t.LOCKED = 423] = "LOCKED", t[t.FAILED_DEPENDENCY = 424] = "FAILED_DEPENDENCY", t[t.UPGRADE_REQUIRED = 426] = "UPGRADE_REQUIRED", t[t.PRECONDITION_REQUIRED = 428] = "PRECONDITION_REQUIRED", t[t.TOO_MANY_REQUESTS = 429] = "TOO_MANY_REQUESTS", t[t.REQUEST_HEADER_FIELDS_TOO_LARGE = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE", t[t.UNAVAILABLE_FOR_LEGAL_REASONS = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS", t[t.INTERNAL_SERVER_ERROR = 500] = "INTERNAL_SERVER_ERROR", t[t.NOT_IMPLEMENTED = 501] = "NOT_IMPLEMENTED", t[t.BAD_GATEWAY = 502] = "BAD_GATEWAY", t[t.SERVICE_UNAVAILABLE = 503] = "SERVICE_UNAVAILABLE", t[t.GATEWAY_TIMEOUT = 504] = "GATEWAY_TIMEOUT", t[t.HTTP_VERSION_NOT_SUPPORTED = 505] = "HTTP_VERSION_NOT_SUPPORTED", t[t.INSUFFICIENT_STORAGE = 507] = "INSUFFICIENT_STORAGE", t[t.NETWORK_AUTHENTICATION_REQUIRED = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
@@ -5076,7 +5076,7 @@ function Ro(t) {
5076
5076
  return e;
5077
5077
  }
5078
5078
  function So(t) {
5079
- if (!t.startsWith("rcb_"))
5079
+ if (!/^rcb_[a-zA-Z0-9_.-]+$/.test(t))
5080
5080
  throw new X(
5081
5081
  te.InvalidCredentialsError,
5082
5082
  "Invalid API key. Use your RevenueCat Billing API key."
@@ -3,7 +3,7 @@
3
3
  -20px 0 #ffff;background:#fff2}50%{box-shadow:20px 0 #fff2,
4
4
  -20px 0 #fff2;background:#ffff}75%{box-shadow:20px 0 #ffff,
5
5
  -20px 0 #fff2;background:#fff2}100%{box-shadow:20px 0 #fff2,
6
- -20px 0 #fff2;background:#fff2}}`)}function ri(t){let e;return{c(){e=k("div"),_(e,"class","processing svelte-rjmul6")},m(r,n){p(r,e,n)},p:v,i:v,o:v,d(r){r&&g(e)}}}class $t extends U{constructor(e){super(),N(this,e,null,ri,Q,{},ni)}}function ii(t){S(t,"svelte-1wxt892",".rcb-stripe-elements-container.svelte-1wxt892{width:100%;margin-top:32px;margin-bottom:24px}")}function oi(t){let e,r;return e=new je({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p:v,i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function si(t){let e,r,n,i,o,s;function l(a){t[9](a)}let c={stripe:t[3],clientSecret:t[4],loader:"always",theme:"stripe",variables:{borderRadius:"12px",fontSizeBase:"16px",fontSizeSm:"16px",spacingGridRow:"16px",colorText:ve["grey-text-dark"],focusBoxShadow:"none",colorDanger:ve.error},rules:{".Input":{boxShadow:"none",border:`2px solid ${ve["grey-ui-dark"]}`},".Input:focus":{border:`2px solid ${ve.focus}`,outline:"none"},".Label":{marginBottom:"8px",fontWeight:"500",lineHeight:"22px"},".Input--invalid":{boxShadow:"none"}},$$slots:{default:[pi]},$$scope:{ctx:t}};return t[2]!==void 0&&(c.elements=t[2]),r=new xr({props:c}),Pe.push(()=>mn(r,"elements",l)),{c(){e=k("form"),w(r.$$.fragment)},m(a,f){p(a,e,f),I(r,e,null),i=!0,o||(s=Ae(e,"submit",lt(t[5])),o=!0)},p(a,f){const m={};f&8&&(m.stripe=a[3]),f&2051&&(m.$$scope={dirty:f,ctx:a}),!n&&f&4&&(n=!0,m.elements=a[2],un(()=>n=!1)),r.$set(m)},i(a){i||(u(r.$$.fragment,a),i=!0)},o(a){d(r.$$.fragment,a),i=!1},d(a){a&&g(e),b(r),o=!1,s()}}}function li(t){let e,r,n,i;return n=new ti({}),{c(){e=k("div"),e.textContent="Secure Checkout",r=T(),w(n.$$.fragment)},m(o,s){p(o,e,s),p(o,r,s),I(n,o,s),i=!0},p:v,i(o){i||(u(n.$$.fragment,o),i=!0)},o(o){d(n.$$.fragment,o),i=!1},d(o){o&&(g(e),g(r)),b(n,o)}}}function ci(t){let e,r,n;return r=new Sr({}),{c(){e=k("div"),w(r.$$.fragment),_(e,"class","rcb-stripe-elements-container svelte-1wxt892")},m(i,o){p(i,e,o),I(r,e,null),n=!0},p:v,i(i){n||(u(r.$$.fragment,i),n=!0)},o(i){d(r.$$.fragment,i),n=!1},d(i){i&&g(e),b(r)}}}function ai(t){let e;return{c(){e=R("Pay")},m(r,n){p(r,e,n)},i:v,o:v,d(r){r&&g(e)}}}function ui(t){let e,r;return e=new $t({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function fi(t){let e,r,n,i;const o=[ui,ai],s=[];function l(c,a){return c[0]?0:1}return e=l(t),r=s[e]=o[e](t),{c(){r.c(),n=ne()},m(c,a){s[e].m(c,a),p(c,n,a),i=!0},p(c,a){let f=e;e=l(c),e!==f&&(F(),d(s[f],1,1,()=>{s[f]=null}),G(),r=s[e],r||(r=s[e]=o[e](c),r.c()),u(r,1),r.m(n.parentNode,n))},i(c){i||(u(r),i=!0)},o(c){d(r),i=!1},d(c){c&&g(n),s[e].d(c)}}}function di(t){let e;return{c(){e=R("Close")},m(r,n){p(r,e,n)},d(r){r&&g(e)}}}function mi(t){let e,r,n,i;return e=new be({props:{disabled:t[0],$$slots:{default:[fi]},$$scope:{ctx:t}}}),n=new be({props:{disabled:t[0],intent:"secondary",$$slots:{default:[di]},$$scope:{ctx:t}}}),n.$on("click",function(){se(t[1])&&t[1].apply(this,arguments)}),{c(){w(e.$$.fragment),r=T(),w(n.$$.fragment)},m(o,s){I(e,o,s),p(o,r,s),I(n,o,s),i=!0},p(o,s){t=o;const l={};s&1&&(l.disabled=t[0]),s&2049&&(l.$$scope={dirty:s,ctx:t}),e.$set(l);const c={};s&1&&(c.disabled=t[0]),s&2048&&(c.$$scope={dirty:s,ctx:t}),n.$set(c)},i(o){i||(u(e.$$.fragment,o),u(n.$$.fragment,o),i=!0)},o(o){d(e.$$.fragment,o),d(n.$$.fragment,o),i=!1},d(o){o&&g(r),b(e,o),b(n,o)}}}function gi(t){let e,r;return e=new we({props:{$$slots:{default:[mi]},$$scope:{ctx:t}}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&2051&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function pi(t){let e,r,n,i,o,s;return e=new Ve({props:{$$slots:{default:[li]},$$scope:{ctx:t}}}),n=new ue({props:{$$slots:{default:[ci]},$$scope:{ctx:t}}}),o=new Je({props:{$$slots:{default:[gi]},$$scope:{ctx:t}}}),{c(){w(e.$$.fragment),r=T(),w(n.$$.fragment),i=T(),w(o.$$.fragment)},m(l,c){I(e,l,c),p(l,r,c),I(n,l,c),p(l,i,c),I(o,l,c),s=!0},p(l,c){const a={};c&2048&&(a.$$scope={dirty:c,ctx:l}),e.$set(a);const f={};c&2048&&(f.$$scope={dirty:c,ctx:l}),n.$set(f);const m={};c&2051&&(m.$$scope={dirty:c,ctx:l}),o.$set(m)},i(l){s||(u(e.$$.fragment,l),u(n.$$.fragment,l),u(o.$$.fragment,l),s=!0)},o(l){d(e.$$.fragment,l),d(n.$$.fragment,l),d(o.$$.fragment,l),s=!1},d(l){l&&(g(r),g(i)),b(e,l),b(n,l),b(o,l)}}}function _i(t){let e,r,n,i;const o=[si,oi],s=[];function l(c,a){return c[3]&&c[4]?0:1}return r=l(t),n=s[r]=o[r](t),{c(){e=k("div"),n.c()},m(c,a){p(c,e,a),s[r].m(e,null),i=!0},p(c,[a]){let f=r;r=l(c),r===f?s[r].p(c,a):(F(),d(s[f],1,1,()=>{s[f]=null}),G(),n=s[r],n?n.p(c,a):(n=s[r]=o[r](c),n.c()),u(n,1),n.m(e,null))},i(c){i||(u(n),i=!0)},o(c){d(n),i=!1},d(c){c&&g(e),s[r].d()}}}function Ai(t,e,r){let{onClose:n}=e,{onContinue:i}=e,{onError:o}=e,{paymentInfoCollectionMetadata:s}=e,{processing:l=!1}=e;const c=s.data.client_secret;let a=null,f,m;Me(async()=>{const A=s.data.publishable_api_key,M=s.data.stripe_account_id;if(!A||!M)throw new Error("Stripe publishable key or account ID not found");r(3,a=await Jr(A,{stripeAccount:M}))});const E=async()=>{if(l||!a||!m)return;r(0,l=!0);const A=await a.confirmSetup({elements:m,redirect:"if_required"});A.error?(r(0,l=!1),o(new j(O.StripeError,A.error.message))):i()};function y(A){f=A,r(2,f)}return t.$$set=A=>{"onClose"in A&&r(1,n=A.onClose),"onContinue"in A&&r(6,i=A.onContinue),"onError"in A&&r(7,o=A.onError),"paymentInfoCollectionMetadata"in A&&r(8,s=A.paymentInfoCollectionMetadata),"processing"in A&&r(0,l=A.processing)},t.$$.update=()=>{t.$$.dirty&4&&f&&f._elements.length>0&&(m=f)},[l,n,f,a,c,E,i,o,s,y]}class hi extends U{constructor(e){super(),N(this,e,Ai,_i,Q,{onClose:1,onContinue:6,onError:7,paymentInfoCollectionMetadata:8,processing:0},ii)}}function Ei(t){S(t,"svelte-favd20","form.svelte-favd20.svelte-favd20{display:flex;flex-direction:column;min-height:100%;flex-grow:1}.form-container.svelte-favd20.svelte-favd20{display:flex;flex-direction:column;width:100%;margin-top:32px;margin-bottom:16px}.form-label.svelte-favd20.svelte-favd20{margin-top:8px;margin-bottom:8px;display:block;font-weight:500;line-height:22px}.form-input.error.svelte-favd20 input.svelte-favd20{border-color:var(--rc-color-error)}.form-error.svelte-favd20.svelte-favd20{margin-top:4px;font-size:16px;line-height:20px;min-height:40px;color:var(--rc-color-error)}input.svelte-favd20.svelte-favd20{width:100%;box-sizing:border-box;padding:8px;border:2px solid var(--rc-color-grey-ui-dark);border-radius:12px;font-size:16px;height:48px;padding:6px 14px}input.svelte-favd20.svelte-favd20:focus{outline:none;border:2px solid var(--rc-color-focus)}")}function Ii(t){let e;return{c(){e=R("Billing email address")},m(r,n){p(r,e,n)},d(r){r&&g(e)}}}function vt(t){let e,r;return{c(){e=k("div"),r=R(t[2]),_(e,"class","form-error svelte-favd20")},m(n,i){p(n,e,i),D(e,r)},p(n,i){i&4&&ie(r,n[2])},d(n){n&&g(e)}}}function bi(t){let e,r,n,i,o,s,l,c,a,f=t[2]&&vt(t);return{c(){e=k("div"),r=k("div"),r.innerHTML='<label for="email">Email</label>',n=T(),i=k("div"),o=k("input"),l=T(),f&&f.c(),_(r,"class","form-label svelte-favd20"),_(o,"name","email"),_(o,"placeholder","john@appleseed.com"),_(o,"autocapitalize","off"),_(o,"class","svelte-favd20"),_(i,"class",s="form-input "+t[4]+" svelte-favd20"),_(e,"class","form-container svelte-favd20")},m(m,E){p(m,e,E),D(e,r),D(e,n),D(e,i),D(i,o),ct(o,t[3]),D(e,l),f&&f.m(e,null),c||(a=Ae(o,"input",t[7]),c=!0)},p(m,E){E&8&&o.value!==m[3]&&ct(o,m[3]),E&16&&s!==(s="form-input "+m[4]+" svelte-favd20")&&_(i,"class",s),m[2]?f?f.p(m,E):(f=vt(m),f.c(),f.m(e,null)):f&&(f.d(1),f=null)},d(m){m&&g(e),f&&f.d(),c=!1,a()}}}function wi(t){let e;return{c(){e=R("Continue")},m(r,n){p(r,e,n)},i:v,o:v,d(r){r&&g(e)}}}function ki(t){let e,r;return e=new $t({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function $i(t){let e,r,n,i;const o=[ki,wi],s=[];function l(c,a){return c[1]?0:1}return e=l(t),r=s[e]=o[e](t),{c(){r.c(),n=ne()},m(c,a){s[e].m(c,a),p(c,n,a),i=!0},p(c,a){let f=e;e=l(c),e!==f&&(F(),d(s[f],1,1,()=>{s[f]=null}),G(),r=s[e],r||(r=s[e]=o[e](c),r.c()),u(r,1),r.m(n.parentNode,n))},i(c){i||(u(r),i=!0)},o(c){d(r),i=!1},d(c){c&&g(n),s[e].d(c)}}}function vi(t){let e;return{c(){e=R("Close")},m(r,n){p(r,e,n)},d(r){r&&g(e)}}}function yi(t){let e,r,n,i;return e=new be({props:{disabled:t[1],$$slots:{default:[$i]},$$scope:{ctx:t}}}),n=new be({props:{intent:"secondary",disabled:t[1],$$slots:{default:[vi]},$$scope:{ctx:t}}}),n.$on("click",function(){se(t[0])&&t[0].apply(this,arguments)}),{c(){w(e.$$.fragment),r=T(),w(n.$$.fragment)},m(o,s){I(e,o,s),p(o,r,s),I(n,o,s),i=!0},p(o,s){t=o;const l={};s&2&&(l.disabled=t[1]),s&258&&(l.$$scope={dirty:s,ctx:t}),e.$set(l);const c={};s&2&&(c.disabled=t[1]),s&256&&(c.$$scope={dirty:s,ctx:t}),n.$set(c)},i(o){i||(u(e.$$.fragment,o),u(n.$$.fragment,o),i=!0)},o(o){d(e.$$.fragment,o),d(n.$$.fragment,o),i=!1},d(o){o&&g(r),b(e,o),b(n,o)}}}function Bi(t){let e,r;return e=new we({props:{$$slots:{default:[yi]},$$scope:{ctx:t}}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&259&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Di(t){let e,r,n,i,o,s,l,c,a;return r=new Ve({props:{$$slots:{default:[Ii]},$$scope:{ctx:t}}}),i=new ue({props:{$$slots:{default:[bi]},$$scope:{ctx:t}}}),s=new Je({props:{$$slots:{default:[Bi]},$$scope:{ctx:t}}}),{c(){e=k("form"),w(r.$$.fragment),n=T(),w(i.$$.fragment),o=T(),w(s.$$.fragment),_(e,"class","svelte-favd20")},m(f,m){p(f,e,m),I(r,e,null),D(e,n),I(i,e,null),D(e,o),I(s,e,null),l=!0,c||(a=Ae(e,"submit",lt(t[5])),c=!0)},p(f,[m]){const E={};m&256&&(E.$$scope={dirty:m,ctx:f}),r.$set(E);const y={};m&284&&(y.$$scope={dirty:m,ctx:f}),i.$set(y);const A={};m&259&&(A.$$scope={dirty:m,ctx:f}),s.$set(A)},i(f){l||(u(r.$$.fragment,f),u(i.$$.fragment,f),u(s.$$.fragment,f),l=!0)},o(f){d(r.$$.fragment,f),d(i.$$.fragment,f),d(s.$$.fragment,f),l=!1},d(f){f&&g(e),b(r),b(i),b(s),c=!1,a()}}}function Ci(t,e,r){let n,i,o,{onContinue:s}=e,{onClose:l}=e,{processing:c}=e;const a=async()=>{n.trim()===""?r(2,i="You need to provide your email address to continue."):s({email:n})};function f(){n=this.value,r(3,n)}return t.$$set=m=>{"onContinue"in m&&r(6,s=m.onContinue),"onClose"in m&&r(0,l=m.onClose),"processing"in m&&r(1,c=m.processing)},t.$$.update=()=>{t.$$.dirty&4&&r(4,o=i?"error":"")},r(3,n=""),r(2,i=""),[l,c,i,n,o,a,s,f]}class Mi extends U{constructor(e){super(),N(this,e,Ci,Di,Q,{onContinue:6,onClose:0,processing:1},Ei)}}function Pi(t){S(t,"svelte-17tslso",".rcb-modal-backdrop.svelte-17tslso{position:fixed;top:0;left:0;right:0;min-width:100%;width:100vw;width:100dvw;min-height:100%;height:100vh;height:100dvh;background-color:rgba(40, 40, 40, 0.75);display:flex;flex-direction:column;justify-content:space-around;z-index:1000001}")}function Qi(t){let e,r;const n=t[1].default,i=Y(n,t,t[0],null);return{c(){e=k("div"),i&&i.c(),_(e,"class","rcb-modal-backdrop svelte-17tslso")},m(o,s){p(o,e,s),i&&i.m(e,null),r=!0},p(o,[s]){i&&i.p&&(!r||s&1)&&K(i,n,o,o[0],r?H(n,o[0],s,null):q(o[0]),null)},i(o){r||(u(i,o),r=!0)},o(o){d(i,o),r=!1},d(o){o&&g(e),i&&i.d(o)}}}function Ti(t,e,r){let{$$slots:n={},$$scope:i}=e;return t.$$set=o=>{"$$scope"in o&&r(0,i=o.$$scope)},[i,n]}class Ni extends U{constructor(e){super(),N(this,e,Ti,Qi,Q,{},Pi)}}function Ui(t){S(t,"svelte-ioxu5d",".rcb-modal-container.svelte-ioxu5d{width:100%}.rcb-modal-main.svelte-ioxu5d{box-sizing:border-box;border-radius:8px;background-color:var(--rc-color-white);color:var(--rc-color-grey-text-dark);min-height:460px;padding:40px;flex-direction:column;display:flex}.rcb-modal-dark.svelte-ioxu5d{background-color:var(--rc-color-grey-text-dark);color:var(--rc-color-white);min-height:0px}@media screen and (max-width: 960px){.rcb-modal-container.svelte-ioxu5d{width:calc(100% - 32px);min-width:300px;max-width:640px;margin:auto}.rcb-modal-main.svelte-ioxu5d,.rcb-modal-dark.svelte-ioxu5d{min-width:300px;max-width:640px;padding:32px}}")}function Ri(t){let e,r,n,i;const o=t[2].default,s=Y(o,t,t[1],null);return{c(){e=k("div"),r=k("main"),s&&s.c(),_(r,"class",n=_e(`rcb-modal-main ${t[0]?"rcb-modal-dark":""}`)+" svelte-ioxu5d"),_(e,"class","rcb-modal-container svelte-ioxu5d")},m(l,c){p(l,e,c),D(e,r),s&&s.m(r,null),i=!0},p(l,[c]){s&&s.p&&(!i||c&2)&&K(s,o,l,l[1],i?H(o,l[1],c,null):q(l[1]),null),(!i||c&1&&n!==(n=_e(`rcb-modal-main ${l[0]?"rcb-modal-dark":""}`)+" svelte-ioxu5d"))&&_(r,"class",n)},i(l){i||(u(s,l),i=!0)},o(l){d(s,l),i=!1},d(l){l&&g(e),s&&s.d(l)}}}function Si(t,e,r){let{$$slots:n={},$$scope:i}=e,{dark:o=!1}=e;return t.$$set=s=>{"dark"in s&&r(0,o=s.dark),"$$scope"in s&&r(1,i=s.$$scope)},[o,i,n]}class Oi extends U{constructor(e){super(),N(this,e,Si,Ri,Q,{dark:0},Ui)}}function Li(t){let e;const r=t[1].default,n=Y(r,t,t[2],null);return{c(){n&&n.c()},m(i,o){n&&n.m(i,o),e=!0},p(i,o){n&&n.p&&(!e||o&4)&&K(n,r,i,i[2],e?H(r,i[2],o,null):q(i[2]),null)},i(i){e||(u(n,i),e=!0)},o(i){d(n,i),e=!1},d(i){n&&n.d(i)}}}function xi(t){let e,r;return e=new Ni({props:{$$slots:{default:[Fi]},$$scope:{ctx:t}}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&4&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Fi(t){let e;const r=t[1].default,n=Y(r,t,t[2],null);return{c(){n&&n.c()},m(i,o){n&&n.m(i,o),e=!0},p(i,o){n&&n.p&&(!e||o&4)&&K(n,r,i,i[2],e?H(r,i[2],o,null):q(i[2]),null)},i(i){e||(u(n,i),e=!0)},o(i){d(n,i),e=!1},d(i){n&&n.d(i)}}}function Gi(t){let e,r,n,i;const o=[xi,Li],s=[];function l(c,a){return c[0]?0:1}return e=l(t),r=s[e]=o[e](t),{c(){r.c(),n=ne()},m(c,a){s[e].m(c,a),p(c,n,a),i=!0},p(c,[a]){let f=e;e=l(c),e===f?s[e].p(c,a):(F(),d(s[f],1,1,()=>{s[f]=null}),G(),r=s[e],r?r.p(c,a):(r=s[e]=o[e](c),r.c()),u(r,1),r.m(n.parentNode,n))},i(c){i||(u(r),i=!0)},o(c){d(r),i=!1},d(c){c&&g(n),s[e].d(c)}}}function Yi(t,e,r){let{$$slots:n={},$$scope:i}=e,{condition:o=!1}=e;return t.$$set=s=>{"condition"in s&&r(0,o=s.condition),"$$scope"in s&&r(2,i=s.$$scope)},[o,n,i]}class Hi extends U{constructor(e){super(),N(this,e,Yi,Gi,Q,{condition:0})}}const Ki=t=>({}),yt=t=>({});function qi(t){let e,r;const n=t[1].header,i=Y(n,t,t[2],yt),o=t[1].default,s=Y(o,t,t[2],null);return{c(){i&&i.c(),e=T(),s&&s.c()},m(l,c){i&&i.m(l,c),p(l,e,c),s&&s.m(l,c),r=!0},p(l,c){i&&i.p&&(!r||c&4)&&K(i,n,l,l[2],r?H(n,l[2],c,Ki):q(l[2]),yt),s&&s.p&&(!r||c&4)&&K(s,o,l,l[2],r?H(o,l[2],c,null):q(l[2]),null)},i(l){r||(u(i,l),u(s,l),r=!0)},o(l){d(i,l),d(s,l),r=!1},d(l){l&&g(e),i&&i.d(l),s&&s.d(l)}}}function ji(t){let e,r;return e=new Oi({props:{dark:t[0],$$slots:{default:[qi]},$$scope:{ctx:t}}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,[i]){const o={};i&1&&(o.dark=n[0]),i&4&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Ji(t,e,r){let{$$slots:n={},$$scope:i}=e,{dark:o=!1}=e;return t.$$set=s=>{"dark"in s&&r(0,o=s.dark),"$$scope"in s&&r(2,i=s.$$scope)},[o,n,i]}class Bt extends U{constructor(e){super(),N(this,e,Ji,ji,Q,{dark:0})}}var re=(t=>(t[t.UnknownError=0]="UnknownError",t[t.UserCancelledError=1]="UserCancelledError",t[t.StoreProblemError=2]="StoreProblemError",t[t.PurchaseNotAllowedError=3]="PurchaseNotAllowedError",t[t.PurchaseInvalidError=4]="PurchaseInvalidError",t[t.ProductNotAvailableForPurchaseError=5]="ProductNotAvailableForPurchaseError",t[t.ProductAlreadyPurchasedError=6]="ProductAlreadyPurchasedError",t[t.ReceiptAlreadyInUseError=7]="ReceiptAlreadyInUseError",t[t.InvalidReceiptError=8]="InvalidReceiptError",t[t.MissingReceiptFileError=9]="MissingReceiptFileError",t[t.NetworkError=10]="NetworkError",t[t.InvalidCredentialsError=11]="InvalidCredentialsError",t[t.UnexpectedBackendResponseError=12]="UnexpectedBackendResponseError",t[t.InvalidAppUserIdError=14]="InvalidAppUserIdError",t[t.OperationAlreadyInProgressError=15]="OperationAlreadyInProgressError",t[t.UnknownBackendError=16]="UnknownBackendError",t[t.InvalidAppleSubscriptionKeyError=17]="InvalidAppleSubscriptionKeyError",t[t.IneligibleError=18]="IneligibleError",t[t.InsufficientPermissionsError=19]="InsufficientPermissionsError",t[t.PaymentPendingError=20]="PaymentPendingError",t[t.InvalidSubscriberAttributesError=21]="InvalidSubscriberAttributesError",t[t.LogOutWithAnonymousUserError=22]="LogOutWithAnonymousUserError",t[t.ConfigurationError=23]="ConfigurationError",t[t.UnsupportedError=24]="UnsupportedError",t[t.EmptySubscriberAttributesError=25]="EmptySubscriberAttributesError",t[t.CustomerInfoError=28]="CustomerInfoError",t[t.SignatureVerificationError=36]="SignatureVerificationError",t))(re||{});class ye{static getPublicMessage(e){switch(e){case 0:return"Unknown error.";case 1:return"Purchase was cancelled.";case 2:return"There was a problem with the store.";case 3:return"The device or user is not allowed to make the purchase.";case 4:return"One or more of the arguments provided are invalid.";case 5:return"The product is not available for purchase.";case 6:return"This product is already active for the user.";case 7:return"There is already another active subscriber using the same receipt.";case 8:return"The receipt is not valid.";case 9:return"The receipt is missing.";case 10:return"Error performing request.";case 11:return"There was a credentials issue. Check the underlying error for more details.";case 12:return"Received unexpected response from the backend.";case 14:return"The app user id is not valid.";case 15:return"The operation is already in progress.";case 16:return"There was an unknown backend error.";case 17:return"Apple Subscription Key is invalid or not present. In order to provide subscription offers, you must first generate a subscription key. Please see https://docs.revenuecat.com/docs/ios-subscription-offers for more info.";case 18:return"The User is ineligible for that action.";case 19:return"App does not have sufficient permissions to make purchases.";case 20:return"The payment is pending.";case 21:return"One or more of the attributes sent could not be saved.";case 22:return"Called logOut but the current user is anonymous.";case 23:return"There is an issue with your configuration. Check the underlying error for more details.";case 24:return"There was a problem with the operation. Looks like we doesn't support that yet. Check the underlying error for more details.";case 25:return"A request for subscriber attributes returned none.";case 28:return"There was a problem related to the customer info.";case 36:return"Request failed signature verification. Please see https://rev.cat/trusted-entitlements for more info."}}static getErrorCodeForBackendErrorCode(e){switch(e){case 7101:return 2;case 7102:return 7;case 7103:return 8;case 7107:case 7224:case 7225:return 11;case 7105:case 7106:return 4;case 7220:return 14;case 7229:return 2;case 7230:case 7e3:return 23;case 7231:return 2;case 7232:return 18;case 7263:case 7264:return 21;case 7104:case 7234:case 7226:case 7110:return 12;case 7662:return 24}}static convertCodeToBackendErrorCode(e){return e in Dt?e:null}static convertPurchaseFlowErrorCodeToErrorCode(e){switch(e){case O.ErrorSettingUpPurchase:return 2;case O.ErrorChargingPayment:return 20;case O.NetworkError:return 10;case O.MissingEmailError:return 4;case O.StripeError:return 2;case O.UnknownError:return 0}}}var Dt=(t=>(t[t.BackendInvalidPlatform=7e3]="BackendInvalidPlatform",t[t.BackendStoreProblem=7101]="BackendStoreProblem",t[t.BackendCannotTransferPurchase=7102]="BackendCannotTransferPurchase",t[t.BackendInvalidReceiptToken=7103]="BackendInvalidReceiptToken",t[t.BackendInvalidAppStoreSharedSecret=7104]="BackendInvalidAppStoreSharedSecret",t[t.BackendInvalidPaymentModeOrIntroPriceNotProvided=7105]="BackendInvalidPaymentModeOrIntroPriceNotProvided",t[t.BackendProductIdForGoogleReceiptNotProvided=7106]="BackendProductIdForGoogleReceiptNotProvided",t[t.BackendInvalidPlayStoreCredentials=7107]="BackendInvalidPlayStoreCredentials",t[t.BackendInternalServerError=7110]="BackendInternalServerError",t[t.BackendEmptyAppUserId=7220]="BackendEmptyAppUserId",t[t.BackendInvalidAuthToken=7224]="BackendInvalidAuthToken",t[t.BackendInvalidAPIKey=7225]="BackendInvalidAPIKey",t[t.BackendBadRequest=7226]="BackendBadRequest",t[t.BackendPlayStoreQuotaExceeded=7229]="BackendPlayStoreQuotaExceeded",t[t.BackendPlayStoreInvalidPackageName=7230]="BackendPlayStoreInvalidPackageName",t[t.BackendPlayStoreGenericError=7231]="BackendPlayStoreGenericError",t[t.BackendUserIneligibleForPromoOffer=7232]="BackendUserIneligibleForPromoOffer",t[t.BackendInvalidAppleSubscriptionKey=7234]="BackendInvalidAppleSubscriptionKey",t[t.BackendInvalidSubscriberAttributes=7263]="BackendInvalidSubscriberAttributes",t[t.BackendInvalidSubscriberAttributesBody=7264]="BackendInvalidSubscriberAttributesBody",t[t.BackendProductIDsMalformed=7662]="BackendProductIDsMalformed",t))(Dt||{});class X extends Error{constructor(r,n,i){super(n);P(this,"toString",()=>`PurchasesError(code: ${re[this.errorCode]}, message: ${this.message})`);this.errorCode=r,this.underlyingErrorMessage=i}static getForBackendError(r,n){const i=ye.getErrorCodeForBackendErrorCode(r);return new X(i,ye.getPublicMessage(i),n)}static getForPurchasesFlowError(r){return new X(ye.convertPurchaseFlowErrorCodeToErrorCode(r.errorCode),r.message,r.underlyingErrorMessage)}}class Ct extends Error{constructor(){super("Purchases must be configured before calling getInstance")}}const Vi="0.2.0",fe="https://api.revenuecat.com";var Se;(function(t){t[t.CONTINUE=100]="CONTINUE",t[t.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",t[t.PROCESSING=102]="PROCESSING",t[t.EARLY_HINTS=103]="EARLY_HINTS",t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.ACCEPTED=202]="ACCEPTED",t[t.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.RESET_CONTENT=205]="RESET_CONTENT",t[t.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",t[t.MULTI_STATUS=207]="MULTI_STATUS",t[t.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",t[t.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",t[t.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",t[t.SEE_OTHER=303]="SEE_OTHER",t[t.NOT_MODIFIED=304]="NOT_MODIFIED",t[t.USE_PROXY=305]="USE_PROXY",t[t.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",t[t.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.UNAUTHORIZED=401]="UNAUTHORIZED",t[t.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",t[t.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",t[t.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",t[t.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",t[t.CONFLICT=409]="CONFLICT",t[t.GONE=410]="GONE",t[t.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",t[t.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",t[t.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",t[t.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",t[t.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",t[t.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",t[t.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",t[t.IM_A_TEAPOT=418]="IM_A_TEAPOT",t[t.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",t[t.METHOD_FAILURE=420]="METHOD_FAILURE",t[t.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",t[t.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",t[t.LOCKED=423]="LOCKED",t[t.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",t[t.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",t[t.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",t[t.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",t[t.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",t[t.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",t[t.BAD_GATEWAY=502]="BAD_GATEWAY",t[t.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",t[t.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",t[t.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",t[t.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",t[t.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(Se||(Se={}));function We(t){return t?t.startsWith("rcb_sb_"):!1}async function de(t,e,r,n){try{const i=await fetch(t.url(),{method:t.method,headers:Xi(e,n),body:zi(r)});return await Wi(i,t),await i.json()}catch(i){throw i instanceof TypeError?new X(re.NetworkError,ye.getPublicMessage(re.NetworkError),i.message):i}}async function Wi(t,e){const r=t.status;if(r>=Se.INTERNAL_SERVER_ERROR)ze(e,r,await t.text());else if(r>=Se.BAD_REQUEST){const n=await t.json(),i=n?JSON.stringify(n):null,o=n==null?void 0:n.code,s=n==null?void 0:n.message;if(o!=null){const l=ye.convertCodeToBackendErrorCode(o);if(l==null)ze(e,r,i);else throw X.getForBackendError(l,s)}else ze(e,r,i)}}function ze(t,e,r){throw new X(re.UnknownBackendError,`Unknown backend error. Request: ${t.name}. Status code: ${e}. Body: ${r}.`)}function zi(t){return t==null?null:JSON.stringify(t)}function Xi(t,e){let r={Authorization:`Bearer ${t}`,"Content-Type":"application/json",Accept:"application/json","X-Platform":"web","X-Version":Vi,"X-Is-Sandbox":`${We(t)}`};return e!=null&&(r={...r,...e}),r}const Mt="/v1/subscribers",Oe="/rcbilling/v1";class Zi{constructor(e){P(this,"appUserId");P(this,"method","GET");P(this,"name","getOfferings");this.appUserId=e}url(){const e=encodeURIComponent(this.appUserId);return`${fe}${Mt}/${e}/offerings`}}class eo{constructor(){P(this,"method","POST");P(this,"name","subscribe")}url(){return`${fe}${Oe}/subscribe`}}class to{constructor(e,r){P(this,"method","GET");P(this,"name","getProducts");P(this,"appUserId");P(this,"productIds");this.appUserId=e,this.productIds=r}url(){const e=encodeURIComponent(this.appUserId),r=this.productIds.map(encodeURIComponent).join("&id=");return`${fe}${Oe}/subscribers/${e}/products?id=${r}`}}class no{constructor(e){P(this,"method","GET");P(this,"name","getCustomerInfo");P(this,"appUserId");this.appUserId=e}url(){const e=encodeURIComponent(this.appUserId);return`${fe}${Mt}/${e}`}}class ro{constructor(){P(this,"method","GET");P(this,"name","getBrandingInfo")}url(){return`${fe}${Oe}/branding`}}class io{constructor(e){P(this,"method","GET");P(this,"name","getCheckoutStatus");P(this,"operationSessionId");this.operationSessionId=e}url(){return`${fe}${Oe}/checkout/${this.operationSessionId}`}}class oo{constructor(e){P(this,"API_KEY");this.API_KEY=e}async getOfferings(e){return await de(new Zi(e),this.API_KEY)}async getCustomerInfo(e){return await de(new no(e),this.API_KEY)}async getProducts(e,r){return await de(new to(e,r),this.API_KEY)}async getBrandingInfo(){return await de(new ro,this.API_KEY)}async postSubscribe(e,r,n,i){return await de(new eo,this.API_KEY,{app_user_id:e,product_id:r,email:n,presented_offering_identifier:i})}async getCheckoutStatus(e){return await de(new io(e),this.API_KEY)}}const so="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20opacity='0.5'%20clip-path='url(%23clip0_344_3390)'%3e%3cpath%20d='M7%2018C5.9%2018%205.01%2018.9%205.01%2020C5.01%2021.1%205.9%2022%207%2022C8.1%2022%209%2021.1%209%2020C9%2018.9%208.1%2018%207%2018ZM1%202V4H3L6.6%2011.59L5.25%2014.04C5.09%2014.32%205%2014.65%205%2015C5%2016.1%205.9%2017%207%2017H19V15H7.42C7.28%2015%207.17%2014.89%207.17%2014.75L7.2%2014.63L8.1%2013H15.55C16.3%2013%2016.96%2012.59%2017.3%2011.97L20.88%205.48C20.96%205.34%2021%205.17%2021%205C21%204.45%2020.55%204%2020%204H5.21L4.27%202H1ZM17%2018C15.9%2018%2015.01%2018.9%2015.01%2020C15.01%2021.1%2015.9%2022%2017%2022C18.1%2022%2019%2021.1%2019%2020C19%2018.9%2018.1%2018%2017%2018Z'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_344_3390'%3e%3crect%20width='24'%20height='24'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";function lo(t){let e,r;return{c(){e=k("img"),te(e.src,r=so)||_(e,"src",r),_(e,"alt","icon"),_(e,"class","rcb-ui-asset-icon")},m(n,i){p(n,e,i)},p:v,i:v,o:v,d(n){n&&g(e)}}}class co extends U{constructor(e){super(),N(this,e,null,lo,Q,{})}}function ao(t){S(t,"svelte-1rhrjxe","div.svelte-1rhrjxe{background-color:var(--rc-color-warning);color:var(--rc-color-grey-text-dark);font-size:10px;font-weight:bold;text-transform:uppercase;padding:4px 10px;line-height:10px;border-radius:9px;margin:0px;margin-left:16px}")}function uo(t){let e;return{c(){e=k("div"),e.textContent="Sandbox",_(e,"class","svelte-1rhrjxe")},m(r,n){p(r,e,n)},p:v,i:v,o:v,d(r){r&&g(e)}}}class fo extends U{constructor(e){super(),N(this,e,null,uo,Q,{},ao)}}function mo(t){S(t,"svelte-13pdaik",`.rcb-ui-container.svelte-13pdaik{color-scheme:none;font-size:16px;line-height:1.5em;font-weight:400;font-family:-apple-system, "system-ui", "Segoe UI", Roboto, Oxygen, Ubuntu,
7
- Cantarell, "Open Sans", "Helvetica Neue", sans-serif}.rcb-ui-layout.svelte-13pdaik{width:100vw;width:100dvw;margin-right:auto;display:flex;justify-content:center;align-items:flex-start;position:relative;padding:0px 80px;box-sizing:border-box}.rcb-ui-aside.svelte-13pdaik{margin-right:16px;flex:320px 1 0;max-width:480px}.rcb-ui-main.svelte-13pdaik{flex:480px 1 0;max-width:640px}@media screen and (max-width: 960px){.rcb-ui-layout.svelte-13pdaik{flex-direction:column;align-items:center;justify-content:center;height:100%;min-width:100%}.rcb-ui-aside.svelte-13pdaik{margin-right:0;margin-bottom:16px;min-width:100%;display:flex;flex-direction:column;align-items:center;flex:none;max-width:none}.rcb-ui-main.svelte-13pdaik{flex:none;max-width:none;min-width:100%}}@media screen and (max-width: 960px) and (max-height: 960px){.rcb-ui-layout.svelte-13pdaik{overflow-y:scroll;justify-content:flex-start;padding:16px 0px}}`)}function Pt(t){let e,r,n;return r=new Bt({props:{dark:!0,$$slots:{header:[ho],default:[go]},$$scope:{ctx:t}}}),{c(){e=k("div"),w(r.$$.fragment),_(e,"class","rcb-ui-aside svelte-13pdaik")},m(i,o){p(i,e,o),I(r,e,null),n=!0},p(i,o){const s={};o&8388622&&(s.$$scope={dirty:o,ctx:i}),r.$set(s)},i(i){n||(u(r.$$.fragment,i),n=!0)},o(i){d(r.$$.fragment,i),n=!1},d(i){i&&g(e),b(r)}}}function Qt(t){let e,r;return e=new ft({props:{productDetails:t[2]}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&4&&(o.productDetails=n[2]),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function go(t){let e,r,n=t[2]&&Qt(t);return{c(){n&&n.c(),e=ne()},m(i,o){n&&n.m(i,o),p(i,e,o),r=!0},p(i,o){i[2]?n?(n.p(i,o),o&4&&u(n,1)):(n=Qt(i),n.c(),u(n,1),n.m(e.parentNode,e)):n&&(F(),d(n,1,1,()=>{n=null}),G())},i(i){r||(u(n),r=!0)},o(i){d(n),r=!1},d(i){i&&g(e),n&&n.d(i)}}}function po(t){let e,r;return e=new co({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function _o(t){let e,r;return e=new fo({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Ao(t){let e,r,n,i,o,s,l;e=new gt({props:{brandingInfo:t[3]}});const c=[_o,po],a=[];function f(m,E){return E&2&&(n=null),n==null&&(n=!!m[1].isSandbox()),n?0:1}return i=f(t,-1),o=a[i]=c[i](t),{c(){w(e.$$.fragment),r=T(),o.c(),s=ne()},m(m,E){I(e,m,E),p(m,r,E),a[i].m(m,E),p(m,s,E),l=!0},p(m,E){const y={};E&8&&(y.brandingInfo=m[3]),e.$set(y);let A=i;i=f(m,E),i!==A&&(F(),d(a[A],1,1,()=>{a[A]=null}),G(),o=a[i],o||(o=a[i]=c[i](m),o.c()),u(o,1),o.m(s.parentNode,s))},i(m){l||(u(e.$$.fragment,m),u(o),l=!0)},o(m){d(e.$$.fragment,m),d(o),l=!1},d(m){m&&(g(r),g(s)),b(e,m),a[i].d(m)}}}function ho(t){let e,r;return e=new Ve({props:{slot:"header",$$slots:{default:[Ao]},$$scope:{ctx:t}}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&8388618&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Tt(t){let e,r;return e=new ft({props:{productDetails:t[2]}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&4&&(o.productDetails=n[2]),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Nt(t){let e,r;return e=new je({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Ut(t){let e,r;return e=new Mi({props:{onContinue:t[10],onClose:t[9],processing:t[6]==="processing-auth-info"}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&64&&(o.processing=n[6]==="processing-auth-info"),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Rt(t){let e,r;return e=new hi({props:{paymentInfoCollectionMetadata:t[4],onContinue:t[10],onClose:t[9],onError:t[11],processing:t[6]==="polling-purchase-status"}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&16&&(o.paymentInfoCollectionMetadata=n[4]),i&64&&(o.processing=n[6]==="polling-purchase-status"),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function St(t){let e,r;return e=new je({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Ot(t){var n;let e,r;return e=new wr({props:{brandingInfo:t[3],lastError:t[5]??new j(O.UnknownError,"Unknown error without state set."),supportEmail:(n=t[3])==null?void 0:n.seller_company_support_email,onContinue:t[12]}}),{c(){w(e.$$.fragment)},m(i,o){I(e,i,o),r=!0},p(i,o){var l;const s={};o&8&&(s.brandingInfo=i[3]),o&32&&(s.lastError=i[5]??new j(O.UnknownError,"Unknown error without state set.")),o&8&&(s.supportEmail=(l=i[3])==null?void 0:l.seller_company_support_email),e.$set(s)},i(i){r||(u(e.$$.fragment,i),r=!0)},o(i){d(e.$$.fragment,i),r=!1},d(i){b(e,i)}}}function Lt(t){let e,r;return e=new Pr({props:{brandingInfo:t[3],onContinue:t[10]}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&8&&(o.brandingInfo=n[3]),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Eo(t){let e,r,n,i,o,s,l,c,a=t[6]==="present-offer"&&t[2]&&Tt(t),f=t[6]==="present-offer"&&!t[2]&&Nt(),m=(t[6]==="needs-auth-info"||t[6]==="processing-auth-info")&&Ut(t),E=t[4]&&(t[6]==="needs-payment-info"||t[6]==="polling-purchase-status")&&Rt(t),y=t[6]==="loading"&&St(),A=t[6]==="error"&&Ot(t),M=t[6]==="success"&&Lt(t);return{c(){a&&a.c(),e=T(),f&&f.c(),r=T(),m&&m.c(),n=T(),E&&E.c(),i=T(),y&&y.c(),o=T(),A&&A.c(),s=T(),M&&M.c(),l=ne()},m(h,B){a&&a.m(h,B),p(h,e,B),f&&f.m(h,B),p(h,r,B),m&&m.m(h,B),p(h,n,B),E&&E.m(h,B),p(h,i,B),y&&y.m(h,B),p(h,o,B),A&&A.m(h,B),p(h,s,B),M&&M.m(h,B),p(h,l,B),c=!0},p(h,B){h[6]==="present-offer"&&h[2]?a?(a.p(h,B),B&68&&u(a,1)):(a=Tt(h),a.c(),u(a,1),a.m(e.parentNode,e)):a&&(F(),d(a,1,1,()=>{a=null}),G()),h[6]==="present-offer"&&!h[2]?f?B&68&&u(f,1):(f=Nt(),f.c(),u(f,1),f.m(r.parentNode,r)):f&&(F(),d(f,1,1,()=>{f=null}),G()),h[6]==="needs-auth-info"||h[6]==="processing-auth-info"?m?(m.p(h,B),B&64&&u(m,1)):(m=Ut(h),m.c(),u(m,1),m.m(n.parentNode,n)):m&&(F(),d(m,1,1,()=>{m=null}),G()),h[4]&&(h[6]==="needs-payment-info"||h[6]==="polling-purchase-status")?E?(E.p(h,B),B&80&&u(E,1)):(E=Rt(h),E.c(),u(E,1),E.m(i.parentNode,i)):E&&(F(),d(E,1,1,()=>{E=null}),G()),h[6]==="loading"?y?B&64&&u(y,1):(y=St(),y.c(),u(y,1),y.m(o.parentNode,o)):y&&(F(),d(y,1,1,()=>{y=null}),G()),h[6]==="error"?A?(A.p(h,B),B&64&&u(A,1)):(A=Ot(h),A.c(),u(A,1),A.m(s.parentNode,s)):A&&(F(),d(A,1,1,()=>{A=null}),G()),h[6]==="success"?M?(M.p(h,B),B&64&&u(M,1)):(M=Lt(h),M.c(),u(M,1),M.m(l.parentNode,l)):M&&(F(),d(M,1,1,()=>{M=null}),G())},i(h){c||(u(a),u(f),u(m),u(E),u(y),u(A),u(M),c=!0)},o(h){d(a),d(f),d(m),d(E),d(y),d(A),d(M),c=!1},d(h){h&&(g(e),g(r),g(n),g(i),g(o),g(s),g(l)),a&&a.d(h),f&&f.d(h),m&&m.d(h),E&&E.d(h),y&&y.d(h),A&&A.d(h),M&&M.d(h)}}}function Io(t){let e,r=t[8].includes(t[6]),n,i,o,s,l=r&&Pt(t);return o=new Bt({props:{$$slots:{default:[Eo]},$$scope:{ctx:t}}}),{c(){e=k("div"),l&&l.c(),n=T(),i=k("div"),w(o.$$.fragment),_(i,"class","rcb-ui-main svelte-13pdaik"),_(e,"class","rcb-ui-layout svelte-13pdaik"),_(e,"style",t[7])},m(c,a){p(c,e,a),l&&l.m(e,null),D(e,n),D(e,i),I(o,i,null),s=!0},p(c,a){a&64&&(r=c[8].includes(c[6])),r?l?(l.p(c,a),a&64&&u(l,1)):(l=Pt(c),l.c(),u(l,1),l.m(e,n)):l&&(F(),d(l,1,1,()=>{l=null}),G());const f={};a&8388732&&(f.$$scope={dirty:a,ctx:c}),o.$set(f)},i(c){s||(u(l),u(o.$$.fragment,c),s=!0)},o(c){d(l),d(o.$$.fragment,c),s=!1},d(c){c&&g(e),l&&l.d(),b(o)}}}function bo(t){let e,r,n;return r=new Hi({props:{condition:t[0],$$slots:{default:[Io]},$$scope:{ctx:t}}}),{c(){e=k("div"),w(r.$$.fragment),_(e,"class","rcb-ui-container svelte-13pdaik")},m(i,o){p(i,e,o),I(r,e,null),n=!0},p(i,[o]){const s={};o&1&&(s.condition=i[0]),o&8388734&&(s.$$scope={dirty:o,ctx:i}),r.$set(s)},i(i){n||(u(r.$$.fragment,i),n=!0)},o(i){d(r.$$.fragment,i),n=!1},d(i){i&&g(e),b(r)}}}function wo(t,e,r){var xt;let{asModal:n=!0}=e,{customerEmail:i}=e,{appUserId:o}=e,{rcPackage:s}=e,{onFinished:l}=e,{onError:c}=e,{onClose:a}=e,{purchases:f}=e,{backend:m}=e,{purchaseOperationHelper:E}=e;const y=Object.entries(ve).map(([C,Ze])=>`--rc-color-${C}: ${Ze}`).join("; ");let A=null,M=null,h=null,B=null;const J=((xt=s.rcBillingProduct)==null?void 0:xt.identifier)??null;let $="present-offer";const Be=["present-offer","needs-auth-info","processing-auth-info","needs-payment-info","polling-purchase-status","loading"];Me(async()=>{if(r(2,A=s.rcBillingProduct),r(3,M=await m.getBrandingInfo()),$==="present-offer"){i?me():r(6,$="needs-auth-info");return}});const xe=()=>{a()},me=()=>{if(J===null){Z(new j(O.ErrorSettingUpPurchase,"Product ID was not set before purchase."));return}else $==="present-offer"&&r(6,$="loading");if(!i){Z(new j(O.MissingEmailError));return}E.startPurchase(o,J,i,s.rcBillingProduct.presentedOfferingIdentifier).then(C=>{if(C.next_action==="collect_payment_info"){r(6,$="needs-payment-info"),r(4,h=C);return}if(C.next_action==="completed"){r(6,$="success");return}}).catch(C=>{Z(new j(O.ErrorSettingUpPurchase,C.message,C.underlyingErrorMessage))})},ee=C=>{if($==="needs-auth-info"){C&&(r(13,i=C.email),r(6,$="processing-auth-info")),me();return}if($==="needs-payment-info"){r(6,$="polling-purchase-status"),E.pollCurrentPurchaseForCompletion().then(()=>{r(6,$="success")}).catch(Ze=>{Z(Ze)});return}if($==="success"||$==="error"){l();return}r(6,$="success")},Z=C=>{r(5,B=C),r(6,$="error")},So=()=>{c(B??new j(O.UnknownError,"Unknown error without state set."))};return t.$$set=C=>{"asModal"in C&&r(0,n=C.asModal),"customerEmail"in C&&r(13,i=C.customerEmail),"appUserId"in C&&r(14,o=C.appUserId),"rcPackage"in C&&r(15,s=C.rcPackage),"onFinished"in C&&r(16,l=C.onFinished),"onError"in C&&r(17,c=C.onError),"onClose"in C&&r(18,a=C.onClose),"purchases"in C&&r(1,f=C.purchases),"backend"in C&&r(19,m=C.backend),"purchaseOperationHelper"in C&&r(20,E=C.purchaseOperationHelper)},[n,f,A,M,h,B,$,y,Be,xe,ee,Z,So,i,o,s,l,c,a,m,E]}class ko extends U{constructor(e){super(),N(this,e,wo,bo,Q,{asModal:0,customerEmail:13,appUserId:14,rcPackage:15,onFinished:16,onError:17,onClose:18,purchases:1,backend:19,purchaseOperationHelper:20},mo)}}function $o(t){return t.expires_date==null?!0:new Date(t.expires_date)>new Date}function vo(t,e,r,n){const i=e.product_identifier;if(i in r)return yo(t,e,r[i]);if(i in n)return Bo(t,e,n[i]);throw new X(re.CustomerInfoError,"Could not find entitlement product in subscriptions or non-subscriptions.")}function yo(t,e,r){return{identifier:t,isActive:$o(e),willRenew:Mo(e,r),store:(r==null?void 0:r.store)??"unknown",latestPurchaseDate:new Date(e.purchase_date),originalPurchaseDate:new Date(e.purchase_date),expirationDate:Le(e.expires_date),productIdentifier:e.product_identifier,unsubscribeDetectedAt:Le(r==null?void 0:r.unsubscribe_detected_at),billingIssueDetectedAt:Le(r==null?void 0:r.billing_issues_detected_at),isSandbox:(r==null?void 0:r.is_sandbox)??!1,periodType:(r==null?void 0:r.period_type)??"normal"}}function Bo(t,e,r){return{identifier:t,isActive:!0,willRenew:!1,store:r.store,latestPurchaseDate:new Date(e.purchase_date),originalPurchaseDate:new Date(r.original_purchase_date),expirationDate:null,productIdentifier:e.product_identifier,unsubscribeDetectedAt:null,billingIssueDetectedAt:null,isSandbox:r.is_sandbox,periodType:"normal"}}function Do(t,e,r){const n={},i={};for(const o in t){const s=vo(o,t[o],e,r);n[o]=s,s.isActive&&(i[o]=s)}return{all:n,active:i}}function Le(t){return t==null?null:new Date(t)}function Co(t){const e=Qo(t),r=t.subscriber,n=No(r.non_subscriptions);return{entitlements:Do(r.entitlements,r.subscriptions,n),allExpirationDatesByProduct:e,allPurchaseDatesByProduct:Po(t,n),activeSubscriptions:To(e),managementURL:r.management_url,requestDate:new Date(t.request_date),firstSeenDate:new Date(r.first_seen),originalPurchaseDate:Le(r.original_purchase_date),originalAppUserId:t.subscriber.original_app_user_id}}function Mo(t,e){if(e==null)return!1;const r=e.store=="promotional",n=t.expires_date==null,i=e.unsubscribe_detected_at!=null,o=e.billing_issues_detected_at!=null;return!(r||n||i||o)}function Po(t,e){const r={};for(const n in t.subscriber.subscriptions){const i=t.subscriber.subscriptions[n];r[n]=new Date(i.purchase_date)}for(const n in e){const i=e[n].purchase_date;i==null?r[n]=null:r[n]=new Date(i)}return r}function Qo(t){const e={};for(const r in t.subscriber.subscriptions){const n=t.subscriber.subscriptions[r];n.expires_date==null?e[r]=null:e[r]=new Date(n.expires_date)}return e}function To(t){const e=new Set,r=new Date;for(const n in t){const i=t[n];(i==null||i>r)&&e.add(n)}return e}function No(t){const e={};for(const r in t){if(t[r].length===0)continue;const n=t[r].length;e[r]=t[r][n-1]}return e}function Uo(t){if(!t.startsWith("rcb_"))throw new X(re.InvalidCredentialsError,"Invalid API key. Use your RevenueCat Billing API key.")}function Ro(t){if(new Set(["no_user","null","none","nil","(null)","NaN","\\x00","","unidentified","undefined","unknown"]).has(t)||t.includes("/"))throw new X(re.InvalidAppUserIdError,'Provided user id: "'+t+'" is not valid. See https://www.revenuecat.com/docs/customers/user-ids#tips-for-setting-app-user-ids for more information.')}const z=class z{constructor(e,r){P(this,"_API_KEY");P(this,"_appUserId");P(this,"backend");P(this,"purchaseOperationHelper");P(this,"toOfferings",(e,r)=>{const n=e.offerings.find(l=>l.identifier===e.current_offering_id)??null,i={};r.product_details.forEach(l=>{i[l.identifier]=l});const o=n==null?null:nt(n,i),s={};return e.offerings.forEach(l=>{const c=nt(l,i);c!=null&&(s[l.identifier]=c)}),Object.keys(s).length==0&&W.debugLog("Empty offerings. Please make sure you've configured offerings correctly in the RevenueCat dashboard and that the products are properly configured."),{all:s,current:o}});this._API_KEY=e,this._appUserId=r,We(e)&&W.debugLog("Initializing Purchases SDK with sandbox API Key"),this.backend=new oo(this._API_KEY),this.purchaseOperationHelper=new Dn(this.backend)}static setLogLevel(e){W.setLogLevel(e)}static getSharedInstance(){if(z.isConfigured())return z.instance;throw new Ct}static isConfigured(){return z.instance!==void 0}static configure(e,r){return z.instance!==void 0?(W.warnLog("Purchases is already initialized. Ignoring and returning existing instance."),z.getSharedInstance()):(Uo(e),Ro(r),z.instance=new z(e,r),z.getSharedInstance())}async getOfferings(){const e=this._appUserId,r=await this.backend.getOfferings(e),n=r.offerings.flatMap(o=>o.packages).map(o=>o.platform_product_identifier),i=await this.backend.getProducts(e,n);return this.logMissingProductIds(n,i.product_details),this.toOfferings(r,i)}async isEntitledTo(e){const r=await this.getCustomerInfo();return e in r.entitlements.active}purchasePackage(e,r,n){let i=n??document.getElementById("rcb-ui-root");if(i===null){const c=document.createElement("div");c.className="rcb-ui-root",document.body.appendChild(c),i=c}if(i===null)throw new Error("Could not generate a mount point for the billing widget");const o=i,s=!n,l=this._appUserId;return W.debugLog(`Presenting purchase form for package ${e.identifier}`),new Promise((c,a)=>{new ko({target:o,props:{appUserId:l,rcPackage:e,customerEmail:r,onFinished:async()=>{W.debugLog("Purchase finished"),o.innerHTML="",c({customerInfo:await this._getCustomerInfoForUserId(l)})},onClose:()=>{o.innerHTML="",W.debugLog("Purchase cancelled by user"),a(new X(re.UserCancelledError))},onError:f=>{o.innerHTML="",a(X.getForPurchasesFlowError(f))},purchases:this,backend:this.backend,purchaseOperationHelper:this.purchaseOperationHelper,asModal:s}})})}async getCustomerInfo(){return await this._getCustomerInfoForUserId(this._appUserId)}getAppUserId(){return this._appUserId}async changeUser(e){return this._appUserId=e,await this.getCustomerInfo()}logMissingProductIds(e,r){const n={};r.forEach(o=>n[o.identifier]=o);const i=[];e.forEach(o=>{n[o]===void 0&&i.push(o)}),i.length>0&&W.debugLog(`Could not find product data for product ids:
6
+ -20px 0 #fff2;background:#fff2}}`)}function ri(t){let e;return{c(){e=k("div"),_(e,"class","processing svelte-rjmul6")},m(r,n){p(r,e,n)},p:v,i:v,o:v,d(r){r&&g(e)}}}class $t extends U{constructor(e){super(),N(this,e,null,ri,Q,{},ni)}}function ii(t){S(t,"svelte-1wxt892",".rcb-stripe-elements-container.svelte-1wxt892{width:100%;margin-top:32px;margin-bottom:24px}")}function oi(t){let e,r;return e=new je({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p:v,i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function si(t){let e,r,n,i,o,s;function l(a){t[9](a)}let c={stripe:t[3],clientSecret:t[4],loader:"always",theme:"stripe",variables:{borderRadius:"12px",fontSizeBase:"16px",fontSizeSm:"16px",spacingGridRow:"16px",colorText:ve["grey-text-dark"],focusBoxShadow:"none",colorDanger:ve.error},rules:{".Input":{boxShadow:"none",border:`2px solid ${ve["grey-ui-dark"]}`},".Input:focus":{border:`2px solid ${ve.focus}`,outline:"none"},".Label":{marginBottom:"8px",fontWeight:"500",lineHeight:"22px"},".Input--invalid":{boxShadow:"none"}},$$slots:{default:[pi]},$$scope:{ctx:t}};return t[2]!==void 0&&(c.elements=t[2]),r=new xr({props:c}),Pe.push(()=>mn(r,"elements",l)),{c(){e=k("form"),w(r.$$.fragment)},m(a,f){p(a,e,f),I(r,e,null),i=!0,o||(s=Ae(e,"submit",lt(t[5])),o=!0)},p(a,f){const m={};f&8&&(m.stripe=a[3]),f&2051&&(m.$$scope={dirty:f,ctx:a}),!n&&f&4&&(n=!0,m.elements=a[2],un(()=>n=!1)),r.$set(m)},i(a){i||(u(r.$$.fragment,a),i=!0)},o(a){d(r.$$.fragment,a),i=!1},d(a){a&&g(e),b(r),o=!1,s()}}}function li(t){let e,r,n,i;return n=new ti({}),{c(){e=k("div"),e.textContent="Secure Checkout",r=T(),w(n.$$.fragment)},m(o,s){p(o,e,s),p(o,r,s),I(n,o,s),i=!0},p:v,i(o){i||(u(n.$$.fragment,o),i=!0)},o(o){d(n.$$.fragment,o),i=!1},d(o){o&&(g(e),g(r)),b(n,o)}}}function ci(t){let e,r,n;return r=new Sr({}),{c(){e=k("div"),w(r.$$.fragment),_(e,"class","rcb-stripe-elements-container svelte-1wxt892")},m(i,o){p(i,e,o),I(r,e,null),n=!0},p:v,i(i){n||(u(r.$$.fragment,i),n=!0)},o(i){d(r.$$.fragment,i),n=!1},d(i){i&&g(e),b(r)}}}function ai(t){let e;return{c(){e=R("Pay")},m(r,n){p(r,e,n)},i:v,o:v,d(r){r&&g(e)}}}function ui(t){let e,r;return e=new $t({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function fi(t){let e,r,n,i;const o=[ui,ai],s=[];function l(c,a){return c[0]?0:1}return e=l(t),r=s[e]=o[e](t),{c(){r.c(),n=ne()},m(c,a){s[e].m(c,a),p(c,n,a),i=!0},p(c,a){let f=e;e=l(c),e!==f&&(F(),d(s[f],1,1,()=>{s[f]=null}),G(),r=s[e],r||(r=s[e]=o[e](c),r.c()),u(r,1),r.m(n.parentNode,n))},i(c){i||(u(r),i=!0)},o(c){d(r),i=!1},d(c){c&&g(n),s[e].d(c)}}}function di(t){let e;return{c(){e=R("Close")},m(r,n){p(r,e,n)},d(r){r&&g(e)}}}function mi(t){let e,r,n,i;return e=new be({props:{disabled:t[0],$$slots:{default:[fi]},$$scope:{ctx:t}}}),n=new be({props:{disabled:t[0],intent:"secondary",$$slots:{default:[di]},$$scope:{ctx:t}}}),n.$on("click",function(){se(t[1])&&t[1].apply(this,arguments)}),{c(){w(e.$$.fragment),r=T(),w(n.$$.fragment)},m(o,s){I(e,o,s),p(o,r,s),I(n,o,s),i=!0},p(o,s){t=o;const l={};s&1&&(l.disabled=t[0]),s&2049&&(l.$$scope={dirty:s,ctx:t}),e.$set(l);const c={};s&1&&(c.disabled=t[0]),s&2048&&(c.$$scope={dirty:s,ctx:t}),n.$set(c)},i(o){i||(u(e.$$.fragment,o),u(n.$$.fragment,o),i=!0)},o(o){d(e.$$.fragment,o),d(n.$$.fragment,o),i=!1},d(o){o&&g(r),b(e,o),b(n,o)}}}function gi(t){let e,r;return e=new we({props:{$$slots:{default:[mi]},$$scope:{ctx:t}}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&2051&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function pi(t){let e,r,n,i,o,s;return e=new Ve({props:{$$slots:{default:[li]},$$scope:{ctx:t}}}),n=new ue({props:{$$slots:{default:[ci]},$$scope:{ctx:t}}}),o=new Je({props:{$$slots:{default:[gi]},$$scope:{ctx:t}}}),{c(){w(e.$$.fragment),r=T(),w(n.$$.fragment),i=T(),w(o.$$.fragment)},m(l,c){I(e,l,c),p(l,r,c),I(n,l,c),p(l,i,c),I(o,l,c),s=!0},p(l,c){const a={};c&2048&&(a.$$scope={dirty:c,ctx:l}),e.$set(a);const f={};c&2048&&(f.$$scope={dirty:c,ctx:l}),n.$set(f);const m={};c&2051&&(m.$$scope={dirty:c,ctx:l}),o.$set(m)},i(l){s||(u(e.$$.fragment,l),u(n.$$.fragment,l),u(o.$$.fragment,l),s=!0)},o(l){d(e.$$.fragment,l),d(n.$$.fragment,l),d(o.$$.fragment,l),s=!1},d(l){l&&(g(r),g(i)),b(e,l),b(n,l),b(o,l)}}}function _i(t){let e,r,n,i;const o=[si,oi],s=[];function l(c,a){return c[3]&&c[4]?0:1}return r=l(t),n=s[r]=o[r](t),{c(){e=k("div"),n.c()},m(c,a){p(c,e,a),s[r].m(e,null),i=!0},p(c,[a]){let f=r;r=l(c),r===f?s[r].p(c,a):(F(),d(s[f],1,1,()=>{s[f]=null}),G(),n=s[r],n?n.p(c,a):(n=s[r]=o[r](c),n.c()),u(n,1),n.m(e,null))},i(c){i||(u(n),i=!0)},o(c){d(n),i=!1},d(c){c&&g(e),s[r].d()}}}function Ai(t,e,r){let{onClose:n}=e,{onContinue:i}=e,{onError:o}=e,{paymentInfoCollectionMetadata:s}=e,{processing:l=!1}=e;const c=s.data.client_secret;let a=null,f,m;Me(async()=>{const A=s.data.publishable_api_key,M=s.data.stripe_account_id;if(!A||!M)throw new Error("Stripe publishable key or account ID not found");r(3,a=await Jr(A,{stripeAccount:M}))});const E=async()=>{if(l||!a||!m)return;r(0,l=!0);const A=await a.confirmSetup({elements:m,redirect:"if_required"});A.error?(r(0,l=!1),o(new j(O.StripeError,A.error.message))):i()};function y(A){f=A,r(2,f)}return t.$$set=A=>{"onClose"in A&&r(1,n=A.onClose),"onContinue"in A&&r(6,i=A.onContinue),"onError"in A&&r(7,o=A.onError),"paymentInfoCollectionMetadata"in A&&r(8,s=A.paymentInfoCollectionMetadata),"processing"in A&&r(0,l=A.processing)},t.$$.update=()=>{t.$$.dirty&4&&f&&f._elements.length>0&&(m=f)},[l,n,f,a,c,E,i,o,s,y]}class hi extends U{constructor(e){super(),N(this,e,Ai,_i,Q,{onClose:1,onContinue:6,onError:7,paymentInfoCollectionMetadata:8,processing:0},ii)}}function Ei(t){S(t,"svelte-favd20","form.svelte-favd20.svelte-favd20{display:flex;flex-direction:column;min-height:100%;flex-grow:1}.form-container.svelte-favd20.svelte-favd20{display:flex;flex-direction:column;width:100%;margin-top:32px;margin-bottom:16px}.form-label.svelte-favd20.svelte-favd20{margin-top:8px;margin-bottom:8px;display:block;font-weight:500;line-height:22px}.form-input.error.svelte-favd20 input.svelte-favd20{border-color:var(--rc-color-error)}.form-error.svelte-favd20.svelte-favd20{margin-top:4px;font-size:16px;line-height:20px;min-height:40px;color:var(--rc-color-error)}input.svelte-favd20.svelte-favd20{width:100%;box-sizing:border-box;padding:8px;border:2px solid var(--rc-color-grey-ui-dark);border-radius:12px;font-size:16px;height:48px;padding:6px 14px}input.svelte-favd20.svelte-favd20:focus{outline:none;border:2px solid var(--rc-color-focus)}")}function Ii(t){let e;return{c(){e=R("Billing email address")},m(r,n){p(r,e,n)},d(r){r&&g(e)}}}function vt(t){let e,r;return{c(){e=k("div"),r=R(t[2]),_(e,"class","form-error svelte-favd20")},m(n,i){p(n,e,i),D(e,r)},p(n,i){i&4&&ie(r,n[2])},d(n){n&&g(e)}}}function bi(t){let e,r,n,i,o,s,l,c,a,f=t[2]&&vt(t);return{c(){e=k("div"),r=k("div"),r.innerHTML='<label for="email">Email</label>',n=T(),i=k("div"),o=k("input"),l=T(),f&&f.c(),_(r,"class","form-label svelte-favd20"),_(o,"name","email"),_(o,"placeholder","john@appleseed.com"),_(o,"autocapitalize","off"),_(o,"class","svelte-favd20"),_(i,"class",s="form-input "+t[4]+" svelte-favd20"),_(e,"class","form-container svelte-favd20")},m(m,E){p(m,e,E),D(e,r),D(e,n),D(e,i),D(i,o),ct(o,t[3]),D(e,l),f&&f.m(e,null),c||(a=Ae(o,"input",t[7]),c=!0)},p(m,E){E&8&&o.value!==m[3]&&ct(o,m[3]),E&16&&s!==(s="form-input "+m[4]+" svelte-favd20")&&_(i,"class",s),m[2]?f?f.p(m,E):(f=vt(m),f.c(),f.m(e,null)):f&&(f.d(1),f=null)},d(m){m&&g(e),f&&f.d(),c=!1,a()}}}function wi(t){let e;return{c(){e=R("Continue")},m(r,n){p(r,e,n)},i:v,o:v,d(r){r&&g(e)}}}function ki(t){let e,r;return e=new $t({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function $i(t){let e,r,n,i;const o=[ki,wi],s=[];function l(c,a){return c[1]?0:1}return e=l(t),r=s[e]=o[e](t),{c(){r.c(),n=ne()},m(c,a){s[e].m(c,a),p(c,n,a),i=!0},p(c,a){let f=e;e=l(c),e!==f&&(F(),d(s[f],1,1,()=>{s[f]=null}),G(),r=s[e],r||(r=s[e]=o[e](c),r.c()),u(r,1),r.m(n.parentNode,n))},i(c){i||(u(r),i=!0)},o(c){d(r),i=!1},d(c){c&&g(n),s[e].d(c)}}}function vi(t){let e;return{c(){e=R("Close")},m(r,n){p(r,e,n)},d(r){r&&g(e)}}}function yi(t){let e,r,n,i;return e=new be({props:{disabled:t[1],$$slots:{default:[$i]},$$scope:{ctx:t}}}),n=new be({props:{intent:"secondary",disabled:t[1],$$slots:{default:[vi]},$$scope:{ctx:t}}}),n.$on("click",function(){se(t[0])&&t[0].apply(this,arguments)}),{c(){w(e.$$.fragment),r=T(),w(n.$$.fragment)},m(o,s){I(e,o,s),p(o,r,s),I(n,o,s),i=!0},p(o,s){t=o;const l={};s&2&&(l.disabled=t[1]),s&258&&(l.$$scope={dirty:s,ctx:t}),e.$set(l);const c={};s&2&&(c.disabled=t[1]),s&256&&(c.$$scope={dirty:s,ctx:t}),n.$set(c)},i(o){i||(u(e.$$.fragment,o),u(n.$$.fragment,o),i=!0)},o(o){d(e.$$.fragment,o),d(n.$$.fragment,o),i=!1},d(o){o&&g(r),b(e,o),b(n,o)}}}function Bi(t){let e,r;return e=new we({props:{$$slots:{default:[yi]},$$scope:{ctx:t}}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&259&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Di(t){let e,r,n,i,o,s,l,c,a;return r=new Ve({props:{$$slots:{default:[Ii]},$$scope:{ctx:t}}}),i=new ue({props:{$$slots:{default:[bi]},$$scope:{ctx:t}}}),s=new Je({props:{$$slots:{default:[Bi]},$$scope:{ctx:t}}}),{c(){e=k("form"),w(r.$$.fragment),n=T(),w(i.$$.fragment),o=T(),w(s.$$.fragment),_(e,"class","svelte-favd20")},m(f,m){p(f,e,m),I(r,e,null),D(e,n),I(i,e,null),D(e,o),I(s,e,null),l=!0,c||(a=Ae(e,"submit",lt(t[5])),c=!0)},p(f,[m]){const E={};m&256&&(E.$$scope={dirty:m,ctx:f}),r.$set(E);const y={};m&284&&(y.$$scope={dirty:m,ctx:f}),i.$set(y);const A={};m&259&&(A.$$scope={dirty:m,ctx:f}),s.$set(A)},i(f){l||(u(r.$$.fragment,f),u(i.$$.fragment,f),u(s.$$.fragment,f),l=!0)},o(f){d(r.$$.fragment,f),d(i.$$.fragment,f),d(s.$$.fragment,f),l=!1},d(f){f&&g(e),b(r),b(i),b(s),c=!1,a()}}}function Ci(t,e,r){let n,i,o,{onContinue:s}=e,{onClose:l}=e,{processing:c}=e;const a=async()=>{n.trim()===""?r(2,i="You need to provide your email address to continue."):s({email:n})};function f(){n=this.value,r(3,n)}return t.$$set=m=>{"onContinue"in m&&r(6,s=m.onContinue),"onClose"in m&&r(0,l=m.onClose),"processing"in m&&r(1,c=m.processing)},t.$$.update=()=>{t.$$.dirty&4&&r(4,o=i?"error":"")},r(3,n=""),r(2,i=""),[l,c,i,n,o,a,s,f]}class Mi extends U{constructor(e){super(),N(this,e,Ci,Di,Q,{onContinue:6,onClose:0,processing:1},Ei)}}function Pi(t){S(t,"svelte-17tslso",".rcb-modal-backdrop.svelte-17tslso{position:fixed;top:0;left:0;right:0;min-width:100%;width:100vw;width:100dvw;min-height:100%;height:100vh;height:100dvh;background-color:rgba(40, 40, 40, 0.75);display:flex;flex-direction:column;justify-content:space-around;z-index:1000001}")}function Qi(t){let e,r;const n=t[1].default,i=Y(n,t,t[0],null);return{c(){e=k("div"),i&&i.c(),_(e,"class","rcb-modal-backdrop svelte-17tslso")},m(o,s){p(o,e,s),i&&i.m(e,null),r=!0},p(o,[s]){i&&i.p&&(!r||s&1)&&K(i,n,o,o[0],r?H(n,o[0],s,null):q(o[0]),null)},i(o){r||(u(i,o),r=!0)},o(o){d(i,o),r=!1},d(o){o&&g(e),i&&i.d(o)}}}function Ti(t,e,r){let{$$slots:n={},$$scope:i}=e;return t.$$set=o=>{"$$scope"in o&&r(0,i=o.$$scope)},[i,n]}class Ni extends U{constructor(e){super(),N(this,e,Ti,Qi,Q,{},Pi)}}function Ui(t){S(t,"svelte-ioxu5d",".rcb-modal-container.svelte-ioxu5d{width:100%}.rcb-modal-main.svelte-ioxu5d{box-sizing:border-box;border-radius:8px;background-color:var(--rc-color-white);color:var(--rc-color-grey-text-dark);min-height:460px;padding:40px;flex-direction:column;display:flex}.rcb-modal-dark.svelte-ioxu5d{background-color:var(--rc-color-grey-text-dark);color:var(--rc-color-white);min-height:0px}@media screen and (max-width: 960px){.rcb-modal-container.svelte-ioxu5d{width:calc(100% - 32px);min-width:300px;max-width:640px;margin:auto}.rcb-modal-main.svelte-ioxu5d,.rcb-modal-dark.svelte-ioxu5d{min-width:300px;max-width:640px;padding:32px}}")}function Ri(t){let e,r,n,i;const o=t[2].default,s=Y(o,t,t[1],null);return{c(){e=k("div"),r=k("main"),s&&s.c(),_(r,"class",n=_e(`rcb-modal-main ${t[0]?"rcb-modal-dark":""}`)+" svelte-ioxu5d"),_(e,"class","rcb-modal-container svelte-ioxu5d")},m(l,c){p(l,e,c),D(e,r),s&&s.m(r,null),i=!0},p(l,[c]){s&&s.p&&(!i||c&2)&&K(s,o,l,l[1],i?H(o,l[1],c,null):q(l[1]),null),(!i||c&1&&n!==(n=_e(`rcb-modal-main ${l[0]?"rcb-modal-dark":""}`)+" svelte-ioxu5d"))&&_(r,"class",n)},i(l){i||(u(s,l),i=!0)},o(l){d(s,l),i=!1},d(l){l&&g(e),s&&s.d(l)}}}function Si(t,e,r){let{$$slots:n={},$$scope:i}=e,{dark:o=!1}=e;return t.$$set=s=>{"dark"in s&&r(0,o=s.dark),"$$scope"in s&&r(1,i=s.$$scope)},[o,i,n]}class Oi extends U{constructor(e){super(),N(this,e,Si,Ri,Q,{dark:0},Ui)}}function Li(t){let e;const r=t[1].default,n=Y(r,t,t[2],null);return{c(){n&&n.c()},m(i,o){n&&n.m(i,o),e=!0},p(i,o){n&&n.p&&(!e||o&4)&&K(n,r,i,i[2],e?H(r,i[2],o,null):q(i[2]),null)},i(i){e||(u(n,i),e=!0)},o(i){d(n,i),e=!1},d(i){n&&n.d(i)}}}function xi(t){let e,r;return e=new Ni({props:{$$slots:{default:[Fi]},$$scope:{ctx:t}}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&4&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Fi(t){let e;const r=t[1].default,n=Y(r,t,t[2],null);return{c(){n&&n.c()},m(i,o){n&&n.m(i,o),e=!0},p(i,o){n&&n.p&&(!e||o&4)&&K(n,r,i,i[2],e?H(r,i[2],o,null):q(i[2]),null)},i(i){e||(u(n,i),e=!0)},o(i){d(n,i),e=!1},d(i){n&&n.d(i)}}}function Gi(t){let e,r,n,i;const o=[xi,Li],s=[];function l(c,a){return c[0]?0:1}return e=l(t),r=s[e]=o[e](t),{c(){r.c(),n=ne()},m(c,a){s[e].m(c,a),p(c,n,a),i=!0},p(c,[a]){let f=e;e=l(c),e===f?s[e].p(c,a):(F(),d(s[f],1,1,()=>{s[f]=null}),G(),r=s[e],r?r.p(c,a):(r=s[e]=o[e](c),r.c()),u(r,1),r.m(n.parentNode,n))},i(c){i||(u(r),i=!0)},o(c){d(r),i=!1},d(c){c&&g(n),s[e].d(c)}}}function Yi(t,e,r){let{$$slots:n={},$$scope:i}=e,{condition:o=!1}=e;return t.$$set=s=>{"condition"in s&&r(0,o=s.condition),"$$scope"in s&&r(2,i=s.$$scope)},[o,n,i]}class Hi extends U{constructor(e){super(),N(this,e,Yi,Gi,Q,{condition:0})}}const Ki=t=>({}),yt=t=>({});function qi(t){let e,r;const n=t[1].header,i=Y(n,t,t[2],yt),o=t[1].default,s=Y(o,t,t[2],null);return{c(){i&&i.c(),e=T(),s&&s.c()},m(l,c){i&&i.m(l,c),p(l,e,c),s&&s.m(l,c),r=!0},p(l,c){i&&i.p&&(!r||c&4)&&K(i,n,l,l[2],r?H(n,l[2],c,Ki):q(l[2]),yt),s&&s.p&&(!r||c&4)&&K(s,o,l,l[2],r?H(o,l[2],c,null):q(l[2]),null)},i(l){r||(u(i,l),u(s,l),r=!0)},o(l){d(i,l),d(s,l),r=!1},d(l){l&&g(e),i&&i.d(l),s&&s.d(l)}}}function ji(t){let e,r;return e=new Oi({props:{dark:t[0],$$slots:{default:[qi]},$$scope:{ctx:t}}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,[i]){const o={};i&1&&(o.dark=n[0]),i&4&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Ji(t,e,r){let{$$slots:n={},$$scope:i}=e,{dark:o=!1}=e;return t.$$set=s=>{"dark"in s&&r(0,o=s.dark),"$$scope"in s&&r(2,i=s.$$scope)},[o,n,i]}class Bt extends U{constructor(e){super(),N(this,e,Ji,ji,Q,{dark:0})}}var re=(t=>(t[t.UnknownError=0]="UnknownError",t[t.UserCancelledError=1]="UserCancelledError",t[t.StoreProblemError=2]="StoreProblemError",t[t.PurchaseNotAllowedError=3]="PurchaseNotAllowedError",t[t.PurchaseInvalidError=4]="PurchaseInvalidError",t[t.ProductNotAvailableForPurchaseError=5]="ProductNotAvailableForPurchaseError",t[t.ProductAlreadyPurchasedError=6]="ProductAlreadyPurchasedError",t[t.ReceiptAlreadyInUseError=7]="ReceiptAlreadyInUseError",t[t.InvalidReceiptError=8]="InvalidReceiptError",t[t.MissingReceiptFileError=9]="MissingReceiptFileError",t[t.NetworkError=10]="NetworkError",t[t.InvalidCredentialsError=11]="InvalidCredentialsError",t[t.UnexpectedBackendResponseError=12]="UnexpectedBackendResponseError",t[t.InvalidAppUserIdError=14]="InvalidAppUserIdError",t[t.OperationAlreadyInProgressError=15]="OperationAlreadyInProgressError",t[t.UnknownBackendError=16]="UnknownBackendError",t[t.InvalidAppleSubscriptionKeyError=17]="InvalidAppleSubscriptionKeyError",t[t.IneligibleError=18]="IneligibleError",t[t.InsufficientPermissionsError=19]="InsufficientPermissionsError",t[t.PaymentPendingError=20]="PaymentPendingError",t[t.InvalidSubscriberAttributesError=21]="InvalidSubscriberAttributesError",t[t.LogOutWithAnonymousUserError=22]="LogOutWithAnonymousUserError",t[t.ConfigurationError=23]="ConfigurationError",t[t.UnsupportedError=24]="UnsupportedError",t[t.EmptySubscriberAttributesError=25]="EmptySubscriberAttributesError",t[t.CustomerInfoError=28]="CustomerInfoError",t[t.SignatureVerificationError=36]="SignatureVerificationError",t))(re||{});class ye{static getPublicMessage(e){switch(e){case 0:return"Unknown error.";case 1:return"Purchase was cancelled.";case 2:return"There was a problem with the store.";case 3:return"The device or user is not allowed to make the purchase.";case 4:return"One or more of the arguments provided are invalid.";case 5:return"The product is not available for purchase.";case 6:return"This product is already active for the user.";case 7:return"There is already another active subscriber using the same receipt.";case 8:return"The receipt is not valid.";case 9:return"The receipt is missing.";case 10:return"Error performing request.";case 11:return"There was a credentials issue. Check the underlying error for more details.";case 12:return"Received unexpected response from the backend.";case 14:return"The app user id is not valid.";case 15:return"The operation is already in progress.";case 16:return"There was an unknown backend error.";case 17:return"Apple Subscription Key is invalid or not present. In order to provide subscription offers, you must first generate a subscription key. Please see https://docs.revenuecat.com/docs/ios-subscription-offers for more info.";case 18:return"The User is ineligible for that action.";case 19:return"App does not have sufficient permissions to make purchases.";case 20:return"The payment is pending.";case 21:return"One or more of the attributes sent could not be saved.";case 22:return"Called logOut but the current user is anonymous.";case 23:return"There is an issue with your configuration. Check the underlying error for more details.";case 24:return"There was a problem with the operation. Looks like we doesn't support that yet. Check the underlying error for more details.";case 25:return"A request for subscriber attributes returned none.";case 28:return"There was a problem related to the customer info.";case 36:return"Request failed signature verification. Please see https://rev.cat/trusted-entitlements for more info."}}static getErrorCodeForBackendErrorCode(e){switch(e){case 7101:return 2;case 7102:return 7;case 7103:return 8;case 7107:case 7224:case 7225:return 11;case 7105:case 7106:return 4;case 7220:return 14;case 7229:return 2;case 7230:case 7e3:return 23;case 7231:return 2;case 7232:return 18;case 7263:case 7264:return 21;case 7104:case 7234:case 7226:case 7110:return 12;case 7662:return 24}}static convertCodeToBackendErrorCode(e){return e in Dt?e:null}static convertPurchaseFlowErrorCodeToErrorCode(e){switch(e){case O.ErrorSettingUpPurchase:return 2;case O.ErrorChargingPayment:return 20;case O.NetworkError:return 10;case O.MissingEmailError:return 4;case O.StripeError:return 2;case O.UnknownError:return 0}}}var Dt=(t=>(t[t.BackendInvalidPlatform=7e3]="BackendInvalidPlatform",t[t.BackendStoreProblem=7101]="BackendStoreProblem",t[t.BackendCannotTransferPurchase=7102]="BackendCannotTransferPurchase",t[t.BackendInvalidReceiptToken=7103]="BackendInvalidReceiptToken",t[t.BackendInvalidAppStoreSharedSecret=7104]="BackendInvalidAppStoreSharedSecret",t[t.BackendInvalidPaymentModeOrIntroPriceNotProvided=7105]="BackendInvalidPaymentModeOrIntroPriceNotProvided",t[t.BackendProductIdForGoogleReceiptNotProvided=7106]="BackendProductIdForGoogleReceiptNotProvided",t[t.BackendInvalidPlayStoreCredentials=7107]="BackendInvalidPlayStoreCredentials",t[t.BackendInternalServerError=7110]="BackendInternalServerError",t[t.BackendEmptyAppUserId=7220]="BackendEmptyAppUserId",t[t.BackendInvalidAuthToken=7224]="BackendInvalidAuthToken",t[t.BackendInvalidAPIKey=7225]="BackendInvalidAPIKey",t[t.BackendBadRequest=7226]="BackendBadRequest",t[t.BackendPlayStoreQuotaExceeded=7229]="BackendPlayStoreQuotaExceeded",t[t.BackendPlayStoreInvalidPackageName=7230]="BackendPlayStoreInvalidPackageName",t[t.BackendPlayStoreGenericError=7231]="BackendPlayStoreGenericError",t[t.BackendUserIneligibleForPromoOffer=7232]="BackendUserIneligibleForPromoOffer",t[t.BackendInvalidAppleSubscriptionKey=7234]="BackendInvalidAppleSubscriptionKey",t[t.BackendInvalidSubscriberAttributes=7263]="BackendInvalidSubscriberAttributes",t[t.BackendInvalidSubscriberAttributesBody=7264]="BackendInvalidSubscriberAttributesBody",t[t.BackendProductIDsMalformed=7662]="BackendProductIDsMalformed",t))(Dt||{});class X extends Error{constructor(r,n,i){super(n);P(this,"toString",()=>`PurchasesError(code: ${re[this.errorCode]}, message: ${this.message})`);this.errorCode=r,this.underlyingErrorMessage=i}static getForBackendError(r,n){const i=ye.getErrorCodeForBackendErrorCode(r);return new X(i,ye.getPublicMessage(i),n)}static getForPurchasesFlowError(r){return new X(ye.convertPurchaseFlowErrorCodeToErrorCode(r.errorCode),r.message,r.underlyingErrorMessage)}}class Ct extends Error{constructor(){super("Purchases must be configured before calling getInstance")}}const Vi="0.2.2",fe="https://api.revenuecat.com";var Se;(function(t){t[t.CONTINUE=100]="CONTINUE",t[t.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",t[t.PROCESSING=102]="PROCESSING",t[t.EARLY_HINTS=103]="EARLY_HINTS",t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.ACCEPTED=202]="ACCEPTED",t[t.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.RESET_CONTENT=205]="RESET_CONTENT",t[t.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",t[t.MULTI_STATUS=207]="MULTI_STATUS",t[t.MULTIPLE_CHOICES=300]="MULTIPLE_CHOICES",t[t.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",t[t.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",t[t.SEE_OTHER=303]="SEE_OTHER",t[t.NOT_MODIFIED=304]="NOT_MODIFIED",t[t.USE_PROXY=305]="USE_PROXY",t[t.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",t[t.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.UNAUTHORIZED=401]="UNAUTHORIZED",t[t.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",t[t.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",t[t.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",t[t.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",t[t.CONFLICT=409]="CONFLICT",t[t.GONE=410]="GONE",t[t.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",t[t.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",t[t.REQUEST_TOO_LONG=413]="REQUEST_TOO_LONG",t[t.REQUEST_URI_TOO_LONG=414]="REQUEST_URI_TOO_LONG",t[t.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",t[t.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",t[t.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",t[t.IM_A_TEAPOT=418]="IM_A_TEAPOT",t[t.INSUFFICIENT_SPACE_ON_RESOURCE=419]="INSUFFICIENT_SPACE_ON_RESOURCE",t[t.METHOD_FAILURE=420]="METHOD_FAILURE",t[t.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",t[t.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",t[t.LOCKED=423]="LOCKED",t[t.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",t[t.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",t[t.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",t[t.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="REQUEST_HEADER_FIELDS_TOO_LARGE",t[t.UNAVAILABLE_FOR_LEGAL_REASONS=451]="UNAVAILABLE_FOR_LEGAL_REASONS",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",t[t.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",t[t.BAD_GATEWAY=502]="BAD_GATEWAY",t[t.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",t[t.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",t[t.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",t[t.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",t[t.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(Se||(Se={}));function We(t){return t?t.startsWith("rcb_sb_"):!1}async function de(t,e,r,n){try{const i=await fetch(t.url(),{method:t.method,headers:Xi(e,n),body:zi(r)});return await Wi(i,t),await i.json()}catch(i){throw i instanceof TypeError?new X(re.NetworkError,ye.getPublicMessage(re.NetworkError),i.message):i}}async function Wi(t,e){const r=t.status;if(r>=Se.INTERNAL_SERVER_ERROR)ze(e,r,await t.text());else if(r>=Se.BAD_REQUEST){const n=await t.json(),i=n?JSON.stringify(n):null,o=n==null?void 0:n.code,s=n==null?void 0:n.message;if(o!=null){const l=ye.convertCodeToBackendErrorCode(o);if(l==null)ze(e,r,i);else throw X.getForBackendError(l,s)}else ze(e,r,i)}}function ze(t,e,r){throw new X(re.UnknownBackendError,`Unknown backend error. Request: ${t.name}. Status code: ${e}. Body: ${r}.`)}function zi(t){return t==null?null:JSON.stringify(t)}function Xi(t,e){let r={Authorization:`Bearer ${t}`,"Content-Type":"application/json",Accept:"application/json","X-Platform":"web","X-Version":Vi,"X-Is-Sandbox":`${We(t)}`};return e!=null&&(r={...r,...e}),r}const Mt="/v1/subscribers",Oe="/rcbilling/v1";class Zi{constructor(e){P(this,"appUserId");P(this,"method","GET");P(this,"name","getOfferings");this.appUserId=e}url(){const e=encodeURIComponent(this.appUserId);return`${fe}${Mt}/${e}/offerings`}}class eo{constructor(){P(this,"method","POST");P(this,"name","subscribe")}url(){return`${fe}${Oe}/subscribe`}}class to{constructor(e,r){P(this,"method","GET");P(this,"name","getProducts");P(this,"appUserId");P(this,"productIds");this.appUserId=e,this.productIds=r}url(){const e=encodeURIComponent(this.appUserId),r=this.productIds.map(encodeURIComponent).join("&id=");return`${fe}${Oe}/subscribers/${e}/products?id=${r}`}}class no{constructor(e){P(this,"method","GET");P(this,"name","getCustomerInfo");P(this,"appUserId");this.appUserId=e}url(){const e=encodeURIComponent(this.appUserId);return`${fe}${Mt}/${e}`}}class ro{constructor(){P(this,"method","GET");P(this,"name","getBrandingInfo")}url(){return`${fe}${Oe}/branding`}}class io{constructor(e){P(this,"method","GET");P(this,"name","getCheckoutStatus");P(this,"operationSessionId");this.operationSessionId=e}url(){return`${fe}${Oe}/checkout/${this.operationSessionId}`}}class oo{constructor(e){P(this,"API_KEY");this.API_KEY=e}async getOfferings(e){return await de(new Zi(e),this.API_KEY)}async getCustomerInfo(e){return await de(new no(e),this.API_KEY)}async getProducts(e,r){return await de(new to(e,r),this.API_KEY)}async getBrandingInfo(){return await de(new ro,this.API_KEY)}async postSubscribe(e,r,n,i){return await de(new eo,this.API_KEY,{app_user_id:e,product_id:r,email:n,presented_offering_identifier:i})}async getCheckoutStatus(e){return await de(new io(e),this.API_KEY)}}const so="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20opacity='0.5'%20clip-path='url(%23clip0_344_3390)'%3e%3cpath%20d='M7%2018C5.9%2018%205.01%2018.9%205.01%2020C5.01%2021.1%205.9%2022%207%2022C8.1%2022%209%2021.1%209%2020C9%2018.9%208.1%2018%207%2018ZM1%202V4H3L6.6%2011.59L5.25%2014.04C5.09%2014.32%205%2014.65%205%2015C5%2016.1%205.9%2017%207%2017H19V15H7.42C7.28%2015%207.17%2014.89%207.17%2014.75L7.2%2014.63L8.1%2013H15.55C16.3%2013%2016.96%2012.59%2017.3%2011.97L20.88%205.48C20.96%205.34%2021%205.17%2021%205C21%204.45%2020.55%204%2020%204H5.21L4.27%202H1ZM17%2018C15.9%2018%2015.01%2018.9%2015.01%2020C15.01%2021.1%2015.9%2022%2017%2022C18.1%2022%2019%2021.1%2019%2020C19%2018.9%2018.1%2018%2017%2018Z'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_344_3390'%3e%3crect%20width='24'%20height='24'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";function lo(t){let e,r;return{c(){e=k("img"),te(e.src,r=so)||_(e,"src",r),_(e,"alt","icon"),_(e,"class","rcb-ui-asset-icon")},m(n,i){p(n,e,i)},p:v,i:v,o:v,d(n){n&&g(e)}}}class co extends U{constructor(e){super(),N(this,e,null,lo,Q,{})}}function ao(t){S(t,"svelte-1rhrjxe","div.svelte-1rhrjxe{background-color:var(--rc-color-warning);color:var(--rc-color-grey-text-dark);font-size:10px;font-weight:bold;text-transform:uppercase;padding:4px 10px;line-height:10px;border-radius:9px;margin:0px;margin-left:16px}")}function uo(t){let e;return{c(){e=k("div"),e.textContent="Sandbox",_(e,"class","svelte-1rhrjxe")},m(r,n){p(r,e,n)},p:v,i:v,o:v,d(r){r&&g(e)}}}class fo extends U{constructor(e){super(),N(this,e,null,uo,Q,{},ao)}}function mo(t){S(t,"svelte-13pdaik",`.rcb-ui-container.svelte-13pdaik{color-scheme:none;font-size:16px;line-height:1.5em;font-weight:400;font-family:-apple-system, "system-ui", "Segoe UI", Roboto, Oxygen, Ubuntu,
7
+ Cantarell, "Open Sans", "Helvetica Neue", sans-serif}.rcb-ui-layout.svelte-13pdaik{width:100vw;width:100dvw;margin-right:auto;display:flex;justify-content:center;align-items:flex-start;position:relative;padding:0px 80px;box-sizing:border-box}.rcb-ui-aside.svelte-13pdaik{margin-right:16px;flex:320px 1 0;max-width:480px}.rcb-ui-main.svelte-13pdaik{flex:480px 1 0;max-width:640px}@media screen and (max-width: 960px){.rcb-ui-layout.svelte-13pdaik{flex-direction:column;align-items:center;justify-content:center;height:100%;min-width:100%}.rcb-ui-aside.svelte-13pdaik{margin-right:0;margin-bottom:16px;min-width:100%;display:flex;flex-direction:column;align-items:center;flex:none;max-width:none}.rcb-ui-main.svelte-13pdaik{flex:none;max-width:none;min-width:100%}}@media screen and (max-width: 960px) and (max-height: 960px){.rcb-ui-layout.svelte-13pdaik{overflow-y:scroll;justify-content:flex-start;padding:16px 0px}}`)}function Pt(t){let e,r,n;return r=new Bt({props:{dark:!0,$$slots:{header:[ho],default:[go]},$$scope:{ctx:t}}}),{c(){e=k("div"),w(r.$$.fragment),_(e,"class","rcb-ui-aside svelte-13pdaik")},m(i,o){p(i,e,o),I(r,e,null),n=!0},p(i,o){const s={};o&8388622&&(s.$$scope={dirty:o,ctx:i}),r.$set(s)},i(i){n||(u(r.$$.fragment,i),n=!0)},o(i){d(r.$$.fragment,i),n=!1},d(i){i&&g(e),b(r)}}}function Qt(t){let e,r;return e=new ft({props:{productDetails:t[2]}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&4&&(o.productDetails=n[2]),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function go(t){let e,r,n=t[2]&&Qt(t);return{c(){n&&n.c(),e=ne()},m(i,o){n&&n.m(i,o),p(i,e,o),r=!0},p(i,o){i[2]?n?(n.p(i,o),o&4&&u(n,1)):(n=Qt(i),n.c(),u(n,1),n.m(e.parentNode,e)):n&&(F(),d(n,1,1,()=>{n=null}),G())},i(i){r||(u(n),r=!0)},o(i){d(n),r=!1},d(i){i&&g(e),n&&n.d(i)}}}function po(t){let e,r;return e=new co({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function _o(t){let e,r;return e=new fo({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Ao(t){let e,r,n,i,o,s,l;e=new gt({props:{brandingInfo:t[3]}});const c=[_o,po],a=[];function f(m,E){return E&2&&(n=null),n==null&&(n=!!m[1].isSandbox()),n?0:1}return i=f(t,-1),o=a[i]=c[i](t),{c(){w(e.$$.fragment),r=T(),o.c(),s=ne()},m(m,E){I(e,m,E),p(m,r,E),a[i].m(m,E),p(m,s,E),l=!0},p(m,E){const y={};E&8&&(y.brandingInfo=m[3]),e.$set(y);let A=i;i=f(m,E),i!==A&&(F(),d(a[A],1,1,()=>{a[A]=null}),G(),o=a[i],o||(o=a[i]=c[i](m),o.c()),u(o,1),o.m(s.parentNode,s))},i(m){l||(u(e.$$.fragment,m),u(o),l=!0)},o(m){d(e.$$.fragment,m),d(o),l=!1},d(m){m&&(g(r),g(s)),b(e,m),a[i].d(m)}}}function ho(t){let e,r;return e=new Ve({props:{slot:"header",$$slots:{default:[Ao]},$$scope:{ctx:t}}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&8388618&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Tt(t){let e,r;return e=new ft({props:{productDetails:t[2]}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&4&&(o.productDetails=n[2]),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Nt(t){let e,r;return e=new je({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Ut(t){let e,r;return e=new Mi({props:{onContinue:t[10],onClose:t[9],processing:t[6]==="processing-auth-info"}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&64&&(o.processing=n[6]==="processing-auth-info"),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Rt(t){let e,r;return e=new hi({props:{paymentInfoCollectionMetadata:t[4],onContinue:t[10],onClose:t[9],onError:t[11],processing:t[6]==="polling-purchase-status"}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&16&&(o.paymentInfoCollectionMetadata=n[4]),i&64&&(o.processing=n[6]==="polling-purchase-status"),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function St(t){let e,r;return e=new je({}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Ot(t){var n;let e,r;return e=new wr({props:{brandingInfo:t[3],lastError:t[5]??new j(O.UnknownError,"Unknown error without state set."),supportEmail:(n=t[3])==null?void 0:n.seller_company_support_email,onContinue:t[12]}}),{c(){w(e.$$.fragment)},m(i,o){I(e,i,o),r=!0},p(i,o){var l;const s={};o&8&&(s.brandingInfo=i[3]),o&32&&(s.lastError=i[5]??new j(O.UnknownError,"Unknown error without state set.")),o&8&&(s.supportEmail=(l=i[3])==null?void 0:l.seller_company_support_email),e.$set(s)},i(i){r||(u(e.$$.fragment,i),r=!0)},o(i){d(e.$$.fragment,i),r=!1},d(i){b(e,i)}}}function Lt(t){let e,r;return e=new Pr({props:{brandingInfo:t[3],onContinue:t[10]}}),{c(){w(e.$$.fragment)},m(n,i){I(e,n,i),r=!0},p(n,i){const o={};i&8&&(o.brandingInfo=n[3]),e.$set(o)},i(n){r||(u(e.$$.fragment,n),r=!0)},o(n){d(e.$$.fragment,n),r=!1},d(n){b(e,n)}}}function Eo(t){let e,r,n,i,o,s,l,c,a=t[6]==="present-offer"&&t[2]&&Tt(t),f=t[6]==="present-offer"&&!t[2]&&Nt(),m=(t[6]==="needs-auth-info"||t[6]==="processing-auth-info")&&Ut(t),E=t[4]&&(t[6]==="needs-payment-info"||t[6]==="polling-purchase-status")&&Rt(t),y=t[6]==="loading"&&St(),A=t[6]==="error"&&Ot(t),M=t[6]==="success"&&Lt(t);return{c(){a&&a.c(),e=T(),f&&f.c(),r=T(),m&&m.c(),n=T(),E&&E.c(),i=T(),y&&y.c(),o=T(),A&&A.c(),s=T(),M&&M.c(),l=ne()},m(h,B){a&&a.m(h,B),p(h,e,B),f&&f.m(h,B),p(h,r,B),m&&m.m(h,B),p(h,n,B),E&&E.m(h,B),p(h,i,B),y&&y.m(h,B),p(h,o,B),A&&A.m(h,B),p(h,s,B),M&&M.m(h,B),p(h,l,B),c=!0},p(h,B){h[6]==="present-offer"&&h[2]?a?(a.p(h,B),B&68&&u(a,1)):(a=Tt(h),a.c(),u(a,1),a.m(e.parentNode,e)):a&&(F(),d(a,1,1,()=>{a=null}),G()),h[6]==="present-offer"&&!h[2]?f?B&68&&u(f,1):(f=Nt(),f.c(),u(f,1),f.m(r.parentNode,r)):f&&(F(),d(f,1,1,()=>{f=null}),G()),h[6]==="needs-auth-info"||h[6]==="processing-auth-info"?m?(m.p(h,B),B&64&&u(m,1)):(m=Ut(h),m.c(),u(m,1),m.m(n.parentNode,n)):m&&(F(),d(m,1,1,()=>{m=null}),G()),h[4]&&(h[6]==="needs-payment-info"||h[6]==="polling-purchase-status")?E?(E.p(h,B),B&80&&u(E,1)):(E=Rt(h),E.c(),u(E,1),E.m(i.parentNode,i)):E&&(F(),d(E,1,1,()=>{E=null}),G()),h[6]==="loading"?y?B&64&&u(y,1):(y=St(),y.c(),u(y,1),y.m(o.parentNode,o)):y&&(F(),d(y,1,1,()=>{y=null}),G()),h[6]==="error"?A?(A.p(h,B),B&64&&u(A,1)):(A=Ot(h),A.c(),u(A,1),A.m(s.parentNode,s)):A&&(F(),d(A,1,1,()=>{A=null}),G()),h[6]==="success"?M?(M.p(h,B),B&64&&u(M,1)):(M=Lt(h),M.c(),u(M,1),M.m(l.parentNode,l)):M&&(F(),d(M,1,1,()=>{M=null}),G())},i(h){c||(u(a),u(f),u(m),u(E),u(y),u(A),u(M),c=!0)},o(h){d(a),d(f),d(m),d(E),d(y),d(A),d(M),c=!1},d(h){h&&(g(e),g(r),g(n),g(i),g(o),g(s),g(l)),a&&a.d(h),f&&f.d(h),m&&m.d(h),E&&E.d(h),y&&y.d(h),A&&A.d(h),M&&M.d(h)}}}function Io(t){let e,r=t[8].includes(t[6]),n,i,o,s,l=r&&Pt(t);return o=new Bt({props:{$$slots:{default:[Eo]},$$scope:{ctx:t}}}),{c(){e=k("div"),l&&l.c(),n=T(),i=k("div"),w(o.$$.fragment),_(i,"class","rcb-ui-main svelte-13pdaik"),_(e,"class","rcb-ui-layout svelte-13pdaik"),_(e,"style",t[7])},m(c,a){p(c,e,a),l&&l.m(e,null),D(e,n),D(e,i),I(o,i,null),s=!0},p(c,a){a&64&&(r=c[8].includes(c[6])),r?l?(l.p(c,a),a&64&&u(l,1)):(l=Pt(c),l.c(),u(l,1),l.m(e,n)):l&&(F(),d(l,1,1,()=>{l=null}),G());const f={};a&8388732&&(f.$$scope={dirty:a,ctx:c}),o.$set(f)},i(c){s||(u(l),u(o.$$.fragment,c),s=!0)},o(c){d(l),d(o.$$.fragment,c),s=!1},d(c){c&&g(e),l&&l.d(),b(o)}}}function bo(t){let e,r,n;return r=new Hi({props:{condition:t[0],$$slots:{default:[Io]},$$scope:{ctx:t}}}),{c(){e=k("div"),w(r.$$.fragment),_(e,"class","rcb-ui-container svelte-13pdaik")},m(i,o){p(i,e,o),I(r,e,null),n=!0},p(i,[o]){const s={};o&1&&(s.condition=i[0]),o&8388734&&(s.$$scope={dirty:o,ctx:i}),r.$set(s)},i(i){n||(u(r.$$.fragment,i),n=!0)},o(i){d(r.$$.fragment,i),n=!1},d(i){i&&g(e),b(r)}}}function wo(t,e,r){var xt;let{asModal:n=!0}=e,{customerEmail:i}=e,{appUserId:o}=e,{rcPackage:s}=e,{onFinished:l}=e,{onError:c}=e,{onClose:a}=e,{purchases:f}=e,{backend:m}=e,{purchaseOperationHelper:E}=e;const y=Object.entries(ve).map(([C,Ze])=>`--rc-color-${C}: ${Ze}`).join("; ");let A=null,M=null,h=null,B=null;const J=((xt=s.rcBillingProduct)==null?void 0:xt.identifier)??null;let $="present-offer";const Be=["present-offer","needs-auth-info","processing-auth-info","needs-payment-info","polling-purchase-status","loading"];Me(async()=>{if(r(2,A=s.rcBillingProduct),r(3,M=await m.getBrandingInfo()),$==="present-offer"){i?me():r(6,$="needs-auth-info");return}});const xe=()=>{a()},me=()=>{if(J===null){Z(new j(O.ErrorSettingUpPurchase,"Product ID was not set before purchase."));return}else $==="present-offer"&&r(6,$="loading");if(!i){Z(new j(O.MissingEmailError));return}E.startPurchase(o,J,i,s.rcBillingProduct.presentedOfferingIdentifier).then(C=>{if(C.next_action==="collect_payment_info"){r(6,$="needs-payment-info"),r(4,h=C);return}if(C.next_action==="completed"){r(6,$="success");return}}).catch(C=>{Z(new j(O.ErrorSettingUpPurchase,C.message,C.underlyingErrorMessage))})},ee=C=>{if($==="needs-auth-info"){C&&(r(13,i=C.email),r(6,$="processing-auth-info")),me();return}if($==="needs-payment-info"){r(6,$="polling-purchase-status"),E.pollCurrentPurchaseForCompletion().then(()=>{r(6,$="success")}).catch(Ze=>{Z(Ze)});return}if($==="success"||$==="error"){l();return}r(6,$="success")},Z=C=>{r(5,B=C),r(6,$="error")},So=()=>{c(B??new j(O.UnknownError,"Unknown error without state set."))};return t.$$set=C=>{"asModal"in C&&r(0,n=C.asModal),"customerEmail"in C&&r(13,i=C.customerEmail),"appUserId"in C&&r(14,o=C.appUserId),"rcPackage"in C&&r(15,s=C.rcPackage),"onFinished"in C&&r(16,l=C.onFinished),"onError"in C&&r(17,c=C.onError),"onClose"in C&&r(18,a=C.onClose),"purchases"in C&&r(1,f=C.purchases),"backend"in C&&r(19,m=C.backend),"purchaseOperationHelper"in C&&r(20,E=C.purchaseOperationHelper)},[n,f,A,M,h,B,$,y,Be,xe,ee,Z,So,i,o,s,l,c,a,m,E]}class ko extends U{constructor(e){super(),N(this,e,wo,bo,Q,{asModal:0,customerEmail:13,appUserId:14,rcPackage:15,onFinished:16,onError:17,onClose:18,purchases:1,backend:19,purchaseOperationHelper:20},mo)}}function $o(t){return t.expires_date==null?!0:new Date(t.expires_date)>new Date}function vo(t,e,r,n){const i=e.product_identifier;if(i in r)return yo(t,e,r[i]);if(i in n)return Bo(t,e,n[i]);throw new X(re.CustomerInfoError,"Could not find entitlement product in subscriptions or non-subscriptions.")}function yo(t,e,r){return{identifier:t,isActive:$o(e),willRenew:Mo(e,r),store:(r==null?void 0:r.store)??"unknown",latestPurchaseDate:new Date(e.purchase_date),originalPurchaseDate:new Date(e.purchase_date),expirationDate:Le(e.expires_date),productIdentifier:e.product_identifier,unsubscribeDetectedAt:Le(r==null?void 0:r.unsubscribe_detected_at),billingIssueDetectedAt:Le(r==null?void 0:r.billing_issues_detected_at),isSandbox:(r==null?void 0:r.is_sandbox)??!1,periodType:(r==null?void 0:r.period_type)??"normal"}}function Bo(t,e,r){return{identifier:t,isActive:!0,willRenew:!1,store:r.store,latestPurchaseDate:new Date(e.purchase_date),originalPurchaseDate:new Date(r.original_purchase_date),expirationDate:null,productIdentifier:e.product_identifier,unsubscribeDetectedAt:null,billingIssueDetectedAt:null,isSandbox:r.is_sandbox,periodType:"normal"}}function Do(t,e,r){const n={},i={};for(const o in t){const s=vo(o,t[o],e,r);n[o]=s,s.isActive&&(i[o]=s)}return{all:n,active:i}}function Le(t){return t==null?null:new Date(t)}function Co(t){const e=Qo(t),r=t.subscriber,n=No(r.non_subscriptions);return{entitlements:Do(r.entitlements,r.subscriptions,n),allExpirationDatesByProduct:e,allPurchaseDatesByProduct:Po(t,n),activeSubscriptions:To(e),managementURL:r.management_url,requestDate:new Date(t.request_date),firstSeenDate:new Date(r.first_seen),originalPurchaseDate:Le(r.original_purchase_date),originalAppUserId:t.subscriber.original_app_user_id}}function Mo(t,e){if(e==null)return!1;const r=e.store=="promotional",n=t.expires_date==null,i=e.unsubscribe_detected_at!=null,o=e.billing_issues_detected_at!=null;return!(r||n||i||o)}function Po(t,e){const r={};for(const n in t.subscriber.subscriptions){const i=t.subscriber.subscriptions[n];r[n]=new Date(i.purchase_date)}for(const n in e){const i=e[n].purchase_date;i==null?r[n]=null:r[n]=new Date(i)}return r}function Qo(t){const e={};for(const r in t.subscriber.subscriptions){const n=t.subscriber.subscriptions[r];n.expires_date==null?e[r]=null:e[r]=new Date(n.expires_date)}return e}function To(t){const e=new Set,r=new Date;for(const n in t){const i=t[n];(i==null||i>r)&&e.add(n)}return e}function No(t){const e={};for(const r in t){if(t[r].length===0)continue;const n=t[r].length;e[r]=t[r][n-1]}return e}function Uo(t){if(!/^rcb_[a-zA-Z0-9_.-]+$/.test(t))throw new X(re.InvalidCredentialsError,"Invalid API key. Use your RevenueCat Billing API key.")}function Ro(t){if(new Set(["no_user","null","none","nil","(null)","NaN","\\x00","","unidentified","undefined","unknown"]).has(t)||t.includes("/"))throw new X(re.InvalidAppUserIdError,'Provided user id: "'+t+'" is not valid. See https://www.revenuecat.com/docs/customers/user-ids#tips-for-setting-app-user-ids for more information.')}const z=class z{constructor(e,r){P(this,"_API_KEY");P(this,"_appUserId");P(this,"backend");P(this,"purchaseOperationHelper");P(this,"toOfferings",(e,r)=>{const n=e.offerings.find(l=>l.identifier===e.current_offering_id)??null,i={};r.product_details.forEach(l=>{i[l.identifier]=l});const o=n==null?null:nt(n,i),s={};return e.offerings.forEach(l=>{const c=nt(l,i);c!=null&&(s[l.identifier]=c)}),Object.keys(s).length==0&&W.debugLog("Empty offerings. Please make sure you've configured offerings correctly in the RevenueCat dashboard and that the products are properly configured."),{all:s,current:o}});this._API_KEY=e,this._appUserId=r,We(e)&&W.debugLog("Initializing Purchases SDK with sandbox API Key"),this.backend=new oo(this._API_KEY),this.purchaseOperationHelper=new Dn(this.backend)}static setLogLevel(e){W.setLogLevel(e)}static getSharedInstance(){if(z.isConfigured())return z.instance;throw new Ct}static isConfigured(){return z.instance!==void 0}static configure(e,r){return z.instance!==void 0?(W.warnLog("Purchases is already initialized. Ignoring and returning existing instance."),z.getSharedInstance()):(Uo(e),Ro(r),z.instance=new z(e,r),z.getSharedInstance())}async getOfferings(){const e=this._appUserId,r=await this.backend.getOfferings(e),n=r.offerings.flatMap(o=>o.packages).map(o=>o.platform_product_identifier),i=await this.backend.getProducts(e,n);return this.logMissingProductIds(n,i.product_details),this.toOfferings(r,i)}async isEntitledTo(e){const r=await this.getCustomerInfo();return e in r.entitlements.active}purchasePackage(e,r,n){let i=n??document.getElementById("rcb-ui-root");if(i===null){const c=document.createElement("div");c.className="rcb-ui-root",document.body.appendChild(c),i=c}if(i===null)throw new Error("Could not generate a mount point for the billing widget");const o=i,s=!n,l=this._appUserId;return W.debugLog(`Presenting purchase form for package ${e.identifier}`),new Promise((c,a)=>{new ko({target:o,props:{appUserId:l,rcPackage:e,customerEmail:r,onFinished:async()=>{W.debugLog("Purchase finished"),o.innerHTML="",c({customerInfo:await this._getCustomerInfoForUserId(l)})},onClose:()=>{o.innerHTML="",W.debugLog("Purchase cancelled by user"),a(new X(re.UserCancelledError))},onError:f=>{o.innerHTML="",a(X.getForPurchasesFlowError(f))},purchases:this,backend:this.backend,purchaseOperationHelper:this.purchaseOperationHelper,asModal:s}})})}async getCustomerInfo(){return await this._getCustomerInfoForUserId(this._appUserId)}getAppUserId(){return this._appUserId}async changeUser(e){return this._appUserId=e,await this.getCustomerInfo()}logMissingProductIds(e,r){const n={};r.forEach(o=>n[o.identifier]=o);const i=[];e.forEach(o=>{n[o]===void 0&&i.push(o)}),i.length>0&&W.debugLog(`Could not find product data for product ids:
8
8
  ${i.join()}.
9
9
  Please check that your product configuration is correct.`)}isSandbox(){return We(this._API_KEY)}close(){z.instance===this?z.instance=void 0:W.warnLog("Trying to close a Purchases instance that is not the current instance. Ignoring.")}async _getCustomerInfoForUserId(e){const r=await this.backend.getCustomerInfo(e);return Co(r)}};P(z,"instance");let Xe=z;x.ErrorCode=re,x.LogLevel=L,x.PackageType=tt,x.Purchases=Xe,x.PurchasesError=X,x.UninitializedPurchasesError=Ct,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@revenuecat/purchases-js",
3
3
  "description": "Web subscriptions made easy. Powered by RevenueCat",
4
4
  "private": false,
5
- "version": "0.2.0",
5
+ "version": "0.2.2",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"