@sesamy/sesamy-js 1.18.0 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/sesamy-js.cjs +5 -5
- package/dist/sesamy-js.d.ts +1 -0
- package/dist/sesamy-js.iife.js +5 -5
- package/dist/sesamy-js.mjs +490 -489
- package/package.json +1 -1
package/dist/sesamy-js.iife.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var sesamyJs=function(re){"use strict";var sa=Object.defineProperty;var ca=(re,X,V)=>X in re?sa(re,X,{enumerable:!0,configurable:!0,writable:!0,value:V}):re[X]=V;var ee=(re,X,V)=>ca(re,typeof X!="symbol"?X+"":X,V);function X(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0});dispatchEvent(n)}function V(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}typeof SuppressedError=="function"&&SuppressedError;var he=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function mt(t,e){return t(e={exports:{}},e.exports),e.exports}var fe=mt(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()}});pt(fe);var Mr=pt(mt(function(t,e){var n=he&&he.__awaiter||function(u,c,f,d){return new(f||(f=Promise))(function(b,I){function w(y){try{_(d.next(y))}catch(l){I(l)}}function E(y){try{_(d.throw(y))}catch(l){I(l)}}function _(y){y.done?b(y.value):new f(function(l){l(y.value)}).then(w,E)}_((d=d.apply(u,c||[])).next())})},r=he&&he.__generator||function(u,c){var f,d,b,I,w={label:0,sent:function(){if(1&b[0])throw b[1];return b[1]},trys:[],ops:[]};return I={next:E(0),throw:E(1),return:E(2)},typeof Symbol=="function"&&(I[Symbol.iterator]=function(){return this}),I;function E(_){return function(y){return function(l){if(f)throw new TypeError("Generator is already executing.");for(;w;)try{if(f=1,d&&(b=2&l[0]?d.return:l[0]?d.throw||((b=d.return)&&b.call(d),0):d.next)&&!(b=b.call(d,l[1])).done)return b;switch(d=0,b&&(l=[2&l[0],b.value]),l[0]){case 0:case 1:b=l;break;case 4:return w.label++,{value:l[1],done:!1};case 5:w.label++,d=l[1],l=[0];continue;case 7:l=w.ops.pop(),w.trys.pop();continue;default:if(b=w.trys,!((b=b.length>0&&b[b.length-1])||l[0]!==6&&l[0]!==2)){w=0;continue}if(l[0]===3&&(!b||l[1]>b[0]&&l[1]<b[3])){w.label=l[1];break}if(l[0]===6&&w.label<b[1]){w.label=b[1],b=l;break}if(b&&w.label<b[2]){w.label=b[2],w.ops.push(l);break}b[2]&&w.ops.pop(),w.trys.pop();continue}l=c.call(u,w)}catch(k){l=[6,k],d=0}finally{f=b=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([_,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(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,b,I,w,E,_,y;return r(this,function(l){switch(l.label){case 0:d=Date.now()+h(4),b=Date.now()+f,I=o+"-"+c,w=this.storageHandler===void 0?a:this.storageHandler,l.label=1;case 1:return Date.now()<b?[4,s(30)]:[3,8];case 2:return l.sent(),w.getItemSync(I)!==null?[3,5]:(E=this.id+"-"+c+"-"+d,[4,s(Math.floor(25*Math.random()))]);case 3:return l.sent(),w.setItemSync(I,JSON.stringify({id:this.id,iat:d,timeoutKey:E,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return l.sent(),(_=w.getItemSync(I))!==null&&(y=JSON.parse(_)).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(b)];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(b){return setTimeout(function(){return n(d,void 0,void 0,function(){var I,w,E;return r(this,function(_){switch(_.label){case 0:return[4,fe.default().lock(f)];case 1:return _.sent(),this.acquiredIatSet.has(f)?(I=this.storageHandler===void 0?a:this.storageHandler,(w=I.getItemSync(c))===null?(fe.default().unlock(f),[2]):((E=JSON.parse(w)).timeRefreshed=Date.now(),I.setItemSync(c,JSON.stringify(E)),fe.default().unlock(f),this.refreshLockWhileAcquired(c,f),[2])):(fe.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 b=!1,I=Date.now(),w=!1;function E(){if(w||(window.removeEventListener("storage",E),u.removeFromWaiting(E),clearTimeout(_),w=!0),!b){b=!0;var y=50-(Date.now()-I);y>0?setTimeout(d,y):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,b,I;return r(this,function(w){switch(w.label){case 0:return f=this.storageHandler===void 0?a:this.storageHandler,d=o+"-"+c,(b=f.getItemSync(d))===null?[2]:(I=JSON.parse(b)).id!==this.id?[3,2]:[4,fe.default().lock(I.iat)];case 1:w.sent(),this.acquiredIatSet.delete(I.iat),f.removeItemSync(d),fe.default().unlock(I.iat),u.notifyWaiters(),w.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var f=Date.now()-5e3,d=c,b=[],I=0;;){var w=d.keySync(I);if(w===null)break;b.push(w),I++}for(var E=!1,_=0;_<b.length;_++){var y=b[_];if(y.includes(o)){var l=d.getItemSync(y);if(l!==null){var k=JSON.parse(l);(k.timeRefreshed===void 0&&k.timeAcquired<f||k.timeRefreshed!==void 0&&k.timeRefreshed<f)&&(d.removeItemSync(y),E=!0)}}}E&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=p}));const Zr={timeoutInSeconds:60},Vt={name:"auth0-spa-js",version:"2.1.3"},Yt=()=>Date.now();let q=class Jt extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,Jt.prototype)}static fromPayload({error:e,error_description:n}){return new Jt(e,n)}},Hr=class Lr extends q{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,Lr.prototype)}},gt=class Ur extends q{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,Ur.prototype)}},Kr=class Rr extends gt{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,Rr.prototype)}},Wr=class Nr extends q{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,Nr.prototype)}},Fr=class Dr extends q{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,Dr.prototype)}},Gt=class zr extends q{constructor(e,n){super("missing_refresh_token",`Missing Refresh Token (audience: '${Bt(e,["default"])}', scope: '${Bt(n)}')`),this.audience=e,this.scope=n,Object.setPrototypeOf(this,zr.prototype)}};function Bt(t,e=[]){return t&&!e.includes(t)?t:""}const Ve=()=>window.crypto,yt=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Ve().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},qt=t=>btoa(t),vt=t=>{var{clientId:e}=t,n=V(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()},Qt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),Jr=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},Xr=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([Jr(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},Vr=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},Yr=async(t,e,n,r,i,o,a=1e4)=>i?Vr(t,e,n,r,a,i,o):Xr(t,r,a);async function Gr(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,h=V(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const p=s?vt(h):JSON.stringify(h);return await async function(u,c,f,d,b,I,w){let E,_=null;for(let A=0;A<3;A++)try{E=await Yr(u,f,d,b,I,w,c),_=null;break}catch(z){_=z}if(_)throw _;const y=E.json,{error:l,error_description:k}=y,O=V(y,["error","error_description"]),{ok:j}=E;if(!j){const A=k||`HTTP error. Unable to fetch ${u}`;throw l==="mfa_required"?new Fr(l,A,O.mfa_token):l==="missing_refresh_token"?new Gt(f,d):new q(l||"request_error",A)}return O}(`${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||Vt))}},e,s)}const Ye=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let pe=class Xt{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 Xt({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new Xt({scope:n,audience:r,clientId:i})}},Br=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@@"))}},en=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)}}()}},qr=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||Yt}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]}},Qr=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 Re=t=>typeof t=="number",ei=["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"],ti=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(Qt(h)),c={__raw:o},f={};return Object.keys(u).forEach(d=>{c[d]=u[d],ei.includes(d)||(f[d]=u[d])}),{encoded:{header:s,payload:h,signature:p},header:JSON.parse(Qt(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&&!Re(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||!Re(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!Re(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&&Re(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&&Re(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=mt(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("="),b=d.slice(1).join("=");b.charAt(0)==='"'&&(b=b.slice(1,-1));try{p[d[0].replace(c,decodeURIComponent)]=b.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}))}});pt(me),me.encode,me.parse,me.getAll;var ni=me.get,tn=me.set,nn=me.remove;const Se={get(t){const e=ni(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),tn(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),nn(t,n)}},ri={get(t){return Se.get(t)||Se.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),tn(`_legacy_${t}`,JSON.stringify(e),r),Se.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),nn(t,n),Se.remove(t,e),Se.remove(`_legacy_${t}`,e)}},ii={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 oi(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 rn,on,an,wt,
|
|
1
|
+
var sesamyJs=function(re){"use strict";var sa=Object.defineProperty;var ca=(re,X,V)=>X in re?sa(re,X,{enumerable:!0,configurable:!0,writable:!0,value:V}):re[X]=V;var ee=(re,X,V)=>ca(re,typeof X!="symbol"?X+"":X,V);function X(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0});dispatchEvent(n)}function V(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}typeof SuppressedError=="function"&&SuppressedError;var he=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function mt(t,e){return t(e={exports:{}},e.exports),e.exports}var fe=mt(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()}});pt(fe);var Zr=pt(mt(function(t,e){var n=he&&he.__awaiter||function(u,c,f,d){return new(f||(f=Promise))(function(b,I){function w(v){try{_(d.next(v))}catch(l){I(l)}}function E(v){try{_(d.throw(v))}catch(l){I(l)}}function _(v){v.done?b(v.value):new f(function(l){l(v.value)}).then(w,E)}_((d=d.apply(u,c||[])).next())})},r=he&&he.__generator||function(u,c){var f,d,b,I,w={label:0,sent:function(){if(1&b[0])throw b[1];return b[1]},trys:[],ops:[]};return I={next:E(0),throw:E(1),return:E(2)},typeof Symbol=="function"&&(I[Symbol.iterator]=function(){return this}),I;function E(_){return function(v){return function(l){if(f)throw new TypeError("Generator is already executing.");for(;w;)try{if(f=1,d&&(b=2&l[0]?d.return:l[0]?d.throw||((b=d.return)&&b.call(d),0):d.next)&&!(b=b.call(d,l[1])).done)return b;switch(d=0,b&&(l=[2&l[0],b.value]),l[0]){case 0:case 1:b=l;break;case 4:return w.label++,{value:l[1],done:!1};case 5:w.label++,d=l[1],l=[0];continue;case 7:l=w.ops.pop(),w.trys.pop();continue;default:if(b=w.trys,!((b=b.length>0&&b[b.length-1])||l[0]!==6&&l[0]!==2)){w=0;continue}if(l[0]===3&&(!b||l[1]>b[0]&&l[1]<b[3])){w.label=l[1];break}if(l[0]===6&&w.label<b[1]){w.label=b[1],b=l;break}if(b&&w.label<b[2]){w.label=b[2],w.ops.push(l);break}b[2]&&w.ops.pop(),w.trys.pop();continue}l=c.call(u,w)}catch(k){l=[6,k],d=0}finally{f=b=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([_,v])}}},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,b,I,w,E,_,v;return r(this,function(l){switch(l.label){case 0:d=Date.now()+h(4),b=Date.now()+f,I=o+"-"+c,w=this.storageHandler===void 0?a:this.storageHandler,l.label=1;case 1:return Date.now()<b?[4,s(30)]:[3,8];case 2:return l.sent(),w.getItemSync(I)!==null?[3,5]:(E=this.id+"-"+c+"-"+d,[4,s(Math.floor(25*Math.random()))]);case 3:return l.sent(),w.setItemSync(I,JSON.stringify({id:this.id,iat:d,timeoutKey:E,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return l.sent(),(_=w.getItemSync(I))!==null&&(v=JSON.parse(_)).id===this.id&&v.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(b)];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(b){return setTimeout(function(){return n(d,void 0,void 0,function(){var I,w,E;return r(this,function(_){switch(_.label){case 0:return[4,fe.default().lock(f)];case 1:return _.sent(),this.acquiredIatSet.has(f)?(I=this.storageHandler===void 0?a:this.storageHandler,(w=I.getItemSync(c))===null?(fe.default().unlock(f),[2]):((E=JSON.parse(w)).timeRefreshed=Date.now(),I.setItemSync(c,JSON.stringify(E)),fe.default().unlock(f),this.refreshLockWhileAcquired(c,f),[2])):(fe.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 b=!1,I=Date.now(),w=!1;function E(){if(w||(window.removeEventListener("storage",E),u.removeFromWaiting(E),clearTimeout(_),w=!0),!b){b=!0;var v=50-(Date.now()-I);v>0?setTimeout(d,v):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,b,I;return r(this,function(w){switch(w.label){case 0:return f=this.storageHandler===void 0?a:this.storageHandler,d=o+"-"+c,(b=f.getItemSync(d))===null?[2]:(I=JSON.parse(b)).id!==this.id?[3,2]:[4,fe.default().lock(I.iat)];case 1:w.sent(),this.acquiredIatSet.delete(I.iat),f.removeItemSync(d),fe.default().unlock(I.iat),u.notifyWaiters(),w.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var f=Date.now()-5e3,d=c,b=[],I=0;;){var w=d.keySync(I);if(w===null)break;b.push(w),I++}for(var E=!1,_=0;_<b.length;_++){var v=b[_];if(v.includes(o)){var l=d.getItemSync(v);if(l!==null){var k=JSON.parse(l);(k.timeRefreshed===void 0&&k.timeAcquired<f||k.timeRefreshed!==void 0&&k.timeRefreshed<f)&&(d.removeItemSync(v),E=!0)}}}E&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=p}));const Hr={timeoutInSeconds:60},Vt={name:"auth0-spa-js",version:"2.1.3"},Yt=()=>Date.now();let q=class Jt extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,Jt.prototype)}static fromPayload({error:e,error_description:n}){return new Jt(e,n)}},Kr=class Ur extends q{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,Ur.prototype)}},gt=class Rr extends q{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,Rr.prototype)}},Wr=class Nr extends gt{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,Nr.prototype)}},Fr=class Dr extends q{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,Dr.prototype)}},Jr=class zr extends q{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,zr.prototype)}},Gt=class Mr extends q{constructor(e,n){super("missing_refresh_token",`Missing Refresh Token (audience: '${Bt(e,["default"])}', scope: '${Bt(n)}')`),this.audience=e,this.scope=n,Object.setPrototypeOf(this,Mr.prototype)}};function Bt(t,e=[]){return t&&!e.includes(t)?t:""}const Ve=()=>window.crypto,yt=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Ve().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},qt=t=>btoa(t),vt=t=>{var{clientId:e}=t,n=V(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()},Qt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),Xr=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},Vr=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([Xr(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},Yr=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},Gr=async(t,e,n,r,i,o,a=1e4)=>i?Yr(t,e,n,r,a,i,o):Vr(t,r,a);async function Br(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,h=V(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const p=s?vt(h):JSON.stringify(h);return await async function(u,c,f,d,b,I,w){let E,_=null;for(let A=0;A<3;A++)try{E=await Gr(u,f,d,b,I,w,c),_=null;break}catch(M){_=M}if(_)throw _;const v=E.json,{error:l,error_description:k}=v,O=V(v,["error","error_description"]),{ok:j}=E;if(!j){const A=k||`HTTP error. Unable to fetch ${u}`;throw l==="mfa_required"?new Jr(l,A,O.mfa_token):l==="missing_refresh_token"?new Gt(f,d):new q(l||"request_error",A)}return O}(`${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||Vt))}},e,s)}const Ye=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let pe=class Xt{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 Xt({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new Xt({scope:n,audience:r,clientId:i})}},qr=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@@"))}},en=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)}}()}},Qr=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||Yt}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]}},ei=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 Re=t=>typeof t=="number",ti=["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"],ni=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(Qt(h)),c={__raw:o},f={};return Object.keys(u).forEach(d=>{c[d]=u[d],ti.includes(d)||(f[d]=u[d])}),{encoded:{header:s,payload:h,signature:p},header:JSON.parse(Qt(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&&!Re(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||!Re(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!Re(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&&Re(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&&Re(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=mt(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("="),b=d.slice(1).join("=");b.charAt(0)==='"'&&(b=b.slice(1,-1));try{p[d[0].replace(c,decodeURIComponent)]=b.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}))}});pt(me),me.encode,me.parse,me.getAll;var ri=me.get,tn=me.set,nn=me.remove;const Se={get(t){const e=ri(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),tn(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),nn(t,n)}},ii={get(t){return Se.get(t)||Se.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),tn(`_legacy_${t}`,JSON.stringify(e),r),Se.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),nn(t,n),Se.remove(t,e),Se.remove(`_legacy_${t}`,e)}},oi={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 ai(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 rn,on,an,wt,si=(rn="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",on=null,an=!1,function(t){return wt=wt||ai(rn,on,an),new Worker(wt,t)});const bt={};let ci=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 ui={memory:()=>new en().enclosedCache,localstorage:()=>new qr},sn=t=>ui[t],cn=t=>{const{openUrl:e,onRedirect:n}=t,r=V(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:e===!1||e?e:n})},kt=new Zr;let li=class{constructor(e){let n,r;if(this.userCache=new en().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await kt.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(!Ve())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Ve().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",!sn(n))throw new Error(`Invalid cache location "${n}"`);r=sn(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?Se:ri,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:ii;var o;this.scope=Ye("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Qr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Yt,this.cacheManager=new qr(r,r.allKeys?void 0:new si(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 ai)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Vt)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${vt(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return ti({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=qt(yt()),o=qt(yt()),a=yt(),s=(u=>{const c=new Uint8Array(u);return(f=>{const d={"+":"-","/":"_","=":""};return f.replace(/[+/=]/g,b=>d[b])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Ve().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),h=((u,c,f,d,b,I,w,E)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),f),{scope:Ye(c,f.scope),response_type:"code",response_mode:E||"query",state:d,nonce:b,redirect_uri:w||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),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 Wr(s.popup)))},1e3),f=setTimeout(()=>{clearInterval(c),p(new Kr(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(q.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 q("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=cn(e),{openUrl:i,fragment:o,appState:a}=r,s=V(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=V(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 q("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new Hr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new q("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:Ye(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=bt[a];return s||(s=o().finally(()=>{delete bt[a],s=null}),bt[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=V(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})(()=>kt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new gt;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 kt.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:Ye(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},Zr),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=V(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${vt(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=cn(e),{openUrl:r}=n,i=V(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 q("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((b,I,w=60)=>new Promise((E,_)=>{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 O=setTimeout(()=>{_(new gt),l()},1e3*w);k=function(j){if(j.origin!=I||!j.data||j.data.type!=="authorization_response")return;const A=j.source;A&&A.close(),j.data.response.error?_(q.fromPayload(j.data.response)):E(j.data.response),clearTimeout(O),window.removeEventListener("message",k,!1),setTimeout(l,2e3)},window.addEventListener("message",k,!1),window.document.body.appendChild(y),y.setAttribute("src",b)}))(i,this.domainUrl,c);if(o!==f.state)throw new q("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 Gt(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=V(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 Gr(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 li(t){const e=new ui(t);return await e.checkSession(),e}var te=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.CLEAR_CACHE="sesamyJsClearCache",t.USER_ATTRIBUTE_CHANGED="sesamyUserAttributeChanged",t.PURCHASE="sesamyJsPurchase",t))(te||{});const di="sesamy.com",hi="sesamy.dev",fi="https://sesa.my",It="sesamyCacheTimestamp";function se(t,e){return`https://${t}.${e==="dev"?hi:di}`}let Q,un;const Ne="sesamyAccessToken";function St(){const t=localStorage.getItem(Ne);if(!t)return null;const e=dn(t);return(!e||!e.exp||e.exp<new Date().getTime()/1e3)&&localStorage.removeItem(Ne),t}function ln(t){try{const e=new URL(t).hostname,n=e.split(".");return n.length>1?n.slice(-2).join("."):e}catch{return null}}async function pi(t){if(t.enabled===!1)return;un=t.organization;const e={domain:se("token",t.environment),clientId:t.clientId,useCookiesForTransactions:!0};if(ln(window.location.href)!==ln(se("auth",t.environment))&&(e.cacheLocation="localstorage",e.useRefreshTokens=!0),Q=await li(e),window.location.search.includes("code="))try{await Q.handleRedirectCallback();const n=await Q.getUser();X(te.AUTHENTICATED,n);const r=new URL(location.href),i=r.searchParams;i.delete("code"),i.delete("state"),r.search=i.toString(),window.history.replaceState({},document.title,r.toString())}catch(n){console.error(n)}}async function _t(){return St()?!0:Q?Q.isAuthenticated():!1}async function mi(){return St()?{sub:"local",name:"Local User"}:Q?Q.getUser():null}function Et(t){if(localStorage.removeItem(Ne),!Q)throw new Error("Auth0 client not initialized");const e=(t==null?void 0:t.authorizationParams)||{};return Q.loginWithRedirect({...t,authorizationParams:{organization:un,redirect_uri:window.location.href,...e}})}async function De(t=!0){const e=St();if(e)return e;try{return Q?await Q.getTokenSilently():null}catch(n){if(t)throw n;return null}}async function gi(t={}){if(localStorage.removeItem(Ne),X(te.LOGOUT,{}),!!Q)return Q.logout({...t,logoutParams:{returnTo:window.location.href,...t.logoutParams}})}function dn(t){const e=t.split(".");if(e.length!==3)return null;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 hn(t){const e=dn(t);if(!e||!e.exp||e.exp<new Date().getTime()/1e3)throw new Error("Invalid token");localStorage.setItem(Ne,t),X(te.AUTHENTICATED,e)}const yi=(t,e)=>e.skipDedupe||e.method!=="GET",vi=(t,e)=>e.method+"@"+t,wi=t=>t.clone(),fn=({skip:t=yi,key:e=vi,resolver:n=wi}={})=>{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)}}},bi=(t,e)=>t*e,ki=t=>t&&t.ok,pn=({delayTimer:t=500,delayRamp:e=bi,maxAttempts:n=10,until:r=ki,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,b)=>Promise.resolve(r(d,b)).then(I=>I?d&&a?d:b?Promise.reject(b):d:(c++,!n||c<=n?new Promise(w=>{const E=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:b,url:p,options:u})).then((_={})=>{var y,l;w(h((y=_&&_.url)!==null&&y!==void 0?y:p,(l=_&&_.options)!==null&&l!==void 0?l:u))}):w(h(p,u))},E)}).then(f).catch(w=>{if(!o)throw w;return f(null,w)}):d&&a?d:Promise.reject(b||new Error("Number of attempts exceeded."))));return h(p,u).then(f).catch(d=>{if(!o)throw d;return f(null,d)})},Ii="application/json",mn="Content-Type",_e=Symbol(),gn=Symbol();function yn(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===mn.toLowerCase()))===null||e===void 0?void 0:e[1]}function vn(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})},Ee={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 Si(t,e=!1){Ee.options=e?t:ge(Ee.options,t)}function _i(t,e=!1){Ee.polyfills=e?t:ge(Ee.polyfills,t)}function Ei(t){Ee.errorType=t}const Pi=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class wn extends Error{}const Ti=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,p=new Map(o),u=ge(i.options,r);let c=n;const f=Pi(s)((y,l)=>(c=y,i.polyfill("fetch")(y,l)))(n,u),d=new Error,b=f.catch(y=>{throw{[_e]:y}}).then(y=>{if(!y.ok){const l=new wn;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 O;if(l.message=k,i.errorType==="json"||((O=y.headers.get("Content-Type"))===null||O===void 0?void 0:O.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(_e),O=k?l[_e]:l,j=(O==null?void 0:O.status)&&p.get(O.status)||p.get(O==null?void 0:O.name)||k&&p.has(_e)&&p.get(_e);if(j)return j(O,t);const A=p.get(gn);if(A)return A(O,t);throw O}),w=y=>l=>I(y?b.then(k=>k&&k[y]()).then(k=>l?l(k):k):b.then(k=>l?l(k):k)),E={_wretchReq:t,_fetchReq:f,_sharedState:e,res:w(null),json:w("json"),blob:w("blob"),formData:w("formData"),arrayBuffer:w("arrayBuffer"),text:w("text"),error(y,l){return p.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(_e,y)}},_=h.reduce((y,l)=>({...y,...typeof l.resolver=="function"?l.resolver(y):l.resolver}),E);return a.reduce((y,l)=>l(y,t),_)},Oi={_url:"",_options:{},_config:Ee,_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({[mn]: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(gn,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=yn(r._options.headers),o=this._config.polyfill("FormData",!1),a=typeof n=="object"&&!(o&&n instanceof o)&&(!r._options.headers||!i||vn(i));return r=n?a?r.json(n,i):r.body(n):r,Ti(r._deferred.reduce((s,h)=>h(s,s._url,s._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=yn(this._options.headers);return this.content(e||vn(n)&&n||Ii).body(JSON.stringify(t))}};function ie(t="",e={}){return{...Oi,_url:t,_options:e}}ie.default=ie,ie.options=Si,ie.errorType=Ei,ie.polyfills=_i,ie.WretchError=wn;function ne(){sessionStorage.removeItem(It),X(te.CLEAR_CACHE,{})}function ji(){var n;return(n=(document.documentElement.getAttribute("lang")??"en").split("-")[0])==null?void 0:n.toLocaleLowerCase()}function Ci(t){const e=se("api2",t.environment),n=v=>async(S,P)=>{let Z=sessionStorage.getItem(It);Z||(Z=Date.now().toString(),sessionStorage.setItem(It,Z));const N={...P,headers:{...P.headers,"Cache-Timestamp":Z}};return v(S,N)},r=(v=!0)=>S=>async(P,Z)=>{let N=null;if(N=await De(v),!N){if(v)throw new Error("No access token available");return S(P,Z)}const B={...Z,headers:{...Z.headers,...N?{Authorization:`Bearer ${N}`}:{}}};return S(P,B)},i=v=>(S,P)=>{if(P.headers.Authorization)return v(S,P);const Z=localStorage.getItem("__anon_id"),N=btoa(`${Z}:`),B={...P,headers:{...P.headers,Authorization:`Basic ${N}`}};return v(S,B)},o=ie(e).headers({"Content-Type":"application/json"}).middlewares([n,r(),fn(),pn({delayTimer:1e3,delayRamp:(v,S)=>v*S,maxAttempts:3,until:v=>!!(v&&(v.ok||v.status>=400&&v.status<500)),retryOnNetworkError:!1})]),a=ie(e).headers({"Content-Type":"application/json"}).middlewares([n,r(!1),i,fn(),pn({delayTimer:1e3,delayRamp:(v,S)=>v*S,maxAttempts:3,until:v=>!!(v&&(v.ok||v.status>=400&&v.status<500)),retryOnNetworkError:!1})]);async function s(){return o.get("/entitlements").json()}async function h(v){const S=await o.get("/entitlements").json();return S==null?void 0:S.find(P=>P.id===v)}async function p(v){return o.get(`/entitlements/${v}/access`).json()}async function u(){return o.get("/contracts").json()}async function c(v){const S=await o.get("/contracts").json();return S==null?void 0:S.find(P=>P.id===v)}async function f(){return o.get("/subscriptions").json()}async function d(){return o.get("/bills").json()}async function b(v){const S=await o.get("/bills").json();return S==null?void 0:S.find(P=>P.id===v)}async function I(v,S){const P=await o.url(`/user-metadata/${v}`).put(S).json();return X(te.USER_ATTRIBUTE_CHANGED,{}),ne(),P}async function w(v){const S=await o.url(`/user-metadata/${v}`).delete().res();return ne(),S.ok}async function E(v){return(await o.url(`/user-metadata/${v}`).get().json())[v]}async function _(){return await o.url("/user-metadata").get().json()}async function y(){return await o.url("/tags").get().json()}async function l(v){const S=await o.url(`/tags/${v}`).delete().res();return ne(),S.ok}async function k(v){const S=await o.url("/tags").post(v).res();return X(te.USER_ATTRIBUTE_CHANGED,{}),ne(),S.ok}async function O(v){return(await a.url("/tallies").get().json())[v]}async function j(){return await a.url("/tallies").get().json()}async function A(v){const S=await a.url(`/tallies/${v}`).delete().res();return ne(),S.ok}async function z(v,S){return await a.url(`/tallies/${v}/push`).post(S).json()}async function M(v){return await o.url(`/products/${v}`).get().json()}async function W(){return await De(!1)?await o.url("/profile").get().json():null}async function L(v){const S=await o.url("/profile").patch(v).res();return ne(),S.ok}async function D(){return await o.url("/payment-issues").get().json()}async function H(){return(await o.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function C(){return(await o.url("/profile/unlink-spotify").post().res()).ok}async function K(v){const S=await De(!1);if(!S)throw new Error("No access token available");const P=new URL(`${se("spotify-oas",t.environment)}/sesamy-callback`);P.searchParams.set("access_token",S),P.searchParams.set("state",v),window.location.href=P.toString()}async function F(v){const S=await o.url(`/products/${v}/auto-onboard`).post().json();return S.length&&ne(),S}async function Ie(v,S=3600){const{shortlink:P}=await ie(fi).post({url:v,ttl:S}).json();return P}async function m(v){const S=await De(!1);let P;switch(v.target){case"account":P=new URL(`${se("account",t.environment)}/subscriptions/${t.clientId}`);break;case"consume":P=new URL(`${se("consume",t.environment)}/@${t.clientId}/${v.sku}`),v.episodeId?P.href+=`/${v.episodeId}`:P.href+="/listen";break;default:throw new Error("Invalid target")}return P.searchParams.set("sesamy-redirect-url",v.redirectUrl||window.location.href),S&&(P.hash=`#access_token=${S}`),v.shorten?Ie(P.href,v.ttl):P.href}async function g(v){return(await a.url("/checkouts").post({language:ji(),...v,vendorId:t.clientId})).json()}async function T(v,S){return(await a.url(`/checkouts/${v}`).patch(S)).json()}async function U(v){return(await a.url(`/checkouts/${v}`).get()).json()}async function R(){const v=await De(!1),S=new URL(`${se("account",t.environment)}/subscriptions/${t.clientId}`);v&&(S.hash=`#access_token=${v}`),window.location.href=S.toString()}return{createCheckout:g,updateCheckout:T,getCheckout:U,getEntitlements:s,getEntitlement:h,getEntitlementAccess:p,getContracts:u,getContract:c,getProfile:W,updateProfile:L,getSubscriptions:f,getBills:d,getBill:b,setUserMetadata:I,deleteUserMetadata:w,getUserMetadata:E,listUserMetadata:_,getTags:y,deleteTag:l,setTag:k,getTally:O,getTallies:j,deleteTally:A,pushTally:z,getProduct:M,getPaymentIssues:D,autoOnboardProduct:F,isSpotifyLinked:H,unlinkSpotify:C,linkSpotify:K,generateLink:m,openHostedAccountPage:R}}const bn="@sesamy/sesamy-js",Pt="1.13.2";function kn(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 Ge="undefined",In="object",Tt=function(){},Sn="any",_n="*",ye="__",Be=typeof process<"u"?process:{};Be.env&&Be.env.NODE_ENV;var J=typeof document<"u";Be.versions!=null&&Be.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 En(t,e){return e.charAt(0)[t]()+e.slice(1)}var xi=En.bind(null,"toUpperCase"),$i=En.bind(null,"toLowerCase");function Ai(t){return Pn(t)?xi("null"):typeof t=="object"?Ni(t):Object.prototype.toString.call(t).slice(8,-1)}function qe(t,e){e===void 0&&(e=!0);var n=Ai(t);return e?$i(n):n}function ze(t,e){return typeof e===t}var Y=ze.bind(null,"function"),ce=ze.bind(null,"string"),Pe=ze.bind(null,"undefined"),Li=ze.bind(null,"boolean");ze.bind(null,"symbol");function Pn(t){return t===null}function Ui(t){return qe(t)==="number"&&!isNaN(t)}function Tn(t){return qe(t)==="array"}function G(t){if(!Ri(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ri(t){return t&&(typeof t=="object"||t!==null)}function Ni(t){return Y(t.constructor)?t.constructor.name:null}function Di(t){return t instanceof Error||ce(t.message)&&t.constructor&&Ui(t.constructor.stackTraceLimit)}function On(t,e){if(typeof e!="object"||Pn(e))return!1;if(e instanceof t)return!0;var n=qe(new t(""));if(Di(e))for(;e;){if(qe(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}On.bind(null,TypeError),On.bind(null,SyntaxError);function Qe(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?zi(t,e):n}function zi(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function et(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}et(Qe,"form"),et(Qe,"button"),et(Qe,"input"),et(Qe,"select");function Mi(t){return t?Tn(t)?t:[t]:[]}function jn(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Zi(){if(J){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Hi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Ki(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=jn(n[1]),a=jn(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&&(Wi(r,h.map(function(p){return p.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){return J&&window.location.search.substring(1)}())}function Wi(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 tt(){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 Fi(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 Me="global",Te=ye+"global"+ye,Oe=typeof self===In&&self.self===self&&self||typeof global===In&&global.global===global&&global||void 0;function ve(t){return Oe[Te][t]}function we(t,e){return Oe[Te][t]=e}function je(t){delete Oe[Te][t]}function Ce(t,e,n){var r;try{if(Ot(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Oe[Te]||(Oe[Te]={});var nt={};function Ot(t){if(typeof nt[t]!==Ge)return nt[t];try{var e=window[t];e.setItem(Ge,Ge),e.removeItem(Ge)}catch{return nt[t]=!1}return nt[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 ue="function",oe="undefined",Ji="@@redux/"+Math.random().toString(36),Cn=function(){return typeof Symbol===ue&&Symbol.observable||"@@observable"}(),rt=" != "+ue;function xn(t,e,n){var r;if(typeof e===ue&&typeof n===oe&&(n=e,e=void 0),typeof n!==oe){if(typeof n!==ue)throw new Error("enhancer"+rt);return n(xn)(t,e)}if(typeof t!==ue)throw new Error("reducer"+rt);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!==ue)throw new Error("Listener"+rt);var b=!0;return p(),s.push(d),function(){if(b){b=!1,p();var I=s.indexOf(d);s.splice(I,1)}}}function f(d){if(!G(d))throw new Error("Act != obj");if(typeof d.type===oe)throw new Error("ActType "+oe);if(h)throw new Error("Dispatch in reducer");try{h=!0,o=i(o,d)}finally{h=!1}for(var b=a=s,I=0;I<b.length;I++)(0,b[I])();return d}return f({type:"@@redux/INIT"}),(r={dispatch:f,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ue)throw new Error("next reducer"+rt);i=d,f({type:"@@redux/INIT"})}})[Cn]=function(){var d,b=c;return(d={subscribe:function(I){if(typeof I!="object")throw new TypeError("Observer != obj");function w(){I.next&&I.next(u())}return w(),{unsubscribe:b(w)}}})[Cn]=function(){return this},d},r}function Xi(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+oe}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 Vi(){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 le=ye+"anon_id",be=ye+"user_id",$e=ye+"user_traits",de="userId",Ae="anonymousId",it=["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"],jt=["name","EVENTS","config","loaded"],$=it.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),$n=/^utm_/,An=/^an_prop_/,Ln=/^an_trait_/;function Yi(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===$.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,h=i.initialUser,p=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(le,a.anonymousId),p||e(be,a.userId),h.traits&&e($e,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(b,I){if(I.match($n)||I.match(/^(d|g)clid/)){var w=I.replace($n,"");b.campaign[w==="campaign"?"name":w]=o[I]}return I.match(An)&&(b.props[I.replace(An,"")]=o[I]),I.match(Ln)&&(b.traits[I.replace(Ln,"")]=o[I]),b},{campaign:{},props:{},traits:{}});n.dispatch(x({type:$.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:$.campaign,campaign:d.campaign})}}return r(i)}}}}function Gi(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===$.setItemEnd){if(n.key===le)return x({},e,{anonymousId:n.value});if(n.key===be)return x({},e,{userId:n.value})}switch(n.type){case $.identify:return Object.assign({},e,{userId:n.userId,traits:x({},e.traits,n.traits)});case $.reset:return[be,le,$e].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function Un(t){return{userId:t.getItem(be),anonymousId:t.getItem(le),traits:t.getItem($e)}}var Ct=function(t){return ye+"TEMP"+ye+t};function Bi(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===$.reset&&([be,$e,le].forEach(function(d){r(d)}),[de,Ae,"traits"].forEach(function(d){je(Ct(d))})),s.type===$.identify){i(le)||n(le,tt());var c=i(be),f=i($e)||{};c&&c!==h&&o.dispatch({type:$.userIdChanged,old:{userId:c,traits:f},new:{userId:h,traits:p},options:u}),h&&n(be,h),p&&n($e,x({},f,p))}return a(s)}}}}var Ze={};function Rn(t,e){Ze[t]&&Y(Ze[t])&&(Ze[t](e),delete Ze[t])}function Nn(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 Nn(t,e,n-10).then(r,i)})})}function qi(t){return{abort:t}}function Dn(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,b=f.payload.type,I=i[d][b];if(I&&Y(I)){var w,E=function(l,k){return l===void 0&&(l={}),k===void 0&&(k={}),[de,Ae].reduce(function(O,j){return l.hasOwnProperty(j)&&k[j]&&k[j]!==l[j]&&(O[j]=k[j]),O},l)}(f.payload,h),_=r[E.meta.rid];if(!_&&(w=I({payload:E,config:a[d].config,instance:n,abort:qi}))&&G(w)&&w.abort)return void(r[E.meta.rid]=!0);if(!_){var y=b+":"+d;t.dispatch(x({},E,{type:y,_:{called:y,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,f){return!~p.processIndex.indexOf(f)});s.actions=u}}}var xt=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(Le),d=e.exact.map(function(w){return w.pluginName});f&&(d=a.during.map(function(w){return w.pluginName}));var b=function(w,E){return function(_,y,l){var k=y.config,O=y.name,j=O+"."+_.type;l&&(j=l.event);var A=_.type.match(Le)?function(z,M,W,L,D){return function(H,C){var K=L?L.name:z,F=C&&He(C)?C:W;if(L&&(!(F=C&&He(C)?C:[z]).includes(z)||F.length!==1))throw new Error("Method "+M+" can only abort "+z+" plugin. "+JSON.stringify(F)+" input valid");return x({},D,{abort:{reason:H,plugins:F,caller:M,_:K}})}}(O,j,E,l,_):function(z,M){return function(){throw new Error(z.type+" action not cancellable. Remove abort in "+M)}}(_,j);return{payload:Qi(_),instance:w,config:k||{},abort:A}}}(r,d),I=e.exact.reduce(function(w,E){var _=E.pluginName,y=E.methodName,l=!1;return y.match(/^initialize/)||y.match(/^reset/)||(l=!p[_].loaded),u.offline&&y.match(/^(page|track|identify)/)&&(l=!0),w[""+_]=l,w},{});return Promise.resolve(e.exact.reduce(function(w,E,_){try{var y=E.pluginName;return Promise.resolve(w).then(function(l){function k(){return Promise.resolve(l)}var O=function(){if(e.namespaced&&e.namespaced[y])return Promise.resolve(e.namespaced[y].reduce(function(j,A,z){try{return Promise.resolve(j).then(function(M){return A.method&&Y(A.method)?(function(H,C){var K=Jn(H);if(K&&K.name===C){var F=Jn(K.method);throw new Error([C+" plugin is calling method "+H,"Plugins cant call self","Use "+K.method+" "+(F?"or "+F.method:"")+" in "+C+" plugin insteadof "+H].join(`
|
|
6
|
-
`))}}(A.methodName,A.pluginName),Promise.resolve(A.method({payload:M,instance:r,abort:(W=M,L=y,D=A.pluginName,function(H,C){return x({},W,{abort:{reason:H,plugins:C||[L],caller:c,from:D||L}})}),config:Zn(A.pluginName,p,o),plugins:p})).then(function(H){var C=G(H)?H:{};return Promise.resolve(x({},M,C))})):M;var W,L,D})}catch(M){return Promise.reject(M)}},Promise.resolve(n))).then(function(j){l[y]=j});l[y]=n}();return O&&O.then?O.then(k):k()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(w){return Promise.resolve(e.exact.reduce(function(E,_,y){try{var l=e.exact.length===y+1,k=_.pluginName,O=o[k];return Promise.resolve(E).then(function(j){var A=w[k]?w[k]:{};if(f&&(A=j),At(A,k))return $t({data:A,method:c,instance:r,pluginName:k,store:s}),Promise.resolve(j);if(At(j,k))return l&&$t({data:j,method:c,instance:r,store:s}),Promise.resolve(j);if(I.hasOwnProperty(k)&&I[k]===!0)return s.dispatch({type:"queue",plugin:k,payload:A,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(j);var z=b(w[k],o[k]);return Promise.resolve(O[c]({abort:z.abort,payload:A,instance:r,config:Zn(k,p,o),plugins:p})).then(function(M){var W=G(M)?M:{},L=x({},j,W),D=w[k];if(At(D,k))$t({data:D,method:c,instance:r,pluginName:k,store:s});else{var H=c+":"+k;(H.match(/:/g)||[]).length<2&&!c.match(zn)&&!c.match(Mn)&&r.dispatch(x({},f?L:A,{type:H,_:{called:H,from:"submethod"}}))}return Promise.resolve(L)})})}catch(j){return Promise.reject(j)}},Promise.resolve(n))).then(function(E){if(!(c.match(Le)||c.match(/^registerPlugin/)||c.match(Mn)||c.match(zn)||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"}});Wn(E,e.exact.length)&&!c.match(/End$/)&&(_=x({},_,{type:E.type+"Aborted"})),s.dispatch(_)}return E})})}catch(w){return Promise.reject(w)}},Le=/Start$/,zn=/^bootstrap/,Mn=/^ready/;function $t(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(x({},t.data,{type:n,_:{called:n,from:"abort"}}))}function Zn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function Hn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function Kn(t,e){var n=t.replace(Le,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function At(t,e){var n=t.abort;return!!n&&(n===!0||Fn(n,e)||n&&Fn(n.plugins,e))}function Wn(t,e){var n=t.abort;if(!n)return!1;if(n===!0||ce(n))return!0;var r=n.plugins;return He(n)&&n.length===e||He(r)&&r.length===e}function He(t){return Array.isArray(t)}function Fn(t,e){return!(!t||!He(t))&&t.includes(e)}function Jn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Qi(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=G(t[n])?Object.assign({},t[n]):t[n]),e},{})}function eo(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===$.enablePlugin&&i.dispatch({type:$.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),p===$.disablePlugin&&setTimeout(function(){return Rn(a.meta.rid,{payload:a})},0),p===$.initializeEnd){var f=e(),d=Object.keys(f),b=d.filter(function(l){return u.includes(l)}).map(function(l){return f[l]}),I=[],w=[],E=a.disabled,_=b.map(function(l){var k=l.loaded,O=l.name,j=l.config;return Nn(l,function(){return k({config:j})},1e4).then(function(A){return r[O]||(i.dispatch({type:$.pluginReadyType(O),name:O,events:Object.keys(l).filter(function(z){return!jt.includes(z)})}),r[O]=!0),I=I.concat(O),l}).catch(function(A){if(A instanceof Error)throw new Error(A);return w=w.concat(A.name),A})});Promise.all(_).then(function(l){var k={plugins:I,failed:w,disabled:E};setTimeout(function(){d.length===_.length+E.length&&i.dispatch(x({},{type:$.ready},k))},0)})}var y=function(){if(p!==$.bootstrap)return/^ready:([^:]*)$/.test(p)&&setTimeout(function(){return Dn(i,e,t)},0),Promise.resolve(function(l,k,O,j,A){try{var z=Y(k)?k():k,M=l.type,W=M.replace(Le,"");if(l._&&l._.called)return Promise.resolve(l);var L=O.getState(),D=(K=z,(F=L.plugins)===void 0&&(F={}),(Ie=l.options)===void 0&&(Ie={}),Object.keys(K).filter(function(m){var g=Ie.plugins||{};return Li(g[m])?g[m]:g.all!==!1&&(!F[m]||F[m].enabled!==!1)}).map(function(m){return K[m]}));M===$.initializeStart&&l.fromEnable&&(D=Object.keys(L.plugins).filter(function(m){var g=L.plugins[m];return l.plugins.includes(m)&&!g.initialized}).map(function(m){return z[m]}));var H=D.map(function(m){return m.name}),C=function(m,g,T){var U=Kn(m).map(function(R){return Hn(R,g)});return g.reduce(function(R,v){var S=v.name,P=Kn(m,S).map(function(Xe){return Hn(Xe,g)}),Z=P[0],N=P[1],B=P[2];return Z.length&&(R.beforeNS[S]=Z),N.length&&(R.duringNS[S]=N),B.length&&(R.afterNS[S]=B),R},{before:U[0],beforeNS:{},during:U[1],duringNS:{},after:U[2],afterNS:{}})}(M,D);return Promise.resolve(xt({action:l,data:{exact:C.before,namespaced:C.beforeNS},state:L,allPlugins:z,allMatches:C,instance:O,store:j,EVENTS:A})).then(function(m){function g(){var R=function(){if(M.match(Le))return Promise.resolve(xt({action:x({},T,{type:W+"End"}),data:{exact:C.after,namespaced:C.afterNS},state:L,allPlugins:z,allMatches:C,instance:O,store:j,EVENTS:A})).then(function(v){v.meta&&v.meta.hasCallback&&Rn(v.meta.rid,{payload:v})})}();return R&&R.then?R.then(function(){return m}):m}if(Wn(m,H.length))return m;var T,U=function(){if(M!==W)return Promise.resolve(xt({action:x({},m,{type:W}),data:{exact:C.during,namespaced:C.duringNS},state:L,allPlugins:z,allMatches:C,instance:O,store:j,EVENTS:A})).then(function(R){T=R});T=m}();return U&&U.then?U.then(g):g()})}catch(m){return Promise.reject(m)}var K,F,Ie}(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 to(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===$.setItem||i===$.removeItem){if(r.abort)return n(r);i===$.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var no=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 ro(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=Xn(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=Xn(n.type,$.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 $.disablePlugin:return x({},e,Vn(n.plugins,!1,e));case $.enablePlugin:return x({},e,Vn(n.plugins,!0,e));default:return e}}}function Xn(t,e){return t.substring(e.length+1,t.length)}function Vn(t,e,n){return t.reduce(function(r,i){return r[i]=x({},n[i],{enabled:e}),r},n)}function Yn(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var io={last:{},history:[]};function oo(t,e){t===void 0&&(t=io);var n=e.options,r=e.meta;if(e.type===$.track){var i=Yn(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 ao={actions:[]};function so(t,e){t===void 0&&(t=ao);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===$.identify?[e].concat(t.actions):t.actions.concat(e),x({},t,{actions:r});case"dequeue":return[];default:return t}}var Gn=/#.*$/;function co(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(Gn,""):"")}var Bn,qn,Qn,er,uo=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 b,I=document.getElementsByTagName("link"),w=0;b=I[w];w++)if(b.getAttribute("rel")==="canonical")return b.getAttribute("href")}}();return d?d.match(/\?/)?d:d+f:window.location.href.replace(Gn,"")}(p),c={title:n,url:u,path:co(u),hash:h,search:p,width:a,height:s};return r&&r!==""&&(c.referrer=r),x({},c,t)},lo={last:{},history:[]};function ho(t,e){t===void 0&&(t=lo);var n=e.options;if(e.type===$.page){var r=Yn(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}Bn=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"}(),qn=J?document.referrer:null,Qn=Zi(),er=Hi();var tr={initialized:!1,sessionId:tt(),app:null,version:null,debug:!1,offline:!!J&&!navigator.onLine,os:{name:Bn},userAgent:J?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.13"},timezone:er,locale:Qn,campaign:{},referrer:qn};function fo(t,e){t===void 0&&(t=tr);var n=t.initialized,r=e.campaign;switch(e.type){case $.campaign:return x({},t,{campaign:r});case $.offline:return x({},t,{offline:!0});case $.online:return x({},t,{offline:!1});default:return n?t:x({},tr,t,{initialized:!0})}}var po=["plugins","reducers","storage"];function mo(t,e,n){if(J){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function go(t){var e=mo.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function nr(){return we("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 Oe[Te].analytics.push(a.action||a),o(a)}})}}}function rr(t){return function(){return xe(xe.apply(null,arguments),nr())}}function Lt(t){return t?Tn(t)?t:[t]:[]}function ir(t,e,n){t===void 0&&(t={});var r,i,o=tt();return e&&(Ze[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 yo(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(v){return g.EVENTS[v]}):[];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(v,S){var P;return v[S]=(P=g.methods[S],function(){for(var Z=Array.prototype.slice.call(arguments),N=new Array(P.length),B=0;B<Z.length;B++)N[B]=Z[B];return N[N.length]=k,P.apply({instance:k},N)}),v},{}),delete g.methods);var U=Object.keys(g).concat(T),R=new Set(m.events.concat(U));if(m.events=Array.from(R),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:ve,setItem:we,removeItem:je},o=function(m){return function(g,T,U){return T.getState("user")[g]||(U&&G(U)&&U[g]?U[g]:Un(m)[g]||ve(Ct(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!jt.includes(m)}).sort(),h=new Set(s.concat(it).filter(function(m){return!jt.includes(m)})),p=Array.from(h).sort(),u=function(){return a},c=new no,f=c.addMiddleware,d=c.removeMiddleware,b=c.dynamicMiddlewares,I=function(){throw new Error("Abort disabled inListener")},w=Ki(),E=Un(i),_=x({},E,n,w.an_uid?{userId:w.an_uid}:{},w.an_aid?{anonymousId:w.an_aid}:{});_.anonymousId||(_.anonymousId=tt());var y=x({enable:function(m,g){return new Promise(function(T){C.dispatch({type:$.enablePlugin,plugins:Lt(m),_:{originalAction:$.enablePlugin}},T,[g])})},disable:function(m,g){return new Promise(function(T){C.dispatch({type:$.disablePlugin,plugins:Lt(m),_:{originalAction:$.disablePlugin}},T,[g])})}},r.methods),l=!1,k={identify:function(m,g,T,U){try{var R=ce(m)?m:null,v=G(m)?m:g,S=T||{},P=k.user();we(Ct(de),R);var Z=R||v.userId||o(de,k,v);return Promise.resolve(new Promise(function(N){C.dispatch(x({type:$.identifyStart,userId:Z,traits:v||{},options:S,anonymousId:P.anonymousId},P.id&&P.id!==R&&{previousId:P.id}),N,[g,T,U])}))}catch(N){return Promise.reject(N)}},track:function(m,g,T,U){try{var R=G(m)?m.event:m;if(!R||!ce(R))throw new Error("EventMissing");var v=G(m)?m:g||{},S=G(T)?T:{};return Promise.resolve(new Promise(function(P){C.dispatch({type:$.trackStart,event:R,properties:v,options:S,userId:o(de,k,g),anonymousId:o(Ae,k,g)},P,[g,T,U])}))}catch(P){return Promise.reject(P)}},page:function(m,g,T){try{var U=G(m)?m:{},R=G(g)?g:{};return Promise.resolve(new Promise(function(v){C.dispatch({type:$.pageStart,properties:uo(U),options:R,userId:o(de,k,U),anonymousId:o(Ae,k,U)},v,[m,g,T])}))}catch(v){return Promise.reject(v)}},user:function(m){if(m===de||m==="id")return o(de,k);if(m===Ae||m==="anonId")return o(Ae,k);var g=k.getState("user");return m?kn(g,m):g},reset:function(m){return new Promise(function(g){C.dispatch({type:$.resetStart},g,m)})},ready:function(m){return l&&m({plugins:y,instance:k}),k.on($.ready,function(g){m(g),l=!0})},on:function(m,g){if(!m||!Y(g))return!1;if(m===$.bootstrap)throw new Error(".on disabled for "+m);var T=/Start$|Start:/;if(m==="*"){var U=function(P){return function(Z){return function(N){return N.type.match(T)&&g({payload:N,instance:k,plugins:a}),Z(N)}}},R=function(P){return function(Z){return function(N){return N.type.match(T)||g({payload:N,instance:k,plugins:a}),Z(N)}}};return f(U,ot),f(R,at),function(){d(U,ot),d(R,at)}}var v=m.match(T)?ot:at,S=function(P){return function(Z){return function(N){return N.type===m&&g({payload:N,instance:k,plugins:a,abort:I}),Z(N)}}};return f(S,v),function(){return d(S,v)}},once:function(m,g){if(!m||!Y(g))return!1;if(m===$.bootstrap)throw new Error(".once disabled for "+m);var T=k.on(m,function(U){g({payload:U.payload,instance:k,plugins:a,abort:I}),T()});return T},getState:function(m){var g=C.getState();return m?kn(g,m):Object.assign({},g)},dispatch:function(m){var g=ce(m)?{type:m}:m;if(it.includes(g.type))throw new Error("reserved action "+g.type);var T=x({},g,{_:x({originalAction:g.type},m._||{})});C.dispatch(T)},enablePlugin:y.enable,disablePlugin:y.disable,plugins:y,storage:{getItem:i.getItem,setItem:function(m,g,T){C.dispatch({type:$.setItemStart,key:m,value:g,options:T})},removeItem:function(m,g){C.dispatch({type:$.removeItemStart,key:m,options:g})}},setAnonymousId:function(m,g){k.storage.setItem(le,m,g)},events:{core:it,plugins:s}},O=r.middlewares.concat([function(m){return function(g){return function(T){return T.meta||(T.meta=ir()),g(T)}}},b(ot),eo(k,u,{all:p,plugins:s}),to(i),Yi(k),Bi(k),b(at)]),j={context:fo,user:Gi(i),page:ho,track:oo,plugins:ro(u),queue:so},A=xe,z=xe;if(J&&t.debug){var M=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;M&&(A=M({trace:!0,traceLimit:25})),z=function(){return arguments.length===0?nr():G(typeof arguments[0])?rr():rr().apply(null,arguments)}}var W,L=function(m){return Object.keys(m).reduce(function(g,T){return po.includes(T)||(g[T]=m[T]),g},{})}(t),D=r.pluginsArray.reduce(function(m,g){var T=g.name,U=g.config,R=g.loaded,v=r.pluginEnabled[T];return m[T]={enabled:v,initialized:!!v&&!g.initialize,loaded:!!R({config:U}),config:U},m},{}),H={context:L,user:_,plugins:D},C=xn(function(m){for(var g=Object.keys(m),T={},U=0;U<g.length;U++){var R=g[U];typeof m[R]===ue&&(T[R]=m[R])}var v,S=Object.keys(T);try{(function(P){Object.keys(P).forEach(function(Z){var N=P[Z];if(typeof N(void 0,{type:"@@redux/INIT"})===oe||typeof N(void 0,{type:Ji})===oe)throw new Error("reducer "+Z+" "+oe)})})(T)}catch(P){v=P}return function(P,Z){if(P===void 0&&(P={}),v)throw v;for(var N=!1,B={},Xe=0;Xe<S.length;Xe++){var ft=S[Xe],Ar=P[ft],Ft=(0,T[ft])(Ar,Z);if(typeof Ft===oe){var aa=Xi(ft,Z);throw new Error(aa)}B[ft]=Ft,N=N||Ft!==Ar}return N?B:P}}(x({},j,e)),H,z(A(Vi.apply(void 0,O))));C.dispatch=(W=C.dispatch,function(m,g,T){var U=x({},m,{meta:ir(m.meta,g,Lt(T))});return W.apply(null,[U])});var K=Object.keys(a);C.dispatch({type:$.bootstrap,plugins:K,config:L,params:w,user:_,initialUser:n,persistedUser:E});var F=K.filter(function(m){return r.pluginEnabled[m]}),Ie=K.filter(function(m){return!r.pluginEnabled[m]});return C.dispatch({type:$.registerPlugins,plugins:K,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,g){var T=m.bootstrap,U=m.config,R=m.name;T&&Y(T)&&T({instance:k,config:U,payload:m}),C.dispatch({type:$.registerPluginType(R),name:R,enabled:r.pluginEnabled[R],plugin:m}),r.pluginsArray.length===g+1&&C.dispatch({type:$.initializeStart,plugins:F,disabled:Ie})}),go(function(m){C.dispatch({type:m?$.offline:$.online})}),function(m,g,T){setInterval(function(){return Dn(m,g,T)},3e3)}(C,u,k),k}var ot="before",at="after",Ke="cookie",ke=sr(),or=st,vo=st;function ar(t){return ke?st(t,"",-1):je(t)}function sr(){if(ke!==void 0)return ke;var t="cookiecookie";try{st(t,t),ke=document.cookie.indexOf(t)!==-1,ar(t)}catch{ke=!1}return ke}function st(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return ke===!1&&(a?we(t,e):ve(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 We="localStorage",wo=Ot.bind(null,"localStorage");Ce("localStorage","getItem",ve),Ce("localStorage","setItem",we),Ce("localStorage","removeItem",je);var Fe="sessionStorage",bo=Ot.bind(null,"sessionStorage");Ce("sessionStorage","getItem",ve),Ce("sessionStorage","setItem",we),Ce("sessionStorage","removeItem",je);function Ue(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(G(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var ko=wo(),Io=bo(),So=sr();function cr(t,e){if(t){var n=Ut(e),r=!zt(n),i=Rt(n)?Ue(localStorage.getItem(t)):void 0;if(r&&!Pe(i))return i;var o=Nt(n)?Ue(or(t)):void 0;if(r&&o)return o;var a=Dt(n)?Ue(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=ve(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function _o(t,e,n){if(t&&!Pe(e)){var r={},i=Ut(n),o=JSON.stringify(e),a=!zt(i);return Rt(i)&&(r[We]=ut(We,e,Ue(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[We]:Nt(i)&&(r[Ke]=ut(Ke,e,Ue(or(t))),vo(t,o),a)?r[Ke]:Dt(i)&&(r[Fe]=ut(Fe,e,Ue(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Fe]:(r[Me]=ut(Me,e,ve(t)),we(t,e),a?r[Me]:r)}}function Eo(t,e){if(t){var n=Ut(e),r=cr(t,_n),i={};return!Pe(r.localStorage)&&Rt(n)&&(localStorage.removeItem(t),i[We]=r.localStorage),!Pe(r.cookie)&&Nt(n)&&(ar(t),i[Ke]=r.cookie),!Pe(r.sessionStorage)&&Dt(n)&&(sessionStorage.removeItem(t),i[Fe]=r.sessionStorage),!Pe(r.global)&&ct(n,Me)&&(je(t),i[Me]=r.global),i}}function Ut(t){return t?ce(t)?t:t.storage:Sn}function Rt(t){return ko&&ct(t,We)}function Nt(t){return So&&ct(t,Ke)}function Dt(t){return Io&&ct(t,Fe)}function zt(t){return t===_n||t==="all"}function ct(t,e){return t===Sn||t===e||zt(t)}function ut(t,e,n){return{location:t,current:e,previous:n}}var Po={setItem:_o,getItem:cr,removeItem:Eo};function To(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ur(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 lr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ur(Object(n),!0).forEach(function(r){To(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ur(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Oo(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:Po};return yo(lr(lr({},e),t))}function jo(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 Co(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=$o(p);return i!==u&&(i=u,setTimeout(()=>t(p),0)),s.apply(n,h)}})}function xo(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function $o(t){return["#","?"].forEach(e=>t=xo(t,e)),t}function Ao(){Co(()=>{ae.page()})}function Lo(t){if(t===void 0&&(t={}),!J)return Tt;var e=hr(),n=Mt(),r=dr(),i=lt(r,e),o=lt(n,e),a=[],s=[],h=[],p=r,u=i,c=o,f=Object.keys(t);if(!f.length)return Tt;var d=f.map(function(I){return Number(I)}),b=Fi(function(){var I=hr(),w=function(L,D){return D.map(function(H){return H===100?L-5:L*(H/100)})}(I,d),E=Mt(),_=dr(),y=lt(_,I),l=lt(E,I);if(u=y>u?y:u,c=l<c?l:c,!(a.length>=d.length)){var k=p===_,O="up";k?O="initial":p<=_&&(O="down");var j=w,A=d;(O==="up"||k)&&(j=w.slice().reverse(),A=d.slice().reverse());var z=A.reduce(function(L,D,H){var C=j[H];return h.includes(D)&&_<=C&&(h=h.filter(function(K){return K!==D}),L.singleFunction=D),O==="down"&&!a.includes(D)&&_>=C&&D>o?(s.push(D),L.callbacks=L.callbacks.concat(D),L):O==="up"&&!a.includes(D)&&_<=C&&D<=y?(L.foundFunc=[D],L):(k&&_>=C&&L.foundFunc.length===0&&(L.foundFunc=[D]),!s.includes(D)&&_>=C&&(s.push(D),L.singleFunction?h.push(D):L.singleFunction=D),L)},{foundFunc:[],singleFunction:null,callbacks:[],direction:O});if(p=_,O==="down"&&z.callbacks&&z.callbacks.forEach(function(L){Y(t[L])&&(t[L]({trigger:L,direction:O,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(L))}),z.singleFunction){var M=z.singleFunction,W=z.direction;Y(t[M])&&t[M]({trigger:M,direction:W,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(M)}}},500);return window.addEventListener("scroll",b),function(){return window.removeEventListener("scroll",b)}}function Mt(){return J?document.body.scrollTop||document.documentElement.scrollTop:0}function Uo(){return J?window.innerHeight||document.documentElement.clientHeight:0}function dr(){return Math.round(Mt()+Uo())}function hr(){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 lt(t,e){return Math.round(t/e*100)}var fr="EventListener";function Ro(t){return function(e,n,r,i){var o=r||Tt,a=i||!1;if(!J)return o;var s=dt(n),h=dt(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"+fr:"remove"+fr,d=0;d<h.length;d++){var b=h[d];p[d]=c?a&&a.once?No(o):o:p[d]||o;for(var I=0;I<s.length;I++)b[f]?b["on"+s[I]]=c?p[d]:null:b[f](s[I],p[d],a)}return u.bind(null,!c)}(t)}}function dt(t,e){if(ce(t))return e?dt(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=Mi(t);return e?o.map(function(a){return ce(a)?dt(a,!0):a}).flat():o}function No(t,e){var n;return function(){return t&&(n=t.apply(this,arguments),t=null),n}}var Zt=Ro("Event");function pr(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}pr.bind(null,"onerror"),pr.bind(null,"onload");var mr=typeof window>"u",gr="hidden";function Do(t){if(mr)return!1;var e=zo(),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 zo(){var t=["webkit","moz","ms","o"];return mr||gr in document?gr:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var Mo=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Zo(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=Do(function(s){s||n({type:"tabVisible"})});return r=[a].concat(Mo.map(function(s){return Zt(document,s,n)})).concat(Zt(window,"load",n)).concat(Zt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Ho(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 b(w){d(),o&&!u&&o(Je(f),w),i&&u&&(u=!1,i(Je(n),w),f=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(Je(f),w))},s)}var I=Zo(b,{throttle:p});return{disable:function(){c=!0,u=!1,d();var w=I();return function(){return c=!1,f=new Date,b({type:"load"}),w()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:Je(f,c),idle:u?Je(n,c):0}}}}function Je(t,e){return e?0:Math.round((new Date-t)/1e3)}const yr=5e3;class Ko{constructor(e){ee(this,"element");ee(this,"isInViewport",!1);ee(this,"isAwake",!1);ee(this,"isFlushing");ee(this,"observer");ee(this,"lastEventAt",Date.now());ee(this,"registeredView",!1);ee(this,"viewCallback");ee(this,"activeDurationCallback");ee(this,"idleDurationCallback");ee(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),Ho({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:yr}),Lo({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*yr: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 vr="sesamy_session_id";function Wo(){let t=sessionStorage.getItem(vr);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(vr,t)),t}let wr=!1,Ht,br,ht;function Fo({clientId:t,enabled:e=!0,environment:n}){if(Ht=t,br=e,ht=`${se("logs",n)}/events`,!br)return;Ao();const r=new Ko({element:document.body,viewCallback:()=>{ae.page()},activeDurationCallback:(i,o,a)=>{ae.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{ae.track("idleDuration",{duration:i,durationStart:a,flushing:o})},scrollCallback:i=>{ae.track("scroll",{scroll:i.scrollMax})}});Vo(document.body,()=>{r.flush()}),Yo(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(te.AUTHENTICATED,async i=>{const o=i;await ae.identify(o.detail.sub)}),window.addEventListener(te.LOGOUT,async()=>{await ae.track("logout",{}),Kt.flush(),await ae.reset()})}function kr(t){return JSON.stringify(t.map(e=>({...e,clientId:Ht,requestId:Math.random().toString(36).slice(2,9),sessionId:Wo(),timestamp:new Date().toISOString(),version:Pt,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:bn,userAgent:navigator.userAgent,clientId:Ht}})))}const Kt=jo(async t=>{if(t.length>0){const e=kr(t);wr?navigator.sendBeacon(ht,e):(await fetch(ht,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function Wt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(ht,kr([n]))}else Kt.push(t)}const ae=Oo({app:bn,version:Pt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Wt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Wt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;Wt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Jo(t,e){ae.track(t,e)}function Xo(){return wr=!0,Kt.flush()}const Ir=new Map;function Vo(t,e){Ir.set(t,e)}window.addEventListener("beforeunload",()=>{Ir.forEach((t,e)=>{t.bind(e)()}),Xo()});const Sr=new Map;function Yo(t,e){Sr.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&Sr.forEach((t,e)=>{t.bind(e)()})});const _r="sesamySignedURLs";function Er(){const t=sessionStorage.getItem(_r);return t?JSON.parse(t):[]}function Go(t){const e=Er();e.push(t),sessionStorage.setItem(_r,JSON.stringify(e))}function Bo(t){const{createCheckout:e,getCheckout:n,updateCheckout:r,getEntitlement:i,getEntitlements:o,getEntitlementAccess:a,getSubscriptions:s,getContract:h,getContracts:p,getBill:u,getBills:c,getProfile:f,updateProfile:d,getTags:b,deleteTag:I,setTag:w,getUserMetadata:E,listUserMetadata:_,setUserMetadata:y,deleteUserMetadata:l,getTally:k,getTallies:O,pushTally:j,deleteTally:A,getProduct:z,getPaymentIssues:M,isSpotifyLinked:W,unlinkSpotify:L,linkSpotify:D,autoOnboardProduct:H,openHostedAccountPage:C,generateLink:K}=Ci(t),F={auth:{getUser:f,isAuthenticated:_t,loginWithRedirect:Et,logout:gi,setToken:hn},checkouts:{get:n,create:e,update:r},profile:{get:f,update:d,openHostedAccountPage:C,isSpotifyLinked:W,unlinkSpotify:L},analytics:{track:Jo},tags:{list:b,set:w,delete:I},entitlements:{get:i,list:o,access:a,signedLinks:Er},contracts:{get:h,list:p},bills:{get:u,list:c},userMetadata:{get:E,list:_,set:y,delete:l},tallies:{get:k,list:O,push:j,delete:A},subscriptions:{list:s},products:{get:z,autoOnboard:H,linkSpotify:D},getVersion:qo,getPaymentIssues:M,generateLink:K,clearCache:ne};return t.namespace&&(window[t.namespace]=F),F}function qo(){return Pt}async function Qo({enabled:t=!1,rules:e}){if(!t)return;const n=await _t(),r=window.location.href;for(const i of e){const o=document.querySelectorAll(i.selector);if(!(i.path&&!new RegExp(i.path).test(r))){for(const a of o)if(!(i.authenticated!==void 0&&i.authenticated!==n))switch(i.transform){case"insert":if(i.contentType==="selector"&&i.content){const s=document.querySelector(i.content);s?a.innerHTML+=s.innerHTML:console.warn(`Source element for selector '${i.content}' not found`)}else if(i.contentType==="url"&&i.content){const s=await Pr(i.content);s?a.innerHTML+=s:console.warn(`Failed to fetch content from URL '${i.content}'`)}else i.content&&(a.innerHTML+=i.content);break;case"replace":if(i.contentType==="selector"&&i.content){const s=document.querySelector(i.content);s?a.innerHTML=s.innerHTML:console.warn(`Source element for selector '${i.content}' not found`)}else if(i.contentType==="url"&&i.content){const s=await Pr(i.content);s?a.innerHTML=s:console.warn(`Failed to fetch content from URL '${i.content}'`)}else i.content&&(a.innerHTML=i.content);break;case"remove":a.remove();break;default:console.warn(`Unknown transform type: ${i.transform}`)}}}}async function Pr(t){try{const e=await fetch(t);return e.ok?await e.text():(console.error(`Failed to fetch content from ${t}: ${e.statusText}`),null)}catch(e){return console.error(`Error fetching content from ${t}:`,e),null}}function ea(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token");if(e){hn(e);const n=new URL(window.location.href);t.delete("access_token"),n.hash=t.toString(),window.history.replaceState(null,"",n)}}const Tr="sesamy-refresh",Or="force-refetch-entitlements";function ta(){const t=new URLSearchParams(window.location.search),e=t.get(Or),n=t.get(Tr);if(e!==null||n!==null){const r=new URL(window.location.href);t.delete(Or),t.delete(Tr),r.search=t.toString(),ne(),window.history.replaceState(null,"",r)}}function na(){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;Go({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 jr="sesamy-user";async function ra(){const e=new URLSearchParams(window.location.search).get(jr);if(!e)return;const n=await mi();(n==null?void 0:n.email)!==e&&(ne(),Et({authorizationParams:{email_hint:e,login_hint:e}}));const r=new URL(window.location.href);r.searchParams.delete(jr),window.history.replaceState(null,"",r)}const Cr="sesamy-purchase";function ia(){const t=new URLSearchParams(window.location.search),e=t.get(Cr);if(e!==null){const n=new URL(window.location.href);t.delete(Cr),n.search=t.toString(),X(te.PURCHASE,{itemSrc:e}),ne(),window.history.replaceState(null,"",n)}}const xr="sesamy-login";async function oa(){if(!new URLSearchParams(window.location.search).get(xr))return;await _t()||Et();const r=new URL(window.location.href);r.searchParams.delete(xr),window.history.replaceState(null,"",r)}async function $r(t){Fo({clientId:t.clientId,environment:t.environment,...t.analytics}),await pi({clientId:t.clientId,organization:t.organization,environment:t.environment,...t.auth}),t.transform&&await Qo(t.transform);const e=Bo({clientId:t.clientId,environment:t.environment,...t.api});return X(te.READY,{}),ea(),ta(),na(),await oa(),await ra(),ia(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);$r(e)}catch(e){console.error("Failed to parse config",e)}}return re.init=$r,Object.defineProperty(re,Symbol.toStringTag,{value:"Module"}),re}({});
|
|
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",!sn(n))throw new Error(`Invalid cache location "${n}"`);r=sn(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?Se:ii,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:oi;var o;this.scope=Ye("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new ei(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Yt,this.cacheManager=new Qr(r,r.allKeys?void 0:new ci(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 si)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Vt)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${vt(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return ni({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=qt(yt()),o=qt(yt()),a=yt(),s=(u=>{const c=new Uint8Array(u);return(f=>{const d={"+":"-","/":"_","=":""};return f.replace(/[+/=]/g,b=>d[b])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Ve().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),h=((u,c,f,d,b,I,w,E)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),f),{scope:Ye(c,f.scope),response_type:"code",response_mode:E||"query",state:d,nonce:b,redirect_uri:w||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),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 Fr(s.popup)))},1e3),f=setTimeout(()=>{clearInterval(c),p(new Wr(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(q.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 q("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=cn(e),{openUrl:i,fragment:o,appState:a}=r,s=V(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=V(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 q("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new Kr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new q("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:Ye(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=bt[a];return s||(s=o().finally(()=>{delete bt[a],s=null}),bt[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=V(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})(()=>kt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new gt;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 kt.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:Ye(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},Hr),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=V(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${vt(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=cn(e),{openUrl:r}=n,i=V(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 q("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((b,I,w=60)=>new Promise((E,_)=>{const v=window.document.createElement("iframe");v.setAttribute("width","0"),v.setAttribute("height","0"),v.style.display="none";const l=()=>{window.document.body.contains(v)&&(window.document.body.removeChild(v),window.removeEventListener("message",k,!1))};let k;const O=setTimeout(()=>{_(new gt),l()},1e3*w);k=function(j){if(j.origin!=I||!j.data||j.data.type!=="authorization_response")return;const A=j.source;A&&A.close(),j.data.response.error?_(q.fromPayload(j.data.response)):E(j.data.response),clearTimeout(O),window.removeEventListener("message",k,!1),setTimeout(l,2e3)},window.addEventListener("message",k,!1),window.document.body.appendChild(v),v.setAttribute("src",b)}))(i,this.domainUrl,c);if(o!==f.state)throw new q("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 Gt(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=V(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 Br(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 di(t){const e=new li(t);return await e.checkSession(),e}var te=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.CLEAR_CACHE="sesamyJsClearCache",t.USER_ATTRIBUTE_CHANGED="sesamyUserAttributeChanged",t.PURCHASE="sesamyJsPurchase",t))(te||{});const hi="sesamy.com",fi="sesamy.dev",pi="https://sesa.my",It="sesamyCacheTimestamp";function se(t,e){return`https://${t}.${e==="dev"?fi:hi}`}let Q,un;const Ne="sesamyAccessToken";function St(){const t=localStorage.getItem(Ne);if(!t)return null;const e=dn(t);return(!e||!e.exp||e.exp<new Date().getTime()/1e3)&&localStorage.removeItem(Ne),t}function ln(t){try{const e=new URL(t).hostname,n=e.split(".");return n.length>1?n.slice(-2).join("."):e}catch{return null}}async function mi(t){if(t.enabled===!1)return;un=t.organization;const e={domain:se("token",t.environment),clientId:t.clientId,useCookiesForTransactions:!0};if(ln(window.location.href)!==ln(se("auth",t.environment))&&(e.cacheLocation="localstorage",e.useRefreshTokens=!0),Q=await di(e),window.location.search.includes("code="))try{await Q.handleRedirectCallback();const n=await Q.getUser();X(te.AUTHENTICATED,n);const r=new URL(location.href),i=r.searchParams;i.delete("code"),i.delete("state"),r.search=i.toString(),window.history.replaceState({},document.title,r.toString())}catch(n){console.error(n)}}async function _t(){return St()?!0:Q?Q.isAuthenticated():!1}async function gi(){return St()?{sub:"local",name:"Local User"}:Q?Q.getUser():null}function Et(t){if(localStorage.removeItem(Ne),!Q)throw new Error("Auth0 client not initialized");const e=(t==null?void 0:t.authorizationParams)||{};return Q.loginWithRedirect({...t,authorizationParams:{organization:un,redirect_uri:window.location.href,...e}})}async function De(t=!0){const e=St();if(e)return e;try{return Q?await Q.getTokenSilently():null}catch(n){if(t)throw n;return null}}async function yi(t={}){if(localStorage.removeItem(Ne),X(te.LOGOUT,{}),!!Q)return Q.logout({...t,logoutParams:{returnTo:window.location.href,...t.logoutParams}})}function dn(t){const e=t.split(".");if(e.length!==3)return null;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 hn(t){const e=dn(t);if(!e||!e.exp||e.exp<new Date().getTime()/1e3)throw new Error("Invalid token");localStorage.setItem(Ne,t),X(te.AUTHENTICATED,e)}const vi=(t,e)=>e.skipDedupe||e.method!=="GET",wi=(t,e)=>e.method+"@"+t,bi=t=>t.clone(),fn=({skip:t=vi,key:e=wi,resolver:n=bi}={})=>{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)}}},ki=(t,e)=>t*e,Ii=t=>t&&t.ok,pn=({delayTimer:t=500,delayRamp:e=ki,maxAttempts:n=10,until:r=Ii,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,b)=>Promise.resolve(r(d,b)).then(I=>I?d&&a?d:b?Promise.reject(b):d:(c++,!n||c<=n?new Promise(w=>{const E=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:b,url:p,options:u})).then((_={})=>{var v,l;w(h((v=_&&_.url)!==null&&v!==void 0?v:p,(l=_&&_.options)!==null&&l!==void 0?l:u))}):w(h(p,u))},E)}).then(f).catch(w=>{if(!o)throw w;return f(null,w)}):d&&a?d:Promise.reject(b||new Error("Number of attempts exceeded."))));return h(p,u).then(f).catch(d=>{if(!o)throw d;return f(null,d)})},Si="application/json",mn="Content-Type",_e=Symbol(),gn=Symbol();function yn(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===mn.toLowerCase()))===null||e===void 0?void 0:e[1]}function vn(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})},Ee={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 _i(t,e=!1){Ee.options=e?t:ge(Ee.options,t)}function Ei(t,e=!1){Ee.polyfills=e?t:ge(Ee.polyfills,t)}function Pi(t){Ee.errorType=t}const Ti=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class wn extends Error{}const Oi=t=>{const e=Object.create(null);t=t._addons.reduce((v,l)=>l.beforeRequest&&l.beforeRequest(v,t._options,e)||v,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=Ti(s)((v,l)=>(c=v,i.polyfill("fetch")(v,l)))(n,u),d=new Error,b=f.catch(v=>{throw{[_e]:v}}).then(v=>{if(!v.ok){const l=new wn;if(l.cause=d,l.stack=l.stack+`
|
|
5
|
+
CAUSE: `+d.stack,l.response=v,l.url=c,v.type==="opaque")throw l;return v.text().then(k=>{var O;if(l.message=k,i.errorType==="json"||((O=v.headers.get("Content-Type"))===null||O===void 0?void 0:O.split(";")[0])==="application/json")try{l.json=JSON.parse(k)}catch{}throw l.text=k,l.status=v.status,l})}return v}),I=v=>v.catch(l=>{const k=l.hasOwnProperty(_e),O=k?l[_e]:l,j=(O==null?void 0:O.status)&&p.get(O.status)||p.get(O==null?void 0:O.name)||k&&p.has(_e)&&p.get(_e);if(j)return j(O,t);const A=p.get(gn);if(A)return A(O,t);throw O}),w=v=>l=>I(v?b.then(k=>k&&k[v]()).then(k=>l?l(k):k):b.then(k=>l?l(k):k)),E={_wretchReq:t,_fetchReq:f,_sharedState:e,res:w(null),json:w("json"),blob:w("blob"),formData:w("formData"),arrayBuffer:w("arrayBuffer"),text:w("text"),error(v,l){return p.set(v,l),this},badRequest(v){return this.error(400,v)},unauthorized(v){return this.error(401,v)},forbidden(v){return this.error(403,v)},notFound(v){return this.error(404,v)},timeout(v){return this.error(408,v)},internalError(v){return this.error(500,v)},fetchError(v){return this.error(_e,v)}},_=h.reduce((v,l)=>({...v,...typeof l.resolver=="function"?l.resolver(v):l.resolver}),E);return a.reduce((v,l)=>l(v,t),_)},ji={_url:"",_options:{},_config:Ee,_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({[mn]: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(gn,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=yn(r._options.headers),o=this._config.polyfill("FormData",!1),a=typeof n=="object"&&!(o&&n instanceof o)&&(!r._options.headers||!i||vn(i));return r=n?a?r.json(n,i):r.body(n):r,Oi(r._deferred.reduce((s,h)=>h(s,s._url,s._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=yn(this._options.headers);return this.content(e||vn(n)&&n||Si).body(JSON.stringify(t))}};function ie(t="",e={}){return{...ji,_url:t,_options:e}}ie.default=ie,ie.options=_i,ie.errorType=Pi,ie.polyfills=Ei,ie.WretchError=wn;function ne(){sessionStorage.removeItem(It),X(te.CLEAR_CACHE,{})}function bn(){var n;return(n=(document.documentElement.getAttribute("lang")??"en").split("-")[0])==null?void 0:n.toLocaleLowerCase()}function Ci(t){const e=se("api2",t.environment),n=y=>async(S,P)=>{let z=sessionStorage.getItem(It);z||(z=Date.now().toString(),sessionStorage.setItem(It,z));const N={...P,headers:{...P.headers,"Cache-Timestamp":z}};return y(S,N)},r=(y=!0)=>S=>async(P,z)=>{let N=null;if(N=await De(y),!N){if(y)throw new Error("No access token available");return S(P,z)}const B={...z,headers:{...z.headers,...N?{Authorization:`Bearer ${N}`}:{}}};return S(P,B)},i=y=>(S,P)=>{if(P.headers.Authorization)return y(S,P);const z=localStorage.getItem("__anon_id"),N=btoa(`${z}:`),B={...P,headers:{...P.headers,Authorization:`Basic ${N}`}};return y(S,B)},o=ie(e).headers({"Content-Type":"application/json"}).middlewares([n,r(),fn(),pn({delayTimer:1e3,delayRamp:(y,S)=>y*S,maxAttempts:3,until:y=>!!(y&&(y.ok||y.status>=400&&y.status<500)),retryOnNetworkError:!1})]),a=ie(e).headers({"Content-Type":"application/json"}).middlewares([n,r(!1),i,fn(),pn({delayTimer:1e3,delayRamp:(y,S)=>y*S,maxAttempts:3,until:y=>!!(y&&(y.ok||y.status>=400&&y.status<500)),retryOnNetworkError:!1})]);async function s(){return o.get("/entitlements").json()}async function h(y){const S=await o.get("/entitlements").json();return S==null?void 0:S.find(P=>P.id===y)}async function p(y){return o.get(`/entitlements/${y}/access`).json()}async function u(){return o.get("/contracts").json()}async function c(y){const S=await o.get("/contracts").json();return S==null?void 0:S.find(P=>P.id===y)}async function f(){return o.get("/subscriptions").json()}async function d(){return o.get("/bills").json()}async function b(y){const S=await o.get("/bills").json();return S==null?void 0:S.find(P=>P.id===y)}async function I(y,S){const P=await o.url(`/user-metadata/${y}`).put(S).json();return X(te.USER_ATTRIBUTE_CHANGED,{}),ne(),P}async function w(y){const S=await o.url(`/user-metadata/${y}`).delete().res();return ne(),S.ok}async function E(y){return(await o.url(`/user-metadata/${y}`).get().json())[y]}async function _(){return await o.url("/user-metadata").get().json()}async function v(){return await o.url("/tags").get().json()}async function l(y){const S=await o.url(`/tags/${y}`).delete().res();return ne(),S.ok}async function k(y){const S=await o.url("/tags").post(y).res();return X(te.USER_ATTRIBUTE_CHANGED,{}),ne(),S.ok}async function O(y){return(await a.url("/tallies").get().json())[y]}async function j(){return await a.url("/tallies").get().json()}async function A(y){const S=await a.url(`/tallies/${y}`).delete().res();return ne(),S.ok}async function M(y,S){return await a.url(`/tallies/${y}/push`).post(S).json()}async function Z(y){return await o.url(`/products/${y}`).get().json()}async function W(){return await De(!1)?await o.url("/profile").get().json():null}async function L(y){const S=await o.url("/profile").patch(y).res();return ne(),S.ok}async function D(){return await o.url("/payment-issues").get().json()}async function H(){return(await o.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function C(){return(await o.url("/profile/unlink-spotify").post().res()).ok}async function K(y){const S=await De(!1);if(!S)throw new Error("No access token available");const P=new URL(`${se("spotify-oas",t.environment)}/sesamy-callback`);P.searchParams.set("access_token",S),P.searchParams.set("state",y),window.location.href=P.toString()}async function F(y){const S=await o.url(`/products/${y}/auto-onboard`).post().json();return S.length&&ne(),S}async function Ie(y,S=3600){const{shortlink:P}=await ie(pi).post({url:y,ttl:S}).json();return P}async function m(y){const S=await De(!1);let P;const z=y.language||bn();switch(y.target){case"account":P=new URL(`${se("account",t.environment)}/${z}/subscriptions/${t.clientId}`);break;case"consume":P=new URL(`${se("consume",t.environment)}/${z}/@${t.clientId}/${y.sku}`),y.episodeId?P.href+=`/${y.episodeId}`:P.href+="/listen";break;default:throw new Error("Invalid target")}return P.searchParams.set("sesamy-redirect-url",y.redirectUrl||window.location.href),S&&(P.hash=`#access_token=${S}`),y.shorten?Ie(P.href,y.ttl):P.href}async function g(y){return(await a.url("/checkouts").post({language:bn(),...y,vendorId:t.clientId})).json()}async function T(y,S){return(await a.url(`/checkouts/${y}`).patch(S)).json()}async function U(y){return(await a.url(`/checkouts/${y}`).get()).json()}async function R(){const y=await De(!1),S=new URL(`${se("account",t.environment)}/subscriptions/${t.clientId}`);y&&(S.hash=`#access_token=${y}`),window.location.href=S.toString()}return{createCheckout:g,updateCheckout:T,getCheckout:U,getEntitlements:s,getEntitlement:h,getEntitlementAccess:p,getContracts:u,getContract:c,getProfile:W,updateProfile:L,getSubscriptions:f,getBills:d,getBill:b,setUserMetadata:I,deleteUserMetadata:w,getUserMetadata:E,listUserMetadata:_,getTags:v,deleteTag:l,setTag:k,getTally:O,getTallies:j,deleteTally:A,pushTally:M,getProduct:Z,getPaymentIssues:D,autoOnboardProduct:F,isSpotifyLinked:H,unlinkSpotify:C,linkSpotify:K,generateLink:m,openHostedAccountPage:R}}const kn="@sesamy/sesamy-js",Pt="1.13.2";function In(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 Ge="undefined",Sn="object",Tt=function(){},_n="any",En="*",ye="__",Be=typeof process<"u"?process:{};Be.env&&Be.env.NODE_ENV;var J=typeof document<"u";Be.versions!=null&&Be.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 Pn(t,e){return e.charAt(0)[t]()+e.slice(1)}var xi=Pn.bind(null,"toUpperCase"),$i=Pn.bind(null,"toLowerCase");function Ai(t){return Tn(t)?xi("null"):typeof t=="object"?Ni(t):Object.prototype.toString.call(t).slice(8,-1)}function qe(t,e){e===void 0&&(e=!0);var n=Ai(t);return e?$i(n):n}function ze(t,e){return typeof e===t}var Y=ze.bind(null,"function"),ce=ze.bind(null,"string"),Pe=ze.bind(null,"undefined"),Li=ze.bind(null,"boolean");ze.bind(null,"symbol");function Tn(t){return t===null}function Ui(t){return qe(t)==="number"&&!isNaN(t)}function On(t){return qe(t)==="array"}function G(t){if(!Ri(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ri(t){return t&&(typeof t=="object"||t!==null)}function Ni(t){return Y(t.constructor)?t.constructor.name:null}function Di(t){return t instanceof Error||ce(t.message)&&t.constructor&&Ui(t.constructor.stackTraceLimit)}function jn(t,e){if(typeof e!="object"||Tn(e))return!1;if(e instanceof t)return!0;var n=qe(new t(""));if(Di(e))for(;e;){if(qe(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}jn.bind(null,TypeError),jn.bind(null,SyntaxError);function Qe(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?zi(t,e):n}function zi(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function et(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}et(Qe,"form"),et(Qe,"button"),et(Qe,"input"),et(Qe,"select");function Mi(t){return t?On(t)?t:[t]:[]}function Cn(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Zi(){if(J){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Hi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Ki(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=Cn(n[1]),a=Cn(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&&(Wi(r,h.map(function(p){return p.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){return J&&window.location.search.substring(1)}())}function Wi(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 tt(){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 Fi(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 Me="global",Te=ye+"global"+ye,Oe=typeof self===Sn&&self.self===self&&self||typeof global===Sn&&global.global===global&&global||void 0;function ve(t){return Oe[Te][t]}function we(t,e){return Oe[Te][t]=e}function je(t){delete Oe[Te][t]}function Ce(t,e,n){var r;try{if(Ot(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Oe[Te]||(Oe[Te]={});var nt={};function Ot(t){if(typeof nt[t]!==Ge)return nt[t];try{var e=window[t];e.setItem(Ge,Ge),e.removeItem(Ge)}catch{return nt[t]=!1}return nt[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 ue="function",oe="undefined",Ji="@@redux/"+Math.random().toString(36),xn=function(){return typeof Symbol===ue&&Symbol.observable||"@@observable"}(),rt=" != "+ue;function $n(t,e,n){var r;if(typeof e===ue&&typeof n===oe&&(n=e,e=void 0),typeof n!==oe){if(typeof n!==ue)throw new Error("enhancer"+rt);return n($n)(t,e)}if(typeof t!==ue)throw new Error("reducer"+rt);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!==ue)throw new Error("Listener"+rt);var b=!0;return p(),s.push(d),function(){if(b){b=!1,p();var I=s.indexOf(d);s.splice(I,1)}}}function f(d){if(!G(d))throw new Error("Act != obj");if(typeof d.type===oe)throw new Error("ActType "+oe);if(h)throw new Error("Dispatch in reducer");try{h=!0,o=i(o,d)}finally{h=!1}for(var b=a=s,I=0;I<b.length;I++)(0,b[I])();return d}return f({type:"@@redux/INIT"}),(r={dispatch:f,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ue)throw new Error("next reducer"+rt);i=d,f({type:"@@redux/INIT"})}})[xn]=function(){var d,b=c;return(d={subscribe:function(I){if(typeof I!="object")throw new TypeError("Observer != obj");function w(){I.next&&I.next(u())}return w(),{unsubscribe:b(w)}}})[xn]=function(){return this},d},r}function Xi(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+oe}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 Vi(){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 le=ye+"anon_id",be=ye+"user_id",$e=ye+"user_traits",de="userId",Ae="anonymousId",it=["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"],jt=["name","EVENTS","config","loaded"],$=it.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),An=/^utm_/,Ln=/^an_prop_/,Un=/^an_trait_/;function Yi(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===$.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,h=i.initialUser,p=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(le,a.anonymousId),p||e(be,a.userId),h.traits&&e($e,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(b,I){if(I.match(An)||I.match(/^(d|g)clid/)){var w=I.replace(An,"");b.campaign[w==="campaign"?"name":w]=o[I]}return I.match(Ln)&&(b.props[I.replace(Ln,"")]=o[I]),I.match(Un)&&(b.traits[I.replace(Un,"")]=o[I]),b},{campaign:{},props:{},traits:{}});n.dispatch(x({type:$.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:$.campaign,campaign:d.campaign})}}return r(i)}}}}function Gi(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===$.setItemEnd){if(n.key===le)return x({},e,{anonymousId:n.value});if(n.key===be)return x({},e,{userId:n.value})}switch(n.type){case $.identify:return Object.assign({},e,{userId:n.userId,traits:x({},e.traits,n.traits)});case $.reset:return[be,le,$e].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function Rn(t){return{userId:t.getItem(be),anonymousId:t.getItem(le),traits:t.getItem($e)}}var Ct=function(t){return ye+"TEMP"+ye+t};function Bi(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===$.reset&&([be,$e,le].forEach(function(d){r(d)}),[de,Ae,"traits"].forEach(function(d){je(Ct(d))})),s.type===$.identify){i(le)||n(le,tt());var c=i(be),f=i($e)||{};c&&c!==h&&o.dispatch({type:$.userIdChanged,old:{userId:c,traits:f},new:{userId:h,traits:p},options:u}),h&&n(be,h),p&&n($e,x({},f,p))}return a(s)}}}}var Ze={};function Nn(t,e){Ze[t]&&Y(Ze[t])&&(Ze[t](e),delete Ze[t])}function Dn(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 Dn(t,e,n-10).then(r,i)})})}function qi(t){return{abort:t}}function zn(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,b=f.payload.type,I=i[d][b];if(I&&Y(I)){var w,E=function(l,k){return l===void 0&&(l={}),k===void 0&&(k={}),[de,Ae].reduce(function(O,j){return l.hasOwnProperty(j)&&k[j]&&k[j]!==l[j]&&(O[j]=k[j]),O},l)}(f.payload,h),_=r[E.meta.rid];if(!_&&(w=I({payload:E,config:a[d].config,instance:n,abort:qi}))&&G(w)&&w.abort)return void(r[E.meta.rid]=!0);if(!_){var v=b+":"+d;t.dispatch(x({},E,{type:v,_:{called:v,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,f){return!~p.processIndex.indexOf(f)});s.actions=u}}}var xt=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(Le),d=e.exact.map(function(w){return w.pluginName});f&&(d=a.during.map(function(w){return w.pluginName}));var b=function(w,E){return function(_,v,l){var k=v.config,O=v.name,j=O+"."+_.type;l&&(j=l.event);var A=_.type.match(Le)?function(M,Z,W,L,D){return function(H,C){var K=L?L.name:M,F=C&&He(C)?C:W;if(L&&(!(F=C&&He(C)?C:[M]).includes(M)||F.length!==1))throw new Error("Method "+Z+" can only abort "+M+" plugin. "+JSON.stringify(F)+" input valid");return x({},D,{abort:{reason:H,plugins:F,caller:Z,_:K}})}}(O,j,E,l,_):function(M,Z){return function(){throw new Error(M.type+" action not cancellable. Remove abort in "+Z)}}(_,j);return{payload:Qi(_),instance:w,config:k||{},abort:A}}}(r,d),I=e.exact.reduce(function(w,E){var _=E.pluginName,v=E.methodName,l=!1;return v.match(/^initialize/)||v.match(/^reset/)||(l=!p[_].loaded),u.offline&&v.match(/^(page|track|identify)/)&&(l=!0),w[""+_]=l,w},{});return Promise.resolve(e.exact.reduce(function(w,E,_){try{var v=E.pluginName;return Promise.resolve(w).then(function(l){function k(){return Promise.resolve(l)}var O=function(){if(e.namespaced&&e.namespaced[v])return Promise.resolve(e.namespaced[v].reduce(function(j,A,M){try{return Promise.resolve(j).then(function(Z){return A.method&&Y(A.method)?(function(H,C){var K=Xn(H);if(K&&K.name===C){var F=Xn(K.method);throw new Error([C+" plugin is calling method "+H,"Plugins cant call self","Use "+K.method+" "+(F?"or "+F.method:"")+" in "+C+" plugin insteadof "+H].join(`
|
|
6
|
+
`))}}(A.methodName,A.pluginName),Promise.resolve(A.method({payload:Z,instance:r,abort:(W=Z,L=v,D=A.pluginName,function(H,C){return x({},W,{abort:{reason:H,plugins:C||[L],caller:c,from:D||L}})}),config:Hn(A.pluginName,p,o),plugins:p})).then(function(H){var C=G(H)?H:{};return Promise.resolve(x({},Z,C))})):Z;var W,L,D})}catch(Z){return Promise.reject(Z)}},Promise.resolve(n))).then(function(j){l[v]=j});l[v]=n}();return O&&O.then?O.then(k):k()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(w){return Promise.resolve(e.exact.reduce(function(E,_,v){try{var l=e.exact.length===v+1,k=_.pluginName,O=o[k];return Promise.resolve(E).then(function(j){var A=w[k]?w[k]:{};if(f&&(A=j),At(A,k))return $t({data:A,method:c,instance:r,pluginName:k,store:s}),Promise.resolve(j);if(At(j,k))return l&&$t({data:j,method:c,instance:r,store:s}),Promise.resolve(j);if(I.hasOwnProperty(k)&&I[k]===!0)return s.dispatch({type:"queue",plugin:k,payload:A,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(j);var M=b(w[k],o[k]);return Promise.resolve(O[c]({abort:M.abort,payload:A,instance:r,config:Hn(k,p,o),plugins:p})).then(function(Z){var W=G(Z)?Z:{},L=x({},j,W),D=w[k];if(At(D,k))$t({data:D,method:c,instance:r,pluginName:k,store:s});else{var H=c+":"+k;(H.match(/:/g)||[]).length<2&&!c.match(Mn)&&!c.match(Zn)&&r.dispatch(x({},f?L:A,{type:H,_:{called:H,from:"submethod"}}))}return Promise.resolve(L)})})}catch(j){return Promise.reject(j)}},Promise.resolve(n))).then(function(E){if(!(c.match(Le)||c.match(/^registerPlugin/)||c.match(Zn)||c.match(Mn)||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"}});Fn(E,e.exact.length)&&!c.match(/End$/)&&(_=x({},_,{type:E.type+"Aborted"})),s.dispatch(_)}return E})})}catch(w){return Promise.reject(w)}},Le=/Start$/,Mn=/^bootstrap/,Zn=/^ready/;function $t(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(x({},t.data,{type:n,_:{called:n,from:"abort"}}))}function Hn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function Kn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function Wn(t,e){var n=t.replace(Le,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function At(t,e){var n=t.abort;return!!n&&(n===!0||Jn(n,e)||n&&Jn(n.plugins,e))}function Fn(t,e){var n=t.abort;if(!n)return!1;if(n===!0||ce(n))return!0;var r=n.plugins;return He(n)&&n.length===e||He(r)&&r.length===e}function He(t){return Array.isArray(t)}function Jn(t,e){return!(!t||!He(t))&&t.includes(e)}function Xn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Qi(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=G(t[n])?Object.assign({},t[n]):t[n]),e},{})}function eo(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===$.enablePlugin&&i.dispatch({type:$.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),p===$.disablePlugin&&setTimeout(function(){return Nn(a.meta.rid,{payload:a})},0),p===$.initializeEnd){var f=e(),d=Object.keys(f),b=d.filter(function(l){return u.includes(l)}).map(function(l){return f[l]}),I=[],w=[],E=a.disabled,_=b.map(function(l){var k=l.loaded,O=l.name,j=l.config;return Dn(l,function(){return k({config:j})},1e4).then(function(A){return r[O]||(i.dispatch({type:$.pluginReadyType(O),name:O,events:Object.keys(l).filter(function(M){return!jt.includes(M)})}),r[O]=!0),I=I.concat(O),l}).catch(function(A){if(A instanceof Error)throw new Error(A);return w=w.concat(A.name),A})});Promise.all(_).then(function(l){var k={plugins:I,failed:w,disabled:E};setTimeout(function(){d.length===_.length+E.length&&i.dispatch(x({},{type:$.ready},k))},0)})}var v=function(){if(p!==$.bootstrap)return/^ready:([^:]*)$/.test(p)&&setTimeout(function(){return zn(i,e,t)},0),Promise.resolve(function(l,k,O,j,A){try{var M=Y(k)?k():k,Z=l.type,W=Z.replace(Le,"");if(l._&&l._.called)return Promise.resolve(l);var L=O.getState(),D=(K=M,(F=L.plugins)===void 0&&(F={}),(Ie=l.options)===void 0&&(Ie={}),Object.keys(K).filter(function(m){var g=Ie.plugins||{};return Li(g[m])?g[m]:g.all!==!1&&(!F[m]||F[m].enabled!==!1)}).map(function(m){return K[m]}));Z===$.initializeStart&&l.fromEnable&&(D=Object.keys(L.plugins).filter(function(m){var g=L.plugins[m];return l.plugins.includes(m)&&!g.initialized}).map(function(m){return M[m]}));var H=D.map(function(m){return m.name}),C=function(m,g,T){var U=Wn(m).map(function(R){return Kn(R,g)});return g.reduce(function(R,y){var S=y.name,P=Wn(m,S).map(function(Xe){return Kn(Xe,g)}),z=P[0],N=P[1],B=P[2];return z.length&&(R.beforeNS[S]=z),N.length&&(R.duringNS[S]=N),B.length&&(R.afterNS[S]=B),R},{before:U[0],beforeNS:{},during:U[1],duringNS:{},after:U[2],afterNS:{}})}(Z,D);return Promise.resolve(xt({action:l,data:{exact:C.before,namespaced:C.beforeNS},state:L,allPlugins:M,allMatches:C,instance:O,store:j,EVENTS:A})).then(function(m){function g(){var R=function(){if(Z.match(Le))return Promise.resolve(xt({action:x({},T,{type:W+"End"}),data:{exact:C.after,namespaced:C.afterNS},state:L,allPlugins:M,allMatches:C,instance:O,store:j,EVENTS:A})).then(function(y){y.meta&&y.meta.hasCallback&&Nn(y.meta.rid,{payload:y})})}();return R&&R.then?R.then(function(){return m}):m}if(Fn(m,H.length))return m;var T,U=function(){if(Z!==W)return Promise.resolve(xt({action:x({},m,{type:W}),data:{exact:C.during,namespaced:C.duringNS},state:L,allPlugins:M,allMatches:C,instance:O,store:j,EVENTS:A})).then(function(R){T=R});T=m}();return U&&U.then?U.then(g):g()})}catch(m){return Promise.reject(m)}var K,F,Ie}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(v&&v.then?v.then(h):h(v))}catch(l){return Promise.reject(l)}}}}}function to(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===$.setItem||i===$.removeItem){if(r.abort)return n(r);i===$.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var no=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 ro(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=Vn(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=Vn(n.type,$.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 $.disablePlugin:return x({},e,Yn(n.plugins,!1,e));case $.enablePlugin:return x({},e,Yn(n.plugins,!0,e));default:return e}}}function Vn(t,e){return t.substring(e.length+1,t.length)}function Yn(t,e,n){return t.reduce(function(r,i){return r[i]=x({},n[i],{enabled:e}),r},n)}function Gn(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var io={last:{},history:[]};function oo(t,e){t===void 0&&(t=io);var n=e.options,r=e.meta;if(e.type===$.track){var i=Gn(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 ao={actions:[]};function so(t,e){t===void 0&&(t=ao);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===$.identify?[e].concat(t.actions):t.actions.concat(e),x({},t,{actions:r});case"dequeue":return[];default:return t}}var Bn=/#.*$/;function co(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(Bn,""):"")}var qn,Qn,er,tr,uo=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 b,I=document.getElementsByTagName("link"),w=0;b=I[w];w++)if(b.getAttribute("rel")==="canonical")return b.getAttribute("href")}}();return d?d.match(/\?/)?d:d+f:window.location.href.replace(Bn,"")}(p),c={title:n,url:u,path:co(u),hash:h,search:p,width:a,height:s};return r&&r!==""&&(c.referrer=r),x({},c,t)},lo={last:{},history:[]};function ho(t,e){t===void 0&&(t=lo);var n=e.options;if(e.type===$.page){var r=Gn(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}qn=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"}(),Qn=J?document.referrer:null,er=Zi(),tr=Hi();var nr={initialized:!1,sessionId:tt(),app:null,version:null,debug:!1,offline:!!J&&!navigator.onLine,os:{name:qn},userAgent:J?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.13"},timezone:tr,locale:er,campaign:{},referrer:Qn};function fo(t,e){t===void 0&&(t=nr);var n=t.initialized,r=e.campaign;switch(e.type){case $.campaign:return x({},t,{campaign:r});case $.offline:return x({},t,{offline:!0});case $.online:return x({},t,{offline:!1});default:return n?t:x({},nr,t,{initialized:!0})}}var po=["plugins","reducers","storage"];function mo(t,e,n){if(J){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function go(t){var e=mo.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function rr(){return we("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 Oe[Te].analytics.push(a.action||a),o(a)}})}}}function ir(t){return function(){return xe(xe.apply(null,arguments),rr())}}function Lt(t){return t?On(t)?t:[t]:[]}function or(t,e,n){t===void 0&&(t={});var r,i,o=tt();return e&&(Ze[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 yo(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(y){return g.EVENTS[y]}):[];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(y,S){var P;return y[S]=(P=g.methods[S],function(){for(var z=Array.prototype.slice.call(arguments),N=new Array(P.length),B=0;B<z.length;B++)N[B]=z[B];return N[N.length]=k,P.apply({instance:k},N)}),y},{}),delete g.methods);var U=Object.keys(g).concat(T),R=new Set(m.events.concat(U));if(m.events=Array.from(R),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:ve,setItem:we,removeItem:je},o=function(m){return function(g,T,U){return T.getState("user")[g]||(U&&G(U)&&U[g]?U[g]:Rn(m)[g]||ve(Ct(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!jt.includes(m)}).sort(),h=new Set(s.concat(it).filter(function(m){return!jt.includes(m)})),p=Array.from(h).sort(),u=function(){return a},c=new no,f=c.addMiddleware,d=c.removeMiddleware,b=c.dynamicMiddlewares,I=function(){throw new Error("Abort disabled inListener")},w=Ki(),E=Rn(i),_=x({},E,n,w.an_uid?{userId:w.an_uid}:{},w.an_aid?{anonymousId:w.an_aid}:{});_.anonymousId||(_.anonymousId=tt());var v=x({enable:function(m,g){return new Promise(function(T){C.dispatch({type:$.enablePlugin,plugins:Lt(m),_:{originalAction:$.enablePlugin}},T,[g])})},disable:function(m,g){return new Promise(function(T){C.dispatch({type:$.disablePlugin,plugins:Lt(m),_:{originalAction:$.disablePlugin}},T,[g])})}},r.methods),l=!1,k={identify:function(m,g,T,U){try{var R=ce(m)?m:null,y=G(m)?m:g,S=T||{},P=k.user();we(Ct(de),R);var z=R||y.userId||o(de,k,y);return Promise.resolve(new Promise(function(N){C.dispatch(x({type:$.identifyStart,userId:z,traits:y||{},options:S,anonymousId:P.anonymousId},P.id&&P.id!==R&&{previousId:P.id}),N,[g,T,U])}))}catch(N){return Promise.reject(N)}},track:function(m,g,T,U){try{var R=G(m)?m.event:m;if(!R||!ce(R))throw new Error("EventMissing");var y=G(m)?m:g||{},S=G(T)?T:{};return Promise.resolve(new Promise(function(P){C.dispatch({type:$.trackStart,event:R,properties:y,options:S,userId:o(de,k,g),anonymousId:o(Ae,k,g)},P,[g,T,U])}))}catch(P){return Promise.reject(P)}},page:function(m,g,T){try{var U=G(m)?m:{},R=G(g)?g:{};return Promise.resolve(new Promise(function(y){C.dispatch({type:$.pageStart,properties:uo(U),options:R,userId:o(de,k,U),anonymousId:o(Ae,k,U)},y,[m,g,T])}))}catch(y){return Promise.reject(y)}},user:function(m){if(m===de||m==="id")return o(de,k);if(m===Ae||m==="anonId")return o(Ae,k);var g=k.getState("user");return m?In(g,m):g},reset:function(m){return new Promise(function(g){C.dispatch({type:$.resetStart},g,m)})},ready:function(m){return l&&m({plugins:v,instance:k}),k.on($.ready,function(g){m(g),l=!0})},on:function(m,g){if(!m||!Y(g))return!1;if(m===$.bootstrap)throw new Error(".on disabled for "+m);var T=/Start$|Start:/;if(m==="*"){var U=function(P){return function(z){return function(N){return N.type.match(T)&&g({payload:N,instance:k,plugins:a}),z(N)}}},R=function(P){return function(z){return function(N){return N.type.match(T)||g({payload:N,instance:k,plugins:a}),z(N)}}};return f(U,ot),f(R,at),function(){d(U,ot),d(R,at)}}var y=m.match(T)?ot:at,S=function(P){return function(z){return function(N){return N.type===m&&g({payload:N,instance:k,plugins:a,abort:I}),z(N)}}};return f(S,y),function(){return d(S,y)}},once:function(m,g){if(!m||!Y(g))return!1;if(m===$.bootstrap)throw new Error(".once disabled for "+m);var T=k.on(m,function(U){g({payload:U.payload,instance:k,plugins:a,abort:I}),T()});return T},getState:function(m){var g=C.getState();return m?In(g,m):Object.assign({},g)},dispatch:function(m){var g=ce(m)?{type:m}:m;if(it.includes(g.type))throw new Error("reserved action "+g.type);var T=x({},g,{_:x({originalAction:g.type},m._||{})});C.dispatch(T)},enablePlugin:v.enable,disablePlugin:v.disable,plugins:v,storage:{getItem:i.getItem,setItem:function(m,g,T){C.dispatch({type:$.setItemStart,key:m,value:g,options:T})},removeItem:function(m,g){C.dispatch({type:$.removeItemStart,key:m,options:g})}},setAnonymousId:function(m,g){k.storage.setItem(le,m,g)},events:{core:it,plugins:s}},O=r.middlewares.concat([function(m){return function(g){return function(T){return T.meta||(T.meta=or()),g(T)}}},b(ot),eo(k,u,{all:p,plugins:s}),to(i),Yi(k),Bi(k),b(at)]),j={context:fo,user:Gi(i),page:ho,track:oo,plugins:ro(u),queue:so},A=xe,M=xe;if(J&&t.debug){var Z=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;Z&&(A=Z({trace:!0,traceLimit:25})),M=function(){return arguments.length===0?rr():G(typeof arguments[0])?ir():ir().apply(null,arguments)}}var W,L=function(m){return Object.keys(m).reduce(function(g,T){return po.includes(T)||(g[T]=m[T]),g},{})}(t),D=r.pluginsArray.reduce(function(m,g){var T=g.name,U=g.config,R=g.loaded,y=r.pluginEnabled[T];return m[T]={enabled:y,initialized:!!y&&!g.initialize,loaded:!!R({config:U}),config:U},m},{}),H={context:L,user:_,plugins:D},C=$n(function(m){for(var g=Object.keys(m),T={},U=0;U<g.length;U++){var R=g[U];typeof m[R]===ue&&(T[R]=m[R])}var y,S=Object.keys(T);try{(function(P){Object.keys(P).forEach(function(z){var N=P[z];if(typeof N(void 0,{type:"@@redux/INIT"})===oe||typeof N(void 0,{type:Ji})===oe)throw new Error("reducer "+z+" "+oe)})})(T)}catch(P){y=P}return function(P,z){if(P===void 0&&(P={}),y)throw y;for(var N=!1,B={},Xe=0;Xe<S.length;Xe++){var ft=S[Xe],Lr=P[ft],Ft=(0,T[ft])(Lr,z);if(typeof Ft===oe){var aa=Xi(ft,z);throw new Error(aa)}B[ft]=Ft,N=N||Ft!==Lr}return N?B:P}}(x({},j,e)),H,M(A(Vi.apply(void 0,O))));C.dispatch=(W=C.dispatch,function(m,g,T){var U=x({},m,{meta:or(m.meta,g,Lt(T))});return W.apply(null,[U])});var K=Object.keys(a);C.dispatch({type:$.bootstrap,plugins:K,config:L,params:w,user:_,initialUser:n,persistedUser:E});var F=K.filter(function(m){return r.pluginEnabled[m]}),Ie=K.filter(function(m){return!r.pluginEnabled[m]});return C.dispatch({type:$.registerPlugins,plugins:K,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,g){var T=m.bootstrap,U=m.config,R=m.name;T&&Y(T)&&T({instance:k,config:U,payload:m}),C.dispatch({type:$.registerPluginType(R),name:R,enabled:r.pluginEnabled[R],plugin:m}),r.pluginsArray.length===g+1&&C.dispatch({type:$.initializeStart,plugins:F,disabled:Ie})}),go(function(m){C.dispatch({type:m?$.offline:$.online})}),function(m,g,T){setInterval(function(){return zn(m,g,T)},3e3)}(C,u,k),k}var ot="before",at="after",Ke="cookie",ke=cr(),ar=st,vo=st;function sr(t){return ke?st(t,"",-1):je(t)}function cr(){if(ke!==void 0)return ke;var t="cookiecookie";try{st(t,t),ke=document.cookie.indexOf(t)!==-1,sr(t)}catch{ke=!1}return ke}function st(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return ke===!1&&(a?we(t,e):ve(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 We="localStorage",wo=Ot.bind(null,"localStorage");Ce("localStorage","getItem",ve),Ce("localStorage","setItem",we),Ce("localStorage","removeItem",je);var Fe="sessionStorage",bo=Ot.bind(null,"sessionStorage");Ce("sessionStorage","getItem",ve),Ce("sessionStorage","setItem",we),Ce("sessionStorage","removeItem",je);function Ue(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(G(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var ko=wo(),Io=bo(),So=cr();function ur(t,e){if(t){var n=Ut(e),r=!zt(n),i=Rt(n)?Ue(localStorage.getItem(t)):void 0;if(r&&!Pe(i))return i;var o=Nt(n)?Ue(ar(t)):void 0;if(r&&o)return o;var a=Dt(n)?Ue(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=ve(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function _o(t,e,n){if(t&&!Pe(e)){var r={},i=Ut(n),o=JSON.stringify(e),a=!zt(i);return Rt(i)&&(r[We]=ut(We,e,Ue(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[We]:Nt(i)&&(r[Ke]=ut(Ke,e,Ue(ar(t))),vo(t,o),a)?r[Ke]:Dt(i)&&(r[Fe]=ut(Fe,e,Ue(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Fe]:(r[Me]=ut(Me,e,ve(t)),we(t,e),a?r[Me]:r)}}function Eo(t,e){if(t){var n=Ut(e),r=ur(t,En),i={};return!Pe(r.localStorage)&&Rt(n)&&(localStorage.removeItem(t),i[We]=r.localStorage),!Pe(r.cookie)&&Nt(n)&&(sr(t),i[Ke]=r.cookie),!Pe(r.sessionStorage)&&Dt(n)&&(sessionStorage.removeItem(t),i[Fe]=r.sessionStorage),!Pe(r.global)&&ct(n,Me)&&(je(t),i[Me]=r.global),i}}function Ut(t){return t?ce(t)?t:t.storage:_n}function Rt(t){return ko&&ct(t,We)}function Nt(t){return So&&ct(t,Ke)}function Dt(t){return Io&&ct(t,Fe)}function zt(t){return t===En||t==="all"}function ct(t,e){return t===_n||t===e||zt(t)}function ut(t,e,n){return{location:t,current:e,previous:n}}var Po={setItem:_o,getItem:ur,removeItem:Eo};function To(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lr(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 dr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?lr(Object(n),!0).forEach(function(r){To(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):lr(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Oo(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:Po};return yo(dr(dr({},e),t))}function jo(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 Co(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=$o(p);return i!==u&&(i=u,setTimeout(()=>t(p),0)),s.apply(n,h)}})}function xo(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function $o(t){return["#","?"].forEach(e=>t=xo(t,e)),t}function Ao(){Co(()=>{ae.page()})}function Lo(t){if(t===void 0&&(t={}),!J)return Tt;var e=fr(),n=Mt(),r=hr(),i=lt(r,e),o=lt(n,e),a=[],s=[],h=[],p=r,u=i,c=o,f=Object.keys(t);if(!f.length)return Tt;var d=f.map(function(I){return Number(I)}),b=Fi(function(){var I=fr(),w=function(L,D){return D.map(function(H){return H===100?L-5:L*(H/100)})}(I,d),E=Mt(),_=hr(),v=lt(_,I),l=lt(E,I);if(u=v>u?v:u,c=l<c?l:c,!(a.length>=d.length)){var k=p===_,O="up";k?O="initial":p<=_&&(O="down");var j=w,A=d;(O==="up"||k)&&(j=w.slice().reverse(),A=d.slice().reverse());var M=A.reduce(function(L,D,H){var C=j[H];return h.includes(D)&&_<=C&&(h=h.filter(function(K){return K!==D}),L.singleFunction=D),O==="down"&&!a.includes(D)&&_>=C&&D>o?(s.push(D),L.callbacks=L.callbacks.concat(D),L):O==="up"&&!a.includes(D)&&_<=C&&D<=v?(L.foundFunc=[D],L):(k&&_>=C&&L.foundFunc.length===0&&(L.foundFunc=[D]),!s.includes(D)&&_>=C&&(s.push(D),L.singleFunction?h.push(D):L.singleFunction=D),L)},{foundFunc:[],singleFunction:null,callbacks:[],direction:O});if(p=_,O==="down"&&M.callbacks&&M.callbacks.forEach(function(L){Y(t[L])&&(t[L]({trigger:L,direction:O,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(L))}),M.singleFunction){var Z=M.singleFunction,W=M.direction;Y(t[Z])&&t[Z]({trigger:Z,direction:W,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(Z)}}},500);return window.addEventListener("scroll",b),function(){return window.removeEventListener("scroll",b)}}function Mt(){return J?document.body.scrollTop||document.documentElement.scrollTop:0}function Uo(){return J?window.innerHeight||document.documentElement.clientHeight:0}function hr(){return Math.round(Mt()+Uo())}function fr(){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 lt(t,e){return Math.round(t/e*100)}var pr="EventListener";function Ro(t){return function(e,n,r,i){var o=r||Tt,a=i||!1;if(!J)return o;var s=dt(n),h=dt(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"+pr:"remove"+pr,d=0;d<h.length;d++){var b=h[d];p[d]=c?a&&a.once?No(o):o:p[d]||o;for(var I=0;I<s.length;I++)b[f]?b["on"+s[I]]=c?p[d]:null:b[f](s[I],p[d],a)}return u.bind(null,!c)}(t)}}function dt(t,e){if(ce(t))return e?dt(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=Mi(t);return e?o.map(function(a){return ce(a)?dt(a,!0):a}).flat():o}function No(t,e){var n;return function(){return t&&(n=t.apply(this,arguments),t=null),n}}var Zt=Ro("Event");function mr(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}mr.bind(null,"onerror"),mr.bind(null,"onload");var gr=typeof window>"u",yr="hidden";function Do(t){if(gr)return!1;var e=zo(),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 zo(){var t=["webkit","moz","ms","o"];return gr||yr in document?yr:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var Mo=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Zo(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=Do(function(s){s||n({type:"tabVisible"})});return r=[a].concat(Mo.map(function(s){return Zt(document,s,n)})).concat(Zt(window,"load",n)).concat(Zt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Ho(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 b(w){d(),o&&!u&&o(Je(f),w),i&&u&&(u=!1,i(Je(n),w),f=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(Je(f),w))},s)}var I=Zo(b,{throttle:p});return{disable:function(){c=!0,u=!1,d();var w=I();return function(){return c=!1,f=new Date,b({type:"load"}),w()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:Je(f,c),idle:u?Je(n,c):0}}}}function Je(t,e){return e?0:Math.round((new Date-t)/1e3)}const vr=5e3;class Ko{constructor(e){ee(this,"element");ee(this,"isInViewport",!1);ee(this,"isAwake",!1);ee(this,"isFlushing");ee(this,"observer");ee(this,"lastEventAt",Date.now());ee(this,"registeredView",!1);ee(this,"viewCallback");ee(this,"activeDurationCallback");ee(this,"idleDurationCallback");ee(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),Ho({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:vr}),Lo({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*vr: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 wr="sesamy_session_id";function Wo(){let t=sessionStorage.getItem(wr);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(wr,t)),t}let br=!1,Ht,kr,ht;function Fo({clientId:t,enabled:e=!0,environment:n}){if(Ht=t,kr=e,ht=`${se("logs",n)}/events`,!kr)return;Ao();const r=new Ko({element:document.body,viewCallback:()=>{ae.page()},activeDurationCallback:(i,o,a)=>{ae.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{ae.track("idleDuration",{duration:i,durationStart:a,flushing:o})},scrollCallback:i=>{ae.track("scroll",{scroll:i.scrollMax})}});Vo(document.body,()=>{r.flush()}),Yo(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(te.AUTHENTICATED,async i=>{const o=i;await ae.identify(o.detail.sub)}),window.addEventListener(te.LOGOUT,async()=>{await ae.track("logout",{}),Kt.flush(),await ae.reset()})}function Ir(t){return JSON.stringify(t.map(e=>({...e,clientId:Ht,requestId:Math.random().toString(36).slice(2,9),sessionId:Wo(),timestamp:new Date().toISOString(),version:Pt,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:kn,userAgent:navigator.userAgent,clientId:Ht}})))}const Kt=jo(async t=>{if(t.length>0){const e=Ir(t);br?navigator.sendBeacon(ht,e):(await fetch(ht,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function Wt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(ht,Ir([n]))}else Kt.push(t)}const ae=Oo({app:kn,version:Pt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Wt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Wt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;Wt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Jo(t,e){ae.track(t,e)}function Xo(){return br=!0,Kt.flush()}const Sr=new Map;function Vo(t,e){Sr.set(t,e)}window.addEventListener("beforeunload",()=>{Sr.forEach((t,e)=>{t.bind(e)()}),Xo()});const _r=new Map;function Yo(t,e){_r.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&_r.forEach((t,e)=>{t.bind(e)()})});const Er="sesamySignedURLs";function Pr(){const t=sessionStorage.getItem(Er);return t?JSON.parse(t):[]}function Go(t){const e=Pr();e.push(t),sessionStorage.setItem(Er,JSON.stringify(e))}function Bo(t){const{createCheckout:e,getCheckout:n,updateCheckout:r,getEntitlement:i,getEntitlements:o,getEntitlementAccess:a,getSubscriptions:s,getContract:h,getContracts:p,getBill:u,getBills:c,getProfile:f,updateProfile:d,getTags:b,deleteTag:I,setTag:w,getUserMetadata:E,listUserMetadata:_,setUserMetadata:v,deleteUserMetadata:l,getTally:k,getTallies:O,pushTally:j,deleteTally:A,getProduct:M,getPaymentIssues:Z,isSpotifyLinked:W,unlinkSpotify:L,linkSpotify:D,autoOnboardProduct:H,openHostedAccountPage:C,generateLink:K}=Ci(t),F={auth:{getUser:f,isAuthenticated:_t,loginWithRedirect:Et,logout:yi,setToken:hn},checkouts:{get:n,create:e,update:r},profile:{get:f,update:d,openHostedAccountPage:C,isSpotifyLinked:W,unlinkSpotify:L},analytics:{track:Jo},tags:{list:b,set:w,delete:I},entitlements:{get:i,list:o,access:a,signedLinks:Pr},contracts:{get:h,list:p},bills:{get:u,list:c},userMetadata:{get:E,list:_,set:v,delete:l},tallies:{get:k,list:O,push:j,delete:A},subscriptions:{list:s},products:{get:M,autoOnboard:H,linkSpotify:D},getVersion:qo,getPaymentIssues:Z,generateLink:K,clearCache:ne};return t.namespace&&(window[t.namespace]=F),F}function qo(){return Pt}async function Qo({enabled:t=!1,rules:e}){if(!t)return;const n=await _t(),r=window.location.href;for(const i of e){const o=document.querySelectorAll(i.selector);if(!(i.path&&!new RegExp(i.path).test(r))){for(const a of o)if(!(i.authenticated!==void 0&&i.authenticated!==n))switch(i.transform){case"insert":if(i.contentType==="selector"&&i.content){const s=document.querySelector(i.content);s?a.innerHTML+=s.innerHTML:console.warn(`Source element for selector '${i.content}' not found`)}else if(i.contentType==="url"&&i.content){const s=await Tr(i.content);s?a.innerHTML+=s:console.warn(`Failed to fetch content from URL '${i.content}'`)}else i.content&&(a.innerHTML+=i.content);break;case"replace":if(i.contentType==="selector"&&i.content){const s=document.querySelector(i.content);s?a.innerHTML=s.innerHTML:console.warn(`Source element for selector '${i.content}' not found`)}else if(i.contentType==="url"&&i.content){const s=await Tr(i.content);s?a.innerHTML=s:console.warn(`Failed to fetch content from URL '${i.content}'`)}else i.content&&(a.innerHTML=i.content);break;case"remove":a.remove();break;default:console.warn(`Unknown transform type: ${i.transform}`)}}}}async function Tr(t){try{const e=await fetch(t);return e.ok?await e.text():(console.error(`Failed to fetch content from ${t}: ${e.statusText}`),null)}catch(e){return console.error(`Error fetching content from ${t}:`,e),null}}function ea(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token");if(e){hn(e);const n=new URL(window.location.href);t.delete("access_token"),n.hash=t.toString(),window.history.replaceState(null,"",n)}}const Or="sesamy-refresh",jr="force-refetch-entitlements";function ta(){const t=new URLSearchParams(window.location.search),e=t.get(jr),n=t.get(Or);if(e!==null||n!==null){const r=new URL(window.location.href);t.delete(jr),t.delete(Or),r.search=t.toString(),ne(),window.history.replaceState(null,"",r)}}function na(){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;Go({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 Cr="sesamy-user";async function ra(){const e=new URLSearchParams(window.location.search).get(Cr);if(!e)return;const n=await gi();(n==null?void 0:n.email)!==e&&(ne(),Et({authorizationParams:{email_hint:e,login_hint:e}}));const r=new URL(window.location.href);r.searchParams.delete(Cr),window.history.replaceState(null,"",r)}const xr="sesamy-purchase";function ia(){const t=new URLSearchParams(window.location.search),e=t.get(xr);if(e!==null){const n=new URL(window.location.href);t.delete(xr),n.search=t.toString(),X(te.PURCHASE,{itemSrc:e}),ne(),window.history.replaceState(null,"",n)}}const $r="sesamy-login";async function oa(){if(!new URLSearchParams(window.location.search).get($r))return;await _t()||Et();const r=new URL(window.location.href);r.searchParams.delete($r),window.history.replaceState(null,"",r)}async function Ar(t){Fo({clientId:t.clientId,environment:t.environment,...t.analytics}),await mi({clientId:t.clientId,organization:t.organization,environment:t.environment,...t.auth}),t.transform&&await Qo(t.transform);const e=Bo({clientId:t.clientId,environment:t.environment,...t.api});return X(te.READY,{}),ea(),ta(),na(),await oa(),await ra(),ia(),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)}}return re.init=Ar,Object.defineProperty(re,Symbol.toStringTag,{value:"Module"}),re}({});
|