@sesamy/sesamy-js 1.10.0 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- "use strict";var Nr=Object.defineProperty;var Ur=(t,e,n)=>e in t?Nr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var q=(t,e,n)=>(Ur(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function ue(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0});dispatchEvent(n)}function te(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}var he=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function At(t,e){return t(e={exports:{}},e.exports),e.exports}var de=At(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function r(){var i=this;this.locked=new Map,this.addToLocked=function(o,a){var s=i.locked.get(o);s===void 0?a===void 0?i.locked.set(o,[]):i.locked.set(o,[a]):a!==void 0&&(s.unshift(a),i.locked.set(o,s))},this.isLocked=function(o){return i.locked.has(o)},this.lock=function(o){return new Promise(function(a,s){i.isLocked(o)?i.addToLocked(o,a):(i.addToLocked(o),a())})},this.unlock=function(o){var a=i.locked.get(o);if(a!==void 0&&a.length!==0){var s=a.pop();i.locked.set(o,a),s!==void 0&&setTimeout(s,0)}else i.locked.delete(o)}}return r.getInstance=function(){return r.instance===void 0&&(r.instance=new r),r.instance},r}();e.default=function(){return n.getInstance()}});xt(de);var zr=xt(At(function(t,e){var n=he&&he.__awaiter||function(u,c,f,d){return new(f||(f=Promise))(function(w,k){function v(g){try{_(d.next(g))}catch(l){k(l)}}function E(g){try{_(d.throw(g))}catch(l){k(l)}}function _(g){g.done?w(g.value):new f(function(l){l(g.value)}).then(v,E)}_((d=d.apply(u,c||[])).next())})},r=he&&he.__generator||function(u,c){var f,d,w,k,v={label:0,sent:function(){if(1&w[0])throw w[1];return w[1]},trys:[],ops:[]};return k={next:E(0),throw:E(1),return:E(2)},typeof Symbol=="function"&&(k[Symbol.iterator]=function(){return this}),k;function E(_){return function(g){return function(l){if(f)throw new TypeError("Generator is already executing.");for(;v;)try{if(f=1,d&&(w=2&l[0]?d.return:l[0]?d.throw||((w=d.return)&&w.call(d),0):d.next)&&!(w=w.call(d,l[1])).done)return w;switch(d=0,w&&(l=[2&l[0],w.value]),l[0]){case 0:case 1:w=l;break;case 4:return v.label++,{value:l[1],done:!1};case 5:v.label++,d=l[1],l=[0];continue;case 7:l=v.ops.pop(),v.trys.pop();continue;default:if(w=v.trys,!((w=w.length>0&&w[w.length-1])||l[0]!==6&&l[0]!==2)){v=0;continue}if(l[0]===3&&(!w||l[1]>w[0]&&l[1]<w[3])){v.label=l[1];break}if(l[0]===6&&v.label<w[1]){v.label=w[1],w=l;break}if(w&&v.label<w[2]){v.label=w[2],v.ops.push(l);break}w[2]&&v.ops.pop(),v.trys.pop();continue}l=c.call(u,v)}catch(b){l=[6,b],d=0}finally{f=w=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([_,g])}}},i=he;Object.defineProperty(e,"__esModule",{value:!0});var o="browser-tabs-lock-key",a={key:function(u){return n(i,void 0,void 0,function(){return r(this,function(c){throw new Error("Unsupported")})})},getItem:function(u){return n(i,void 0,void 0,function(){return r(this,function(c){throw new Error("Unsupported")})})},clear:function(){return n(i,void 0,void 0,function(){return r(this,function(u){return[2,window.localStorage.clear()]})})},removeItem:function(u){return n(i,void 0,void 0,function(){return r(this,function(c){throw new Error("Unsupported")})})},setItem:function(u,c){return n(i,void 0,void 0,function(){return r(this,function(f){throw new Error("Unsupported")})})},keySync:function(u){return window.localStorage.key(u)},getItemSync:function(u){return window.localStorage.getItem(u)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(u){return window.localStorage.removeItem(u)},setItemSync:function(u,c){return window.localStorage.setItem(u,c)}};function s(u){return new Promise(function(c){return setTimeout(c,u)})}function h(u){for(var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",f="",d=0;d<u;d++)f+=c[Math.floor(Math.random()*c.length)];return f}var p=function(){function u(c){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+h(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=c,u.waiters===void 0&&(u.waiters=[])}return u.prototype.acquireLock=function(c,f){return f===void 0&&(f=5e3),n(this,void 0,void 0,function(){var d,w,k,v,E,_,g;return r(this,function(l){switch(l.label){case 0:d=Date.now()+h(4),w=Date.now()+f,k=o+"-"+c,v=this.storageHandler===void 0?a:this.storageHandler,l.label=1;case 1:return Date.now()<w?[4,s(30)]:[3,8];case 2:return l.sent(),v.getItemSync(k)!==null?[3,5]:(E=this.id+"-"+c+"-"+d,[4,s(Math.floor(25*Math.random()))]);case 3:return l.sent(),v.setItemSync(k,JSON.stringify({id:this.id,iat:d,timeoutKey:E,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return l.sent(),(_=v.getItemSync(k))!==null&&(g=JSON.parse(_)).id===this.id&&g.iat===d?(this.acquiredIatSet.add(d),this.refreshLockWhileAcquired(k,d),[2,!0]):[3,7];case 5:return u.lockCorrector(this.storageHandler===void 0?a:this.storageHandler),[4,this.waitForSomethingToChange(w)];case 6:l.sent(),l.label=7;case 7:return d=Date.now()+h(4),[3,1];case 8:return[2,!1]}})})},u.prototype.refreshLockWhileAcquired=function(c,f){return n(this,void 0,void 0,function(){var d=this;return r(this,function(w){return setTimeout(function(){return n(d,void 0,void 0,function(){var k,v,E;return r(this,function(_){switch(_.label){case 0:return[4,de.default().lock(f)];case 1:return _.sent(),this.acquiredIatSet.has(f)?(k=this.storageHandler===void 0?a:this.storageHandler,(v=k.getItemSync(c))===null?(de.default().unlock(f),[2]):((E=JSON.parse(v)).timeRefreshed=Date.now(),k.setItemSync(c,JSON.stringify(E)),de.default().unlock(f),this.refreshLockWhileAcquired(c,f),[2])):(de.default().unlock(f),[2])}})})},1e3),[2]})})},u.prototype.waitForSomethingToChange=function(c){return n(this,void 0,void 0,function(){return r(this,function(f){switch(f.label){case 0:return[4,new Promise(function(d){var w=!1,k=Date.now(),v=!1;function E(){if(v||(window.removeEventListener("storage",E),u.removeFromWaiting(E),clearTimeout(_),v=!0),!w){w=!0;var g=50-(Date.now()-k);g>0?setTimeout(d,g):d(null)}}window.addEventListener("storage",E),u.addToWaiting(E);var _=setTimeout(E,Math.max(0,c-Date.now()))})];case 1:return f.sent(),[2]}})})},u.addToWaiting=function(c){this.removeFromWaiting(c),u.waiters!==void 0&&u.waiters.push(c)},u.removeFromWaiting=function(c){u.waiters!==void 0&&(u.waiters=u.waiters.filter(function(f){return f!==c}))},u.notifyWaiters=function(){u.waiters!==void 0&&u.waiters.slice().forEach(function(c){return c()})},u.prototype.releaseLock=function(c){return n(this,void 0,void 0,function(){return r(this,function(f){switch(f.label){case 0:return[4,this.releaseLock__private__(c)];case 1:return[2,f.sent()]}})})},u.prototype.releaseLock__private__=function(c){return n(this,void 0,void 0,function(){var f,d,w,k;return r(this,function(v){switch(v.label){case 0:return f=this.storageHandler===void 0?a:this.storageHandler,d=o+"-"+c,(w=f.getItemSync(d))===null?[2]:(k=JSON.parse(w)).id!==this.id?[3,2]:[4,de.default().lock(k.iat)];case 1:v.sent(),this.acquiredIatSet.delete(k.iat),f.removeItemSync(d),de.default().unlock(k.iat),u.notifyWaiters(),v.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var f=Date.now()-5e3,d=c,w=[],k=0;;){var v=d.keySync(k);if(v===null)break;w.push(v),k++}for(var E=!1,_=0;_<w.length;_++){var g=w[_];if(g.includes(o)){var l=d.getItemSync(g);if(l!==null){var b=JSON.parse(l);(b.timeRefreshed===void 0&&b.timeAcquired<f||b.timeRefreshed!==void 0&&b.timeRefreshed<f)&&(d.removeItemSync(g),E=!0)}}}E&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=p}));const Rr={timeoutInSeconds:60},Dn={name:"auth0-spa-js",version:"2.1.3"},Ln=()=>Date.now();let G=class kt extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,kt.prototype)}static fromPayload({error:e,error_description:n}){return new kt(e,n)}},Dr=class Mn extends G{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,Mn.prototype)}},It=class Zn extends G{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,Zn.prototype)}},Lr=class Kn extends It{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,Kn.prototype)}},Mr=class Wn extends G{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,Wn.prototype)}},Zr=class Hn extends G{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,Hn.prototype)}},Fn=class Jn extends G{constructor(e,n){super("missing_refresh_token",`Missing Refresh Token (audience: '${Ft(e,["default"])}', scope: '${Ft(n)}')`),this.audience=e,this.scope=n,Object.setPrototypeOf(this,Jn.prototype)}};function Ft(t,e=[]){return t&&!e.includes(t)?t:""}const Qe=()=>window.crypto,dt=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Qe().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},Jt=t=>btoa(t),St=t=>{var{clientId:e}=t,n=te(t,["clientId"]);return new URLSearchParams((r=>Object.keys(r).filter(i=>r[i]!==void 0).reduce((i,o)=>Object.assign(Object.assign({},i),{[o]:r[o]}),{}))(Object.assign({client_id:e},n))).toString()},Xt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),Kr=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},Wr=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([Kr(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},Hr=async(t,e,n,r,i,o,a)=>{return s={auth:{audience:e,scope:n},timeout:i,fetchUrl:t,fetchOptions:r,useFormData:a},h=o,new Promise(function(p,u){const c=new MessageChannel;c.port1.onmessage=function(f){f.data.error?u(new Error(f.data.error)):p(f.data),c.port1.close()},h.postMessage(s,[c.port2])});var s,h},Fr=async(t,e,n,r,i,o,a=1e4)=>i?Hr(t,e,n,r,a,i,o):Wr(t,r,a);async function Jr(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,h=te(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const p=s?St(h):JSON.stringify(h);return await async function(u,c,f,d,w,k,v){let E,_=null;for(let j=0;j<3;j++)try{E=await Fr(u,f,d,w,k,v,c),_=null;break}catch(D){_=D}if(_)throw _;const g=E.json,{error:l,error_description:b}=g,P=te(g,["error","error_description"]),{ok:O}=E;if(!O){const j=b||`HTTP error. Unable to fetch ${u}`;throw l==="mfa_required"?new Zr(l,j,P.mfa_token):l==="missing_refresh_token"?new Fn(f,d):new G(l||"request_error",j)}return P}(`${n}/oauth/token`,r,i||"default",o,{method:"POST",body:p,headers:{"Content-Type":s?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||Dn))}},e,s)}const Fe=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let pe=class _t{constructor(e,n="@@auth0spajs@@",r){this.prefix=n,this.suffix=r,this.clientId=e.clientId,this.scope=e.scope,this.audience=e.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join("::")}static fromKey(e){const[n,r,i,o]=e.split("::");return new _t({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new _t({scope:n,audience:r,clientId:i})}},Xr=class{set(e,n){localStorage.setItem(e,JSON.stringify(n))}get(e){const n=window.localStorage.getItem(e);if(n)try{return JSON.parse(n)}catch{return}}remove(e){localStorage.removeItem(e)}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith("@@auth0spajs@@"))}},Xn=class{constructor(){this.enclosedCache=function(){let e={};return{set(n,r){e[n]=r},get(n){const r=e[n];if(r)return r},remove(n){delete e[n]},allKeys:()=>Object.keys(e)}}()}},Vr=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||Ln}async setIdToken(e,n,r){var i;const o=this.getIdTokenCacheKey(e);await this.cache.set(o,{id_token:n,decodedToken:r}),await((i=this.keyManifest)===null||i===void 0?void 0:i.add(o))}async getIdToken(e){const n=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!n&&e.scope&&e.audience){const r=await this.get(e);return!r||!r.id_token||!r.decodedToken?void 0:{id_token:r.id_token,decodedToken:r.decodedToken}}if(n)return{id_token:n.id_token,decodedToken:n.decodedToken}}async get(e,n=0){var r;let i=await this.cache.get(e.toKey());if(!i){const s=await this.getCacheKeys();if(!s)return;const h=this.matchExistingCacheKey(e,s);h&&(i=await this.cache.get(h))}if(!i)return;const o=await this.nowProvider(),a=Math.floor(o/1e3);return i.expiresAt-n<a?i.body.refresh_token?(i.body={refresh_token:i.body.refresh_token},await this.cache.set(e.toKey(),i),i.body):(await this.cache.remove(e.toKey()),void await((r=this.keyManifest)===null||r===void 0?void 0:r.remove(e.toKey()))):i.body}async set(e){var n;const r=new pe({clientId:e.client_id,scope:e.scope,audience:e.audience}),i=await this.wrapCacheEntry(e);await this.cache.set(r.toKey(),i),await((n=this.keyManifest)===null||n===void 0?void 0:n.add(r.toKey()))}async clear(e){var n;const r=await this.getCacheKeys();r&&(await r.filter(i=>!e||i.includes(e)).reduce(async(i,o)=>{await i,await this.cache.remove(o)},Promise.resolve()),await((n=this.keyManifest)===null||n===void 0?void 0:n.clear()))}async wrapCacheEntry(e){const n=await this.nowProvider();return{body:e,expiresAt:Math.floor(n/1e3)+e.expires_in}}async getCacheKeys(){var e;return this.keyManifest?(e=await this.keyManifest.get())===null||e===void 0?void 0:e.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new pe({clientId:e},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(e,n){return n.filter(r=>{var i;const o=pe.fromKey(r),a=new Set(o.scope&&o.scope.split(" ")),s=((i=e.scope)===null||i===void 0?void 0:i.split(" "))||[],h=o.scope&&s.reduce((p,u)=>p&&a.has(u),!0);return o.prefix==="@@auth0spajs@@"&&o.clientId===e.clientId&&o.audience===e.audience&&h})[0]}},Yr=class{constructor(e,n,r){this.storage=e,this.clientId=n,this.cookieDomain=r,this.storageKey=`a0.spajs.txs.${this.clientId}`}create(e){this.storage.save(this.storageKey,e,{daysUntilExpire:1,cookieDomain:this.cookieDomain})}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain})}};const Ue=t=>typeof t=="number",Gr=["iss","aud","exp","nbf","iat","jti","azp","nonce","auth_time","at_hash","c_hash","acr","amr","sub_jwk","cnf","sip_from_tag","sip_date","sip_callid","sip_cseq_num","sip_via_branch","orig","dest","mky","events","toe","txn","rph","sid","vot","vtm"],Br=t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(o=>{const a=o.split("."),[s,h,p]=a;if(a.length!==3||!s||!h||!p)throw new Error("ID token could not be decoded");const u=JSON.parse(Xt(h)),c={__raw:o},f={};return Object.keys(u).forEach(d=>{c[d]=u[d],Gr.includes(d)||(f[d]=u[d])}),{encoded:{header:s,payload:h,signature:p},header:JSON.parse(Xt(s)),claims:c,user:f}})(t.id_token);if(!e.claims.iss)throw new Error("Issuer (iss) claim must be a string present in the ID token");if(e.claims.iss!==t.iss)throw new Error(`Issuer (iss) claim mismatch in the ID token; expected "${t.iss}", found "${e.claims.iss}"`);if(!e.user.sub)throw new Error("Subject (sub) claim must be a string present in the ID token");if(e.header.alg!=="RS256")throw new Error(`Signature algorithm of "${e.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);if(!e.claims.aud||typeof e.claims.aud!="string"&&!Array.isArray(e.claims.aud))throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");if(Array.isArray(e.claims.aud)){if(!e.claims.aud.includes(t.aud))throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but was not one of "${e.claims.aud.join(", ")}"`);if(e.claims.aud.length>1){if(!e.claims.azp)throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");if(e.claims.azp!==t.aud)throw new Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${t.aud}", found "${e.claims.azp}"`)}}else if(e.claims.aud!==t.aud)throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but found "${e.claims.aud}"`);if(t.nonce){if(!e.claims.nonce)throw new Error("Nonce (nonce) claim must be a string present in the ID token");if(e.claims.nonce!==t.nonce)throw new Error(`Nonce (nonce) claim mismatch in the ID token; expected "${t.nonce}", found "${e.claims.nonce}"`)}if(t.max_age&&!Ue(e.claims.auth_time))throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");if(e.claims.exp==null||!Ue(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!Ue(e.claims.iat))throw new Error("Issued At (iat) claim must be a number present in the ID token");const n=t.leeway||60,r=new Date(t.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(e.claims.exp+n),r>i)throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${r}) is after expiration time (${i})`);if(e.claims.nbf!=null&&Ue(e.claims.nbf)){const o=new Date(0);if(o.setUTCSeconds(e.claims.nbf-n),r<o)throw new Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${r}) is before ${o}`)}if(e.claims.auth_time!=null&&Ue(e.claims.auth_time)){const o=new Date(0);if(o.setUTCSeconds(parseInt(e.claims.auth_time)+t.max_age+n),r>o)throw new Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${r}) is after last auth at ${o}`)}if(t.organization){const o=t.organization.trim();if(o.startsWith("org_")){const a=o;if(!e.claims.org_id)throw new Error("Organization ID (org_id) claim must be a string present in the ID token");if(a!==e.claims.org_id)throw new Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_id}"`)}else{const a=o.toLowerCase();if(!e.claims.org_name)throw new Error("Organization Name (org_name) claim must be a string present in the ID token");if(a!==e.claims.org_name)throw new Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_name}"`)}}return e};var me=At(function(t,e){var n=he&&he.__assign||function(){return n=Object.assign||function(h){for(var p,u=1,c=arguments.length;u<c;u++)for(var f in p=arguments[u])Object.prototype.hasOwnProperty.call(p,f)&&(h[f]=p[f]);return h},n.apply(this,arguments)};function r(h,p){if(!p)return"";var u="; "+h;return p===!0?u:u+"="+p}function i(h,p,u){return encodeURIComponent(h).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(p).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(c){if(typeof c.expires=="number"){var f=new Date;f.setMilliseconds(f.getMilliseconds()+864e5*c.expires),c.expires=f}return r("Expires",c.expires?c.expires.toUTCString():"")+r("Domain",c.domain)+r("Path",c.path)+r("Secure",c.secure)+r("SameSite",c.sameSite)}(u)}function o(h){for(var p={},u=h?h.split("; "):[],c=/(%[\dA-F]{2})+/gi,f=0;f<u.length;f++){var d=u[f].split("="),w=d.slice(1).join("=");w.charAt(0)==='"'&&(w=w.slice(1,-1));try{p[d[0].replace(c,decodeURIComponent)]=w.replace(c,decodeURIComponent)}catch{}}return p}function a(){return o(document.cookie)}function s(h,p,u){document.cookie=i(h,p,n({path:"/"},u))}e.__esModule=!0,e.encode=i,e.parse=o,e.getAll=a,e.get=function(h){return a()[h]},e.set=s,e.remove=function(h,p){s(h,"",n(n({},p),{expires:-1}))}});xt(me),me.encode,me.parse,me.getAll;var qr=me.get,Vn=me.set,Yn=me.remove;const Ie={get(t){const e=qr(t);if(e!==void 0)return JSON.parse(e)},save(t,e,n){let r={};window.location.protocol==="https:"&&(r={secure:!0,sameSite:"none"}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Vn(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Yn(t,n)}},Qr={get(t){return Ie.get(t)||Ie.get(`_legacy_${t}`)},save(t,e,n){let r={};window.location.protocol==="https:"&&(r={secure:!0}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Vn(`_legacy_${t}`,JSON.stringify(e),r),Ie.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Yn(t,n),Ie.remove(t,e),Ie.remove(`_legacy_${t}`,e)}},ei={get(t){if(typeof sessionStorage>"u")return;const e=sessionStorage.getItem(t);return e!=null?JSON.parse(e):void 0},save(t,e){sessionStorage.setItem(t,JSON.stringify(e))},remove(t){sessionStorage.removeItem(t)}};function ti(t,e,n){var r=e===void 0?null:e,i=function(h,p){var u=atob(h);if(p){for(var c=new Uint8Array(u.length),f=0,d=u.length;f<d;++f)c[f]=u.charCodeAt(f);return String.fromCharCode.apply(null,new Uint16Array(c.buffer))}return u}(t,n!==void 0&&n),o=i.indexOf(`
2
- `,10)+1,a=i.substring(o)+(r?"//# sourceMappingURL="+r:""),s=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(s)}var Vt,Yt,Gt,ht,ni=(Vt="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",Yt=null,Gt=!1,function(t){return ht=ht||ti(Vt,Yt,Gt),new Worker(ht,t)});const ft={};let ri=class{constructor(e,n){this.cache=e,this.clientId=n,this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(e){var n;const r=new Set(((n=await this.cache.get(this.manifestKey))===null||n===void 0?void 0:n.keys)||[]);r.add(e),await this.cache.set(this.manifestKey,{keys:[...r]})}async remove(e){const n=await this.cache.get(this.manifestKey);if(n){const r=new Set(n.keys);return r.delete(e),r.size>0?await this.cache.set(this.manifestKey,{keys:[...r]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(e){return`@@auth0spajs@@::${e}`}};const ii={memory:()=>new Xn().enclosedCache,localstorage:()=>new Xr},Bt=t=>ii[t],qt=t=>{const{openUrl:e,onRedirect:n}=t,r=te(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:e===!1||e?e:n})},pt=new zr;let oi=class{constructor(e){let n,r;if(this.userCache=new Xn().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await pt.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)},this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),e),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),e.authorizationParams)}),typeof window<"u"&&(()=>{if(!Qe())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Qe().subtle===void 0)throw new Error(`
1
+ "use strict";var Nr=Object.defineProperty;var Ur=(t,e,n)=>e in t?Nr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var q=(t,e,n)=>(Ur(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function ue(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0});dispatchEvent(n)}function ne(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}var he=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function At(t,e){return t(e={exports:{}},e.exports),e.exports}var de=At(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function r(){var i=this;this.locked=new Map,this.addToLocked=function(o,a){var s=i.locked.get(o);s===void 0?a===void 0?i.locked.set(o,[]):i.locked.set(o,[a]):a!==void 0&&(s.unshift(a),i.locked.set(o,s))},this.isLocked=function(o){return i.locked.has(o)},this.lock=function(o){return new Promise(function(a,s){i.isLocked(o)?i.addToLocked(o,a):(i.addToLocked(o),a())})},this.unlock=function(o){var a=i.locked.get(o);if(a!==void 0&&a.length!==0){var s=a.pop();i.locked.set(o,a),s!==void 0&&setTimeout(s,0)}else i.locked.delete(o)}}return r.getInstance=function(){return r.instance===void 0&&(r.instance=new r),r.instance},r}();e.default=function(){return n.getInstance()}});xt(de);var zr=xt(At(function(t,e){var n=he&&he.__awaiter||function(u,c,p,d){return new(p||(p=Promise))(function(w,I){function v(y){try{S(d.next(y))}catch(l){I(l)}}function _(y){try{S(d.throw(y))}catch(l){I(l)}}function S(y){y.done?w(y.value):new p(function(l){l(y.value)}).then(v,_)}S((d=d.apply(u,c||[])).next())})},r=he&&he.__generator||function(u,c){var p,d,w,I,v={label:0,sent:function(){if(1&w[0])throw w[1];return w[1]},trys:[],ops:[]};return I={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(I[Symbol.iterator]=function(){return this}),I;function _(S){return function(y){return function(l){if(p)throw new TypeError("Generator is already executing.");for(;v;)try{if(p=1,d&&(w=2&l[0]?d.return:l[0]?d.throw||((w=d.return)&&w.call(d),0):d.next)&&!(w=w.call(d,l[1])).done)return w;switch(d=0,w&&(l=[2&l[0],w.value]),l[0]){case 0:case 1:w=l;break;case 4:return v.label++,{value:l[1],done:!1};case 5:v.label++,d=l[1],l=[0];continue;case 7:l=v.ops.pop(),v.trys.pop();continue;default:if(w=v.trys,!((w=w.length>0&&w[w.length-1])||l[0]!==6&&l[0]!==2)){v=0;continue}if(l[0]===3&&(!w||l[1]>w[0]&&l[1]<w[3])){v.label=l[1];break}if(l[0]===6&&v.label<w[1]){v.label=w[1],w=l;break}if(w&&v.label<w[2]){v.label=w[2],v.ops.push(l);break}w[2]&&v.ops.pop(),v.trys.pop();continue}l=c.call(u,v)}catch(k){l=[6,k],d=0}finally{p=w=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([S,y])}}},i=he;Object.defineProperty(e,"__esModule",{value:!0});var o="browser-tabs-lock-key",a={key:function(u){return n(i,void 0,void 0,function(){return r(this,function(c){throw new Error("Unsupported")})})},getItem:function(u){return n(i,void 0,void 0,function(){return r(this,function(c){throw new Error("Unsupported")})})},clear:function(){return n(i,void 0,void 0,function(){return r(this,function(u){return[2,window.localStorage.clear()]})})},removeItem:function(u){return n(i,void 0,void 0,function(){return r(this,function(c){throw new Error("Unsupported")})})},setItem:function(u,c){return n(i,void 0,void 0,function(){return r(this,function(p){throw new Error("Unsupported")})})},keySync:function(u){return window.localStorage.key(u)},getItemSync:function(u){return window.localStorage.getItem(u)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(u){return window.localStorage.removeItem(u)},setItemSync:function(u,c){return window.localStorage.setItem(u,c)}};function s(u){return new Promise(function(c){return setTimeout(c,u)})}function h(u){for(var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",p="",d=0;d<u;d++)p+=c[Math.floor(Math.random()*c.length)];return p}var f=function(){function u(c){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+h(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=c,u.waiters===void 0&&(u.waiters=[])}return u.prototype.acquireLock=function(c,p){return p===void 0&&(p=5e3),n(this,void 0,void 0,function(){var d,w,I,v,_,S,y;return r(this,function(l){switch(l.label){case 0:d=Date.now()+h(4),w=Date.now()+p,I=o+"-"+c,v=this.storageHandler===void 0?a:this.storageHandler,l.label=1;case 1:return Date.now()<w?[4,s(30)]:[3,8];case 2:return l.sent(),v.getItemSync(I)!==null?[3,5]:(_=this.id+"-"+c+"-"+d,[4,s(Math.floor(25*Math.random()))]);case 3:return l.sent(),v.setItemSync(I,JSON.stringify({id:this.id,iat:d,timeoutKey:_,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return l.sent(),(S=v.getItemSync(I))!==null&&(y=JSON.parse(S)).id===this.id&&y.iat===d?(this.acquiredIatSet.add(d),this.refreshLockWhileAcquired(I,d),[2,!0]):[3,7];case 5:return u.lockCorrector(this.storageHandler===void 0?a:this.storageHandler),[4,this.waitForSomethingToChange(w)];case 6:l.sent(),l.label=7;case 7:return d=Date.now()+h(4),[3,1];case 8:return[2,!1]}})})},u.prototype.refreshLockWhileAcquired=function(c,p){return n(this,void 0,void 0,function(){var d=this;return r(this,function(w){return setTimeout(function(){return n(d,void 0,void 0,function(){var I,v,_;return r(this,function(S){switch(S.label){case 0:return[4,de.default().lock(p)];case 1:return S.sent(),this.acquiredIatSet.has(p)?(I=this.storageHandler===void 0?a:this.storageHandler,(v=I.getItemSync(c))===null?(de.default().unlock(p),[2]):((_=JSON.parse(v)).timeRefreshed=Date.now(),I.setItemSync(c,JSON.stringify(_)),de.default().unlock(p),this.refreshLockWhileAcquired(c,p),[2])):(de.default().unlock(p),[2])}})})},1e3),[2]})})},u.prototype.waitForSomethingToChange=function(c){return n(this,void 0,void 0,function(){return r(this,function(p){switch(p.label){case 0:return[4,new Promise(function(d){var w=!1,I=Date.now(),v=!1;function _(){if(v||(window.removeEventListener("storage",_),u.removeFromWaiting(_),clearTimeout(S),v=!0),!w){w=!0;var y=50-(Date.now()-I);y>0?setTimeout(d,y):d(null)}}window.addEventListener("storage",_),u.addToWaiting(_);var S=setTimeout(_,Math.max(0,c-Date.now()))})];case 1:return p.sent(),[2]}})})},u.addToWaiting=function(c){this.removeFromWaiting(c),u.waiters!==void 0&&u.waiters.push(c)},u.removeFromWaiting=function(c){u.waiters!==void 0&&(u.waiters=u.waiters.filter(function(p){return p!==c}))},u.notifyWaiters=function(){u.waiters!==void 0&&u.waiters.slice().forEach(function(c){return c()})},u.prototype.releaseLock=function(c){return n(this,void 0,void 0,function(){return r(this,function(p){switch(p.label){case 0:return[4,this.releaseLock__private__(c)];case 1:return[2,p.sent()]}})})},u.prototype.releaseLock__private__=function(c){return n(this,void 0,void 0,function(){var p,d,w,I;return r(this,function(v){switch(v.label){case 0:return p=this.storageHandler===void 0?a:this.storageHandler,d=o+"-"+c,(w=p.getItemSync(d))===null?[2]:(I=JSON.parse(w)).id!==this.id?[3,2]:[4,de.default().lock(I.iat)];case 1:v.sent(),this.acquiredIatSet.delete(I.iat),p.removeItemSync(d),de.default().unlock(I.iat),u.notifyWaiters(),v.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var p=Date.now()-5e3,d=c,w=[],I=0;;){var v=d.keySync(I);if(v===null)break;w.push(v),I++}for(var _=!1,S=0;S<w.length;S++){var y=w[S];if(y.includes(o)){var l=d.getItemSync(y);if(l!==null){var k=JSON.parse(l);(k.timeRefreshed===void 0&&k.timeAcquired<p||k.timeRefreshed!==void 0&&k.timeRefreshed<p)&&(d.removeItemSync(y),_=!0)}}}_&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=f}));const Rr={timeoutInSeconds:60},Dn={name:"auth0-spa-js",version:"2.1.3"},Ln=()=>Date.now();let G=class kt extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,kt.prototype)}static fromPayload({error:e,error_description:n}){return new kt(e,n)}},Dr=class Mn extends G{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,Mn.prototype)}},It=class Zn extends G{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,Zn.prototype)}},Lr=class Kn extends It{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,Kn.prototype)}},Mr=class Wn extends G{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,Wn.prototype)}},Zr=class Hn extends G{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,Hn.prototype)}},Fn=class Jn extends G{constructor(e,n){super("missing_refresh_token",`Missing Refresh Token (audience: '${Ft(e,["default"])}', scope: '${Ft(n)}')`),this.audience=e,this.scope=n,Object.setPrototypeOf(this,Jn.prototype)}};function Ft(t,e=[]){return t&&!e.includes(t)?t:""}const Qe=()=>window.crypto,dt=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Qe().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},Jt=t=>btoa(t),St=t=>{var{clientId:e}=t,n=ne(t,["clientId"]);return new URLSearchParams((r=>Object.keys(r).filter(i=>r[i]!==void 0).reduce((i,o)=>Object.assign(Object.assign({},i),{[o]:r[o]}),{}))(Object.assign({client_id:e},n))).toString()},Xt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),Kr=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},Wr=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([Kr(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},Hr=async(t,e,n,r,i,o,a)=>{return s={auth:{audience:e,scope:n},timeout:i,fetchUrl:t,fetchOptions:r,useFormData:a},h=o,new Promise(function(f,u){const c=new MessageChannel;c.port1.onmessage=function(p){p.data.error?u(new Error(p.data.error)):f(p.data),c.port1.close()},h.postMessage(s,[c.port2])});var s,h},Fr=async(t,e,n,r,i,o,a=1e4)=>i?Hr(t,e,n,r,a,i,o):Wr(t,r,a);async function Jr(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,h=ne(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const f=s?St(h):JSON.stringify(h);return await async function(u,c,p,d,w,I,v){let _,S=null;for(let j=0;j<3;j++)try{_=await Fr(u,p,d,w,I,v,c),S=null;break}catch(z){S=z}if(S)throw S;const y=_.json,{error:l,error_description:k}=y,P=ne(y,["error","error_description"]),{ok:O}=_;if(!O){const j=k||`HTTP error. Unable to fetch ${u}`;throw l==="mfa_required"?new Zr(l,j,P.mfa_token):l==="missing_refresh_token"?new Fn(p,d):new G(l||"request_error",j)}return P}(`${n}/oauth/token`,r,i||"default",o,{method:"POST",body:f,headers:{"Content-Type":s?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||Dn))}},e,s)}const Fe=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let pe=class _t{constructor(e,n="@@auth0spajs@@",r){this.prefix=n,this.suffix=r,this.clientId=e.clientId,this.scope=e.scope,this.audience=e.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join("::")}static fromKey(e){const[n,r,i,o]=e.split("::");return new _t({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new _t({scope:n,audience:r,clientId:i})}},Xr=class{set(e,n){localStorage.setItem(e,JSON.stringify(n))}get(e){const n=window.localStorage.getItem(e);if(n)try{return JSON.parse(n)}catch{return}}remove(e){localStorage.removeItem(e)}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith("@@auth0spajs@@"))}},Xn=class{constructor(){this.enclosedCache=function(){let e={};return{set(n,r){e[n]=r},get(n){const r=e[n];if(r)return r},remove(n){delete e[n]},allKeys:()=>Object.keys(e)}}()}},Vr=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||Ln}async setIdToken(e,n,r){var i;const o=this.getIdTokenCacheKey(e);await this.cache.set(o,{id_token:n,decodedToken:r}),await((i=this.keyManifest)===null||i===void 0?void 0:i.add(o))}async getIdToken(e){const n=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!n&&e.scope&&e.audience){const r=await this.get(e);return!r||!r.id_token||!r.decodedToken?void 0:{id_token:r.id_token,decodedToken:r.decodedToken}}if(n)return{id_token:n.id_token,decodedToken:n.decodedToken}}async get(e,n=0){var r;let i=await this.cache.get(e.toKey());if(!i){const s=await this.getCacheKeys();if(!s)return;const h=this.matchExistingCacheKey(e,s);h&&(i=await this.cache.get(h))}if(!i)return;const o=await this.nowProvider(),a=Math.floor(o/1e3);return i.expiresAt-n<a?i.body.refresh_token?(i.body={refresh_token:i.body.refresh_token},await this.cache.set(e.toKey(),i),i.body):(await this.cache.remove(e.toKey()),void await((r=this.keyManifest)===null||r===void 0?void 0:r.remove(e.toKey()))):i.body}async set(e){var n;const r=new pe({clientId:e.client_id,scope:e.scope,audience:e.audience}),i=await this.wrapCacheEntry(e);await this.cache.set(r.toKey(),i),await((n=this.keyManifest)===null||n===void 0?void 0:n.add(r.toKey()))}async clear(e){var n;const r=await this.getCacheKeys();r&&(await r.filter(i=>!e||i.includes(e)).reduce(async(i,o)=>{await i,await this.cache.remove(o)},Promise.resolve()),await((n=this.keyManifest)===null||n===void 0?void 0:n.clear()))}async wrapCacheEntry(e){const n=await this.nowProvider();return{body:e,expiresAt:Math.floor(n/1e3)+e.expires_in}}async getCacheKeys(){var e;return this.keyManifest?(e=await this.keyManifest.get())===null||e===void 0?void 0:e.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new pe({clientId:e},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(e,n){return n.filter(r=>{var i;const o=pe.fromKey(r),a=new Set(o.scope&&o.scope.split(" ")),s=((i=e.scope)===null||i===void 0?void 0:i.split(" "))||[],h=o.scope&&s.reduce((f,u)=>f&&a.has(u),!0);return o.prefix==="@@auth0spajs@@"&&o.clientId===e.clientId&&o.audience===e.audience&&h})[0]}},Yr=class{constructor(e,n,r){this.storage=e,this.clientId=n,this.cookieDomain=r,this.storageKey=`a0.spajs.txs.${this.clientId}`}create(e){this.storage.save(this.storageKey,e,{daysUntilExpire:1,cookieDomain:this.cookieDomain})}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain})}};const Ue=t=>typeof t=="number",Gr=["iss","aud","exp","nbf","iat","jti","azp","nonce","auth_time","at_hash","c_hash","acr","amr","sub_jwk","cnf","sip_from_tag","sip_date","sip_callid","sip_cseq_num","sip_via_branch","orig","dest","mky","events","toe","txn","rph","sid","vot","vtm"],Br=t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(o=>{const a=o.split("."),[s,h,f]=a;if(a.length!==3||!s||!h||!f)throw new Error("ID token could not be decoded");const u=JSON.parse(Xt(h)),c={__raw:o},p={};return Object.keys(u).forEach(d=>{c[d]=u[d],Gr.includes(d)||(p[d]=u[d])}),{encoded:{header:s,payload:h,signature:f},header:JSON.parse(Xt(s)),claims:c,user:p}})(t.id_token);if(!e.claims.iss)throw new Error("Issuer (iss) claim must be a string present in the ID token");if(e.claims.iss!==t.iss)throw new Error(`Issuer (iss) claim mismatch in the ID token; expected "${t.iss}", found "${e.claims.iss}"`);if(!e.user.sub)throw new Error("Subject (sub) claim must be a string present in the ID token");if(e.header.alg!=="RS256")throw new Error(`Signature algorithm of "${e.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);if(!e.claims.aud||typeof e.claims.aud!="string"&&!Array.isArray(e.claims.aud))throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");if(Array.isArray(e.claims.aud)){if(!e.claims.aud.includes(t.aud))throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but was not one of "${e.claims.aud.join(", ")}"`);if(e.claims.aud.length>1){if(!e.claims.azp)throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");if(e.claims.azp!==t.aud)throw new Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${t.aud}", found "${e.claims.azp}"`)}}else if(e.claims.aud!==t.aud)throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but found "${e.claims.aud}"`);if(t.nonce){if(!e.claims.nonce)throw new Error("Nonce (nonce) claim must be a string present in the ID token");if(e.claims.nonce!==t.nonce)throw new Error(`Nonce (nonce) claim mismatch in the ID token; expected "${t.nonce}", found "${e.claims.nonce}"`)}if(t.max_age&&!Ue(e.claims.auth_time))throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");if(e.claims.exp==null||!Ue(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!Ue(e.claims.iat))throw new Error("Issued At (iat) claim must be a number present in the ID token");const n=t.leeway||60,r=new Date(t.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(e.claims.exp+n),r>i)throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${r}) is after expiration time (${i})`);if(e.claims.nbf!=null&&Ue(e.claims.nbf)){const o=new Date(0);if(o.setUTCSeconds(e.claims.nbf-n),r<o)throw new Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${r}) is before ${o}`)}if(e.claims.auth_time!=null&&Ue(e.claims.auth_time)){const o=new Date(0);if(o.setUTCSeconds(parseInt(e.claims.auth_time)+t.max_age+n),r>o)throw new Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${r}) is after last auth at ${o}`)}if(t.organization){const o=t.organization.trim();if(o.startsWith("org_")){const a=o;if(!e.claims.org_id)throw new Error("Organization ID (org_id) claim must be a string present in the ID token");if(a!==e.claims.org_id)throw new Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_id}"`)}else{const a=o.toLowerCase();if(!e.claims.org_name)throw new Error("Organization Name (org_name) claim must be a string present in the ID token");if(a!==e.claims.org_name)throw new Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_name}"`)}}return e};var me=At(function(t,e){var n=he&&he.__assign||function(){return n=Object.assign||function(h){for(var f,u=1,c=arguments.length;u<c;u++)for(var p in f=arguments[u])Object.prototype.hasOwnProperty.call(f,p)&&(h[p]=f[p]);return h},n.apply(this,arguments)};function r(h,f){if(!f)return"";var u="; "+h;return f===!0?u:u+"="+f}function i(h,f,u){return encodeURIComponent(h).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(f).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(c){if(typeof c.expires=="number"){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*c.expires),c.expires=p}return r("Expires",c.expires?c.expires.toUTCString():"")+r("Domain",c.domain)+r("Path",c.path)+r("Secure",c.secure)+r("SameSite",c.sameSite)}(u)}function o(h){for(var f={},u=h?h.split("; "):[],c=/(%[\dA-F]{2})+/gi,p=0;p<u.length;p++){var d=u[p].split("="),w=d.slice(1).join("=");w.charAt(0)==='"'&&(w=w.slice(1,-1));try{f[d[0].replace(c,decodeURIComponent)]=w.replace(c,decodeURIComponent)}catch{}}return f}function a(){return o(document.cookie)}function s(h,f,u){document.cookie=i(h,f,n({path:"/"},u))}e.__esModule=!0,e.encode=i,e.parse=o,e.getAll=a,e.get=function(h){return a()[h]},e.set=s,e.remove=function(h,f){s(h,"",n(n({},f),{expires:-1}))}});xt(me),me.encode,me.parse,me.getAll;var qr=me.get,Vn=me.set,Yn=me.remove;const Ie={get(t){const e=qr(t);if(e!==void 0)return JSON.parse(e)},save(t,e,n){let r={};window.location.protocol==="https:"&&(r={secure:!0,sameSite:"none"}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Vn(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Yn(t,n)}},Qr={get(t){return Ie.get(t)||Ie.get(`_legacy_${t}`)},save(t,e,n){let r={};window.location.protocol==="https:"&&(r={secure:!0}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Vn(`_legacy_${t}`,JSON.stringify(e),r),Ie.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Yn(t,n),Ie.remove(t,e),Ie.remove(`_legacy_${t}`,e)}},ei={get(t){if(typeof sessionStorage>"u")return;const e=sessionStorage.getItem(t);return e!=null?JSON.parse(e):void 0},save(t,e){sessionStorage.setItem(t,JSON.stringify(e))},remove(t){sessionStorage.removeItem(t)}};function ti(t,e,n){var r=e===void 0?null:e,i=function(h,f){var u=atob(h);if(f){for(var c=new Uint8Array(u.length),p=0,d=u.length;p<d;++p)c[p]=u.charCodeAt(p);return String.fromCharCode.apply(null,new Uint16Array(c.buffer))}return u}(t,n!==void 0&&n),o=i.indexOf(`
2
+ `,10)+1,a=i.substring(o)+(r?"//# sourceMappingURL="+r:""),s=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(s)}var Vt,Yt,Gt,ht,ni=(Vt="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",Yt=null,Gt=!1,function(t){return ht=ht||ti(Vt,Yt,Gt),new Worker(ht,t)});const ft={};let ri=class{constructor(e,n){this.cache=e,this.clientId=n,this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(e){var n;const r=new Set(((n=await this.cache.get(this.manifestKey))===null||n===void 0?void 0:n.keys)||[]);r.add(e),await this.cache.set(this.manifestKey,{keys:[...r]})}async remove(e){const n=await this.cache.get(this.manifestKey);if(n){const r=new Set(n.keys);return r.delete(e),r.size>0?await this.cache.set(this.manifestKey,{keys:[...r]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(e){return`@@auth0spajs@@::${e}`}};const ii={memory:()=>new Xn().enclosedCache,localstorage:()=>new Xr},Bt=t=>ii[t],qt=t=>{const{openUrl:e,onRedirect:n}=t,r=ne(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:e===!1||e?e:n})},pt=new zr;let oi=class{constructor(e){let n,r;if(this.userCache=new Xn().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await pt.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)},this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),e),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),e.authorizationParams)}),typeof window<"u"&&(()=>{if(!Qe())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Qe().subtle===void 0)throw new Error(`
3
3
  auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
4
- `)})(),e.cache&&e.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),e.cache)r=e.cache;else{if(n=e.cacheLocation||"memory",!Bt(n))throw new Error(`Invalid cache location "${n}"`);r=Bt(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?Ie:Qr,this.orgHintCookieName=`auth0.${this.options.clientId}.organization_hint`,this.isAuthenticatedCookieName=(a=>`auth0.${a}.is.authenticated`)(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;const i=e.useCookiesForTransactions?this.cookieStorage:ei;var o;this.scope=Fe("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Yr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Ln,this.cacheManager=new Vr(r,r.allKeys?void 0:new ri(r,this.options.clientId),this.nowProvider),this.domainUrl=(o=this.options.domain,/^https?:\/\//.test(o)?o:`https://${o}`),this.tokenIssuer=((a,s)=>a?a.startsWith("https://")?a:`https://${a}/`:`${s}/`)(this.options.issuer,this.domainUrl),typeof window<"u"&&window.Worker&&this.options.useRefreshTokens&&n==="memory"&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new ni)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Dn)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${St(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return Br({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:n,organization:r,leeway:this.options.leeway,max_age:(o=this.options.authorizationParams.max_age,typeof o!="string"?o:parseInt(o,10)||void 0),now:i});var o}_processOrgHint(e){e?this.cookieStorage.save(this.orgHintCookieName,e,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}async _prepareAuthorizeUrl(e,n,r){const i=Jt(dt()),o=Jt(dt()),a=dt(),s=(u=>{const c=new Uint8Array(u);return(f=>{const d={"+":"-","/":"_","=":""};return f.replace(/[+/=]/g,w=>d[w])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Qe().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),h=((u,c,f,d,w,k,v,E)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),f),{scope:Fe(c,f.scope),response_type:"code",response_mode:E||"query",state:d,nonce:w,redirect_uri:v||u.authorizationParams.redirect_uri,code_challenge:k,code_challenge_method:"S256"}))(this.options,this.scope,e,i,o,s,e.redirect_uri||this.options.authorizationParams.redirect_uri||r,n==null?void 0:n.response_mode),p=this._authorizeUrl(h);return{nonce:o,code_verifier:a,scope:h.scope,audience:h.audience||"default",redirect_uri:h.redirect_uri,state:i,url:p}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const h=window.screenX+(window.innerWidth-400)/2,p=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${h},top=${p},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!n.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const i=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await(s=>new Promise((h,p)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(f),window.removeEventListener("message",u,!1),p(new Mr(s.popup)))},1e3),f=setTimeout(()=>{clearInterval(c),p(new Lr(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(f),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return p(G.fromPayload(d.data.response));h(d.data.response)}},window.addEventListener("message",u)}))(Object.assign(Object.assign({},n),{timeoutInSeconds:n.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}));if(i.state!==o.state)throw new G("state_mismatch","Invalid state");const a=((r=e.authorizationParams)===null||r===void 0?void 0:r.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:i.audience,scope:i.scope,code_verifier:i.code_verifier,grant_type:"authorization_code",code:o.code,redirect_uri:i.redirect_uri},{nonceIn:i.nonce,organization:a})}async getUser(){var e;const n=await this._getIdTokenFromCache();return(e=n==null?void 0:n.decodedToken)===null||e===void 0?void 0:e.user}async getIdTokenClaims(){var e;const n=await this._getIdTokenFromCache();return(e=n==null?void 0:n.decodedToken)===null||e===void 0?void 0:e.claims}async loginWithRedirect(e={}){var n;const r=qt(e),{openUrl:i,fragment:o,appState:a}=r,s=te(r,["openUrl","fragment","appState"]),h=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,p=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=p,c=te(p,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),h&&{organization:h}));const f=o?`${u}#${o}`:u;i?await i(f):window.location.assign(f)}async handleRedirectCallback(e=window.location.href){const n=e.split("?").slice(1);if(n.length===0)throw new Error("There are no query params available for parsing.");const{state:r,code:i,error:o,error_description:a}=(c=>{c.indexOf("#")>-1&&(c=c.substring(0,c.indexOf("#")));const f=new URLSearchParams(c);return{state:f.get("state"),code:f.get("code")||void 0,error:f.get("error")||void 0,error_description:f.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new G("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new Dr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new G("state_mismatch","Invalid state");const h=s.organization,p=s.nonce,u=s.redirect_uri;return await this._requestToken(Object.assign({audience:s.audience,scope:s.scope,code_verifier:s.code_verifier,grant_type:"authorization_code",code:i},u?{redirect_uri:u}:{}),{nonceIn:p,organization:h}),{appState:s.appState}}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get("auth0.is.authenticated"))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove("auth0.is.authenticated")}try{await this.getTokenSilently(e)}catch{}}async getTokenSilently(e={}){var n;const r=Object.assign(Object.assign({cacheMode:"on"},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Fe(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=ft[a];return s||(s=o().finally(()=>{delete ft[a],s=null}),ft[a]=s),s})(()=>this._getTokenSilently(r),`${this.options.clientId}::${r.authorizationParams.audience}::${r.authorizationParams.scope}`);return e.detailedResponse?i:i==null?void 0:i.access_token}async _getTokenSilently(e){const{cacheMode:n}=e,r=te(e,["cacheMode"]);if(n!=="off"){const i=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(i)return i}if(n!=="cache-only"){if(!await(async(i,o=3)=>{for(let a=0;a<o;a++)if(await i())return!0;return!1})(()=>pt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new It;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const p=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(p)return p}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:h}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:h})}finally{await pt.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}}async getTokenWithPopup(e={},n={}){var r;const i=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Fe(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},Rr),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new pe({scope:i.authorizationParams.scope,audience:i.authorizationParams.audience||"default",clientId:this.options.clientId}))).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(e){e.clientId!==null?e.clientId=e.clientId||this.options.clientId:delete e.clientId;const n=e.logoutParams||{},{federated:r}=n,i=te(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${St(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=qt(e),{openUrl:r}=n,i=te(n,["openUrl"]);e.clientId===null?await this.cacheManager.clear():await this.cacheManager.clear(e.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove("@@user@@");const o=this._buildLogoutUrl(i);r?await r(o):r!==!1&&window.location.assign(o)}async _getTokenFromIFrame(e){const n=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),r=this.cookieStorage.get(this.orgHintCookieName);r&&!n.organization&&(n.organization=r);const{url:i,state:o,nonce:a,code_verifier:s,redirect_uri:h,scope:p,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new G("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const c=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,f=await((w,k,v=60)=>new Promise((E,_)=>{const g=window.document.createElement("iframe");g.setAttribute("width","0"),g.setAttribute("height","0"),g.style.display="none";const l=()=>{window.document.body.contains(g)&&(window.document.body.removeChild(g),window.removeEventListener("message",b,!1))};let b;const P=setTimeout(()=>{_(new It),l()},1e3*v);b=function(O){if(O.origin!=k||!O.data||O.data.type!=="authorization_response")return;const j=O.source;j&&j.close(),O.data.response.error?_(G.fromPayload(O.data.response)):E(O.data.response),clearTimeout(P),window.removeEventListener("message",b,!1),setTimeout(l,2e3)},window.addEventListener("message",b,!1),window.document.body.appendChild(g),g.setAttribute("src",w)}))(i,this.domainUrl,c);if(o!==f.state)throw new G("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:f.code,grant_type:"authorization_code",redirect_uri:h,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},d),{scope:p,oauthTokenScope:d.scope,audience:u})}catch(c){throw c.error==="login_required"&&this.logout({openUrl:!1}),c}}async _getTokenUsingRefreshToken(e){const n=await this.cacheManager.get(new pe({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||"default",clientId:this.options.clientId}));if(!(n&&n.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw new Fn(e.authorizationParams.audience||"default",e.authorizationParams.scope)}const r=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,i=typeof e.timeoutInSeconds=="number"?1e3*e.timeoutInSeconds:null;try{const o=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:"refresh_token",refresh_token:n&&n.refresh_token,redirect_uri:r}),i&&{timeout:i}));return Object.assign(Object.assign({},o),{scope:e.authorizationParams.scope,oauthTokenScope:o.scope,audience:e.authorizationParams.audience||"default"})}catch(o){if((o.message.indexOf("Missing Refresh Token")>-1||o.message&&o.message.indexOf("invalid refresh token")>-1)&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw o}}async _saveEntryInCache(e){const{id_token:n,decodedToken:r}=e,i=te(e,["id_token","decodedToken"]);this.userCache.set("@@user@@",{id_token:n,decodedToken:r}),await this.cacheManager.setIdToken(this.options.clientId,e.id_token,e.decodedToken),await this.cacheManager.set(i)}async _getIdTokenFromCache(){const e=this.options.authorizationParams.audience||"default",n=await this.cacheManager.getIdToken(new pe({clientId:this.options.clientId,audience:e,scope:this.scope})),r=this.userCache.get("@@user@@");return n&&n.id_token===(r==null?void 0:r.id_token)?r:(this.userCache.set("@@user@@",n),n)}async _getEntryFromCache({scope:e,audience:n,clientId:r}){const i=await this.cacheManager.get(new pe({scope:e,audience:n,clientId:r}),60);if(i&&i.access_token){const{access_token:o,oauthTokenScope:a,expires_in:s}=i,h=await this._getIdTokenFromCache();return h&&Object.assign(Object.assign({id_token:h.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await Jr(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs},e),this.worker),a=await this._verifyIdToken(o.id_token,r,i);return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},o),{decodedToken:a,scope:e.scope,audience:e.audience||"default"}),o.scope?{oauthTokenScope:o.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(i||a.claims.org_id),Object.assign(Object.assign({},o),{decodedToken:a})}};async function ai(t){const e=new oi(t);return await e.checkSession(),e}const Gn="sesamy.com",si="https://logs.sesamy.com/events",Et="sesamyCacheTimestamp";var Q=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.CLEAR_CACHE="sesamyJsClearCache",t.USER_ATTRIBUTE_CHANGED="sesamyUserAttributeChanged",t.PURCHASE="sesamyJsPurchase",t))(Q||{});let B;const $t="sesamyAccessToken",Nt="sesamyExpires";function Ut(){const t=localStorage.getItem(Nt);if(!(t&&parseInt(t,10)<new Date().getTime()))return localStorage.getItem($t)}async function ci(t){if(t.enabled!==!1&&(B=await ai({domain:t.endpoint||`token.${Gn}`,clientId:t.clientId}),window.location.search.includes("code=")))try{await B.handleRedirectCallback();const e=await B.getUser();ue(Q.AUTHENTICATED,e);const n=new URL(location.href),r=n.searchParams;r.delete("code"),r.delete("state"),n.search=r.toString(),window.history.replaceState({},document.title,n.toString())}catch{}}async function ui(){if(Ut())return!0;if(!B)throw new Error("Auth0 client not initialized");return B.isAuthenticated()}async function li(){if(Ut())return{sub:"local",name:"Local User"};if(!B)throw new Error("Auth0 client not initialized");return B.getUser()}function Bn(){if(!B)throw new Error("Auth0 client not initialized");return B.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function di(t=!0){const e=Ut();if(e)return e;try{if(!B)throw new Error("Auth0 client not initialized");return await B.getTokenSilently()}catch(n){if(t)throw n;return null}}async function hi(){if(localStorage.removeItem($t),localStorage.removeItem(Nt),!B)throw new Error("Auth0 client not initialized");return ue(Q.LOGOUT,{}),B.logout({logoutParams:{returnTo:window.location.href}})}function fi(t){const e=t.split(".");if(e.length!==3)throw new Error("Invalid JWT token format.");const r=e[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(r).split("").map(function(o){return"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(i)}async function qn(t,e){localStorage.setItem($t,t),e&&localStorage.setItem(Nt,JSON.stringify(e*1e3+new Date().getTime()));const n=fi(t);ue(Q.AUTHENTICATED,n)}const pi=(t,e)=>e.skipDedupe||e.method!=="GET",mi=(t,e)=>e.method+"@"+t,gi=t=>t.clone(),Qt=({skip:t=pi,key:e=mi,resolver:n=gi}={})=>{const r=new Map;return i=>(o,a)=>{if(t(o,a))return i(o,a);const s=e(o,a);if(!r.has(s))r.set(s,[]);else return new Promise((h,p)=>{r.get(s).push([h,p])});try{return i(o,a).then(h=>(r.get(s).forEach(([p])=>p(n(h))),r.delete(s),h)).catch(h=>{throw r.get(s).forEach(([p,u])=>u(h)),r.delete(s),h})}catch(h){return r.delete(s),Promise.reject(h)}}},yi=(t,e)=>t*e,vi=t=>t&&t.ok,en=({delayTimer:t=500,delayRamp:e=yi,maxAttempts:n=10,until:r=vi,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>h=>(p,u)=>{let c=0;if(s&&s(p,u))return h(p,u);const f=(d,w)=>Promise.resolve(r(d,w)).then(k=>k?d&&a?d:w?Promise.reject(w):d:(c++,!n||c<=n?new Promise(v=>{const E=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:w,url:p,options:u})).then((_={})=>{var g,l;v(h((g=_&&_.url)!==null&&g!==void 0?g:p,(l=_&&_.options)!==null&&l!==void 0?l:u))}):v(h(p,u))},E)}).then(f).catch(v=>{if(!o)throw v;return f(null,v)}):d&&a?d:Promise.reject(w||new Error("Number of attempts exceeded."))));return h(p,u).then(f).catch(d=>{if(!o)throw d;return f(null,d)})},wi="application/json",Qn="Content-Type",ke=Symbol(),er=Symbol();function tn(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===Qn.toLowerCase()))===null||e===void 0?void 0:e[1]}function nn(t){return/^application\/.*json.*/.test(t)}const ge=function(t,e,n=!1){return Object.entries(e).reduce((r,[i,o])=>{const a=t[i];return Array.isArray(a)&&Array.isArray(o)?r[i]=n?[...a,...o]:o:typeof a=="object"&&typeof o=="object"?r[i]=ge(a,o,n):r[i]=o,r},{...t})},Oe={options:{},errorType:"text",polyfills:{},polyfill(t,e=!0,n=!1,...r){const i=this.polyfills[t]||(typeof self<"u"?self[t]:null)||(typeof global<"u"?global[t]:null);if(e&&!i)throw new Error(t+" is not defined");return n&&i?new i(...r):i}};function bi(t,e=!1){Oe.options=e?t:ge(Oe.options,t)}function ki(t,e=!1){Oe.polyfills=e?t:ge(Oe.polyfills,t)}function Ii(t){Oe.errorType=t}const Si=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class tr extends Error{}const _i=t=>{const e=Object.create(null);t=t._addons.reduce((g,l)=>l.beforeRequest&&l.beforeRequest(g,t._options,e)||g,t);const{_url:n,_options:r,_config:i,_catchers:o,_resolvers:a,_middlewares:s,_addons:h}=t,p=new Map(o),u=ge(i.options,r);let c=n;const f=Si(s)((g,l)=>(c=g,i.polyfill("fetch")(g,l)))(n,u),d=new Error,w=f.catch(g=>{throw{[ke]:g}}).then(g=>{if(!g.ok){const l=new tr;if(l.cause=d,l.stack=l.stack+`
5
- CAUSE: `+d.stack,l.response=g,l.url=c,g.type==="opaque")throw l;return g.text().then(b=>{var P;if(l.message=b,i.errorType==="json"||((P=g.headers.get("Content-Type"))===null||P===void 0?void 0:P.split(";")[0])==="application/json")try{l.json=JSON.parse(b)}catch{}throw l.text=b,l.status=g.status,l})}return g}),k=g=>g.catch(l=>{const b=l.hasOwnProperty(ke),P=b?l[ke]:l,O=(P==null?void 0:P.status)&&p.get(P.status)||p.get(P==null?void 0:P.name)||b&&p.has(ke)&&p.get(ke);if(O)return O(P,t);const j=p.get(er);if(j)return j(P,t);throw P}),v=g=>l=>k(g?w.then(b=>b&&b[g]()).then(b=>l?l(b):b):w.then(b=>l?l(b):b)),E={_wretchReq:t,_fetchReq:f,_sharedState:e,res:v(null),json:v("json"),blob:v("blob"),formData:v("formData"),arrayBuffer:v("arrayBuffer"),text:v("text"),error(g,l){return p.set(g,l),this},badRequest(g){return this.error(400,g)},unauthorized(g){return this.error(401,g)},forbidden(g){return this.error(403,g)},notFound(g){return this.error(404,g)},timeout(g){return this.error(408,g)},internalError(g){return this.error(500,g)},fetchError(g){return this.error(ke,g)}},_=h.reduce((g,l)=>({...g,...typeof l.resolver=="function"?l.resolver(g):l.resolver}),E);return a.reduce((g,l)=>l(g,t),_)},Ei={_url:"",_options:{},_config:Oe,_catchers:new Map,_resolvers:[],_deferred:[],_middlewares:[],_addons:[],addon(t){return{...this,_addons:[...this._addons,t],...t.wretch}},errorType(t){return{...this,_config:{...this._config,errorType:t}}},polyfills(t,e=!1){return{...this,_config:{...this._config,polyfills:e?t:ge(this._config.polyfills,t)}}},url(t,e=!1){if(e)return{...this,_url:t};const n=this._url.split("?");return{...this,_url:n.length>1?n[0]+t+"?"+n[1]:this._url+t}},options(t,e=!1){return{...this,_options:e?t:ge(this._options,t)}},headers(t){const e=t?Array.isArray(t)?Object.fromEntries(t):"entries"in t?Object.fromEntries(t.entries()):t:{};return{...this,_options:ge(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[Qn]:t})},auth(t){return this.headers({Authorization:t})},catcher(t,e){const n=new Map(this._catchers);return n.set(t,e),{...this,_catchers:n}},catcherFallback(t){return this.catcher(er,t)},resolve(t,e=!1){return{...this,_resolvers:e?[t]:[...this._resolvers,t]}},defer(t,e=!1){return{...this,_deferred:e?[t]:[...this._deferred,t]}},middlewares(t,e=!1){return{...this,_middlewares:e?t:[...this._middlewares,...t]}},fetch(t=this._options.method,e="",n=null){let r=this.url(e).options({method:t});const i=tn(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||nn(i));return r=n?o?r.json(n,i):r.body(n):r,_i(r._deferred.reduce((a,s)=>s(a,a._url,a._options),r))},get(t=""){return this.fetch("GET",t)},delete(t=""){return this.fetch("DELETE",t)},put(t,e=""){return this.fetch("PUT",e,t)},post(t,e=""){return this.fetch("POST",e,t)},patch(t,e=""){return this.fetch("PATCH",e,t)},head(t=""){return this.fetch("HEAD",t)},opts(t=""){return this.fetch("OPTIONS",t)},body(t){return{...this,_options:{...this._options,body:t}}},json(t,e){const n=tn(this._options.headers);return this.content(e||nn(n)&&n||wi).body(JSON.stringify(t))}};function le(t="",e={}){return{...Ei,_url:t,_options:e}}le.default=le;le.options=bi;le.errorType=Ii;le.polyfills=ki;le.WretchError=tr;function re(){sessionStorage.removeItem(Et),ue(Q.CLEAR_CACHE,{})}function Pi(t){const e=t.endpoint||`https://api2.${Gn}`,n=S=>async(I,N)=>{let K=sessionStorage.getItem(Et);K||(K=Date.now().toString(),sessionStorage.setItem(Et,K));const X={...N,headers:{...N.headers,"Cache-Timestamp":K}};return S(I,X)},r=(S=!0)=>I=>async(N,K)=>{let X=null;if(X=await di(S),!X){if(S)throw new Error("No access token available");return I(N,K)}const m={...K,headers:{...K.headers,...X?{Authorization:`Bearer ${X}`}:{}}};return I(N,m)},i=S=>(I,N)=>{if(N.headers.Authorization)return S(I,N);const K=localStorage.getItem("__anon_id"),X=btoa(`${K}:`),m={...N,headers:{...N.headers,Authorization:`Basic ${X}`}};return S(I,m)},o=le(e).headers({"Content-Type":"application/json"}).middlewares([n,r(),Qt(),en({delayTimer:1e3,delayRamp:(S,I)=>S*I,maxAttempts:3,until:S=>!!(S&&(S.ok||S.status>=400&&S.status<500)),retryOnNetworkError:!1})]),a=le(e).headers({"Content-Type":"application/json"}).middlewares([n,r(!1),i,Qt(),en({delayTimer:1e3,delayRamp:(S,I)=>S*I,maxAttempts:3,until:S=>!!(S&&(S.ok||S.status>=400&&S.status<500)),retryOnNetworkError:!1})]);async function s(){return o.get("/entitlements").json()}async function h(S){const I=await o.get("/entitlements").json();return I==null?void 0:I.find(N=>N.id===S)}async function p(S){return o.get(`/entitlements/${S}/access`).json()}async function u(){return o.get("/contracts").json()}async function c(S){const I=await o.get("/contracts").json();return I==null?void 0:I.find(N=>N.id===S)}async function f(){return o.get("/subscriptions").json()}async function d(){return o.get("/bills").json()}async function w(S){const I=await o.get("/bills").json();return I==null?void 0:I.find(N=>N.id===S)}async function k(S,I){const N=await o.url(`/user-metadata/${S}`).put(I).json();return ue(Q.USER_ATTRIBUTE_CHANGED,{}),re(),N}async function v(S){const I=await o.url(`/user-metadata/${S}`).delete().res();return re(),I.ok}async function E(S){return(await o.url(`/user-metadata/${S}`).get().json())[S]}async function _(){return await o.url("/user-metadata").get().json()}async function g(){return await o.url("/tags").get().json()}async function l(S){const I=await o.url(`/tags/${S}`).delete().res();return re(),I.ok}async function b(S){const I=await o.url("/tags").post(S).res();return ue(Q.USER_ATTRIBUTE_CHANGED,{}),re(),I.ok}async function P(S){return(await a.url("/tallies").get().json())[S]}async function O(){return await a.url("/tallies").get().json()}async function j(S){const I=await a.url(`/tallies/${S}`).delete().res();return re(),I.ok}async function D(S,I){return await a.url(`/tallies/${S}/push`).post(I).json()}async function L(S){return await o.url(`/products/${S}`).get().json()}async function H(){return await o.url("/profile").get().json()}async function A(){return await o.url("/payment-issues").get().json()}async function z(S){const I=await o.url(`/products/${S}/auto-onboard`).post().json();return I.length&&re(),I}return{getEntitlements:s,getEntitlement:h,getEntitlementAccess:p,getContracts:u,getContract:c,getProfile:H,getSubscriptions:f,getBills:d,getBill:w,setUserMetadata:k,deleteUserMetadata:v,getUserMetadata:E,listUserMetadata:_,getTags:g,deleteTag:l,setTag:b,getTally:P,getTallies:O,deleteTally:j,pushTally:D,getProduct:L,getPaymentIssues:A,autoOnboardProduct:z}}const nr="@sesamy/sesamy-js",zt="1.3.2";function rn(t,e,n,r,i){for(e=e.split?e.split("."):e,r=0;r<e.length;r++)t=t?t[e[r]]:i;return t===i?n:t}var Je="undefined",on="object",Pt=function(){},rr="any",ir="*",ve="__",tt=typeof process<"u"?process:{};tt.env&&tt.env.NODE_ENV;var J=typeof document<"u";tt.versions!=null&&tt.versions.node!=null;typeof Deno<"u"&&Deno.core;J&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function or(t,e){return e.charAt(0)[t]()+e.slice(1)}var Ti=or.bind(null,"toUpperCase"),Oi=or.bind(null,"toLowerCase");function ji(t){return ar(t)?Ti("null"):typeof t=="object"?$i(t):Object.prototype.toString.call(t).slice(8,-1)}function nt(t,e){e===void 0&&(e=!0);var n=ji(t);return e?Oi(n):n}function We(t,e){return typeof e===t}var Y=We.bind(null,"function"),se=We.bind(null,"string"),Se=We.bind(null,"undefined"),Ci=We.bind(null,"boolean");We.bind(null,"symbol");function ar(t){return t===null}function xi(t){return nt(t)==="number"&&!isNaN(t)}function sr(t){return nt(t)==="array"}function V(t){if(!Ai(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ai(t){return t&&(typeof t=="object"||t!==null)}function $i(t){return Y(t.constructor)?t.constructor.name:null}function Ni(t){return t instanceof Error||se(t.message)&&t.constructor&&xi(t.constructor.stackTraceLimit)}function cr(t,e){if(typeof e!="object"||ar(e))return!1;if(e instanceof t)return!0;var n=nt(new t(""));if(Ni(e))for(;e;){if(nt(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}cr.bind(null,TypeError);cr.bind(null,SyntaxError);function ot(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Ui(t,e):n}function Ui(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function at(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}at(ot,"form");at(ot,"button");at(ot,"input");at(ot,"select");function zi(t){return t?sr(t)?t:[t]:[]}function an(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Ri(){if(J){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Di(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Li(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=an(n[1]),a=an(n[2]);o.substring(o.length-2)==="[]"?(r[o=o.substring(0,o.length-2)]||(r[o]=[])).push(a):r[o]=a===""||a}for(var s in r){var h=s.split("[");h.length>1&&(Mi(r,h.map(function(p){return p.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return J&&window.location.search.substring(1)}(t))}function Mi(t,e,n){for(var r=e.length-1,i=0;i<r;++i){var o=e[i];if(o==="__proto__"||o==="constructor")break;o in t||(t[o]={}),t=t[o]}t[e[r]]=n}function st(){for(var t="",e=0,n=4294967295*Math.random()|0;e++<36;){var r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],i=15&n;t+=r=="-"||r=="4"?r:(r=="x"?i:3&i|8).toString(16),n=e%8==0?4294967295*Math.random()|0:n>>4}return t}function Zi(t,e){var n,r,i,o=null,a=0,s=function(){a=new Date,o=null,i=t.apply(n,r)};return function(){var h=new Date;a||(a=h);var p=e-(h-a);return n=this,r=arguments,p<=0?(clearTimeout(o),o=null,a=h,i=t.apply(n,r)):o||(o=setTimeout(s,p)),i}}var De="global",je=ve+"global"+ve,Ce=typeof self===on&&self.self===self&&self||typeof global===on&&global.global===global&&global||void 0;function we(t){return Ce[je][t]}function be(t,e){return Ce[je][t]=e}function Ae(t){delete Ce[je][t]}function $e(t,e,n){var r;try{if(Rt(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Ce[je]||(Ce[je]={});var Xe={};function Rt(t){if(typeof Xe[t]!==Je)return Xe[t];try{var e=window[t];e.setItem(Je,Je),e.removeItem(Je)}catch{return Xe[t]=!1}return Xe[t]=!0}function x(){return x=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},x.apply(this,arguments)}var ae="function",ie="undefined",Ki="@@redux/"+Math.random().toString(36),sn=function(){return typeof Symbol===ae&&Symbol.observable||"@@observable"}(),Ve=" != "+ae;function ur(t,e,n){var r;if(typeof e===ae&&typeof n===ie&&(n=e,e=void 0),typeof n!==ie){if(typeof n!==ae)throw new Error("enhancer"+Ve);return n(ur)(t,e)}if(typeof t!==ae)throw new Error("reducer"+Ve);var i=t,o=e,a=[],s=a,h=!1;function p(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==ae)throw new Error("Listener"+Ve);var w=!0;return p(),s.push(d),function(){if(w){w=!1,p();var k=s.indexOf(d);s.splice(k,1)}}}function f(d){if(!V(d))throw new Error("Act != obj");if(typeof d.type===ie)throw new Error("ActType "+ie);if(h)throw new Error("Dispatch in reducer");try{h=!0,o=i(o,d)}finally{h=!1}for(var w=a=s,k=0;k<w.length;k++)(0,w[k])();return d}return f({type:"@@redux/INIT"}),(r={dispatch:f,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ae)throw new Error("next reducer"+Ve);i=d,f({type:"@@redux/INIT"})}})[sn]=function(){var d,w=c;return(d={subscribe:function(k){if(typeof k!="object")throw new TypeError("Observer != obj");function v(){k.next&&k.next(u())}return v(),{unsubscribe:w(v)}}})[sn]=function(){return this},d},r}function Wi(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+ie}function xe(){var t=[].slice.call(arguments);return t.length===0?function(e){return e}:t.length===1?t[0]:t.reduce(function(e,n){return function(){return e(n.apply(void 0,[].slice.call(arguments)))}})}function Hi(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,h={getState:a.getState,dispatch:function(p){return s(p)}};return o=[].slice.call(t).map(function(p){return p(h)}),x({},a,{dispatch:s=xe.apply(void 0,o)(a.dispatch)})}}}var ce=ve+"anon_id",ye=ve+"user_id",Ee=ve+"user_traits",oe="userId",_e="anonymousId",et=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],Tt=["name","EVENTS","config","loaded"],C=et.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),cn=/^utm_/,un=/^an_prop_/,ln=/^an_trait_/;function Fi(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===C.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,h=i.initialUser,p=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(ce,a.anonymousId),p||e(ye,a.userId),h.traits&&e(Ee,x({},p&&s.traits?s.traits:{},h.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,f=o.an_event,d=u.reduce(function(w,k){if(k.match(cn)||k.match(/^(d|g)clid/)){var v=k.replace(cn,"");w.campaign[v==="campaign"?"name":v]=o[k]}return k.match(un)&&(w.props[k.replace(un,"")]=o[k]),k.match(ln)&&(w.traits[k.replace(ln,"")]=o[k]),w},{campaign:{},props:{},traits:{}});n.dispatch(x({type:C.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),f&&setTimeout(function(){return t.track(f,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:C.campaign,campaign:d.campaign})}}return r(i)}}}}function Ji(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===C.setItemEnd){if(n.key===ce)return x({},e,{anonymousId:n.value});if(n.key===ye)return x({},e,{userId:n.value})}switch(n.type){case C.identify:return Object.assign({},e,{userId:n.userId,traits:x({},e.traits,n.traits)});case C.reset:return[ye,ce,Ee].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function dn(t){return{userId:t.getItem(ye),anonymousId:t.getItem(ce),traits:t.getItem(Ee)}}var Ot=function(t){return ve+"TEMP"+ve+t};function Xi(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var h=s.userId,p=s.traits,u=s.options;if(s.type===C.reset&&([ye,Ee,ce].forEach(function(d){r(d)}),[oe,_e,"traits"].forEach(function(d){Ae(Ot(d))})),s.type===C.identify){i(ce)||n(ce,st());var c=i(ye),f=i(Ee)||{};c&&c!==h&&o.dispatch({type:C.userIdChanged,old:{userId:c,traits:f},new:{userId:h,traits:p},options:u}),h&&n(ye,h),p&&n(Ee,x({},f,p))}return a(s)}}}}var Re={};function hn(t,e){Re[t]&&Y(Re[t])&&(Re[t](e),delete Re[t])}function lr(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(x({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return lr(t,e,n-10).then(r,i)})})}function Vi(t){return{abort:t}}function dr(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,h=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var p=s.actions.reduce(function(c,f,d){return a[f.plugin].loaded?(c.process.push(f),c.processIndex.push(d)):(c.requeue.push(f),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(p.processIndex&&p.processIndex.length){p.processIndex.forEach(function(c){var f=s.actions[c],d=f.plugin,w=f.payload.type,k=i[d][w];if(k&&Y(k)){var v,E=function(l,b){return l===void 0&&(l={}),b===void 0&&(b={}),[oe,_e].reduce(function(P,O){return l.hasOwnProperty(O)&&b[O]&&b[O]!==l[O]&&(P[O]=b[O]),P},l)}(f.payload,h),_=r[E.meta.rid];if(!_&&(v=k({payload:E,config:a[d].config,instance:n,abort:Vi}))&&V(v)&&v.abort)return void(r[E.meta.rid]=!0);if(!_){var g=w+":"+d;t.dispatch(x({},E,{type:g,_:{called:g,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,f){return!~p.processIndex.indexOf(f)});s.actions=u}}}var mt=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,h=t.EVENTS;try{var p=i.plugins,u=i.context,c=n.type,f=c.match(Pe),d=e.exact.map(function(v){return v.pluginName});f&&(d=a.during.map(function(v){return v.pluginName}));var w=function(v,E){return function(_,g,l){var b=g.config,P=g.name,O=P+"."+_.type;l&&(O=l.event);var j=_.type.match(Pe)?function(D,L,H,A,z){return function(S,I){var N=A?A.name:D,K=I&&Ke(I)?I:H;if(A&&(!(K=I&&Ke(I)?I:[D]).includes(D)||K.length!==1))throw new Error("Method "+L+" can only abort "+D+" plugin. "+JSON.stringify(K)+" input valid");return x({},z,{abort:{reason:S,plugins:K,caller:L,_:N}})}}(P,O,E,l,_):function(D,L){return function(){throw new Error(D.type+" action not cancellable. Remove abort in "+L)}}(_,O);return{payload:Yi(_),instance:v,config:b||{},abort:j}}}(r,d),k=e.exact.reduce(function(v,E){var _=E.pluginName,g=E.methodName,l=!1;return g.match(/^initialize/)||g.match(/^reset/)||(l=!p[_].loaded),u.offline&&g.match(/^(page|track|identify)/)&&(l=!0),v[""+_]=l,v},{});return Promise.resolve(e.exact.reduce(function(v,E,_){try{var g=E.pluginName;return Promise.resolve(v).then(function(l){function b(){return Promise.resolve(l)}var P=function(){if(e.namespaced&&e.namespaced[g])return Promise.resolve(e.namespaced[g].reduce(function(O,j,D){try{return Promise.resolve(O).then(function(L){return j.method&&Y(j.method)?(function(S,I){var N=wn(S);if(N&&N.name===I){var K=wn(N.method);throw new Error([I+" plugin is calling method "+S,"Plugins cant call self","Use "+N.method+" "+(K?"or "+K.method:"")+" in "+I+" plugin insteadof "+S].join(`
6
- `))}}(j.methodName,j.pluginName),Promise.resolve(j.method({payload:L,instance:r,abort:(H=L,A=g,z=j.pluginName,function(S,I){return x({},H,{abort:{reason:S,plugins:I||[A],caller:c,from:z||A}})}),config:mn(j.pluginName,p,o),plugins:p})).then(function(S){var I=V(S)?S:{};return Promise.resolve(x({},L,I))})):L;var H,A,z})}catch(L){return Promise.reject(L)}},Promise.resolve(n))).then(function(O){l[g]=O});l[g]=n}();return P&&P.then?P.then(b):b()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(v){return Promise.resolve(e.exact.reduce(function(E,_,g){try{var l=e.exact.length===g+1,b=_.pluginName,P=o[b];return Promise.resolve(E).then(function(O){var j=v[b]?v[b]:{};if(f&&(j=O),yt(j,b))return gt({data:j,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(O);if(yt(O,b))return l&&gt({data:O,method:c,instance:r,store:s}),Promise.resolve(O);if(k.hasOwnProperty(b)&&k[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:j,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(O);var D=w(v[b],o[b]);return Promise.resolve(P[c]({abort:D.abort,payload:j,instance:r,config:mn(b,p,o),plugins:p})).then(function(L){var H=V(L)?L:{},A=x({},O,H),z=v[b];if(yt(z,b))gt({data:z,method:c,instance:r,pluginName:b,store:s});else{var S=c+":"+b;(S.match(/:/g)||[]).length<2&&!c.match(fn)&&!c.match(pn)&&r.dispatch(x({},f?A:j,{type:S,_:{called:S,from:"submethod"}}))}return Promise.resolve(A)})})}catch(O){return Promise.reject(O)}},Promise.resolve(n))).then(function(E){if(!(c.match(Pe)||c.match(/^registerPlugin/)||c.match(pn)||c.match(fn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(h.plugins.includes(c),E._&&E._.originalAction===c)return E;var _=x({},E,{_:{originalAction:E.type,called:E.type,from:"engineEnd"}});hr(E,e.exact.length)&&!c.match(/End$/)&&(_=x({},_,{type:E.type+"Aborted"})),s.dispatch(_)}return E})})}catch(v){return Promise.reject(v)}},Pe=/Start$/,fn=/^bootstrap/,pn=/^ready/;function gt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(x({},t.data,{type:n,_:{called:n,from:"abort"}}))}function mn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function gn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function yn(t,e){var n=t.replace(Pe,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function yt(t,e){var n=t.abort;return!!n&&(n===!0||vn(n,e)||n&&vn(n.plugins,e))}function hr(t,e){var n=t.abort;if(!n)return!1;if(n===!0||se(n))return!0;var r=n.plugins;return Ke(n)&&n.length===e||Ke(r)&&r.length===e}function Ke(t){return Array.isArray(t)}function vn(t,e){return!(!t||!Ke(t))&&t.includes(e)}function wn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Yi(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=V(t[n])?Object.assign({},t[n]):t[n]),e},{})}function Gi(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,h=function(l){return s?l:o(c)},p=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(p===C.enablePlugin&&i.dispatch({type:C.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),p===C.disablePlugin&&setTimeout(function(){return hn(a.meta.rid,{payload:a})},0),p===C.initializeEnd){var f=e(),d=Object.keys(f),w=d.filter(function(l){return u.includes(l)}).map(function(l){return f[l]}),k=[],v=[],E=a.disabled,_=w.map(function(l){var b=l.loaded,P=l.name,O=l.config;return lr(l,function(){return b({config:O})},1e4).then(function(j){return r[P]||(i.dispatch({type:C.pluginReadyType(P),name:P,events:Object.keys(l).filter(function(D){return!Tt.includes(D)})}),r[P]=!0),k=k.concat(P),l}).catch(function(j){if(j instanceof Error)throw new Error(j);return v=v.concat(j.name),j})});Promise.all(_).then(function(l){var b={plugins:k,failed:v,disabled:E};setTimeout(function(){d.length===_.length+E.length&&i.dispatch(x({},{type:C.ready},b))},0)})}var g=function(){if(p!==C.bootstrap)return/^ready:([^:]*)$/.test(p)&&setTimeout(function(){return dr(i,e,t)},0),Promise.resolve(function(l,b,P,O,j){try{var D=Y(b)?b():b,L=l.type,H=L.replace(Pe,"");if(l._&&l._.called)return Promise.resolve(l);var A=P.getState(),z=(N=D,(K=A.plugins)===void 0&&(K={}),(X=l.options)===void 0&&(X={}),Object.keys(N).filter(function(m){var y=X.plugins||{};return Ci(y[m])?y[m]:y.all!==!1&&(!K[m]||K[m].enabled!==!1)}).map(function(m){return N[m]}));L===C.initializeStart&&l.fromEnable&&(z=Object.keys(A.plugins).filter(function(m){var y=A.plugins[m];return l.plugins.includes(m)&&!y.initialized}).map(function(m){return D[m]}));var S=z.map(function(m){return m.name}),I=function(m,y,T){var $=yn(m).map(function(U){return gn(U,y)});return y.reduce(function(U,R){var F=R.name,Z=yn(m,F).map(function(Ne){return gn(Ne,y)}),W=Z[0],M=Z[1],ee=Z[2];return W.length&&(U.beforeNS[F]=W),M.length&&(U.duringNS[F]=M),ee.length&&(U.afterNS[F]=ee),U},{before:$[0],beforeNS:{},during:$[1],duringNS:{},after:$[2],afterNS:{}})}(L,z);return Promise.resolve(mt({action:l,data:{exact:I.before,namespaced:I.beforeNS},state:A,allPlugins:D,allMatches:I,instance:P,store:O,EVENTS:j})).then(function(m){function y(){var U=function(){if(L.match(Pe))return Promise.resolve(mt({action:x({},T,{type:H+"End"}),data:{exact:I.after,namespaced:I.afterNS},state:A,allPlugins:D,allMatches:I,instance:P,store:O,EVENTS:j})).then(function(R){R.meta&&R.meta.hasCallback&&hn(R.meta.rid,{payload:R})})}();return U&&U.then?U.then(function(){return m}):m}if(hr(m,S.length))return m;var T,$=function(){if(L!==H)return Promise.resolve(mt({action:x({},m,{type:H}),data:{exact:I.during,namespaced:I.duringNS},state:A,allPlugins:D,allMatches:I,instance:P,store:O,EVENTS:j})).then(function(U){T=U});T=m}();return $&&$.then?$.then(y):y()})}catch(m){return Promise.reject(m)}var N,K,X}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(g&&g.then?g.then(h):h(g))}catch(l){return Promise.reject(l)}}}}}function Bi(t){return function(e){return function(n){return function(r){var i=r.type,o=r.key,a=r.value,s=r.options;if(i===C.setItem||i===C.removeItem){if(r.abort)return n(r);i===C.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var qi=function(){var t=this;this.before=[],this.after=[],this.addMiddleware=function(e,n){t[n]=t[n].concat(e)},this.removeMiddleware=function(e,n){var r=t[n].findIndex(function(i){return i===e});r!==-1&&(t[n]=[].concat(t[n].slice(0,r),t[n].slice(r+1)))},this.dynamicMiddlewares=function(e){return function(n){return function(r){return function(i){var o={getState:n.getState,dispatch:function(s){return n.dispatch(s)}},a=t[e].map(function(s){return s(o)});return xe.apply(void 0,a)(r)(i)}}}}};function Qi(t){return function(e,n){e===void 0&&(e={});var r={};if(n.type==="initialize:aborted")return e;if(/^registerPlugin:([^:]*)$/.test(n.type)){var i=bn(n.type,"registerPlugin"),o=t()[i];if(!o||!i)return e;var a=n.enabled,s=o.config;return r[i]={enabled:a,initialized:!!a&&!o.initialize,loaded:!!a&&!!o.loaded({config:s}),config:s},x({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var h=bn(n.type,C.initialize),p=t()[h];return p&&h?(r[h]=x({},e[h],{initialized:!0,loaded:!!p.loaded({config:p.config})}),x({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=x({},e[n.name],{loaded:!0}),x({},e,r);switch(n.type){case C.disablePlugin:return x({},e,kn(n.plugins,!1,e));case C.enablePlugin:return x({},e,kn(n.plugins,!0,e));default:return e}}}function bn(t,e){return t.substring(e.length+1,t.length)}function kn(t,e,n){return t.reduce(function(r,i){return r[i]=x({},n[i],{enabled:e}),r},n)}function fr(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var eo={last:{},history:[]};function to(t,e){t===void 0&&(t=eo);var n=e.options,r=e.meta;if(e.type===C.track){var i=fr(x({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return x({},t,{last:i,history:t.history.concat(i)})}return t}var no={actions:[]};function ro(t,e){t===void 0&&(t=no);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===C.identify?[e].concat(t.actions):t.actions.concat(e),x({},t,{actions:r});case"dequeue":return[];default:return t}}var pr=/#.*$/;function io(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(pr,""):"")}var mr,gr,yr,vr,oo=function(t){if(t===void 0&&(t={}),!J)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,h=o.hash,p=o.search,u=function(f){var d=function(){if(J){for(var w,k=document.getElementsByTagName("link"),v=0;w=k[v];v++)if(w.getAttribute("rel")==="canonical")return w.getAttribute("href")}}();return d?d.match(/\?/)?d:d+f:window.location.href.replace(pr,"")}(p),c={title:n,url:u,path:io(u),hash:h,search:p,width:a,height:s};return r&&r!==""&&(c.referrer=r),x({},c,t)},ao={last:{},history:[]};function so(t,e){t===void 0&&(t=ao);var n=e.options;if(e.type===C.page){var r=fr(x({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return x({},t,{last:r,history:t.history.concat(r)})}return t}mr=function(){if(!J)return!1;var t=navigator.appVersion;return~t.indexOf("Win")?"Windows":~t.indexOf("Mac")?"MacOS":~t.indexOf("X11")?"UNIX":~t.indexOf("Linux")?"Linux":"Unknown OS"}(),gr=J?document.referrer:null,yr=Ri(),vr=Di();var In={initialized:!1,sessionId:st(),app:null,version:null,debug:!1,offline:!!J&&!navigator.onLine,os:{name:mr},userAgent:J?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:vr,locale:yr,campaign:{},referrer:gr};function co(t,e){t===void 0&&(t=In);var n=t.initialized,r=e.campaign;switch(e.type){case C.campaign:return x({},t,{campaign:r});case C.offline:return x({},t,{offline:!0});case C.online:return x({},t,{offline:!1});default:return n?t:x({},In,t,{initialized:!0})}}var uo=["plugins","reducers","storage"];function lo(t,e,n){if(J){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function ho(t){var e=lo.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function wr(){return be("analytics",[]),function(t){return function(e,n,r){var i=t(e,n,r),o=i.dispatch;return Object.assign(i,{dispatch:function(a){return Ce[je].analytics.push(a.action||a),o(a)}})}}}function Sn(t){return function(){return xe(xe.apply(null,arguments),wr())}}function vt(t){return t?sr(t)?t:[t]:[]}function _n(t,e,n){t===void 0&&(t={});var r,i,o=st();return e&&(Re[o]=(r=e,i=function(a){for(var s,h=a||Array.prototype.slice.call(arguments),p=0;p<h.length;p++)if(Y(h[p])){s=h[p];break}return s}(n),function(a){i&&i(a),r(a)})),x({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function fo(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(m,y){if(Y(y))return m.middlewares=m.middlewares.concat(y),m;if(y.NAMESPACE&&(y.name=y.NAMESPACE),!y.name)throw new Error("https://lytics.dev/errors/1");y.config||(y.config={});var T=y.EVENTS?Object.keys(y.EVENTS).map(function(R){return y.EVENTS[R]}):[];m.pluginEnabled[y.name]=!(y.enabled===!1||y.config.enabled===!1),delete y.enabled,y.methods&&(m.methods[y.name]=Object.keys(y.methods).reduce(function(R,F){var Z;return R[F]=(Z=y.methods[F],function(){for(var W=Array.prototype.slice.call(arguments),M=new Array(Z.length),ee=0;ee<W.length;ee++)M[ee]=W[ee];return M[M.length]=b,Z.apply({instance:b},M)}),R},{}),delete y.methods);var $=Object.keys(y).concat(T),U=new Set(m.events.concat($));if(m.events=Array.from(U),m.pluginsArray=m.pluginsArray.concat(y),m.plugins[y.name])throw new Error(y.name+"AlreadyLoaded");return m.plugins[y.name]=y,m.plugins[y.name].loaded||(m.plugins[y.name].loaded=function(){return!0}),m},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:we,setItem:be,removeItem:Ae},o=function(m){return function(y,T,$){return T.getState("user")[y]||($&&V($)&&$[y]?$[y]:dn(m)[y]||we(Ot(y))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!Tt.includes(m)}).sort(),h=new Set(s.concat(et).filter(function(m){return!Tt.includes(m)})),p=Array.from(h).sort(),u=function(){return a},c=new qi,f=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,k=function(){throw new Error("Abort disabled inListener")},v=Li(),E=dn(i),_=x({},E,n,v.an_uid?{userId:v.an_uid}:{},v.an_aid?{anonymousId:v.an_aid}:{});_.anonymousId||(_.anonymousId=st());var g=x({enable:function(m,y){return new Promise(function(T){I.dispatch({type:C.enablePlugin,plugins:vt(m),_:{originalAction:C.enablePlugin}},T,[y])})},disable:function(m,y){return new Promise(function(T){I.dispatch({type:C.disablePlugin,plugins:vt(m),_:{originalAction:C.disablePlugin}},T,[y])})}},r.methods),l=!1,b={identify:function(m,y,T,$){try{var U=se(m)?m:null,R=V(m)?m:y,F=T||{},Z=b.user();be(Ot(oe),U);var W=U||R.userId||o(oe,b,R);return Promise.resolve(new Promise(function(M){I.dispatch(x({type:C.identifyStart,userId:W,traits:R||{},options:F,anonymousId:Z.anonymousId},Z.id&&Z.id!==U&&{previousId:Z.id}),M,[y,T,$])}))}catch(M){return Promise.reject(M)}},track:function(m,y,T,$){try{var U=V(m)?m.event:m;if(!U||!se(U))throw new Error("EventMissing");var R=V(m)?m:y||{},F=V(T)?T:{};return Promise.resolve(new Promise(function(Z){I.dispatch({type:C.trackStart,event:U,properties:R,options:F,userId:o(oe,b,y),anonymousId:o(_e,b,y)},Z,[y,T,$])}))}catch(Z){return Promise.reject(Z)}},page:function(m,y,T){try{var $=V(m)?m:{},U=V(y)?y:{};return Promise.resolve(new Promise(function(R){I.dispatch({type:C.pageStart,properties:oo($),options:U,userId:o(oe,b,$),anonymousId:o(_e,b,$)},R,[m,y,T])}))}catch(R){return Promise.reject(R)}},user:function(m){if(m===oe||m==="id")return o(oe,b);if(m===_e||m==="anonId")return o(_e,b);var y=b.getState("user");return m?rn(y,m):y},reset:function(m){return new Promise(function(y){I.dispatch({type:C.resetStart},y,m)})},ready:function(m){return l&&m({plugins:g,instance:b}),b.on(C.ready,function(y){m(y),l=!0})},on:function(m,y){if(!m||!Y(y))return!1;if(m===C.bootstrap)throw new Error(".on disabled for "+m);var T=/Start$|Start:/;if(m==="*"){var $=function(Z){return function(W){return function(M){return M.type.match(T)&&y({payload:M,instance:b,plugins:a}),W(M)}}},U=function(Z){return function(W){return function(M){return M.type.match(T)||y({payload:M,instance:b,plugins:a}),W(M)}}};return f($,Ye),f(U,Ge),function(){d($,Ye),d(U,Ge)}}var R=m.match(T)?Ye:Ge,F=function(Z){return function(W){return function(M){return M.type===m&&y({payload:M,instance:b,plugins:a,abort:k}),W(M)}}};return f(F,R),function(){return d(F,R)}},once:function(m,y){if(!m||!Y(y))return!1;if(m===C.bootstrap)throw new Error(".once disabled for "+m);var T=b.on(m,function($){y({payload:$.payload,instance:b,plugins:a,abort:k}),T()});return T},getState:function(m){var y=I.getState();return m?rn(y,m):Object.assign({},y)},dispatch:function(m){var y=se(m)?{type:m}:m;if(et.includes(y.type))throw new Error("reserved action "+y.type);var T=x({},y,{_:x({originalAction:y.type},m._||{})});I.dispatch(T)},enablePlugin:g.enable,disablePlugin:g.disable,plugins:g,storage:{getItem:i.getItem,setItem:function(m,y,T){I.dispatch({type:C.setItemStart,key:m,value:y,options:T})},removeItem:function(m,y){I.dispatch({type:C.removeItemStart,key:m,options:y})}},setAnonymousId:function(m,y){b.storage.setItem(ce,m,y)},events:{core:et,plugins:s}},P=r.middlewares.concat([function(m){return function(y){return function(T){return T.meta||(T.meta=_n()),y(T)}}},w(Ye),Gi(b,u,{all:p,plugins:s}),Bi(i),Fi(b),Xi(b),w(Ge)]),O={context:co,user:Ji(i),page:so,track:to,plugins:Qi(u),queue:ro},j=xe,D=xe;if(J&&t.debug){var L=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;L&&(j=L({trace:!0,traceLimit:25})),D=function(){return arguments.length===0?wr():V(typeof arguments[0])?Sn():Sn().apply(null,arguments)}}var H,A=function(m){return Object.keys(m).reduce(function(y,T){return uo.includes(T)||(y[T]=m[T]),y},{})}(t),z=r.pluginsArray.reduce(function(m,y){var T=y.name,$=y.config,U=y.loaded,R=r.pluginEnabled[T];return m[T]={enabled:R,initialized:!!R&&!y.initialize,loaded:!!U({config:$}),config:$},m},{}),S={context:A,user:_,plugins:z},I=ur(function(m){for(var y=Object.keys(m),T={},$=0;$<y.length;$++){var U=y[$];typeof m[U]===ae&&(T[U]=m[U])}var R,F=Object.keys(T);try{(function(Z){Object.keys(Z).forEach(function(W){var M=Z[W];if(typeof M(void 0,{type:"@@redux/INIT"})===ie||typeof M(void 0,{type:Ki})===ie)throw new Error("reducer "+W+" "+ie)})})(T)}catch(Z){R=Z}return function(Z,W){if(Z===void 0&&(Z={}),R)throw R;for(var M=!1,ee={},Ne=0;Ne<F.length;Ne++){var He=F[Ne],Ht=Z[He],lt=(0,T[He])(Ht,W);if(typeof lt===ie){var $r=Wi(He,W);throw new Error($r)}ee[He]=lt,M=M||lt!==Ht}return M?ee:Z}}(x({},O,e)),S,D(j(Hi.apply(void 0,P))));I.dispatch=(H=I.dispatch,function(m,y,T){var $=x({},m,{meta:_n(m.meta,y,vt(T))});return H.apply(null,[$])});var N=Object.keys(a);I.dispatch({type:C.bootstrap,plugins:N,config:A,params:v,user:_,initialUser:n,persistedUser:E});var K=N.filter(function(m){return r.pluginEnabled[m]}),X=N.filter(function(m){return!r.pluginEnabled[m]});return I.dispatch({type:C.registerPlugins,plugins:N,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,y){var T=m.bootstrap,$=m.config,U=m.name;T&&Y(T)&&T({instance:b,config:$,payload:m}),I.dispatch({type:C.registerPluginType(U),name:U,enabled:r.pluginEnabled[U],plugin:m}),r.pluginsArray.length===y+1&&I.dispatch({type:C.initializeStart,plugins:K,disabled:X})}),ho(function(m){I.dispatch({type:m?C.offline:C.online})}),function(m,y,T){setInterval(function(){return dr(m,y,T)},3e3)}(I,u,b),b}var Ye="before",Ge="after",Le="cookie",fe=Ir(),br=ct,po=ct;function kr(t){return fe?ct(t,"",-1):Ae(t)}function Ir(){if(fe!==void 0)return fe;var t="cookiecookie";try{ct(t,t),fe=document.cookie.indexOf(t)!==-1,kr(t)}catch{fe=!1}return fe}function ct(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return fe===!1&&(a?be(t,e):we(t)),a?document.cookie=t+"="+encodeURIComponent(e)+(n?"; expires="+new Date(+new Date+1e3*n).toUTCString()+(r?"; path="+r:"")+(i?"; domain="+i:"")+(o?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+t+"=")[1]||"").split(";")[0])}}var Me="localStorage",mo=Rt.bind(null,"localStorage");$e("localStorage","getItem",we);$e("localStorage","setItem",be);$e("localStorage","removeItem",Ae);var Ze="sessionStorage",go=Rt.bind(null,"sessionStorage");$e("sessionStorage","getItem",we);$e("sessionStorage","setItem",be);$e("sessionStorage","removeItem",Ae);function Te(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(V(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var yo=mo(),vo=go(),wo=Ir();function Sr(t,e){if(t){var n=Dt(e),r=!Kt(n),i=Lt(n)?Te(localStorage.getItem(t)):void 0;if(r&&!Se(i))return i;var o=Mt(n)?Te(br(t)):void 0;if(r&&o)return o;var a=Zt(n)?Te(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=we(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function bo(t,e,n){if(t&&!Se(e)){var r={},i=Dt(n),o=JSON.stringify(e),a=!Kt(i);return Lt(i)&&(r[Me]=Be(Me,e,Te(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Me]:Mt(i)&&(r[Le]=Be(Le,e,Te(br(t))),po(t,o),a)?r[Le]:Zt(i)&&(r[Ze]=Be(Ze,e,Te(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Ze]:(r[De]=Be(De,e,we(t)),be(t,e),a?r[De]:r)}}function ko(t,e){if(t){var n=Dt(e),r=Sr(t,ir),i={};return!Se(r.localStorage)&&Lt(n)&&(localStorage.removeItem(t),i[Me]=r.localStorage),!Se(r.cookie)&&Mt(n)&&(kr(t),i[Le]=r.cookie),!Se(r.sessionStorage)&&Zt(n)&&(sessionStorage.removeItem(t),i[Ze]=r.sessionStorage),!Se(r.global)&&ut(n,De)&&(Ae(t),i[De]=r.global),i}}function Dt(t){return t?se(t)?t:t.storage:rr}function Lt(t){return yo&&ut(t,Me)}function Mt(t){return wo&&ut(t,Le)}function Zt(t){return vo&&ut(t,Ze)}function Kt(t){return t===ir||t==="all"}function ut(t,e){return t===rr||t===e||Kt(t)}function Be(t,e,n){return{location:t,current:e,previous:n}}var Io={setItem:bo,getItem:Sr,removeItem:ko};function So(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function En(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Pn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?En(Object(n),!0).forEach(function(r){So(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):En(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _o(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:Io};return fo(Pn(Pn({},e),t))}function Eo(t,e){e=e||{};var n,r,i=[],o=e.max||1/0;function a(){clearInterval(n),t(i.splice(0,o)),s()}function s(){n=setInterval(a,e.interval||1e4)}return s(),{flush:a,push:function(h){return r=i.push(h),r>=o&&a(),r},size:function(){return i.length},end:function(h){h&&a(),clearInterval(n)}}}function Po(t){if(typeof window>"u")return;const{addEventListener:e,history:n,location:r}=window;let i=r.pathname;e("popstate",()=>t(r.pathname)),["push","replace"].map(o=>{const a=`${o}State`;if(a!=="pushState"&&a!=="replaceState")return;const s=n[a];n[a]=function(...h){var c;const p=((c=h[2])==null?void 0:c.toString())||"",u=Oo(p);return i!==u&&(i=u,setTimeout(()=>t(p),0)),s.apply(n,h)}})}function To(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function Oo(t){return["#","?"].forEach(e=>t=To(t,e)),t}function jo(){Po(()=>{ne.page()})}function Co(t){if(t===void 0&&(t={}),!J)return Pt;var e=On(),n=jt(),r=Tn(),i=qe(r,e),o=qe(n,e),a=[],s=[],h=[],p=r,u=i,c=o,f=Object.keys(t);if(!f.length)return Pt;var d=f.map(function(k){return Number(k)}),w=Zi(function(){var k=On(),v=function(A,z){return z.map(function(S){return S===100?A-5:A*(S/100)})}(k,d),E=jt(),_=Tn(),g=qe(_,k),l=qe(E,k);if(u=g>u?g:u,c=l<c?l:c,!(a.length>=d.length)){var b=p===_,P="up";b?P="initial":p<=_&&(P="down");var O=v,j=d;(P==="up"||b)&&(O=v.slice().reverse(),j=d.slice().reverse());var D=j.reduce(function(A,z,S){var I=O[S];return h.includes(z)&&_<=I&&(h=h.filter(function(N){return N!==z}),A.singleFunction=z),P==="down"&&!a.includes(z)&&_>=I&&z>o?(s.push(z),A.callbacks=A.callbacks.concat(z),A):P==="up"&&!a.includes(z)&&_<=I&&z<=g?(A.foundFunc=[z],A):(b&&_>=I&&A.foundFunc.length===0&&(A.foundFunc=[z]),!s.includes(z)&&_>=I&&(s.push(z),A.singleFunction?h.push(z):A.singleFunction=z),A)},{foundFunc:[],singleFunction:null,callbacks:[],direction:P});if(p=_,P==="down"&&D.callbacks&&D.callbacks.forEach(function(A){Y(t[A])&&(t[A]({trigger:A,direction:P,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(A))}),D.singleFunction){var L=D.singleFunction,H=D.direction;Y(t[L])&&t[L]({trigger:L,direction:H,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(L)}}},500);return window.addEventListener("scroll",w),function(){return window.removeEventListener("scroll",w)}}function jt(){return J?document.body.scrollTop||document.documentElement.scrollTop:0}function xo(){return J?window.innerHeight||document.documentElement.clientHeight:0}function Tn(){return Math.round(jt()+xo())}function On(){if(!J)return 0;var t=document.body,e=document.documentElement;return Math.max(t.scrollHeight,t.offsetHeight,e.clientHeight,e.scrollHeight,e.offsetHeight)}function qe(t,e){return Math.round(t/e*100)}var jn="EventListener";function Ao(t){return function(e,n,r,i){var o=r||Pt,a=i||!1;if(!J)return o;var s=rt(n),h=rt(e,!0);if(!h.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var p=[];return function u(c){c&&(p=[]);for(var f=c?"add"+jn:"remove"+jn,d=0;d<h.length;d++){var w=h[d];p[d]=c?a&&a.once?$o(o):o:p[d]||o;for(var k=0;k<s.length;k++)w[f]?w["on"+s[k]]=c?p[d]:null:w[f](s[k],p[d],a)}return u.bind(null,!c)}(t)}}function rt(t,e){if(se(t))return e?rt(document.querySelectorAll(t)):(n=t).split(n.indexOf(",")>-1?",":" ").map(function(a){return a.trim()});var n;if(NodeList.prototype.isPrototypeOf(t)){for(var r=[],i=t.length>>>0;i--;)r[i]=t[i];return r}var o=zi(t);return e?o.map(function(a){return se(a)?rt(a,!0):a}).flat():o}function $o(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var wt=Ao("Event");function _r(t,e){return J&&Y(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),Y(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}_r.bind(null,"onerror");_r.bind(null,"onload");var Er=typeof window>"u",Cn="hidden";function No(t){if(Er)return!1;var e=Uo(),n="".concat(e.replace(/[H|h]idden/,""),"visibilitychange"),r=function(){return t(!!document[e])},i=function(){return document.addEventListener(n,r)};return i(),function(){return document.removeEventListener(n,r),i}}function Uo(){var t=["webkit","moz","ms","o"];return Er||Cn in document?Cn:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var zo=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Ro(t,e){e===void 0&&(e={});var n=function(a,s){var h=this,p=!1;return function(u){p||(a.call(h,u),p=!0,setTimeout(function(){return p=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=No(function(s){s||n({type:"tabVisible"})});return r=[a].concat(zo.map(function(s){return wt(document,s,n)})).concat(wt(window,"load",n)).concat(wt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Do(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,h=t.throttle,p=h===void 0?2e3:h,u=!1,c=!1,f=new Date,d=function(){return clearTimeout(e)};function w(v){d(),o&&!u&&o(ze(f),v),i&&u&&(u=!1,i(ze(n),v),f=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(ze(f),v))},s)}var k=Ro(w,{throttle:p});return{disable:function(){c=!0,u=!1,d();var v=k();return function(){return c=!1,f=new Date,w({type:"load"}),v()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:ze(f,c),idle:u?ze(n,c):0}}}}function ze(t,e){return e?0:Math.round((new Date-t)/1e3)}const xn=5e3;class Lo{constructor(e){q(this,"element");q(this,"isInViewport",!1);q(this,"isAwake",!1);q(this,"isFlushing");q(this,"observer");q(this,"lastEventAt",Date.now());q(this,"registeredView",!1);q(this,"viewCallback");q(this,"activeDurationCallback");q(this,"idleDurationCallback");q(this,"scrollCallback");this.element=e.element,this.viewCallback=e.viewCallback,this.activeDurationCallback=e.activeDurationCallback,this.idleDurationCallback=e.idleDurationCallback,this.scrollCallback=e.scrollCallback,this.observer=new IntersectionObserver(n=>{n.forEach(r=>{this.handleInViewPort(r.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),Do({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:xn}),Co({25:this.handleScroll.bind(this),50:this.handleScroll.bind(this),75:this.handleScroll.bind(this),90:this.handleScroll.bind(this),100:this.handleScroll.bind(this)})}flush(){this.isFlushing=!0,this.handleAwake(!this.isAwake)}handleInViewPort(e){e?(this.isAwake=!0,this.trackInViewport()):this.handleAwake(!1),this.isInViewport=e}handleAwake(e,n=Math.round((Date.now()-this.lastEventAt)/1e3)){this.isAwake=e,this.lastEventAt=e?Date.now()-n*xn:Date.now(),this.isInViewport&&this.trackAwake(e,n)}handleScroll(e){this.scrollCallback&&this.scrollCallback(e)}handleVisibilityChange(){this.isAwake=!1;const e=Math.round((Date.now()-this.lastEventAt)/1e3);e>1&&(this.lastEventAt=Date.now(),this.trackAwake(!1,e))}trackAwake(e,n){!e&&this.activeDurationCallback&&this.activeDurationCallback(n,this.isFlushing,this.lastEventAt),e&&this.idleDurationCallback&&this.idleDurationCallback(n,this.isFlushing,this.lastEventAt)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}const An="sesamy_session_id";function Mo(){let t=sessionStorage.getItem(An);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(An,t)),t}let Pr=!1,Ct,$n,it;function Zo({clientId:t,enabled:e=!0,endpoint:n=si}){if(Ct=t,$n=e,it=n,!$n)return;jo();const r=new Lo({element:document.body,viewCallback:()=>{ne.page()},activeDurationCallback:(i,o,a)=>{ne.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{ne.track("idleDuration",{duration:i,durationStart:a,flushing:o})},scrollCallback:i=>{ne.track("scroll",{scroll:i.scrollMax})}});Ho(document.body,()=>{r.flush()}),Fo(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(Q.AUTHENTICATED,async i=>{const o=i;await ne.identify(o.detail.sub)}),window.addEventListener(Q.LOGOUT,async()=>{await ne.track("logout",{}),Wt.flush(),await ne.reset()})}function Tr(t){return JSON.stringify(t.map(e=>({...e,clientId:Ct,requestId:Math.random().toString(36).slice(2,9),sessionId:Mo(),timestamp:new Date().toISOString(),version:zt,event:e.event,context:{page:{url:window.location.hostname,path:window.location.pathname,title:document.title,search:window.location.search,referrer:document.referrer},locale:navigator.language,library:nr,userAgent:navigator.userAgent,clientId:Ct}})))}const Wt=Eo(async t=>{if(t.length>0){const e=Tr(t);Pr?navigator.sendBeacon(it,e):(await fetch(it,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function bt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(it,Tr([n]))}else Wt.push(t)}const ne=_o({app:nr,version:zt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;bt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;bt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;bt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Ko(t,e){ne.track(t,e)}function Wo(){return Pr=!0,Wt.flush()}const Or=new Map;function Ho(t,e){Or.set(t,e)}window.addEventListener("beforeunload",()=>{Or.forEach((t,e)=>{t.bind(e)()}),Wo()});const jr=new Map;function Fo(t,e){jr.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&jr.forEach((t,e)=>{t.bind(e)()})});const Cr="sesamySignedURLs";function xr(){const t=sessionStorage.getItem(Cr);return t?JSON.parse(t):[]}function Jo(t){const e=xr();e.push(t),sessionStorage.setItem(Cr,JSON.stringify(e))}function Xo(t){const{getEntitlement:e,getEntitlements:n,getEntitlementAccess:r,getSubscriptions:i,getContract:o,getContracts:a,getBill:s,getBills:h,getProfile:p,getTags:u,deleteTag:c,setTag:f,getUserMetadata:d,listUserMetadata:w,setUserMetadata:k,deleteUserMetadata:v,getTally:E,getTallies:_,pushTally:g,deleteTally:l,getProduct:b,getPaymentIssues:P,autoOnboardProduct:O}=Pi(t),j={auth:{getUser:p,isAuthenticated:ui,loginWithRedirect:Bn,logout:hi,setToken:qn},analytics:{track:Ko},tags:{list:u,set:f,delete:c},entitlements:{get:e,list:n,access:r,signedLinks:xr},contracts:{get:o,list:a},bills:{get:s,list:h},userMetadata:{get:d,list:w,set:k,delete:v},tallies:{get:E,list:_,push:g,delete:l},subscriptions:{list:i},products:{get:b,autoOnboard:O},getVersion:Vo,getPaymentIssues:P,clearCache:re};return t.namespace&&(window[t.namespace]=j),j}function Vo(){return zt}function Yo(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e){qn(e,n?parseInt(n,10):void 0);const r=new URL(window.location.href);t.delete("access_token"),t.delete("expires_in"),r.hash=t.toString(),window.history.replaceState(null,"",r)}}const Nn="sesamy-refresh",Un="force-refetch-entitlements";function Go(){const t=new URLSearchParams(window.location.search),e=t.get(Un),n=t.get(Nn);if(e!==null||n!==null){const r=new URL(window.location.href);t.delete(Un),t.delete(Nn),r.search=t.toString(),re(),window.history.replaceState(null,"",r)}}function Bo(){const t=new URLSearchParams(window.location.search),e=t.get("token"),n=t.get("se");if(!n||!e)return;const r=parseInt(n,10);if(Number.isNaN(r)||r<Date.now())return;Jo({url:window.location.href.split("?")[0],token:e,expiresAt:r,publisherContentId:t.get("sp")??void 0});const i=new URL(window.location.href);i.searchParams.delete("ss"),i.searchParams.delete("se"),i.searchParams.delete("sp"),i.searchParams.delete("so"),i.searchParams.delete("token"),window.history.replaceState(null,"",i)}const zn="sesamy-user";async function qo(){const e=new URLSearchParams(window.location.search).get(zn);if(!e)return;const n=await li();(n==null?void 0:n.email)!==e&&Bn();const r=new URL(window.location.href);r.searchParams.delete(zn),window.history.replaceState(null,"",r)}const Rn="sesamy-purchase";function Qo(){const t=new URLSearchParams(window.location.search),e=t.get(Rn);if(e!==null){const n=new URL(window.location.href);t.delete(Rn),n.search=t.toString(),ue(Q.PURCHASE,{itemSrc:e}),re(),window.history.replaceState(null,"",n)}}async function Ar(t){Zo({clientId:t.clientId,...t.analytics}),await ci({clientId:t.clientId,...t.auth});const e=Xo(t.api||{});return ue(Q.READY,{}),Yo(),Go(),Bo(),await qo(),Qo(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);Ar(e)}catch(e){console.error("Failed to parse config",e)}}exports.init=Ar;
4
+ `)})(),e.cache&&e.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),e.cache)r=e.cache;else{if(n=e.cacheLocation||"memory",!Bt(n))throw new Error(`Invalid cache location "${n}"`);r=Bt(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?Ie:Qr,this.orgHintCookieName=`auth0.${this.options.clientId}.organization_hint`,this.isAuthenticatedCookieName=(a=>`auth0.${a}.is.authenticated`)(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;const i=e.useCookiesForTransactions?this.cookieStorage:ei;var o;this.scope=Fe("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Yr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Ln,this.cacheManager=new Vr(r,r.allKeys?void 0:new ri(r,this.options.clientId),this.nowProvider),this.domainUrl=(o=this.options.domain,/^https?:\/\//.test(o)?o:`https://${o}`),this.tokenIssuer=((a,s)=>a?a.startsWith("https://")?a:`https://${a}/`:`${s}/`)(this.options.issuer,this.domainUrl),typeof window<"u"&&window.Worker&&this.options.useRefreshTokens&&n==="memory"&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new ni)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Dn)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${St(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return Br({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:n,organization:r,leeway:this.options.leeway,max_age:(o=this.options.authorizationParams.max_age,typeof o!="string"?o:parseInt(o,10)||void 0),now:i});var o}_processOrgHint(e){e?this.cookieStorage.save(this.orgHintCookieName,e,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}async _prepareAuthorizeUrl(e,n,r){const i=Jt(dt()),o=Jt(dt()),a=dt(),s=(u=>{const c=new Uint8Array(u);return(p=>{const d={"+":"-","/":"_","=":""};return p.replace(/[+/=]/g,w=>d[w])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Qe().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),h=((u,c,p,d,w,I,v,_)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),p),{scope:Fe(c,p.scope),response_type:"code",response_mode:_||"query",state:d,nonce:w,redirect_uri:v||u.authorizationParams.redirect_uri,code_challenge:I,code_challenge_method:"S256"}))(this.options,this.scope,e,i,o,s,e.redirect_uri||this.options.authorizationParams.redirect_uri||r,n==null?void 0:n.response_mode),f=this._authorizeUrl(h);return{nonce:o,code_verifier:a,scope:h.scope,audience:h.audience||"default",redirect_uri:h.redirect_uri,state:i,url:f}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const h=window.screenX+(window.innerWidth-400)/2,f=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${h},top=${f},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!n.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const i=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await(s=>new Promise((h,f)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(p),window.removeEventListener("message",u,!1),f(new Mr(s.popup)))},1e3),p=setTimeout(()=>{clearInterval(c),f(new Lr(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(p),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return f(G.fromPayload(d.data.response));h(d.data.response)}},window.addEventListener("message",u)}))(Object.assign(Object.assign({},n),{timeoutInSeconds:n.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}));if(i.state!==o.state)throw new G("state_mismatch","Invalid state");const a=((r=e.authorizationParams)===null||r===void 0?void 0:r.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:i.audience,scope:i.scope,code_verifier:i.code_verifier,grant_type:"authorization_code",code:o.code,redirect_uri:i.redirect_uri},{nonceIn:i.nonce,organization:a})}async getUser(){var e;const n=await this._getIdTokenFromCache();return(e=n==null?void 0:n.decodedToken)===null||e===void 0?void 0:e.user}async getIdTokenClaims(){var e;const n=await this._getIdTokenFromCache();return(e=n==null?void 0:n.decodedToken)===null||e===void 0?void 0:e.claims}async loginWithRedirect(e={}){var n;const r=qt(e),{openUrl:i,fragment:o,appState:a}=r,s=ne(r,["openUrl","fragment","appState"]),h=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,f=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=f,c=ne(f,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),h&&{organization:h}));const p=o?`${u}#${o}`:u;i?await i(p):window.location.assign(p)}async handleRedirectCallback(e=window.location.href){const n=e.split("?").slice(1);if(n.length===0)throw new Error("There are no query params available for parsing.");const{state:r,code:i,error:o,error_description:a}=(c=>{c.indexOf("#")>-1&&(c=c.substring(0,c.indexOf("#")));const p=new URLSearchParams(c);return{state:p.get("state"),code:p.get("code")||void 0,error:p.get("error")||void 0,error_description:p.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new G("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new Dr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new G("state_mismatch","Invalid state");const h=s.organization,f=s.nonce,u=s.redirect_uri;return await this._requestToken(Object.assign({audience:s.audience,scope:s.scope,code_verifier:s.code_verifier,grant_type:"authorization_code",code:i},u?{redirect_uri:u}:{}),{nonceIn:f,organization:h}),{appState:s.appState}}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get("auth0.is.authenticated"))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove("auth0.is.authenticated")}try{await this.getTokenSilently(e)}catch{}}async getTokenSilently(e={}){var n;const r=Object.assign(Object.assign({cacheMode:"on"},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Fe(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=ft[a];return s||(s=o().finally(()=>{delete ft[a],s=null}),ft[a]=s),s})(()=>this._getTokenSilently(r),`${this.options.clientId}::${r.authorizationParams.audience}::${r.authorizationParams.scope}`);return e.detailedResponse?i:i==null?void 0:i.access_token}async _getTokenSilently(e){const{cacheMode:n}=e,r=ne(e,["cacheMode"]);if(n!=="off"){const i=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(i)return i}if(n!=="cache-only"){if(!await(async(i,o=3)=>{for(let a=0;a<o;a++)if(await i())return!0;return!1})(()=>pt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new It;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const f=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(f)return f}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:h}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:h})}finally{await pt.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}}async getTokenWithPopup(e={},n={}){var r;const i=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Fe(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},Rr),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new pe({scope:i.authorizationParams.scope,audience:i.authorizationParams.audience||"default",clientId:this.options.clientId}))).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(e){e.clientId!==null?e.clientId=e.clientId||this.options.clientId:delete e.clientId;const n=e.logoutParams||{},{federated:r}=n,i=ne(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${St(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=qt(e),{openUrl:r}=n,i=ne(n,["openUrl"]);e.clientId===null?await this.cacheManager.clear():await this.cacheManager.clear(e.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove("@@user@@");const o=this._buildLogoutUrl(i);r?await r(o):r!==!1&&window.location.assign(o)}async _getTokenFromIFrame(e){const n=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),r=this.cookieStorage.get(this.orgHintCookieName);r&&!n.organization&&(n.organization=r);const{url:i,state:o,nonce:a,code_verifier:s,redirect_uri:h,scope:f,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new G("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const c=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,p=await((w,I,v=60)=>new Promise((_,S)=>{const y=window.document.createElement("iframe");y.setAttribute("width","0"),y.setAttribute("height","0"),y.style.display="none";const l=()=>{window.document.body.contains(y)&&(window.document.body.removeChild(y),window.removeEventListener("message",k,!1))};let k;const P=setTimeout(()=>{S(new It),l()},1e3*v);k=function(O){if(O.origin!=I||!O.data||O.data.type!=="authorization_response")return;const j=O.source;j&&j.close(),O.data.response.error?S(G.fromPayload(O.data.response)):_(O.data.response),clearTimeout(P),window.removeEventListener("message",k,!1),setTimeout(l,2e3)},window.addEventListener("message",k,!1),window.document.body.appendChild(y),y.setAttribute("src",w)}))(i,this.domainUrl,c);if(o!==p.state)throw new G("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:p.code,grant_type:"authorization_code",redirect_uri:h,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},d),{scope:f,oauthTokenScope:d.scope,audience:u})}catch(c){throw c.error==="login_required"&&this.logout({openUrl:!1}),c}}async _getTokenUsingRefreshToken(e){const n=await this.cacheManager.get(new pe({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||"default",clientId:this.options.clientId}));if(!(n&&n.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw new Fn(e.authorizationParams.audience||"default",e.authorizationParams.scope)}const r=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,i=typeof e.timeoutInSeconds=="number"?1e3*e.timeoutInSeconds:null;try{const o=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:"refresh_token",refresh_token:n&&n.refresh_token,redirect_uri:r}),i&&{timeout:i}));return Object.assign(Object.assign({},o),{scope:e.authorizationParams.scope,oauthTokenScope:o.scope,audience:e.authorizationParams.audience||"default"})}catch(o){if((o.message.indexOf("Missing Refresh Token")>-1||o.message&&o.message.indexOf("invalid refresh token")>-1)&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw o}}async _saveEntryInCache(e){const{id_token:n,decodedToken:r}=e,i=ne(e,["id_token","decodedToken"]);this.userCache.set("@@user@@",{id_token:n,decodedToken:r}),await this.cacheManager.setIdToken(this.options.clientId,e.id_token,e.decodedToken),await this.cacheManager.set(i)}async _getIdTokenFromCache(){const e=this.options.authorizationParams.audience||"default",n=await this.cacheManager.getIdToken(new pe({clientId:this.options.clientId,audience:e,scope:this.scope})),r=this.userCache.get("@@user@@");return n&&n.id_token===(r==null?void 0:r.id_token)?r:(this.userCache.set("@@user@@",n),n)}async _getEntryFromCache({scope:e,audience:n,clientId:r}){const i=await this.cacheManager.get(new pe({scope:e,audience:n,clientId:r}),60);if(i&&i.access_token){const{access_token:o,oauthTokenScope:a,expires_in:s}=i,h=await this._getIdTokenFromCache();return h&&Object.assign(Object.assign({id_token:h.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await Jr(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs},e),this.worker),a=await this._verifyIdToken(o.id_token,r,i);return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},o),{decodedToken:a,scope:e.scope,audience:e.audience||"default"}),o.scope?{oauthTokenScope:o.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(i||a.claims.org_id),Object.assign(Object.assign({},o),{decodedToken:a})}};async function ai(t){const e=new oi(t);return await e.checkSession(),e}const Gn="sesamy.com",si="https://logs.sesamy.com/events",Et="sesamyCacheTimestamp";var Q=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.CLEAR_CACHE="sesamyJsClearCache",t.USER_ATTRIBUTE_CHANGED="sesamyUserAttributeChanged",t.PURCHASE="sesamyJsPurchase",t))(Q||{});let B;const $t="sesamyAccessToken",Nt="sesamyExpires";function Ut(){const t=localStorage.getItem(Nt);if(!(t&&parseInt(t,10)<new Date().getTime()))return localStorage.getItem($t)}async function ci(t){if(t.enabled!==!1&&(B=await ai({domain:t.endpoint||`token.${Gn}`,clientId:t.clientId}),window.location.search.includes("code=")))try{await B.handleRedirectCallback();const e=await B.getUser();ue(Q.AUTHENTICATED,e);const n=new URL(location.href),r=n.searchParams;r.delete("code"),r.delete("state"),n.search=r.toString(),window.history.replaceState({},document.title,n.toString())}catch{}}async function ui(){if(Ut())return!0;if(!B)throw new Error("Auth0 client not initialized");return B.isAuthenticated()}async function li(){if(Ut())return{sub:"local",name:"Local User"};if(!B)throw new Error("Auth0 client not initialized");return B.getUser()}function Bn(){if(!B)throw new Error("Auth0 client not initialized");return B.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function di(t=!0){const e=Ut();if(e)return e;try{if(!B)throw new Error("Auth0 client not initialized");return await B.getTokenSilently()}catch(n){if(t)throw n;return null}}async function hi(){if(localStorage.removeItem($t),localStorage.removeItem(Nt),!B)throw new Error("Auth0 client not initialized");return ue(Q.LOGOUT,{}),B.logout({logoutParams:{returnTo:window.location.href}})}function fi(t){const e=t.split(".");if(e.length!==3)throw new Error("Invalid JWT token format.");const r=e[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(r).split("").map(function(o){return"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(i)}async function qn(t,e){localStorage.setItem($t,t),e&&localStorage.setItem(Nt,JSON.stringify(e*1e3+new Date().getTime()));const n=fi(t);ue(Q.AUTHENTICATED,n)}const pi=(t,e)=>e.skipDedupe||e.method!=="GET",mi=(t,e)=>e.method+"@"+t,gi=t=>t.clone(),Qt=({skip:t=pi,key:e=mi,resolver:n=gi}={})=>{const r=new Map;return i=>(o,a)=>{if(t(o,a))return i(o,a);const s=e(o,a);if(!r.has(s))r.set(s,[]);else return new Promise((h,f)=>{r.get(s).push([h,f])});try{return i(o,a).then(h=>(r.get(s).forEach(([f])=>f(n(h))),r.delete(s),h)).catch(h=>{throw r.get(s).forEach(([f,u])=>u(h)),r.delete(s),h})}catch(h){return r.delete(s),Promise.reject(h)}}},yi=(t,e)=>t*e,vi=t=>t&&t.ok,en=({delayTimer:t=500,delayRamp:e=yi,maxAttempts:n=10,until:r=vi,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>h=>(f,u)=>{let c=0;if(s&&s(f,u))return h(f,u);const p=(d,w)=>Promise.resolve(r(d,w)).then(I=>I?d&&a?d:w?Promise.reject(w):d:(c++,!n||c<=n?new Promise(v=>{const _=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:w,url:f,options:u})).then((S={})=>{var y,l;v(h((y=S&&S.url)!==null&&y!==void 0?y:f,(l=S&&S.options)!==null&&l!==void 0?l:u))}):v(h(f,u))},_)}).then(p).catch(v=>{if(!o)throw v;return p(null,v)}):d&&a?d:Promise.reject(w||new Error("Number of attempts exceeded."))));return h(f,u).then(p).catch(d=>{if(!o)throw d;return p(null,d)})},wi="application/json",Qn="Content-Type",ke=Symbol(),er=Symbol();function tn(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===Qn.toLowerCase()))===null||e===void 0?void 0:e[1]}function nn(t){return/^application\/.*json.*/.test(t)}const ge=function(t,e,n=!1){return Object.entries(e).reduce((r,[i,o])=>{const a=t[i];return Array.isArray(a)&&Array.isArray(o)?r[i]=n?[...a,...o]:o:typeof a=="object"&&typeof o=="object"?r[i]=ge(a,o,n):r[i]=o,r},{...t})},Oe={options:{},errorType:"text",polyfills:{},polyfill(t,e=!0,n=!1,...r){const i=this.polyfills[t]||(typeof self<"u"?self[t]:null)||(typeof global<"u"?global[t]:null);if(e&&!i)throw new Error(t+" is not defined");return n&&i?new i(...r):i}};function bi(t,e=!1){Oe.options=e?t:ge(Oe.options,t)}function ki(t,e=!1){Oe.polyfills=e?t:ge(Oe.polyfills,t)}function Ii(t){Oe.errorType=t}const Si=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class tr extends Error{}const _i=t=>{const e=Object.create(null);t=t._addons.reduce((y,l)=>l.beforeRequest&&l.beforeRequest(y,t._options,e)||y,t);const{_url:n,_options:r,_config:i,_catchers:o,_resolvers:a,_middlewares:s,_addons:h}=t,f=new Map(o),u=ge(i.options,r);let c=n;const p=Si(s)((y,l)=>(c=y,i.polyfill("fetch")(y,l)))(n,u),d=new Error,w=p.catch(y=>{throw{[ke]:y}}).then(y=>{if(!y.ok){const l=new tr;if(l.cause=d,l.stack=l.stack+`
5
+ CAUSE: `+d.stack,l.response=y,l.url=c,y.type==="opaque")throw l;return y.text().then(k=>{var P;if(l.message=k,i.errorType==="json"||((P=y.headers.get("Content-Type"))===null||P===void 0?void 0:P.split(";")[0])==="application/json")try{l.json=JSON.parse(k)}catch{}throw l.text=k,l.status=y.status,l})}return y}),I=y=>y.catch(l=>{const k=l.hasOwnProperty(ke),P=k?l[ke]:l,O=(P==null?void 0:P.status)&&f.get(P.status)||f.get(P==null?void 0:P.name)||k&&f.has(ke)&&f.get(ke);if(O)return O(P,t);const j=f.get(er);if(j)return j(P,t);throw P}),v=y=>l=>I(y?w.then(k=>k&&k[y]()).then(k=>l?l(k):k):w.then(k=>l?l(k):k)),_={_wretchReq:t,_fetchReq:p,_sharedState:e,res:v(null),json:v("json"),blob:v("blob"),formData:v("formData"),arrayBuffer:v("arrayBuffer"),text:v("text"),error(y,l){return f.set(y,l),this},badRequest(y){return this.error(400,y)},unauthorized(y){return this.error(401,y)},forbidden(y){return this.error(403,y)},notFound(y){return this.error(404,y)},timeout(y){return this.error(408,y)},internalError(y){return this.error(500,y)},fetchError(y){return this.error(ke,y)}},S=h.reduce((y,l)=>({...y,...typeof l.resolver=="function"?l.resolver(y):l.resolver}),_);return a.reduce((y,l)=>l(y,t),S)},Ei={_url:"",_options:{},_config:Oe,_catchers:new Map,_resolvers:[],_deferred:[],_middlewares:[],_addons:[],addon(t){return{...this,_addons:[...this._addons,t],...t.wretch}},errorType(t){return{...this,_config:{...this._config,errorType:t}}},polyfills(t,e=!1){return{...this,_config:{...this._config,polyfills:e?t:ge(this._config.polyfills,t)}}},url(t,e=!1){if(e)return{...this,_url:t};const n=this._url.split("?");return{...this,_url:n.length>1?n[0]+t+"?"+n[1]:this._url+t}},options(t,e=!1){return{...this,_options:e?t:ge(this._options,t)}},headers(t){const e=t?Array.isArray(t)?Object.fromEntries(t):"entries"in t?Object.fromEntries(t.entries()):t:{};return{...this,_options:ge(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[Qn]:t})},auth(t){return this.headers({Authorization:t})},catcher(t,e){const n=new Map(this._catchers);return n.set(t,e),{...this,_catchers:n}},catcherFallback(t){return this.catcher(er,t)},resolve(t,e=!1){return{...this,_resolvers:e?[t]:[...this._resolvers,t]}},defer(t,e=!1){return{...this,_deferred:e?[t]:[...this._deferred,t]}},middlewares(t,e=!1){return{...this,_middlewares:e?t:[...this._middlewares,...t]}},fetch(t=this._options.method,e="",n=null){let r=this.url(e).options({method:t});const i=tn(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||nn(i));return r=n?o?r.json(n,i):r.body(n):r,_i(r._deferred.reduce((a,s)=>s(a,a._url,a._options),r))},get(t=""){return this.fetch("GET",t)},delete(t=""){return this.fetch("DELETE",t)},put(t,e=""){return this.fetch("PUT",e,t)},post(t,e=""){return this.fetch("POST",e,t)},patch(t,e=""){return this.fetch("PATCH",e,t)},head(t=""){return this.fetch("HEAD",t)},opts(t=""){return this.fetch("OPTIONS",t)},body(t){return{...this,_options:{...this._options,body:t}}},json(t,e){const n=tn(this._options.headers);return this.content(e||nn(n)&&n||wi).body(JSON.stringify(t))}};function le(t="",e={}){return{...Ei,_url:t,_options:e}}le.default=le;le.options=bi;le.errorType=Ii;le.polyfills=ki;le.WretchError=tr;function te(){sessionStorage.removeItem(Et),ue(Q.CLEAR_CACHE,{})}function Pi(t){const e=t.endpoint||`https://api2.${Gn}`,n=b=>async(E,U)=>{let X=sessionStorage.getItem(Et);X||(X=Date.now().toString(),sessionStorage.setItem(Et,X));const m={...U,headers:{...U.headers,"Cache-Timestamp":X}};return b(E,m)},r=(b=!0)=>E=>async(U,X)=>{let m=null;if(m=await di(b),!m){if(b)throw new Error("No access token available");return E(U,X)}const g={...X,headers:{...X.headers,...m?{Authorization:`Bearer ${m}`}:{}}};return E(U,g)},i=b=>(E,U)=>{if(U.headers.Authorization)return b(E,U);const X=localStorage.getItem("__anon_id"),m=btoa(`${X}:`),g={...U,headers:{...U.headers,Authorization:`Basic ${m}`}};return b(E,g)},o=le(e).headers({"Content-Type":"application/json"}).middlewares([n,r(),Qt(),en({delayTimer:1e3,delayRamp:(b,E)=>b*E,maxAttempts:3,until:b=>!!(b&&(b.ok||b.status>=400&&b.status<500)),retryOnNetworkError:!1})]),a=le(e).headers({"Content-Type":"application/json"}).middlewares([n,r(!1),i,Qt(),en({delayTimer:1e3,delayRamp:(b,E)=>b*E,maxAttempts:3,until:b=>!!(b&&(b.ok||b.status>=400&&b.status<500)),retryOnNetworkError:!1})]);async function s(){return o.get("/entitlements").json()}async function h(b){const E=await o.get("/entitlements").json();return E==null?void 0:E.find(U=>U.id===b)}async function f(b){return o.get(`/entitlements/${b}/access`).json()}async function u(){return o.get("/contracts").json()}async function c(b){const E=await o.get("/contracts").json();return E==null?void 0:E.find(U=>U.id===b)}async function p(){return o.get("/subscriptions").json()}async function d(){return o.get("/bills").json()}async function w(b){const E=await o.get("/bills").json();return E==null?void 0:E.find(U=>U.id===b)}async function I(b,E){const U=await o.url(`/user-metadata/${b}`).put(E).json();return ue(Q.USER_ATTRIBUTE_CHANGED,{}),te(),U}async function v(b){const E=await o.url(`/user-metadata/${b}`).delete().res();return te(),E.ok}async function _(b){return(await o.url(`/user-metadata/${b}`).get().json())[b]}async function S(){return await o.url("/user-metadata").get().json()}async function y(){return await o.url("/tags").get().json()}async function l(b){const E=await o.url(`/tags/${b}`).delete().res();return te(),E.ok}async function k(b){const E=await o.url("/tags").post(b).res();return ue(Q.USER_ATTRIBUTE_CHANGED,{}),te(),E.ok}async function P(b){return(await a.url("/tallies").get().json())[b]}async function O(){return await a.url("/tallies").get().json()}async function j(b){const E=await a.url(`/tallies/${b}`).delete().res();return te(),E.ok}async function z(b,E){return await a.url(`/tallies/${b}/push`).post(E).json()}async function L(b){return await o.url(`/products/${b}`).get().json()}async function H(){return await o.url("/profile").get().json()}async function A(b){const E=await o.url("/profile").patch(b).res();return te(),E.ok}async function R(){return await o.url("/payment-issues").get().json()}async function K(b){const E=await o.url(`/products/${b}/auto-onboard`).post().json();return E.length&&te(),E}return{getEntitlements:s,getEntitlement:h,getEntitlementAccess:f,getContracts:u,getContract:c,getProfile:H,updateProfile:A,getSubscriptions:p,getBills:d,getBill:w,setUserMetadata:I,deleteUserMetadata:v,getUserMetadata:_,listUserMetadata:S,getTags:y,deleteTag:l,setTag:k,getTally:P,getTallies:O,deleteTally:j,pushTally:z,getProduct:L,getPaymentIssues:R,autoOnboardProduct:K}}const nr="@sesamy/sesamy-js",zt="1.3.2";function rn(t,e,n,r,i){for(e=e.split?e.split("."):e,r=0;r<e.length;r++)t=t?t[e[r]]:i;return t===i?n:t}var Je="undefined",on="object",Pt=function(){},rr="any",ir="*",ve="__",tt=typeof process<"u"?process:{};tt.env&&tt.env.NODE_ENV;var J=typeof document<"u";tt.versions!=null&&tt.versions.node!=null;typeof Deno<"u"&&Deno.core;J&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function or(t,e){return e.charAt(0)[t]()+e.slice(1)}var Ti=or.bind(null,"toUpperCase"),Oi=or.bind(null,"toLowerCase");function ji(t){return ar(t)?Ti("null"):typeof t=="object"?$i(t):Object.prototype.toString.call(t).slice(8,-1)}function nt(t,e){e===void 0&&(e=!0);var n=ji(t);return e?Oi(n):n}function We(t,e){return typeof e===t}var Y=We.bind(null,"function"),se=We.bind(null,"string"),Se=We.bind(null,"undefined"),Ci=We.bind(null,"boolean");We.bind(null,"symbol");function ar(t){return t===null}function xi(t){return nt(t)==="number"&&!isNaN(t)}function sr(t){return nt(t)==="array"}function V(t){if(!Ai(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ai(t){return t&&(typeof t=="object"||t!==null)}function $i(t){return Y(t.constructor)?t.constructor.name:null}function Ni(t){return t instanceof Error||se(t.message)&&t.constructor&&xi(t.constructor.stackTraceLimit)}function cr(t,e){if(typeof e!="object"||ar(e))return!1;if(e instanceof t)return!0;var n=nt(new t(""));if(Ni(e))for(;e;){if(nt(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}cr.bind(null,TypeError);cr.bind(null,SyntaxError);function ot(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Ui(t,e):n}function Ui(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function at(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}at(ot,"form");at(ot,"button");at(ot,"input");at(ot,"select");function zi(t){return t?sr(t)?t:[t]:[]}function an(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Ri(){if(J){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Di(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Li(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=an(n[1]),a=an(n[2]);o.substring(o.length-2)==="[]"?(r[o=o.substring(0,o.length-2)]||(r[o]=[])).push(a):r[o]=a===""||a}for(var s in r){var h=s.split("[");h.length>1&&(Mi(r,h.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return J&&window.location.search.substring(1)}(t))}function Mi(t,e,n){for(var r=e.length-1,i=0;i<r;++i){var o=e[i];if(o==="__proto__"||o==="constructor")break;o in t||(t[o]={}),t=t[o]}t[e[r]]=n}function st(){for(var t="",e=0,n=4294967295*Math.random()|0;e++<36;){var r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],i=15&n;t+=r=="-"||r=="4"?r:(r=="x"?i:3&i|8).toString(16),n=e%8==0?4294967295*Math.random()|0:n>>4}return t}function Zi(t,e){var n,r,i,o=null,a=0,s=function(){a=new Date,o=null,i=t.apply(n,r)};return function(){var h=new Date;a||(a=h);var f=e-(h-a);return n=this,r=arguments,f<=0?(clearTimeout(o),o=null,a=h,i=t.apply(n,r)):o||(o=setTimeout(s,f)),i}}var De="global",je=ve+"global"+ve,Ce=typeof self===on&&self.self===self&&self||typeof global===on&&global.global===global&&global||void 0;function we(t){return Ce[je][t]}function be(t,e){return Ce[je][t]=e}function Ae(t){delete Ce[je][t]}function $e(t,e,n){var r;try{if(Rt(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Ce[je]||(Ce[je]={});var Xe={};function Rt(t){if(typeof Xe[t]!==Je)return Xe[t];try{var e=window[t];e.setItem(Je,Je),e.removeItem(Je)}catch{return Xe[t]=!1}return Xe[t]=!0}function x(){return x=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},x.apply(this,arguments)}var ae="function",ie="undefined",Ki="@@redux/"+Math.random().toString(36),sn=function(){return typeof Symbol===ae&&Symbol.observable||"@@observable"}(),Ve=" != "+ae;function ur(t,e,n){var r;if(typeof e===ae&&typeof n===ie&&(n=e,e=void 0),typeof n!==ie){if(typeof n!==ae)throw new Error("enhancer"+Ve);return n(ur)(t,e)}if(typeof t!==ae)throw new Error("reducer"+Ve);var i=t,o=e,a=[],s=a,h=!1;function f(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==ae)throw new Error("Listener"+Ve);var w=!0;return f(),s.push(d),function(){if(w){w=!1,f();var I=s.indexOf(d);s.splice(I,1)}}}function p(d){if(!V(d))throw new Error("Act != obj");if(typeof d.type===ie)throw new Error("ActType "+ie);if(h)throw new Error("Dispatch in reducer");try{h=!0,o=i(o,d)}finally{h=!1}for(var w=a=s,I=0;I<w.length;I++)(0,w[I])();return d}return p({type:"@@redux/INIT"}),(r={dispatch:p,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ae)throw new Error("next reducer"+Ve);i=d,p({type:"@@redux/INIT"})}})[sn]=function(){var d,w=c;return(d={subscribe:function(I){if(typeof I!="object")throw new TypeError("Observer != obj");function v(){I.next&&I.next(u())}return v(),{unsubscribe:w(v)}}})[sn]=function(){return this},d},r}function Wi(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+ie}function xe(){var t=[].slice.call(arguments);return t.length===0?function(e){return e}:t.length===1?t[0]:t.reduce(function(e,n){return function(){return e(n.apply(void 0,[].slice.call(arguments)))}})}function Hi(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,h={getState:a.getState,dispatch:function(f){return s(f)}};return o=[].slice.call(t).map(function(f){return f(h)}),x({},a,{dispatch:s=xe.apply(void 0,o)(a.dispatch)})}}}var ce=ve+"anon_id",ye=ve+"user_id",Ee=ve+"user_traits",oe="userId",_e="anonymousId",et=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],Tt=["name","EVENTS","config","loaded"],C=et.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),cn=/^utm_/,un=/^an_prop_/,ln=/^an_trait_/;function Fi(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===C.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,h=i.initialUser,f=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(ce,a.anonymousId),f||e(ye,a.userId),h.traits&&e(Ee,x({},f&&s.traits?s.traits:{},h.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,p=o.an_event,d=u.reduce(function(w,I){if(I.match(cn)||I.match(/^(d|g)clid/)){var v=I.replace(cn,"");w.campaign[v==="campaign"?"name":v]=o[I]}return I.match(un)&&(w.props[I.replace(un,"")]=o[I]),I.match(ln)&&(w.traits[I.replace(ln,"")]=o[I]),w},{campaign:{},props:{},traits:{}});n.dispatch(x({type:C.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),p&&setTimeout(function(){return t.track(p,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:C.campaign,campaign:d.campaign})}}return r(i)}}}}function Ji(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===C.setItemEnd){if(n.key===ce)return x({},e,{anonymousId:n.value});if(n.key===ye)return x({},e,{userId:n.value})}switch(n.type){case C.identify:return Object.assign({},e,{userId:n.userId,traits:x({},e.traits,n.traits)});case C.reset:return[ye,ce,Ee].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function dn(t){return{userId:t.getItem(ye),anonymousId:t.getItem(ce),traits:t.getItem(Ee)}}var Ot=function(t){return ve+"TEMP"+ve+t};function Xi(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var h=s.userId,f=s.traits,u=s.options;if(s.type===C.reset&&([ye,Ee,ce].forEach(function(d){r(d)}),[oe,_e,"traits"].forEach(function(d){Ae(Ot(d))})),s.type===C.identify){i(ce)||n(ce,st());var c=i(ye),p=i(Ee)||{};c&&c!==h&&o.dispatch({type:C.userIdChanged,old:{userId:c,traits:p},new:{userId:h,traits:f},options:u}),h&&n(ye,h),f&&n(Ee,x({},p,f))}return a(s)}}}}var Re={};function hn(t,e){Re[t]&&Y(Re[t])&&(Re[t](e),delete Re[t])}function lr(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(x({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return lr(t,e,n-10).then(r,i)})})}function Vi(t){return{abort:t}}function dr(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,h=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var f=s.actions.reduce(function(c,p,d){return a[p.plugin].loaded?(c.process.push(p),c.processIndex.push(d)):(c.requeue.push(p),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(c){var p=s.actions[c],d=p.plugin,w=p.payload.type,I=i[d][w];if(I&&Y(I)){var v,_=function(l,k){return l===void 0&&(l={}),k===void 0&&(k={}),[oe,_e].reduce(function(P,O){return l.hasOwnProperty(O)&&k[O]&&k[O]!==l[O]&&(P[O]=k[O]),P},l)}(p.payload,h),S=r[_.meta.rid];if(!S&&(v=I({payload:_,config:a[d].config,instance:n,abort:Vi}))&&V(v)&&v.abort)return void(r[_.meta.rid]=!0);if(!S){var y=w+":"+d;t.dispatch(x({},_,{type:y,_:{called:y,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,p){return!~f.processIndex.indexOf(p)});s.actions=u}}}var mt=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,h=t.EVENTS;try{var f=i.plugins,u=i.context,c=n.type,p=c.match(Pe),d=e.exact.map(function(v){return v.pluginName});p&&(d=a.during.map(function(v){return v.pluginName}));var w=function(v,_){return function(S,y,l){var k=y.config,P=y.name,O=P+"."+S.type;l&&(O=l.event);var j=S.type.match(Pe)?function(z,L,H,A,R){return function(K,b){var E=A?A.name:z,U=b&&Ke(b)?b:H;if(A&&(!(U=b&&Ke(b)?b:[z]).includes(z)||U.length!==1))throw new Error("Method "+L+" can only abort "+z+" plugin. "+JSON.stringify(U)+" input valid");return x({},R,{abort:{reason:K,plugins:U,caller:L,_:E}})}}(P,O,_,l,S):function(z,L){return function(){throw new Error(z.type+" action not cancellable. Remove abort in "+L)}}(S,O);return{payload:Yi(S),instance:v,config:k||{},abort:j}}}(r,d),I=e.exact.reduce(function(v,_){var S=_.pluginName,y=_.methodName,l=!1;return y.match(/^initialize/)||y.match(/^reset/)||(l=!f[S].loaded),u.offline&&y.match(/^(page|track|identify)/)&&(l=!0),v[""+S]=l,v},{});return Promise.resolve(e.exact.reduce(function(v,_,S){try{var y=_.pluginName;return Promise.resolve(v).then(function(l){function k(){return Promise.resolve(l)}var P=function(){if(e.namespaced&&e.namespaced[y])return Promise.resolve(e.namespaced[y].reduce(function(O,j,z){try{return Promise.resolve(O).then(function(L){return j.method&&Y(j.method)?(function(K,b){var E=wn(K);if(E&&E.name===b){var U=wn(E.method);throw new Error([b+" plugin is calling method "+K,"Plugins cant call self","Use "+E.method+" "+(U?"or "+U.method:"")+" in "+b+" plugin insteadof "+K].join(`
6
+ `))}}(j.methodName,j.pluginName),Promise.resolve(j.method({payload:L,instance:r,abort:(H=L,A=y,R=j.pluginName,function(K,b){return x({},H,{abort:{reason:K,plugins:b||[A],caller:c,from:R||A}})}),config:mn(j.pluginName,f,o),plugins:f})).then(function(K){var b=V(K)?K:{};return Promise.resolve(x({},L,b))})):L;var H,A,R})}catch(L){return Promise.reject(L)}},Promise.resolve(n))).then(function(O){l[y]=O});l[y]=n}();return P&&P.then?P.then(k):k()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(v){return Promise.resolve(e.exact.reduce(function(_,S,y){try{var l=e.exact.length===y+1,k=S.pluginName,P=o[k];return Promise.resolve(_).then(function(O){var j=v[k]?v[k]:{};if(p&&(j=O),yt(j,k))return gt({data:j,method:c,instance:r,pluginName:k,store:s}),Promise.resolve(O);if(yt(O,k))return l&&gt({data:O,method:c,instance:r,store:s}),Promise.resolve(O);if(I.hasOwnProperty(k)&&I[k]===!0)return s.dispatch({type:"queue",plugin:k,payload:j,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(O);var z=w(v[k],o[k]);return Promise.resolve(P[c]({abort:z.abort,payload:j,instance:r,config:mn(k,f,o),plugins:f})).then(function(L){var H=V(L)?L:{},A=x({},O,H),R=v[k];if(yt(R,k))gt({data:R,method:c,instance:r,pluginName:k,store:s});else{var K=c+":"+k;(K.match(/:/g)||[]).length<2&&!c.match(fn)&&!c.match(pn)&&r.dispatch(x({},p?A:j,{type:K,_:{called:K,from:"submethod"}}))}return Promise.resolve(A)})})}catch(O){return Promise.reject(O)}},Promise.resolve(n))).then(function(_){if(!(c.match(Pe)||c.match(/^registerPlugin/)||c.match(pn)||c.match(fn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(h.plugins.includes(c),_._&&_._.originalAction===c)return _;var S=x({},_,{_:{originalAction:_.type,called:_.type,from:"engineEnd"}});hr(_,e.exact.length)&&!c.match(/End$/)&&(S=x({},S,{type:_.type+"Aborted"})),s.dispatch(S)}return _})})}catch(v){return Promise.reject(v)}},Pe=/Start$/,fn=/^bootstrap/,pn=/^ready/;function gt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(x({},t.data,{type:n,_:{called:n,from:"abort"}}))}function mn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function gn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function yn(t,e){var n=t.replace(Pe,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function yt(t,e){var n=t.abort;return!!n&&(n===!0||vn(n,e)||n&&vn(n.plugins,e))}function hr(t,e){var n=t.abort;if(!n)return!1;if(n===!0||se(n))return!0;var r=n.plugins;return Ke(n)&&n.length===e||Ke(r)&&r.length===e}function Ke(t){return Array.isArray(t)}function vn(t,e){return!(!t||!Ke(t))&&t.includes(e)}function wn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Yi(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=V(t[n])?Object.assign({},t[n]):t[n]),e},{})}function Gi(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,h=function(l){return s?l:o(c)},f=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(f===C.enablePlugin&&i.dispatch({type:C.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),f===C.disablePlugin&&setTimeout(function(){return hn(a.meta.rid,{payload:a})},0),f===C.initializeEnd){var p=e(),d=Object.keys(p),w=d.filter(function(l){return u.includes(l)}).map(function(l){return p[l]}),I=[],v=[],_=a.disabled,S=w.map(function(l){var k=l.loaded,P=l.name,O=l.config;return lr(l,function(){return k({config:O})},1e4).then(function(j){return r[P]||(i.dispatch({type:C.pluginReadyType(P),name:P,events:Object.keys(l).filter(function(z){return!Tt.includes(z)})}),r[P]=!0),I=I.concat(P),l}).catch(function(j){if(j instanceof Error)throw new Error(j);return v=v.concat(j.name),j})});Promise.all(S).then(function(l){var k={plugins:I,failed:v,disabled:_};setTimeout(function(){d.length===S.length+_.length&&i.dispatch(x({},{type:C.ready},k))},0)})}var y=function(){if(f!==C.bootstrap)return/^ready:([^:]*)$/.test(f)&&setTimeout(function(){return dr(i,e,t)},0),Promise.resolve(function(l,k,P,O,j){try{var z=Y(k)?k():k,L=l.type,H=L.replace(Pe,"");if(l._&&l._.called)return Promise.resolve(l);var A=P.getState(),R=(E=z,(U=A.plugins)===void 0&&(U={}),(X=l.options)===void 0&&(X={}),Object.keys(E).filter(function(m){var g=X.plugins||{};return Ci(g[m])?g[m]:g.all!==!1&&(!U[m]||U[m].enabled!==!1)}).map(function(m){return E[m]}));L===C.initializeStart&&l.fromEnable&&(R=Object.keys(A.plugins).filter(function(m){var g=A.plugins[m];return l.plugins.includes(m)&&!g.initialized}).map(function(m){return z[m]}));var K=R.map(function(m){return m.name}),b=function(m,g,T){var $=yn(m).map(function(N){return gn(N,g)});return g.reduce(function(N,D){var F=D.name,Z=yn(m,F).map(function(Ne){return gn(Ne,g)}),W=Z[0],M=Z[1],ee=Z[2];return W.length&&(N.beforeNS[F]=W),M.length&&(N.duringNS[F]=M),ee.length&&(N.afterNS[F]=ee),N},{before:$[0],beforeNS:{},during:$[1],duringNS:{},after:$[2],afterNS:{}})}(L,R);return Promise.resolve(mt({action:l,data:{exact:b.before,namespaced:b.beforeNS},state:A,allPlugins:z,allMatches:b,instance:P,store:O,EVENTS:j})).then(function(m){function g(){var N=function(){if(L.match(Pe))return Promise.resolve(mt({action:x({},T,{type:H+"End"}),data:{exact:b.after,namespaced:b.afterNS},state:A,allPlugins:z,allMatches:b,instance:P,store:O,EVENTS:j})).then(function(D){D.meta&&D.meta.hasCallback&&hn(D.meta.rid,{payload:D})})}();return N&&N.then?N.then(function(){return m}):m}if(hr(m,K.length))return m;var T,$=function(){if(L!==H)return Promise.resolve(mt({action:x({},m,{type:H}),data:{exact:b.during,namespaced:b.duringNS},state:A,allPlugins:z,allMatches:b,instance:P,store:O,EVENTS:j})).then(function(N){T=N});T=m}();return $&&$.then?$.then(g):g()})}catch(m){return Promise.reject(m)}var E,U,X}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(y&&y.then?y.then(h):h(y))}catch(l){return Promise.reject(l)}}}}}function Bi(t){return function(e){return function(n){return function(r){var i=r.type,o=r.key,a=r.value,s=r.options;if(i===C.setItem||i===C.removeItem){if(r.abort)return n(r);i===C.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var qi=function(){var t=this;this.before=[],this.after=[],this.addMiddleware=function(e,n){t[n]=t[n].concat(e)},this.removeMiddleware=function(e,n){var r=t[n].findIndex(function(i){return i===e});r!==-1&&(t[n]=[].concat(t[n].slice(0,r),t[n].slice(r+1)))},this.dynamicMiddlewares=function(e){return function(n){return function(r){return function(i){var o={getState:n.getState,dispatch:function(s){return n.dispatch(s)}},a=t[e].map(function(s){return s(o)});return xe.apply(void 0,a)(r)(i)}}}}};function Qi(t){return function(e,n){e===void 0&&(e={});var r={};if(n.type==="initialize:aborted")return e;if(/^registerPlugin:([^:]*)$/.test(n.type)){var i=bn(n.type,"registerPlugin"),o=t()[i];if(!o||!i)return e;var a=n.enabled,s=o.config;return r[i]={enabled:a,initialized:!!a&&!o.initialize,loaded:!!a&&!!o.loaded({config:s}),config:s},x({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var h=bn(n.type,C.initialize),f=t()[h];return f&&h?(r[h]=x({},e[h],{initialized:!0,loaded:!!f.loaded({config:f.config})}),x({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=x({},e[n.name],{loaded:!0}),x({},e,r);switch(n.type){case C.disablePlugin:return x({},e,kn(n.plugins,!1,e));case C.enablePlugin:return x({},e,kn(n.plugins,!0,e));default:return e}}}function bn(t,e){return t.substring(e.length+1,t.length)}function kn(t,e,n){return t.reduce(function(r,i){return r[i]=x({},n[i],{enabled:e}),r},n)}function fr(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var eo={last:{},history:[]};function to(t,e){t===void 0&&(t=eo);var n=e.options,r=e.meta;if(e.type===C.track){var i=fr(x({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return x({},t,{last:i,history:t.history.concat(i)})}return t}var no={actions:[]};function ro(t,e){t===void 0&&(t=no);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===C.identify?[e].concat(t.actions):t.actions.concat(e),x({},t,{actions:r});case"dequeue":return[];default:return t}}var pr=/#.*$/;function io(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(pr,""):"")}var mr,gr,yr,vr,oo=function(t){if(t===void 0&&(t={}),!J)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,h=o.hash,f=o.search,u=function(p){var d=function(){if(J){for(var w,I=document.getElementsByTagName("link"),v=0;w=I[v];v++)if(w.getAttribute("rel")==="canonical")return w.getAttribute("href")}}();return d?d.match(/\?/)?d:d+p:window.location.href.replace(pr,"")}(f),c={title:n,url:u,path:io(u),hash:h,search:f,width:a,height:s};return r&&r!==""&&(c.referrer=r),x({},c,t)},ao={last:{},history:[]};function so(t,e){t===void 0&&(t=ao);var n=e.options;if(e.type===C.page){var r=fr(x({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return x({},t,{last:r,history:t.history.concat(r)})}return t}mr=function(){if(!J)return!1;var t=navigator.appVersion;return~t.indexOf("Win")?"Windows":~t.indexOf("Mac")?"MacOS":~t.indexOf("X11")?"UNIX":~t.indexOf("Linux")?"Linux":"Unknown OS"}(),gr=J?document.referrer:null,yr=Ri(),vr=Di();var In={initialized:!1,sessionId:st(),app:null,version:null,debug:!1,offline:!!J&&!navigator.onLine,os:{name:mr},userAgent:J?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:vr,locale:yr,campaign:{},referrer:gr};function co(t,e){t===void 0&&(t=In);var n=t.initialized,r=e.campaign;switch(e.type){case C.campaign:return x({},t,{campaign:r});case C.offline:return x({},t,{offline:!0});case C.online:return x({},t,{offline:!1});default:return n?t:x({},In,t,{initialized:!0})}}var uo=["plugins","reducers","storage"];function lo(t,e,n){if(J){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function ho(t){var e=lo.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function wr(){return be("analytics",[]),function(t){return function(e,n,r){var i=t(e,n,r),o=i.dispatch;return Object.assign(i,{dispatch:function(a){return Ce[je].analytics.push(a.action||a),o(a)}})}}}function Sn(t){return function(){return xe(xe.apply(null,arguments),wr())}}function vt(t){return t?sr(t)?t:[t]:[]}function _n(t,e,n){t===void 0&&(t={});var r,i,o=st();return e&&(Re[o]=(r=e,i=function(a){for(var s,h=a||Array.prototype.slice.call(arguments),f=0;f<h.length;f++)if(Y(h[f])){s=h[f];break}return s}(n),function(a){i&&i(a),r(a)})),x({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function fo(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(m,g){if(Y(g))return m.middlewares=m.middlewares.concat(g),m;if(g.NAMESPACE&&(g.name=g.NAMESPACE),!g.name)throw new Error("https://lytics.dev/errors/1");g.config||(g.config={});var T=g.EVENTS?Object.keys(g.EVENTS).map(function(D){return g.EVENTS[D]}):[];m.pluginEnabled[g.name]=!(g.enabled===!1||g.config.enabled===!1),delete g.enabled,g.methods&&(m.methods[g.name]=Object.keys(g.methods).reduce(function(D,F){var Z;return D[F]=(Z=g.methods[F],function(){for(var W=Array.prototype.slice.call(arguments),M=new Array(Z.length),ee=0;ee<W.length;ee++)M[ee]=W[ee];return M[M.length]=k,Z.apply({instance:k},M)}),D},{}),delete g.methods);var $=Object.keys(g).concat(T),N=new Set(m.events.concat($));if(m.events=Array.from(N),m.pluginsArray=m.pluginsArray.concat(g),m.plugins[g.name])throw new Error(g.name+"AlreadyLoaded");return m.plugins[g.name]=g,m.plugins[g.name].loaded||(m.plugins[g.name].loaded=function(){return!0}),m},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:we,setItem:be,removeItem:Ae},o=function(m){return function(g,T,$){return T.getState("user")[g]||($&&V($)&&$[g]?$[g]:dn(m)[g]||we(Ot(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!Tt.includes(m)}).sort(),h=new Set(s.concat(et).filter(function(m){return!Tt.includes(m)})),f=Array.from(h).sort(),u=function(){return a},c=new qi,p=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,I=function(){throw new Error("Abort disabled inListener")},v=Li(),_=dn(i),S=x({},_,n,v.an_uid?{userId:v.an_uid}:{},v.an_aid?{anonymousId:v.an_aid}:{});S.anonymousId||(S.anonymousId=st());var y=x({enable:function(m,g){return new Promise(function(T){b.dispatch({type:C.enablePlugin,plugins:vt(m),_:{originalAction:C.enablePlugin}},T,[g])})},disable:function(m,g){return new Promise(function(T){b.dispatch({type:C.disablePlugin,plugins:vt(m),_:{originalAction:C.disablePlugin}},T,[g])})}},r.methods),l=!1,k={identify:function(m,g,T,$){try{var N=se(m)?m:null,D=V(m)?m:g,F=T||{},Z=k.user();be(Ot(oe),N);var W=N||D.userId||o(oe,k,D);return Promise.resolve(new Promise(function(M){b.dispatch(x({type:C.identifyStart,userId:W,traits:D||{},options:F,anonymousId:Z.anonymousId},Z.id&&Z.id!==N&&{previousId:Z.id}),M,[g,T,$])}))}catch(M){return Promise.reject(M)}},track:function(m,g,T,$){try{var N=V(m)?m.event:m;if(!N||!se(N))throw new Error("EventMissing");var D=V(m)?m:g||{},F=V(T)?T:{};return Promise.resolve(new Promise(function(Z){b.dispatch({type:C.trackStart,event:N,properties:D,options:F,userId:o(oe,k,g),anonymousId:o(_e,k,g)},Z,[g,T,$])}))}catch(Z){return Promise.reject(Z)}},page:function(m,g,T){try{var $=V(m)?m:{},N=V(g)?g:{};return Promise.resolve(new Promise(function(D){b.dispatch({type:C.pageStart,properties:oo($),options:N,userId:o(oe,k,$),anonymousId:o(_e,k,$)},D,[m,g,T])}))}catch(D){return Promise.reject(D)}},user:function(m){if(m===oe||m==="id")return o(oe,k);if(m===_e||m==="anonId")return o(_e,k);var g=k.getState("user");return m?rn(g,m):g},reset:function(m){return new Promise(function(g){b.dispatch({type:C.resetStart},g,m)})},ready:function(m){return l&&m({plugins:y,instance:k}),k.on(C.ready,function(g){m(g),l=!0})},on:function(m,g){if(!m||!Y(g))return!1;if(m===C.bootstrap)throw new Error(".on disabled for "+m);var T=/Start$|Start:/;if(m==="*"){var $=function(Z){return function(W){return function(M){return M.type.match(T)&&g({payload:M,instance:k,plugins:a}),W(M)}}},N=function(Z){return function(W){return function(M){return M.type.match(T)||g({payload:M,instance:k,plugins:a}),W(M)}}};return p($,Ye),p(N,Ge),function(){d($,Ye),d(N,Ge)}}var D=m.match(T)?Ye:Ge,F=function(Z){return function(W){return function(M){return M.type===m&&g({payload:M,instance:k,plugins:a,abort:I}),W(M)}}};return p(F,D),function(){return d(F,D)}},once:function(m,g){if(!m||!Y(g))return!1;if(m===C.bootstrap)throw new Error(".once disabled for "+m);var T=k.on(m,function($){g({payload:$.payload,instance:k,plugins:a,abort:I}),T()});return T},getState:function(m){var g=b.getState();return m?rn(g,m):Object.assign({},g)},dispatch:function(m){var g=se(m)?{type:m}:m;if(et.includes(g.type))throw new Error("reserved action "+g.type);var T=x({},g,{_:x({originalAction:g.type},m._||{})});b.dispatch(T)},enablePlugin:y.enable,disablePlugin:y.disable,plugins:y,storage:{getItem:i.getItem,setItem:function(m,g,T){b.dispatch({type:C.setItemStart,key:m,value:g,options:T})},removeItem:function(m,g){b.dispatch({type:C.removeItemStart,key:m,options:g})}},setAnonymousId:function(m,g){k.storage.setItem(ce,m,g)},events:{core:et,plugins:s}},P=r.middlewares.concat([function(m){return function(g){return function(T){return T.meta||(T.meta=_n()),g(T)}}},w(Ye),Gi(k,u,{all:f,plugins:s}),Bi(i),Fi(k),Xi(k),w(Ge)]),O={context:co,user:Ji(i),page:so,track:to,plugins:Qi(u),queue:ro},j=xe,z=xe;if(J&&t.debug){var L=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;L&&(j=L({trace:!0,traceLimit:25})),z=function(){return arguments.length===0?wr():V(typeof arguments[0])?Sn():Sn().apply(null,arguments)}}var H,A=function(m){return Object.keys(m).reduce(function(g,T){return uo.includes(T)||(g[T]=m[T]),g},{})}(t),R=r.pluginsArray.reduce(function(m,g){var T=g.name,$=g.config,N=g.loaded,D=r.pluginEnabled[T];return m[T]={enabled:D,initialized:!!D&&!g.initialize,loaded:!!N({config:$}),config:$},m},{}),K={context:A,user:S,plugins:R},b=ur(function(m){for(var g=Object.keys(m),T={},$=0;$<g.length;$++){var N=g[$];typeof m[N]===ae&&(T[N]=m[N])}var D,F=Object.keys(T);try{(function(Z){Object.keys(Z).forEach(function(W){var M=Z[W];if(typeof M(void 0,{type:"@@redux/INIT"})===ie||typeof M(void 0,{type:Ki})===ie)throw new Error("reducer "+W+" "+ie)})})(T)}catch(Z){D=Z}return function(Z,W){if(Z===void 0&&(Z={}),D)throw D;for(var M=!1,ee={},Ne=0;Ne<F.length;Ne++){var He=F[Ne],Ht=Z[He],lt=(0,T[He])(Ht,W);if(typeof lt===ie){var $r=Wi(He,W);throw new Error($r)}ee[He]=lt,M=M||lt!==Ht}return M?ee:Z}}(x({},O,e)),K,z(j(Hi.apply(void 0,P))));b.dispatch=(H=b.dispatch,function(m,g,T){var $=x({},m,{meta:_n(m.meta,g,vt(T))});return H.apply(null,[$])});var E=Object.keys(a);b.dispatch({type:C.bootstrap,plugins:E,config:A,params:v,user:S,initialUser:n,persistedUser:_});var U=E.filter(function(m){return r.pluginEnabled[m]}),X=E.filter(function(m){return!r.pluginEnabled[m]});return b.dispatch({type:C.registerPlugins,plugins:E,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,g){var T=m.bootstrap,$=m.config,N=m.name;T&&Y(T)&&T({instance:k,config:$,payload:m}),b.dispatch({type:C.registerPluginType(N),name:N,enabled:r.pluginEnabled[N],plugin:m}),r.pluginsArray.length===g+1&&b.dispatch({type:C.initializeStart,plugins:U,disabled:X})}),ho(function(m){b.dispatch({type:m?C.offline:C.online})}),function(m,g,T){setInterval(function(){return dr(m,g,T)},3e3)}(b,u,k),k}var Ye="before",Ge="after",Le="cookie",fe=Ir(),br=ct,po=ct;function kr(t){return fe?ct(t,"",-1):Ae(t)}function Ir(){if(fe!==void 0)return fe;var t="cookiecookie";try{ct(t,t),fe=document.cookie.indexOf(t)!==-1,kr(t)}catch{fe=!1}return fe}function ct(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return fe===!1&&(a?be(t,e):we(t)),a?document.cookie=t+"="+encodeURIComponent(e)+(n?"; expires="+new Date(+new Date+1e3*n).toUTCString()+(r?"; path="+r:"")+(i?"; domain="+i:"")+(o?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+t+"=")[1]||"").split(";")[0])}}var Me="localStorage",mo=Rt.bind(null,"localStorage");$e("localStorage","getItem",we);$e("localStorage","setItem",be);$e("localStorage","removeItem",Ae);var Ze="sessionStorage",go=Rt.bind(null,"sessionStorage");$e("sessionStorage","getItem",we);$e("sessionStorage","setItem",be);$e("sessionStorage","removeItem",Ae);function Te(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(V(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var yo=mo(),vo=go(),wo=Ir();function Sr(t,e){if(t){var n=Dt(e),r=!Kt(n),i=Lt(n)?Te(localStorage.getItem(t)):void 0;if(r&&!Se(i))return i;var o=Mt(n)?Te(br(t)):void 0;if(r&&o)return o;var a=Zt(n)?Te(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=we(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function bo(t,e,n){if(t&&!Se(e)){var r={},i=Dt(n),o=JSON.stringify(e),a=!Kt(i);return Lt(i)&&(r[Me]=Be(Me,e,Te(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Me]:Mt(i)&&(r[Le]=Be(Le,e,Te(br(t))),po(t,o),a)?r[Le]:Zt(i)&&(r[Ze]=Be(Ze,e,Te(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Ze]:(r[De]=Be(De,e,we(t)),be(t,e),a?r[De]:r)}}function ko(t,e){if(t){var n=Dt(e),r=Sr(t,ir),i={};return!Se(r.localStorage)&&Lt(n)&&(localStorage.removeItem(t),i[Me]=r.localStorage),!Se(r.cookie)&&Mt(n)&&(kr(t),i[Le]=r.cookie),!Se(r.sessionStorage)&&Zt(n)&&(sessionStorage.removeItem(t),i[Ze]=r.sessionStorage),!Se(r.global)&&ut(n,De)&&(Ae(t),i[De]=r.global),i}}function Dt(t){return t?se(t)?t:t.storage:rr}function Lt(t){return yo&&ut(t,Me)}function Mt(t){return wo&&ut(t,Le)}function Zt(t){return vo&&ut(t,Ze)}function Kt(t){return t===ir||t==="all"}function ut(t,e){return t===rr||t===e||Kt(t)}function Be(t,e,n){return{location:t,current:e,previous:n}}var Io={setItem:bo,getItem:Sr,removeItem:ko};function So(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function En(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Pn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?En(Object(n),!0).forEach(function(r){So(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):En(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _o(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:Io};return fo(Pn(Pn({},e),t))}function Eo(t,e){e=e||{};var n,r,i=[],o=e.max||1/0;function a(){clearInterval(n),t(i.splice(0,o)),s()}function s(){n=setInterval(a,e.interval||1e4)}return s(),{flush:a,push:function(h){return r=i.push(h),r>=o&&a(),r},size:function(){return i.length},end:function(h){h&&a(),clearInterval(n)}}}function Po(t){if(typeof window>"u")return;const{addEventListener:e,history:n,location:r}=window;let i=r.pathname;e("popstate",()=>t(r.pathname)),["push","replace"].map(o=>{const a=`${o}State`;if(a!=="pushState"&&a!=="replaceState")return;const s=n[a];n[a]=function(...h){var c;const f=((c=h[2])==null?void 0:c.toString())||"",u=Oo(f);return i!==u&&(i=u,setTimeout(()=>t(f),0)),s.apply(n,h)}})}function To(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function Oo(t){return["#","?"].forEach(e=>t=To(t,e)),t}function jo(){Po(()=>{re.page()})}function Co(t){if(t===void 0&&(t={}),!J)return Pt;var e=On(),n=jt(),r=Tn(),i=qe(r,e),o=qe(n,e),a=[],s=[],h=[],f=r,u=i,c=o,p=Object.keys(t);if(!p.length)return Pt;var d=p.map(function(I){return Number(I)}),w=Zi(function(){var I=On(),v=function(A,R){return R.map(function(K){return K===100?A-5:A*(K/100)})}(I,d),_=jt(),S=Tn(),y=qe(S,I),l=qe(_,I);if(u=y>u?y:u,c=l<c?l:c,!(a.length>=d.length)){var k=f===S,P="up";k?P="initial":f<=S&&(P="down");var O=v,j=d;(P==="up"||k)&&(O=v.slice().reverse(),j=d.slice().reverse());var z=j.reduce(function(A,R,K){var b=O[K];return h.includes(R)&&S<=b&&(h=h.filter(function(E){return E!==R}),A.singleFunction=R),P==="down"&&!a.includes(R)&&S>=b&&R>o?(s.push(R),A.callbacks=A.callbacks.concat(R),A):P==="up"&&!a.includes(R)&&S<=b&&R<=y?(A.foundFunc=[R],A):(k&&S>=b&&A.foundFunc.length===0&&(A.foundFunc=[R]),!s.includes(R)&&S>=b&&(s.push(R),A.singleFunction?h.push(R):A.singleFunction=R),A)},{foundFunc:[],singleFunction:null,callbacks:[],direction:P});if(f=S,P==="down"&&z.callbacks&&z.callbacks.forEach(function(A){Y(t[A])&&(t[A]({trigger:A,direction:P,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(A))}),z.singleFunction){var L=z.singleFunction,H=z.direction;Y(t[L])&&t[L]({trigger:L,direction:H,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(L)}}},500);return window.addEventListener("scroll",w),function(){return window.removeEventListener("scroll",w)}}function jt(){return J?document.body.scrollTop||document.documentElement.scrollTop:0}function xo(){return J?window.innerHeight||document.documentElement.clientHeight:0}function Tn(){return Math.round(jt()+xo())}function On(){if(!J)return 0;var t=document.body,e=document.documentElement;return Math.max(t.scrollHeight,t.offsetHeight,e.clientHeight,e.scrollHeight,e.offsetHeight)}function qe(t,e){return Math.round(t/e*100)}var jn="EventListener";function Ao(t){return function(e,n,r,i){var o=r||Pt,a=i||!1;if(!J)return o;var s=rt(n),h=rt(e,!0);if(!h.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var f=[];return function u(c){c&&(f=[]);for(var p=c?"add"+jn:"remove"+jn,d=0;d<h.length;d++){var w=h[d];f[d]=c?a&&a.once?$o(o):o:f[d]||o;for(var I=0;I<s.length;I++)w[p]?w["on"+s[I]]=c?f[d]:null:w[p](s[I],f[d],a)}return u.bind(null,!c)}(t)}}function rt(t,e){if(se(t))return e?rt(document.querySelectorAll(t)):(n=t).split(n.indexOf(",")>-1?",":" ").map(function(a){return a.trim()});var n;if(NodeList.prototype.isPrototypeOf(t)){for(var r=[],i=t.length>>>0;i--;)r[i]=t[i];return r}var o=zi(t);return e?o.map(function(a){return se(a)?rt(a,!0):a}).flat():o}function $o(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var wt=Ao("Event");function _r(t,e){return J&&Y(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),Y(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}_r.bind(null,"onerror");_r.bind(null,"onload");var Er=typeof window>"u",Cn="hidden";function No(t){if(Er)return!1;var e=Uo(),n="".concat(e.replace(/[H|h]idden/,""),"visibilitychange"),r=function(){return t(!!document[e])},i=function(){return document.addEventListener(n,r)};return i(),function(){return document.removeEventListener(n,r),i}}function Uo(){var t=["webkit","moz","ms","o"];return Er||Cn in document?Cn:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var zo=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Ro(t,e){e===void 0&&(e={});var n=function(a,s){var h=this,f=!1;return function(u){f||(a.call(h,u),f=!0,setTimeout(function(){return f=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=No(function(s){s||n({type:"tabVisible"})});return r=[a].concat(zo.map(function(s){return wt(document,s,n)})).concat(wt(window,"load",n)).concat(wt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Do(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,h=t.throttle,f=h===void 0?2e3:h,u=!1,c=!1,p=new Date,d=function(){return clearTimeout(e)};function w(v){d(),o&&!u&&o(ze(p),v),i&&u&&(u=!1,i(ze(n),v),p=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(ze(p),v))},s)}var I=Ro(w,{throttle:f});return{disable:function(){c=!0,u=!1,d();var v=I();return function(){return c=!1,p=new Date,w({type:"load"}),v()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:ze(p,c),idle:u?ze(n,c):0}}}}function ze(t,e){return e?0:Math.round((new Date-t)/1e3)}const xn=5e3;class Lo{constructor(e){q(this,"element");q(this,"isInViewport",!1);q(this,"isAwake",!1);q(this,"isFlushing");q(this,"observer");q(this,"lastEventAt",Date.now());q(this,"registeredView",!1);q(this,"viewCallback");q(this,"activeDurationCallback");q(this,"idleDurationCallback");q(this,"scrollCallback");this.element=e.element,this.viewCallback=e.viewCallback,this.activeDurationCallback=e.activeDurationCallback,this.idleDurationCallback=e.idleDurationCallback,this.scrollCallback=e.scrollCallback,this.observer=new IntersectionObserver(n=>{n.forEach(r=>{this.handleInViewPort(r.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),Do({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:xn}),Co({25:this.handleScroll.bind(this),50:this.handleScroll.bind(this),75:this.handleScroll.bind(this),90:this.handleScroll.bind(this),100:this.handleScroll.bind(this)})}flush(){this.isFlushing=!0,this.handleAwake(!this.isAwake)}handleInViewPort(e){e?(this.isAwake=!0,this.trackInViewport()):this.handleAwake(!1),this.isInViewport=e}handleAwake(e,n=Math.round((Date.now()-this.lastEventAt)/1e3)){this.isAwake=e,this.lastEventAt=e?Date.now()-n*xn:Date.now(),this.isInViewport&&this.trackAwake(e,n)}handleScroll(e){this.scrollCallback&&this.scrollCallback(e)}handleVisibilityChange(){this.isAwake=!1;const e=Math.round((Date.now()-this.lastEventAt)/1e3);e>1&&(this.lastEventAt=Date.now(),this.trackAwake(!1,e))}trackAwake(e,n){!e&&this.activeDurationCallback&&this.activeDurationCallback(n,this.isFlushing,this.lastEventAt),e&&this.idleDurationCallback&&this.idleDurationCallback(n,this.isFlushing,this.lastEventAt)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}const An="sesamy_session_id";function Mo(){let t=sessionStorage.getItem(An);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(An,t)),t}let Pr=!1,Ct,$n,it;function Zo({clientId:t,enabled:e=!0,endpoint:n=si}){if(Ct=t,$n=e,it=n,!$n)return;jo();const r=new Lo({element:document.body,viewCallback:()=>{re.page()},activeDurationCallback:(i,o,a)=>{re.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{re.track("idleDuration",{duration:i,durationStart:a,flushing:o})},scrollCallback:i=>{re.track("scroll",{scroll:i.scrollMax})}});Ho(document.body,()=>{r.flush()}),Fo(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(Q.AUTHENTICATED,async i=>{const o=i;await re.identify(o.detail.sub)}),window.addEventListener(Q.LOGOUT,async()=>{await re.track("logout",{}),Wt.flush(),await re.reset()})}function Tr(t){return JSON.stringify(t.map(e=>({...e,clientId:Ct,requestId:Math.random().toString(36).slice(2,9),sessionId:Mo(),timestamp:new Date().toISOString(),version:zt,event:e.event,context:{page:{url:window.location.hostname,path:window.location.pathname,title:document.title,search:window.location.search,referrer:document.referrer},locale:navigator.language,library:nr,userAgent:navigator.userAgent,clientId:Ct}})))}const Wt=Eo(async t=>{if(t.length>0){const e=Tr(t);Pr?navigator.sendBeacon(it,e):(await fetch(it,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function bt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(it,Tr([n]))}else Wt.push(t)}const re=_o({app:nr,version:zt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;bt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;bt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;bt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Ko(t,e){re.track(t,e)}function Wo(){return Pr=!0,Wt.flush()}const Or=new Map;function Ho(t,e){Or.set(t,e)}window.addEventListener("beforeunload",()=>{Or.forEach((t,e)=>{t.bind(e)()}),Wo()});const jr=new Map;function Fo(t,e){jr.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&jr.forEach((t,e)=>{t.bind(e)()})});const Cr="sesamySignedURLs";function xr(){const t=sessionStorage.getItem(Cr);return t?JSON.parse(t):[]}function Jo(t){const e=xr();e.push(t),sessionStorage.setItem(Cr,JSON.stringify(e))}function Xo(t){const{getEntitlement:e,getEntitlements:n,getEntitlementAccess:r,getSubscriptions:i,getContract:o,getContracts:a,getBill:s,getBills:h,getProfile:f,updateProfile:u,getTags:c,deleteTag:p,setTag:d,getUserMetadata:w,listUserMetadata:I,setUserMetadata:v,deleteUserMetadata:_,getTally:S,getTallies:y,pushTally:l,deleteTally:k,getProduct:P,getPaymentIssues:O,autoOnboardProduct:j}=Pi(t),z={auth:{getUser:f,isAuthenticated:ui,loginWithRedirect:Bn,logout:hi,setToken:qn},profile:{get:f,update:u},analytics:{track:Ko},tags:{list:c,set:d,delete:p},entitlements:{get:e,list:n,access:r,signedLinks:xr},contracts:{get:o,list:a},bills:{get:s,list:h},userMetadata:{get:w,list:I,set:v,delete:_},tallies:{get:S,list:y,push:l,delete:k},subscriptions:{list:i},products:{get:P,autoOnboard:j},getVersion:Vo,getPaymentIssues:O,clearCache:te};return t.namespace&&(window[t.namespace]=z),z}function Vo(){return zt}function Yo(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token"),n=t.get("expires_in");if(e){qn(e,n?parseInt(n,10):void 0);const r=new URL(window.location.href);t.delete("access_token"),t.delete("expires_in"),r.hash=t.toString(),window.history.replaceState(null,"",r)}}const Nn="sesamy-refresh",Un="force-refetch-entitlements";function Go(){const t=new URLSearchParams(window.location.search),e=t.get(Un),n=t.get(Nn);if(e!==null||n!==null){const r=new URL(window.location.href);t.delete(Un),t.delete(Nn),r.search=t.toString(),te(),window.history.replaceState(null,"",r)}}function Bo(){const t=new URLSearchParams(window.location.search),e=t.get("token"),n=t.get("se");if(!n||!e)return;const r=parseInt(n,10);if(Number.isNaN(r)||r<Date.now())return;Jo({url:window.location.href.split("?")[0],token:e,expiresAt:r,publisherContentId:t.get("sp")??void 0});const i=new URL(window.location.href);i.searchParams.delete("ss"),i.searchParams.delete("se"),i.searchParams.delete("sp"),i.searchParams.delete("so"),i.searchParams.delete("token"),window.history.replaceState(null,"",i)}const zn="sesamy-user";async function qo(){const e=new URLSearchParams(window.location.search).get(zn);if(!e)return;const n=await li();(n==null?void 0:n.email)!==e&&Bn();const r=new URL(window.location.href);r.searchParams.delete(zn),window.history.replaceState(null,"",r)}const Rn="sesamy-purchase";function Qo(){const t=new URLSearchParams(window.location.search),e=t.get(Rn);if(e!==null){const n=new URL(window.location.href);t.delete(Rn),n.search=t.toString(),ue(Q.PURCHASE,{itemSrc:e}),te(),window.history.replaceState(null,"",n)}}async function Ar(t){Zo({clientId:t.clientId,...t.analytics}),await ci({clientId:t.clientId,...t.auth});const e=Xo(t.api||{});return ue(Q.READY,{}),Yo(),Go(),Bo(),await qo(),Qo(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);Ar(e)}catch(e){console.error("Failed to parse config",e)}}exports.init=Ar;
@@ -21,14 +21,21 @@ export interface AuthConfig {
21
21
  endpoint?: string;
22
22
  }
23
23
  export type Profile = {
24
- id: string;
24
+ sub: string;
25
25
  email: string;
26
+ email_verified?: boolean;
26
27
  given_name?: string;
27
28
  family_name?: string;
28
29
  name?: string;
30
+ locale?: string;
31
+ picture?: string;
32
+ phone_number?: string;
29
33
  createdAt: string;
30
34
  updatedAt: string;
31
35
  tags: string[];
36
+ user_metadata?: {
37
+ [id: string]: string | number;
38
+ };
32
39
  };
33
40
  declare function isAuthenticated(): Promise<boolean>;
34
41
  declare function loginWithRedirect(): Promise<void>;
@@ -144,6 +151,10 @@ export declare function init(config: Config): Promise<{
144
151
  logout: typeof logout;
145
152
  setToken: typeof setToken;
146
153
  };
154
+ profile: {
155
+ get: () => Promise<Profile>;
156
+ update: (profile: Partial<Profile>) => Promise<boolean>;
157
+ };
147
158
  analytics: {
148
159
  track: typeof track;
149
160
  };