@sesamy/sesamy-js 1.3.10 → 1.3.12
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 +10 -2
- package/dist/sesamy-js.cjs +5 -5
- package/dist/sesamy-js.d.ts +37 -50
- package/dist/sesamy-js.iife.js +5 -5
- package/dist/sesamy-js.mjs +1083 -1086
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -60,10 +60,18 @@ These are the available configuration options, with their default values:
|
|
|
60
60
|
```javascript
|
|
61
61
|
{
|
|
62
62
|
clientId: null,
|
|
63
|
-
|
|
63
|
+
api: {
|
|
64
|
+
namespace: 'sesamy',
|
|
65
|
+
endpoint: 'https://api2.sesamy.com'
|
|
66
|
+
},
|
|
64
67
|
analytics: {
|
|
65
68
|
enabled: true,
|
|
66
69
|
endpoint: 'https://logs.sesamy.com/events'
|
|
67
|
-
}
|
|
70
|
+
},
|
|
71
|
+
auth: {
|
|
72
|
+
enabled: true,
|
|
73
|
+
endpoint: 'https://auth.sesamy.com',
|
|
74
|
+
redirectUri: window.location.origin
|
|
75
|
+
},
|
|
68
76
|
}
|
|
69
77
|
```
|
package/dist/sesamy-js.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var yr=Object.defineProperty;var vr=(t,e,n)=>e in t?yr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var B=(t,e,n)=>(vr(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function rt(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0});dispatchEvent(n)}function Q(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}var ce=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function jt(t,e){return t(e={exports:{}},e.exports),e.exports}var ae=jt(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()}});Tt(ae);var wr=Tt(jt(function(t,e){var n=ce&&ce.__awaiter||function(u,c,h,d){return new(h||(h=Promise))(function(w,k){function v(y){try{_(d.next(y))}catch(l){k(l)}}function I(y){try{_(d.throw(y))}catch(l){k(l)}}function _(y){y.done?w(y.value):new h(function(l){l(y.value)}).then(v,I)}_((d=d.apply(u,c||[])).next())})},r=ce&&ce.__generator||function(u,c){var h,d,w,k,v={label:0,sent:function(){if(1&w[0])throw w[1];return w[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(h)throw new TypeError("Generator is already executing.");for(;v;)try{if(h=1,d&&(w=2&l[0]?d.return:l[0]?d.throw||((w=d.return)&&w.call(d),0):d.next)&&!(w=w.call(d,l[1])).done)return w;switch(d=0,w&&(l=[2&l[0],w.value]),l[0]){case 0:case 1:w=l;break;case 4:return v.label++,{value:l[1],done:!1};case 5:v.label++,d=l[1],l=[0];continue;case 7:l=v.ops.pop(),v.trys.pop();continue;default:if(w=v.trys,!((w=w.length>0&&w[w.length-1])||l[0]!==6&&l[0]!==2)){v=0;continue}if(l[0]===3&&(!w||l[1]>w[0]&&l[1]<w[3])){v.label=l[1];break}if(l[0]===6&&v.label<w[1]){v.label=w[1],w=l;break}if(w&&v.label<w[2]){v.label=w[2],v.ops.push(l);break}w[2]&&v.ops.pop(),v.trys.pop();continue}l=c.call(u,v)}catch(b){l=[6,b],d=0}finally{h=w=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([_,y])}}},i=ce;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(h){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 m(u){for(var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",h="",d=0;d<u;d++)h+=c[Math.floor(Math.random()*c.length)];return h}var p=function(){function u(c){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+m(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,h){return h===void 0&&(h=5e3),n(this,void 0,void 0,function(){var d,w,k,v,I,_,y;return r(this,function(l){switch(l.label){case 0:d=Date.now()+m(4),w=Date.now()+h,k=o+"-"+c,v=this.storageHandler===void 0?a:this.storageHandler,l.label=1;case 1:return Date.now()<w?[4,s(30)]:[3,8];case 2:return l.sent(),v.getItemSync(k)!==null?[3,5]:(I=this.id+"-"+c+"-"+d,[4,s(Math.floor(25*Math.random()))]);case 3:return l.sent(),v.setItemSync(k,JSON.stringify({id:this.id,iat:d,timeoutKey:I,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return l.sent(),(_=v.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(w)];case 6:l.sent(),l.label=7;case 7:return d=Date.now()+m(4),[3,1];case 8:return[2,!1]}})})},u.prototype.refreshLockWhileAcquired=function(c,h){return n(this,void 0,void 0,function(){var d=this;return r(this,function(w){return setTimeout(function(){return n(d,void 0,void 0,function(){var k,v,I;return r(this,function(_){switch(_.label){case 0:return[4,ae.default().lock(h)];case 1:return _.sent(),this.acquiredIatSet.has(h)?(k=this.storageHandler===void 0?a:this.storageHandler,(v=k.getItemSync(c))===null?(ae.default().unlock(h),[2]):((I=JSON.parse(v)).timeRefreshed=Date.now(),k.setItemSync(c,JSON.stringify(I)),ae.default().unlock(h),this.refreshLockWhileAcquired(c,h),[2])):(ae.default().unlock(h),[2])}})})},1e3),[2]})})},u.prototype.waitForSomethingToChange=function(c){return n(this,void 0,void 0,function(){return r(this,function(h){switch(h.label){case 0:return[4,new Promise(function(d){var w=!1,k=Date.now(),v=!1;function I(){if(v||(window.removeEventListener("storage",I),u.removeFromWaiting(I),clearTimeout(_),v=!0),!w){w=!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 h.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(h){return h!==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(h){switch(h.label){case 0:return[4,this.releaseLock__private__(c)];case 1:return[2,h.sent()]}})})},u.prototype.releaseLock__private__=function(c){return n(this,void 0,void 0,function(){var h,d,w,k;return r(this,function(v){switch(v.label){case 0:return h=this.storageHandler===void 0?a:this.storageHandler,d=o+"-"+c,(w=h.getItemSync(d))===null?[2]:(k=JSON.parse(w)).id!==this.id?[3,2]:[4,ae.default().lock(k.iat)];case 1:v.sent(),this.acquiredIatSet.delete(k.iat),h.removeItemSync(d),ae.default().unlock(k.iat),u.notifyWaiters(),v.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var h=Date.now()-5e3,d=c,w=[],k=0;;){var v=d.keySync(k);if(v===null)break;w.push(v),k++}for(var I=!1,_=0;_<w.length;_++){var y=w[_];if(y.includes(o)){var l=d.getItemSync(y);if(l!==null){var b=JSON.parse(l);(b.timeRefreshed===void 0&&b.timeAcquired<h||b.timeRefreshed!==void 0&&b.timeRefreshed<h)&&(d.removeItemSync(y),I=!0)}}}I&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=p}));const br={timeoutInSeconds:60},En={name:"auth0-spa-js",version:"2.1.3"},On=()=>Date.now();let V=class kt extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,kt.prototype)}static fromPayload({error:e,error_description:n}){return new kt(e,n)}},kr=class Pn extends V{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,Pn.prototype)}},It=class Tn extends V{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,Tn.prototype)}},Ir=class jn extends It{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,jn.prototype)}},_r=class xn extends V{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,xn.prototype)}},Sr=class Cn extends V{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,Cn.prototype)}},$n=class An extends V{constructor(e,n){super("missing_refresh_token",`Missing Refresh Token (audience: '${Zt(e,["default"])}', scope: '${Zt(n)}')`),this.audience=e,this.scope=n,Object.setPrototypeOf(this,An.prototype)}};function Zt(t,e=[]){return t&&!e.includes(t)?t:""}const Be=()=>window.crypto,dt=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Be().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},Wt=t=>btoa(t),_t=t=>{var{clientId:e}=t,n=Q(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()},Kt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),Er=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},Or=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([Er(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},Pr=async(t,e,n,r,i,o,a)=>{return s={auth:{audience:e,scope:n},timeout:i,fetchUrl:t,fetchOptions:r,useFormData:a},m=o,new Promise(function(p,u){const c=new MessageChannel;c.port1.onmessage=function(h){h.data.error?u(new Error(h.data.error)):p(h.data),c.port1.close()},m.postMessage(s,[c.port2])});var s,m},Tr=async(t,e,n,r,i,o,a=1e4)=>i?Pr(t,e,n,r,a,i,o):Or(t,r,a);async function jr(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,m=Q(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const p=s?_t(m):JSON.stringify(m);return await async function(u,c,h,d,w,k,v){let I,_=null;for(let x=0;x<3;x++)try{I=await Tr(u,h,d,w,k,v,c),_=null;break}catch(L){_=L}if(_)throw _;const y=I.json,{error:l,error_description:b}=y,T=Q(y,["error","error_description"]),{ok:P}=I;if(!P){const x=b||`HTTP error. Unable to fetch ${u}`;throw l==="mfa_required"?new Sr(l,x,T.mfa_token):l==="missing_refresh_token"?new $n(h,d):new V(l||"request_error",x)}return T}(`${n}/oauth/token`,r,i||"default",o,{method:"POST",body:p,headers:{"Content-Type":s?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||En))}},e,s)}const Je=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let le=class St{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 St({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new St({scope:n,audience:r,clientId:i})}},xr=class{set(e,n){localStorage.setItem(e,JSON.stringify(n))}get(e){const n=window.localStorage.getItem(e);if(n)try{return JSON.parse(n)}catch{return}}remove(e){localStorage.removeItem(e)}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith("@@auth0spajs@@"))}},zn=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)}}()}},Cr=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||On}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 m=this.matchExistingCacheKey(e,s);m&&(i=await this.cache.get(m))}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 le({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 le({clientId:e},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(e,n){return n.filter(r=>{var i;const o=le.fromKey(r),a=new Set(o.scope&&o.scope.split(" ")),s=((i=e.scope)===null||i===void 0?void 0:i.split(" "))||[],m=o.scope&&s.reduce((p,u)=>p&&a.has(u),!0);return o.prefix==="@@auth0spajs@@"&&o.clientId===e.clientId&&o.audience===e.audience&&m})[0]}},$r=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 ze=t=>typeof t=="number",Ar=["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"],zr=t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(o=>{const a=o.split("."),[s,m,p]=a;if(a.length!==3||!s||!m||!p)throw new Error("ID token could not be decoded");const u=JSON.parse(Kt(m)),c={__raw:o},h={};return Object.keys(u).forEach(d=>{c[d]=u[d],Ar.includes(d)||(h[d]=u[d])}),{encoded:{header:s,payload:m,signature:p},header:JSON.parse(Kt(s)),claims:c,user:h}})(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&&!ze(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||!ze(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!ze(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&&ze(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&&ze(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 de=jt(function(t,e){var n=ce&&ce.__assign||function(){return n=Object.assign||function(m){for(var p,u=1,c=arguments.length;u<c;u++)for(var h in p=arguments[u])Object.prototype.hasOwnProperty.call(p,h)&&(m[h]=p[h]);return m},n.apply(this,arguments)};function r(m,p){if(!p)return"";var u="; "+m;return p===!0?u:u+"="+p}function i(m,p,u){return encodeURIComponent(m).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(p).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(c){if(typeof c.expires=="number"){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*c.expires),c.expires=h}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(m){for(var p={},u=m?m.split("; "):[],c=/(%[\dA-F]{2})+/gi,h=0;h<u.length;h++){var d=u[h].split("="),w=d.slice(1).join("=");w.charAt(0)==='"'&&(w=w.slice(1,-1));try{p[d[0].replace(c,decodeURIComponent)]=w.replace(c,decodeURIComponent)}catch{}}return p}function a(){return o(document.cookie)}function s(m,p,u){document.cookie=i(m,p,n({path:"/"},u))}e.__esModule=!0,e.encode=i,e.parse=o,e.getAll=a,e.get=function(m){return a()[m]},e.set=s,e.remove=function(m,p){s(m,"",n(n({},p),{expires:-1}))}});Tt(de),de.encode,de.parse,de.getAll;var Nr=de.get,Nn=de.set,Dn=de.remove;const we={get(t){const e=Nr(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),Nn(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Dn(t,n)}},Dr={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),Nn(`_legacy_${t}`,JSON.stringify(e),r),we.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Dn(t,n),we.remove(t,e),we.remove(`_legacy_${t}`,e)}},Lr={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 Ur(t,e,n){var r=e===void 0?null:e,i=function(m,p){var u=atob(m);if(p){for(var c=new Uint8Array(u.length),h=0,d=u.length;h<d;++h)c[h]=u.charCodeAt(h);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
|
+
"use strict";var mr=Object.defineProperty;var gr=(t,e,n)=>e in t?mr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var B=(t,e,n)=>(gr(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Et(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,composed:!0});dispatchEvent(n)}function Q(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function"){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}var ce=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 Pt(t,e){return t(e={exports:{}},e.exports),e.exports}var ae=Pt(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(ae);var yr=Ot(Pt(function(t,e){var n=ce&&ce.__awaiter||function(u,c,h,d){return new(h||(h=Promise))(function(b,v){function g(w){try{_(d.next(w))}catch(l){v(l)}}function I(w){try{_(d.throw(w))}catch(l){v(l)}}function _(w){w.done?b(w.value):new h(function(l){l(w.value)}).then(g,I)}_((d=d.apply(u,c||[])).next())})},r=ce&&ce.__generator||function(u,c){var h,d,b,v,g={label:0,sent:function(){if(1&b[0])throw b[1];return b[1]},trys:[],ops:[]};return v={next:I(0),throw:I(1),return:I(2)},typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function I(_){return function(w){return function(l){if(h)throw new TypeError("Generator is already executing.");for(;g;)try{if(h=1,d&&(b=2&l[0]?d.return:l[0]?d.throw||((b=d.return)&&b.call(d),0):d.next)&&!(b=b.call(d,l[1])).done)return b;switch(d=0,b&&(l=[2&l[0],b.value]),l[0]){case 0:case 1:b=l;break;case 4:return g.label++,{value:l[1],done:!1};case 5:g.label++,d=l[1],l=[0];continue;case 7:l=g.ops.pop(),g.trys.pop();continue;default:if(b=g.trys,!((b=b.length>0&&b[b.length-1])||l[0]!==6&&l[0]!==2)){g=0;continue}if(l[0]===3&&(!b||l[1]>b[0]&&l[1]<b[3])){g.label=l[1];break}if(l[0]===6&&g.label<b[1]){g.label=b[1],b=l;break}if(b&&g.label<b[2]){g.label=b[2],g.ops.push(l);break}b[2]&&g.ops.pop(),g.trys.pop();continue}l=c.call(u,g)}catch(k){l=[6,k],d=0}finally{h=b=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([_,w])}}},i=ce;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(h){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",h="",d=0;d<u;d++)h+=c[Math.floor(Math.random()*c.length)];return h}var f=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,h){return h===void 0&&(h=5e3),n(this,void 0,void 0,function(){var d,b,v,g,I,_,w;return r(this,function(l){switch(l.label){case 0:d=Date.now()+p(4),b=Date.now()+h,v=o+"-"+c,g=this.storageHandler===void 0?a:this.storageHandler,l.label=1;case 1:return Date.now()<b?[4,s(30)]:[3,8];case 2:return l.sent(),g.getItemSync(v)!==null?[3,5]:(I=this.id+"-"+c+"-"+d,[4,s(Math.floor(25*Math.random()))]);case 3:return l.sent(),g.setItemSync(v,JSON.stringify({id:this.id,iat:d,timeoutKey:I,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,s(30)];case 4:return l.sent(),(_=g.getItemSync(v))!==null&&(w=JSON.parse(_)).id===this.id&&w.iat===d?(this.acquiredIatSet.add(d),this.refreshLockWhileAcquired(v,d),[2,!0]):[3,7];case 5:return u.lockCorrector(this.storageHandler===void 0?a:this.storageHandler),[4,this.waitForSomethingToChange(b)];case 6:l.sent(),l.label=7;case 7:return d=Date.now()+p(4),[3,1];case 8:return[2,!1]}})})},u.prototype.refreshLockWhileAcquired=function(c,h){return n(this,void 0,void 0,function(){var d=this;return r(this,function(b){return setTimeout(function(){return n(d,void 0,void 0,function(){var v,g,I;return r(this,function(_){switch(_.label){case 0:return[4,ae.default().lock(h)];case 1:return _.sent(),this.acquiredIatSet.has(h)?(v=this.storageHandler===void 0?a:this.storageHandler,(g=v.getItemSync(c))===null?(ae.default().unlock(h),[2]):((I=JSON.parse(g)).timeRefreshed=Date.now(),v.setItemSync(c,JSON.stringify(I)),ae.default().unlock(h),this.refreshLockWhileAcquired(c,h),[2])):(ae.default().unlock(h),[2])}})})},1e3),[2]})})},u.prototype.waitForSomethingToChange=function(c){return n(this,void 0,void 0,function(){return r(this,function(h){switch(h.label){case 0:return[4,new Promise(function(d){var b=!1,v=Date.now(),g=!1;function I(){if(g||(window.removeEventListener("storage",I),u.removeFromWaiting(I),clearTimeout(_),g=!0),!b){b=!0;var w=50-(Date.now()-v);w>0?setTimeout(d,w):d(null)}}window.addEventListener("storage",I),u.addToWaiting(I);var _=setTimeout(I,Math.max(0,c-Date.now()))})];case 1:return h.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(h){return h!==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(h){switch(h.label){case 0:return[4,this.releaseLock__private__(c)];case 1:return[2,h.sent()]}})})},u.prototype.releaseLock__private__=function(c){return n(this,void 0,void 0,function(){var h,d,b,v;return r(this,function(g){switch(g.label){case 0:return h=this.storageHandler===void 0?a:this.storageHandler,d=o+"-"+c,(b=h.getItemSync(d))===null?[2]:(v=JSON.parse(b)).id!==this.id?[3,2]:[4,ae.default().lock(v.iat)];case 1:g.sent(),this.acquiredIatSet.delete(v.iat),h.removeItemSync(d),ae.default().unlock(v.iat),u.notifyWaiters(),g.label=2;case 2:return[2]}})})},u.lockCorrector=function(c){for(var h=Date.now()-5e3,d=c,b=[],v=0;;){var g=d.keySync(v);if(g===null)break;b.push(g),v++}for(var I=!1,_=0;_<b.length;_++){var w=b[_];if(w.includes(o)){var l=d.getItemSync(w);if(l!==null){var k=JSON.parse(l);(k.timeRefreshed===void 0&&k.timeAcquired<h||k.timeRefreshed!==void 0&&k.timeRefreshed<h)&&(d.removeItemSync(w),I=!0)}}}I&&u.notifyWaiters()},u.waiters=void 0,u}();e.default=f}));const vr={timeoutInSeconds:60},Sn={name:"auth0-spa-js",version:"2.1.3"},En=()=>Date.now();let V=class vt extends Error{constructor(e,n){super(n),this.error=e,this.error_description=n,Object.setPrototypeOf(this,vt.prototype)}static fromPayload({error:e,error_description:n}){return new vt(e,n)}},wr=class On extends V{constructor(e,n,r,i=null){super(e,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,On.prototype)}},wt=class Pn extends V{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,Pn.prototype)}},br=class Tn extends wt{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,Tn.prototype)}},kr=class jn extends V{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,jn.prototype)}},Ir=class xn extends V{constructor(e,n,r){super(e,n),this.mfa_token=r,Object.setPrototypeOf(this,xn.prototype)}},Cn=class $n extends V{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,$n.prototype)}};function Lt(t,e=[]){return t&&!e.includes(t)?t:""}const Ge=()=>window.crypto,ct=()=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";let e="";return Array.from(Ge().getRandomValues(new Uint8Array(43))).forEach(n=>e+=t[n%t.length]),e},Ut=t=>btoa(t),bt=t=>{var{clientId:e}=t,n=Q(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()},Rt=t=>(e=>decodeURIComponent(atob(e).split("").map(n=>"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g,"/").replace(/-/g,"+")),_r=async(t,e)=>{const n=await fetch(t,e);return{ok:n.ok,json:await n.json()}},Sr=async(t,e,n)=>{const r=new AbortController;let i;return e.signal=r.signal,Promise.race([_r(t,e),new Promise((o,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(i)})},Er=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(f,u){const c=new MessageChannel;c.port1.onmessage=function(h){h.data.error?u(new Error(h.data.error)):f(h.data),c.port1.close()},p.postMessage(s,[c.port2])});var s,p},Or=async(t,e,n,r,i,o,a=1e4)=>i?Er(t,e,n,r,a,i,o):Sr(t,r,a);async function Pr(t,e){var{baseUrl:n,timeout:r,audience:i,scope:o,auth0Client:a,useFormData:s}=t,p=Q(t,["baseUrl","timeout","audience","scope","auth0Client","useFormData"]);const f=s?bt(p):JSON.stringify(p);return await async function(u,c,h,d,b,v,g){let I,_=null;for(let x=0;x<3;x++)try{I=await Or(u,h,d,b,v,g,c),_=null;break}catch(L){_=L}if(_)throw _;const w=I.json,{error:l,error_description:k}=w,T=Q(w,["error","error_description"]),{ok:P}=I;if(!P){const x=k||`HTTP error. Unable to fetch ${u}`;throw l==="mfa_required"?new Ir(l,x,T.mfa_token):l==="missing_refresh_token"?new Cn(h,d):new V(l||"request_error",x)}return T}(`${n}/oauth/token`,r,i||"default",o,{method:"POST",body:f,headers:{"Content-Type":s?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(a||Sn))}},e,s)}const Me=(...t)=>{return(e=t.filter(Boolean).join(" ").trim().split(/\s+/),Array.from(new Set(e))).join(" ");var e};let le=class kt{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 kt({clientId:r,scope:o,audience:i},n)}static fromCacheEntry(e){const{scope:n,audience:r,client_id:i}=e;return new kt({scope:n,audience:r,clientId:i})}},Tr=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@@"))}},zn=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)}}()}},jr=class{constructor(e,n,r){this.cache=e,this.keyManifest=n,this.nowProvider=r||En}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 le({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 le({clientId:e},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(e,n){return n.filter(r=>{var i;const o=le.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((f,u)=>f&&a.has(u),!0);return o.prefix==="@@auth0spajs@@"&&o.clientId===e.clientId&&o.audience===e.audience&&p})[0]}},xr=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 ze=t=>typeof t=="number",Cr=["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"],$r=t=>{if(!t.id_token)throw new Error("ID token is required but missing");const e=(o=>{const a=o.split("."),[s,p,f]=a;if(a.length!==3||!s||!p||!f)throw new Error("ID token could not be decoded");const u=JSON.parse(Rt(p)),c={__raw:o},h={};return Object.keys(u).forEach(d=>{c[d]=u[d],Cr.includes(d)||(h[d]=u[d])}),{encoded:{header:s,payload:p,signature:f},header:JSON.parse(Rt(s)),claims:c,user:h}})(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&&!ze(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||!ze(e.claims.exp))throw new Error("Expiration Time (exp) claim must be a number present in the ID token");if(!ze(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&&ze(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&&ze(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 de=Pt(function(t,e){var n=ce&&ce.__assign||function(){return n=Object.assign||function(p){for(var f,u=1,c=arguments.length;u<c;u++)for(var h in f=arguments[u])Object.prototype.hasOwnProperty.call(f,h)&&(p[h]=f[h]);return p},n.apply(this,arguments)};function r(p,f){if(!f)return"";var u="; "+p;return f===!0?u:u+"="+f}function i(p,f,u){return encodeURIComponent(p).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(f).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(c){if(typeof c.expires=="number"){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*c.expires),c.expires=h}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 f={},u=p?p.split("; "):[],c=/(%[\dA-F]{2})+/gi,h=0;h<u.length;h++){var d=u[h].split("="),b=d.slice(1).join("=");b.charAt(0)==='"'&&(b=b.slice(1,-1));try{f[d[0].replace(c,decodeURIComponent)]=b.replace(c,decodeURIComponent)}catch{}}return f}function a(){return o(document.cookie)}function s(p,f,u){document.cookie=i(p,f,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,f){s(p,"",n(n({},f),{expires:-1}))}});Ot(de),de.encode,de.parse,de.getAll;var zr=de.get,An=de.set,Nn=de.remove;const ve={get(t){const e=zr(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),An(t,JSON.stringify(e),r)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Nn(t,n)}},Ar={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),An(`_legacy_${t}`,JSON.stringify(e),r),ve.save(t,e,n)},remove(t,e){let n={};e!=null&&e.cookieDomain&&(n.domain=e.cookieDomain),Nn(t,n),ve.remove(t,e),ve.remove(`_legacy_${t}`,e)}},Nr={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 Dr(t,e,n){var r=e===void 0?null:e,i=function(p,f){var u=atob(p);if(f){for(var c=new Uint8Array(u.length),h=0,d=u.length;h<d;++h)c[h]=u.charCodeAt(h);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 Zt,Wt,Kt,ut,Lr=(Zt="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",Wt=null,Kt=!1,function(t){return ut=ut||Dr(Zt,Wt,Kt),new Worker(ut,t)});const lt={};let Ur=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 Rr={memory:()=>new zn().enclosedCache,localstorage:()=>new Tr},Mt=t=>Rr[t],Jt=t=>{const{openUrl:e,onRedirect:n}=t,r=Q(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:e===!1||e?e:n})},dt=new yr;let Zr=class{constructor(e){let n,r;if(this.userCache=new zn().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await dt.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(!Ge())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Ge().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",!Ft(n))throw new Error(`Invalid cache location "${n}"`);r=Ft(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?we:Dr,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:Lr;var o;this.scope=Je("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new $r(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||On,this.cacheManager=new Cr(r,r.allKeys?void 0:new Zr(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 Rr)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||En)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${_t(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return zr({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=Wt(dt()),o=Wt(dt()),a=dt(),s=(u=>{const c=new Uint8Array(u);return(h=>{const d={"+":"-","/":"_","=":""};return h.replace(/[+/=]/g,w=>d[w])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Be().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),m=((u,c,h,d,w,k,v,I)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),h),{scope:Je(c,h.scope),response_type:"code",response_mode:I||"query",state:d,nonce:w,redirect_uri:v||u.authorizationParams.redirect_uri,code_challenge:k,code_challenge_method:"S256"}))(this.options,this.scope,e,i,o,s,e.redirect_uri||this.options.authorizationParams.redirect_uri||r,n==null?void 0:n.response_mode),p=this._authorizeUrl(m);return{nonce:o,code_verifier:a,scope:m.scope,audience:m.audience||"default",redirect_uri:m.redirect_uri,state:i,url:p}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const m=window.screenX+(window.innerWidth-400)/2,p=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${m},top=${p},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!n.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const i=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await(s=>new Promise((m,p)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(h),window.removeEventListener("message",u,!1),p(new _r(s.popup)))},1e3),h=setTimeout(()=>{clearInterval(c),p(new Ir(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(h),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return p(V.fromPayload(d.data.response));m(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 V("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=Ht(e),{openUrl:i,fragment:o,appState:a}=r,s=Q(r,["openUrl","fragment","appState"]),m=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,p=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=p,c=Q(p,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),m&&{organization:m}));const h=o?`${u}#${o}`:u;i?await i(h):window.location.assign(h)}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 h=new URLSearchParams(c);return{state:h.get("state"),code:h.get("code")||void 0,error:h.get("error")||void 0,error_description:h.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new V("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new kr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new V("state_mismatch","Invalid state");const m=s.organization,p=s.nonce,u=s.redirect_uri;return await this._requestToken(Object.assign({audience:s.audience,scope:s.scope,code_verifier:s.code_verifier,grant_type:"authorization_code",code:i},u?{redirect_uri:u}:{}),{nonceIn:p,organization:m}),{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:Je(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=ft[a];return s||(s=o().finally(()=>{delete ft[a],s=null}),ft[a]=s),s})(()=>this._getTokenSilently(r),`${this.options.clientId}::${r.authorizationParams.audience}::${r.authorizationParams.scope}`);return e.detailedResponse?i:i==null?void 0:i.access_token}async _getTokenSilently(e){const{cacheMode:n}=e,r=Q(e,["cacheMode"]);if(n!=="off"){const i=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(i)return i}if(n!=="cache-only"){if(!await(async(i,o=3)=>{for(let a=0;a<o;a++)if(await i())return!0;return!1})(()=>pt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new It;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const p=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(p)return p}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:m}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:m})}finally{await pt.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}}async getTokenWithPopup(e={},n={}){var r;const i=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Je(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},br),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new le({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=Q(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${_t(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=Ht(e),{openUrl:r}=n,i=Q(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:m,scope:p,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new V("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,h=await((w,k,v=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 It),l()},1e3*v);b=function(P){if(P.origin!=k||!P.data||P.data.type!=="authorization_response")return;const x=P.source;x&&x.close(),P.data.response.error?_(V.fromPayload(P.data.response)):I(P.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",w)}))(i,this.domainUrl,c);if(o!==h.state)throw new V("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:h.code,grant_type:"authorization_code",redirect_uri:m,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},d),{scope:p,oauthTokenScope:d.scope,audience:u})}catch(c){throw c.error==="login_required"&&this.logout({openUrl:!1}),c}}async _getTokenUsingRefreshToken(e){const n=await this.cacheManager.get(new le({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 $n(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=Q(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 le({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 le({scope:e,audience:n,clientId:r}),60);if(i&&i.access_token){const{access_token:o,oauthTokenScope:a,expires_in:s}=i,m=await this._getIdTokenFromCache();return m&&Object.assign(Object.assign({id_token:m.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await jr(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs},e),this.worker),a=await this._verifyIdToken(o.id_token,r,i);return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},o),{decodedToken:a,scope:e.scope,audience:e.audience||"default"}),o.scope?{oauthTokenScope:o.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(i||a.claims.org_id),Object.assign(Object.assign({},o),{decodedToken:a})}};async function Mr(t){const e=new Kr(t);return await e.checkSession(),e}const xt="sesamy.com",Jr="https://logs.sesamy.com/events";var pe=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.SOFT_PAYWALL="sesamyJsSoftPaywall",t))(pe||{});let X;async function Xr(t){if(t.enabled!==!1&&(X=await Mr({domain:t.endpoint||`token.${xt}`,clientId:t.clientId,cacheLocation:"localstorage"}),window.location.search.includes("code=")))try{await X.handleRedirectCallback();const e=await X.getUser();rt(pe.AUTHENTICATED,e),window.history.replaceState({},document.title,"/");const n=await X.getTokenSilently();localStorage.setItem("accessToken",n)}catch{}}async function Fr(){if(!X)throw new Error("Auth0 client not initialized");return X.isAuthenticated()}async function Hr(){if(!X)throw new Error("Auth0 client not initialized");return X.getUser()}function Vr(){if(!X)throw new Error("Auth0 client not initialized");return X.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function Yr(){if(!X)throw new Error("Auth0 client not initialized");return X.getTokenSilently()}async function Gr(){if(!X)throw new Error("Auth0 client not initialized");return rt(pe.LOGOUT,{}),X.logout({logoutParams:{returnTo:window.location.href}})}const Br=(t,e)=>e.skipDedupe||e.method!=="GET",qr=(t,e)=>e.method+"@"+t,Qr=t=>t.clone(),Ln=({skip:t=Br,key:e=qr,resolver:n=Qr}={})=>{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((m,p)=>{r.get(s).push([m,p])});try{return i(o,a).then(m=>(r.get(s).forEach(([p])=>p(n(m))),r.delete(s),m)).catch(m=>{throw r.get(s).forEach(([p,u])=>u(m)),r.delete(s),m})}catch(m){return r.delete(s),Promise.reject(m)}}},ei=(t,e)=>t*e,ti=t=>t&&t.ok,Un=({delayTimer:t=500,delayRamp:e=ei,maxAttempts:n=10,until:r=ti,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>m=>(p,u)=>{let c=0;if(s&&s(p,u))return m(p,u);const h=(d,w)=>Promise.resolve(r(d,w)).then(k=>k?d&&a?d:w?Promise.reject(w):d:(c++,!n||c<=n?new Promise(v=>{const I=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:w,url:p,options:u})).then((_={})=>{var y,l;v(m((y=_&&_.url)!==null&&y!==void 0?y:p,(l=_&&_.options)!==null&&l!==void 0?l:u))}):v(m(p,u))},I)}).then(h).catch(v=>{if(!o)throw v;return h(null,v)}):d&&a?d:Promise.reject(w||new Error("Number of attempts exceeded."))));return m(p,u).then(h).catch(d=>{if(!o)throw d;return h(null,d)})},ni="application/json",Rn="Content-Type",ve=Symbol(),Zn=Symbol();function Vt(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===Rn.toLowerCase()))===null||e===void 0?void 0:e[1]}function Yt(t){return/^application\/.*json.*/.test(t)}const he=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]=he(a,o,n):r[i]=o,r},{...t})},Ee={options:{},errorType:"text",polyfills:{},polyfill(t,e=!0,n=!1,...r){const i=this.polyfills[t]||(typeof self<"u"?self[t]:null)||(typeof global<"u"?global[t]:null);if(e&&!i)throw new Error(t+" is not defined");return n&&i?new i(...r):i}};function ri(t,e=!1){Ee.options=e?t:he(Ee.options,t)}function ii(t,e=!1){Ee.polyfills=e?t:he(Ee.polyfills,t)}function oi(t){Ee.errorType=t}const ai=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class Wn extends Error{}const si=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:m}=t,p=new Map(o),u=he(i.options,r);let c=n;const h=ai(s)((y,l)=>(c=y,i.polyfill("fetch")(y,l)))(n,u),d=new Error,w=h.catch(y=>{throw{[ve]:y}}).then(y=>{if(!y.ok){const l=new Wn;if(l.cause=d,l.stack=l.stack+`
|
|
5
|
-
CAUSE: `+d.stack,l.response=y,l.url=c,y.type==="opaque")throw l;return y.text().then(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(ve),T=b?l[ve]:l,P=(T==null?void 0:T.status)&&p.get(T.status)||p.get(T==null?void 0:T.name)||b&&p.has(ve)&&p.get(ve);if(P)return P(T,t);const x=p.get(Zn);if(x)return x(T,t);throw T}),v=y=>l=>k(y?w.then(b=>b&&b[y]()).then(b=>l?l(b):b):w.then(b=>l?l(b):b)),I={_wretchReq:t,_fetchReq:h,_sharedState:e,res:v(null),json:v("json"),blob:v("blob"),formData:v("formData"),arrayBuffer:v("arrayBuffer"),text:v("text"),error(y,l){return p.set(y,l),this},badRequest(y){return this.error(400,y)},unauthorized(y){return this.error(401,y)},forbidden(y){return this.error(403,y)},notFound(y){return this.error(404,y)},timeout(y){return this.error(408,y)},internalError(y){return this.error(500,y)},fetchError(y){return this.error(ve,y)}},_=m.reduce((y,l)=>({...y,...typeof l.resolver=="function"?l.resolver(y):l.resolver}),I);return a.reduce((y,l)=>l(y,t),_)},ci={_url:"",_options:{},_config:Ee,_catchers:new Map,_resolvers:[],_deferred:[],_middlewares:[],_addons:[],addon(t){return{...this,_addons:[...this._addons,t],...t.wretch}},errorType(t){return{...this,_config:{...this._config,errorType:t}}},polyfills(t,e=!1){return{...this,_config:{...this._config,polyfills:e?t:he(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:he(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:he(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[Rn]: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(Zn,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=Vt(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||Yt(i));return r=n?o?r.json(n,i):r.body(n):r,si(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=Vt(this._options.headers);return this.content(e||Yt(n)&&n||ni).body(JSON.stringify(t))}};function oe(t="",e={}){return{...ci,_url:t,_options:e}}oe.default=oe;oe.options=ri;oe.errorType=oi;oe.polyfills=ii;oe.WretchError=Wn;const ui=t=>async(e,n)=>{try{const r=await Yr(),i={...n,headers:{...n.headers,Authorization:`Bearer ${r}`}};return t(e,i)}catch(r){throw console.error("Error fetching access token:",r),r}},li=t=>(e,n)=>{const r=localStorage.getItem("__anon_id"),i=btoa(`${r}:`),o={...n,headers:{...n.headers,Authorization:`Basic ${i}`}};return t(e,o)},je=oe(`https://api2.${xt}`).headers({"Content-Type":"application/json"}).middlewares([ui,Ln(),Un({delayTimer:1e3,delayRamp:(t,e)=>t*e,maxAttempts:3,until:t=>(t==null?void 0:t.ok)||!1,retryOnNetworkError:!1})]),it=oe(`https://api2.${xt}`).headers({"Content-Type":"application/json"}).middlewares([li,Ln(),Un({delayTimer:1e3,delayRamp:(t,e)=>t*e,maxAttempts:3,until:t=>(t==null?void 0:t.ok)||!1,retryOnNetworkError:!1})]);async function di(){return je.get("/entitlements").json()}async function hi(t){const e=await je.get("/entitlements").json();return e==null?void 0:e.find(n=>n.id===t)}async function fi(){return je.get("/contracts").json()}async function pi(t){const e=await je.get("/contracts").json();return e==null?void 0:e.find(n=>n.id===t)}async function mi(){return je.get("/bills").json()}async function gi(t){const e=await je.get("/bills").json();return e==null?void 0:e.find(n=>n.id===t)}async function yi(){return await it.url("/tags").get().json()}async function vi(t,e){return await it.url(`/tags/${t}`).put(e).json()}async function wi(t,e){return await it.url(`/tags/${t}/push`).post(e).json()}async function bi(t){const e=localStorage.getItem("__anon_id");if(!e)throw new Error("User id not found");return it.url("/articles/access").post({articleId:t.articleId,userId:e}).json()}async function ki(t){const e=await bi({articleId:t});return e.status!=="ok"&&rt(pe.SOFT_PAYWALL,{}),e}const Kn="@sesamy/sesamy-js",Ct="1.3.2";function Ii(){return Ct}function _i(t="sesamy"){const e={auth:{getUser:Hr,isAuthenticated:Fr,loginWithRedirect:Vr,logout:Gr},articles:{access:ki},tags:{list:yi,set:vi,push:wi},getEntitlement:hi,getEntitlements:di,getContract:pi,getContracts:fi,getBill:gi,getBills:mi,getVersion:Ii};return t!==null&&(window[t]=e),e}function Gt(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 Xe="undefined",Bt="object",Si=function(){},Mn="any",Jn="*",me="__",Qe=typeof process<"u"?process:{};Qe.env&&Qe.env.NODE_ENV;var Y=typeof document<"u";Qe.versions!=null&&Qe.versions.node!=null;typeof Deno<"u"&&Deno.core;Y&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function Xn(t,e){return e.charAt(0)[t]()+e.slice(1)}var Ei=Xn.bind(null,"toUpperCase"),Oi=Xn.bind(null,"toLowerCase");function Pi(t){return Fn(t)?Ei("null"):typeof t=="object"?Ci(t):Object.prototype.toString.call(t).slice(8,-1)}function et(t,e){e===void 0&&(e=!0);var n=Pi(t);return e?Oi(n):n}function Ke(t,e){return typeof e===t}var G=Ke.bind(null,"function"),re=Ke.bind(null,"string"),be=Ke.bind(null,"undefined"),Ti=Ke.bind(null,"boolean");Ke.bind(null,"symbol");function Fn(t){return t===null}function ji(t){return et(t)==="number"&&!isNaN(t)}function Hn(t){return et(t)==="array"}function J(t){if(!xi(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function xi(t){return t&&(typeof t=="object"||t!==null)}function Ci(t){return G(t.constructor)?t.constructor.name:null}function $i(t){return t instanceof Error||re(t.message)&&t.constructor&&ji(t.constructor.stackTraceLimit)}function Vn(t,e){if(typeof e!="object"||Fn(e))return!1;if(e instanceof t)return!0;var n=et(new t(""));if($i(e))for(;e;){if(et(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}Vn.bind(null,TypeError);Vn.bind(null,SyntaxError);function ot(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Ai(t,e):n}function Ai(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function at(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}at(ot,"form");at(ot,"button");at(ot,"input");at(ot,"select");function zi(t){return t?Hn(t)?t:[t]:[]}function qt(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Ni(){if(Y){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Di(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Li(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=qt(n[1]),a=qt(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 m=s.split("[");m.length>1&&(Ui(r,m.map(function(p){return p.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return Y&&window.location.search.substring(1)}(t))}function Ui(t,e,n){for(var r=e.length-1,i=0;i<r;++i){var o=e[i];if(o==="__proto__"||o==="constructor")break;o in t||(t[o]={}),t=t[o]}t[e[r]]=n}function st(){for(var t="",e=0,n=4294967295*Math.random()|0;e++<36;){var r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],i=15&n;t+=r=="-"||r=="4"?r:(r=="x"?i:3&i|8).toString(16),n=e%8==0?4294967295*Math.random()|0:n>>4}return t}var Le="global",Oe=me+"global"+me,Pe=typeof self===Bt&&self.self===self&&self||typeof global===Bt&&global.global===global&&global||void 0;function ge(t){return Pe[Oe][t]}function ye(t,e){return Pe[Oe][t]=e}function xe(t){delete Pe[Oe][t]}function Ce(t,e,n){var r;try{if($t(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Pe[Oe]||(Pe[Oe]={});var Fe={};function $t(t){if(typeof Fe[t]!==Xe)return Fe[t];try{var e=window[t];e.setItem(Xe,Xe),e.removeItem(Xe)}catch{return Fe[t]=!1}return Fe[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 ne="function",ee="undefined",Ri="@@redux/"+Math.random().toString(36),Qt=function(){return typeof Symbol===ne&&Symbol.observable||"@@observable"}(),He=" != "+ne;function Yn(t,e,n){var r;if(typeof e===ne&&typeof n===ee&&(n=e,e=void 0),typeof n!==ee){if(typeof n!==ne)throw new Error("enhancer"+He);return n(Yn)(t,e)}if(typeof t!==ne)throw new Error("reducer"+He);var i=t,o=e,a=[],s=a,m=!1;function p(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==ne)throw new Error("Listener"+He);var w=!0;return p(),s.push(d),function(){if(w){w=!1,p();var k=s.indexOf(d);s.splice(k,1)}}}function h(d){if(!J(d))throw new Error("Act != obj");if(typeof d.type===ee)throw new Error("ActType "+ee);if(m)throw new Error("Dispatch in reducer");try{m=!0,o=i(o,d)}finally{m=!1}for(var w=a=s,k=0;k<w.length;k++)(0,w[k])();return d}return h({type:"@@redux/INIT"}),(r={dispatch:h,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ne)throw new Error("next reducer"+He);i=d,h({type:"@@redux/INIT"})}})[Qt]=function(){var d,w=c;return(d={subscribe:function(k){if(typeof k!="object")throw new TypeError("Observer != obj");function v(){k.next&&k.next(u())}return v(),{unsubscribe:w(v)}}})[Qt]=function(){return this},d},r}function Zi(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+ee}function Te(){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 Wi(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,m={getState:a.getState,dispatch:function(p){return s(p)}};return o=[].slice.call(t).map(function(p){return p(m)}),O({},a,{dispatch:s=Te.apply(void 0,o)(a.dispatch)})}}}var ie=me+"anon_id",fe=me+"user_id",Ie=me+"user_traits",te="userId",ke="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"],Et=["name","EVENTS","config","loaded"],E=qe.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),en=/^utm_/,tn=/^an_prop_/,nn=/^an_trait_/;function Ki(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,m=i.initialUser,p=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(ie,a.anonymousId),p||e(fe,a.userId),m.traits&&e(Ie,O({},p&&s.traits?s.traits:{},m.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,h=o.an_event,d=u.reduce(function(w,k){if(k.match(en)||k.match(/^(d|g)clid/)){var v=k.replace(en,"");w.campaign[v==="campaign"?"name":v]=o[k]}return k.match(tn)&&(w.props[k.replace(tn,"")]=o[k]),k.match(nn)&&(w.traits[k.replace(nn,"")]=o[k]),w},{campaign:{},props:{},traits:{}});n.dispatch(O({type:E.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),h&&setTimeout(function(){return t.track(h,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:E.campaign,campaign:d.campaign})}}return r(i)}}}}function Mi(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===E.setItemEnd){if(n.key===ie)return O({},e,{anonymousId:n.value});if(n.key===fe)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[fe,ie,Ie].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function rn(t){return{userId:t.getItem(fe),anonymousId:t.getItem(ie),traits:t.getItem(Ie)}}var Ot=function(t){return me+"TEMP"+me+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 m=s.userId,p=s.traits,u=s.options;if(s.type===E.reset&&([fe,Ie,ie].forEach(function(d){r(d)}),[te,ke,"traits"].forEach(function(d){xe(Ot(d))})),s.type===E.identify){i(ie)||n(ie,st());var c=i(fe),h=i(Ie)||{};c&&c!==m&&o.dispatch({type:E.userIdChanged,old:{userId:c,traits:h},new:{userId:m,traits:p},options:u}),m&&n(fe,m),p&&n(Ie,O({},h,p))}return a(s)}}}}var De={};function on(t,e){De[t]&&G(De[t])&&(De[t](e),delete De[t])}function Gn(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 Gn(t,e,n-10).then(r,i)})})}function Xi(t){return{abort:t}}function Bn(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,m=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var p=s.actions.reduce(function(c,h,d){return a[h.plugin].loaded?(c.process.push(h),c.processIndex.push(d)):(c.requeue.push(h),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(p.processIndex&&p.processIndex.length){p.processIndex.forEach(function(c){var h=s.actions[c],d=h.plugin,w=h.payload.type,k=i[d][w];if(k&&G(k)){var v,I=function(l,b){return l===void 0&&(l={}),b===void 0&&(b={}),[te,ke].reduce(function(T,P){return l.hasOwnProperty(P)&&b[P]&&b[P]!==l[P]&&(T[P]=b[P]),T},l)}(h.payload,m),_=r[I.meta.rid];if(!_&&(v=k({payload:I,config:a[d].config,instance:n,abort:Xi}))&&J(v)&&v.abort)return void(r[I.meta.rid]=!0);if(!_){var y=w+":"+d;t.dispatch(O({},I,{type:y,_:{called:y,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,h){return!~p.processIndex.indexOf(h)});s.actions=u}}}var mt=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,m=t.EVENTS;try{var p=i.plugins,u=i.context,c=n.type,h=c.match(_e),d=e.exact.map(function(v){return v.pluginName});h&&(d=a.during.map(function(v){return v.pluginName}));var w=function(v,I){return function(_,y,l){var b=y.config,T=y.name,P=T+"."+_.type;l&&(P=l.event);var x=_.type.match(_e)?function(L,D,F,U,H){return function(Z,j){var K=U?U.name:L,M=j&&We(j)?j:F;if(U&&(!(M=j&&We(j)?j:[L]).includes(L)||M.length!==1))throw new Error("Method "+D+" can only abort "+L+" plugin. "+JSON.stringify(M)+" input valid");return O({},H,{abort:{reason:Z,plugins:M,caller:D,_:K}})}}(T,P,I,l,_):function(L,D){return function(){throw new Error(L.type+" action not cancellable. Remove abort in "+D)}}(_,P);return{payload:Fi(_),instance:v,config:b||{},abort:x}}}(r,d),k=e.exact.reduce(function(v,I){var _=I.pluginName,y=I.methodName,l=!1;return y.match(/^initialize/)||y.match(/^reset/)||(l=!p[_].loaded),u.offline&&y.match(/^(page|track|identify)/)&&(l=!0),v[""+_]=l,v},{});return Promise.resolve(e.exact.reduce(function(v,I,_){try{var y=I.pluginName;return Promise.resolve(v).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(P,x,L){try{return Promise.resolve(P).then(function(D){return x.method&&G(x.method)?(function(Z,j){var K=hn(Z);if(K&&K.name===j){var M=hn(K.method);throw new Error([j+" plugin is calling method "+Z,"Plugins cant call self","Use "+K.method+" "+(M?"or "+M.method:"")+" in "+j+" plugin insteadof "+Z].join(`
|
|
6
|
-
`))}}(x.methodName,x.pluginName),Promise.resolve(x.method({payload:D,instance:r,abort:(F=D,U=y,H=x.pluginName,function(Z,j){return O({},F,{abort:{reason:Z,plugins:j||[U],caller:c,from:H||U}})}),config:cn(x.pluginName,p,o),plugins:p})).then(function(Z){var j=J(Z)?Z:{};return Promise.resolve(O({},D,j))})):D;var F,U,H})}catch(D){return Promise.reject(D)}},Promise.resolve(n))).then(function(P){l[y]=P});l[y]=n}();return T&&T.then?T.then(b):b()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(v){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(P){var x=v[b]?v[b]:{};if(h&&(x=P),yt(x,b))return gt({data:x,method:c,instance:r,pluginName:b,store:s}),Promise.resolve(P);if(yt(P,b))return l&>({data:P,method:c,instance:r,store:s}),Promise.resolve(P);if(k.hasOwnProperty(b)&&k[b]===!0)return s.dispatch({type:"queue",plugin:b,payload:x,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(P);var L=w(v[b],o[b]);return Promise.resolve(T[c]({abort:L.abort,payload:x,instance:r,config:cn(b,p,o),plugins:p})).then(function(D){var F=J(D)?D:{},U=O({},P,F),H=v[b];if(yt(H,b))gt({data:H,method:c,instance:r,pluginName:b,store:s});else{var Z=c+":"+b;(Z.match(/:/g)||[]).length<2&&!c.match(an)&&!c.match(sn)&&r.dispatch(O({},h?U:x,{type:Z,_:{called:Z,from:"submethod"}}))}return Promise.resolve(U)})})}catch(P){return Promise.reject(P)}},Promise.resolve(n))).then(function(I){if(!(c.match(_e)||c.match(/^registerPlugin/)||c.match(sn)||c.match(an)||c.match(/^params/)||c.match(/^userIdChanged/))){if(m.plugins.includes(c),I._&&I._.originalAction===c)return I;var _=O({},I,{_:{originalAction:I.type,called:I.type,from:"engineEnd"}});qn(I,e.exact.length)&&!c.match(/End$/)&&(_=O({},_,{type:I.type+"Aborted"})),s.dispatch(_)}return I})})}catch(v){return Promise.reject(v)}},_e=/Start$/,an=/^bootstrap/,sn=/^ready/;function gt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(O({},t.data,{type:n,_:{called:n,from:"abort"}}))}function cn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function un(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function ln(t,e){var n=t.replace(_e,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function yt(t,e){var n=t.abort;return!!n&&(n===!0||dn(n,e)||n&&dn(n.plugins,e))}function qn(t,e){var n=t.abort;if(!n)return!1;if(n===!0||re(n))return!0;var r=n.plugins;return We(n)&&n.length===e||We(r)&&r.length===e}function We(t){return Array.isArray(t)}function dn(t,e){return!(!t||!We(t))&&t.includes(e)}function hn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Fi(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=J(t[n])?Object.assign({},t[n]):t[n]),e},{})}function Hi(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,m=function(l){return s?l:o(c)},p=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(p===E.enablePlugin&&i.dispatch({type:E.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),p===E.disablePlugin&&setTimeout(function(){return on(a.meta.rid,{payload:a})},0),p===E.initializeEnd){var h=e(),d=Object.keys(h),w=d.filter(function(l){return u.includes(l)}).map(function(l){return h[l]}),k=[],v=[],I=a.disabled,_=w.map(function(l){var b=l.loaded,T=l.name,P=l.config;return Gn(l,function(){return b({config:P})},1e4).then(function(x){return r[T]||(i.dispatch({type:E.pluginReadyType(T),name:T,events:Object.keys(l).filter(function(L){return!Et.includes(L)})}),r[T]=!0),k=k.concat(T),l}).catch(function(x){if(x instanceof Error)throw new Error(x);return v=v.concat(x.name),x})});Promise.all(_).then(function(l){var b={plugins:k,failed:v,disabled:I};setTimeout(function(){d.length===_.length+I.length&&i.dispatch(O({},{type:E.ready},b))},0)})}var y=function(){if(p!==E.bootstrap)return/^ready:([^:]*)$/.test(p)&&setTimeout(function(){return Bn(i,e,t)},0),Promise.resolve(function(l,b,T,P,x){try{var L=G(b)?b():b,D=l.type,F=D.replace(_e,"");if(l._&&l._.called)return Promise.resolve(l);var U=T.getState(),H=(K=L,(M=U.plugins)===void 0&&(M={}),($e=l.options)===void 0&&($e={}),Object.keys(K).filter(function(f){var g=$e.plugins||{};return Ti(g[f])?g[f]:g.all!==!1&&(!M[f]||M[f].enabled!==!1)}).map(function(f){return K[f]}));D===E.initializeStart&&l.fromEnable&&(H=Object.keys(U.plugins).filter(function(f){var g=U.plugins[f];return l.plugins.includes(f)&&!g.initialized}).map(function(f){return L[f]}));var Z=H.map(function(f){return f.name}),j=function(f,g,S){var C=ln(f).map(function($){return un($,g)});return g.reduce(function($,A){var W=A.name,N=ln(f,W).map(function(Ae){return un(Ae,g)}),R=N[0],z=N[1],q=N[2];return R.length&&($.beforeNS[W]=R),z.length&&($.duringNS[W]=z),q.length&&($.afterNS[W]=q),$},{before:C[0],beforeNS:{},during:C[1],duringNS:{},after:C[2],afterNS:{}})}(D,H);return Promise.resolve(mt({action:l,data:{exact:j.before,namespaced:j.beforeNS},state:U,allPlugins:L,allMatches:j,instance:T,store:P,EVENTS:x})).then(function(f){function g(){var $=function(){if(D.match(_e))return Promise.resolve(mt({action:O({},S,{type:F+"End"}),data:{exact:j.after,namespaced:j.afterNS},state:U,allPlugins:L,allMatches:j,instance:T,store:P,EVENTS:x})).then(function(A){A.meta&&A.meta.hasCallback&&on(A.meta.rid,{payload:A})})}();return $&&$.then?$.then(function(){return f}):f}if(qn(f,Z.length))return f;var S,C=function(){if(D!==F)return Promise.resolve(mt({action:O({},f,{type:F}),data:{exact:j.during,namespaced:j.duringNS},state:U,allPlugins:L,allMatches:j,instance:T,store:P,EVENTS:x})).then(function($){S=$});S=f}();return C&&C.then?C.then(g):g()})}catch(f){return Promise.reject(f)}var K,M,$e}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(y&&y.then?y.then(m):m(y))}catch(l){return Promise.reject(l)}}}}}function Vi(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 Yi=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 Te.apply(void 0,a)(r)(i)}}}}};function Gi(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=fn(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 m=fn(n.type,E.initialize),p=t()[m];return p&&m?(r[m]=O({},e[m],{initialized:!0,loaded:!!p.loaded({config:p.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,pn(n.plugins,!1,e));case E.enablePlugin:return O({},e,pn(n.plugins,!0,e));default:return e}}}function fn(t,e){return t.substring(e.length+1,t.length)}function pn(t,e,n){return t.reduce(function(r,i){return r[i]=O({},n[i],{enabled:e}),r},n)}function Qn(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var Bi={last:{},history:[]};function qi(t,e){t===void 0&&(t=Bi);var n=e.options,r=e.meta;if(e.type===E.track){var i=Qn(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 Qi={actions:[]};function eo(t,e){t===void 0&&(t=Qi);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 er=/#.*$/;function to(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(er,""):"")}var tr,nr,rr,ir,no=function(t){if(t===void 0&&(t={}),!Y)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,m=o.hash,p=o.search,u=function(h){var d=function(){if(Y){for(var w,k=document.getElementsByTagName("link"),v=0;w=k[v];v++)if(w.getAttribute("rel")==="canonical")return w.getAttribute("href")}}();return d?d.match(/\?/)?d:d+h:window.location.href.replace(er,"")}(p),c={title:n,url:u,path:to(u),hash:m,search:p,width:a,height:s};return r&&r!==""&&(c.referrer=r),O({},c,t)},ro={last:{},history:[]};function io(t,e){t===void 0&&(t=ro);var n=e.options;if(e.type===E.page){var r=Qn(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}tr=function(){if(!Y)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"}(),nr=Y?document.referrer:null,rr=Ni(),ir=Di();var mn={initialized:!1,sessionId:st(),app:null,version:null,debug:!1,offline:!!Y&&!navigator.onLine,os:{name:tr},userAgent:Y?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:ir,locale:rr,campaign:{},referrer:nr};function oo(t,e){t===void 0&&(t=mn);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({},mn,t,{initialized:!0})}}var ao=["plugins","reducers","storage"];function so(t,e,n){if(Y){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function co(t){var e=so.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function or(){return ye("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 Pe[Oe].analytics.push(a.action||a),o(a)}})}}}function gn(t){return function(){return Te(Te.apply(null,arguments),or())}}function vt(t){return t?Hn(t)?t:[t]:[]}function yn(t,e,n){t===void 0&&(t={});var r,i,o=st();return e&&(De[o]=(r=e,i=function(a){for(var s,m=a||Array.prototype.slice.call(arguments),p=0;p<m.length;p++)if(G(m[p])){s=m[p];break}return s}(n),function(a){i&&i(a),r(a)})),O({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function uo(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(f,g){if(G(g))return f.middlewares=f.middlewares.concat(g),f;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(A){return g.EVENTS[A]}):[];f.pluginEnabled[g.name]=!(g.enabled===!1||g.config.enabled===!1),delete g.enabled,g.methods&&(f.methods[g.name]=Object.keys(g.methods).reduce(function(A,W){var N;return A[W]=(N=g.methods[W],function(){for(var R=Array.prototype.slice.call(arguments),z=new Array(N.length),q=0;q<R.length;q++)z[q]=R[q];return z[z.length]=b,N.apply({instance:b},z)}),A},{}),delete g.methods);var C=Object.keys(g).concat(S),$=new Set(f.events.concat(C));if(f.events=Array.from($),f.pluginsArray=f.pluginsArray.concat(g),f.plugins[g.name])throw new Error(g.name+"AlreadyLoaded");return f.plugins[g.name]=g,f.plugins[g.name].loaded||(f.plugins[g.name].loaded=function(){return!0}),f},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:ge,setItem:ye,removeItem:xe},o=function(f){return function(g,S,C){return S.getState("user")[g]||(C&&J(C)&&C[g]?C[g]:rn(f)[g]||ge(Ot(g))||null)}}(i),a=r.plugins,s=r.events.filter(function(f){return!Et.includes(f)}).sort(),m=new Set(s.concat(qe).filter(function(f){return!Et.includes(f)})),p=Array.from(m).sort(),u=function(){return a},c=new Yi,h=c.addMiddleware,d=c.removeMiddleware,w=c.dynamicMiddlewares,k=function(){throw new Error("Abort disabled inListener")},v=Li(),I=rn(i),_=O({},I,n,v.an_uid?{userId:v.an_uid}:{},v.an_aid?{anonymousId:v.an_aid}:{});_.anonymousId||(_.anonymousId=st());var y=O({enable:function(f,g){return new Promise(function(S){j.dispatch({type:E.enablePlugin,plugins:vt(f),_:{originalAction:E.enablePlugin}},S,[g])})},disable:function(f,g){return new Promise(function(S){j.dispatch({type:E.disablePlugin,plugins:vt(f),_:{originalAction:E.disablePlugin}},S,[g])})}},r.methods),l=!1,b={identify:function(f,g,S,C){try{var $=re(f)?f:null,A=J(f)?f:g,W=S||{},N=b.user();ye(Ot(te),$);var R=$||A.userId||o(te,b,A);return Promise.resolve(new Promise(function(z){j.dispatch(O({type:E.identifyStart,userId:R,traits:A||{},options:W,anonymousId:N.anonymousId},N.id&&N.id!==$&&{previousId:N.id}),z,[g,S,C])}))}catch(z){return Promise.reject(z)}},track:function(f,g,S,C){try{var $=J(f)?f.event:f;if(!$||!re($))throw new Error("EventMissing");var A=J(f)?f:g||{},W=J(S)?S:{};return Promise.resolve(new Promise(function(N){j.dispatch({type:E.trackStart,event:$,properties:A,options:W,userId:o(te,b,g),anonymousId:o(ke,b,g)},N,[g,S,C])}))}catch(N){return Promise.reject(N)}},page:function(f,g,S){try{var C=J(f)?f:{},$=J(g)?g:{};return Promise.resolve(new Promise(function(A){j.dispatch({type:E.pageStart,properties:no(C),options:$,userId:o(te,b,C),anonymousId:o(ke,b,C)},A,[f,g,S])}))}catch(A){return Promise.reject(A)}},user:function(f){if(f===te||f==="id")return o(te,b);if(f===ke||f==="anonId")return o(ke,b);var g=b.getState("user");return f?Gt(g,f):g},reset:function(f){return new Promise(function(g){j.dispatch({type:E.resetStart},g,f)})},ready:function(f){return l&&f({plugins:y,instance:b}),b.on(E.ready,function(g){f(g),l=!0})},on:function(f,g){if(!f||!G(g))return!1;if(f===E.bootstrap)throw new Error(".on disabled for "+f);var S=/Start$|Start:/;if(f==="*"){var C=function(N){return function(R){return function(z){return z.type.match(S)&&g({payload:z,instance:b,plugins:a}),R(z)}}},$=function(N){return function(R){return function(z){return z.type.match(S)||g({payload:z,instance:b,plugins:a}),R(z)}}};return h(C,Ve),h($,Ye),function(){d(C,Ve),d($,Ye)}}var A=f.match(S)?Ve:Ye,W=function(N){return function(R){return function(z){return z.type===f&&g({payload:z,instance:b,plugins:a,abort:k}),R(z)}}};return h(W,A),function(){return d(W,A)}},once:function(f,g){if(!f||!G(g))return!1;if(f===E.bootstrap)throw new Error(".once disabled for "+f);var S=b.on(f,function(C){g({payload:C.payload,instance:b,plugins:a,abort:k}),S()});return S},getState:function(f){var g=j.getState();return f?Gt(g,f):Object.assign({},g)},dispatch:function(f){var g=re(f)?{type:f}:f;if(qe.includes(g.type))throw new Error("reserved action "+g.type);var S=O({},g,{_:O({originalAction:g.type},f._||{})});j.dispatch(S)},enablePlugin:y.enable,disablePlugin:y.disable,plugins:y,storage:{getItem:i.getItem,setItem:function(f,g,S){j.dispatch({type:E.setItemStart,key:f,value:g,options:S})},removeItem:function(f,g){j.dispatch({type:E.removeItemStart,key:f,options:g})}},setAnonymousId:function(f,g){b.storage.setItem(ie,f,g)},events:{core:qe,plugins:s}},T=r.middlewares.concat([function(f){return function(g){return function(S){return S.meta||(S.meta=yn()),g(S)}}},w(Ve),Hi(b,u,{all:p,plugins:s}),Vi(i),Ki(b),Ji(b),w(Ye)]),P={context:oo,user:Mi(i),page:io,track:qi,plugins:Gi(u),queue:eo},x=Te,L=Te;if(Y&&t.debug){var D=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;D&&(x=D({trace:!0,traceLimit:25})),L=function(){return arguments.length===0?or():J(typeof arguments[0])?gn():gn().apply(null,arguments)}}var F,U=function(f){return Object.keys(f).reduce(function(g,S){return ao.includes(S)||(g[S]=f[S]),g},{})}(t),H=r.pluginsArray.reduce(function(f,g){var S=g.name,C=g.config,$=g.loaded,A=r.pluginEnabled[S];return f[S]={enabled:A,initialized:!!A&&!g.initialize,loaded:!!$({config:C}),config:C},f},{}),Z={context:U,user:_,plugins:H},j=Yn(function(f){for(var g=Object.keys(f),S={},C=0;C<g.length;C++){var $=g[C];typeof f[$]===ne&&(S[$]=f[$])}var A,W=Object.keys(S);try{(function(N){Object.keys(N).forEach(function(R){var z=N[R];if(typeof z(void 0,{type:"@@redux/INIT"})===ee||typeof z(void 0,{type:Ri})===ee)throw new Error("reducer "+R+" "+ee)})})(S)}catch(N){A=N}return function(N,R){if(N===void 0&&(N={}),A)throw A;for(var z=!1,q={},Ae=0;Ae<W.length;Ae++){var Me=W[Ae],Rt=N[Me],lt=(0,S[Me])(Rt,R);if(typeof lt===ee){var gr=Zi(Me,R);throw new Error(gr)}q[Me]=lt,z=z||lt!==Rt}return z?q:N}}(O({},P,e)),Z,L(x(Wi.apply(void 0,T))));j.dispatch=(F=j.dispatch,function(f,g,S){var C=O({},f,{meta:yn(f.meta,g,vt(S))});return F.apply(null,[C])});var K=Object.keys(a);j.dispatch({type:E.bootstrap,plugins:K,config:U,params:v,user:_,initialUser:n,persistedUser:I});var M=K.filter(function(f){return r.pluginEnabled[f]}),$e=K.filter(function(f){return!r.pluginEnabled[f]});return j.dispatch({type:E.registerPlugins,plugins:K,enabled:r.pluginEnabled}),r.pluginsArray.map(function(f,g){var S=f.bootstrap,C=f.config,$=f.name;S&&G(S)&&S({instance:b,config:C,payload:f}),j.dispatch({type:E.registerPluginType($),name:$,enabled:r.pluginEnabled[$],plugin:f}),r.pluginsArray.length===g+1&&j.dispatch({type:E.initializeStart,plugins:M,disabled:$e})}),co(function(f){j.dispatch({type:f?E.offline:E.online})}),function(f,g,S){setInterval(function(){return Bn(f,g,S)},3e3)}(j,u,b),b}var Ve="before",Ye="after",Ue="cookie",ue=cr(),ar=ct,lo=ct;function sr(t){return ue?ct(t,"",-1):xe(t)}function cr(){if(ue!==void 0)return ue;var t="cookiecookie";try{ct(t,t),ue=document.cookie.indexOf(t)!==-1,sr(t)}catch{ue=!1}return ue}function ct(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return ue===!1&&(a?ye(t,e):ge(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 Re="localStorage",ho=$t.bind(null,"localStorage");Ce("localStorage","getItem",ge);Ce("localStorage","setItem",ye);Ce("localStorage","removeItem",xe);var Ze="sessionStorage",fo=$t.bind(null,"sessionStorage");Ce("sessionStorage","getItem",ge);Ce("sessionStorage","setItem",ye);Ce("sessionStorage","removeItem",xe);function Se(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(J(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var po=ho(),mo=fo(),go=cr();function ur(t,e){if(t){var n=At(e),r=!Lt(n),i=zt(n)?Se(localStorage.getItem(t)):void 0;if(r&&!be(i))return i;var o=Nt(n)?Se(ar(t)):void 0;if(r&&o)return o;var a=Dt(n)?Se(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=ge(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function yo(t,e,n){if(t&&!be(e)){var r={},i=At(n),o=JSON.stringify(e),a=!Lt(i);return zt(i)&&(r[Re]=Ge(Re,e,Se(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Re]:Nt(i)&&(r[Ue]=Ge(Ue,e,Se(ar(t))),lo(t,o),a)?r[Ue]:Dt(i)&&(r[Ze]=Ge(Ze,e,Se(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Ze]:(r[Le]=Ge(Le,e,ge(t)),ye(t,e),a?r[Le]:r)}}function vo(t,e){if(t){var n=At(e),r=ur(t,Jn),i={};return!be(r.localStorage)&&zt(n)&&(localStorage.removeItem(t),i[Re]=r.localStorage),!be(r.cookie)&&Nt(n)&&(sr(t),i[Ue]=r.cookie),!be(r.sessionStorage)&&Dt(n)&&(sessionStorage.removeItem(t),i[Ze]=r.sessionStorage),!be(r.global)&&ut(n,Le)&&(xe(t),i[Le]=r.global),i}}function At(t){return t?re(t)?t:t.storage:Mn}function zt(t){return po&&ut(t,Re)}function Nt(t){return go&&ut(t,Ue)}function Dt(t){return mo&&ut(t,Ze)}function Lt(t){return t===Jn||t==="all"}function ut(t,e){return t===Mn||t===e||Lt(t)}function Ge(t,e,n){return{location:t,current:e,previous:n}}var wo={setItem:yo,getItem:ur,removeItem:vo};function bo(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vn(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 wn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vn(Object(n),!0).forEach(function(r){bo(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vn(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ko(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:wo};return uo(wn(wn({},e),t))}function Io(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(m){return r=i.push(m),r>=o&&a(),r},size:function(){return i.length},end:function(m){m&&a(),clearInterval(n)}}}function _o(t){if(typeof window>"u")return;const{addEventListener:e,history:n,location:r}=window;let i=r.pathname;e("popstate",()=>t(r.pathname)),["push","replace"].map(o=>{const a=`${o}State`;if(a!=="pushState"&&a!=="replaceState")return;const s=n[a];n[a]=function(...m){var c;const p=((c=m[2])==null?void 0:c.toString())||"",u=Eo(p);return i!==u&&(i=u,setTimeout(()=>t(p),0)),s.apply(n,m)}})}function So(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function Eo(t){return["#","?"].forEach(e=>t=So(t,e)),t}function Oo(){_o(()=>{se.page()})}var bn="EventListener";function Po(t){return function(e,n,r,i){var o=r||Si,a=i||!1;if(!Y)return o;var s=tt(n),m=tt(e,!0);if(!m.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var p=[];return function u(c){c&&(p=[]);for(var h=c?"add"+bn:"remove"+bn,d=0;d<m.length;d++){var w=m[d];p[d]=c?a&&a.once?To(o):o:p[d]||o;for(var k=0;k<s.length;k++)w[h]?w["on"+s[k]]=c?p[d]:null:w[h](s[k],p[d],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=zi(t);return e?o.map(function(a){return re(a)?tt(a,!0):a}).flat():o}function To(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var wt=Po("Event");function lr(t,e){return Y&&G(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),G(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}lr.bind(null,"onerror");lr.bind(null,"onload");var dr=typeof window>"u",kn="hidden";function jo(t){if(dr)return!1;var e=xo(),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 xo(){var t=["webkit","moz","ms","o"];return dr||kn in document?kn:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var Co=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function $o(t,e){e===void 0&&(e={});var n=function(a,s){var m=this,p=!1;return function(u){p||(a.call(m,u),p=!0,setTimeout(function(){return p=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=jo(function(s){s||n({type:"tabVisible"})});return r=[a].concat(Co.map(function(s){return wt(document,s,n)})).concat(wt(window,"load",n)).concat(wt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Ao(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,m=t.throttle,p=m===void 0?2e3:m,u=!1,c=!1,h=new Date,d=function(){return clearTimeout(e)};function w(v){d(),o&&!u&&o(Ne(h),v),i&&u&&(u=!1,i(Ne(n),v),h=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(Ne(h),v))},s)}var k=$o(w,{throttle:p});return{disable:function(){c=!0,u=!1,d();var v=k();return function(){return c=!1,h=new Date,w({type:"load"}),v()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:Ne(h,c),idle:u?Ne(n,c):0}}}}function Ne(t,e){return e?0:Math.round((new Date-t)/1e3)}const In=5e3;class zo{constructor(e){B(this,"element");B(this,"isInViewport",!1);B(this,"isAwake",!1);B(this,"isFlushing");B(this,"observer");B(this,"lastEventAt",Date.now());B(this,"registeredView",!1);B(this,"viewCallback");B(this,"activeDurationCallback");B(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),Ao({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:In})}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*In: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 _n="sesamy_session_id";function No(){let t=sessionStorage.getItem(_n);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(_n,t)),t}let hr=!1,Pt,Sn,nt;function Do({clientId:t,enabled:e=!0,endpoint:n=Jr}){if(Pt=t,Sn=e,nt=n,!Sn)return;Oo();const r=new zo({element:document.body,viewCallback:()=>{se.page()},activeDurationCallback:(i,o)=>{se.track("activeDuration",{duration:i,flushing:o})},idleDurationCallback:(i,o)=>{se.track("idleDuration",{duration:i,flushing:o})}});Uo(document.body,()=>{r.flush()}),window.addEventListener(pe.AUTHENTICATED,async i=>{const o=i;await se.identify(o.detail.sub)}),window.addEventListener(pe.LOGOUT,async()=>{await se.track("logout",{}),Ut.flush(),await se.reset()})}function fr(t){return JSON.stringify(t.map(e=>({...e,clientId:Pt,requestId:Math.random().toString(36).slice(2,9),sessionId:No(),timestamp:new Date().toISOString(),version:Ct,event:e.event,context:{page:{url:window.location.hostname,path:window.location.pathname,title:document.title,search:window.location.search,referrer:document.referrer},locale:navigator.language,library:Kn,userAgent:navigator.userAgent,clientId:Pt}})))}const Ut=Io(async t=>{if(t.length>0){const e=fr(t);hr?navigator.sendBeacon(nt,e):(await fetch(nt,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function bt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(nt,fr([n]))}else Ut.push(t)}const se=ko({app:Kn,version:Ct,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;bt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;bt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;bt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Lo(){return hr=!0,Ut.flush()}const pr=new Map;function Uo(t,e){pr.set(t,e)}window.addEventListener("beforeunload",()=>{pr.forEach((t,e)=>{t.bind(e)()}),Lo()});async function mr(t){Do({clientId:t.clientId,...t.analytics}),await Xr({clientId:t.clientId,...t.auth});const e=_i(t.namespace);return rt(pe.READY,{}),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);mr(e)}catch(e){console.error("Failed to parse config",e)}}exports.init=mr;
|
|
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",!Mt(n))throw new Error(`Invalid cache location "${n}"`);r=Mt(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?ve:Ar,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:Nr;var o;this.scope=Me("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new xr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||En,this.cacheManager=new jr(r,r.allKeys?void 0:new Ur(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 Lr)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Sn)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${bt(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return $r({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=Ut(ct()),o=Ut(ct()),a=ct(),s=(u=>{const c=new Uint8Array(u);return(h=>{const d={"+":"-","/":"_","=":""};return h.replace(/[+/=]/g,b=>d[b])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Ge().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),p=((u,c,h,d,b,v,g,I)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),h),{scope:Me(c,h.scope),response_type:"code",response_mode:I||"query",state:d,nonce:b,redirect_uri:g||u.authorizationParams.redirect_uri,code_challenge:v,code_challenge_method:"S256"}))(this.options,this.scope,e,i,o,s,e.redirect_uri||this.options.authorizationParams.redirect_uri||r,n==null?void 0:n.response_mode),f=this._authorizeUrl(p);return{nonce:o,code_verifier:a,scope:p.scope,audience:p.audience||"default",redirect_uri:p.redirect_uri,state:i,url:f}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const p=window.screenX+(window.innerWidth-400)/2,f=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${p},top=${f},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!n.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const i=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await(s=>new Promise((p,f)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(h),window.removeEventListener("message",u,!1),f(new kr(s.popup)))},1e3),h=setTimeout(()=>{clearInterval(c),f(new br(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(h),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return f(V.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 V("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=Jt(e),{openUrl:i,fragment:o,appState:a}=r,s=Q(r,["openUrl","fragment","appState"]),p=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,f=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=f,c=Q(f,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),p&&{organization:p}));const h=o?`${u}#${o}`:u;i?await i(h):window.location.assign(h)}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 h=new URLSearchParams(c);return{state:h.get("state"),code:h.get("code")||void 0,error:h.get("error")||void 0,error_description:h.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new V("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new wr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new V("state_mismatch","Invalid state");const p=s.organization,f=s.nonce,u=s.redirect_uri;return await this._requestToken(Object.assign({audience:s.audience,scope:s.scope,code_verifier:s.code_verifier,grant_type:"authorization_code",code:i},u?{redirect_uri:u}:{}),{nonceIn:f,organization: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:Me(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=lt[a];return s||(s=o().finally(()=>{delete lt[a],s=null}),lt[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=Q(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})(()=>dt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new wt;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const f=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(f)return f}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:p}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:p})}finally{await dt.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:Me(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},vr),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new le({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=Q(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${bt(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=Jt(e),{openUrl:r}=n,i=Q(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:f,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new V("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,h=await((b,v,g=60)=>new Promise((I,_)=>{const w=window.document.createElement("iframe");w.setAttribute("width","0"),w.setAttribute("height","0"),w.style.display="none";const l=()=>{window.document.body.contains(w)&&(window.document.body.removeChild(w),window.removeEventListener("message",k,!1))};let k;const T=setTimeout(()=>{_(new wt),l()},1e3*g);k=function(P){if(P.origin!=v||!P.data||P.data.type!=="authorization_response")return;const x=P.source;x&&x.close(),P.data.response.error?_(V.fromPayload(P.data.response)):I(P.data.response),clearTimeout(T),window.removeEventListener("message",k,!1),setTimeout(l,2e3)},window.addEventListener("message",k,!1),window.document.body.appendChild(w),w.setAttribute("src",b)}))(i,this.domainUrl,c);if(o!==h.state)throw new V("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:h.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:f,oauthTokenScope:d.scope,audience:u})}catch(c){throw c.error==="login_required"&&this.logout({openUrl:!1}),c}}async _getTokenUsingRefreshToken(e){const n=await this.cacheManager.get(new le({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 Cn(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=Q(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 le({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 le({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 Pr(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 Wr(t){const e=new Zr(t);return await e.checkSession(),e}const Dn="sesamy.com",Kr="https://logs.sesamy.com/events";var Se=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.SOFT_PAYWALL="sesamyJsSoftPaywall",t))(Se||{});let X;async function Mr(t){if(t.enabled!==!1&&(X=await Wr({domain:t.endpoint||`token.${Dn}`,clientId:t.clientId,cacheLocation:"localstorage"}),window.location.search.includes("code=")))try{await X.handleRedirectCallback();const e=await X.getUser();Et(Se.AUTHENTICATED,e),window.history.replaceState({},document.title,"/");const n=await X.getTokenSilently();localStorage.setItem("accessToken",n)}catch{}}async function Jr(){if(!X)throw new Error("Auth0 client not initialized");return X.isAuthenticated()}async function Xr(){if(!X)throw new Error("Auth0 client not initialized");return X.getUser()}function Fr(){if(!X)throw new Error("Auth0 client not initialized");return X.loginWithRedirect({authorizationParams:{redirect_uri:window.location.href}})}async function Hr(){if(!X)throw new Error("Auth0 client not initialized");return X.getTokenSilently()}async function Vr(){if(!X)throw new Error("Auth0 client not initialized");return Et(Se.LOGOUT,{}),X.logout({logoutParams:{returnTo:window.location.href}})}const Yr=(t,e)=>e.skipDedupe||e.method!=="GET",Gr=(t,e)=>e.method+"@"+t,Br=t=>t.clone(),Xt=({skip:t=Yr,key:e=Gr,resolver:n=Br}={})=>{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,f)=>{r.get(s).push([p,f])});try{return i(o,a).then(p=>(r.get(s).forEach(([f])=>f(n(p))),r.delete(s),p)).catch(p=>{throw r.get(s).forEach(([f,u])=>u(p)),r.delete(s),p})}catch(p){return r.delete(s),Promise.reject(p)}}},qr=(t,e)=>t*e,Qr=t=>t&&t.ok,Ft=({delayTimer:t=500,delayRamp:e=qr,maxAttempts:n=10,until:r=Qr,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>p=>(f,u)=>{let c=0;if(s&&s(f,u))return p(f,u);const h=(d,b)=>Promise.resolve(r(d,b)).then(v=>v?d&&a?d:b?Promise.reject(b):d:(c++,!n||c<=n?new Promise(g=>{const I=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:b,url:f,options:u})).then((_={})=>{var w,l;g(p((w=_&&_.url)!==null&&w!==void 0?w:f,(l=_&&_.options)!==null&&l!==void 0?l:u))}):g(p(f,u))},I)}).then(h).catch(g=>{if(!o)throw g;return h(null,g)}):d&&a?d:Promise.reject(b||new Error("Number of attempts exceeded."))));return p(f,u).then(h).catch(d=>{if(!o)throw d;return h(null,d)})},ei="application/json",Ln="Content-Type",ye=Symbol(),Un=Symbol();function Ht(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===Ln.toLowerCase()))===null||e===void 0?void 0:e[1]}function Vt(t){return/^application\/.*json.*/.test(t)}const he=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]=he(a,o,n):r[i]=o,r},{...t})},Ee={options:{},errorType:"text",polyfills:{},polyfill(t,e=!0,n=!1,...r){const i=this.polyfills[t]||(typeof self<"u"?self[t]:null)||(typeof global<"u"?global[t]:null);if(e&&!i)throw new Error(t+" is not defined");return n&&i?new i(...r):i}};function ti(t,e=!1){Ee.options=e?t:he(Ee.options,t)}function ni(t,e=!1){Ee.polyfills=e?t:he(Ee.polyfills,t)}function ri(t){Ee.errorType=t}const ii=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class Rn extends Error{}const oi=t=>{const e=Object.create(null);t=t._addons.reduce((w,l)=>l.beforeRequest&&l.beforeRequest(w,t._options,e)||w,t);const{_url:n,_options:r,_config:i,_catchers:o,_resolvers:a,_middlewares:s,_addons:p}=t,f=new Map(o),u=he(i.options,r);let c=n;const h=ii(s)((w,l)=>(c=w,i.polyfill("fetch")(w,l)))(n,u),d=new Error,b=h.catch(w=>{throw{[ye]:w}}).then(w=>{if(!w.ok){const l=new Rn;if(l.cause=d,l.stack=l.stack+`
|
|
5
|
+
CAUSE: `+d.stack,l.response=w,l.url=c,w.type==="opaque")throw l;return w.text().then(k=>{var T;if(l.message=k,i.errorType==="json"||((T=w.headers.get("Content-Type"))===null||T===void 0?void 0:T.split(";")[0])==="application/json")try{l.json=JSON.parse(k)}catch{}throw l.text=k,l.status=w.status,l})}return w}),v=w=>w.catch(l=>{const k=l.hasOwnProperty(ye),T=k?l[ye]:l,P=(T==null?void 0:T.status)&&f.get(T.status)||f.get(T==null?void 0:T.name)||k&&f.has(ye)&&f.get(ye);if(P)return P(T,t);const x=f.get(Un);if(x)return x(T,t);throw T}),g=w=>l=>v(w?b.then(k=>k&&k[w]()).then(k=>l?l(k):k):b.then(k=>l?l(k):k)),I={_wretchReq:t,_fetchReq:h,_sharedState:e,res:g(null),json:g("json"),blob:g("blob"),formData:g("formData"),arrayBuffer:g("arrayBuffer"),text:g("text"),error(w,l){return f.set(w,l),this},badRequest(w){return this.error(400,w)},unauthorized(w){return this.error(401,w)},forbidden(w){return this.error(403,w)},notFound(w){return this.error(404,w)},timeout(w){return this.error(408,w)},internalError(w){return this.error(500,w)},fetchError(w){return this.error(ye,w)}},_=p.reduce((w,l)=>({...w,...typeof l.resolver=="function"?l.resolver(w):l.resolver}),I);return a.reduce((w,l)=>l(w,t),_)},ai={_url:"",_options:{},_config:Ee,_catchers:new Map,_resolvers:[],_deferred:[],_middlewares:[],_addons:[],addon(t){return{...this,_addons:[...this._addons,t],...t.wretch}},errorType(t){return{...this,_config:{...this._config,errorType:t}}},polyfills(t,e=!1){return{...this,_config:{...this._config,polyfills:e?t:he(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:he(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:he(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[Ln]: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(Un,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=Ht(r._options.headers),o=typeof n=="object"&&(!r._options.headers||!i||Vt(i));return r=n?o?r.json(n,i):r.body(n):r,oi(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=Ht(this._options.headers);return this.content(e||Vt(n)&&n||ei).body(JSON.stringify(t))}};function oe(t="",e={}){return{...ai,_url:t,_options:e}}oe.default=oe;oe.options=ti;oe.errorType=ri;oe.polyfills=ni;oe.WretchError=Rn;function si(t){const e=t.endpoint||`https://api.${Dn}`,n=v=>async(g,I)=>{try{const _=await Hr(),w={...I,headers:{...I.headers,Authorization:`Bearer ${_}`}};return v(g,w)}catch(_){throw console.error("Error fetching access token:",_),_}},r=v=>(g,I)=>{const _=localStorage.getItem("__anon_id"),w=btoa(`${_}:`),l={...I,headers:{...I.headers,Authorization:`Basic ${w}`}};return v(g,l)},i=oe(e).headers({"Content-Type":"application/json"}).middlewares([n,Xt(),Ft({delayTimer:1e3,delayRamp:(v,g)=>v*g,maxAttempts:3,until:v=>(v==null?void 0:v.ok)||!1,retryOnNetworkError:!1})]),o=oe(e).headers({"Content-Type":"application/json"}).middlewares([r,Xt(),Ft({delayTimer:1e3,delayRamp:(v,g)=>v*g,maxAttempts:3,until:v=>(v==null?void 0:v.ok)||!1,retryOnNetworkError:!1})]);async function a(){return i.get("/entitlements").json()}async function s(v){const g=await i.get("/entitlements").json();return g==null?void 0:g.find(I=>I.id===v)}async function p(){return i.get("/contracts").json()}async function f(v){const g=await i.get("/contracts").json();return g==null?void 0:g.find(I=>I.id===v)}async function u(){return i.get("/bills").json()}async function c(v){const g=await i.get("/bills").json();return g==null?void 0:g.find(I=>I.id===v)}async function h(){return await o.url("/tags").get().json()}async function d(v,g){return await o.url(`/tags/${v}`).put(g).json()}async function b(v,g){return await o.url(`/tags/${v}/push`).post(g).json()}return{getEntitlements:a,getEntitlement:s,getContracts:p,getContract:f,getBills:u,getBill:c,getTags:h,setTag:d,pushTag:b}}const Zn="@sesamy/sesamy-js",Tt="1.3.2";function ci(t){const{getEntitlement:e,getEntitlements:n,getContract:r,getContracts:i,getBill:o,getBills:a,getTags:s,setTag:p,pushTag:f}=si(t),u={auth:{getUser:Xr,isAuthenticated:Jr,loginWithRedirect:Fr,logout:Vr},tags:{list:s,set:p,push:f},getEntitlement:e,getEntitlements:n,getContract:r,getContracts:i,getBill:o,getBills:a,getVersion:ui};return t.namespace&&(window[t.namespace]=u),u}function ui(){return Tt}function Yt(t,e,n,r,i){for(e=e.split?e.split("."):e,r=0;r<e.length;r++)t=t?t[e[r]]:i;return t===i?n:t}var Je="undefined",Gt="object",li=function(){},Wn="any",Kn="*",pe="__",qe=typeof process<"u"?process:{};qe.env&&qe.env.NODE_ENV;var Y=typeof document<"u";qe.versions!=null&&qe.versions.node!=null;typeof Deno<"u"&&Deno.core;Y&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function Mn(t,e){return e.charAt(0)[t]()+e.slice(1)}var di=Mn.bind(null,"toUpperCase"),hi=Mn.bind(null,"toLowerCase");function fi(t){return Jn(t)?di("null"):typeof t=="object"?yi(t):Object.prototype.toString.call(t).slice(8,-1)}function Qe(t,e){e===void 0&&(e=!0);var n=fi(t);return e?hi(n):n}function We(t,e){return typeof e===t}var G=We.bind(null,"function"),re=We.bind(null,"string"),we=We.bind(null,"undefined"),pi=We.bind(null,"boolean");We.bind(null,"symbol");function Jn(t){return t===null}function mi(t){return Qe(t)==="number"&&!isNaN(t)}function Xn(t){return Qe(t)==="array"}function J(t){if(!gi(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function gi(t){return t&&(typeof t=="object"||t!==null)}function yi(t){return G(t.constructor)?t.constructor.name:null}function vi(t){return t instanceof Error||re(t.message)&&t.constructor&&mi(t.constructor.stackTraceLimit)}function Fn(t,e){if(typeof e!="object"||Jn(e))return!1;if(e instanceof t)return!0;var n=Qe(new t(""));if(vi(e))for(;e;){if(Qe(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}Fn.bind(null,TypeError);Fn.bind(null,SyntaxError);function nt(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?wi(t,e):n}function wi(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function rt(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}rt(nt,"form");rt(nt,"button");rt(nt,"input");rt(nt,"select");function bi(t){return t?Xn(t)?t:[t]:[]}function Bt(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function ki(){if(Y){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Ii(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function _i(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=Bt(n[1]),a=Bt(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&&(Si(r,p.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){if(e){var n=e.match(/\?(.*)/);return n&&n[1]?n[1].split("#")[0]:""}return Y&&window.location.search.substring(1)}(t))}function Si(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 it(){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 De="global",Oe=pe+"global"+pe,Pe=typeof self===Gt&&self.self===self&&self||typeof global===Gt&&global.global===global&&global||void 0;function me(t){return Pe[Oe][t]}function ge(t,e){return Pe[Oe][t]=e}function je(t){delete Pe[Oe][t]}function xe(t,e,n){var r;try{if(jt(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Pe[Oe]||(Pe[Oe]={});var Xe={};function jt(t){if(typeof Xe[t]!==Je)return Xe[t];try{var e=window[t];e.setItem(Je,Je),e.removeItem(Je)}catch{return Xe[t]=!1}return Xe[t]=!0}function 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 ne="function",ee="undefined",Ei="@@redux/"+Math.random().toString(36),qt=function(){return typeof Symbol===ne&&Symbol.observable||"@@observable"}(),Fe=" != "+ne;function Hn(t,e,n){var r;if(typeof e===ne&&typeof n===ee&&(n=e,e=void 0),typeof n!==ee){if(typeof n!==ne)throw new Error("enhancer"+Fe);return n(Hn)(t,e)}if(typeof t!==ne)throw new Error("reducer"+Fe);var i=t,o=e,a=[],s=a,p=!1;function f(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==ne)throw new Error("Listener"+Fe);var b=!0;return f(),s.push(d),function(){if(b){b=!1,f();var v=s.indexOf(d);s.splice(v,1)}}}function h(d){if(!J(d))throw new Error("Act != obj");if(typeof d.type===ee)throw new Error("ActType "+ee);if(p)throw new Error("Dispatch in reducer");try{p=!0,o=i(o,d)}finally{p=!1}for(var b=a=s,v=0;v<b.length;v++)(0,b[v])();return d}return h({type:"@@redux/INIT"}),(r={dispatch:h,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ne)throw new Error("next reducer"+Fe);i=d,h({type:"@@redux/INIT"})}})[qt]=function(){var d,b=c;return(d={subscribe:function(v){if(typeof v!="object")throw new TypeError("Observer != obj");function g(){v.next&&v.next(u())}return g(),{unsubscribe:b(g)}}})[qt]=function(){return this},d},r}function Oi(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+ee}function Te(){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 Pi(){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(f){return s(f)}};return o=[].slice.call(t).map(function(f){return f(p)}),O({},a,{dispatch:s=Te.apply(void 0,o)(a.dispatch)})}}}var ie=pe+"anon_id",fe=pe+"user_id",ke=pe+"user_traits",te="userId",be="anonymousId",Be=["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"],It=["name","EVENTS","config","loaded"],E=Be.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),Qt=/^utm_/,en=/^an_prop_/,tn=/^an_trait_/;function Ti(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,p=i.initialUser,f=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(ie,a.anonymousId),f||e(fe,a.userId),p.traits&&e(ke,O({},f&&s.traits?s.traits:{},p.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,h=o.an_event,d=u.reduce(function(b,v){if(v.match(Qt)||v.match(/^(d|g)clid/)){var g=v.replace(Qt,"");b.campaign[g==="campaign"?"name":g]=o[v]}return v.match(en)&&(b.props[v.replace(en,"")]=o[v]),v.match(tn)&&(b.traits[v.replace(tn,"")]=o[v]),b},{campaign:{},props:{},traits:{}});n.dispatch(O({type:E.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),h&&setTimeout(function(){return t.track(h,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:E.campaign,campaign:d.campaign})}}return r(i)}}}}function ji(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===E.setItemEnd){if(n.key===ie)return O({},e,{anonymousId:n.value});if(n.key===fe)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[fe,ie,ke].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function nn(t){return{userId:t.getItem(fe),anonymousId:t.getItem(ie),traits:t.getItem(ke)}}var _t=function(t){return pe+"TEMP"+pe+t};function xi(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var p=s.userId,f=s.traits,u=s.options;if(s.type===E.reset&&([fe,ke,ie].forEach(function(d){r(d)}),[te,be,"traits"].forEach(function(d){je(_t(d))})),s.type===E.identify){i(ie)||n(ie,it());var c=i(fe),h=i(ke)||{};c&&c!==p&&o.dispatch({type:E.userIdChanged,old:{userId:c,traits:h},new:{userId:p,traits:f},options:u}),p&&n(fe,p),f&&n(ke,O({},h,f))}return a(s)}}}}var Ne={};function rn(t,e){Ne[t]&&G(Ne[t])&&(Ne[t](e),delete Ne[t])}function Vn(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 Vn(t,e,n-10).then(r,i)})})}function Ci(t){return{abort:t}}function Yn(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,p=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var f=s.actions.reduce(function(c,h,d){return a[h.plugin].loaded?(c.process.push(h),c.processIndex.push(d)):(c.requeue.push(h),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(c){var h=s.actions[c],d=h.plugin,b=h.payload.type,v=i[d][b];if(v&&G(v)){var g,I=function(l,k){return l===void 0&&(l={}),k===void 0&&(k={}),[te,be].reduce(function(T,P){return l.hasOwnProperty(P)&&k[P]&&k[P]!==l[P]&&(T[P]=k[P]),T},l)}(h.payload,p),_=r[I.meta.rid];if(!_&&(g=v({payload:I,config:a[d].config,instance:n,abort:Ci}))&&J(g)&&g.abort)return void(r[I.meta.rid]=!0);if(!_){var w=b+":"+d;t.dispatch(O({},I,{type:w,_:{called:w,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,h){return!~f.processIndex.indexOf(h)});s.actions=u}}}var ht=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 f=i.plugins,u=i.context,c=n.type,h=c.match(Ie),d=e.exact.map(function(g){return g.pluginName});h&&(d=a.during.map(function(g){return g.pluginName}));var b=function(g,I){return function(_,w,l){var k=w.config,T=w.name,P=T+"."+_.type;l&&(P=l.event);var x=_.type.match(Ie)?function(L,D,F,U,H){return function(Z,j){var K=U?U.name:L,M=j&&Ze(j)?j:F;if(U&&(!(M=j&&Ze(j)?j:[L]).includes(L)||M.length!==1))throw new Error("Method "+D+" can only abort "+L+" plugin. "+JSON.stringify(M)+" input valid");return O({},H,{abort:{reason:Z,plugins:M,caller:D,_:K}})}}(T,P,I,l,_):function(L,D){return function(){throw new Error(L.type+" action not cancellable. Remove abort in "+D)}}(_,P);return{payload:$i(_),instance:g,config:k||{},abort:x}}}(r,d),v=e.exact.reduce(function(g,I){var _=I.pluginName,w=I.methodName,l=!1;return w.match(/^initialize/)||w.match(/^reset/)||(l=!f[_].loaded),u.offline&&w.match(/^(page|track|identify)/)&&(l=!0),g[""+_]=l,g},{});return Promise.resolve(e.exact.reduce(function(g,I,_){try{var w=I.pluginName;return Promise.resolve(g).then(function(l){function k(){return Promise.resolve(l)}var T=function(){if(e.namespaced&&e.namespaced[w])return Promise.resolve(e.namespaced[w].reduce(function(P,x,L){try{return Promise.resolve(P).then(function(D){return x.method&&G(x.method)?(function(Z,j){var K=dn(Z);if(K&&K.name===j){var M=dn(K.method);throw new Error([j+" plugin is calling method "+Z,"Plugins cant call self","Use "+K.method+" "+(M?"or "+M.method:"")+" in "+j+" plugin insteadof "+Z].join(`
|
|
6
|
+
`))}}(x.methodName,x.pluginName),Promise.resolve(x.method({payload:D,instance:r,abort:(F=D,U=w,H=x.pluginName,function(Z,j){return O({},F,{abort:{reason:Z,plugins:j||[U],caller:c,from:H||U}})}),config:sn(x.pluginName,f,o),plugins:f})).then(function(Z){var j=J(Z)?Z:{};return Promise.resolve(O({},D,j))})):D;var F,U,H})}catch(D){return Promise.reject(D)}},Promise.resolve(n))).then(function(P){l[w]=P});l[w]=n}();return T&&T.then?T.then(k):k()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(g){return Promise.resolve(e.exact.reduce(function(I,_,w){try{var l=e.exact.length===w+1,k=_.pluginName,T=o[k];return Promise.resolve(I).then(function(P){var x=g[k]?g[k]:{};if(h&&(x=P),pt(x,k))return ft({data:x,method:c,instance:r,pluginName:k,store:s}),Promise.resolve(P);if(pt(P,k))return l&&ft({data:P,method:c,instance:r,store:s}),Promise.resolve(P);if(v.hasOwnProperty(k)&&v[k]===!0)return s.dispatch({type:"queue",plugin:k,payload:x,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(P);var L=b(g[k],o[k]);return Promise.resolve(T[c]({abort:L.abort,payload:x,instance:r,config:sn(k,f,o),plugins:f})).then(function(D){var F=J(D)?D:{},U=O({},P,F),H=g[k];if(pt(H,k))ft({data:H,method:c,instance:r,pluginName:k,store:s});else{var Z=c+":"+k;(Z.match(/:/g)||[]).length<2&&!c.match(on)&&!c.match(an)&&r.dispatch(O({},h?U:x,{type:Z,_:{called:Z,from:"submethod"}}))}return Promise.resolve(U)})})}catch(P){return Promise.reject(P)}},Promise.resolve(n))).then(function(I){if(!(c.match(Ie)||c.match(/^registerPlugin/)||c.match(an)||c.match(on)||c.match(/^params/)||c.match(/^userIdChanged/))){if(p.plugins.includes(c),I._&&I._.originalAction===c)return I;var _=O({},I,{_:{originalAction:I.type,called:I.type,from:"engineEnd"}});Gn(I,e.exact.length)&&!c.match(/End$/)&&(_=O({},_,{type:I.type+"Aborted"})),s.dispatch(_)}return I})})}catch(g){return Promise.reject(g)}},Ie=/Start$/,on=/^bootstrap/,an=/^ready/;function ft(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(O({},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 cn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function un(t,e){var n=t.replace(Ie,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function pt(t,e){var n=t.abort;return!!n&&(n===!0||ln(n,e)||n&&ln(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 Ze(n)&&n.length===e||Ze(r)&&r.length===e}function Ze(t){return Array.isArray(t)}function ln(t,e){return!(!t||!Ze(t))&&t.includes(e)}function dn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function $i(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=J(t[n])?Object.assign({},t[n]):t[n]),e},{})}function zi(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)},f=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(f===E.enablePlugin&&i.dispatch({type:E.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),f===E.disablePlugin&&setTimeout(function(){return rn(a.meta.rid,{payload:a})},0),f===E.initializeEnd){var h=e(),d=Object.keys(h),b=d.filter(function(l){return u.includes(l)}).map(function(l){return h[l]}),v=[],g=[],I=a.disabled,_=b.map(function(l){var k=l.loaded,T=l.name,P=l.config;return Vn(l,function(){return k({config:P})},1e4).then(function(x){return r[T]||(i.dispatch({type:E.pluginReadyType(T),name:T,events:Object.keys(l).filter(function(L){return!It.includes(L)})}),r[T]=!0),v=v.concat(T),l}).catch(function(x){if(x instanceof Error)throw new Error(x);return g=g.concat(x.name),x})});Promise.all(_).then(function(l){var k={plugins:v,failed:g,disabled:I};setTimeout(function(){d.length===_.length+I.length&&i.dispatch(O({},{type:E.ready},k))},0)})}var w=function(){if(f!==E.bootstrap)return/^ready:([^:]*)$/.test(f)&&setTimeout(function(){return Yn(i,e,t)},0),Promise.resolve(function(l,k,T,P,x){try{var L=G(k)?k():k,D=l.type,F=D.replace(Ie,"");if(l._&&l._.called)return Promise.resolve(l);var U=T.getState(),H=(K=L,(M=U.plugins)===void 0&&(M={}),(Ce=l.options)===void 0&&(Ce={}),Object.keys(K).filter(function(m){var y=Ce.plugins||{};return pi(y[m])?y[m]:y.all!==!1&&(!M[m]||M[m].enabled!==!1)}).map(function(m){return K[m]}));D===E.initializeStart&&l.fromEnable&&(H=Object.keys(U.plugins).filter(function(m){var y=U.plugins[m];return l.plugins.includes(m)&&!y.initialized}).map(function(m){return L[m]}));var Z=H.map(function(m){return m.name}),j=function(m,y,S){var C=un(m).map(function($){return cn($,y)});return y.reduce(function($,z){var W=z.name,N=un(m,W).map(function($e){return cn($e,y)}),R=N[0],A=N[1],q=N[2];return R.length&&($.beforeNS[W]=R),A.length&&($.duringNS[W]=A),q.length&&($.afterNS[W]=q),$},{before:C[0],beforeNS:{},during:C[1],duringNS:{},after:C[2],afterNS:{}})}(D,H);return Promise.resolve(ht({action:l,data:{exact:j.before,namespaced:j.beforeNS},state:U,allPlugins:L,allMatches:j,instance:T,store:P,EVENTS:x})).then(function(m){function y(){var $=function(){if(D.match(Ie))return Promise.resolve(ht({action:O({},S,{type:F+"End"}),data:{exact:j.after,namespaced:j.afterNS},state:U,allPlugins:L,allMatches:j,instance:T,store:P,EVENTS:x})).then(function(z){z.meta&&z.meta.hasCallback&&rn(z.meta.rid,{payload:z})})}();return $&&$.then?$.then(function(){return m}):m}if(Gn(m,Z.length))return m;var S,C=function(){if(D!==F)return Promise.resolve(ht({action:O({},m,{type:F}),data:{exact:j.during,namespaced:j.duringNS},state:U,allPlugins:L,allMatches:j,instance:T,store:P,EVENTS:x})).then(function($){S=$});S=m}();return C&&C.then?C.then(y):y()})}catch(m){return Promise.reject(m)}var K,M,Ce}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(w&&w.then?w.then(p):p(w))}catch(l){return Promise.reject(l)}}}}}function Ai(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 Ni=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 Te.apply(void 0,a)(r)(i)}}}}};function Di(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=hn(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 p=hn(n.type,E.initialize),f=t()[p];return f&&p?(r[p]=O({},e[p],{initialized:!0,loaded:!!f.loaded({config:f.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,fn(n.plugins,!1,e));case E.enablePlugin:return O({},e,fn(n.plugins,!0,e));default:return e}}}function hn(t,e){return t.substring(e.length+1,t.length)}function fn(t,e,n){return t.reduce(function(r,i){return r[i]=O({},n[i],{enabled:e}),r},n)}function Bn(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var Li={last:{},history:[]};function Ui(t,e){t===void 0&&(t=Li);var n=e.options,r=e.meta;if(e.type===E.track){var i=Bn(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 Ri={actions:[]};function Zi(t,e){t===void 0&&(t=Ri);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 qn=/#.*$/;function Wi(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(qn,""):"")}var Qn,er,tr,nr,Ki=function(t){if(t===void 0&&(t={}),!Y)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,f=o.search,u=function(h){var d=function(){if(Y){for(var b,v=document.getElementsByTagName("link"),g=0;b=v[g];g++)if(b.getAttribute("rel")==="canonical")return b.getAttribute("href")}}();return d?d.match(/\?/)?d:d+h:window.location.href.replace(qn,"")}(f),c={title:n,url:u,path:Wi(u),hash:p,search:f,width:a,height:s};return r&&r!==""&&(c.referrer=r),O({},c,t)},Mi={last:{},history:[]};function Ji(t,e){t===void 0&&(t=Mi);var n=e.options;if(e.type===E.page){var r=Bn(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}Qn=function(){if(!Y)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"}(),er=Y?document.referrer:null,tr=ki(),nr=Ii();var pn={initialized:!1,sessionId:it(),app:null,version:null,debug:!1,offline:!!Y&&!navigator.onLine,os:{name:Qn},userAgent:Y?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:nr,locale:tr,campaign:{},referrer:er};function Xi(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 Fi=["plugins","reducers","storage"];function Hi(t,e,n){if(Y){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function Vi(t){var e=Hi.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function rr(){return ge("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 Pe[Oe].analytics.push(a.action||a),o(a)}})}}}function mn(t){return function(){return Te(Te.apply(null,arguments),rr())}}function mt(t){return t?Xn(t)?t:[t]:[]}function gn(t,e,n){t===void 0&&(t={});var r,i,o=it();return e&&(Ne[o]=(r=e,i=function(a){for(var s,p=a||Array.prototype.slice.call(arguments),f=0;f<p.length;f++)if(G(p[f])){s=p[f];break}return s}(n),function(a){i&&i(a),r(a)})),O({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function Yi(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(m,y){if(G(y))return m.middlewares=m.middlewares.concat(y),m;if(y.NAMESPACE&&(y.name=y.NAMESPACE),!y.name)throw new Error("https://lytics.dev/errors/1");y.config||(y.config={});var S=y.EVENTS?Object.keys(y.EVENTS).map(function(z){return y.EVENTS[z]}):[];m.pluginEnabled[y.name]=!(y.enabled===!1||y.config.enabled===!1),delete y.enabled,y.methods&&(m.methods[y.name]=Object.keys(y.methods).reduce(function(z,W){var N;return z[W]=(N=y.methods[W],function(){for(var R=Array.prototype.slice.call(arguments),A=new Array(N.length),q=0;q<R.length;q++)A[q]=R[q];return A[A.length]=k,N.apply({instance:k},A)}),z},{}),delete y.methods);var C=Object.keys(y).concat(S),$=new Set(m.events.concat(C));if(m.events=Array.from($),m.pluginsArray=m.pluginsArray.concat(y),m.plugins[y.name])throw new Error(y.name+"AlreadyLoaded");return m.plugins[y.name]=y,m.plugins[y.name].loaded||(m.plugins[y.name].loaded=function(){return!0}),m},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),i=t.storage?t.storage:{getItem:me,setItem:ge,removeItem:je},o=function(m){return function(y,S,C){return S.getState("user")[y]||(C&&J(C)&&C[y]?C[y]:nn(m)[y]||me(_t(y))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!It.includes(m)}).sort(),p=new Set(s.concat(Be).filter(function(m){return!It.includes(m)})),f=Array.from(p).sort(),u=function(){return a},c=new Ni,h=c.addMiddleware,d=c.removeMiddleware,b=c.dynamicMiddlewares,v=function(){throw new Error("Abort disabled inListener")},g=_i(),I=nn(i),_=O({},I,n,g.an_uid?{userId:g.an_uid}:{},g.an_aid?{anonymousId:g.an_aid}:{});_.anonymousId||(_.anonymousId=it());var w=O({enable:function(m,y){return new Promise(function(S){j.dispatch({type:E.enablePlugin,plugins:mt(m),_:{originalAction:E.enablePlugin}},S,[y])})},disable:function(m,y){return new Promise(function(S){j.dispatch({type:E.disablePlugin,plugins:mt(m),_:{originalAction:E.disablePlugin}},S,[y])})}},r.methods),l=!1,k={identify:function(m,y,S,C){try{var $=re(m)?m:null,z=J(m)?m:y,W=S||{},N=k.user();ge(_t(te),$);var R=$||z.userId||o(te,k,z);return Promise.resolve(new Promise(function(A){j.dispatch(O({type:E.identifyStart,userId:R,traits:z||{},options:W,anonymousId:N.anonymousId},N.id&&N.id!==$&&{previousId:N.id}),A,[y,S,C])}))}catch(A){return Promise.reject(A)}},track:function(m,y,S,C){try{var $=J(m)?m.event:m;if(!$||!re($))throw new Error("EventMissing");var z=J(m)?m:y||{},W=J(S)?S:{};return Promise.resolve(new Promise(function(N){j.dispatch({type:E.trackStart,event:$,properties:z,options:W,userId:o(te,k,y),anonymousId:o(be,k,y)},N,[y,S,C])}))}catch(N){return Promise.reject(N)}},page:function(m,y,S){try{var C=J(m)?m:{},$=J(y)?y:{};return Promise.resolve(new Promise(function(z){j.dispatch({type:E.pageStart,properties:Ki(C),options:$,userId:o(te,k,C),anonymousId:o(be,k,C)},z,[m,y,S])}))}catch(z){return Promise.reject(z)}},user:function(m){if(m===te||m==="id")return o(te,k);if(m===be||m==="anonId")return o(be,k);var y=k.getState("user");return m?Yt(y,m):y},reset:function(m){return new Promise(function(y){j.dispatch({type:E.resetStart},y,m)})},ready:function(m){return l&&m({plugins:w,instance:k}),k.on(E.ready,function(y){m(y),l=!0})},on:function(m,y){if(!m||!G(y))return!1;if(m===E.bootstrap)throw new Error(".on disabled for "+m);var S=/Start$|Start:/;if(m==="*"){var C=function(N){return function(R){return function(A){return A.type.match(S)&&y({payload:A,instance:k,plugins:a}),R(A)}}},$=function(N){return function(R){return function(A){return A.type.match(S)||y({payload:A,instance:k,plugins:a}),R(A)}}};return h(C,He),h($,Ve),function(){d(C,He),d($,Ve)}}var z=m.match(S)?He:Ve,W=function(N){return function(R){return function(A){return A.type===m&&y({payload:A,instance:k,plugins:a,abort:v}),R(A)}}};return h(W,z),function(){return d(W,z)}},once:function(m,y){if(!m||!G(y))return!1;if(m===E.bootstrap)throw new Error(".once disabled for "+m);var S=k.on(m,function(C){y({payload:C.payload,instance:k,plugins:a,abort:v}),S()});return S},getState:function(m){var y=j.getState();return m?Yt(y,m):Object.assign({},y)},dispatch:function(m){var y=re(m)?{type:m}:m;if(Be.includes(y.type))throw new Error("reserved action "+y.type);var S=O({},y,{_:O({originalAction:y.type},m._||{})});j.dispatch(S)},enablePlugin:w.enable,disablePlugin:w.disable,plugins:w,storage:{getItem:i.getItem,setItem:function(m,y,S){j.dispatch({type:E.setItemStart,key:m,value:y,options:S})},removeItem:function(m,y){j.dispatch({type:E.removeItemStart,key:m,options:y})}},setAnonymousId:function(m,y){k.storage.setItem(ie,m,y)},events:{core:Be,plugins:s}},T=r.middlewares.concat([function(m){return function(y){return function(S){return S.meta||(S.meta=gn()),y(S)}}},b(He),zi(k,u,{all:f,plugins:s}),Ai(i),Ti(k),xi(k),b(Ve)]),P={context:Xi,user:ji(i),page:Ji,track:Ui,plugins:Di(u),queue:Zi},x=Te,L=Te;if(Y&&t.debug){var D=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;D&&(x=D({trace:!0,traceLimit:25})),L=function(){return arguments.length===0?rr():J(typeof arguments[0])?mn():mn().apply(null,arguments)}}var F,U=function(m){return Object.keys(m).reduce(function(y,S){return Fi.includes(S)||(y[S]=m[S]),y},{})}(t),H=r.pluginsArray.reduce(function(m,y){var S=y.name,C=y.config,$=y.loaded,z=r.pluginEnabled[S];return m[S]={enabled:z,initialized:!!z&&!y.initialize,loaded:!!$({config:C}),config:C},m},{}),Z={context:U,user:_,plugins:H},j=Hn(function(m){for(var y=Object.keys(m),S={},C=0;C<y.length;C++){var $=y[C];typeof m[$]===ne&&(S[$]=m[$])}var z,W=Object.keys(S);try{(function(N){Object.keys(N).forEach(function(R){var A=N[R];if(typeof A(void 0,{type:"@@redux/INIT"})===ee||typeof A(void 0,{type:Ei})===ee)throw new Error("reducer "+R+" "+ee)})})(S)}catch(N){z=N}return function(N,R){if(N===void 0&&(N={}),z)throw z;for(var A=!1,q={},$e=0;$e<W.length;$e++){var Ke=W[$e],Dt=N[Ke],st=(0,S[Ke])(Dt,R);if(typeof st===ee){var pr=Oi(Ke,R);throw new Error(pr)}q[Ke]=st,A=A||st!==Dt}return A?q:N}}(O({},P,e)),Z,L(x(Pi.apply(void 0,T))));j.dispatch=(F=j.dispatch,function(m,y,S){var C=O({},m,{meta:gn(m.meta,y,mt(S))});return F.apply(null,[C])});var K=Object.keys(a);j.dispatch({type:E.bootstrap,plugins:K,config:U,params:g,user:_,initialUser:n,persistedUser:I});var M=K.filter(function(m){return r.pluginEnabled[m]}),Ce=K.filter(function(m){return!r.pluginEnabled[m]});return j.dispatch({type:E.registerPlugins,plugins:K,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,y){var S=m.bootstrap,C=m.config,$=m.name;S&&G(S)&&S({instance:k,config:C,payload:m}),j.dispatch({type:E.registerPluginType($),name:$,enabled:r.pluginEnabled[$],plugin:m}),r.pluginsArray.length===y+1&&j.dispatch({type:E.initializeStart,plugins:M,disabled:Ce})}),Vi(function(m){j.dispatch({type:m?E.offline:E.online})}),function(m,y,S){setInterval(function(){return Yn(m,y,S)},3e3)}(j,u,k),k}var He="before",Ve="after",Le="cookie",ue=ar(),ir=ot,Gi=ot;function or(t){return ue?ot(t,"",-1):je(t)}function ar(){if(ue!==void 0)return ue;var t="cookiecookie";try{ot(t,t),ue=document.cookie.indexOf(t)!==-1,or(t)}catch{ue=!1}return ue}function ot(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return ue===!1&&(a?ge(t,e):me(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",Bi=jt.bind(null,"localStorage");xe("localStorage","getItem",me);xe("localStorage","setItem",ge);xe("localStorage","removeItem",je);var Re="sessionStorage",qi=jt.bind(null,"sessionStorage");xe("sessionStorage","getItem",me);xe("sessionStorage","setItem",ge);xe("sessionStorage","removeItem",je);function _e(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(J(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var Qi=Bi(),eo=qi(),to=ar();function sr(t,e){if(t){var n=xt(e),r=!At(n),i=Ct(n)?_e(localStorage.getItem(t)):void 0;if(r&&!we(i))return i;var o=$t(n)?_e(ir(t)):void 0;if(r&&o)return o;var a=zt(n)?_e(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=me(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function no(t,e,n){if(t&&!we(e)){var r={},i=xt(n),o=JSON.stringify(e),a=!At(i);return Ct(i)&&(r[Ue]=Ye(Ue,e,_e(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Ue]:$t(i)&&(r[Le]=Ye(Le,e,_e(ir(t))),Gi(t,o),a)?r[Le]:zt(i)&&(r[Re]=Ye(Re,e,_e(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Re]:(r[De]=Ye(De,e,me(t)),ge(t,e),a?r[De]:r)}}function ro(t,e){if(t){var n=xt(e),r=sr(t,Kn),i={};return!we(r.localStorage)&&Ct(n)&&(localStorage.removeItem(t),i[Ue]=r.localStorage),!we(r.cookie)&&$t(n)&&(or(t),i[Le]=r.cookie),!we(r.sessionStorage)&&zt(n)&&(sessionStorage.removeItem(t),i[Re]=r.sessionStorage),!we(r.global)&&at(n,De)&&(je(t),i[De]=r.global),i}}function xt(t){return t?re(t)?t:t.storage:Wn}function Ct(t){return Qi&&at(t,Ue)}function $t(t){return to&&at(t,Le)}function zt(t){return eo&&at(t,Re)}function At(t){return t===Kn||t==="all"}function at(t,e){return t===Wn||t===e||At(t)}function Ye(t,e,n){return{location:t,current:e,previous:n}}var io={setItem:no,getItem:sr,removeItem:ro};function oo(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yn(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 vn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yn(Object(n),!0).forEach(function(r){oo(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yn(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ao(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:io};return Yi(vn(vn({},e),t))}function so(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)}}}function co(t){if(typeof window>"u")return;const{addEventListener:e,history:n,location:r}=window;let i=r.pathname;e("popstate",()=>t(r.pathname)),["push","replace"].map(o=>{const a=`${o}State`;if(a!=="pushState"&&a!=="replaceState")return;const s=n[a];n[a]=function(...p){var c;const f=((c=p[2])==null?void 0:c.toString())||"",u=lo(f);return i!==u&&(i=u,setTimeout(()=>t(f),0)),s.apply(n,p)}})}function uo(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function lo(t){return["#","?"].forEach(e=>t=uo(t,e)),t}function ho(){co(()=>{se.page()})}var wn="EventListener";function fo(t){return function(e,n,r,i){var o=r||li,a=i||!1;if(!Y)return o;var s=et(n),p=et(e,!0);if(!p.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var f=[];return function u(c){c&&(f=[]);for(var h=c?"add"+wn:"remove"+wn,d=0;d<p.length;d++){var b=p[d];f[d]=c?a&&a.once?po(o):o:f[d]||o;for(var v=0;v<s.length;v++)b[h]?b["on"+s[v]]=c?f[d]:null:b[h](s[v],f[d],a)}return u.bind(null,!c)}(t)}}function et(t,e){if(re(t))return e?et(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=bi(t);return e?o.map(function(a){return re(a)?et(a,!0):a}).flat():o}function po(t,e){var n;return function(){return t&&(n=t.apply(e||this,arguments),t=null),n}}var gt=fo("Event");function cr(t,e){return Y&&G(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),G(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}cr.bind(null,"onerror");cr.bind(null,"onload");var ur=typeof window>"u",bn="hidden";function mo(t){if(ur)return!1;var e=go(),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 go(){var t=["webkit","moz","ms","o"];return ur||bn in document?bn:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var yo=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function vo(t,e){e===void 0&&(e={});var n=function(a,s){var p=this,f=!1;return function(u){f||(a.call(p,u),f=!0,setTimeout(function(){return f=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=mo(function(s){s||n({type:"tabVisible"})});return r=[a].concat(yo.map(function(s){return gt(document,s,n)})).concat(gt(window,"load",n)).concat(gt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function wo(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,f=p===void 0?2e3:p,u=!1,c=!1,h=new Date,d=function(){return clearTimeout(e)};function b(g){d(),o&&!u&&o(Ae(h),g),i&&u&&(u=!1,i(Ae(n),g),h=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(Ae(h),g))},s)}var v=vo(b,{throttle:f});return{disable:function(){c=!0,u=!1,d();var g=v();return function(){return c=!1,h=new Date,b({type:"load"}),g()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:Ae(h,c),idle:u?Ae(n,c):0}}}}function Ae(t,e){return e?0:Math.round((new Date-t)/1e3)}const kn=5e3;class bo{constructor(e){B(this,"element");B(this,"isInViewport",!1);B(this,"isAwake",!1);B(this,"isFlushing");B(this,"observer");B(this,"lastEventAt",Date.now());B(this,"registeredView",!1);B(this,"viewCallback");B(this,"activeDurationCallback");B(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),wo({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:kn})}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*kn: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 In="sesamy_session_id";function ko(){let t=sessionStorage.getItem(In);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(In,t)),t}let lr=!1,St,_n,tt;function Io({clientId:t,enabled:e=!0,endpoint:n=Kr}){if(St=t,_n=e,tt=n,!_n)return;ho();const r=new bo({element:document.body,viewCallback:()=>{se.page()},activeDurationCallback:(i,o)=>{se.track("activeDuration",{duration:i,flushing:o})},idleDurationCallback:(i,o)=>{se.track("idleDuration",{duration:i,flushing:o})}});So(document.body,()=>{r.flush()}),window.addEventListener(Se.AUTHENTICATED,async i=>{const o=i;await se.identify(o.detail.sub)}),window.addEventListener(Se.LOGOUT,async()=>{await se.track("logout",{}),Nt.flush(),await se.reset()})}function dr(t){return JSON.stringify(t.map(e=>({...e,clientId:St,requestId:Math.random().toString(36).slice(2,9),sessionId:ko(),timestamp:new Date().toISOString(),version:Tt,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:Zn,userAgent:navigator.userAgent,clientId:St}})))}const Nt=so(async t=>{if(t.length>0){const e=dr(t);lr?navigator.sendBeacon(tt,e):(await fetch(tt,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function yt(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(tt,dr([n]))}else Nt.push(t)}const se=ao({app:Zn,version:Tt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;yt({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;yt({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;yt({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function _o(){return lr=!0,Nt.flush()}const hr=new Map;function So(t,e){hr.set(t,e)}window.addEventListener("beforeunload",()=>{hr.forEach((t,e)=>{t.bind(e)()}),_o()});async function fr(t){Io({clientId:t.clientId,...t.analytics}),await Mr({clientId:t.clientId,...t.auth});const e=ci(t.api||{});return Et(Se.READY,{}),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);fr(e)}catch(e){console.error("Failed to parse config",e)}}exports.init=fr;
|
package/dist/sesamy-js.d.ts
CHANGED
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
export interface Config {
|
|
4
4
|
clientId: string;
|
|
5
|
-
|
|
5
|
+
api?: Partial<ApiConfig>;
|
|
6
6
|
analytics?: Partial<AnalyticsConfig>;
|
|
7
7
|
auth?: Partial<AuthConfig>;
|
|
8
8
|
}
|
|
9
|
+
export interface ApiConfig {
|
|
10
|
+
namespace?: string;
|
|
11
|
+
endpoint?: string;
|
|
12
|
+
}
|
|
9
13
|
export interface AnalyticsConfig {
|
|
10
14
|
clientId: string;
|
|
11
15
|
enabled?: boolean;
|
|
@@ -20,6 +24,20 @@ declare function isAuthenticated(): Promise<boolean>;
|
|
|
20
24
|
declare function getUser(): Promise<import("@auth0/auth0-spa-js").User | undefined>;
|
|
21
25
|
declare function loginWithRedirect(): Promise<void>;
|
|
22
26
|
declare function logout(): Promise<void>;
|
|
27
|
+
export type TagValue = string | number | (string | number)[];
|
|
28
|
+
export type Tag = {
|
|
29
|
+
id: string;
|
|
30
|
+
value: TagValue;
|
|
31
|
+
policies?: {
|
|
32
|
+
ttl?: number;
|
|
33
|
+
maxItems?: number;
|
|
34
|
+
unique?: boolean;
|
|
35
|
+
overflow?: "block" | "fifo";
|
|
36
|
+
ipSessionSharing?: boolean;
|
|
37
|
+
};
|
|
38
|
+
updatedAt: string;
|
|
39
|
+
createdAt: string;
|
|
40
|
+
};
|
|
23
41
|
export type Entitlement = {
|
|
24
42
|
id: string;
|
|
25
43
|
sku: string;
|
|
@@ -53,43 +71,7 @@ export type Bill = {
|
|
|
53
71
|
status: string;
|
|
54
72
|
createdAt: string;
|
|
55
73
|
};
|
|
56
|
-
export
|
|
57
|
-
export type Tag = {
|
|
58
|
-
id: string;
|
|
59
|
-
value: TagValue;
|
|
60
|
-
policies?: {
|
|
61
|
-
ttl?: number;
|
|
62
|
-
maxItems?: number;
|
|
63
|
-
unique?: boolean;
|
|
64
|
-
overflow?: "block" | "fifo";
|
|
65
|
-
ipSessionSharing?: boolean;
|
|
66
|
-
};
|
|
67
|
-
updatedAt: string;
|
|
68
|
-
createdAt: string;
|
|
69
|
-
};
|
|
70
|
-
declare function getEntitlements(): Promise<Entitlement[]>;
|
|
71
|
-
declare function getEntitlement(entitlementId: string): Promise<Entitlement | undefined>;
|
|
72
|
-
declare function getContracts(): Promise<Contract[]>;
|
|
73
|
-
declare function getContract(contractId: string): Promise<Contract | undefined>;
|
|
74
|
-
declare function getBills(): Promise<Bill[]>;
|
|
75
|
-
declare function getBill(billId: string): Promise<Bill | undefined>;
|
|
76
|
-
declare function getTags(): Promise<{
|
|
77
|
-
[id: string]: TagValue;
|
|
78
|
-
}[]>;
|
|
79
|
-
declare function setTag(id: string, tag: Tag): Promise<{
|
|
80
|
-
[id: string]: Tag;
|
|
81
|
-
}[]>;
|
|
82
|
-
declare function pushTag(id: string, tag: Tag): Promise<{
|
|
83
|
-
[id: string]: TagValue;
|
|
84
|
-
}[]>;
|
|
85
|
-
declare function accessArticle(articleId: string): Promise<{
|
|
86
|
-
status: string;
|
|
87
|
-
}>;
|
|
88
|
-
declare function getVersion(): string;
|
|
89
|
-
export interface SesamyApi {
|
|
90
|
-
articles: {
|
|
91
|
-
access: typeof accessArticle;
|
|
92
|
-
};
|
|
74
|
+
export declare function init(config: Config): Promise<{
|
|
93
75
|
auth: {
|
|
94
76
|
getUser: typeof getUser;
|
|
95
77
|
isAuthenticated: typeof isAuthenticated;
|
|
@@ -97,18 +79,23 @@ export interface SesamyApi {
|
|
|
97
79
|
logout: typeof logout;
|
|
98
80
|
};
|
|
99
81
|
tags: {
|
|
100
|
-
list:
|
|
101
|
-
|
|
102
|
-
|
|
82
|
+
list: () => Promise<{
|
|
83
|
+
[id: string]: TagValue;
|
|
84
|
+
}[]>;
|
|
85
|
+
set: (id: string, tag: Tag) => Promise<{
|
|
86
|
+
[id: string]: Tag;
|
|
87
|
+
}[]>;
|
|
88
|
+
push: (id: string, tag: Tag) => Promise<{
|
|
89
|
+
[id: string]: TagValue;
|
|
90
|
+
}[]>;
|
|
103
91
|
};
|
|
104
|
-
getEntitlement:
|
|
105
|
-
getEntitlements:
|
|
106
|
-
getContract:
|
|
107
|
-
getContracts:
|
|
108
|
-
getBill:
|
|
109
|
-
getBills:
|
|
110
|
-
getVersion:
|
|
111
|
-
}
|
|
112
|
-
export declare function init(config: Config): Promise<SesamyApi>;
|
|
92
|
+
getEntitlement: (entitlementId: string) => Promise<Entitlement | undefined>;
|
|
93
|
+
getEntitlements: () => Promise<Entitlement[]>;
|
|
94
|
+
getContract: (contractId: string) => Promise<Contract | undefined>;
|
|
95
|
+
getContracts: () => Promise<Contract[]>;
|
|
96
|
+
getBill: (billId: string) => Promise<Bill | undefined>;
|
|
97
|
+
getBills: () => Promise<Bill[]>;
|
|
98
|
+
getVersion: () => string;
|
|
99
|
+
}>;
|
|
113
100
|
|
|
114
101
|
export {};
|