@sesamy/sesamy-js 1.0.3 → 1.0.4
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 +7 -0
- package/dist/sesamy-js.es.js +1423 -1095
- package/dist/sesamy-js.umd.js +12 -6
- package/package.json +3 -2
package/dist/sesamy-js.umd.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
(function(B){typeof define=="function"&&define.amd?define(B):B()})(function(){"use strict";var qi=Object.defineProperty;var Qi=(B,R,V)=>R in B?qi(B,R,{enumerable:!0,configurable:!0,writable:!0,value:V}):B[R]=V;var Q=(B,R,V)=>(Qi(B,typeof R!="symbol"?R+"":R,V),V);function B(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0});dispatchEvent(n)}function R(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 V=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ot(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function at(t,e){return t(e={exports:{}},e.exports),e.exports}var se=at(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function r(){var i=this;this.locked=new Map,this.addToLocked=function(o,a){var s=i.locked.get(o);s===void 0?a===void 0?i.locked.set(o,[]):i.locked.set(o,[a]):a!==void 0&&(s.unshift(a),i.locked.set(o,s))},this.isLocked=function(o){return i.locked.has(o)},this.lock=function(o){return new Promise(function(a,s){i.isLocked(o)?i.addToLocked(o,a):(i.addToLocked(o),a())})},this.unlock=function(o){var a=i.locked.get(o);if(a!==void 0&&a.length!==0){var s=a.pop();i.locked.set(o,a),s!==void 0&&setTimeout(s,0)}else i.locked.delete(o)}}return r.getInstance=function(){return r.instance===void 0&&(r.instance=new r),r.instance},r}();e.default=function(){return n.getInstance()}});ot(se);var nr=ot(at(function(t,e){var n=V&&V.__awaiter||function(u,c,d,h){return new(d||(d=Promise))(function(v,w){function y(I){try{_(h.next(I))}catch(g){w(g)}}function k(I){try{_(h.throw(I))}catch(g){w(g)}}function _(I){I.done?v(I.value):new d(function(g){g(I.value)}).then(y,k)}_((h=h.apply(u,c||[])).next())})},r=V&&V.__generator||function(u,c){var d,h,v,w,y={label:0,sent:function(){if(1&v[0])throw v[1];return v[1]},trys:[],ops:[]};return w={next:k(0),throw:k(1),return:k(2)},typeof Symbol=="function"&&(w[Symbol.iterator]=function(){return this}),w;function k(_){return function(I){return function(g){if(d)throw new TypeError("Generator is already executing.");for(;y;)try{if(d=1,h&&(v=2&g[0]?h.return:g[0]?h.throw||((v=h.return)&&v.call(h),0):h.next)&&!(v=v.call(h,g[1])).done)return v;switch(h=0,v&&(g=[2&g[0],v.value]),g[0]){case 0:case 1:v=g;break;case 4:return y.label++,{value:g[1],done:!1};case 5:y.label++,h=g[1],g=[0];continue;case 7:g=y.ops.pop(),y.trys.pop();continue;default:if(v=y.trys,!((v=v.length>0&&v[v.length-1])||g[0]!==6&&g[0]!==2)){y=0;continue}if(g[0]===3&&(!v||g[1]>v[0]&&g[1]<v[3])){y.label=g[1];break}if(g[0]===6&&y.label<v[1]){y.label=v[1],v=g;break}if(v&&y.label<v[2]){y.label=v[2],y.ops.push(g);break}v[2]&&y.ops.pop(),y.trys.pop();continue}g=c.call(u,y)}catch(b){g=[6,b],h=0}finally{d=v=0}if(5&g[0])throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}([_,I])}}},i=V;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(d){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 f(u){for(var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",d="",h=0;h<u;h++)d+=c[Math.floor(Math.random()*c.length)];return d}var m=function(){function u(c){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+f(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,d){return d===void 0&&(d=5e3),n(this,void 0,void 0,function(){var h,v,w,y,k,_,I;return r(this,function(g){switch(g.label){case 0:h=Date.now()+f(4),v=Date.now()+d,w=o+"-"+c,y=this.storageHandler===void 0?a:this.storageHandler,g.label=1;case 1:return Date.now()<v?[4,s(30)]:[3,8];case 2:return g.sent(),y.getItemSync(w)!==null?[3,5]:(k=this.id+"-"+c+"-"+h,[4,s(Math.floor(25*Math.random()))]);case 3:return g.sent(),y.setItemSync(w,JSON.stringify({id:this.id,iat:h,timeoutKey:k,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return g.sent(),(_=y.getItemSync(w))!==null&&(I=JSON.parse(_)).id===this.id&&I.iat===h?(this.acquiredIatSet.add(h),this.refreshLockWhileAcquired(w,h),[2,!0]):[3,7];case 5:return u.lockCorrector(this.storageHandler===void 0?a:this.storageHandler),[4,this.waitForSomethingToChange(v)];case 6:g.sent(),g.label=7;case 7:return h=Date.now()+f(4),[3,1];case 8:return[2,!1]}})})},u.prototype.refreshLockWhileAcquired=function(c,d){return n(this,void 0,void 0,function(){var h=this;return r(this,function(v){return setTimeout(function(){return n(h,void 0,void 0,function(){var w,y,k;return r(this,function(_){switch(_.label){case 0:return[4,se.default().lock(d)];case 1:return _.sent(),this.acquiredIatSet.has(d)?(w=this.storageHandler===void 0?a:this.storageHandler,(y=w.getItemSync(c))===null?(se.default().unlock(d),[2]):((k=JSON.parse(y)).timeRefreshed=Date.now(),w.setItemSync(c,JSON.stringify(k)),se.default().unlock(d),this.refreshLockWhileAcquired(c,d),[2])):(se.default().unlock(d),[2])}})})},1e3),[2]})})},u.prototype.waitForSomethingToChange=function(c){return n(this,void 0,void 0,function(){return r(this,function(d){switch(d.label){case 0:return[4,new Promise(function(h){var v=!1,w=Date.now(),y=!1;function k(){if(y||(window.removeEventListener("storage",k),u.removeFromWaiting(k),clearTimeout(_),y=!0),!v){v=!0;var I=50-(Date.now()-w);I>0?setTimeout(h,I):h(null)}}window.addEventListener("storage",k),u.addToWaiting(k);var _=setTimeout(k,Math.max(0,c-Date.now()))})];case 1:return d.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(d){return d!==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(d){switch(d.label){case 0:return[4,this.releaseLock__private__(c)];case 1:return[2,d.sent()]}})})},u.prototype.releaseLock__private__=function(c){return n(this,void 0,void 0,function(){var d,h,v,w;return r(this,function(y){switch(y.label){case 0:return d=this.storageHandler===void 0?a:this.storageHandler,h=o+"-"+c,(v=d.getItemSync(h))===null?[2]:(w=JSON.parse(v)).id!==this.id?[3,2]:[4,se.default().lock(w.iat)];case 1:y.sent(),this.acquiredIatSet.delete(w.iat),d.removeItemSync(h),se.default().unlock(w.iat),u.notifyWaiters(),y.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var d=Date.now()-5e3,h=c,v=[],w=0;;){var y=h.keySync(w);if(y===null)break;v.push(y),w++}for(var k=!1,_=0;_<v.length;_++){var I=v[_];if(I.includes(o)){var g=h.getItemSync(I);if(g!==null){var b=JSON.parse(g);(b.timeRefreshed===void 0&&b.timeAcquired<d||b.timeRefreshed!==void 0&&b.timeRefreshed<d)&&(h.removeItemSync(I),k=!0)}}}k&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=m}));const rr={timeoutInSeconds:60},$t={name:"auth0-spa-js",version:"2.1.3"},zt=()=>Date.now();let F=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)}},ir=class Gn extends F{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,Gn.prototype)}},st=class Bn extends F{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,Bn.prototype)}},or=class qn extends st{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,qn.prototype)}},ar=class Qn extends F{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,Qn.prototype)}},sr=class er extends F{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,er.prototype)}},Nt=class tr extends F{constructor(e,n){super("missing_refresh_token",`Missing Refresh Token (audience: '${Lt(e,["default"])}', scope: '${Lt(n)}')`),this.audience=e,this.scope=n,Object.setPrototypeOf(this,tr.prototype)}};function Lt(t,e=[]){return t&&!e.includes(t)?t:""}const Ze=()=>window.crypto,ct=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Ze().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},At=t=>btoa(t),ut=t=>{var{clientId:e}=t,n=R(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()},Dt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),cr=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},ur=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([cr(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},lr=async(t,e,n,r,i,o,a)=>{return s={auth:{audience:e,scope:n},timeout:i,fetchUrl:t,fetchOptions:r,useFormData:a},f=o,new Promise(function(m,u){const c=new MessageChannel;c.port1.onmessage=function(d){d.data.error?u(new Error(d.data.error)):m(d.data),c.port1.close()},f.postMessage(s,[c.port2])});var s,f},dr=async(t,e,n,r,i,o,a=1e4)=>i?lr(t,e,n,r,a,i,o):ur(t,r,a);async function hr(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,f=R(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const m=s?ut(f):JSON.stringify(f);return await async function(u,c,d,h,v,w,y){let k,_=null;for(let x=0;x<3;x++)try{k=await dr(u,d,h,v,w,y,c),_=null;break}catch(D){_=D}if(_)throw _;const I=k.json,{error:g,error_description:b}=I,L=R(I,["error","error_description"]),{ok:C}=k;if(!C){const x=b||`HTTP error. Unable to fetch ${u}`;throw g==="mfa_required"?new sr(g,x,L.mfa_token):g==="missing_refresh_token"?new Nt(d,h):new F(g||"request_error",x)}return L}(`${n}/oauth/token`,r,i||"default",o,{method:"POST",body:m,headers:{"Content-Type":s?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||$t))}},e,s)}const Re=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let ce=class Ct{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 Ct({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new Ct({scope:n,audience:r,clientId:i})}},fr=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@@"))}},Ut=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)}}()}},pr=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||zt}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 f=this.matchExistingCacheKey(e,s);f&&(i=await this.cache.get(f))}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 ce({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 ce({clientId:e},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(e,n){return n.filter(r=>{var i;const o=ce.fromKey(r),a=new Set(o.scope&&o.scope.split(" ")),s=((i=e.scope)===null||i===void 0?void 0:i.split(" "))||[],f=o.scope&&s.reduce((m,u)=>m&&a.has(u),!0);return o.prefix==="@@auth0spajs@@"&&o.clientId===e.clientId&&o.audience===e.audience&&f})[0]}},mr=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 xe=t=>typeof t=="number",gr=["iss","aud","exp","nbf","iat","jti","azp","nonce","auth_time","at_hash","c_hash","acr","amr","sub_jwk","cnf","sip_from_tag","sip_date","sip_callid","sip_cseq_num","sip_via_branch","orig","dest","mky","events","toe","txn","rph","sid","vot","vtm"],vr=t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(o=>{const a=o.split("."),[s,f,m]=a;if(a.length!==3||!s||!f||!m)throw new Error("ID token could not be decoded");const u=JSON.parse(Dt(f)),c={__raw:o},d={};return Object.keys(u).forEach(h=>{c[h]=u[h],gr.includes(h)||(d[h]=u[h])}),{encoded:{header:s,payload:f,signature:m},header:JSON.parse(Dt(s)),claims:c,user:d}})(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&&!xe(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||!xe(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!xe(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&&xe(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&&xe(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 ue=at(function(t,e){var n=V&&V.__assign||function(){return n=Object.assign||function(f){for(var m,u=1,c=arguments.length;u<c;u++)for(var d in m=arguments[u])Object.prototype.hasOwnProperty.call(m,d)&&(f[d]=m[d]);return f},n.apply(this,arguments)};function r(f,m){if(!m)return"";var u="; "+f;return m===!0?u:u+"="+m}function i(f,m,u){return encodeURIComponent(f).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(m).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 d=new Date;d.setMilliseconds(d.getMilliseconds()+864e5*c.expires),c.expires=d}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(f){for(var m={},u=f?f.split("; "):[],c=/(%[\dA-F]{2})+/gi,d=0;d<u.length;d++){var h=u[d].split("="),v=h.slice(1).join("=");v.charAt(0)==='"'&&(v=v.slice(1,-1));try{m[h[0].replace(c,decodeURIComponent)]=v.replace(c,decodeURIComponent)}catch{}}return m}function a(){return o(document.cookie)}function s(f,m,u){document.cookie=i(f,m,n({path:"/"},u))}e.__esModule=!0,e.encode=i,e.parse=o,e.getAll=a,e.get=function(f){return a()[f]},e.set=s,e.remove=function(f,m){s(f,"",n(n({},m),{expires:-1}))}});ot(ue),ue.encode,ue.parse,ue.getAll;var yr=ue.get,Zt=ue.set,Rt=ue.remove;const ve={get(t){const e=yr(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),Zt(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Rt(t,n)}},wr={get(t){return ve.get(t)||ve.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),Zt(`_legacy_${t}`,JSON.stringify(e),r),ve.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Rt(t,n),ve.remove(t,e),ve.remove(`_legacy_${t}`,e)}},br={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 kr(t,e,n){var r=e===void 0?null:e,i=function(f,m){var u=atob(f);if(m){for(var c=new Uint8Array(u.length),d=0,h=u.length;d<h;++d)c[d]=u.charCodeAt(d);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
|
|
1
|
+
(function(q){typeof define=="function"&&define.amd?define(q):q()})(function(){"use strict";var Po=Object.defineProperty;var To=(q,Z,J)=>Z in q?Po(q,Z,{enumerable:!0,configurable:!0,writable:!0,value:J}):q[Z]=J;var ee=(q,Z,J)=>(To(q,typeof Z!="symbol"?Z+"":Z,J),J);function q(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0});dispatchEvent(n)}function Z(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 J=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ut(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function lt(t,e){return t(e={exports:{}},e.exports),e.exports}var se=lt(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()}});ut(se);var fr=ut(lt(function(t,e){var n=J&&J.__awaiter||function(u,c,f,d){return new(f||(f=Promise))(function(v,k){function w(y){try{_(d.next(y))}catch(l){k(l)}}function I(y){try{_(d.throw(y))}catch(l){k(l)}}function _(y){y.done?v(y.value):new f(function(l){l(y.value)}).then(w,I)}_((d=d.apply(u,c||[])).next())})},r=J&&J.__generator||function(u,c){var f,d,v,k,w={label:0,sent:function(){if(1&v[0])throw v[1];return v[1]},trys:[],ops:[]};return k={next:I(0),throw:I(1),return:I(2)},typeof Symbol=="function"&&(k[Symbol.iterator]=function(){return this}),k;function I(_){return function(y){return function(l){if(f)throw new TypeError("Generator is already executing.");for(;w;)try{if(f=1,d&&(v=2&l[0]?d.return:l[0]?d.throw||((v=d.return)&&v.call(d),0):d.next)&&!(v=v.call(d,l[1])).done)return v;switch(d=0,v&&(l=[2&l[0],v.value]),l[0]){case 0:case 1:v=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(v=w.trys,!((v=v.length>0&&v[v.length-1])||l[0]!==6&&l[0]!==2)){w=0;continue}if(l[0]===3&&(!v||l[1]>v[0]&&l[1]<v[3])){w.label=l[1];break}if(l[0]===6&&w.label<v[1]){w.label=v[1],v=l;break}if(v&&w.label<v[2]){w.label=v[2],w.ops.push(l);break}v[2]&&w.ops.pop(),w.trys.pop();continue}l=c.call(u,w)}catch(b){l=[6,b],d=0}finally{f=v=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([_,y])}}},i=J;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 p(u){for(var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",f="",d=0;d<u;d++)f+=c[Math.floor(Math.random()*c.length)];return f}var m=function(){function u(c){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+p(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,v,k,w,I,_,y;return r(this,function(l){switch(l.label){case 0:d=Date.now()+p(4),v=Date.now()+f,k=o+"-"+c,w=this.storageHandler===void 0?a:this.storageHandler,l.label=1;case 1:return Date.now()<v?[4,s(30)]:[3,8];case 2:return l.sent(),w.getItemSync(k)!==null?[3,5]:(I=this.id+"-"+c+"-"+d,[4,s(Math.floor(25*Math.random()))]);case 3:return l.sent(),w.setItemSync(k,JSON.stringify({id:this.id,iat:d,timeoutKey:I,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return l.sent(),(_=w.getItemSync(k))!==null&&(y=JSON.parse(_)).id===this.id&&y.iat===d?(this.acquiredIatSet.add(d),this.refreshLockWhileAcquired(k,d),[2,!0]):[3,7];case 5:return u.lockCorrector(this.storageHandler===void 0?a:this.storageHandler),[4,this.waitForSomethingToChange(v)];case 6:l.sent(),l.label=7;case 7:return d=Date.now()+p(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(v){return setTimeout(function(){return n(d,void 0,void 0,function(){var k,w,I;return r(this,function(_){switch(_.label){case 0:return[4,se.default().lock(f)];case 1:return _.sent(),this.acquiredIatSet.has(f)?(k=this.storageHandler===void 0?a:this.storageHandler,(w=k.getItemSync(c))===null?(se.default().unlock(f),[2]):((I=JSON.parse(w)).timeRefreshed=Date.now(),k.setItemSync(c,JSON.stringify(I)),se.default().unlock(f),this.refreshLockWhileAcquired(c,f),[2])):(se.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 v=!1,k=Date.now(),w=!1;function I(){if(w||(window.removeEventListener("storage",I),u.removeFromWaiting(I),clearTimeout(_),w=!0),!v){v=!0;var y=50-(Date.now()-k);y>0?setTimeout(d,y):d(null)}}window.addEventListener("storage",I),u.addToWaiting(I);var _=setTimeout(I,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,v,k;return r(this,function(w){switch(w.label){case 0:return f=this.storageHandler===void 0?a:this.storageHandler,d=o+"-"+c,(v=f.getItemSync(d))===null?[2]:(k=JSON.parse(v)).id!==this.id?[3,2]:[4,se.default().lock(k.iat)];case 1:w.sent(),this.acquiredIatSet.delete(k.iat),f.removeItemSync(d),se.default().unlock(k.iat),u.notifyWaiters(),w.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var f=Date.now()-5e3,d=c,v=[],k=0;;){var w=d.keySync(k);if(w===null)break;v.push(w),k++}for(var I=!1,_=0;_<v.length;_++){var y=v[_];if(y.includes(o)){var l=d.getItemSync(y);if(l!==null){var b=JSON.parse(l);(b.timeRefreshed===void 0&&b.timeAcquired<f||b.timeRefreshed!==void 0&&b.timeRefreshed<f)&&(d.removeItemSync(y),I=!0)}}}I&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=m}));const pr={timeoutInSeconds:60},Lt={name:"auth0-spa-js",version:"2.1.3"},Dt=()=>Date.now();let H=class At extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,At.prototype)}static fromPayload({error:e,error_description:n}){return new At(e,n)}},mr=class sr extends H{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,sr.prototype)}},dt=class cr extends H{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,cr.prototype)}},gr=class ur extends dt{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,ur.prototype)}},yr=class lr extends H{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,lr.prototype)}},vr=class dr extends H{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,dr.prototype)}},Ut=class hr extends H{constructor(e,n){super("missing_refresh_token",`Missing Refresh Token (audience: '${Rt(e,["default"])}', scope: '${Rt(n)}')`),this.audience=e,this.scope=n,Object.setPrototypeOf(this,hr.prototype)}};function Rt(t,e=[]){return t&&!e.includes(t)?t:""}const Me=()=>window.crypto,ht=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Me().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},Zt=t=>btoa(t),ft=t=>{var{clientId:e}=t,n=Z(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()},Wt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),wr=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},br=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([wr(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},kr=async(t,e,n,r,i,o,a)=>{return s={auth:{audience:e,scope:n},timeout:i,fetchUrl:t,fetchOptions:r,useFormData:a},p=o,new Promise(function(m,u){const c=new MessageChannel;c.port1.onmessage=function(f){f.data.error?u(new Error(f.data.error)):m(f.data),c.port1.close()},p.postMessage(s,[c.port2])});var s,p},Ir=async(t,e,n,r,i,o,a=1e4)=>i?kr(t,e,n,r,a,i,o):br(t,r,a);async function _r(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,p=Z(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const m=s?ft(p):JSON.stringify(p);return await async function(u,c,f,d,v,k,w){let I,_=null;for(let j=0;j<3;j++)try{I=await Ir(u,f,d,v,k,w,c),_=null;break}catch(D){_=D}if(_)throw _;const y=I.json,{error:l,error_description:b}=y,T=Z(y,["error","error_description"]),{ok:x}=I;if(!x){const j=b||`HTTP error. Unable to fetch ${u}`;throw l==="mfa_required"?new vr(l,j,T.mfa_token):l==="missing_refresh_token"?new Ut(f,d):new H(l||"request_error",j)}return T}(`${n}/oauth/token`,r,i||"default",o,{method:"POST",body:m,headers:{"Content-Type":s?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||Lt))}},e,s)}const Xe=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let ce=class Nt{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 Nt({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new Nt({scope:n,audience:r,clientId:i})}},Sr=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@@"))}},Kt=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)}}()}},Er=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||Dt}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 p=this.matchExistingCacheKey(e,s);p&&(i=await this.cache.get(p))}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 ce({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 ce({clientId:e},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(e,n){return n.filter(r=>{var i;const o=ce.fromKey(r),a=new Set(o.scope&&o.scope.split(" ")),s=((i=e.scope)===null||i===void 0?void 0:i.split(" "))||[],p=o.scope&&s.reduce((m,u)=>m&&a.has(u),!0);return o.prefix==="@@auth0spajs@@"&&o.clientId===e.clientId&&o.audience===e.audience&&p})[0]}},Or=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 $e=t=>typeof t=="number",Pr=["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"],Tr=t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(o=>{const a=o.split("."),[s,p,m]=a;if(a.length!==3||!s||!p||!m)throw new Error("ID token could not be decoded");const u=JSON.parse(Wt(p)),c={__raw:o},f={};return Object.keys(u).forEach(d=>{c[d]=u[d],Pr.includes(d)||(f[d]=u[d])}),{encoded:{header:s,payload:p,signature:m},header:JSON.parse(Wt(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&&!$e(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||!$e(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!$e(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&&$e(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&&$e(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 ue=lt(function(t,e){var n=J&&J.__assign||function(){return n=Object.assign||function(p){for(var m,u=1,c=arguments.length;u<c;u++)for(var f in m=arguments[u])Object.prototype.hasOwnProperty.call(m,f)&&(p[f]=m[f]);return p},n.apply(this,arguments)};function r(p,m){if(!m)return"";var u="; "+p;return m===!0?u:u+"="+m}function i(p,m,u){return encodeURIComponent(p).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(m).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(p){for(var m={},u=p?p.split("; "):[],c=/(%[\dA-F]{2})+/gi,f=0;f<u.length;f++){var d=u[f].split("="),v=d.slice(1).join("=");v.charAt(0)==='"'&&(v=v.slice(1,-1));try{m[d[0].replace(c,decodeURIComponent)]=v.replace(c,decodeURIComponent)}catch{}}return m}function a(){return o(document.cookie)}function s(p,m,u){document.cookie=i(p,m,n({path:"/"},u))}e.__esModule=!0,e.encode=i,e.parse=o,e.getAll=a,e.get=function(p){return a()[p]},e.set=s,e.remove=function(p,m){s(p,"",n(n({},m),{expires:-1}))}});ut(ue),ue.encode,ue.parse,ue.getAll;var jr=ue.get,Mt=ue.set,Xt=ue.remove;const we={get(t){const e=jr(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),Mt(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Xt(t,n)}},xr={get(t){return we.get(t)||we.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),Mt(`_legacy_${t}`,JSON.stringify(e),r),we.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Xt(t,n),we.remove(t,e),we.remove(`_legacy_${t}`,e)}},Cr={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 $r(t,e,n){var r=e===void 0?null:e,i=function(p,m){var u=atob(p);if(m){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 Ft,Jt,Ht,pt,zr=(Ft="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",Jt=null,Ht=!1,function(t){return pt=pt||$r(Ft,Jt,Ht),new Worker(pt,t)});const mt={};let Ar=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 Nr={memory:()=>new Kt().enclosedCache,localstorage:()=>new Sr},Vt=t=>Nr[t],Yt=t=>{const{openUrl:e,onRedirect:n}=t,r=Z(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:e===!1||e?e:n})},gt=new fr;let Lr=class{constructor(e){let n,r;if(this.userCache=new Kt().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await gt.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(!Me())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Me().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",!Xt(n))throw new Error(`Invalid cache location "${n}"`);r=Xt(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?ve:wr,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:br;var o;this.scope=Re("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new mr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||zt,this.cacheManager=new pr(r,r.allKeys?void 0:new Sr(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 Ir)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||$t)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${ut(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return vr({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=At(ct()),o=At(ct()),a=ct(),s=(u=>{const c=new Uint8Array(u);return(d=>{const h={"+":"-","/":"_","=":""};return d.replace(/[+/=]/g,v=>h[v])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Ze().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),f=((u,c,d,h,v,w,y,k)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),d),{scope:Re(c,d.scope),response_type:"code",response_mode:k||"query",state:h,nonce:v,redirect_uri:y||u.authorizationParams.redirect_uri,code_challenge:w,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),m=this._authorizeUrl(f);return{nonce:o,code_verifier:a,scope:f.scope,audience:f.audience||"default",redirect_uri:f.redirect_uri,state:i,url:m}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const f=window.screenX+(window.innerWidth-400)/2,m=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${f},top=${m},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((f,m)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(d),window.removeEventListener("message",u,!1),m(new ar(s.popup)))},1e3),d=setTimeout(()=>{clearInterval(c),m(new or(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(h){if(h.data&&h.data.type==="authorization_response"){if(clearTimeout(d),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),h.data.response.error)return m(F.fromPayload(h.data.response));f(h.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 F("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=Vt(e),{openUrl:i,fragment:o,appState:a}=r,s=R(r,["openUrl","fragment","appState"]),f=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,m=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=m,c=R(m,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),f&&{organization:f}));const d=o?`${u}#${o}`:u;i?await i(d):window.location.assign(d)}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 d=new URLSearchParams(c);return{state:d.get("state"),code:d.get("code")||void 0,error:d.get("error")||void 0,error_description:d.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new F("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new ir(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new F("state_mismatch","Invalid state");const f=s.organization,m=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:m,organization:f}),{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:Re(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=dt[a];return s||(s=o().finally(()=>{delete dt[a],s=null}),dt[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=R(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})(()=>ht.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new st;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const m=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(m)return m}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:f}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:f})}finally{await ht.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:Re(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},rr),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new ce({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=R(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${ut(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=Vt(e),{openUrl:r}=n,i=R(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:f,scope:m,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new F("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,d=await((v,w,y=60)=>new Promise((k,_)=>{const I=window.document.createElement("iframe");I.setAttribute("width","0"),I.setAttribute("height","0"),I.style.display="none";const g=()=>{window.document.body.contains(I)&&(window.document.body.removeChild(I),window.removeEventListener("message",b,!1))};let b;const L=setTimeout(()=>{_(new st),g()},1e3*y);b=function(C){if(C.origin!=w||!C.data||C.data.type!=="authorization_response")return;const x=C.source;x&&x.close(),C.data.response.error?_(F.fromPayload(C.data.response)):k(C.data.response),clearTimeout(L),window.removeEventListener("message",b,!1),setTimeout(g,2e3)},window.addEventListener("message",b,!1),window.document.body.appendChild(I),I.setAttribute("src",v)}))(i,this.domainUrl,c);if(o!==d.state)throw new F("state_mismatch","Invalid state");const h=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:d.code,grant_type:"authorization_code",redirect_uri:f,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},h),{scope:m,oauthTokenScope:h.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 ce({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 Nt(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=R(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 ce({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 ce({scope:e,audience:n,clientId:r}),60);if(i&&i.access_token){const{access_token:o,oauthTokenScope:a,expires_in:s}=i,f=await this._getIdTokenFromCache();return f&&Object.assign(Object.assign({id_token:f.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await hr(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 Er(t){const e=new Or(t);return await e.checkSession(),e}const Pr="sesamy.com",xr="https://logs.sesamy.com/events";var le=(t=>(t.READY="sesamyReady",t.AUTHENTICATED="sesamyAuthenticated",t.LOGOUT="sesamyLogout",t))(le||{});let ee;async function Tr({clientId:t}){if(ee=await Er({domain:`token.${Pr}`,clientId:t,cacheLocation:"localstorage"}),window.location.search.includes("code="))try{await ee.handleRedirectCallback();const e=await ee.getUser();B(le.AUTHENTICATED,e),window.history.replaceState({},document.title,"/")}catch{}}async function jr(){if(!ee)throw new Error("Auth0 client not initialized");return ee.isAuthenticated()}async function Cr(){if(!ee)throw new Error("Auth0 client not initialized");return ee.getUser()}function $r(){if(!ee)throw new Error("Auth0 client not initialized");return ee.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function zr(){if(!ee)throw new Error("Auth0 client not initialized");return B(le.LOGOUT,{}),ee.logout({logoutParams:{returnTo:window.location.href}})}function Nr(t="sesamy"){window[t]={getUser:Cr,isAuthenticated:jr,loginWithRedirect:$r,logout:zr}}function Ft(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 We="undefined",Jt="object",Lr=function(){},Ht="any",Yt="*",de="__",Ke=typeof process<"u"?process:{};Ke.env&&Ke.env.NODE_ENV;var J=typeof document<"u";Ke.versions!=null&&Ke.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 Gt(t,e){return e.charAt(0)[t]()+e.slice(1)}var Ar=Gt.bind(null,"toUpperCase"),Dr=Gt.bind(null,"toLowerCase");function Ur(t){return Bt(t)?Ar("null"):typeof t=="object"?Kr(t):Object.prototype.toString.call(t).slice(8,-1)}function Me(t,e){e===void 0&&(e=!0);var n=Ur(t);return e?Dr(n):n}function Te(t,e){return typeof e===t}var q=Te.bind(null,"function"),re=Te.bind(null,"string"),ye=Te.bind(null,"undefined"),Zr=Te.bind(null,"boolean");Te.bind(null,"symbol");function Bt(t){return t===null}function Rr(t){return Me(t)==="number"&&!isNaN(t)}function qt(t){return Me(t)==="array"}function H(t){if(!Wr(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Wr(t){return t&&(typeof t=="object"||t!==null)}function Kr(t){return q(t.constructor)?t.constructor.name:null}function Mr(t){return t instanceof Error||re(t.message)&&t.constructor&&Rr(t.constructor.stackTraceLimit)}function Qt(t,e){if(typeof e!="object"||Bt(e))return!1;if(e instanceof t)return!0;var n=Me(new t(""));if(Mr(e))for(;e;){if(Me(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}Qt.bind(null,TypeError),Qt.bind(null,SyntaxError);function Xe(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Xr(t,e):n}function Xr(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function Ve(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}Ve(Xe,"form"),Ve(Xe,"button"),Ve(Xe,"input"),Ve(Xe,"select");function Vr(t){return t?qt(t)?t:[t]:[]}function en(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Fr(){if(J){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Jr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Hr(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=en(n[1]),a=en(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 f=s.split("[");f.length>1&&(Yr(r,f.map(function(m){return m.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return J&&window.location.search.substring(1)}(t))}function Yr(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 Fe(){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}var je="global",we=de+"global"+de,be=typeof self===Jt&&self.self===self&&self||typeof global===Jt&&global.global===global&&global||void 0;function he(t){return be[we][t]}function fe(t,e){return be[we][t]=e}function ke(t){delete be[we][t]}function Ie(t,e,n){var r;try{if(ft(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}be[we]||(be[we]={});var Je={};function ft(t){if(typeof Je[t]!==We)return Je[t];try{var e=window[t];e.setItem(We,We),e.removeItem(We)}catch{return Je[t]=!1}return Je[t]=!0}function O(){return O=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},O.apply(this,arguments)}var ie="function",ne="undefined",Gr="@@redux/"+Math.random().toString(36),tn=function(){return typeof Symbol===ie&&Symbol.observable||"@@observable"}(),He=" != "+ie;function nn(t,e,n){var r;if(typeof e===ie&&typeof n===ne&&(n=e,e=void 0),typeof n!==ne){if(typeof n!==ie)throw new Error("enhancer"+He);return n(nn)(t,e)}if(typeof t!==ie)throw new Error("reducer"+He);var i=t,o=e,a=[],s=a,f=!1;function m(){s===a&&(s=a.slice())}function u(){return o}function c(h){if(typeof h!==ie)throw new Error("Listener"+He);var v=!0;return m(),s.push(h),function(){if(v){v=!1,m();var w=s.indexOf(h);s.splice(w,1)}}}function d(h){if(!H(h))throw new Error("Act != obj");if(typeof h.type===ne)throw new Error("ActType "+ne);if(f)throw new Error("Dispatch in reducer");try{f=!0,o=i(o,h)}finally{f=!1}for(var v=a=s,w=0;w<v.length;w++)(0,v[w])();return h}return d({type:"@@redux/INIT"}),(r={dispatch:d,subscribe:c,getState:u,replaceReducer:function(h){if(typeof h!==ie)throw new Error("next reducer"+He);i=h,d({type:"@@redux/INIT"})}})[tn]=function(){var h,v=c;return(h={subscribe:function(w){if(typeof w!="object")throw new TypeError("Observer != obj");function y(){w.next&&w.next(u())}return y(),{unsubscribe:v(y)}}})[tn]=function(){return this},h},r}function Br(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+ne}function Se(){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 qr(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,f={getState:a.getState,dispatch:function(m){return s(m)}};return o=[].slice.call(t).map(function(m){return m(f)}),O({},a,{dispatch:s=Se.apply(void 0,o)(a.dispatch)})}}}var oe=de+"anon_id",pe=de+"user_id",_e=de+"user_traits",ae="userId",Oe="anonymousId",Ye=["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"],pt=["name","EVENTS","config","loaded"],E=Ye.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),rn=/^utm_/,on=/^an_prop_/,an=/^an_trait_/;function Qr(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===E.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,f=i.initialUser,m=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(oe,a.anonymousId),m||e(pe,a.userId),f.traits&&e(_e,O({},m&&s.traits?s.traits:{},f.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,d=o.an_event,h=u.reduce(function(v,w){if(w.match(rn)||w.match(/^(d|g)clid/)){var y=w.replace(rn,"");v.campaign[y==="campaign"?"name":y]=o[w]}return w.match(on)&&(v.props[w.replace(on,"")]=o[w]),w.match(an)&&(v.traits[w.replace(an,"")]=o[w]),v},{campaign:{},props:{},traits:{}});n.dispatch(O({type:E.params,raw:o},h,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,h.traits)},0),d&&setTimeout(function(){return t.track(d,h.props)},0),Object.keys(h.campaign).length&&n.dispatch({type:E.campaign,campaign:h.campaign})}}return r(i)}}}}function ei(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===E.setItemEnd){if(n.key===oe)return O({},e,{anonymousId:n.value});if(n.key===pe)return O({},e,{userId:n.value})}switch(n.type){case E.identify:return Object.assign({},e,{userId:n.userId,traits:O({},e.traits,n.traits)});case E.reset:return[pe,oe,_e].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function sn(t){return{userId:t.getItem(pe),anonymousId:t.getItem(oe),traits:t.getItem(_e)}}var mt=function(t){return de+"TEMP"+de+t};function ti(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var f=s.userId,m=s.traits,u=s.options;if(s.type===E.reset&&([pe,_e,oe].forEach(function(h){r(h)}),[ae,Oe,"traits"].forEach(function(h){ke(mt(h))})),s.type===E.identify){i(oe)||n(oe,Fe());var c=i(pe),d=i(_e)||{};c&&c!==f&&o.dispatch({type:E.userIdChanged,old:{userId:c,traits:d},new:{userId:f,traits:m},options:u}),f&&n(pe,f),m&&n(_e,O({},d,m))}return a(s)}}}}var Ce={};function cn(t,e){Ce[t]&&q(Ce[t])&&(Ce[t](e),delete Ce[t])}function un(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(O({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return un(t,e,n-10).then(r,i)})})}function ln(t,e,n){var r=e(),i=t.getState(),o=i.plugins,a=i.queue,s=i.user;if(!i.context.offline&&a&&a.actions&&a.actions.length){var f=a.actions.reduce(function(u,c,d){return o[c.plugin].loaded?(u.process.push(c),u.processIndex.push(d)):(u.requeue.push(c),u.requeueIndex.push(d)),u},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(u){var c=a.actions[u],d=c.plugin,h=c.payload.type,v=r[d][h];if(v&&q(v)){var w=function(k,_){return k===void 0&&(k={}),_===void 0&&(_={}),[ae,Oe].reduce(function(I,g){return k.hasOwnProperty(g)&&_[g]&&_[g]!==k[g]&&(I[g]=_[g]),I},k)}(c.payload,s);v({payload:w,config:o[d].config,instance:n});var y=h+":"+d;t.dispatch(O({},w,{type:y,_:{called:y,from:"queueDrain"}}))}});var m=a.actions.filter(function(u,c){return!~f.processIndex.indexOf(c)});a.actions=m}}}var gt=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,f=t.EVENTS;try{var m=i.plugins,u=i.context,c=n.type,d=c.match(Ee),h=e.exact.map(function(y){return y.pluginName});d&&(h=a.during.map(function(y){return y.pluginName}));var v=function(y,k){return function(_,I,g){var b=I.config,L=I.name,C=L+"."+_.type;g&&(C=g.event);var x=_.type.match(Ee)?function(D,A,Y,U,G){return function(W,P){var M=U?U.name:D,X=P&&$e(P)?P:Y;if(U&&(!(X=P&&$e(P)?P:[D]).includes(D)||X.length!==1))throw new Error("Method "+A+" can only abort "+D+" plugin. "+JSON.stringify(X)+" input valid");return O({},G,{abort:{reason:W,plugins:X,caller:A,_:M}})}}(L,C,k,g,_):function(D,A){return function(){throw new Error(D.type+" action not cancellable. Remove abort in "+A)}}(_,C);return{payload:ni(_),instance:y,config:b||{},abort:x}}}(r,h),w=e.exact.reduce(function(y,k){var _=k.pluginName,I=k.methodName,g=!1;return I.match(/^initialize/)||I.match(/^reset/)||(g=!m[_].loaded),u.offline&&I.match(/^(page|track|identify)/)&&(g=!0),y[""+_]=g,y},{});return Promise.resolve(e.exact.reduce(function(y,k,_){try{var I=k.pluginName;return Promise.resolve(y).then(function(g){function b(){return Promise.resolve(g)}var L=function(){if(e.namespaced&&e.namespaced[I])return Promise.resolve(e.namespaced[I].reduce(function(C,x,D){try{return Promise.resolve(C).then(function(A){return x.method&&q(x.method)?(function(W,P){var M=yn(W);if(M&&M.name===P){var X=yn(M.method);throw new Error([P+" plugin is calling method "+W,"Plugins cant call self","Use "+M.method+" "+(X?"or "+X.method:"")+" in "+P+" plugin insteadof "+W].join(`
|
|
5
|
-
`))}}(x.methodName,x.pluginName),Promise.resolve(x.method({payload:A,instance:r,abort:(Y=A,U=I,G=x.pluginName,function(W,P){return O({},Y,{abort:{reason:W,plugins:P||[U],caller:c,from:G||U}})}),config:fn(x.pluginName,m,o),plugins:m})).then(function(W){var P=H(W)?W:{};return Promise.resolve(O({},A,P))})):A;var Y,U,G})}catch(A){return Promise.reject(A)}},Promise.resolve(n))).then(function(C){g[I]=C});g[I]=n}();return L&&L.then?L.then(b):b()})}catch(g){return Promise.reject(g)}},Promise.resolve({}))).then(function(y){return Promise.resolve(e.exact.reduce(function(k,_,I){try{var g=e.exact.length===I+1,b=_.pluginName,L=o[b];return Promise.resolve(k).then(function(C){var x=y[b]?y[b]:{};if(d&&(x=C),yt(x,b))return vt({data:x,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(C);if(yt(C,b))return g&&vt({data:C,method:c,instance:r,store:s}),Promise.resolve(C);if(w.hasOwnProperty(b)&&w[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:x,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(C);var D=v(y[b],o[b]);return Promise.resolve(L[c]({abort:D.abort,payload:x,instance:r,config:fn(b,m,o),plugins:m})).then(function(A){var Y=H(A)?A:{},U=O({},C,Y),G=y[b];if(yt(G,b))vt({data:G,method:c,instance:r,pluginName:b,store:s});else{var W=c+":"+b;(W.match(/:/g)||[]).length<2&&!c.match(dn)&&!c.match(hn)&&r.dispatch(O({},d?U:x,{type:W,_:{called:W,from:"submethod"}}))}return Promise.resolve(U)})})}catch(C){return Promise.reject(C)}},Promise.resolve(n))).then(function(k){if(!(c.match(Ee)||c.match(/^registerPlugin/)||c.match(hn)||c.match(dn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(f.plugins.includes(c),k._&&k._.originalAction===c)return k;var _=O({},k,{_:{originalAction:k.type,called:k.type,from:"engineEnd"}});gn(k,e.exact.length)&&!c.match(/End$/)&&(_=O({},_,{type:k.type+"Aborted"})),s.dispatch(_)}return k})})}catch(y){return Promise.reject(y)}},Ee=/Start$/,dn=/^bootstrap/,hn=/^ready/;function vt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(O({},t.data,{type:n,_:{called:n,from:"abort"}}))}function fn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function pn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function mn(t,e){var n=t.replace(Ee,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function yt(t,e){var n=t.abort;return!!n&&(n===!0||vn(n,e)||n&&vn(n.plugins,e))}function gn(t,e){var n=t.abort;if(!n)return!1;if(n===!0||re(n))return!0;var r=n.plugins;return $e(n)&&n.length===e||$e(r)&&r.length===e}function $e(t){return Array.isArray(t)}function vn(t,e){return!(!t||!$e(t))&&t.includes(e)}function yn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function ni(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=H(t[n])?Object.assign({},t[n]):t[n]),e},{})}function ri(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,f=function(g){return s?g:o(c)},m=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(m===E.enablePlugin&&i.dispatch({type:E.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),m===E.disablePlugin&&setTimeout(function(){return cn(a.meta.rid,{payload:a})},0),m===E.initializeEnd){var d=e(),h=Object.keys(d),v=h.filter(function(g){return u.includes(g)}).map(function(g){return d[g]}),w=[],y=[],k=a.disabled,_=v.map(function(g){var b=g.loaded,L=g.name,C=g.config;return un(g,function(){return b({config:C})},1e4).then(function(x){return r[L]||(i.dispatch({type:E.pluginReadyType(L),name:L,events:Object.keys(g).filter(function(D){return!pt.includes(D)})}),r[L]=!0),w=w.concat(L),g}).catch(function(x){if(x instanceof Error)throw new Error(x);return y=y.concat(x.name),x})});Promise.all(_).then(function(g){var b={plugins:w,failed:y,disabled:k};setTimeout(function(){h.length===_.length+k.length&&i.dispatch(O({},{type:E.ready},b))},0)})}var I=function(){if(m!==E.bootstrap)return/^ready:([^:]*)$/.test(m)&&setTimeout(function(){return ln(i,e,t)},0),Promise.resolve(function(g,b,L,C,x){try{var D=q(b)?b():b,A=g.type,Y=A.replace(Ee,"");if(g._&&g._.called)return Promise.resolve(g);var U=L.getState(),G=(M=D,(X=U.plugins)===void 0&&(X={}),(De=g.options)===void 0&&(De={}),Object.keys(M).filter(function(l){var p=De.plugins||{};return Zr(p[l])?p[l]:p.all!==!1&&(!X[l]||X[l].enabled!==!1)}).map(function(l){return M[l]}));A===E.initializeStart&&g.fromEnable&&(G=Object.keys(U.plugins).filter(function(l){var p=U.plugins[l];return g.plugins.includes(l)&&!p.initialized}).map(function(l){return D[l]}));var W=G.map(function(l){return l.name}),P=function(l,p,S){var T=mn(l).map(function(j){return pn(j,p)});return p.reduce(function(j,$){var K=$.name,N=mn(l,K).map(function(Ue){return pn(Ue,p)}),Z=N[0],z=N[1],te=N[2];return Z.length&&(j.beforeNS[K]=Z),z.length&&(j.duringNS[K]=z),te.length&&(j.afterNS[K]=te),j},{before:T[0],beforeNS:{},during:T[1],duringNS:{},after:T[2],afterNS:{}})}(A,G);return Promise.resolve(gt({action:g,data:{exact:P.before,namespaced:P.beforeNS},state:U,allPlugins:D,allMatches:P,instance:L,store:C,EVENTS:x})).then(function(l){function p(){var j=function(){if(A.match(Ee))return Promise.resolve(gt({action:O({},S,{type:Y+"End"}),data:{exact:P.after,namespaced:P.afterNS},state:U,allPlugins:D,allMatches:P,instance:L,store:C,EVENTS:x})).then(function($){$.meta&&$.meta.hasCallback&&cn($.meta.rid,{payload:$})})}();return j&&j.then?j.then(function(){return l}):l}if(gn(l,W.length))return l;var S,T=function(){if(A!==Y)return Promise.resolve(gt({action:O({},l,{type:Y}),data:{exact:P.during,namespaced:P.duringNS},state:U,allPlugins:D,allMatches:P,instance:L,store:C,EVENTS:x})).then(function(j){S=j});S=l}();return T&&T.then?T.then(p):p()})}catch(l){return Promise.reject(l)}var M,X,De}(a,e,t,i,n)).then(function(g){return s=1,o(g)})}();return Promise.resolve(I&&I.then?I.then(f):f(I))}catch(g){return Promise.reject(g)}}}}}function ii(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===E.setItem||i===E.removeItem){if(r.abort)return n(r);i===E.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var oi=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 Se.apply(void 0,a)(r)(i)}}}}};function ai(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=wn(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},O({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var f=wn(n.type,E.initialize),m=t()[f];return m&&f?(r[f]=O({},e[f],{initialized:!0,loaded:!!m.loaded({config:m.config})}),O({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=O({},e[n.name],{loaded:!0}),O({},e,r);switch(n.type){case E.disablePlugin:return O({},e,bn(n.plugins,!1,e));case E.enablePlugin:return O({},e,bn(n.plugins,!0,e));default:return e}}}function wn(t,e){return t.substring(e.length+1,t.length)}function bn(t,e,n){return t.reduce(function(r,i){return r[i]=O({},n[i],{enabled:e}),r},n)}function kn(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var si={last:{},history:[]};function ci(t,e){t===void 0&&(t=si);var n=e.options,r=e.meta;if(e.type===E.track){var i=kn(O({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return O({},t,{last:i,history:t.history.concat(i)})}return t}var ui={actions:[]};function li(t,e){t===void 0&&(t=ui);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===E.identify?[e].concat(t.actions):t.actions.concat(e),O({},t,{actions:r});case"dequeue":return[];default:return t}}var In=/#.*$/;function di(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(In,""):"")}var Sn,_n,On,En,hi=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,f=o.hash,m=o.search,u=function(d){var h=function(){if(J){for(var v,w=document.getElementsByTagName("link"),y=0;v=w[y];y++)if(v.getAttribute("rel")==="canonical")return v.getAttribute("href")}}();return h?h.match(/\?/)?h:h+d:window.location.href.replace(In,"")}(m),c={title:n,url:u,path:di(u),hash:f,search:m,width:a,height:s};return r&&r!==""&&(c.referrer=r),O({},c,t)},fi={last:{},history:[]};function pi(t,e){t===void 0&&(t=fi);var n=e.options;if(e.type===E.page){var r=kn(O({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return O({},t,{last:r,history:t.history.concat(r)})}return t}Sn=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"}(),_n=J?document.referrer:null,On=Fr(),En=Jr();var Pn={initialized:!1,sessionId:Fe(),app:null,version:null,debug:!1,offline:!!J&&!navigator.onLine,os:{name:Sn},userAgent:J?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.5"},timezone:En,locale:On,campaign:{},referrer:_n};function mi(t,e){t===void 0&&(t=Pn);var n=t.initialized,r=e.campaign;switch(e.type){case E.campaign:return O({},t,{campaign:r});case E.offline:return O({},t,{offline:!0});case E.online:return O({},t,{offline:!1});default:return n?t:O({},Pn,t,{initialized:!0})}}var gi=["plugins","reducers","storage"];function vi(t,e,n){if(J){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function yi(t){var e=vi.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function xn(){return fe("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 be[we].analytics.push(a.action||a),o(a)}})}}}function Tn(t){return function(){return Se(Se.apply(null,arguments),xn())}}function wt(t){return t?qt(t)?t:[t]:[]}function jn(t,e,n){t===void 0&&(t={});var r,i,o=Fe();return e&&(Ce[o]=(r=e,i=function(a){for(var s,f=a||Array.prototype.slice.call(arguments),m=0;m<f.length;m++)if(q(f[m])){s=f[m];break}return s}(n),function(a){i&&i(a),r(a)})),O({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function wi(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(l,p){if(q(p))return l.middlewares=l.middlewares.concat(p),l;if(p.NAMESPACE&&(p.name=p.NAMESPACE),!p.name)throw new Error("https://lytics.dev/errors/1");p.config||(p.config={});var S=p.EVENTS?Object.keys(p.EVENTS).map(function($){return p.EVENTS[$]}):[];l.pluginEnabled[p.name]=!(p.enabled===!1||p.config.enabled===!1),delete p.enabled,p.methods&&(l.methods[p.name]=Object.keys(p.methods).reduce(function($,K){var N;return $[K]=(N=p.methods[K],function(){for(var Z=Array.prototype.slice.call(arguments),z=new Array(N.length),te=0;te<Z.length;te++)z[te]=Z[te];return z[z.length]=b,N.apply({instance:b},z)}),$},{}),delete p.methods);var T=Object.keys(p).concat(S),j=new Set(l.events.concat(T));if(l.events=Array.from(j),l.pluginsArray=l.pluginsArray.concat(p),l.plugins[p.name])throw new Error(p.name+"AlreadyLoaded");return l.plugins[p.name]=p,l.plugins[p.name].loaded||(l.plugins[p.name].loaded=function(){return!0}),l},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:he,setItem:fe,removeItem:ke},o=function(l){return function(p,S,T){return S.getState("user")[p]||(T&&H(T)&&T[p]?T[p]:sn(l)[p]||he(mt(p))||null)}}(i),a=r.plugins,s=r.events.filter(function(l){return!pt.includes(l)}).sort(),f=new Set(s.concat(Ye).filter(function(l){return!pt.includes(l)})),m=Array.from(f).sort(),u=function(){return a},c=new oi,d=c.addMiddleware,h=c.removeMiddleware,v=c.dynamicMiddlewares,w=function(){throw new Error("Abort disabled inListener")},y=Hr(),k=sn(i),_=O({},k,n,y.an_uid?{userId:y.an_uid}:{},y.an_aid?{anonymousId:y.an_aid}:{});_.anonymousId||(_.anonymousId=Fe());var I=O({enable:function(l,p){return new Promise(function(S){P.dispatch({type:E.enablePlugin,plugins:wt(l),_:{originalAction:E.enablePlugin}},S,[p])})},disable:function(l,p){return new Promise(function(S){P.dispatch({type:E.disablePlugin,plugins:wt(l),_:{originalAction:E.disablePlugin}},S,[p])})}},r.methods),g=!1,b={identify:function(l,p,S,T){try{var j=re(l)?l:null,$=H(l)?l:p,K=S||{},N=b.user();fe(mt(ae),j);var Z=j||$.userId||o(ae,b,$);return Promise.resolve(new Promise(function(z){P.dispatch(O({type:E.identifyStart,userId:Z,traits:$||{},options:K,anonymousId:N.anonymousId},N.id&&N.id!==j&&{previousId:N.id}),z,[p,S,T])}))}catch(z){return Promise.reject(z)}},track:function(l,p,S,T){try{var j=H(l)?l.event:l;if(!j||!re(j))throw new Error("EventMissing");var $=H(l)?l:p||{},K=H(S)?S:{};return Promise.resolve(new Promise(function(N){P.dispatch({type:E.trackStart,event:j,properties:$,options:K,userId:o(ae,b,p),anonymousId:o(Oe,b,p)},N,[p,S,T])}))}catch(N){return Promise.reject(N)}},page:function(l,p,S){try{var T=H(l)?l:{},j=H(p)?p:{};return Promise.resolve(new Promise(function($){P.dispatch({type:E.pageStart,properties:hi(T),options:j,userId:o(ae,b,T),anonymousId:o(Oe,b,T)},$,[l,p,S])}))}catch($){return Promise.reject($)}},user:function(l){if(l===ae||l==="id")return o(ae,b);if(l===Oe||l==="anonId")return o(Oe,b);var p=b.getState("user");return l?Ft(p,l):p},reset:function(l){return new Promise(function(p){P.dispatch({type:E.resetStart},p,l)})},ready:function(l){return g&&l({plugins:I,instance:b}),b.on(E.ready,function(p){l(p),g=!0})},on:function(l,p){if(!l||!q(p))return!1;if(l===E.bootstrap)throw new Error(".on disabled for "+l);var S=/Start$|Start:/;if(l==="*"){var T=function(N){return function(Z){return function(z){return z.type.match(S)&&p({payload:z,instance:b,plugins:a}),Z(z)}}},j=function(N){return function(Z){return function(z){return z.type.match(S)||p({payload:z,instance:b,plugins:a}),Z(z)}}};return d(T,Ge),d(j,Be),function(){h(T,Ge),h(j,Be)}}var $=l.match(S)?Ge:Be,K=function(N){return function(Z){return function(z){return z.type===l&&p({payload:z,instance:b,plugins:a,abort:w}),Z(z)}}};return d(K,$),function(){return h(K,$)}},once:function(l,p){if(!l||!q(p))return!1;if(l===E.bootstrap)throw new Error(".once disabled for "+l);var S=b.on(l,function(T){p({payload:T.payload,instance:b,plugins:a,abort:w}),S()});return S},getState:function(l){var p=P.getState();return l?Ft(p,l):Object.assign({},p)},dispatch:function(l){var p=re(l)?{type:l}:l;if(Ye.includes(p.type))throw new Error("reserved action "+p.type);var S=O({},p,{_:O({originalAction:p.type},l._||{})});P.dispatch(S)},enablePlugin:I.enable,disablePlugin:I.disable,plugins:I,storage:{getItem:i.getItem,setItem:function(l,p,S){P.dispatch({type:E.setItemStart,key:l,value:p,options:S})},removeItem:function(l,p){P.dispatch({type:E.removeItemStart,key:l,options:p})}},setAnonymousId:function(l,p){b.storage.setItem(oe,l,p)},events:{core:Ye,plugins:s}},L=r.middlewares.concat([function(l){return function(p){return function(S){return S.meta||(S.meta=jn()),p(S)}}},v(Ge),ri(b,u,{all:m,plugins:s}),ii(i),Qr(b),ti(b),v(Be)]),C={context:mi,user:ei(i),page:pi,track:ci,plugins:ai(u),queue:li},x=Se,D=Se;if(J&&t.debug){var A=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;A&&(x=A({trace:!0,traceLimit:25})),D=function(){return arguments.length===0?xn():H(typeof arguments[0])?Tn():Tn().apply(null,arguments)}}var Y,U=function(l){return Object.keys(l).reduce(function(p,S){return gi.includes(S)||(p[S]=l[S]),p},{})}(t),G=r.pluginsArray.reduce(function(l,p){var S=p.name,T=p.config,j=p.loaded,$=r.pluginEnabled[S];return l[S]={enabled:$,initialized:!!$&&!p.initialize,loaded:!!j({config:T}),config:T},l},{}),W={context:U,user:_,plugins:G},P=nn(function(l){for(var p=Object.keys(l),S={},T=0;T<p.length;T++){var j=p[T];typeof l[j]===ie&&(S[j]=l[j])}var $,K=Object.keys(S);try{(function(N){Object.keys(N).forEach(function(Z){var z=N[Z];if(typeof z(void 0,{type:"@@redux/INIT"})===ne||typeof z(void 0,{type:Gr})===ne)throw new Error("reducer "+Z+" "+ne)})})(S)}catch(N){$=N}return function(N,Z){if(N===void 0&&(N={}),$)throw $;for(var z=!1,te={},Ue=0;Ue<K.length;Ue++){var it=K[Ue],Yn=N[it],Tt=(0,S[it])(Yn,Z);if(typeof Tt===ne){var Bi=Br(it,Z);throw new Error(Bi)}te[it]=Tt,z=z||Tt!==Yn}return z?te:N}}(O({},C,e)),W,D(x(qr.apply(void 0,L))));P.dispatch=(Y=P.dispatch,function(l,p,S){var T=O({},l,{meta:jn(l.meta,p,wt(S))});return Y.apply(null,[T])});var M=Object.keys(a);P.dispatch({type:E.bootstrap,plugins:M,config:U,params:y,user:_,initialUser:n,persistedUser:k});var X=M.filter(function(l){return r.pluginEnabled[l]}),De=M.filter(function(l){return!r.pluginEnabled[l]});return P.dispatch({type:E.registerPlugins,plugins:M,enabled:r.pluginEnabled}),r.pluginsArray.map(function(l,p){var S=l.bootstrap,T=l.config,j=l.name;S&&q(S)&&S({instance:b,config:T,payload:l}),P.dispatch({type:E.registerPluginType(j),name:j,enabled:r.pluginEnabled[j],plugin:l}),r.pluginsArray.length===p+1&&P.dispatch({type:E.initializeStart,plugins:X,disabled:De})}),yi(function(l){P.dispatch({type:l?E.offline:E.online})}),function(l,p,S){setInterval(function(){return ln(l,p,S)},3e3)}(P,u,b),b}var Ge="before",Be="after",ze="cookie",me=zn(),Cn=qe,bi=qe;function $n(t){return me?qe(t,"",-1):ke(t)}function zn(){if(me!==void 0)return me;var t="cookiecookie";try{qe(t,t),me=document.cookie.indexOf(t)!==-1,$n(t)}catch{me=!1}return me}function qe(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return me===!1&&(a?fe(t,e):he(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 Ne="localStorage",ki=ft.bind(null,"localStorage");Ie("localStorage","getItem",he),Ie("localStorage","setItem",fe),Ie("localStorage","removeItem",ke);var Le="sessionStorage",Ii=ft.bind(null,"sessionStorage");Ie("sessionStorage","getItem",he),Ie("sessionStorage","setItem",fe),Ie("sessionStorage","removeItem",ke);function Pe(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(H(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var Si=ki(),_i=Ii(),Oi=zn();function Nn(t,e){if(t){var n=bt(e),r=!_t(n),i=kt(n)?Pe(localStorage.getItem(t)):void 0;if(r&&!ye(i))return i;var o=It(n)?Pe(Cn(t)):void 0;if(r&&o)return o;var a=St(n)?Pe(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=he(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function Ei(t,e,n){if(t&&!ye(e)){var r={},i=bt(n),o=JSON.stringify(e),a=!_t(i);return kt(i)&&(r[Ne]=et(Ne,e,Pe(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Ne]:It(i)&&(r[ze]=et(ze,e,Pe(Cn(t))),bi(t,o),a)?r[ze]:St(i)&&(r[Le]=et(Le,e,Pe(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Le]:(r[je]=et(je,e,he(t)),fe(t,e),a?r[je]:r)}}function Pi(t,e){if(t){var n=bt(e),r=Nn(t,Yt),i={};return!ye(r.localStorage)&&kt(n)&&(localStorage.removeItem(t),i[Ne]=r.localStorage),!ye(r.cookie)&&It(n)&&($n(t),i[ze]=r.cookie),!ye(r.sessionStorage)&&St(n)&&(sessionStorage.removeItem(t),i[Le]=r.sessionStorage),!ye(r.global)&&Qe(n,je)&&(ke(t),i[je]=r.global),i}}function bt(t){return t?re(t)?t:t.storage:Ht}function kt(t){return Si&&Qe(t,Ne)}function It(t){return Oi&&Qe(t,ze)}function St(t){return _i&&Qe(t,Le)}function _t(t){return t===Yt||t==="all"}function Qe(t,e){return t===Ht||t===e||_t(t)}function et(t,e,n){return{location:t,current:e,previous:n}}var xi={setItem:Ei,getItem:Nn,removeItem:Pi};function Ti(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ln(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 An(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ln(Object(n),!0).forEach(function(r){Ti(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ln(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ji(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:xi};return wi(An(An({},e),t))}function Ci(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(f){return r=i.push(f),r>=o&&a(),r},size:function(){return i.length},end:function(f){f&&a(),clearInterval(n)}}}const Dn="@sesamy/sesamy-js",Un="1.0.2";function $i(t){if(!(typeof window>"u")){var e=window,n=e.addEventListener,r=e.history,i=e.location,o=i.pathname;n("popstate",function(){return t(i.pathname)}),["push","replace"].map(function(a){var s="".concat(a,"State"),f=r[s];r[s]=function(){var m=arguments,u=Ni(arguments[2]);return o!==u&&(o=u,setTimeout(function(){return t(m[2])},0)),f.apply(r,arguments)}})}}function zi(t,e){var n=t.indexOf(e);return n>-1?t.slice(0,n):t}function Ni(t){return["#","?"].forEach(function(e){return t=zi(t,e)}),t}function Li(){$i(()=>{ge.page()})}var Zn="EventListener";function Ai(t){return function(e,n,r,i){var o=r||Lr,a=i||!1;if(!J)return o;var s=tt(n),f=tt(e,!0);if(!f.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var m=[];return function u(c){c&&(m=[]);for(var d=c?"add"+Zn:"remove"+Zn,h=0;h<f.length;h++){var v=f[h];m[h]=c?a&&a.once?Di(o):o:m[h]||o;for(var w=0;w<s.length;w++)v[d]?v["on"+s[w]]=c?m[h]:null:v[d](s[w],m[h],a)}return u.bind(null,!c)}(t)}}function tt(t,e){if(re(t))return e?tt(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=Vr(t);return e?o.map(function(a){return re(a)?tt(a,!0):a}).flat():o}function Di(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var Ot=Ai("Event");function Rn(t,e){return J&&q(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),q(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}Rn.bind(null,"onerror"),Rn.bind(null,"onload");var Wn=typeof window>"u",Kn="hidden";function Ui(t){if(Wn)return!1;var e=Zi(),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 Zi(){var t=["webkit","moz","ms","o"];return Wn||Kn in document?Kn:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var Ri=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Wi(t,e){e===void 0&&(e={});var n=function(a,s){var f=this,m=!1;return function(u){m||(a.call(f,u),m=!0,setTimeout(function(){return m=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=Ui(function(s){s||n({type:"tabVisible"})});return r=[a].concat(Ri.map(function(s){return Ot(document,s,n)})).concat(Ot(window,"load",n)).concat(Ot(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Ki(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,f=t.throttle,m=f===void 0?2e3:f,u=!1,c=!1,d=new Date,h=function(){return clearTimeout(e)};function v(y){h(),o&&!u&&o(Ae(d),y),i&&u&&(u=!1,i(Ae(n),y),d=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(Ae(d),y))},s)}var w=Wi(v,{throttle:m});return{disable:function(){c=!0,u=!1,h();var y=w();return function(){return c=!1,d=new Date,v({type:"load"}),y()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:Ae(d,c),idle:u?Ae(n,c):0}}}}function Ae(t,e){return e?0:Math.round((new Date-t)/1e3)}const Mn=5e3;class Mi{constructor(e){Q(this,"element");Q(this,"isInViewport",!1);Q(this,"isAwake",!1);Q(this,"isFlushing");Q(this,"observer");Q(this,"lastEventAt",Date.now());Q(this,"registeredView",!1);Q(this,"viewCallback");Q(this,"activeDurationCallback");Q(this,"idleDurationCallback");this.element=e.element,this.viewCallback=e.viewCallback,this.activeDurationCallback=e.activeDurationCallback,this.idleDurationCallback=e.idleDurationCallback,this.observer=new IntersectionObserver(n=>{n.forEach(r=>{this.handleInViewPort(r.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),Ki({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:Mn})}flush(){this.isFlushing=!0,this.handleAwake(!this.isAwake,Math.round((Date.now()-this.lastEventAt)/1e3))}handleInViewPort(e){e?(this.isAwake=!0,this.trackInViewport()):this.handleAwake(!1,Math.round((Date.now()-this.lastEventAt)/1e3)),this.isInViewport=e}handleAwake(e,n){this.isAwake=e,this.lastEventAt=e?Date.now()-n*Mn:Date.now(),this.isInViewport&&this.trackAwake(e,n)}trackAwake(e,n){!e&&this.activeDurationCallback&&this.activeDurationCallback(n,this.isFlushing),e&&this.idleDurationCallback&&this.idleDurationCallback(n,this.isFlushing)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}const Xn="sesamy_session_id";function Xi(){let t=sessionStorage.getItem(Xn);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(Xn,t)),t}let Vn=!1,Et,Fn,nt;function Vi({clientId:t,enabled:e=!0,endpoint:n=xr}){if(Et=t,Fn=e,nt=n,!Fn)return;Li();const r=new Mi({element:document.body,viewCallback:()=>{ge.page()},activeDurationCallback:(i,o)=>{ge.track("activeDuration",{duration:i,flushing:o})},idleDurationCallback:(i,o)=>{ge.track("idleDuration",{duration:i,flushing:o})}});Ji(document.body,()=>{r.flush()}),window.addEventListener(le.AUTHENTICATED,async i=>{const o=i;await ge.identify(o.detail.sub)}),window.addEventListener(le.LOGOUT,async()=>{await ge.track("logout",{}),Pt.flush(),await ge.reset()})}function Jn(t){return JSON.stringify(t.map(e=>({...e,clientId:Et,requestId:Math.random().toString(36).slice(2,9),sessionId:Xi(),timestamp:new Date().toISOString(),version:Un,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:Dn,userAgent:navigator.userAgent,clientId:Et}})))}const Pt=Ci(async t=>{if(t.length>0){const e=Jn(t);Vn?navigator.sendBeacon(nt,e):(await fetch(nt,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function xt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(nt,Jn([n]))}else Pt.push(t)}const ge=ji({app:Dn,version:Un,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;xt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;xt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;xt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Fi(){return Vn=!0,Pt.flush()}const Hn=new Map;function Ji(t,e){Hn.set(t,e)}window.addEventListener("beforeunload",()=>{Hn.forEach((t,e)=>{t.bind(e)()}),Fi()});async function Hi(t){Vi({clientId:t.clientId,...t.analytics}),await Tr(t),Nr(t.namespace),B(le.READY,{})}const rt=document.getElementById("sesamy-js");if(rt!=null&&rt.textContent)try{const t=JSON.parse(rt.textContent);Hi(t)}catch(t){console.error("Failed to parse config",t)}const Yi="/sesamy.png";class Gi extends HTMLElement{constructor(){super();Q(this,"user")}async _handleProfile(){this.user=await window.sesamy.getUser(),this.render()}async connectedCallback(){if(this.setupEventListeners(),!window.sesamy){window.addEventListener(le.READY,()=>this._handleProfile());return}this._handleProfile()}render(){this.innerHTML=`
|
|
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",!Vt(n))throw new Error(`Invalid cache location "${n}"`);r=Vt(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?we:xr,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:Cr;var o;this.scope=Xe("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Or(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Dt,this.cacheManager=new Er(r,r.allKeys?void 0:new Ar(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 zr)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Lt)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${ft(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return Tr({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=Zt(ht()),o=Zt(ht()),a=ht(),s=(u=>{const c=new Uint8Array(u);return(f=>{const d={"+":"-","/":"_","=":""};return f.replace(/[+/=]/g,v=>d[v])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Me().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),p=((u,c,f,d,v,k,w,I)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),f),{scope:Xe(c,f.scope),response_type:"code",response_mode:I||"query",state:d,nonce:v,redirect_uri:w||u.authorizationParams.redirect_uri,code_challenge:k,code_challenge_method:"S256"}))(this.options,this.scope,e,i,o,s,e.redirect_uri||this.options.authorizationParams.redirect_uri||r,n==null?void 0:n.response_mode),m=this._authorizeUrl(p);return{nonce:o,code_verifier:a,scope:p.scope,audience:p.audience||"default",redirect_uri:p.redirect_uri,state:i,url:m}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const p=window.screenX+(window.innerWidth-400)/2,m=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${p},top=${m},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((p,m)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(f),window.removeEventListener("message",u,!1),m(new yr(s.popup)))},1e3),f=setTimeout(()=>{clearInterval(c),m(new gr(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 m(H.fromPayload(d.data.response));p(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 H("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=Yt(e),{openUrl:i,fragment:o,appState:a}=r,s=Z(r,["openUrl","fragment","appState"]),p=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,m=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=m,c=Z(m,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),p&&{organization:p}));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 H("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new mr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new H("state_mismatch","Invalid state");const p=s.organization,m=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:m,organization:p}),{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:Xe(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=mt[a];return s||(s=o().finally(()=>{delete mt[a],s=null}),mt[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=Z(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})(()=>gt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new dt;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const m=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(m)return m}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:p}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:p})}finally{await gt.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:Xe(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},pr),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new ce({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=Z(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${ft(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=Yt(e),{openUrl:r}=n,i=Z(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:p,scope:m,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new H("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((v,k,w=60)=>new Promise((I,_)=>{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",b,!1))};let b;const T=setTimeout(()=>{_(new dt),l()},1e3*w);b=function(x){if(x.origin!=k||!x.data||x.data.type!=="authorization_response")return;const j=x.source;j&&j.close(),x.data.response.error?_(H.fromPayload(x.data.response)):I(x.data.response),clearTimeout(T),window.removeEventListener("message",b,!1),setTimeout(l,2e3)},window.addEventListener("message",b,!1),window.document.body.appendChild(y),y.setAttribute("src",v)}))(i,this.domainUrl,c);if(o!==f.state)throw new H("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:p,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},d),{scope:m,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 ce({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 Ut(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=Z(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 ce({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 ce({scope:e,audience:n,clientId:r}),60);if(i&&i.access_token){const{access_token:o,oauthTokenScope:a,expires_in:s}=i,p=await this._getIdTokenFromCache();return p&&Object.assign(Object.assign({id_token:p.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await _r(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 Dr(t){const e=new Lr(t);return await e.checkSession(),e}const Gt="sesamy.com",Ur="https://logs.sesamy.com/events";var le=(t=>(t.READY="sesamyReady",t.AUTHENTICATED="sesamyAuthenticated",t.LOGOUT="sesamyLogout",t))(le||{});let X;async function Rr({clientId:t}){if(X=await Dr({domain:`token.${Gt}`,clientId:t,cacheLocation:"localstorage"}),window.location.search.includes("code="))try{await X.handleRedirectCallback();const e=await X.getUser();q(le.AUTHENTICATED,e),window.history.replaceState({},document.title,"/");const n=await X.getTokenSilently();localStorage.setItem("accessToken",n)}catch{}}async function Zr(){if(!X)throw new Error("Auth0 client not initialized");return X.isAuthenticated()}async function Wr(){if(!X)throw new Error("Auth0 client not initialized");return X.getUser()}function Kr(){if(!X)throw new Error("Auth0 client not initialized");return X.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function Mr(){if(!X)throw new Error("Auth0 client not initialized");return X.getTokenSilently()}async function Xr(){if(!X)throw new Error("Auth0 client not initialized");return q(le.LOGOUT,{}),X.logout({logoutParams:{returnTo:window.location.href}})}const Fr=(t,e)=>e.skipDedupe||e.method!=="GET",Jr=(t,e)=>e.method+"@"+t,Hr=t=>t.clone(),Vr=({skip:t=Fr,key:e=Jr,resolver:n=Hr}={})=>{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((p,m)=>{r.get(s).push([p,m])});try{return i(o,a).then(p=>(r.get(s).forEach(([m])=>m(n(p))),r.delete(s),p)).catch(p=>{throw r.get(s).forEach(([m,u])=>u(p)),r.delete(s),p})}catch(p){return r.delete(s),Promise.reject(p)}}},Yr=(t,e)=>t*e,Gr=t=>t&&t.ok,Br=({delayTimer:t=500,delayRamp:e=Yr,maxAttempts:n=10,until:r=Gr,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>p=>(m,u)=>{let c=0;if(s&&s(m,u))return p(m,u);const f=(d,v)=>Promise.resolve(r(d,v)).then(k=>k?d&&a?d:v?Promise.reject(v):d:(c++,!n||c<=n?new Promise(w=>{const I=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:v,url:m,options:u})).then((_={})=>{var y,l;w(p((y=_&&_.url)!==null&&y!==void 0?y:m,(l=_&&_.options)!==null&&l!==void 0?l:u))}):w(p(m,u))},I)}).then(f).catch(w=>{if(!o)throw w;return f(null,w)}):d&&a?d:Promise.reject(v||new Error("Number of attempts exceeded."))));return p(m,u).then(f).catch(d=>{if(!o)throw d;return f(null,d)})},qr="application/json",Bt="Content-Type",be=Symbol(),qt=Symbol();function Qt(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===Bt.toLowerCase()))===null||e===void 0?void 0:e[1]}function en(t){return/^application\/.*json.*/.test(t)}const de=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]=de(a,o,n):r[i]=o,r},{...t})},ke={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 Qr(t,e=!1){ke.options=e?t:de(ke.options,t)}function ei(t,e=!1){ke.polyfills=e?t:de(ke.polyfills,t)}function ti(t){ke.errorType=t}const ni=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class tn extends Error{}const ri=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:p}=t,m=new Map(o),u=de(i.options,r);let c=n;const f=ni(s)((y,l)=>(c=y,i.polyfill("fetch")(y,l)))(n,u),d=new Error,v=f.catch(y=>{throw{[be]:y}}).then(y=>{if(!y.ok){const l=new tn;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(b=>{var T;if(l.message=b,i.errorType==="json"||((T=y.headers.get("Content-Type"))===null||T===void 0?void 0:T.split(";")[0])==="application/json")try{l.json=JSON.parse(b)}catch{}throw l.text=b,l.status=y.status,l})}return y}),k=y=>y.catch(l=>{const b=l.hasOwnProperty(be),T=b?l[be]:l,x=(T==null?void 0:T.status)&&m.get(T.status)||m.get(T==null?void 0:T.name)||b&&m.has(be)&&m.get(be);if(x)return x(T,t);const j=m.get(qt);if(j)return j(T,t);throw T}),w=y=>l=>k(y?v.then(b=>b&&b[y]()).then(b=>l?l(b):b):v.then(b=>l?l(b):b)),I={_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 m.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(be,y)}},_=p.reduce((y,l)=>({...y,...typeof l.resolver=="function"?l.resolver(y):l.resolver}),I);return a.reduce((y,l)=>l(y,t),_)},ii={_url:"",_options:{},_config:ke,_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:de(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:de(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:de(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[Bt]: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(qt,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=Qt(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||en(i));return r=n?o?r.json(n,i):r.body(n):r,ri(r._deferred.reduce((a,s)=>s(a,a._url,a._options),r))},get(t=""){return this.fetch("GET",t)},delete(t=""){return this.fetch("DELETE",t)},put(t,e=""){return this.fetch("PUT",e,t)},post(t,e=""){return this.fetch("POST",e,t)},patch(t,e=""){return this.fetch("PATCH",e,t)},head(t=""){return this.fetch("HEAD",t)},opts(t=""){return this.fetch("OPTIONS",t)},body(t){return{...this,_options:{...this._options,body:t}}},json(t,e){const n=Qt(this._options.headers);return this.content(e||en(n)&&n||qr).body(JSON.stringify(t))}};function he(t="",e={}){return{...ii,_url:t,_options:e}}he.default=he,he.options=Qr,he.errorType=ti,he.polyfills=ei,he.WretchError=tn;const oi=t=>(e,n)=>new Promise(async(r,i)=>{try{const o=await Mr(),a={...n,headers:{...n.headers,Authorization:`Bearer ${o}`}};r(t(e,a))}catch(o){console.error("Error fetching access token:",o),i(o)}}),nn=he(`https://api2.${Gt}`).headers({"Content-Type":"application/json"}).middlewares([oi,Vr(),Br({delayTimer:1e3,delayRamp:(t,e)=>t*e,maxAttempts:3,until:t=>(t==null?void 0:t.ok)||!1,retryOnNetworkError:!1})]);async function ai(){return nn.get("/entitlements").json()}async function si(t){const e=await nn.get("/entitlements").json();return e==null?void 0:e.find(n=>n.id===t)}function ci(t="sesamy"){window[t]={getUser:Wr,getEntitlement:si,getEntitlements:ai,isAuthenticated:Zr,loginWithRedirect:Kr,logout:Xr}}function rn(t,e,n,r,i){for(e=e.split?e.split("."):e,r=0;r<e.length;r++)t=t?t[e[r]]:i;return t===i?n:t}var Fe="undefined",on="object",ui=function(){},an="any",sn="*",fe="__",Je=typeof process<"u"?process:{};Je.env&&Je.env.NODE_ENV;var V=typeof document<"u";Je.versions!=null&&Je.versions.node!=null,typeof Deno<"u"&&Deno.core,V&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function cn(t,e){return e.charAt(0)[t]()+e.slice(1)}var li=cn.bind(null,"toUpperCase"),di=cn.bind(null,"toLowerCase");function hi(t){return un(t)?li("null"):typeof t=="object"?gi(t):Object.prototype.toString.call(t).slice(8,-1)}function He(t,e){e===void 0&&(e=!0);var n=hi(t);return e?di(n):n}function ze(t,e){return typeof e===t}var Q=ze.bind(null,"function"),re=ze.bind(null,"string"),Ie=ze.bind(null,"undefined"),fi=ze.bind(null,"boolean");ze.bind(null,"symbol");function un(t){return t===null}function pi(t){return He(t)==="number"&&!isNaN(t)}function ln(t){return He(t)==="array"}function Y(t){if(!mi(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function mi(t){return t&&(typeof t=="object"||t!==null)}function gi(t){return Q(t.constructor)?t.constructor.name:null}function yi(t){return t instanceof Error||re(t.message)&&t.constructor&&pi(t.constructor.stackTraceLimit)}function dn(t,e){if(typeof e!="object"||un(e))return!1;if(e instanceof t)return!0;var n=He(new t(""));if(yi(e))for(;e;){if(He(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}dn.bind(null,TypeError),dn.bind(null,SyntaxError);function Ve(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?vi(t,e):n}function vi(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function Ye(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}Ye(Ve,"form"),Ye(Ve,"button"),Ye(Ve,"input"),Ye(Ve,"select");function wi(t){return t?ln(t)?t:[t]:[]}function hn(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function bi(){if(V){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function ki(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Ii(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=hn(n[1]),a=hn(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 p=s.split("[");p.length>1&&(_i(r,p.map(function(m){return m.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return V&&window.location.search.substring(1)}(t))}function _i(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 Ge(){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}var Ae="global",_e=fe+"global"+fe,Se=typeof self===on&&self.self===self&&self||typeof global===on&&global.global===global&&global||void 0;function pe(t){return Se[_e][t]}function me(t,e){return Se[_e][t]=e}function Ee(t){delete Se[_e][t]}function Oe(t,e,n){var r;try{if(yt(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Se[_e]||(Se[_e]={});var Be={};function yt(t){if(typeof Be[t]!==Fe)return Be[t];try{var e=window[t];e.setItem(Fe,Fe),e.removeItem(Fe)}catch{return Be[t]=!1}return Be[t]=!0}function E(){return E=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},E.apply(this,arguments)}var ie="function",ne="undefined",Si="@@redux/"+Math.random().toString(36),fn=function(){return typeof Symbol===ie&&Symbol.observable||"@@observable"}(),qe=" != "+ie;function pn(t,e,n){var r;if(typeof e===ie&&typeof n===ne&&(n=e,e=void 0),typeof n!==ne){if(typeof n!==ie)throw new Error("enhancer"+qe);return n(pn)(t,e)}if(typeof t!==ie)throw new Error("reducer"+qe);var i=t,o=e,a=[],s=a,p=!1;function m(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==ie)throw new Error("Listener"+qe);var v=!0;return m(),s.push(d),function(){if(v){v=!1,m();var k=s.indexOf(d);s.splice(k,1)}}}function f(d){if(!Y(d))throw new Error("Act != obj");if(typeof d.type===ne)throw new Error("ActType "+ne);if(p)throw new Error("Dispatch in reducer");try{p=!0,o=i(o,d)}finally{p=!1}for(var v=a=s,k=0;k<v.length;k++)(0,v[k])();return d}return f({type:"@@redux/INIT"}),(r={dispatch:f,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ie)throw new Error("next reducer"+qe);i=d,f({type:"@@redux/INIT"})}})[fn]=function(){var d,v=c;return(d={subscribe:function(k){if(typeof k!="object")throw new TypeError("Observer != obj");function w(){k.next&&k.next(u())}return w(),{unsubscribe:v(w)}}})[fn]=function(){return this},d},r}function Ei(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+ne}function Pe(){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 Oi(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,p={getState:a.getState,dispatch:function(m){return s(m)}};return o=[].slice.call(t).map(function(m){return m(p)}),E({},a,{dispatch:s=Pe.apply(void 0,o)(a.dispatch)})}}}var oe=fe+"anon_id",ge=fe+"user_id",Te=fe+"user_traits",ae="userId",je="anonymousId",Qe=["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"],vt=["name","EVENTS","config","loaded"],O=Qe.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),mn=/^utm_/,gn=/^an_prop_/,yn=/^an_trait_/;function Pi(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===O.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,p=i.initialUser,m=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(oe,a.anonymousId),m||e(ge,a.userId),p.traits&&e(Te,E({},m&&s.traits?s.traits:{},p.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,f=o.an_event,d=u.reduce(function(v,k){if(k.match(mn)||k.match(/^(d|g)clid/)){var w=k.replace(mn,"");v.campaign[w==="campaign"?"name":w]=o[k]}return k.match(gn)&&(v.props[k.replace(gn,"")]=o[k]),k.match(yn)&&(v.traits[k.replace(yn,"")]=o[k]),v},{campaign:{},props:{},traits:{}});n.dispatch(E({type:O.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:O.campaign,campaign:d.campaign})}}return r(i)}}}}function Ti(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===O.setItemEnd){if(n.key===oe)return E({},e,{anonymousId:n.value});if(n.key===ge)return E({},e,{userId:n.value})}switch(n.type){case O.identify:return Object.assign({},e,{userId:n.userId,traits:E({},e.traits,n.traits)});case O.reset:return[ge,oe,Te].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function vn(t){return{userId:t.getItem(ge),anonymousId:t.getItem(oe),traits:t.getItem(Te)}}var wt=function(t){return fe+"TEMP"+fe+t};function ji(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var p=s.userId,m=s.traits,u=s.options;if(s.type===O.reset&&([ge,Te,oe].forEach(function(d){r(d)}),[ae,je,"traits"].forEach(function(d){Ee(wt(d))})),s.type===O.identify){i(oe)||n(oe,Ge());var c=i(ge),f=i(Te)||{};c&&c!==p&&o.dispatch({type:O.userIdChanged,old:{userId:c,traits:f},new:{userId:p,traits:m},options:u}),p&&n(ge,p),m&&n(Te,E({},f,m))}return a(s)}}}}var Ne={};function wn(t,e){Ne[t]&&Q(Ne[t])&&(Ne[t](e),delete Ne[t])}function bn(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(E({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return bn(t,e,n-10).then(r,i)})})}function kn(t,e,n){var r=e(),i=t.getState(),o=i.plugins,a=i.queue,s=i.user;if(!i.context.offline&&a&&a.actions&&a.actions.length){var p=a.actions.reduce(function(u,c,f){return o[c.plugin].loaded?(u.process.push(c),u.processIndex.push(f)):(u.requeue.push(c),u.requeueIndex.push(f)),u},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(p.processIndex&&p.processIndex.length){p.processIndex.forEach(function(u){var c=a.actions[u],f=c.plugin,d=c.payload.type,v=r[f][d];if(v&&Q(v)){var k=function(I,_){return I===void 0&&(I={}),_===void 0&&(_={}),[ae,je].reduce(function(y,l){return I.hasOwnProperty(l)&&_[l]&&_[l]!==I[l]&&(y[l]=_[l]),y},I)}(c.payload,s);v({payload:k,config:o[f].config,instance:n});var w=d+":"+f;t.dispatch(E({},k,{type:w,_:{called:w,from:"queueDrain"}}))}});var m=a.actions.filter(function(u,c){return!~p.processIndex.indexOf(c)});a.actions=m}}}var bt=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,p=t.EVENTS;try{var m=i.plugins,u=i.context,c=n.type,f=c.match(xe),d=e.exact.map(function(w){return w.pluginName});f&&(d=a.during.map(function(w){return w.pluginName}));var v=function(w,I){return function(_,y,l){var b=y.config,T=y.name,x=T+"."+_.type;l&&(x=l.event);var j=_.type.match(xe)?function(D,L,G,U,B){return function(W,P){var M=U?U.name:D,F=P&&Le(P)?P:G;if(U&&(!(F=P&&Le(P)?P:[D]).includes(D)||F.length!==1))throw new Error("Method "+L+" can only abort "+D+" plugin. "+JSON.stringify(F)+" input valid");return E({},B,{abort:{reason:W,plugins:F,caller:L,_:M}})}}(T,x,I,l,_):function(D,L){return function(){throw new Error(D.type+" action not cancellable. Remove abort in "+L)}}(_,x);return{payload:xi(_),instance:w,config:b||{},abort:j}}}(r,d),k=e.exact.reduce(function(w,I){var _=I.pluginName,y=I.methodName,l=!1;return y.match(/^initialize/)||y.match(/^reset/)||(l=!m[_].loaded),u.offline&&y.match(/^(page|track|identify)/)&&(l=!0),w[""+_]=l,w},{});return Promise.resolve(e.exact.reduce(function(w,I,_){try{var y=I.pluginName;return Promise.resolve(w).then(function(l){function b(){return Promise.resolve(l)}var T=function(){if(e.namespaced&&e.namespaced[y])return Promise.resolve(e.namespaced[y].reduce(function(x,j,D){try{return Promise.resolve(x).then(function(L){return j.method&&Q(j.method)?(function(W,P){var M=jn(W);if(M&&M.name===P){var F=jn(M.method);throw new Error([P+" plugin is calling method "+W,"Plugins cant call self","Use "+M.method+" "+(F?"or "+F.method:"")+" in "+P+" plugin insteadof "+W].join(`
|
|
6
|
+
`))}}(j.methodName,j.pluginName),Promise.resolve(j.method({payload:L,instance:r,abort:(G=L,U=y,B=j.pluginName,function(W,P){return E({},G,{abort:{reason:W,plugins:P||[U],caller:c,from:B||U}})}),config:Sn(j.pluginName,m,o),plugins:m})).then(function(W){var P=Y(W)?W:{};return Promise.resolve(E({},L,P))})):L;var G,U,B})}catch(L){return Promise.reject(L)}},Promise.resolve(n))).then(function(x){l[y]=x});l[y]=n}();return T&&T.then?T.then(b):b()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(w){return Promise.resolve(e.exact.reduce(function(I,_,y){try{var l=e.exact.length===y+1,b=_.pluginName,T=o[b];return Promise.resolve(I).then(function(x){var j=w[b]?w[b]:{};if(f&&(j=x),It(j,b))return kt({data:j,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(x);if(It(x,b))return l&&kt({data:x,method:c,instance:r,store:s}),Promise.resolve(x);if(k.hasOwnProperty(b)&&k[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:j,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(x);var D=v(w[b],o[b]);return Promise.resolve(T[c]({abort:D.abort,payload:j,instance:r,config:Sn(b,m,o),plugins:m})).then(function(L){var G=Y(L)?L:{},U=E({},x,G),B=w[b];if(It(B,b))kt({data:B,method:c,instance:r,pluginName:b,store:s});else{var W=c+":"+b;(W.match(/:/g)||[]).length<2&&!c.match(In)&&!c.match(_n)&&r.dispatch(E({},f?U:j,{type:W,_:{called:W,from:"submethod"}}))}return Promise.resolve(U)})})}catch(x){return Promise.reject(x)}},Promise.resolve(n))).then(function(I){if(!(c.match(xe)||c.match(/^registerPlugin/)||c.match(_n)||c.match(In)||c.match(/^params/)||c.match(/^userIdChanged/))){if(p.plugins.includes(c),I._&&I._.originalAction===c)return I;var _=E({},I,{_:{originalAction:I.type,called:I.type,from:"engineEnd"}});Pn(I,e.exact.length)&&!c.match(/End$/)&&(_=E({},_,{type:I.type+"Aborted"})),s.dispatch(_)}return I})})}catch(w){return Promise.reject(w)}},xe=/Start$/,In=/^bootstrap/,_n=/^ready/;function kt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(E({},t.data,{type:n,_:{called:n,from:"abort"}}))}function Sn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function En(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function On(t,e){var n=t.replace(xe,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function It(t,e){var n=t.abort;return!!n&&(n===!0||Tn(n,e)||n&&Tn(n.plugins,e))}function Pn(t,e){var n=t.abort;if(!n)return!1;if(n===!0||re(n))return!0;var r=n.plugins;return Le(n)&&n.length===e||Le(r)&&r.length===e}function Le(t){return Array.isArray(t)}function Tn(t,e){return!(!t||!Le(t))&&t.includes(e)}function jn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function xi(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=Y(t[n])?Object.assign({},t[n]):t[n]),e},{})}function Ci(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,p=function(l){return s?l:o(c)},m=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(m===O.enablePlugin&&i.dispatch({type:O.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),m===O.disablePlugin&&setTimeout(function(){return wn(a.meta.rid,{payload:a})},0),m===O.initializeEnd){var f=e(),d=Object.keys(f),v=d.filter(function(l){return u.includes(l)}).map(function(l){return f[l]}),k=[],w=[],I=a.disabled,_=v.map(function(l){var b=l.loaded,T=l.name,x=l.config;return bn(l,function(){return b({config:x})},1e4).then(function(j){return r[T]||(i.dispatch({type:O.pluginReadyType(T),name:T,events:Object.keys(l).filter(function(D){return!vt.includes(D)})}),r[T]=!0),k=k.concat(T),l}).catch(function(j){if(j instanceof Error)throw new Error(j);return w=w.concat(j.name),j})});Promise.all(_).then(function(l){var b={plugins:k,failed:w,disabled:I};setTimeout(function(){d.length===_.length+I.length&&i.dispatch(E({},{type:O.ready},b))},0)})}var y=function(){if(m!==O.bootstrap)return/^ready:([^:]*)$/.test(m)&&setTimeout(function(){return kn(i,e,t)},0),Promise.resolve(function(l,b,T,x,j){try{var D=Q(b)?b():b,L=l.type,G=L.replace(xe,"");if(l._&&l._.called)return Promise.resolve(l);var U=T.getState(),B=(M=D,(F=U.plugins)===void 0&&(F={}),(We=l.options)===void 0&&(We={}),Object.keys(M).filter(function(h){var g=We.plugins||{};return fi(g[h])?g[h]:g.all!==!1&&(!F[h]||F[h].enabled!==!1)}).map(function(h){return M[h]}));L===O.initializeStart&&l.fromEnable&&(B=Object.keys(U.plugins).filter(function(h){var g=U.plugins[h];return l.plugins.includes(h)&&!g.initialized}).map(function(h){return D[h]}));var W=B.map(function(h){return h.name}),P=function(h,g,S){var C=On(h).map(function($){return En($,g)});return g.reduce(function($,z){var K=z.name,N=On(h,K).map(function(Ke){return En(Ke,g)}),R=N[0],A=N[1],te=N[2];return R.length&&($.beforeNS[K]=R),A.length&&($.duringNS[K]=A),te.length&&($.afterNS[K]=te),$},{before:C[0],beforeNS:{},during:C[1],duringNS:{},after:C[2],afterNS:{}})}(L,B);return Promise.resolve(bt({action:l,data:{exact:P.before,namespaced:P.beforeNS},state:U,allPlugins:D,allMatches:P,instance:T,store:x,EVENTS:j})).then(function(h){function g(){var $=function(){if(L.match(xe))return Promise.resolve(bt({action:E({},S,{type:G+"End"}),data:{exact:P.after,namespaced:P.afterNS},state:U,allPlugins:D,allMatches:P,instance:T,store:x,EVENTS:j})).then(function(z){z.meta&&z.meta.hasCallback&&wn(z.meta.rid,{payload:z})})}();return $&&$.then?$.then(function(){return h}):h}if(Pn(h,W.length))return h;var S,C=function(){if(L!==G)return Promise.resolve(bt({action:E({},h,{type:G}),data:{exact:P.during,namespaced:P.duringNS},state:U,allPlugins:D,allMatches:P,instance:T,store:x,EVENTS:j})).then(function($){S=$});S=h}();return C&&C.then?C.then(g):g()})}catch(h){return Promise.reject(h)}var M,F,We}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(y&&y.then?y.then(p):p(y))}catch(l){return Promise.reject(l)}}}}}function $i(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===O.setItem||i===O.removeItem){if(r.abort)return n(r);i===O.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var zi=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 Pe.apply(void 0,a)(r)(i)}}}}};function Ai(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},E({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var p=xn(n.type,O.initialize),m=t()[p];return m&&p?(r[p]=E({},e[p],{initialized:!0,loaded:!!m.loaded({config:m.config})}),E({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=E({},e[n.name],{loaded:!0}),E({},e,r);switch(n.type){case O.disablePlugin:return E({},e,Cn(n.plugins,!1,e));case O.enablePlugin:return E({},e,Cn(n.plugins,!0,e));default:return e}}}function xn(t,e){return t.substring(e.length+1,t.length)}function Cn(t,e,n){return t.reduce(function(r,i){return r[i]=E({},n[i],{enabled:e}),r},n)}function $n(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var Ni={last:{},history:[]};function Li(t,e){t===void 0&&(t=Ni);var n=e.options,r=e.meta;if(e.type===O.track){var i=$n(E({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return E({},t,{last:i,history:t.history.concat(i)})}return t}var Di={actions:[]};function Ui(t,e){t===void 0&&(t=Di);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===O.identify?[e].concat(t.actions):t.actions.concat(e),E({},t,{actions:r});case"dequeue":return[];default:return t}}var zn=/#.*$/;function Ri(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(zn,""):"")}var An,Nn,Ln,Dn,Zi=function(t){if(t===void 0&&(t={}),!V)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,p=o.hash,m=o.search,u=function(f){var d=function(){if(V){for(var v,k=document.getElementsByTagName("link"),w=0;v=k[w];w++)if(v.getAttribute("rel")==="canonical")return v.getAttribute("href")}}();return d?d.match(/\?/)?d:d+f:window.location.href.replace(zn,"")}(m),c={title:n,url:u,path:Ri(u),hash:p,search:m,width:a,height:s};return r&&r!==""&&(c.referrer=r),E({},c,t)},Wi={last:{},history:[]};function Ki(t,e){t===void 0&&(t=Wi);var n=e.options;if(e.type===O.page){var r=$n(E({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return E({},t,{last:r,history:t.history.concat(r)})}return t}An=function(){if(!V)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"}(),Nn=V?document.referrer:null,Ln=bi(),Dn=ki();var Un={initialized:!1,sessionId:Ge(),app:null,version:null,debug:!1,offline:!!V&&!navigator.onLine,os:{name:An},userAgent:V?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.5"},timezone:Dn,locale:Ln,campaign:{},referrer:Nn};function Mi(t,e){t===void 0&&(t=Un);var n=t.initialized,r=e.campaign;switch(e.type){case O.campaign:return E({},t,{campaign:r});case O.offline:return E({},t,{offline:!0});case O.online:return E({},t,{offline:!1});default:return n?t:E({},Un,t,{initialized:!0})}}var Xi=["plugins","reducers","storage"];function Fi(t,e,n){if(V){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function Ji(t){var e=Fi.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function Rn(){return me("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 Se[_e].analytics.push(a.action||a),o(a)}})}}}function Zn(t){return function(){return Pe(Pe.apply(null,arguments),Rn())}}function _t(t){return t?ln(t)?t:[t]:[]}function Wn(t,e,n){t===void 0&&(t={});var r,i,o=Ge();return e&&(Ne[o]=(r=e,i=function(a){for(var s,p=a||Array.prototype.slice.call(arguments),m=0;m<p.length;m++)if(Q(p[m])){s=p[m];break}return s}(n),function(a){i&&i(a),r(a)})),E({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function Hi(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(h,g){if(Q(g))return h.middlewares=h.middlewares.concat(g),h;if(g.NAMESPACE&&(g.name=g.NAMESPACE),!g.name)throw new Error("https://lytics.dev/errors/1");g.config||(g.config={});var S=g.EVENTS?Object.keys(g.EVENTS).map(function(z){return g.EVENTS[z]}):[];h.pluginEnabled[g.name]=!(g.enabled===!1||g.config.enabled===!1),delete g.enabled,g.methods&&(h.methods[g.name]=Object.keys(g.methods).reduce(function(z,K){var N;return z[K]=(N=g.methods[K],function(){for(var R=Array.prototype.slice.call(arguments),A=new Array(N.length),te=0;te<R.length;te++)A[te]=R[te];return A[A.length]=b,N.apply({instance:b},A)}),z},{}),delete g.methods);var C=Object.keys(g).concat(S),$=new Set(h.events.concat(C));if(h.events=Array.from($),h.pluginsArray=h.pluginsArray.concat(g),h.plugins[g.name])throw new Error(g.name+"AlreadyLoaded");return h.plugins[g.name]=g,h.plugins[g.name].loaded||(h.plugins[g.name].loaded=function(){return!0}),h},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:pe,setItem:me,removeItem:Ee},o=function(h){return function(g,S,C){return S.getState("user")[g]||(C&&Y(C)&&C[g]?C[g]:vn(h)[g]||pe(wt(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(h){return!vt.includes(h)}).sort(),p=new Set(s.concat(Qe).filter(function(h){return!vt.includes(h)})),m=Array.from(p).sort(),u=function(){return a},c=new zi,f=c.addMiddleware,d=c.removeMiddleware,v=c.dynamicMiddlewares,k=function(){throw new Error("Abort disabled inListener")},w=Ii(),I=vn(i),_=E({},I,n,w.an_uid?{userId:w.an_uid}:{},w.an_aid?{anonymousId:w.an_aid}:{});_.anonymousId||(_.anonymousId=Ge());var y=E({enable:function(h,g){return new Promise(function(S){P.dispatch({type:O.enablePlugin,plugins:_t(h),_:{originalAction:O.enablePlugin}},S,[g])})},disable:function(h,g){return new Promise(function(S){P.dispatch({type:O.disablePlugin,plugins:_t(h),_:{originalAction:O.disablePlugin}},S,[g])})}},r.methods),l=!1,b={identify:function(h,g,S,C){try{var $=re(h)?h:null,z=Y(h)?h:g,K=S||{},N=b.user();me(wt(ae),$);var R=$||z.userId||o(ae,b,z);return Promise.resolve(new Promise(function(A){P.dispatch(E({type:O.identifyStart,userId:R,traits:z||{},options:K,anonymousId:N.anonymousId},N.id&&N.id!==$&&{previousId:N.id}),A,[g,S,C])}))}catch(A){return Promise.reject(A)}},track:function(h,g,S,C){try{var $=Y(h)?h.event:h;if(!$||!re($))throw new Error("EventMissing");var z=Y(h)?h:g||{},K=Y(S)?S:{};return Promise.resolve(new Promise(function(N){P.dispatch({type:O.trackStart,event:$,properties:z,options:K,userId:o(ae,b,g),anonymousId:o(je,b,g)},N,[g,S,C])}))}catch(N){return Promise.reject(N)}},page:function(h,g,S){try{var C=Y(h)?h:{},$=Y(g)?g:{};return Promise.resolve(new Promise(function(z){P.dispatch({type:O.pageStart,properties:Zi(C),options:$,userId:o(ae,b,C),anonymousId:o(je,b,C)},z,[h,g,S])}))}catch(z){return Promise.reject(z)}},user:function(h){if(h===ae||h==="id")return o(ae,b);if(h===je||h==="anonId")return o(je,b);var g=b.getState("user");return h?rn(g,h):g},reset:function(h){return new Promise(function(g){P.dispatch({type:O.resetStart},g,h)})},ready:function(h){return l&&h({plugins:y,instance:b}),b.on(O.ready,function(g){h(g),l=!0})},on:function(h,g){if(!h||!Q(g))return!1;if(h===O.bootstrap)throw new Error(".on disabled for "+h);var S=/Start$|Start:/;if(h==="*"){var C=function(N){return function(R){return function(A){return A.type.match(S)&&g({payload:A,instance:b,plugins:a}),R(A)}}},$=function(N){return function(R){return function(A){return A.type.match(S)||g({payload:A,instance:b,plugins:a}),R(A)}}};return f(C,et),f($,tt),function(){d(C,et),d($,tt)}}var z=h.match(S)?et:tt,K=function(N){return function(R){return function(A){return A.type===h&&g({payload:A,instance:b,plugins:a,abort:k}),R(A)}}};return f(K,z),function(){return d(K,z)}},once:function(h,g){if(!h||!Q(g))return!1;if(h===O.bootstrap)throw new Error(".once disabled for "+h);var S=b.on(h,function(C){g({payload:C.payload,instance:b,plugins:a,abort:k}),S()});return S},getState:function(h){var g=P.getState();return h?rn(g,h):Object.assign({},g)},dispatch:function(h){var g=re(h)?{type:h}:h;if(Qe.includes(g.type))throw new Error("reserved action "+g.type);var S=E({},g,{_:E({originalAction:g.type},h._||{})});P.dispatch(S)},enablePlugin:y.enable,disablePlugin:y.disable,plugins:y,storage:{getItem:i.getItem,setItem:function(h,g,S){P.dispatch({type:O.setItemStart,key:h,value:g,options:S})},removeItem:function(h,g){P.dispatch({type:O.removeItemStart,key:h,options:g})}},setAnonymousId:function(h,g){b.storage.setItem(oe,h,g)},events:{core:Qe,plugins:s}},T=r.middlewares.concat([function(h){return function(g){return function(S){return S.meta||(S.meta=Wn()),g(S)}}},v(et),Ci(b,u,{all:m,plugins:s}),$i(i),Pi(b),ji(b),v(tt)]),x={context:Mi,user:Ti(i),page:Ki,track:Li,plugins:Ai(u),queue:Ui},j=Pe,D=Pe;if(V&&t.debug){var L=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;L&&(j=L({trace:!0,traceLimit:25})),D=function(){return arguments.length===0?Rn():Y(typeof arguments[0])?Zn():Zn().apply(null,arguments)}}var G,U=function(h){return Object.keys(h).reduce(function(g,S){return Xi.includes(S)||(g[S]=h[S]),g},{})}(t),B=r.pluginsArray.reduce(function(h,g){var S=g.name,C=g.config,$=g.loaded,z=r.pluginEnabled[S];return h[S]={enabled:z,initialized:!!z&&!g.initialize,loaded:!!$({config:C}),config:C},h},{}),W={context:U,user:_,plugins:B},P=pn(function(h){for(var g=Object.keys(h),S={},C=0;C<g.length;C++){var $=g[C];typeof h[$]===ie&&(S[$]=h[$])}var z,K=Object.keys(S);try{(function(N){Object.keys(N).forEach(function(R){var A=N[R];if(typeof A(void 0,{type:"@@redux/INIT"})===ne||typeof A(void 0,{type:Si})===ne)throw new Error("reducer "+R+" "+ne)})})(S)}catch(N){z=N}return function(N,R){if(N===void 0&&(N={}),z)throw z;for(var A=!1,te={},Ke=0;Ke<K.length;Ke++){var ct=K[Ke],ar=N[ct],zt=(0,S[ct])(ar,R);if(typeof zt===ne){var Oo=Ei(ct,R);throw new Error(Oo)}te[ct]=zt,A=A||zt!==ar}return A?te:N}}(E({},x,e)),W,D(j(Oi.apply(void 0,T))));P.dispatch=(G=P.dispatch,function(h,g,S){var C=E({},h,{meta:Wn(h.meta,g,_t(S))});return G.apply(null,[C])});var M=Object.keys(a);P.dispatch({type:O.bootstrap,plugins:M,config:U,params:w,user:_,initialUser:n,persistedUser:I});var F=M.filter(function(h){return r.pluginEnabled[h]}),We=M.filter(function(h){return!r.pluginEnabled[h]});return P.dispatch({type:O.registerPlugins,plugins:M,enabled:r.pluginEnabled}),r.pluginsArray.map(function(h,g){var S=h.bootstrap,C=h.config,$=h.name;S&&Q(S)&&S({instance:b,config:C,payload:h}),P.dispatch({type:O.registerPluginType($),name:$,enabled:r.pluginEnabled[$],plugin:h}),r.pluginsArray.length===g+1&&P.dispatch({type:O.initializeStart,plugins:F,disabled:We})}),Ji(function(h){P.dispatch({type:h?O.offline:O.online})}),function(h,g,S){setInterval(function(){return kn(h,g,S)},3e3)}(P,u,b),b}var et="before",tt="after",De="cookie",ye=Xn(),Kn=nt,Vi=nt;function Mn(t){return ye?nt(t,"",-1):Ee(t)}function Xn(){if(ye!==void 0)return ye;var t="cookiecookie";try{nt(t,t),ye=document.cookie.indexOf(t)!==-1,Mn(t)}catch{ye=!1}return ye}function nt(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return ye===!1&&(a?me(t,e):pe(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 Ue="localStorage",Yi=yt.bind(null,"localStorage");Oe("localStorage","getItem",pe),Oe("localStorage","setItem",me),Oe("localStorage","removeItem",Ee);var Re="sessionStorage",Gi=yt.bind(null,"sessionStorage");Oe("sessionStorage","getItem",pe),Oe("sessionStorage","setItem",me),Oe("sessionStorage","removeItem",Ee);function Ce(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(Y(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var Bi=Yi(),qi=Gi(),Qi=Xn();function Fn(t,e){if(t){var n=St(e),r=!Tt(n),i=Et(n)?Ce(localStorage.getItem(t)):void 0;if(r&&!Ie(i))return i;var o=Ot(n)?Ce(Kn(t)):void 0;if(r&&o)return o;var a=Pt(n)?Ce(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=pe(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function eo(t,e,n){if(t&&!Ie(e)){var r={},i=St(n),o=JSON.stringify(e),a=!Tt(i);return Et(i)&&(r[Ue]=it(Ue,e,Ce(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Ue]:Ot(i)&&(r[De]=it(De,e,Ce(Kn(t))),Vi(t,o),a)?r[De]:Pt(i)&&(r[Re]=it(Re,e,Ce(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Re]:(r[Ae]=it(Ae,e,pe(t)),me(t,e),a?r[Ae]:r)}}function to(t,e){if(t){var n=St(e),r=Fn(t,sn),i={};return!Ie(r.localStorage)&&Et(n)&&(localStorage.removeItem(t),i[Ue]=r.localStorage),!Ie(r.cookie)&&Ot(n)&&(Mn(t),i[De]=r.cookie),!Ie(r.sessionStorage)&&Pt(n)&&(sessionStorage.removeItem(t),i[Re]=r.sessionStorage),!Ie(r.global)&&rt(n,Ae)&&(Ee(t),i[Ae]=r.global),i}}function St(t){return t?re(t)?t:t.storage:an}function Et(t){return Bi&&rt(t,Ue)}function Ot(t){return Qi&&rt(t,De)}function Pt(t){return qi&&rt(t,Re)}function Tt(t){return t===sn||t==="all"}function rt(t,e){return t===an||t===e||Tt(t)}function it(t,e,n){return{location:t,current:e,previous:n}}var no={setItem:eo,getItem:Fn,removeItem:to};function ro(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Jn(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 Hn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Jn(Object(n),!0).forEach(function(r){ro(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Jn(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function io(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:no};return Hi(Hn(Hn({},e),t))}function oo(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(p){return r=i.push(p),r>=o&&a(),r},size:function(){return i.length},end:function(p){p&&a(),clearInterval(n)}}}const Vn="@sesamy/sesamy-js",Yn="1.0.3";function ao(t){if(!(typeof window>"u")){var e=window,n=e.addEventListener,r=e.history,i=e.location,o=i.pathname;n("popstate",function(){return t(i.pathname)}),["push","replace"].map(function(a){var s="".concat(a,"State"),p=r[s];r[s]=function(){var m=arguments,u=co(arguments[2]);return o!==u&&(o=u,setTimeout(function(){return t(m[2])},0)),p.apply(r,arguments)}})}}function so(t,e){var n=t.indexOf(e);return n>-1?t.slice(0,n):t}function co(t){return["#","?"].forEach(function(e){return t=so(t,e)}),t}function uo(){ao(()=>{ve.page()})}var Gn="EventListener";function lo(t){return function(e,n,r,i){var o=r||ui,a=i||!1;if(!V)return o;var s=ot(n),p=ot(e,!0);if(!p.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var m=[];return function u(c){c&&(m=[]);for(var f=c?"add"+Gn:"remove"+Gn,d=0;d<p.length;d++){var v=p[d];m[d]=c?a&&a.once?ho(o):o:m[d]||o;for(var k=0;k<s.length;k++)v[f]?v["on"+s[k]]=c?m[d]:null:v[f](s[k],m[d],a)}return u.bind(null,!c)}(t)}}function ot(t,e){if(re(t))return e?ot(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=wi(t);return e?o.map(function(a){return re(a)?ot(a,!0):a}).flat():o}function ho(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var jt=lo("Event");function Bn(t,e){return V&&Q(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),Q(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}Bn.bind(null,"onerror"),Bn.bind(null,"onload");var qn=typeof window>"u",Qn="hidden";function fo(t){if(qn)return!1;var e=po(),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 po(){var t=["webkit","moz","ms","o"];return qn||Qn in document?Qn: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 go(t,e){e===void 0&&(e={});var n=function(a,s){var p=this,m=!1;return function(u){m||(a.call(p,u),m=!0,setTimeout(function(){return m=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=fo(function(s){s||n({type:"tabVisible"})});return r=[a].concat(mo.map(function(s){return jt(document,s,n)})).concat(jt(window,"load",n)).concat(jt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function yo(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,p=t.throttle,m=p===void 0?2e3:p,u=!1,c=!1,f=new Date,d=function(){return clearTimeout(e)};function v(w){d(),o&&!u&&o(Ze(f),w),i&&u&&(u=!1,i(Ze(n),w),f=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(Ze(f),w))},s)}var k=go(v,{throttle:m});return{disable:function(){c=!0,u=!1,d();var w=k();return function(){return c=!1,f=new Date,v({type:"load"}),w()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:Ze(f,c),idle:u?Ze(n,c):0}}}}function Ze(t,e){return e?0:Math.round((new Date-t)/1e3)}const er=5e3;class vo{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");this.element=e.element,this.viewCallback=e.viewCallback,this.activeDurationCallback=e.activeDurationCallback,this.idleDurationCallback=e.idleDurationCallback,this.observer=new IntersectionObserver(n=>{n.forEach(r=>{this.handleInViewPort(r.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),yo({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:er})}flush(){this.isFlushing=!0,this.handleAwake(!this.isAwake,Math.round((Date.now()-this.lastEventAt)/1e3))}handleInViewPort(e){e?(this.isAwake=!0,this.trackInViewport()):this.handleAwake(!1,Math.round((Date.now()-this.lastEventAt)/1e3)),this.isInViewport=e}handleAwake(e,n){this.isAwake=e,this.lastEventAt=e?Date.now()-n*er:Date.now(),this.isInViewport&&this.trackAwake(e,n)}trackAwake(e,n){!e&&this.activeDurationCallback&&this.activeDurationCallback(n,this.isFlushing),e&&this.idleDurationCallback&&this.idleDurationCallback(n,this.isFlushing)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}const tr="sesamy_session_id";function wo(){let t=sessionStorage.getItem(tr);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(tr,t)),t}let nr=!1,xt,rr,at;function bo({clientId:t,enabled:e=!0,endpoint:n=Ur}){if(xt=t,rr=e,at=n,!rr)return;uo();const r=new vo({element:document.body,viewCallback:()=>{ve.page()},activeDurationCallback:(i,o)=>{ve.track("activeDuration",{duration:i,flushing:o})},idleDurationCallback:(i,o)=>{ve.track("idleDuration",{duration:i,flushing:o})}});Io(document.body,()=>{r.flush()}),window.addEventListener(le.AUTHENTICATED,async i=>{const o=i;await ve.identify(o.detail.sub)}),window.addEventListener(le.LOGOUT,async()=>{await ve.track("logout",{}),Ct.flush(),await ve.reset()})}function ir(t){return JSON.stringify(t.map(e=>({...e,clientId:xt,requestId:Math.random().toString(36).slice(2,9),sessionId:wo(),timestamp:new Date().toISOString(),version:Yn,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:Vn,userAgent:navigator.userAgent,clientId:xt}})))}const Ct=oo(async t=>{if(t.length>0){const e=ir(t);nr?navigator.sendBeacon(at,e):(await fetch(at,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function $t(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(at,ir([n]))}else Ct.push(t)}const ve=io({app:Vn,version:Yn,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;$t({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;$t({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;$t({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function ko(){return nr=!0,Ct.flush()}const or=new Map;function Io(t,e){or.set(t,e)}window.addEventListener("beforeunload",()=>{or.forEach((t,e)=>{t.bind(e)()}),ko()});async function _o(t){bo({clientId:t.clientId,...t.analytics}),await Rr(t),ci(t.namespace),q(le.READY,{})}const st=document.getElementById("sesamy-js");if(st!=null&&st.textContent)try{const t=JSON.parse(st.textContent);_o(t)}catch(t){console.error("Failed to parse config",t)}const So="/sesamy.png";class Eo extends HTMLElement{constructor(){super();ee(this,"user")}async _handleProfile(){this.user=await window.sesamy.getUser(),this.render()}async connectedCallback(){if(this.setupEventListeners(),!window.sesamy){window.addEventListener(le.READY,()=>this._handleProfile());return}this._handleProfile()}render(){this.innerHTML=`
|
|
6
7
|
<div>
|
|
7
8
|
<a href="https://docs.sesamy.com" target="_blank">
|
|
8
|
-
<img src="${
|
|
9
|
+
<img src="${So}" class="logo" alt="Vite logo" />
|
|
9
10
|
</a>
|
|
10
11
|
<h1>Sesamy JS</h1>
|
|
11
12
|
<p class="read-the-docs">
|
|
@@ -27,4 +28,9 @@
|
|
|
27
28
|
<div class="logout-wrap">
|
|
28
29
|
<a href="#" class="logout-btn" id="logout-btn"> Logout </a>
|
|
29
30
|
</div>
|
|
30
|
-
|
|
31
|
+
<div>
|
|
32
|
+
<a href="/entitlements.html">
|
|
33
|
+
View Entitlements
|
|
34
|
+
</a>
|
|
35
|
+
</div>
|
|
36
|
+
</div>`}setupEventListeners(){this.addEventListener("click",n=>{const r=n.target,i=r.closest("#logout-btn"),o=r.closest("#login-btn");i&&window.sesamy.logout(),o&&window.sesamy.loginWithRedirect()})}}customElements.define("sesamy-app",Eo)});
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"registry": "https://registry.npmjs.org/",
|
|
7
7
|
"tag": "latest"
|
|
8
8
|
},
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.4",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"files": [
|
|
12
12
|
"dist/sesamy-js.es.js",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"@analytics/scroll-utils": "^0.1.22",
|
|
69
69
|
"@auth0/auth0-spa-js": "^2.1.3",
|
|
70
70
|
"analytics": "^0.8.9",
|
|
71
|
-
"saturated": "^1.0.0"
|
|
71
|
+
"saturated": "^1.0.0",
|
|
72
|
+
"wretch": "^2.8.0"
|
|
72
73
|
}
|
|
73
74
|
}
|