@sesamy/sesamy-js 1.13.4 → 1.13.5
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/dist/sesamy-js.cjs +1 -1
- package/dist/sesamy-js.iife.js +1 -1
- package/dist/sesamy-js.mjs +1 -1
- package/package.json +1 -1
package/dist/sesamy-js.cjs
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
`,10)+1,a=i.substring(o)+(r?"//# sourceMappingURL="+r:""),s=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(s)}var Bt,qt,Qt,mt,ai=(Bt="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",qt=null,Qt=!1,function(t){return mt=mt||oi(Bt,qt,Qt),new Worker(mt,t)});const gt={};let si=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 ci={memory:()=>new Bn().enclosedCache,localstorage:()=>new Br},en=t=>ci[t],tn=t=>{const{openUrl:e,onRedirect:n}=t,r=te(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:e===!1||e?e:n})},yt=new Mr;let ui=class{constructor(e){let n,r;if(this.userCache=new Bn().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await yt.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(!nt())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(nt().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
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",!en(n))throw new Error(`Invalid cache location "${n}"`);r=en(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?Se:ri,this.orgHintCookieName=`auth0.${this.options.clientId}.organization_hint`,this.isAuthenticatedCookieName=(a=>`auth0.${a}.is.authenticated`)(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;const i=e.useCookiesForTransactions?this.cookieStorage:ii;var o;this.scope=Xe("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Qr(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Wn,this.cacheManager=new qr(r,r.allKeys?void 0:new si(r,this.options.clientId),this.nowProvider),this.domainUrl=(o=this.options.domain,/^https?:\/\//.test(o)?o:`https://${o}`),this.tokenIssuer=((a,s)=>a?a.startsWith("https://")?a:`https://${a}/`:`${s}/`)(this.options.issuer,this.domainUrl),typeof window<"u"&&window.Worker&&this.options.useRefreshTokens&&n==="memory"&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new ai)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Kn)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${Pt(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return ti({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:n,organization:r,leeway:this.options.leeway,max_age:(o=this.options.authorizationParams.max_age,typeof o!="string"?o:parseInt(o,10)||void 0),now:i});var o}_processOrgHint(e){e?this.cookieStorage.save(this.orgHintCookieName,e,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}async _prepareAuthorizeUrl(e,n,r){const i=Yt(pt()),o=Yt(pt()),a=pt(),s=(u=>{const c=new Uint8Array(u);return(p=>{const d={"+":"-","/":"_","=":""};return p.replace(/[+/=]/g,b=>d[b])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await nt().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),h=((u,c,p,d,b,S,w,P)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),p),{scope:Xe(c,p.scope),response_type:"code",response_mode:P||"query",state:d,nonce:b,redirect_uri:w||u.authorizationParams.redirect_uri,code_challenge:S,code_challenge_method:"S256"}))(this.options,this.scope,e,i,o,s,e.redirect_uri||this.options.authorizationParams.redirect_uri||r,n==null?void 0:n.response_mode),f=this._authorizeUrl(h);return{nonce:o,code_verifier:a,scope:h.scope,audience:h.audience||"default",redirect_uri:h.redirect_uri,state:i,url:f}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const h=window.screenX+(window.innerWidth-400)/2,f=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${h},top=${f},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!n.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const i=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await(s=>new Promise((h,f)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(p),window.removeEventListener("message",u,!1),f(new Fr(s.popup)))},1e3),p=setTimeout(()=>{clearInterval(c),f(new Wr(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(p),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return f(Y.fromPayload(d.data.response));h(d.data.response)}},window.addEventListener("message",u)}))(Object.assign(Object.assign({},n),{timeoutInSeconds:n.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}));if(i.state!==o.state)throw new Y("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=tn(e),{openUrl:i,fragment:o,appState:a}=r,s=te(r,["openUrl","fragment","appState"]),h=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,f=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=f,c=te(f,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),h&&{organization:h}));const p=o?`${u}#${o}`:u;i?await i(p):window.location.assign(p)}async handleRedirectCallback(e=window.location.href){const n=e.split("?").slice(1);if(n.length===0)throw new Error("There are no query params available for parsing.");const{state:r,code:i,error:o,error_description:a}=(c=>{c.indexOf("#")>-1&&(c=c.substring(0,c.indexOf("#")));const p=new URLSearchParams(c);return{state:p.get("state"),code:p.get("code")||void 0,error:p.get("error")||void 0,error_description:p.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new Y("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 Y("state_mismatch","Invalid state");const h=s.organization,f=s.nonce,u=s.redirect_uri;return await this._requestToken(Object.assign({audience:s.audience,scope:s.scope,code_verifier:s.code_verifier,grant_type:"authorization_code",code:i},u?{redirect_uri:u}:{}),{nonceIn:f,organization:h}),{appState:s.appState}}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get("auth0.is.authenticated"))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove("auth0.is.authenticated")}try{await this.getTokenSilently(e)}catch{}}async getTokenSilently(e={}){var n;const r=Object.assign(Object.assign({cacheMode:"on"},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Xe(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=gt[a];return s||(s=o().finally(()=>{delete gt[a],s=null}),gt[a]=s),s})(()=>this._getTokenSilently(r),`${this.options.clientId}::${r.authorizationParams.audience}::${r.authorizationParams.scope}`);return e.detailedResponse?i:i==null?void 0:i.access_token}async _getTokenSilently(e){const{cacheMode:n}=e,r=te(e,["cacheMode"]);if(n!=="off"){const i=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(i)return i}if(n!=="cache-only"){if(!await(async(i,o=3)=>{for(let a=0;a<o;a++)if(await i())return!0;return!1})(()=>yt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new Et;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const f=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(f)return f}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:h}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:h})}finally{await yt.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}}async getTokenWithPopup(e={},n={}){var r;const i=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Xe(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},Zr),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new me({scope:i.authorizationParams.scope,audience:i.authorizationParams.audience||"default",clientId:this.options.clientId}))).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(e){e.clientId!==null?e.clientId=e.clientId||this.options.clientId:delete e.clientId;const n=e.logoutParams||{},{federated:r}=n,i=te(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${Pt(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=tn(e),{openUrl:r}=n,i=te(n,["openUrl"]);e.clientId===null?await this.cacheManager.clear():await this.cacheManager.clear(e.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove("@@user@@");const o=this._buildLogoutUrl(i);r?await r(o):r!==!1&&window.location.assign(o)}async _getTokenFromIFrame(e){const n=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),r=this.cookieStorage.get(this.orgHintCookieName);r&&!n.organization&&(n.organization=r);const{url:i,state:o,nonce:a,code_verifier:s,redirect_uri:h,scope:f,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new Y("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const c=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,p=await((b,S,w=60)=>new Promise((P,_)=>{const v=window.document.createElement("iframe");v.setAttribute("width","0"),v.setAttribute("height","0"),v.style.display="none";const l=()=>{window.document.body.contains(v)&&(window.document.body.removeChild(v),window.removeEventListener("message",k,!1))};let k;const T=setTimeout(()=>{_(new Et),l()},1e3*w);k=function(O){if(O.origin!=S||!O.data||O.data.type!=="authorization_response")return;const C=O.source;C&&C.close(),O.data.response.error?_(Y.fromPayload(O.data.response)):P(O.data.response),clearTimeout(T),window.removeEventListener("message",k,!1),setTimeout(l,2e3)},window.addEventListener("message",k,!1),window.document.body.appendChild(v),v.setAttribute("src",b)}))(i,this.domainUrl,c);if(o!==p.state)throw new Y("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:p.code,grant_type:"authorization_code",redirect_uri:h,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},d),{scope:f,oauthTokenScope:d.scope,audience:u})}catch(c){throw c.error==="login_required"&&this.logout({openUrl:!1}),c}}async _getTokenUsingRefreshToken(e){const n=await this.cacheManager.get(new me({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 Yn(e.authorizationParams.audience||"default",e.authorizationParams.scope)}const r=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,i=typeof e.timeoutInSeconds=="number"?1e3*e.timeoutInSeconds:null;try{const o=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:"refresh_token",refresh_token:n&&n.refresh_token,redirect_uri:r}),i&&{timeout:i}));return Object.assign(Object.assign({},o),{scope:e.authorizationParams.scope,oauthTokenScope:o.scope,audience:e.authorizationParams.audience||"default"})}catch(o){if((o.message.indexOf("Missing Refresh Token")>-1||o.message&&o.message.indexOf("invalid refresh token")>-1)&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw o}}async _saveEntryInCache(e){const{id_token:n,decodedToken:r}=e,i=te(e,["id_token","decodedToken"]);this.userCache.set("@@user@@",{id_token:n,decodedToken:r}),await this.cacheManager.setIdToken(this.options.clientId,e.id_token,e.decodedToken),await this.cacheManager.set(i)}async _getIdTokenFromCache(){const e=this.options.authorizationParams.audience||"default",n=await this.cacheManager.getIdToken(new me({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 me({scope:e,audience:n,clientId:r}),60);if(i&&i.access_token){const{access_token:o,oauthTokenScope:a,expires_in:s}=i,h=await this._getIdTokenFromCache();return h&&Object.assign(Object.assign({id_token:h.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await Gr(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs},e),this.worker),a=await this._verifyIdToken(o.id_token,r,i);return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},o),{decodedToken:a,scope:e.scope,audience:e.audience||"default"}),o.scope?{oauthTokenScope:o.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(i||a.claims.org_id),Object.assign(Object.assign({},o),{decodedToken:a})}};async function li(t){const e=new ui(t);return await e.checkSession(),e}const fe="sesamy.com",di="https://sesa.my",hi="https://logs.sesamy.com/events",Ot="sesamyCacheTimestamp";var q=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.CLEAR_CACHE="sesamyJsClearCache",t.USER_ATTRIBUTE_CHANGED="sesamyUserAttributeChanged",t.PURCHASE="sesamyJsPurchase",t))(q||{});let G,er;const We="sesamyAccessToken";function Nt(){const t=localStorage.getItem(We);if(!t)return null;const e=tr(t);return(!e||!e.exp||e.exp<new Date().getTime()/1e3)&&localStorage.removeItem(We),t}function fi(t){try{const e=new URL(t).hostname,n=e.split(".");return n.length>1?n.slice(-2).join("."):e}catch{return null}}async function pi(t){if(t.enabled===!1)return;er=t.organization;const e={domain:t.endpoint||`token.${fe}`,clientId:t.clientId};if(fi(window.location.href)!==fe&&(e.cacheLocation="localstorage",e.useRefreshTokens=!0),G=await li(e),window.location.search.includes("code="))try{await G.handleRedirectCallback();const n=await G.getUser();ue(q.AUTHENTICATED,n);const r=new URL(location.href),i=r.searchParams;i.delete("code"),i.delete("state"),r.search=i.toString(),window.history.replaceState({},document.title,r.toString())}catch(n){console.error(n)}}async function Rt(){return Nt()?!0:G?G.isAuthenticated():!1}async function mi(){return Nt()?{sub:"local",name:"Local User"}:G?G.getUser():null}function zt(t){if(localStorage.removeItem(We),!G)throw new Error("Auth0 client not initialized");const e=(t==null?void 0:t.authorizationParams)||{};return G.loginWithRedirect({...t,authorizationParams:{organization:er,redirect_uri:window.location.href,...e}})}async function Ve(t=!0){const e=Nt();if(e)return e;try{return G?await G.getTokenSilently():null}catch(n){if(t)throw n;return null}}async function gi(t={}){if(localStorage.removeItem(We),ue(q.LOGOUT,{}),!!G)return G.logout({...t,logoutParams:{returnTo:window.location.href,...t.logoutParams}})}function tr(t){const e=t.split(".");if(e.length!==3)return null;const r=e[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(r).split("").map(function(o){return"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(i)}async function nr(t){const e=tr(t);if(!e||!e.exp||e.exp<new Date().getTime()/1e3)throw new Error("Invalid token");localStorage.setItem(We,t),ue(q.AUTHENTICATED,e)}const yi=(t,e)=>e.skipDedupe||e.method!=="GET",vi=(t,e)=>e.method+"@"+t,wi=t=>t.clone(),nn=({skip:t=yi,key:e=vi,resolver:n=wi}={})=>{const r=new Map;return i=>(o,a)=>{if(t(o,a))return i(o,a);const s=e(o,a);if(!r.has(s))r.set(s,[]);else return new Promise((h,f)=>{r.get(s).push([h,f])});try{return i(o,a).then(h=>(r.get(s).forEach(([f])=>f(n(h))),r.delete(s),h)).catch(h=>{throw r.get(s).forEach(([f,u])=>u(h)),r.delete(s),h})}catch(h){return r.delete(s),Promise.reject(h)}}},bi=(t,e)=>t*e,ki=t=>t&&t.ok,rn=({delayTimer:t=500,delayRamp:e=bi,maxAttempts:n=10,until:r=ki,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>h=>(f,u)=>{let c=0;if(s&&s(f,u))return h(f,u);const p=(d,b)=>Promise.resolve(r(d,b)).then(S=>S?d&&a?d:b?Promise.reject(b):d:(c++,!n||c<=n?new Promise(w=>{const P=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:b,url:f,options:u})).then((_={})=>{var v,l;w(h((v=_&&_.url)!==null&&v!==void 0?v:f,(l=_&&_.options)!==null&&l!==void 0?l:u))}):w(h(f,u))},P)}).then(p).catch(w=>{if(!o)throw w;return p(null,w)}):d&&a?d:Promise.reject(b||new Error("Number of attempts exceeded."))));return h(f,u).then(p).catch(d=>{if(!o)throw d;return p(null,d)})},Ii="application/json",rr="Content-Type",Ie=Symbol(),ir=Symbol();function on(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===rr.toLowerCase()))===null||e===void 0?void 0:e[1]}function an(t){return/^application\/.*json.*/.test(t)}const ye=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]=ye(a,o,n):r[i]=o,r},{...t})},je={options:{},errorType:"text",polyfills:{},polyfill(t,e=!0,n=!1,...r){const i=this.polyfills[t]||(typeof self<"u"?self[t]:null)||(typeof global<"u"?global[t]:null);if(e&&!i)throw new Error(t+" is not defined");return n&&i?new i(...r):i}};function Si(t,e=!1){je.options=e?t:ye(je.options,t)}function _i(t,e=!1){je.polyfills=e?t:ye(je.polyfills,t)}function Ei(t){je.errorType=t}const Pi=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class or extends Error{}const Ti=t=>{const e=Object.create(null);t=t._addons.reduce((v,l)=>l.beforeRequest&&l.beforeRequest(v,t._options,e)||v,t);const{_url:n,_options:r,_config:i,_catchers:o,_resolvers:a,_middlewares:s,_addons:h}=t,f=new Map(o),u=ye(i.options,r);let c=n;const p=Pi(s)((v,l)=>(c=v,i.polyfill("fetch")(v,l)))(n,u),d=new Error,b=p.catch(v=>{throw{[Ie]:v}}).then(v=>{if(!v.ok){const l=new or;if(l.cause=d,l.stack=l.stack+`
|
|
5
|
-
CAUSE: `+d.stack,l.response=v,l.url=c,v.type==="opaque")throw l;return v.text().then(k=>{var T;if(l.message=k,i.errorType==="json"||((T=v.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=v.status,l})}return v}),S=v=>v.catch(l=>{const k=l.hasOwnProperty(Ie),T=k?l[Ie]:l,O=(T==null?void 0:T.status)&&f.get(T.status)||f.get(T==null?void 0:T.name)||k&&f.has(Ie)&&f.get(Ie);if(O)return O(T,t);const C=f.get(ir);if(C)return C(T,t);throw T}),w=v=>l=>S(v?b.then(k=>k&&k[v]()).then(k=>l?l(k):k):b.then(k=>l?l(k):k)),P={_wretchReq:t,_fetchReq:p,_sharedState:e,res:w(null),json:w("json"),blob:w("blob"),formData:w("formData"),arrayBuffer:w("arrayBuffer"),text:w("text"),error(v,l){return f.set(v,l),this},badRequest(v){return this.error(400,v)},unauthorized(v){return this.error(401,v)},forbidden(v){return this.error(403,v)},notFound(v){return this.error(404,v)},timeout(v){return this.error(408,v)},internalError(v){return this.error(500,v)},fetchError(v){return this.error(Ie,v)}},_=h.reduce((v,l)=>({...v,...typeof l.resolver=="function"?l.resolver(v):l.resolver}),P);return a.reduce((v,l)=>l(v,t),_)},Oi={_url:"",_options:{},_config:je,_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:ye(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:ye(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:ye(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[rr]: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(ir,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=on(r._options.headers),o=this._config.polyfill("FormData",!1),a=typeof n=="object"&&!(o&&n instanceof o)&&(!r._options.headers||!i||an(i));return r=n?a?r.json(n,i):r.body(n):r,Ti(r._deferred.reduce((s,h)=>h(s,s._url,s._options),r))},get(t=""){return this.fetch("GET",t)},delete(t=""){return this.fetch("DELETE",t)},put(t,e=""){return this.fetch("PUT",e,t)},post(t,e=""){return this.fetch("POST",e,t)},patch(t,e=""){return this.fetch("PATCH",e,t)},head(t=""){return this.fetch("HEAD",t)},opts(t=""){return this.fetch("OPTIONS",t)},body(t){return{...this,_options:{...this._options,body:t}}},json(t,e){const n=on(this._options.headers);return this.content(e||an(n)&&n||Ii).body(JSON.stringify(t))}};function ie(t="",e={}){return{...Oi,_url:t,_options:e}}ie.default=ie;ie.options=Si;ie.errorType=Ei;ie.polyfills=_i;ie.WretchError=or;function ee(){sessionStorage.removeItem(Ot),ue(q.CLEAR_CACHE,{})}function ji(t){const e=t.endpoint||`https://api2.${fe}`,n=g=>async(I,E)=>{let L=sessionStorage.getItem(Ot);L||(L=Date.now().toString(),sessionStorage.setItem(Ot,L));const Z={...E,headers:{...E.headers,"Cache-Timestamp":L}};return g(I,Z)},r=(g=!1)=>I=>async(E,L)=>{let Z=null;if(Z=await Ve(g),!Z){if(g)throw new Error("No access token available");return I(E,L)}const N={...L,headers:{...L.headers,...Z?{Authorization:`Bearer ${Z}`}:{}}};return I(E,N)},i=g=>(I,E)=>{if(E.headers.Authorization)return g(I,E);const L=localStorage.getItem("__anon_id"),Z=btoa(`${L}:`),N={...E,headers:{...E.headers,Authorization:`Basic ${Z}`}};return g(I,N)},o=ie(e).headers({"Content-Type":"application/json"}).middlewares([n,r(),nn(),rn({delayTimer:1e3,delayRamp:(g,I)=>g*I,maxAttempts:3,until:g=>!!(g&&(g.ok||g.status>=400&&g.status<500)),retryOnNetworkError:!1})]),a=ie(e).headers({"Content-Type":"application/json"}).middlewares([n,r(!1),i,nn(),rn({delayTimer:1e3,delayRamp:(g,I)=>g*I,maxAttempts:3,until:g=>!!(g&&(g.ok||g.status>=400&&g.status<500)),retryOnNetworkError:!1})]);async function s(){return o.get("/entitlements").json()}async function h(g){const I=await o.get("/entitlements").json();return I==null?void 0:I.find(E=>E.id===g)}async function f(g){return o.get(`/entitlements/${g}/access`).json()}async function u(){return o.get("/contracts").json()}async function c(g){const I=await o.get("/contracts").json();return I==null?void 0:I.find(E=>E.id===g)}async function p(){return o.get("/subscriptions").json()}async function d(){return o.get("/bills").json()}async function b(g){const I=await o.get("/bills").json();return I==null?void 0:I.find(E=>E.id===g)}async function S(g,I){const E=await o.url(`/user-metadata/${g}`).put(I).json();return ue(q.USER_ATTRIBUTE_CHANGED,{}),ee(),E}async function w(g){const I=await o.url(`/user-metadata/${g}`).delete().res();return ee(),I.ok}async function P(g){return(await o.url(`/user-metadata/${g}`).get().json())[g]}async function _(){return await o.url("/user-metadata").get().json()}async function v(){return await o.url("/tags").get().json()}async function l(g){const I=await o.url(`/tags/${g}`).delete().res();return ee(),I.ok}async function k(g){const I=await o.url("/tags").post(g).res();return ue(q.USER_ATTRIBUTE_CHANGED,{}),ee(),I.ok}async function T(g){return(await a.url("/tallies").get().json())[g]}async function O(){return await a.url("/tallies").get().json()}async function C(g){const I=await a.url(`/tallies/${g}`).delete().res();return ee(),I.ok}async function R(g,I){return await a.url(`/tallies/${g}/push`).post(I).json()}async function z(g){return await o.url(`/products/${g}`).get().json()}async function K(){return await Rt()?await o.url("/profile").get().json():null}async function $(g){const I=await o.url("/profile").patch(g).res();return ee(),I.ok}async function U(){return await o.url("/payment-issues").get().json()}async function M(){return(await o.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function j(){return(await o.url("/profile/unlink-spotify").post().res()).ok}async function W(g){const I=await Ve(!1);if(!I)throw new Error("No access token available");const E=new URL(`https://spotify-oas.${fe}/sesamy-callback`);E.searchParams.set("access_token",I),E.searchParams.set("state",g),window.location.href=E.toString()}async function J(g){const I=await o.url(`/products/${g}/auto-onboard`).post().json();return I.length&&ee(),I}async function le(g,I=3600){const{shortlink:E}=await ie(di).post({url:g,ttl:I}).json();return E}async function m(g){const I=await Ve(!1);let E;switch(g.target){case"account":E=new URL(`https://account.${fe}/subscriptions/${t.clientId}`);break;case"consume":E=new URL(`https://consume.${fe}/@${t.clientId}/${g.sku}`),g.episodeId&&(E.href+=`/${g.episodeId}`);break;default:throw new Error("Invalid target")}return I&&(E.hash=`#access_token=${I}`),g.shorten?le(E.href,g.ttl):E.href}async function y(){const g=await Ve(!1),I=new URL(`https://account.${fe}/subscriptions/${t.clientId}`);g&&(I.hash=`#access_token=${g}`),window.location.href=I.toString()}return{getEntitlements:s,getEntitlement:h,getEntitlementAccess:f,getContracts:u,getContract:c,getProfile:K,updateProfile:$,getSubscriptions:p,getBills:d,getBill:b,setUserMetadata:S,deleteUserMetadata:w,getUserMetadata:P,listUserMetadata:_,getTags:v,deleteTag:l,setTag:k,getTally:T,getTallies:O,deleteTally:C,pushTally:R,getProduct:z,getPaymentIssues:U,autoOnboardProduct:J,isSpotifyLinked:M,unlinkSpotify:j,linkSpotify:W,generateLink:m,openHostedAccountPage:y}}const ar="@sesamy/sesamy-js",Dt="1.13.2";function sn(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 Ye="undefined",cn="object",jt=function(){},sr="any",cr="*",we="__",it=typeof process<"u"?process:{};it.env&&it.env.NODE_ENV;var H=typeof document<"u";it.versions!=null&&it.versions.node!=null;typeof Deno<"u"&&Deno.core;H&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function ur(t,e){return e.charAt(0)[t]()+e.slice(1)}var Ci=ur.bind(null,"toUpperCase"),xi=ur.bind(null,"toLowerCase");function Ai(t){return lr(t)?Ci("null"):typeof t=="object"?Ni(t):Object.prototype.toString.call(t).slice(8,-1)}function ot(t,e){e===void 0&&(e=!0);var n=Ai(t);return e?xi(n):n}function He(t,e){return typeof e===t}var V=He.bind(null,"function"),se=He.bind(null,"string"),_e=He.bind(null,"undefined"),$i=He.bind(null,"boolean");He.bind(null,"symbol");function lr(t){return t===null}function Li(t){return ot(t)==="number"&&!isNaN(t)}function dr(t){return ot(t)==="array"}function X(t){if(!Ui(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ui(t){return t&&(typeof t=="object"||t!==null)}function Ni(t){return V(t.constructor)?t.constructor.name:null}function Ri(t){return t instanceof Error||se(t.message)&&t.constructor&&Li(t.constructor.stackTraceLimit)}function hr(t,e){if(typeof e!="object"||lr(e))return!1;if(e instanceof t)return!0;var n=ot(new t(""));if(Ri(e))for(;e;){if(ot(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}hr.bind(null,TypeError);hr.bind(null,SyntaxError);function ct(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?zi(t,e):n}function zi(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function ut(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}ut(ct,"form");ut(ct,"button");ut(ct,"input");ut(ct,"select");function Di(t){return t?dr(t)?t:[t]:[]}function un(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Mi(){if(H){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Zi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Ki(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=un(n[1]),a=un(n[2]);o.substring(o.length-2)==="[]"?(r[o=o.substring(0,o.length-2)]||(r[o]=[])).push(a):r[o]=a===""||a}for(var s in r){var h=s.split("[");h.length>1&&(Wi(r,h.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){return H&&window.location.search.substring(1)}())}function Wi(t,e,n){for(var r=e.length-1,i=0;i<r;++i){var o=e[i];if(o==="__proto__"||o==="constructor")break;o in t||(t[o]={}),t=t[o]}t[e[r]]=n}function lt(){for(var t="",e=0,n=4294967295*Math.random()|0;e++<36;){var r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],i=15&n;t+=r=="-"||r=="4"?r:(r=="x"?i:3&i|8).toString(16),n=e%8==0?4294967295*Math.random()|0:n>>4}return t}function Fi(t,e){var n,r,i,o=null,a=0,s=function(){a=new Date,o=null,i=t.apply(n,r)};return function(){var h=new Date;a||(a=h);var f=e-(h-a);return n=this,r=arguments,f<=0?(clearTimeout(o),o=null,a=h,i=t.apply(n,r)):o||(o=setTimeout(s,f)),i}}var De="global",Ce=we+"global"+we,xe=typeof self===cn&&self.self===self&&self||typeof global===cn&&global.global===global&&global||void 0;function be(t){return xe[Ce][t]}function ke(t,e){return xe[Ce][t]=e}function $e(t){delete xe[Ce][t]}function Le(t,e,n){var r;try{if(Mt(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}xe[Ce]||(xe[Ce]={});var Ge={};function Mt(t){if(typeof Ge[t]!==Ye)return Ge[t];try{var e=window[t];e.setItem(Ye,Ye),e.removeItem(Ye)}catch{return Ge[t]=!1}return Ge[t]=!0}function A(){return A=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},A.apply(this,arguments)}var ae="function",re="undefined",Hi="@@redux/"+Math.random().toString(36),ln=function(){return typeof Symbol===ae&&Symbol.observable||"@@observable"}(),Be=" != "+ae;function fr(t,e,n){var r;if(typeof e===ae&&typeof n===re&&(n=e,e=void 0),typeof n!==re){if(typeof n!==ae)throw new Error("enhancer"+Be);return n(fr)(t,e)}if(typeof t!==ae)throw new Error("reducer"+Be);var i=t,o=e,a=[],s=a,h=!1;function f(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==ae)throw new Error("Listener"+Be);var b=!0;return f(),s.push(d),function(){if(b){b=!1,f();var S=s.indexOf(d);s.splice(S,1)}}}function p(d){if(!X(d))throw new Error("Act != obj");if(typeof d.type===re)throw new Error("ActType "+re);if(h)throw new Error("Dispatch in reducer");try{h=!0,o=i(o,d)}finally{h=!1}for(var b=a=s,S=0;S<b.length;S++)(0,b[S])();return d}return p({type:"@@redux/INIT"}),(r={dispatch:p,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ae)throw new Error("next reducer"+Be);i=d,p({type:"@@redux/INIT"})}})[ln]=function(){var d,b=c;return(d={subscribe:function(S){if(typeof S!="object")throw new TypeError("Observer != obj");function w(){S.next&&S.next(u())}return w(),{unsubscribe:b(w)}}})[ln]=function(){return this},d},r}function Ji(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+re}function Ae(){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 Xi(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,h={getState:a.getState,dispatch:function(f){return s(f)}};return o=[].slice.call(t).map(function(f){return f(h)}),A({},a,{dispatch:s=Ae.apply(void 0,o)(a.dispatch)})}}}var ce=we+"anon_id",ve=we+"user_id",Pe=we+"user_traits",oe="userId",Ee="anonymousId",rt=["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"],Ct=["name","EVENTS","config","loaded"],x=rt.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),dn=/^utm_/,hn=/^an_prop_/,fn=/^an_trait_/;function Vi(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===x.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,h=i.initialUser,f=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(ce,a.anonymousId),f||e(ve,a.userId),h.traits&&e(Pe,A({},f&&s.traits?s.traits:{},h.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,p=o.an_event,d=u.reduce(function(b,S){if(S.match(dn)||S.match(/^(d|g)clid/)){var w=S.replace(dn,"");b.campaign[w==="campaign"?"name":w]=o[S]}return S.match(hn)&&(b.props[S.replace(hn,"")]=o[S]),S.match(fn)&&(b.traits[S.replace(fn,"")]=o[S]),b},{campaign:{},props:{},traits:{}});n.dispatch(A({type:x.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),p&&setTimeout(function(){return t.track(p,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:x.campaign,campaign:d.campaign})}}return r(i)}}}}function Yi(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===x.setItemEnd){if(n.key===ce)return A({},e,{anonymousId:n.value});if(n.key===ve)return A({},e,{userId:n.value})}switch(n.type){case x.identify:return Object.assign({},e,{userId:n.userId,traits:A({},e.traits,n.traits)});case x.reset:return[ve,ce,Pe].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function pn(t){return{userId:t.getItem(ve),anonymousId:t.getItem(ce),traits:t.getItem(Pe)}}var xt=function(t){return we+"TEMP"+we+t};function Gi(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var h=s.userId,f=s.traits,u=s.options;if(s.type===x.reset&&([ve,Pe,ce].forEach(function(d){r(d)}),[oe,Ee,"traits"].forEach(function(d){$e(xt(d))})),s.type===x.identify){i(ce)||n(ce,lt());var c=i(ve),p=i(Pe)||{};c&&c!==h&&o.dispatch({type:x.userIdChanged,old:{userId:c,traits:p},new:{userId:h,traits:f},options:u}),h&&n(ve,h),f&&n(Pe,A({},p,f))}return a(s)}}}}var ze={};function mn(t,e){ze[t]&&V(ze[t])&&(ze[t](e),delete ze[t])}function pr(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(A({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return pr(t,e,n-10).then(r,i)})})}function Bi(t){return{abort:t}}function mr(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,h=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var f=s.actions.reduce(function(c,p,d){return a[p.plugin].loaded?(c.process.push(p),c.processIndex.push(d)):(c.requeue.push(p),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(c){var p=s.actions[c],d=p.plugin,b=p.payload.type,S=i[d][b];if(S&&V(S)){var w,P=function(l,k){return l===void 0&&(l={}),k===void 0&&(k={}),[oe,Ee].reduce(function(T,O){return l.hasOwnProperty(O)&&k[O]&&k[O]!==l[O]&&(T[O]=k[O]),T},l)}(p.payload,h),_=r[P.meta.rid];if(!_&&(w=S({payload:P,config:a[d].config,instance:n,abort:Bi}))&&X(w)&&w.abort)return void(r[P.meta.rid]=!0);if(!_){var v=b+":"+d;t.dispatch(A({},P,{type:v,_:{called:v,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,p){return!~f.processIndex.indexOf(p)});s.actions=u}}}var vt=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,h=t.EVENTS;try{var f=i.plugins,u=i.context,c=n.type,p=c.match(Te),d=e.exact.map(function(w){return w.pluginName});p&&(d=a.during.map(function(w){return w.pluginName}));var b=function(w,P){return function(_,v,l){var k=v.config,T=v.name,O=T+"."+_.type;l&&(O=l.event);var C=_.type.match(Te)?function(R,z,K,$,U){return function(M,j){var W=$?$.name:R,J=j&&Fe(j)?j:K;if($&&(!(J=j&&Fe(j)?j:[R]).includes(R)||J.length!==1))throw new Error("Method "+z+" can only abort "+R+" plugin. "+JSON.stringify(J)+" input valid");return A({},U,{abort:{reason:M,plugins:J,caller:z,_:W}})}}(T,O,P,l,_):function(R,z){return function(){throw new Error(R.type+" action not cancellable. Remove abort in "+z)}}(_,O);return{payload:qi(_),instance:w,config:k||{},abort:C}}}(r,d),S=e.exact.reduce(function(w,P){var _=P.pluginName,v=P.methodName,l=!1;return v.match(/^initialize/)||v.match(/^reset/)||(l=!f[_].loaded),u.offline&&v.match(/^(page|track|identify)/)&&(l=!0),w[""+_]=l,w},{});return Promise.resolve(e.exact.reduce(function(w,P,_){try{var v=P.pluginName;return Promise.resolve(w).then(function(l){function k(){return Promise.resolve(l)}var T=function(){if(e.namespaced&&e.namespaced[v])return Promise.resolve(e.namespaced[v].reduce(function(O,C,R){try{return Promise.resolve(O).then(function(z){return C.method&&V(C.method)?(function(M,j){var W=In(M);if(W&&W.name===j){var J=In(W.method);throw new Error([j+" plugin is calling method "+M,"Plugins cant call self","Use "+W.method+" "+(J?"or "+J.method:"")+" in "+j+" plugin insteadof "+M].join(`
|
|
5
|
+
CAUSE: `+d.stack,l.response=v,l.url=c,v.type==="opaque")throw l;return v.text().then(k=>{var T;if(l.message=k,i.errorType==="json"||((T=v.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=v.status,l})}return v}),S=v=>v.catch(l=>{const k=l.hasOwnProperty(Ie),T=k?l[Ie]:l,O=(T==null?void 0:T.status)&&f.get(T.status)||f.get(T==null?void 0:T.name)||k&&f.has(Ie)&&f.get(Ie);if(O)return O(T,t);const C=f.get(ir);if(C)return C(T,t);throw T}),w=v=>l=>S(v?b.then(k=>k&&k[v]()).then(k=>l?l(k):k):b.then(k=>l?l(k):k)),P={_wretchReq:t,_fetchReq:p,_sharedState:e,res:w(null),json:w("json"),blob:w("blob"),formData:w("formData"),arrayBuffer:w("arrayBuffer"),text:w("text"),error(v,l){return f.set(v,l),this},badRequest(v){return this.error(400,v)},unauthorized(v){return this.error(401,v)},forbidden(v){return this.error(403,v)},notFound(v){return this.error(404,v)},timeout(v){return this.error(408,v)},internalError(v){return this.error(500,v)},fetchError(v){return this.error(Ie,v)}},_=h.reduce((v,l)=>({...v,...typeof l.resolver=="function"?l.resolver(v):l.resolver}),P);return a.reduce((v,l)=>l(v,t),_)},Oi={_url:"",_options:{},_config:je,_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:ye(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:ye(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:ye(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[rr]: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(ir,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=on(r._options.headers),o=this._config.polyfill("FormData",!1),a=typeof n=="object"&&!(o&&n instanceof o)&&(!r._options.headers||!i||an(i));return r=n?a?r.json(n,i):r.body(n):r,Ti(r._deferred.reduce((s,h)=>h(s,s._url,s._options),r))},get(t=""){return this.fetch("GET",t)},delete(t=""){return this.fetch("DELETE",t)},put(t,e=""){return this.fetch("PUT",e,t)},post(t,e=""){return this.fetch("POST",e,t)},patch(t,e=""){return this.fetch("PATCH",e,t)},head(t=""){return this.fetch("HEAD",t)},opts(t=""){return this.fetch("OPTIONS",t)},body(t){return{...this,_options:{...this._options,body:t}}},json(t,e){const n=on(this._options.headers);return this.content(e||an(n)&&n||Ii).body(JSON.stringify(t))}};function ie(t="",e={}){return{...Oi,_url:t,_options:e}}ie.default=ie;ie.options=Si;ie.errorType=Ei;ie.polyfills=_i;ie.WretchError=or;function ee(){sessionStorage.removeItem(Ot),ue(q.CLEAR_CACHE,{})}function ji(t){const e=t.endpoint||`https://api2.${fe}`,n=g=>async(I,E)=>{let L=sessionStorage.getItem(Ot);L||(L=Date.now().toString(),sessionStorage.setItem(Ot,L));const Z={...E,headers:{...E.headers,"Cache-Timestamp":L}};return g(I,Z)},r=(g=!0)=>I=>async(E,L)=>{let Z=null;if(Z=await Ve(g),!Z){if(g)throw new Error("No access token available");return I(E,L)}const N={...L,headers:{...L.headers,...Z?{Authorization:`Bearer ${Z}`}:{}}};return I(E,N)},i=g=>(I,E)=>{if(E.headers.Authorization)return g(I,E);const L=localStorage.getItem("__anon_id"),Z=btoa(`${L}:`),N={...E,headers:{...E.headers,Authorization:`Basic ${Z}`}};return g(I,N)},o=ie(e).headers({"Content-Type":"application/json"}).middlewares([n,r(),nn(),rn({delayTimer:1e3,delayRamp:(g,I)=>g*I,maxAttempts:3,until:g=>!!(g&&(g.ok||g.status>=400&&g.status<500)),retryOnNetworkError:!1})]),a=ie(e).headers({"Content-Type":"application/json"}).middlewares([n,r(!1),i,nn(),rn({delayTimer:1e3,delayRamp:(g,I)=>g*I,maxAttempts:3,until:g=>!!(g&&(g.ok||g.status>=400&&g.status<500)),retryOnNetworkError:!1})]);async function s(){return o.get("/entitlements").json()}async function h(g){const I=await o.get("/entitlements").json();return I==null?void 0:I.find(E=>E.id===g)}async function f(g){return o.get(`/entitlements/${g}/access`).json()}async function u(){return o.get("/contracts").json()}async function c(g){const I=await o.get("/contracts").json();return I==null?void 0:I.find(E=>E.id===g)}async function p(){return o.get("/subscriptions").json()}async function d(){return o.get("/bills").json()}async function b(g){const I=await o.get("/bills").json();return I==null?void 0:I.find(E=>E.id===g)}async function S(g,I){const E=await o.url(`/user-metadata/${g}`).put(I).json();return ue(q.USER_ATTRIBUTE_CHANGED,{}),ee(),E}async function w(g){const I=await o.url(`/user-metadata/${g}`).delete().res();return ee(),I.ok}async function P(g){return(await o.url(`/user-metadata/${g}`).get().json())[g]}async function _(){return await o.url("/user-metadata").get().json()}async function v(){return await o.url("/tags").get().json()}async function l(g){const I=await o.url(`/tags/${g}`).delete().res();return ee(),I.ok}async function k(g){const I=await o.url("/tags").post(g).res();return ue(q.USER_ATTRIBUTE_CHANGED,{}),ee(),I.ok}async function T(g){return(await a.url("/tallies").get().json())[g]}async function O(){return await a.url("/tallies").get().json()}async function C(g){const I=await a.url(`/tallies/${g}`).delete().res();return ee(),I.ok}async function R(g,I){return await a.url(`/tallies/${g}/push`).post(I).json()}async function z(g){return await o.url(`/products/${g}`).get().json()}async function K(){return await Rt()?await o.url("/profile").get().json():null}async function $(g){const I=await o.url("/profile").patch(g).res();return ee(),I.ok}async function U(){return await o.url("/payment-issues").get().json()}async function M(){return(await o.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function j(){return(await o.url("/profile/unlink-spotify").post().res()).ok}async function W(g){const I=await Ve(!1);if(!I)throw new Error("No access token available");const E=new URL(`https://spotify-oas.${fe}/sesamy-callback`);E.searchParams.set("access_token",I),E.searchParams.set("state",g),window.location.href=E.toString()}async function J(g){const I=await o.url(`/products/${g}/auto-onboard`).post().json();return I.length&&ee(),I}async function le(g,I=3600){const{shortlink:E}=await ie(di).post({url:g,ttl:I}).json();return E}async function m(g){const I=await Ve(!1);let E;switch(g.target){case"account":E=new URL(`https://account.${fe}/subscriptions/${t.clientId}`);break;case"consume":E=new URL(`https://consume.${fe}/@${t.clientId}/${g.sku}`),g.episodeId&&(E.href+=`/${g.episodeId}`);break;default:throw new Error("Invalid target")}return I&&(E.hash=`#access_token=${I}`),g.shorten?le(E.href,g.ttl):E.href}async function y(){const g=await Ve(!1),I=new URL(`https://account.${fe}/subscriptions/${t.clientId}`);g&&(I.hash=`#access_token=${g}`),window.location.href=I.toString()}return{getEntitlements:s,getEntitlement:h,getEntitlementAccess:f,getContracts:u,getContract:c,getProfile:K,updateProfile:$,getSubscriptions:p,getBills:d,getBill:b,setUserMetadata:S,deleteUserMetadata:w,getUserMetadata:P,listUserMetadata:_,getTags:v,deleteTag:l,setTag:k,getTally:T,getTallies:O,deleteTally:C,pushTally:R,getProduct:z,getPaymentIssues:U,autoOnboardProduct:J,isSpotifyLinked:M,unlinkSpotify:j,linkSpotify:W,generateLink:m,openHostedAccountPage:y}}const ar="@sesamy/sesamy-js",Dt="1.13.2";function sn(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 Ye="undefined",cn="object",jt=function(){},sr="any",cr="*",we="__",it=typeof process<"u"?process:{};it.env&&it.env.NODE_ENV;var H=typeof document<"u";it.versions!=null&&it.versions.node!=null;typeof Deno<"u"&&Deno.core;H&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function ur(t,e){return e.charAt(0)[t]()+e.slice(1)}var Ci=ur.bind(null,"toUpperCase"),xi=ur.bind(null,"toLowerCase");function Ai(t){return lr(t)?Ci("null"):typeof t=="object"?Ni(t):Object.prototype.toString.call(t).slice(8,-1)}function ot(t,e){e===void 0&&(e=!0);var n=Ai(t);return e?xi(n):n}function He(t,e){return typeof e===t}var V=He.bind(null,"function"),se=He.bind(null,"string"),_e=He.bind(null,"undefined"),$i=He.bind(null,"boolean");He.bind(null,"symbol");function lr(t){return t===null}function Li(t){return ot(t)==="number"&&!isNaN(t)}function dr(t){return ot(t)==="array"}function X(t){if(!Ui(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Ui(t){return t&&(typeof t=="object"||t!==null)}function Ni(t){return V(t.constructor)?t.constructor.name:null}function Ri(t){return t instanceof Error||se(t.message)&&t.constructor&&Li(t.constructor.stackTraceLimit)}function hr(t,e){if(typeof e!="object"||lr(e))return!1;if(e instanceof t)return!0;var n=ot(new t(""));if(Ri(e))for(;e;){if(ot(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}hr.bind(null,TypeError);hr.bind(null,SyntaxError);function ct(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?zi(t,e):n}function zi(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function ut(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}ut(ct,"form");ut(ct,"button");ut(ct,"input");ut(ct,"select");function Di(t){return t?dr(t)?t:[t]:[]}function un(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function Mi(){if(H){var t=navigator,e=t.languages;return t.userLanguage||(e&&e.length?e[0]:t.language)}}function Zi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function Ki(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=un(n[1]),a=un(n[2]);o.substring(o.length-2)==="[]"?(r[o=o.substring(0,o.length-2)]||(r[o]=[])).push(a):r[o]=a===""||a}for(var s in r){var h=s.split("[");h.length>1&&(Wi(r,h.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){return H&&window.location.search.substring(1)}())}function Wi(t,e,n){for(var r=e.length-1,i=0;i<r;++i){var o=e[i];if(o==="__proto__"||o==="constructor")break;o in t||(t[o]={}),t=t[o]}t[e[r]]=n}function lt(){for(var t="",e=0,n=4294967295*Math.random()|0;e++<36;){var r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],i=15&n;t+=r=="-"||r=="4"?r:(r=="x"?i:3&i|8).toString(16),n=e%8==0?4294967295*Math.random()|0:n>>4}return t}function Fi(t,e){var n,r,i,o=null,a=0,s=function(){a=new Date,o=null,i=t.apply(n,r)};return function(){var h=new Date;a||(a=h);var f=e-(h-a);return n=this,r=arguments,f<=0?(clearTimeout(o),o=null,a=h,i=t.apply(n,r)):o||(o=setTimeout(s,f)),i}}var De="global",Ce=we+"global"+we,xe=typeof self===cn&&self.self===self&&self||typeof global===cn&&global.global===global&&global||void 0;function be(t){return xe[Ce][t]}function ke(t,e){return xe[Ce][t]=e}function $e(t){delete xe[Ce][t]}function Le(t,e,n){var r;try{if(Mt(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}xe[Ce]||(xe[Ce]={});var Ge={};function Mt(t){if(typeof Ge[t]!==Ye)return Ge[t];try{var e=window[t];e.setItem(Ye,Ye),e.removeItem(Ye)}catch{return Ge[t]=!1}return Ge[t]=!0}function A(){return A=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},A.apply(this,arguments)}var ae="function",re="undefined",Hi="@@redux/"+Math.random().toString(36),ln=function(){return typeof Symbol===ae&&Symbol.observable||"@@observable"}(),Be=" != "+ae;function fr(t,e,n){var r;if(typeof e===ae&&typeof n===re&&(n=e,e=void 0),typeof n!==re){if(typeof n!==ae)throw new Error("enhancer"+Be);return n(fr)(t,e)}if(typeof t!==ae)throw new Error("reducer"+Be);var i=t,o=e,a=[],s=a,h=!1;function f(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==ae)throw new Error("Listener"+Be);var b=!0;return f(),s.push(d),function(){if(b){b=!1,f();var S=s.indexOf(d);s.splice(S,1)}}}function p(d){if(!X(d))throw new Error("Act != obj");if(typeof d.type===re)throw new Error("ActType "+re);if(h)throw new Error("Dispatch in reducer");try{h=!0,o=i(o,d)}finally{h=!1}for(var b=a=s,S=0;S<b.length;S++)(0,b[S])();return d}return p({type:"@@redux/INIT"}),(r={dispatch:p,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ae)throw new Error("next reducer"+Be);i=d,p({type:"@@redux/INIT"})}})[ln]=function(){var d,b=c;return(d={subscribe:function(S){if(typeof S!="object")throw new TypeError("Observer != obj");function w(){S.next&&S.next(u())}return w(),{unsubscribe:b(w)}}})[ln]=function(){return this},d},r}function Ji(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+re}function Ae(){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 Xi(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,h={getState:a.getState,dispatch:function(f){return s(f)}};return o=[].slice.call(t).map(function(f){return f(h)}),A({},a,{dispatch:s=Ae.apply(void 0,o)(a.dispatch)})}}}var ce=we+"anon_id",ve=we+"user_id",Pe=we+"user_traits",oe="userId",Ee="anonymousId",rt=["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"],Ct=["name","EVENTS","config","loaded"],x=rt.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),dn=/^utm_/,hn=/^an_prop_/,fn=/^an_trait_/;function Vi(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===x.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,h=i.initialUser,f=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(ce,a.anonymousId),f||e(ve,a.userId),h.traits&&e(Pe,A({},f&&s.traits?s.traits:{},h.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,p=o.an_event,d=u.reduce(function(b,S){if(S.match(dn)||S.match(/^(d|g)clid/)){var w=S.replace(dn,"");b.campaign[w==="campaign"?"name":w]=o[S]}return S.match(hn)&&(b.props[S.replace(hn,"")]=o[S]),S.match(fn)&&(b.traits[S.replace(fn,"")]=o[S]),b},{campaign:{},props:{},traits:{}});n.dispatch(A({type:x.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),p&&setTimeout(function(){return t.track(p,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:x.campaign,campaign:d.campaign})}}return r(i)}}}}function Yi(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===x.setItemEnd){if(n.key===ce)return A({},e,{anonymousId:n.value});if(n.key===ve)return A({},e,{userId:n.value})}switch(n.type){case x.identify:return Object.assign({},e,{userId:n.userId,traits:A({},e.traits,n.traits)});case x.reset:return[ve,ce,Pe].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function pn(t){return{userId:t.getItem(ve),anonymousId:t.getItem(ce),traits:t.getItem(Pe)}}var xt=function(t){return we+"TEMP"+we+t};function Gi(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var h=s.userId,f=s.traits,u=s.options;if(s.type===x.reset&&([ve,Pe,ce].forEach(function(d){r(d)}),[oe,Ee,"traits"].forEach(function(d){$e(xt(d))})),s.type===x.identify){i(ce)||n(ce,lt());var c=i(ve),p=i(Pe)||{};c&&c!==h&&o.dispatch({type:x.userIdChanged,old:{userId:c,traits:p},new:{userId:h,traits:f},options:u}),h&&n(ve,h),f&&n(Pe,A({},p,f))}return a(s)}}}}var ze={};function mn(t,e){ze[t]&&V(ze[t])&&(ze[t](e),delete ze[t])}function pr(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(A({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return pr(t,e,n-10).then(r,i)})})}function Bi(t){return{abort:t}}function mr(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,h=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var f=s.actions.reduce(function(c,p,d){return a[p.plugin].loaded?(c.process.push(p),c.processIndex.push(d)):(c.requeue.push(p),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(c){var p=s.actions[c],d=p.plugin,b=p.payload.type,S=i[d][b];if(S&&V(S)){var w,P=function(l,k){return l===void 0&&(l={}),k===void 0&&(k={}),[oe,Ee].reduce(function(T,O){return l.hasOwnProperty(O)&&k[O]&&k[O]!==l[O]&&(T[O]=k[O]),T},l)}(p.payload,h),_=r[P.meta.rid];if(!_&&(w=S({payload:P,config:a[d].config,instance:n,abort:Bi}))&&X(w)&&w.abort)return void(r[P.meta.rid]=!0);if(!_){var v=b+":"+d;t.dispatch(A({},P,{type:v,_:{called:v,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,p){return!~f.processIndex.indexOf(p)});s.actions=u}}}var vt=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,h=t.EVENTS;try{var f=i.plugins,u=i.context,c=n.type,p=c.match(Te),d=e.exact.map(function(w){return w.pluginName});p&&(d=a.during.map(function(w){return w.pluginName}));var b=function(w,P){return function(_,v,l){var k=v.config,T=v.name,O=T+"."+_.type;l&&(O=l.event);var C=_.type.match(Te)?function(R,z,K,$,U){return function(M,j){var W=$?$.name:R,J=j&&Fe(j)?j:K;if($&&(!(J=j&&Fe(j)?j:[R]).includes(R)||J.length!==1))throw new Error("Method "+z+" can only abort "+R+" plugin. "+JSON.stringify(J)+" input valid");return A({},U,{abort:{reason:M,plugins:J,caller:z,_:W}})}}(T,O,P,l,_):function(R,z){return function(){throw new Error(R.type+" action not cancellable. Remove abort in "+z)}}(_,O);return{payload:qi(_),instance:w,config:k||{},abort:C}}}(r,d),S=e.exact.reduce(function(w,P){var _=P.pluginName,v=P.methodName,l=!1;return v.match(/^initialize/)||v.match(/^reset/)||(l=!f[_].loaded),u.offline&&v.match(/^(page|track|identify)/)&&(l=!0),w[""+_]=l,w},{});return Promise.resolve(e.exact.reduce(function(w,P,_){try{var v=P.pluginName;return Promise.resolve(w).then(function(l){function k(){return Promise.resolve(l)}var T=function(){if(e.namespaced&&e.namespaced[v])return Promise.resolve(e.namespaced[v].reduce(function(O,C,R){try{return Promise.resolve(O).then(function(z){return C.method&&V(C.method)?(function(M,j){var W=In(M);if(W&&W.name===j){var J=In(W.method);throw new Error([j+" plugin is calling method "+M,"Plugins cant call self","Use "+W.method+" "+(J?"or "+J.method:"")+" in "+j+" plugin insteadof "+M].join(`
|
|
6
6
|
`))}}(C.methodName,C.pluginName),Promise.resolve(C.method({payload:z,instance:r,abort:(K=z,$=v,U=C.pluginName,function(M,j){return A({},K,{abort:{reason:M,plugins:j||[$],caller:c,from:U||$}})}),config:vn(C.pluginName,f,o),plugins:f})).then(function(M){var j=X(M)?M:{};return Promise.resolve(A({},z,j))})):z;var K,$,U})}catch(z){return Promise.reject(z)}},Promise.resolve(n))).then(function(O){l[v]=O});l[v]=n}();return T&&T.then?T.then(k):k()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(w){return Promise.resolve(e.exact.reduce(function(P,_,v){try{var l=e.exact.length===v+1,k=_.pluginName,T=o[k];return Promise.resolve(P).then(function(O){var C=w[k]?w[k]:{};if(p&&(C=O),bt(C,k))return wt({data:C,method:c,instance:r,pluginName:k,store:s}),Promise.resolve(O);if(bt(O,k))return l&&wt({data:O,method:c,instance:r,store:s}),Promise.resolve(O);if(S.hasOwnProperty(k)&&S[k]===!0)return s.dispatch({type:"queue",plugin:k,payload:C,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(O);var R=b(w[k],o[k]);return Promise.resolve(T[c]({abort:R.abort,payload:C,instance:r,config:vn(k,f,o),plugins:f})).then(function(z){var K=X(z)?z:{},$=A({},O,K),U=w[k];if(bt(U,k))wt({data:U,method:c,instance:r,pluginName:k,store:s});else{var M=c+":"+k;(M.match(/:/g)||[]).length<2&&!c.match(gn)&&!c.match(yn)&&r.dispatch(A({},p?$:C,{type:M,_:{called:M,from:"submethod"}}))}return Promise.resolve($)})})}catch(O){return Promise.reject(O)}},Promise.resolve(n))).then(function(P){if(!(c.match(Te)||c.match(/^registerPlugin/)||c.match(yn)||c.match(gn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(h.plugins.includes(c),P._&&P._.originalAction===c)return P;var _=A({},P,{_:{originalAction:P.type,called:P.type,from:"engineEnd"}});gr(P,e.exact.length)&&!c.match(/End$/)&&(_=A({},_,{type:P.type+"Aborted"})),s.dispatch(_)}return P})})}catch(w){return Promise.reject(w)}},Te=/Start$/,gn=/^bootstrap/,yn=/^ready/;function wt(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(A({},t.data,{type:n,_:{called:n,from:"abort"}}))}function vn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function wn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function bn(t,e){var n=t.replace(Te,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function bt(t,e){var n=t.abort;return!!n&&(n===!0||kn(n,e)||n&&kn(n.plugins,e))}function gr(t,e){var n=t.abort;if(!n)return!1;if(n===!0||se(n))return!0;var r=n.plugins;return Fe(n)&&n.length===e||Fe(r)&&r.length===e}function Fe(t){return Array.isArray(t)}function kn(t,e){return!(!t||!Fe(t))&&t.includes(e)}function In(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function qi(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=X(t[n])?Object.assign({},t[n]):t[n]),e},{})}function Qi(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,h=function(l){return s?l:o(c)},f=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(f===x.enablePlugin&&i.dispatch({type:x.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),f===x.disablePlugin&&setTimeout(function(){return mn(a.meta.rid,{payload:a})},0),f===x.initializeEnd){var p=e(),d=Object.keys(p),b=d.filter(function(l){return u.includes(l)}).map(function(l){return p[l]}),S=[],w=[],P=a.disabled,_=b.map(function(l){var k=l.loaded,T=l.name,O=l.config;return pr(l,function(){return k({config:O})},1e4).then(function(C){return r[T]||(i.dispatch({type:x.pluginReadyType(T),name:T,events:Object.keys(l).filter(function(R){return!Ct.includes(R)})}),r[T]=!0),S=S.concat(T),l}).catch(function(C){if(C instanceof Error)throw new Error(C);return w=w.concat(C.name),C})});Promise.all(_).then(function(l){var k={plugins:S,failed:w,disabled:P};setTimeout(function(){d.length===_.length+P.length&&i.dispatch(A({},{type:x.ready},k))},0)})}var v=function(){if(f!==x.bootstrap)return/^ready:([^:]*)$/.test(f)&&setTimeout(function(){return mr(i,e,t)},0),Promise.resolve(function(l,k,T,O,C){try{var R=V(k)?k():k,z=l.type,K=z.replace(Te,"");if(l._&&l._.called)return Promise.resolve(l);var $=T.getState(),U=(W=R,(J=$.plugins)===void 0&&(J={}),(le=l.options)===void 0&&(le={}),Object.keys(W).filter(function(m){var y=le.plugins||{};return $i(y[m])?y[m]:y.all!==!1&&(!J[m]||J[m].enabled!==!1)}).map(function(m){return W[m]}));z===x.initializeStart&&l.fromEnable&&(U=Object.keys($.plugins).filter(function(m){var y=$.plugins[m];return l.plugins.includes(m)&&!y.initialized}).map(function(m){return R[m]}));var M=U.map(function(m){return m.name}),j=function(m,y,g){var I=bn(m).map(function(E){return wn(E,y)});return y.reduce(function(E,L){var Z=L.name,N=bn(m,Z).map(function(Ue){return wn(Ue,y)}),F=N[0],D=N[1],Q=N[2];return F.length&&(E.beforeNS[Z]=F),D.length&&(E.duringNS[Z]=D),Q.length&&(E.afterNS[Z]=Q),E},{before:I[0],beforeNS:{},during:I[1],duringNS:{},after:I[2],afterNS:{}})}(z,U);return Promise.resolve(vt({action:l,data:{exact:j.before,namespaced:j.beforeNS},state:$,allPlugins:R,allMatches:j,instance:T,store:O,EVENTS:C})).then(function(m){function y(){var E=function(){if(z.match(Te))return Promise.resolve(vt({action:A({},g,{type:K+"End"}),data:{exact:j.after,namespaced:j.afterNS},state:$,allPlugins:R,allMatches:j,instance:T,store:O,EVENTS:C})).then(function(L){L.meta&&L.meta.hasCallback&&mn(L.meta.rid,{payload:L})})}();return E&&E.then?E.then(function(){return m}):m}if(gr(m,M.length))return m;var g,I=function(){if(z!==K)return Promise.resolve(vt({action:A({},m,{type:K}),data:{exact:j.during,namespaced:j.duringNS},state:$,allPlugins:R,allMatches:j,instance:T,store:O,EVENTS:C})).then(function(E){g=E});g=m}();return I&&I.then?I.then(y):y()})}catch(m){return Promise.reject(m)}var W,J,le}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(v&&v.then?v.then(h):h(v))}catch(l){return Promise.reject(l)}}}}}function eo(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===x.setItem||i===x.removeItem){if(r.abort)return n(r);i===x.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var to=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 Ae.apply(void 0,a)(r)(i)}}}}};function no(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=Sn(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},A({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var h=Sn(n.type,x.initialize),f=t()[h];return f&&h?(r[h]=A({},e[h],{initialized:!0,loaded:!!f.loaded({config:f.config})}),A({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=A({},e[n.name],{loaded:!0}),A({},e,r);switch(n.type){case x.disablePlugin:return A({},e,_n(n.plugins,!1,e));case x.enablePlugin:return A({},e,_n(n.plugins,!0,e));default:return e}}}function Sn(t,e){return t.substring(e.length+1,t.length)}function _n(t,e,n){return t.reduce(function(r,i){return r[i]=A({},n[i],{enabled:e}),r},n)}function yr(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var ro={last:{},history:[]};function io(t,e){t===void 0&&(t=ro);var n=e.options,r=e.meta;if(e.type===x.track){var i=yr(A({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return A({},t,{last:i,history:t.history.concat(i)})}return t}var oo={actions:[]};function ao(t,e){t===void 0&&(t=oo);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===x.identify?[e].concat(t.actions):t.actions.concat(e),A({},t,{actions:r});case"dequeue":return[];default:return t}}var vr=/#.*$/;function so(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(vr,""):"")}var wr,br,kr,Ir,co=function(t){if(t===void 0&&(t={}),!H)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,h=o.hash,f=o.search,u=function(p){var d=function(){if(H){for(var b,S=document.getElementsByTagName("link"),w=0;b=S[w];w++)if(b.getAttribute("rel")==="canonical")return b.getAttribute("href")}}();return d?d.match(/\?/)?d:d+p:window.location.href.replace(vr,"")}(f),c={title:n,url:u,path:so(u),hash:h,search:f,width:a,height:s};return r&&r!==""&&(c.referrer=r),A({},c,t)},uo={last:{},history:[]};function lo(t,e){t===void 0&&(t=uo);var n=e.options;if(e.type===x.page){var r=yr(A({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return A({},t,{last:r,history:t.history.concat(r)})}return t}wr=function(){if(!H)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"}(),br=H?document.referrer:null,kr=Mi(),Ir=Zi();var En={initialized:!1,sessionId:lt(),app:null,version:null,debug:!1,offline:!!H&&!navigator.onLine,os:{name:wr},userAgent:H?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:Ir,locale:kr,campaign:{},referrer:br};function ho(t,e){t===void 0&&(t=En);var n=t.initialized,r=e.campaign;switch(e.type){case x.campaign:return A({},t,{campaign:r});case x.offline:return A({},t,{offline:!0});case x.online:return A({},t,{offline:!1});default:return n?t:A({},En,t,{initialized:!0})}}var fo=["plugins","reducers","storage"];function po(t,e,n){if(H){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function mo(t){var e=po.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function Sr(){return ke("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 xe[Ce].analytics.push(a.action||a),o(a)}})}}}function Pn(t){return function(){return Ae(Ae.apply(null,arguments),Sr())}}function kt(t){return t?dr(t)?t:[t]:[]}function Tn(t,e,n){t===void 0&&(t={});var r,i,o=lt();return e&&(ze[o]=(r=e,i=function(a){for(var s,h=a||Array.prototype.slice.call(arguments),f=0;f<h.length;f++)if(V(h[f])){s=h[f];break}return s}(n),function(a){i&&i(a),r(a)})),A({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function go(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(m,y){if(V(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 g=y.EVENTS?Object.keys(y.EVENTS).map(function(L){return y.EVENTS[L]}):[];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(L,Z){var N;return L[Z]=(N=y.methods[Z],function(){for(var F=Array.prototype.slice.call(arguments),D=new Array(N.length),Q=0;Q<F.length;Q++)D[Q]=F[Q];return D[D.length]=k,N.apply({instance:k},D)}),L},{}),delete y.methods);var I=Object.keys(y).concat(g),E=new Set(m.events.concat(I));if(m.events=Array.from(E),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:be,setItem:ke,removeItem:$e},o=function(m){return function(y,g,I){return g.getState("user")[y]||(I&&X(I)&&I[y]?I[y]:pn(m)[y]||be(xt(y))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!Ct.includes(m)}).sort(),h=new Set(s.concat(rt).filter(function(m){return!Ct.includes(m)})),f=Array.from(h).sort(),u=function(){return a},c=new to,p=c.addMiddleware,d=c.removeMiddleware,b=c.dynamicMiddlewares,S=function(){throw new Error("Abort disabled inListener")},w=Ki(),P=pn(i),_=A({},P,n,w.an_uid?{userId:w.an_uid}:{},w.an_aid?{anonymousId:w.an_aid}:{});_.anonymousId||(_.anonymousId=lt());var v=A({enable:function(m,y){return new Promise(function(g){j.dispatch({type:x.enablePlugin,plugins:kt(m),_:{originalAction:x.enablePlugin}},g,[y])})},disable:function(m,y){return new Promise(function(g){j.dispatch({type:x.disablePlugin,plugins:kt(m),_:{originalAction:x.disablePlugin}},g,[y])})}},r.methods),l=!1,k={identify:function(m,y,g,I){try{var E=se(m)?m:null,L=X(m)?m:y,Z=g||{},N=k.user();ke(xt(oe),E);var F=E||L.userId||o(oe,k,L);return Promise.resolve(new Promise(function(D){j.dispatch(A({type:x.identifyStart,userId:F,traits:L||{},options:Z,anonymousId:N.anonymousId},N.id&&N.id!==E&&{previousId:N.id}),D,[y,g,I])}))}catch(D){return Promise.reject(D)}},track:function(m,y,g,I){try{var E=X(m)?m.event:m;if(!E||!se(E))throw new Error("EventMissing");var L=X(m)?m:y||{},Z=X(g)?g:{};return Promise.resolve(new Promise(function(N){j.dispatch({type:x.trackStart,event:E,properties:L,options:Z,userId:o(oe,k,y),anonymousId:o(Ee,k,y)},N,[y,g,I])}))}catch(N){return Promise.reject(N)}},page:function(m,y,g){try{var I=X(m)?m:{},E=X(y)?y:{};return Promise.resolve(new Promise(function(L){j.dispatch({type:x.pageStart,properties:co(I),options:E,userId:o(oe,k,I),anonymousId:o(Ee,k,I)},L,[m,y,g])}))}catch(L){return Promise.reject(L)}},user:function(m){if(m===oe||m==="id")return o(oe,k);if(m===Ee||m==="anonId")return o(Ee,k);var y=k.getState("user");return m?sn(y,m):y},reset:function(m){return new Promise(function(y){j.dispatch({type:x.resetStart},y,m)})},ready:function(m){return l&&m({plugins:v,instance:k}),k.on(x.ready,function(y){m(y),l=!0})},on:function(m,y){if(!m||!V(y))return!1;if(m===x.bootstrap)throw new Error(".on disabled for "+m);var g=/Start$|Start:/;if(m==="*"){var I=function(N){return function(F){return function(D){return D.type.match(g)&&y({payload:D,instance:k,plugins:a}),F(D)}}},E=function(N){return function(F){return function(D){return D.type.match(g)||y({payload:D,instance:k,plugins:a}),F(D)}}};return p(I,qe),p(E,Qe),function(){d(I,qe),d(E,Qe)}}var L=m.match(g)?qe:Qe,Z=function(N){return function(F){return function(D){return D.type===m&&y({payload:D,instance:k,plugins:a,abort:S}),F(D)}}};return p(Z,L),function(){return d(Z,L)}},once:function(m,y){if(!m||!V(y))return!1;if(m===x.bootstrap)throw new Error(".once disabled for "+m);var g=k.on(m,function(I){y({payload:I.payload,instance:k,plugins:a,abort:S}),g()});return g},getState:function(m){var y=j.getState();return m?sn(y,m):Object.assign({},y)},dispatch:function(m){var y=se(m)?{type:m}:m;if(rt.includes(y.type))throw new Error("reserved action "+y.type);var g=A({},y,{_:A({originalAction:y.type},m._||{})});j.dispatch(g)},enablePlugin:v.enable,disablePlugin:v.disable,plugins:v,storage:{getItem:i.getItem,setItem:function(m,y,g){j.dispatch({type:x.setItemStart,key:m,value:y,options:g})},removeItem:function(m,y){j.dispatch({type:x.removeItemStart,key:m,options:y})}},setAnonymousId:function(m,y){k.storage.setItem(ce,m,y)},events:{core:rt,plugins:s}},T=r.middlewares.concat([function(m){return function(y){return function(g){return g.meta||(g.meta=Tn()),y(g)}}},b(qe),Qi(k,u,{all:f,plugins:s}),eo(i),Vi(k),Gi(k),b(Qe)]),O={context:ho,user:Yi(i),page:lo,track:io,plugins:no(u),queue:ao},C=Ae,R=Ae;if(H&&t.debug){var z=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;z&&(C=z({trace:!0,traceLimit:25})),R=function(){return arguments.length===0?Sr():X(typeof arguments[0])?Pn():Pn().apply(null,arguments)}}var K,$=function(m){return Object.keys(m).reduce(function(y,g){return fo.includes(g)||(y[g]=m[g]),y},{})}(t),U=r.pluginsArray.reduce(function(m,y){var g=y.name,I=y.config,E=y.loaded,L=r.pluginEnabled[g];return m[g]={enabled:L,initialized:!!L&&!y.initialize,loaded:!!E({config:I}),config:I},m},{}),M={context:$,user:_,plugins:U},j=fr(function(m){for(var y=Object.keys(m),g={},I=0;I<y.length;I++){var E=y[I];typeof m[E]===ae&&(g[E]=m[E])}var L,Z=Object.keys(g);try{(function(N){Object.keys(N).forEach(function(F){var D=N[F];if(typeof D(void 0,{type:"@@redux/INIT"})===re||typeof D(void 0,{type:Hi})===re)throw new Error("reducer "+F+" "+re)})})(g)}catch(N){L=N}return function(N,F){if(N===void 0&&(N={}),L)throw L;for(var D=!1,Q={},Ue=0;Ue<Z.length;Ue++){var Je=Z[Ue],Xt=N[Je],ft=(0,g[Je])(Xt,F);if(typeof ft===re){var Rr=Ji(Je,F);throw new Error(Rr)}Q[Je]=ft,D=D||ft!==Xt}return D?Q:N}}(A({},O,e)),M,R(C(Xi.apply(void 0,T))));j.dispatch=(K=j.dispatch,function(m,y,g){var I=A({},m,{meta:Tn(m.meta,y,kt(g))});return K.apply(null,[I])});var W=Object.keys(a);j.dispatch({type:x.bootstrap,plugins:W,config:$,params:w,user:_,initialUser:n,persistedUser:P});var J=W.filter(function(m){return r.pluginEnabled[m]}),le=W.filter(function(m){return!r.pluginEnabled[m]});return j.dispatch({type:x.registerPlugins,plugins:W,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,y){var g=m.bootstrap,I=m.config,E=m.name;g&&V(g)&&g({instance:k,config:I,payload:m}),j.dispatch({type:x.registerPluginType(E),name:E,enabled:r.pluginEnabled[E],plugin:m}),r.pluginsArray.length===y+1&&j.dispatch({type:x.initializeStart,plugins:J,disabled:le})}),mo(function(m){j.dispatch({type:m?x.offline:x.online})}),function(m,y,g){setInterval(function(){return mr(m,y,g)},3e3)}(j,u,k),k}var qe="before",Qe="after",Me="cookie",pe=Pr(),_r=dt,yo=dt;function Er(t){return pe?dt(t,"",-1):$e(t)}function Pr(){if(pe!==void 0)return pe;var t="cookiecookie";try{dt(t,t),pe=document.cookie.indexOf(t)!==-1,Er(t)}catch{pe=!1}return pe}function dt(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return pe===!1&&(a?ke(t,e):be(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 Ze="localStorage",vo=Mt.bind(null,"localStorage");Le("localStorage","getItem",be);Le("localStorage","setItem",ke);Le("localStorage","removeItem",$e);var Ke="sessionStorage",wo=Mt.bind(null,"sessionStorage");Le("sessionStorage","getItem",be);Le("sessionStorage","setItem",ke);Le("sessionStorage","removeItem",$e);function Oe(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(X(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var bo=vo(),ko=wo(),Io=Pr();function Tr(t,e){if(t){var n=Zt(e),r=!Ht(n),i=Kt(n)?Oe(localStorage.getItem(t)):void 0;if(r&&!_e(i))return i;var o=Wt(n)?Oe(_r(t)):void 0;if(r&&o)return o;var a=Ft(n)?Oe(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=be(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function So(t,e,n){if(t&&!_e(e)){var r={},i=Zt(n),o=JSON.stringify(e),a=!Ht(i);return Kt(i)&&(r[Ze]=et(Ze,e,Oe(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[Ze]:Wt(i)&&(r[Me]=et(Me,e,Oe(_r(t))),yo(t,o),a)?r[Me]:Ft(i)&&(r[Ke]=et(Ke,e,Oe(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Ke]:(r[De]=et(De,e,be(t)),ke(t,e),a?r[De]:r)}}function _o(t,e){if(t){var n=Zt(e),r=Tr(t,cr),i={};return!_e(r.localStorage)&&Kt(n)&&(localStorage.removeItem(t),i[Ze]=r.localStorage),!_e(r.cookie)&&Wt(n)&&(Er(t),i[Me]=r.cookie),!_e(r.sessionStorage)&&Ft(n)&&(sessionStorage.removeItem(t),i[Ke]=r.sessionStorage),!_e(r.global)&&ht(n,De)&&($e(t),i[De]=r.global),i}}function Zt(t){return t?se(t)?t:t.storage:sr}function Kt(t){return bo&&ht(t,Ze)}function Wt(t){return Io&&ht(t,Me)}function Ft(t){return ko&&ht(t,Ke)}function Ht(t){return t===cr||t==="all"}function ht(t,e){return t===sr||t===e||Ht(t)}function et(t,e,n){return{location:t,current:e,previous:n}}var Eo={setItem:So,getItem:Tr,removeItem:_o};function Po(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function On(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 jn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?On(Object(n),!0).forEach(function(r){Po(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):On(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function To(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:Eo};return go(jn(jn({},e),t))}function Oo(t,e){e=e||{};var n,r,i=[],o=e.max||1/0;function a(){clearInterval(n),t(i.splice(0,o)),s()}function s(){n=setInterval(a,e.interval||1e4)}return s(),{flush:a,push:function(h){return r=i.push(h),r>=o&&a(),r},size:function(){return i.length},end:function(h){h&&a(),clearInterval(n)}}}function jo(t){if(typeof window>"u")return;const{addEventListener:e,history:n,location:r}=window;let i=r.pathname;e("popstate",()=>t(r.pathname)),["push","replace"].map(o=>{const a=`${o}State`;if(a!=="pushState"&&a!=="replaceState")return;const s=n[a];n[a]=function(...h){var c;const f=((c=h[2])==null?void 0:c.toString())||"",u=xo(f);return i!==u&&(i=u,setTimeout(()=>t(f),0)),s.apply(n,h)}})}function Co(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function xo(t){return["#","?"].forEach(e=>t=Co(t,e)),t}function Ao(){jo(()=>{ne.page()})}function $o(t){if(t===void 0&&(t={}),!H)return jt;var e=xn(),n=At(),r=Cn(),i=tt(r,e),o=tt(n,e),a=[],s=[],h=[],f=r,u=i,c=o,p=Object.keys(t);if(!p.length)return jt;var d=p.map(function(S){return Number(S)}),b=Fi(function(){var S=xn(),w=function($,U){return U.map(function(M){return M===100?$-5:$*(M/100)})}(S,d),P=At(),_=Cn(),v=tt(_,S),l=tt(P,S);if(u=v>u?v:u,c=l<c?l:c,!(a.length>=d.length)){var k=f===_,T="up";k?T="initial":f<=_&&(T="down");var O=w,C=d;(T==="up"||k)&&(O=w.slice().reverse(),C=d.slice().reverse());var R=C.reduce(function($,U,M){var j=O[M];return h.includes(U)&&_<=j&&(h=h.filter(function(W){return W!==U}),$.singleFunction=U),T==="down"&&!a.includes(U)&&_>=j&&U>o?(s.push(U),$.callbacks=$.callbacks.concat(U),$):T==="up"&&!a.includes(U)&&_<=j&&U<=v?($.foundFunc=[U],$):(k&&_>=j&&$.foundFunc.length===0&&($.foundFunc=[U]),!s.includes(U)&&_>=j&&(s.push(U),$.singleFunction?h.push(U):$.singleFunction=U),$)},{foundFunc:[],singleFunction:null,callbacks:[],direction:T});if(f=_,T==="down"&&R.callbacks&&R.callbacks.forEach(function($){V(t[$])&&(t[$]({trigger:$,direction:T,scrollMin:c,scrollMax:u,range:[c,u]}),a.push($))}),R.singleFunction){var z=R.singleFunction,K=R.direction;V(t[z])&&t[z]({trigger:z,direction:K,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(z)}}},500);return window.addEventListener("scroll",b),function(){return window.removeEventListener("scroll",b)}}function At(){return H?document.body.scrollTop||document.documentElement.scrollTop:0}function Lo(){return H?window.innerHeight||document.documentElement.clientHeight:0}function Cn(){return Math.round(At()+Lo())}function xn(){if(!H)return 0;var t=document.body,e=document.documentElement;return Math.max(t.scrollHeight,t.offsetHeight,e.clientHeight,e.scrollHeight,e.offsetHeight)}function tt(t,e){return Math.round(t/e*100)}var An="EventListener";function Uo(t){return function(e,n,r,i){var o=r||jt,a=i||!1;if(!H)return o;var s=at(n),h=at(e,!0);if(!h.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var f=[];return function u(c){c&&(f=[]);for(var p=c?"add"+An:"remove"+An,d=0;d<h.length;d++){var b=h[d];f[d]=c?a&&a.once?No(o):o:f[d]||o;for(var S=0;S<s.length;S++)b[p]?b["on"+s[S]]=c?f[d]:null:b[p](s[S],f[d],a)}return u.bind(null,!c)}(t)}}function at(t,e){if(se(t))return e?at(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=Di(t);return e?o.map(function(a){return se(a)?at(a,!0):a}).flat():o}function No(t,e){var n;return function(){return t&&(n=t.apply(this,arguments),t=null),n}}var It=Uo("Event");function Or(t,e){return H&&V(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),V(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}Or.bind(null,"onerror");Or.bind(null,"onload");var jr=typeof window>"u",$n="hidden";function Ro(t){if(jr)return!1;var e=zo(),n="".concat(e.replace(/[H|h]idden/,""),"visibilitychange"),r=function(){return t(!!document[e])},i=function(){return document.addEventListener(n,r)};return i(),function(){return document.removeEventListener(n,r),i}}function zo(){var t=["webkit","moz","ms","o"];return jr||$n in document?$n:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var Do=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function Mo(t,e){e===void 0&&(e={});var n=function(a,s){var h=this,f=!1;return function(u){f||(a.call(h,u),f=!0,setTimeout(function(){return f=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=Ro(function(s){s||n({type:"tabVisible"})});return r=[a].concat(Do.map(function(s){return It(document,s,n)})).concat(It(window,"load",n)).concat(It(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Zo(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,h=t.throttle,f=h===void 0?2e3:h,u=!1,c=!1,p=new Date,d=function(){return clearTimeout(e)};function b(w){d(),o&&!u&&o(Re(p),w),i&&u&&(u=!1,i(Re(n),w),p=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(Re(p),w))},s)}var S=Mo(b,{throttle:f});return{disable:function(){c=!0,u=!1,d();var w=S();return function(){return c=!1,p=new Date,b({type:"load"}),w()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:Re(p,c),idle:u?Re(n,c):0}}}}function Re(t,e){return e?0:Math.round((new Date-t)/1e3)}const Ln=5e3;class Ko{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");B(this,"scrollCallback");this.element=e.element,this.viewCallback=e.viewCallback,this.activeDurationCallback=e.activeDurationCallback,this.idleDurationCallback=e.idleDurationCallback,this.scrollCallback=e.scrollCallback,this.observer=new IntersectionObserver(n=>{n.forEach(r=>{this.handleInViewPort(r.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),Zo({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:Ln}),$o({25:this.handleScroll.bind(this),50:this.handleScroll.bind(this),75:this.handleScroll.bind(this),90:this.handleScroll.bind(this),100:this.handleScroll.bind(this)})}flush(){this.isFlushing=!0,this.handleAwake(!this.isAwake)}handleInViewPort(e){e?(this.isAwake=!0,this.trackInViewport()):this.handleAwake(!1),this.isInViewport=e}handleAwake(e,n=Math.round((Date.now()-this.lastEventAt)/1e3)){this.isAwake=e,this.lastEventAt=e?Date.now()-n*Ln:Date.now(),this.isInViewport&&this.trackAwake(e,n)}handleScroll(e){this.scrollCallback&&this.scrollCallback(e)}handleVisibilityChange(){this.isAwake=!1;const e=Math.round((Date.now()-this.lastEventAt)/1e3);e>1&&(this.lastEventAt=Date.now(),this.trackAwake(!1,e))}trackAwake(e,n){!e&&this.activeDurationCallback&&this.activeDurationCallback(n,this.isFlushing,this.lastEventAt),e&&this.idleDurationCallback&&this.idleDurationCallback(n,this.isFlushing,this.lastEventAt)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}const Un="sesamy_session_id";function Wo(){let t=sessionStorage.getItem(Un);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(Un,t)),t}let Cr=!1,$t,Nn,st;function Fo({clientId:t,enabled:e=!0,endpoint:n=hi}){if($t=t,Nn=e,st=n,!Nn)return;Ao();const r=new Ko({element:document.body,viewCallback:()=>{ne.page()},activeDurationCallback:(i,o,a)=>{ne.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{ne.track("idleDuration",{duration:i,durationStart:a,flushing:o})},scrollCallback:i=>{ne.track("scroll",{scroll:i.scrollMax})}});Xo(document.body,()=>{r.flush()}),Vo(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(q.AUTHENTICATED,async i=>{const o=i;await ne.identify(o.detail.sub)}),window.addEventListener(q.LOGOUT,async()=>{await ne.track("logout",{}),Jt.flush(),await ne.reset()})}function xr(t){return JSON.stringify(t.map(e=>({...e,clientId:$t,requestId:Math.random().toString(36).slice(2,9),sessionId:Wo(),timestamp:new Date().toISOString(),version:Dt,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:ar,userAgent:navigator.userAgent,clientId:$t}})))}const Jt=Oo(async t=>{if(t.length>0){const e=xr(t);Cr?navigator.sendBeacon(st,e):(await fetch(st,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function St(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(st,xr([n]))}else Jt.push(t)}const ne=To({app:ar,version:Dt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;St({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;St({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;St({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Ho(t,e){ne.track(t,e)}function Jo(){return Cr=!0,Jt.flush()}const Ar=new Map;function Xo(t,e){Ar.set(t,e)}window.addEventListener("beforeunload",()=>{Ar.forEach((t,e)=>{t.bind(e)()}),Jo()});const $r=new Map;function Vo(t,e){$r.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&$r.forEach((t,e)=>{t.bind(e)()})});const Lr="sesamySignedURLs";function Ur(){const t=sessionStorage.getItem(Lr);return t?JSON.parse(t):[]}function Yo(t){const e=Ur();e.push(t),sessionStorage.setItem(Lr,JSON.stringify(e))}function Go(t){const{getEntitlement:e,getEntitlements:n,getEntitlementAccess:r,getSubscriptions:i,getContract:o,getContracts:a,getBill:s,getBills:h,getProfile:f,updateProfile:u,getTags:c,deleteTag:p,setTag:d,getUserMetadata:b,listUserMetadata:S,setUserMetadata:w,deleteUserMetadata:P,getTally:_,getTallies:v,pushTally:l,deleteTally:k,getProduct:T,getPaymentIssues:O,isSpotifyLinked:C,unlinkSpotify:R,linkSpotify:z,autoOnboardProduct:K,openHostedAccountPage:$,generateLink:U}=ji(t),M={auth:{getUser:f,isAuthenticated:Rt,loginWithRedirect:zt,logout:gi,setToken:nr},profile:{get:f,update:u,openHostedAccountPage:$,isSpotifyLinked:C,unlinkSpotify:R},analytics:{track:Ho},tags:{list:c,set:d,delete:p},entitlements:{get:e,list:n,access:r,signedLinks:Ur},contracts:{get:o,list:a},bills:{get:s,list:h},userMetadata:{get:b,list:S,set:w,delete:P},tallies:{get:_,list:v,push:l,delete:k},subscriptions:{list:i},products:{get:T,autoOnboard:K,linkSpotify:z},getVersion:Bo,getPaymentIssues:O,generateLink:U,clearCache:ee};return t.namespace&&(window[t.namespace]=M),M}function Bo(){return Dt}function qo(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token");if(e){nr(e);const n=new URL(window.location.href);t.delete("access_token"),n.hash=t.toString(),window.history.replaceState(null,"",n)}}const Rn="sesamy-refresh",zn="force-refetch-entitlements";function Qo(){const t=new URLSearchParams(window.location.search),e=t.get(zn),n=t.get(Rn);if(e!==null||n!==null){const r=new URL(window.location.href);t.delete(zn),t.delete(Rn),r.search=t.toString(),ee(),window.history.replaceState(null,"",r)}}function ea(){const t=new URLSearchParams(window.location.search),e=t.get("token"),n=t.get("se");if(!n||!e)return;const r=parseInt(n,10);if(Number.isNaN(r)||r<Date.now())return;Yo({url:window.location.href.split("?")[0],token:e,expiresAt:r,publisherContentId:t.get("sp")??void 0});const i=new URL(window.location.href);i.searchParams.delete("ss"),i.searchParams.delete("se"),i.searchParams.delete("sp"),i.searchParams.delete("so"),i.searchParams.delete("token"),window.history.replaceState(null,"",i)}const Dn="sesamy-user";async function ta(){const e=new URLSearchParams(window.location.search).get(Dn);if(!e)return;const n=await mi();(n==null?void 0:n.email)!==e&&zt({authorizationParams:{email_hint:e}});const r=new URL(window.location.href);r.searchParams.delete(Dn),window.history.replaceState(null,"",r)}const Mn="sesamy-purchase";function na(){const t=new URLSearchParams(window.location.search),e=t.get(Mn);if(e!==null){const n=new URL(window.location.href);t.delete(Mn),n.search=t.toString(),ue(q.PURCHASE,{itemSrc:e}),ee(),window.history.replaceState(null,"",n)}}const Zn="sesamy-login";async function ra(){if(!new URLSearchParams(window.location.search).get(Zn))return;await Rt()||zt();const r=new URL(window.location.href);r.searchParams.delete(Zn),window.history.replaceState(null,"",r)}async function Nr(t){Fo({clientId:t.clientId,...t.analytics}),await pi({clientId:t.clientId,organization:t.organization,...t.auth});const e=Go({clientId:t.clientId,...t.api});return ue(q.READY,{}),qo(),Qo(),ea(),await ra(),await ta(),na(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);Nr(e)}catch(e){console.error("Failed to parse config",e)}}exports.init=Nr;
|
package/dist/sesamy-js.iife.js
CHANGED
|
@@ -2,5 +2,5 @@ var sesamyJs=function(re){"use strict";var ra=Object.defineProperty;var ia=(re,J
|
|
|
2
2
|
`,10)+1,a=i.substring(o)+(r?"//# sourceMappingURL="+r:""),s=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(s)}var rn,on,an,wt,ii=(rn="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=",on=null,an=!1,function(t){return wt=wt||ri(rn,on,an),new Worker(wt,t)});const bt={};let oi=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 ai={memory:()=>new en().enclosedCache,localstorage:()=>new Yr},sn=t=>ai[t],cn=t=>{const{openUrl:e,onRedirect:n}=t,r=X(t,["openUrl","onRedirect"]);return Object.assign(Object.assign({},r),{openUrl:e===!1||e?e:n})},kt=new zr;let si=class{constructor(e){let n,r;if(this.userCache=new en().enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{await kt.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)},this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),e),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),e.authorizationParams)}),typeof window<"u"&&(()=>{if(!Xe())throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Xe().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
4
|
`)})(),e.cache&&e.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),e.cache)r=e.cache;else{if(n=e.cacheLocation||"memory",!sn(n))throw new Error(`Invalid cache location "${n}"`);r=sn(n)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=e.legacySameSiteCookie===!1?Se:ti,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:ni;var o;this.scope=Ve("openid",this.options.authorizationParams.scope,this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new Br(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||Yt,this.cacheManager=new Gr(r,r.allKeys?void 0:new oi(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 ii)}_url(e){const n=encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client||Vt)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${vt(e)}`)}async _verifyIdToken(e,n,r){const i=await this.nowProvider();return Qr({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:n,organization:r,leeway:this.options.leeway,max_age:(o=this.options.authorizationParams.max_age,typeof o!="string"?o:parseInt(o,10)||void 0),now:i});var o}_processOrgHint(e){e?this.cookieStorage.save(this.orgHintCookieName,e,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}async _prepareAuthorizeUrl(e,n,r){const i=qt(yt()),o=qt(yt()),a=yt(),s=(u=>{const c=new Uint8Array(u);return(p=>{const d={"+":"-","/":"_","=":""};return p.replace(/[+/=]/g,b=>d[b])})(window.btoa(String.fromCharCode(...Array.from(c))))})(await(async u=>await Xe().subtle.digest({name:"SHA-256"},new TextEncoder().encode(u)))(a)),h=((u,c,p,d,b,S,w,P)=>Object.assign(Object.assign(Object.assign({client_id:u.clientId},u.authorizationParams),p),{scope:Ve(c,p.scope),response_type:"code",response_mode:P||"query",state:d,nonce:b,redirect_uri:w||u.authorizationParams.redirect_uri,code_challenge:S,code_challenge_method:"S256"}))(this.options,this.scope,e,i,o,s,e.redirect_uri||this.options.authorizationParams.redirect_uri||r,n==null?void 0:n.response_mode),f=this._authorizeUrl(h);return{nonce:o,code_verifier:a,scope:h.scope,audience:h.audience||"default",redirect_uri:h.redirect_uri,state:i,url:f}}async loginWithPopup(e,n){var r;if(e=e||{},!(n=n||{}).popup&&(n.popup=(s=>{const h=window.screenX+(window.innerWidth-400)/2,f=window.screenY+(window.innerHeight-600)/2;return window.open(s,"auth0:authorize:popup",`left=${h},top=${f},width=400,height=600,resizable,scrollbars=yes,status=1`)})(""),!n.popup))throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");const i=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await(s=>new Promise((h,f)=>{let u;const c=setInterval(()=>{s.popup&&s.popup.closed&&(clearInterval(c),clearTimeout(p),window.removeEventListener("message",u,!1),f(new Kr(s.popup)))},1e3),p=setTimeout(()=>{clearInterval(c),f(new Zr(s.popup)),window.removeEventListener("message",u,!1)},1e3*(s.timeoutInSeconds||60));u=function(d){if(d.data&&d.data.type==="authorization_response"){if(clearTimeout(p),clearInterval(c),window.removeEventListener("message",u,!1),s.popup.close(),d.data.response.error)return f(B.fromPayload(d.data.response));h(d.data.response)}},window.addEventListener("message",u)}))(Object.assign(Object.assign({},n),{timeoutInSeconds:n.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}));if(i.state!==o.state)throw new B("state_mismatch","Invalid state");const a=((r=e.authorizationParams)===null||r===void 0?void 0:r.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:i.audience,scope:i.scope,code_verifier:i.code_verifier,grant_type:"authorization_code",code:o.code,redirect_uri:i.redirect_uri},{nonceIn:i.nonce,organization:a})}async getUser(){var e;const n=await this._getIdTokenFromCache();return(e=n==null?void 0:n.decodedToken)===null||e===void 0?void 0:e.user}async getIdTokenClaims(){var e;const n=await this._getIdTokenFromCache();return(e=n==null?void 0:n.decodedToken)===null||e===void 0?void 0:e.claims}async loginWithRedirect(e={}){var n;const r=cn(e),{openUrl:i,fragment:o,appState:a}=r,s=X(r,["openUrl","fragment","appState"]),h=((n=s.authorizationParams)===null||n===void 0?void 0:n.organization)||this.options.authorizationParams.organization,f=await this._prepareAuthorizeUrl(s.authorizationParams||{}),{url:u}=f,c=X(f,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},c),{appState:a}),h&&{organization:h}));const p=o?`${u}#${o}`:u;i?await i(p):window.location.assign(p)}async handleRedirectCallback(e=window.location.href){const n=e.split("?").slice(1);if(n.length===0)throw new Error("There are no query params available for parsing.");const{state:r,code:i,error:o,error_description:a}=(c=>{c.indexOf("#")>-1&&(c=c.substring(0,c.indexOf("#")));const p=new URLSearchParams(c);return{state:p.get("state"),code:p.get("code")||void 0,error:p.get("error")||void 0,error_description:p.get("error_description")||void 0}})(n.join("")),s=this.transactionManager.get();if(!s)throw new B("missing_transaction","Invalid state");if(this.transactionManager.remove(),o)throw new Mr(o,a||o,r,s.appState);if(!s.code_verifier||s.state&&s.state!==r)throw new B("state_mismatch","Invalid state");const h=s.organization,f=s.nonce,u=s.redirect_uri;return await this._requestToken(Object.assign({audience:s.audience,scope:s.scope,code_verifier:s.code_verifier,grant_type:"authorization_code",code:i},u?{redirect_uri:u}:{}),{nonceIn:f,organization:h}),{appState:s.appState}}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get("auth0.is.authenticated"))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove("auth0.is.authenticated")}try{await this.getTokenSilently(e)}catch{}}async getTokenSilently(e={}){var n;const r=Object.assign(Object.assign({cacheMode:"on"},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Ve(this.scope,(n=e.authorizationParams)===null||n===void 0?void 0:n.scope)})}),i=await((o,a)=>{let s=bt[a];return s||(s=o().finally(()=>{delete bt[a],s=null}),bt[a]=s),s})(()=>this._getTokenSilently(r),`${this.options.clientId}::${r.authorizationParams.audience}::${r.authorizationParams.scope}`);return e.detailedResponse?i:i==null?void 0:i.access_token}async _getTokenSilently(e){const{cacheMode:n}=e,r=X(e,["cacheMode"]);if(n!=="off"){const i=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(i)return i}if(n!=="cache-only"){if(!await(async(i,o=3)=>{for(let a=0;a<o;a++)if(await i())return!0;return!1})(()=>kt.acquireLock("auth0.lock.getTokenSilently",5e3),10))throw new gt;try{if(window.addEventListener("pagehide",this._releaseLockOnPageHide),n!=="off"){const f=await this._getEntryFromCache({scope:r.authorizationParams.scope,audience:r.authorizationParams.audience||"default",clientId:this.options.clientId});if(f)return f}const i=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(r):await this._getTokenFromIFrame(r),{id_token:o,access_token:a,oauthTokenScope:s,expires_in:h}=i;return Object.assign(Object.assign({id_token:o,access_token:a},s?{scope:s}:null),{expires_in:h})}finally{await kt.releaseLock("auth0.lock.getTokenSilently"),window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}}async getTokenWithPopup(e={},n={}){var r;const i=Object.assign(Object.assign({},e),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),e.authorizationParams),{scope:Ve(this.scope,(r=e.authorizationParams)===null||r===void 0?void 0:r.scope)})});return n=Object.assign(Object.assign({},Dr),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new fe({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=X(n,["federated"]),o=r?"&federated":"";return this._url(`/v2/logout?${vt(Object.assign({clientId:e.clientId},i))}`)+o}async logout(e={}){const n=cn(e),{openUrl:r}=n,i=X(n,["openUrl"]);e.clientId===null?await this.cacheManager.clear():await this.cacheManager.clear(e.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove("@@user@@");const o=this._buildLogoutUrl(i);r?await r(o):r!==!1&&window.location.assign(o)}async _getTokenFromIFrame(e){const n=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),r=this.cookieStorage.get(this.orgHintCookieName);r&&!n.organization&&(n.organization=r);const{url:i,state:o,nonce:a,code_verifier:s,redirect_uri:h,scope:f,audience:u}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);try{if(window.crossOriginIsolated)throw new B("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const c=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,p=await((b,S,w=60)=>new Promise((P,_)=>{const v=window.document.createElement("iframe");v.setAttribute("width","0"),v.setAttribute("height","0"),v.style.display="none";const l=()=>{window.document.body.contains(v)&&(window.document.body.removeChild(v),window.removeEventListener("message",k,!1))};let k;const T=setTimeout(()=>{_(new gt),l()},1e3*w);k=function(O){if(O.origin!=S||!O.data||O.data.type!=="authorization_response")return;const A=O.source;A&&A.close(),O.data.response.error?_(B.fromPayload(O.data.response)):P(O.data.response),clearTimeout(T),window.removeEventListener("message",k,!1),setTimeout(l,2e3)},window.addEventListener("message",k,!1),window.document.body.appendChild(v),v.setAttribute("src",b)}))(i,this.domainUrl,c);if(o!==p.state)throw new B("state_mismatch","Invalid state");const d=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:s,code:p.code,grant_type:"authorization_code",redirect_uri:h,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},d),{scope:f,oauthTokenScope:d.scope,audience:u})}catch(c){throw c.error==="login_required"&&this.logout({openUrl:!1}),c}}async _getTokenUsingRefreshToken(e){const n=await this.cacheManager.get(new fe({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||"default",clientId:this.options.clientId}));if(!(n&&n.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw new Gt(e.authorizationParams.audience||"default",e.authorizationParams.scope)}const r=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,i=typeof e.timeoutInSeconds=="number"?1e3*e.timeoutInSeconds:null;try{const o=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:"refresh_token",refresh_token:n&&n.refresh_token,redirect_uri:r}),i&&{timeout:i}));return Object.assign(Object.assign({},o),{scope:e.authorizationParams.scope,oauthTokenScope:o.scope,audience:e.authorizationParams.audience||"default"})}catch(o){if((o.message.indexOf("Missing Refresh Token")>-1||o.message&&o.message.indexOf("invalid refresh token")>-1)&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw o}}async _saveEntryInCache(e){const{id_token:n,decodedToken:r}=e,i=X(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 fe({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 fe({scope:e,audience:n,clientId:r}),60);if(i&&i.access_token){const{access_token:o,oauthTokenScope:a,expires_in:s}=i,h=await this._getIdTokenFromCache();return h&&Object.assign(Object.assign({id_token:h.id_token,access_token:o},a?{scope:a}:null),{expires_in:s})}}async _requestToken(e,n){const{nonceIn:r,organization:i}=n||{},o=await Vr(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 ci(t){const e=new si(t);return await e.checkSession(),e}const me="sesamy.com",ui="https://sesa.my",li="https://logs.sesamy.com/events",It="sesamyCacheTimestamp";var ee=(t=>(t.READY="sesamyJsReady",t.AUTHENTICATED="sesamyJsAuthenticated",t.LOGOUT="sesamyJsLogout",t.CLEAR_CACHE="sesamyJsClearCache",t.USER_ATTRIBUTE_CHANGED="sesamyUserAttributeChanged",t.PURCHASE="sesamyJsPurchase",t))(ee||{});let q,un;const Re="sesamyAccessToken";function St(){const t=localStorage.getItem(Re);if(!t)return null;const e=ln(t);return(!e||!e.exp||e.exp<new Date().getTime()/1e3)&&localStorage.removeItem(Re),t}function di(t){try{const e=new URL(t).hostname,n=e.split(".");return n.length>1?n.slice(-2).join("."):e}catch{return null}}async function hi(t){if(t.enabled===!1)return;un=t.organization;const e={domain:t.endpoint||`token.${me}`,clientId:t.clientId};if(di(window.location.href)!==me&&(e.cacheLocation="localstorage",e.useRefreshTokens=!0),q=await ci(e),window.location.search.includes("code="))try{await q.handleRedirectCallback();const n=await q.getUser();J(ee.AUTHENTICATED,n);const r=new URL(location.href),i=r.searchParams;i.delete("code"),i.delete("state"),r.search=i.toString(),window.history.replaceState({},document.title,r.toString())}catch(n){console.error(n)}}async function _t(){return St()?!0:q?q.isAuthenticated():!1}async function fi(){return St()?{sub:"local",name:"Local User"}:q?q.getUser():null}function Et(t){if(localStorage.removeItem(Re),!q)throw new Error("Auth0 client not initialized");const e=(t==null?void 0:t.authorizationParams)||{};return q.loginWithRedirect({...t,authorizationParams:{organization:un,redirect_uri:window.location.href,...e}})}async function Ye(t=!0){const e=St();if(e)return e;try{return q?await q.getTokenSilently():null}catch(n){if(t)throw n;return null}}async function pi(t={}){if(localStorage.removeItem(Re),J(ee.LOGOUT,{}),!!q)return q.logout({...t,logoutParams:{returnTo:window.location.href,...t.logoutParams}})}function ln(t){const e=t.split(".");if(e.length!==3)return null;const r=e[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(r).split("").map(function(o){return"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(i)}async function dn(t){const e=ln(t);if(!e||!e.exp||e.exp<new Date().getTime()/1e3)throw new Error("Invalid token");localStorage.setItem(Re,t),J(ee.AUTHENTICATED,e)}const mi=(t,e)=>e.skipDedupe||e.method!=="GET",gi=(t,e)=>e.method+"@"+t,yi=t=>t.clone(),hn=({skip:t=mi,key:e=gi,resolver:n=yi}={})=>{const r=new Map;return i=>(o,a)=>{if(t(o,a))return i(o,a);const s=e(o,a);if(!r.has(s))r.set(s,[]);else return new Promise((h,f)=>{r.get(s).push([h,f])});try{return i(o,a).then(h=>(r.get(s).forEach(([f])=>f(n(h))),r.delete(s),h)).catch(h=>{throw r.get(s).forEach(([f,u])=>u(h)),r.delete(s),h})}catch(h){return r.delete(s),Promise.reject(h)}}},vi=(t,e)=>t*e,wi=t=>t&&t.ok,fn=({delayTimer:t=500,delayRamp:e=vi,maxAttempts:n=10,until:r=wi,onRetry:i=null,retryOnNetworkError:o=!1,resolveWithLatestResponse:a=!1,skip:s}={})=>h=>(f,u)=>{let c=0;if(s&&s(f,u))return h(f,u);const p=(d,b)=>Promise.resolve(r(d,b)).then(S=>S?d&&a?d:b?Promise.reject(b):d:(c++,!n||c<=n?new Promise(w=>{const P=e(t,c);setTimeout(()=>{typeof i=="function"?Promise.resolve(i({response:d,error:b,url:f,options:u})).then((_={})=>{var v,l;w(h((v=_&&_.url)!==null&&v!==void 0?v:f,(l=_&&_.options)!==null&&l!==void 0?l:u))}):w(h(f,u))},P)}).then(p).catch(w=>{if(!o)throw w;return p(null,w)}):d&&a?d:Promise.reject(b||new Error("Number of attempts exceeded."))));return h(f,u).then(p).catch(d=>{if(!o)throw d;return p(null,d)})},bi="application/json",pn="Content-Type",_e=Symbol(),mn=Symbol();function gn(t={}){var e;return(e=Object.entries(t).find(([n])=>n.toLowerCase()===pn.toLowerCase()))===null||e===void 0?void 0:e[1]}function yn(t){return/^application\/.*json.*/.test(t)}const ge=function(t,e,n=!1){return Object.entries(e).reduce((r,[i,o])=>{const a=t[i];return Array.isArray(a)&&Array.isArray(o)?r[i]=n?[...a,...o]:o:typeof a=="object"&&typeof o=="object"?r[i]=ge(a,o,n):r[i]=o,r},{...t})},Ee={options:{},errorType:"text",polyfills:{},polyfill(t,e=!0,n=!1,...r){const i=this.polyfills[t]||(typeof self<"u"?self[t]:null)||(typeof global<"u"?global[t]:null);if(e&&!i)throw new Error(t+" is not defined");return n&&i?new i(...r):i}};function ki(t,e=!1){Ee.options=e?t:ge(Ee.options,t)}function Ii(t,e=!1){Ee.polyfills=e?t:ge(Ee.polyfills,t)}function Si(t){Ee.errorType=t}const _i=t=>e=>t.reduceRight((n,r)=>r(n),e)||e;class vn extends Error{}const Ei=t=>{const e=Object.create(null);t=t._addons.reduce((v,l)=>l.beforeRequest&&l.beforeRequest(v,t._options,e)||v,t);const{_url:n,_options:r,_config:i,_catchers:o,_resolvers:a,_middlewares:s,_addons:h}=t,f=new Map(o),u=ge(i.options,r);let c=n;const p=_i(s)((v,l)=>(c=v,i.polyfill("fetch")(v,l)))(n,u),d=new Error,b=p.catch(v=>{throw{[_e]:v}}).then(v=>{if(!v.ok){const l=new vn;if(l.cause=d,l.stack=l.stack+`
|
|
5
|
-
CAUSE: `+d.stack,l.response=v,l.url=c,v.type==="opaque")throw l;return v.text().then(k=>{var T;if(l.message=k,i.errorType==="json"||((T=v.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=v.status,l})}return v}),S=v=>v.catch(l=>{const k=l.hasOwnProperty(_e),T=k?l[_e]:l,O=(T==null?void 0:T.status)&&f.get(T.status)||f.get(T==null?void 0:T.name)||k&&f.has(_e)&&f.get(_e);if(O)return O(T,t);const A=f.get(mn);if(A)return A(T,t);throw T}),w=v=>l=>S(v?b.then(k=>k&&k[v]()).then(k=>l?l(k):k):b.then(k=>l?l(k):k)),P={_wretchReq:t,_fetchReq:p,_sharedState:e,res:w(null),json:w("json"),blob:w("blob"),formData:w("formData"),arrayBuffer:w("arrayBuffer"),text:w("text"),error(v,l){return f.set(v,l),this},badRequest(v){return this.error(400,v)},unauthorized(v){return this.error(401,v)},forbidden(v){return this.error(403,v)},notFound(v){return this.error(404,v)},timeout(v){return this.error(408,v)},internalError(v){return this.error(500,v)},fetchError(v){return this.error(_e,v)}},_=h.reduce((v,l)=>({...v,...typeof l.resolver=="function"?l.resolver(v):l.resolver}),P);return a.reduce((v,l)=>l(v,t),_)},Pi={_url:"",_options:{},_config:Ee,_catchers:new Map,_resolvers:[],_deferred:[],_middlewares:[],_addons:[],addon(t){return{...this,_addons:[...this._addons,t],...t.wretch}},errorType(t){return{...this,_config:{...this._config,errorType:t}}},polyfills(t,e=!1){return{...this,_config:{...this._config,polyfills:e?t:ge(this._config.polyfills,t)}}},url(t,e=!1){if(e)return{...this,_url:t};const n=this._url.split("?");return{...this,_url:n.length>1?n[0]+t+"?"+n[1]:this._url+t}},options(t,e=!1){return{...this,_options:e?t:ge(this._options,t)}},headers(t){const e=t?Array.isArray(t)?Object.fromEntries(t):"entries"in t?Object.fromEntries(t.entries()):t:{};return{...this,_options:ge(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[pn]: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(mn,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=gn(r._options.headers),o=this._config.polyfill("FormData",!1),a=typeof n=="object"&&!(o&&n instanceof o)&&(!r._options.headers||!i||yn(i));return r=n?a?r.json(n,i):r.body(n):r,Ei(r._deferred.reduce((s,h)=>h(s,s._url,s._options),r))},get(t=""){return this.fetch("GET",t)},delete(t=""){return this.fetch("DELETE",t)},put(t,e=""){return this.fetch("PUT",e,t)},post(t,e=""){return this.fetch("POST",e,t)},patch(t,e=""){return this.fetch("PATCH",e,t)},head(t=""){return this.fetch("HEAD",t)},opts(t=""){return this.fetch("OPTIONS",t)},body(t){return{...this,_options:{...this._options,body:t}}},json(t,e){const n=gn(this._options.headers);return this.content(e||yn(n)&&n||bi).body(JSON.stringify(t))}};function ie(t="",e={}){return{...Pi,_url:t,_options:e}}ie.default=ie,ie.options=ki,ie.errorType=Si,ie.polyfills=Ii,ie.WretchError=vn;function te(){sessionStorage.removeItem(It),J(ee.CLEAR_CACHE,{})}function Ti(t){const e=t.endpoint||`https://api2.${me}`,n=g=>async(I,E)=>{let L=sessionStorage.getItem(It);L||(L=Date.now().toString(),sessionStorage.setItem(It,L));const Z={...E,headers:{...E.headers,"Cache-Timestamp":L}};return g(I,Z)},r=(g=!1)=>I=>async(E,L)=>{let Z=null;if(Z=await Ye(g),!Z){if(g)throw new Error("No access token available");return I(E,L)}const N={...L,headers:{...L.headers,...Z?{Authorization:`Bearer ${Z}`}:{}}};return I(E,N)},i=g=>(I,E)=>{if(E.headers.Authorization)return g(I,E);const L=localStorage.getItem("__anon_id"),Z=btoa(`${L}:`),N={...E,headers:{...E.headers,Authorization:`Basic ${Z}`}};return g(I,N)},o=ie(e).headers({"Content-Type":"application/json"}).middlewares([n,r(),hn(),fn({delayTimer:1e3,delayRamp:(g,I)=>g*I,maxAttempts:3,until:g=>!!(g&&(g.ok||g.status>=400&&g.status<500)),retryOnNetworkError:!1})]),a=ie(e).headers({"Content-Type":"application/json"}).middlewares([n,r(!1),i,hn(),fn({delayTimer:1e3,delayRamp:(g,I)=>g*I,maxAttempts:3,until:g=>!!(g&&(g.ok||g.status>=400&&g.status<500)),retryOnNetworkError:!1})]);async function s(){return o.get("/entitlements").json()}async function h(g){const I=await o.get("/entitlements").json();return I==null?void 0:I.find(E=>E.id===g)}async function f(g){return o.get(`/entitlements/${g}/access`).json()}async function u(){return o.get("/contracts").json()}async function c(g){const I=await o.get("/contracts").json();return I==null?void 0:I.find(E=>E.id===g)}async function p(){return o.get("/subscriptions").json()}async function d(){return o.get("/bills").json()}async function b(g){const I=await o.get("/bills").json();return I==null?void 0:I.find(E=>E.id===g)}async function S(g,I){const E=await o.url(`/user-metadata/${g}`).put(I).json();return J(ee.USER_ATTRIBUTE_CHANGED,{}),te(),E}async function w(g){const I=await o.url(`/user-metadata/${g}`).delete().res();return te(),I.ok}async function P(g){return(await o.url(`/user-metadata/${g}`).get().json())[g]}async function _(){return await o.url("/user-metadata").get().json()}async function v(){return await o.url("/tags").get().json()}async function l(g){const I=await o.url(`/tags/${g}`).delete().res();return te(),I.ok}async function k(g){const I=await o.url("/tags").post(g).res();return J(ee.USER_ATTRIBUTE_CHANGED,{}),te(),I.ok}async function T(g){return(await a.url("/tallies").get().json())[g]}async function O(){return await a.url("/tallies").get().json()}async function A(g){const I=await a.url(`/tallies/${g}`).delete().res();return te(),I.ok}async function R(g,I){return await a.url(`/tallies/${g}/push`).post(I).json()}async function z(g){return await o.url(`/products/${g}`).get().json()}async function K(){return await _t()?await o.url("/profile").get().json():null}async function $(g){const I=await o.url("/profile").patch(g).res();return te(),I.ok}async function U(){return await o.url("/payment-issues").get().json()}async function M(){return(await o.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function j(){return(await o.url("/profile/unlink-spotify").post().res()).ok}async function W(g){const I=await Ye(!1);if(!I)throw new Error("No access token available");const E=new URL(`https://spotify-oas.${me}/sesamy-callback`);E.searchParams.set("access_token",I),E.searchParams.set("state",g),window.location.href=E.toString()}async function V(g){const I=await o.url(`/products/${g}/auto-onboard`).post().json();return I.length&&te(),I}async function Ie(g,I=3600){const{shortlink:E}=await ie(ui).post({url:g,ttl:I}).json();return E}async function m(g){const I=await Ye(!1);let E;switch(g.target){case"account":E=new URL(`https://account.${me}/subscriptions/${t.clientId}`);break;case"consume":E=new URL(`https://consume.${me}/@${t.clientId}/${g.sku}`),g.episodeId&&(E.href+=`/${g.episodeId}`);break;default:throw new Error("Invalid target")}return I&&(E.hash=`#access_token=${I}`),g.shorten?Ie(E.href,g.ttl):E.href}async function y(){const g=await Ye(!1),I=new URL(`https://account.${me}/subscriptions/${t.clientId}`);g&&(I.hash=`#access_token=${g}`),window.location.href=I.toString()}return{getEntitlements:s,getEntitlement:h,getEntitlementAccess:f,getContracts:u,getContract:c,getProfile:K,updateProfile:$,getSubscriptions:p,getBills:d,getBill:b,setUserMetadata:S,deleteUserMetadata:w,getUserMetadata:P,listUserMetadata:_,getTags:v,deleteTag:l,setTag:k,getTally:T,getTallies:O,deleteTally:A,pushTally:R,getProduct:z,getPaymentIssues:U,autoOnboardProduct:V,isSpotifyLinked:M,unlinkSpotify:j,linkSpotify:W,generateLink:m,openHostedAccountPage:y}}const wn="@sesamy/sesamy-js",Pt="1.13.2";function bn(t,e,n,r,i){for(e=e.split?e.split("."):e,r=0;r<e.length;r++)t=t?t[e[r]]:i;return t===i?n:t}var Ge="undefined",kn="object",Tt=function(){},In="any",Sn="*",ye="__",Be=typeof process<"u"?process:{};Be.env&&Be.env.NODE_ENV;var H=typeof document<"u";Be.versions!=null&&Be.versions.node!=null,typeof Deno<"u"&&Deno.core,H&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function _n(t,e){return e.charAt(0)[t]()+e.slice(1)}var Oi=_n.bind(null,"toUpperCase"),ji=_n.bind(null,"toLowerCase");function Ci(t){return En(t)?Oi("null"):typeof t=="object"?Li(t):Object.prototype.toString.call(t).slice(8,-1)}function qe(t,e){e===void 0&&(e=!0);var n=Ci(t);return e?ji(n):n}function ze(t,e){return typeof e===t}var Y=ze.bind(null,"function"),se=ze.bind(null,"string"),Pe=ze.bind(null,"undefined"),xi=ze.bind(null,"boolean");ze.bind(null,"symbol");function En(t){return t===null}function Ai(t){return qe(t)==="number"&&!isNaN(t)}function Pn(t){return qe(t)==="array"}function G(t){if(!$i(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function $i(t){return t&&(typeof t=="object"||t!==null)}function Li(t){return Y(t.constructor)?t.constructor.name:null}function Ui(t){return t instanceof Error||se(t.message)&&t.constructor&&Ai(t.constructor.stackTraceLimit)}function Tn(t,e){if(typeof e!="object"||En(e))return!1;if(e instanceof t)return!0;var n=qe(new t(""));if(Ui(e))for(;e;){if(qe(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}Tn.bind(null,TypeError),Tn.bind(null,SyntaxError);function Qe(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Ni(t,e):n}function Ni(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function et(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}et(Qe,"form"),et(Qe,"button"),et(Qe,"input"),et(Qe,"select");function Ri(t){return t?Pn(t)?t:[t]:[]}function On(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function zi(){if(H){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 Mi(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=On(n[1]),a=On(n[2]);o.substring(o.length-2)==="[]"?(r[o=o.substring(0,o.length-2)]||(r[o]=[])).push(a):r[o]=a===""||a}for(var s in r){var h=s.split("[");h.length>1&&(Zi(r,h.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){return H&&window.location.search.substring(1)}())}function Zi(t,e,n){for(var r=e.length-1,i=0;i<r;++i){var o=e[i];if(o==="__proto__"||o==="constructor")break;o in t||(t[o]={}),t=t[o]}t[e[r]]=n}function tt(){for(var t="",e=0,n=4294967295*Math.random()|0;e++<36;){var r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],i=15&n;t+=r=="-"||r=="4"?r:(r=="x"?i:3&i|8).toString(16),n=e%8==0?4294967295*Math.random()|0:n>>4}return t}function Ki(t,e){var n,r,i,o=null,a=0,s=function(){a=new Date,o=null,i=t.apply(n,r)};return function(){var h=new Date;a||(a=h);var f=e-(h-a);return n=this,r=arguments,f<=0?(clearTimeout(o),o=null,a=h,i=t.apply(n,r)):o||(o=setTimeout(s,f)),i}}var De="global",Te=ye+"global"+ye,Oe=typeof self===kn&&self.self===self&&self||typeof global===kn&&global.global===global&&global||void 0;function ve(t){return Oe[Te][t]}function we(t,e){return Oe[Te][t]=e}function je(t){delete Oe[Te][t]}function Ce(t,e,n){var r;try{if(Ot(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Oe[Te]||(Oe[Te]={});var nt={};function Ot(t){if(typeof nt[t]!==Ge)return nt[t];try{var e=window[t];e.setItem(Ge,Ge),e.removeItem(Ge)}catch{return nt[t]=!1}return nt[t]=!0}function C(){return C=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},C.apply(this,arguments)}var ce="function",oe="undefined",Wi="@@redux/"+Math.random().toString(36),jn=function(){return typeof Symbol===ce&&Symbol.observable||"@@observable"}(),rt=" != "+ce;function Cn(t,e,n){var r;if(typeof e===ce&&typeof n===oe&&(n=e,e=void 0),typeof n!==oe){if(typeof n!==ce)throw new Error("enhancer"+rt);return n(Cn)(t,e)}if(typeof t!==ce)throw new Error("reducer"+rt);var i=t,o=e,a=[],s=a,h=!1;function f(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==ce)throw new Error("Listener"+rt);var b=!0;return f(),s.push(d),function(){if(b){b=!1,f();var S=s.indexOf(d);s.splice(S,1)}}}function p(d){if(!G(d))throw new Error("Act != obj");if(typeof d.type===oe)throw new Error("ActType "+oe);if(h)throw new Error("Dispatch in reducer");try{h=!0,o=i(o,d)}finally{h=!1}for(var b=a=s,S=0;S<b.length;S++)(0,b[S])();return d}return p({type:"@@redux/INIT"}),(r={dispatch:p,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ce)throw new Error("next reducer"+rt);i=d,p({type:"@@redux/INIT"})}})[jn]=function(){var d,b=c;return(d={subscribe:function(S){if(typeof S!="object")throw new TypeError("Observer != obj");function w(){S.next&&S.next(u())}return w(),{unsubscribe:b(w)}}})[jn]=function(){return this},d},r}function Fi(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+oe}function xe(){var t=[].slice.call(arguments);return t.length===0?function(e){return e}:t.length===1?t[0]:t.reduce(function(e,n){return function(){return e(n.apply(void 0,[].slice.call(arguments)))}})}function Hi(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,h={getState:a.getState,dispatch:function(f){return s(f)}};return o=[].slice.call(t).map(function(f){return f(h)}),C({},a,{dispatch:s=xe.apply(void 0,o)(a.dispatch)})}}}var ue=ye+"anon_id",be=ye+"user_id",Ae=ye+"user_traits",le="userId",$e="anonymousId",it=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],jt=["name","EVENTS","config","loaded"],x=it.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),xn=/^utm_/,An=/^an_prop_/,$n=/^an_trait_/;function Ji(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===x.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,h=i.initialUser,f=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(ue,a.anonymousId),f||e(be,a.userId),h.traits&&e(Ae,C({},f&&s.traits?s.traits:{},h.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,p=o.an_event,d=u.reduce(function(b,S){if(S.match(xn)||S.match(/^(d|g)clid/)){var w=S.replace(xn,"");b.campaign[w==="campaign"?"name":w]=o[S]}return S.match(An)&&(b.props[S.replace(An,"")]=o[S]),S.match($n)&&(b.traits[S.replace($n,"")]=o[S]),b},{campaign:{},props:{},traits:{}});n.dispatch(C({type:x.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),p&&setTimeout(function(){return t.track(p,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:x.campaign,campaign:d.campaign})}}return r(i)}}}}function Xi(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===x.setItemEnd){if(n.key===ue)return C({},e,{anonymousId:n.value});if(n.key===be)return C({},e,{userId:n.value})}switch(n.type){case x.identify:return Object.assign({},e,{userId:n.userId,traits:C({},e.traits,n.traits)});case x.reset:return[be,ue,Ae].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function Ln(t){return{userId:t.getItem(be),anonymousId:t.getItem(ue),traits:t.getItem(Ae)}}var Ct=function(t){return ye+"TEMP"+ye+t};function Vi(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var h=s.userId,f=s.traits,u=s.options;if(s.type===x.reset&&([be,Ae,ue].forEach(function(d){r(d)}),[le,$e,"traits"].forEach(function(d){je(Ct(d))})),s.type===x.identify){i(ue)||n(ue,tt());var c=i(be),p=i(Ae)||{};c&&c!==h&&o.dispatch({type:x.userIdChanged,old:{userId:c,traits:p},new:{userId:h,traits:f},options:u}),h&&n(be,h),f&&n(Ae,C({},p,f))}return a(s)}}}}var Me={};function Un(t,e){Me[t]&&Y(Me[t])&&(Me[t](e),delete Me[t])}function Nn(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(C({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return Nn(t,e,n-10).then(r,i)})})}function Yi(t){return{abort:t}}function Rn(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,h=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var f=s.actions.reduce(function(c,p,d){return a[p.plugin].loaded?(c.process.push(p),c.processIndex.push(d)):(c.requeue.push(p),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(c){var p=s.actions[c],d=p.plugin,b=p.payload.type,S=i[d][b];if(S&&Y(S)){var w,P=function(l,k){return l===void 0&&(l={}),k===void 0&&(k={}),[le,$e].reduce(function(T,O){return l.hasOwnProperty(O)&&k[O]&&k[O]!==l[O]&&(T[O]=k[O]),T},l)}(p.payload,h),_=r[P.meta.rid];if(!_&&(w=S({payload:P,config:a[d].config,instance:n,abort:Yi}))&&G(w)&&w.abort)return void(r[P.meta.rid]=!0);if(!_){var v=b+":"+d;t.dispatch(C({},P,{type:v,_:{called:v,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,p){return!~f.processIndex.indexOf(p)});s.actions=u}}}var xt=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,h=t.EVENTS;try{var f=i.plugins,u=i.context,c=n.type,p=c.match(Le),d=e.exact.map(function(w){return w.pluginName});p&&(d=a.during.map(function(w){return w.pluginName}));var b=function(w,P){return function(_,v,l){var k=v.config,T=v.name,O=T+"."+_.type;l&&(O=l.event);var A=_.type.match(Le)?function(R,z,K,$,U){return function(M,j){var W=$?$.name:R,V=j&&Ze(j)?j:K;if($&&(!(V=j&&Ze(j)?j:[R]).includes(R)||V.length!==1))throw new Error("Method "+z+" can only abort "+R+" plugin. "+JSON.stringify(V)+" input valid");return C({},U,{abort:{reason:M,plugins:V,caller:z,_:W}})}}(T,O,P,l,_):function(R,z){return function(){throw new Error(R.type+" action not cancellable. Remove abort in "+z)}}(_,O);return{payload:Gi(_),instance:w,config:k||{},abort:A}}}(r,d),S=e.exact.reduce(function(w,P){var _=P.pluginName,v=P.methodName,l=!1;return v.match(/^initialize/)||v.match(/^reset/)||(l=!f[_].loaded),u.offline&&v.match(/^(page|track|identify)/)&&(l=!0),w[""+_]=l,w},{});return Promise.resolve(e.exact.reduce(function(w,P,_){try{var v=P.pluginName;return Promise.resolve(w).then(function(l){function k(){return Promise.resolve(l)}var T=function(){if(e.namespaced&&e.namespaced[v])return Promise.resolve(e.namespaced[v].reduce(function(O,A,R){try{return Promise.resolve(O).then(function(z){return A.method&&Y(A.method)?(function(M,j){var W=Hn(M);if(W&&W.name===j){var V=Hn(W.method);throw new Error([j+" plugin is calling method "+M,"Plugins cant call self","Use "+W.method+" "+(V?"or "+V.method:"")+" in "+j+" plugin insteadof "+M].join(`
|
|
5
|
+
CAUSE: `+d.stack,l.response=v,l.url=c,v.type==="opaque")throw l;return v.text().then(k=>{var T;if(l.message=k,i.errorType==="json"||((T=v.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=v.status,l})}return v}),S=v=>v.catch(l=>{const k=l.hasOwnProperty(_e),T=k?l[_e]:l,O=(T==null?void 0:T.status)&&f.get(T.status)||f.get(T==null?void 0:T.name)||k&&f.has(_e)&&f.get(_e);if(O)return O(T,t);const A=f.get(mn);if(A)return A(T,t);throw T}),w=v=>l=>S(v?b.then(k=>k&&k[v]()).then(k=>l?l(k):k):b.then(k=>l?l(k):k)),P={_wretchReq:t,_fetchReq:p,_sharedState:e,res:w(null),json:w("json"),blob:w("blob"),formData:w("formData"),arrayBuffer:w("arrayBuffer"),text:w("text"),error(v,l){return f.set(v,l),this},badRequest(v){return this.error(400,v)},unauthorized(v){return this.error(401,v)},forbidden(v){return this.error(403,v)},notFound(v){return this.error(404,v)},timeout(v){return this.error(408,v)},internalError(v){return this.error(500,v)},fetchError(v){return this.error(_e,v)}},_=h.reduce((v,l)=>({...v,...typeof l.resolver=="function"?l.resolver(v):l.resolver}),P);return a.reduce((v,l)=>l(v,t),_)},Pi={_url:"",_options:{},_config:Ee,_catchers:new Map,_resolvers:[],_deferred:[],_middlewares:[],_addons:[],addon(t){return{...this,_addons:[...this._addons,t],...t.wretch}},errorType(t){return{...this,_config:{...this._config,errorType:t}}},polyfills(t,e=!1){return{...this,_config:{...this._config,polyfills:e?t:ge(this._config.polyfills,t)}}},url(t,e=!1){if(e)return{...this,_url:t};const n=this._url.split("?");return{...this,_url:n.length>1?n[0]+t+"?"+n[1]:this._url+t}},options(t,e=!1){return{...this,_options:e?t:ge(this._options,t)}},headers(t){const e=t?Array.isArray(t)?Object.fromEntries(t):"entries"in t?Object.fromEntries(t.entries()):t:{};return{...this,_options:ge(this._options,{headers:e})}},accept(t){return this.headers({Accept:t})},content(t){return this.headers({[pn]: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(mn,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=gn(r._options.headers),o=this._config.polyfill("FormData",!1),a=typeof n=="object"&&!(o&&n instanceof o)&&(!r._options.headers||!i||yn(i));return r=n?a?r.json(n,i):r.body(n):r,Ei(r._deferred.reduce((s,h)=>h(s,s._url,s._options),r))},get(t=""){return this.fetch("GET",t)},delete(t=""){return this.fetch("DELETE",t)},put(t,e=""){return this.fetch("PUT",e,t)},post(t,e=""){return this.fetch("POST",e,t)},patch(t,e=""){return this.fetch("PATCH",e,t)},head(t=""){return this.fetch("HEAD",t)},opts(t=""){return this.fetch("OPTIONS",t)},body(t){return{...this,_options:{...this._options,body:t}}},json(t,e){const n=gn(this._options.headers);return this.content(e||yn(n)&&n||bi).body(JSON.stringify(t))}};function ie(t="",e={}){return{...Pi,_url:t,_options:e}}ie.default=ie,ie.options=ki,ie.errorType=Si,ie.polyfills=Ii,ie.WretchError=vn;function te(){sessionStorage.removeItem(It),J(ee.CLEAR_CACHE,{})}function Ti(t){const e=t.endpoint||`https://api2.${me}`,n=g=>async(I,E)=>{let L=sessionStorage.getItem(It);L||(L=Date.now().toString(),sessionStorage.setItem(It,L));const Z={...E,headers:{...E.headers,"Cache-Timestamp":L}};return g(I,Z)},r=(g=!0)=>I=>async(E,L)=>{let Z=null;if(Z=await Ye(g),!Z){if(g)throw new Error("No access token available");return I(E,L)}const N={...L,headers:{...L.headers,...Z?{Authorization:`Bearer ${Z}`}:{}}};return I(E,N)},i=g=>(I,E)=>{if(E.headers.Authorization)return g(I,E);const L=localStorage.getItem("__anon_id"),Z=btoa(`${L}:`),N={...E,headers:{...E.headers,Authorization:`Basic ${Z}`}};return g(I,N)},o=ie(e).headers({"Content-Type":"application/json"}).middlewares([n,r(),hn(),fn({delayTimer:1e3,delayRamp:(g,I)=>g*I,maxAttempts:3,until:g=>!!(g&&(g.ok||g.status>=400&&g.status<500)),retryOnNetworkError:!1})]),a=ie(e).headers({"Content-Type":"application/json"}).middlewares([n,r(!1),i,hn(),fn({delayTimer:1e3,delayRamp:(g,I)=>g*I,maxAttempts:3,until:g=>!!(g&&(g.ok||g.status>=400&&g.status<500)),retryOnNetworkError:!1})]);async function s(){return o.get("/entitlements").json()}async function h(g){const I=await o.get("/entitlements").json();return I==null?void 0:I.find(E=>E.id===g)}async function f(g){return o.get(`/entitlements/${g}/access`).json()}async function u(){return o.get("/contracts").json()}async function c(g){const I=await o.get("/contracts").json();return I==null?void 0:I.find(E=>E.id===g)}async function p(){return o.get("/subscriptions").json()}async function d(){return o.get("/bills").json()}async function b(g){const I=await o.get("/bills").json();return I==null?void 0:I.find(E=>E.id===g)}async function S(g,I){const E=await o.url(`/user-metadata/${g}`).put(I).json();return J(ee.USER_ATTRIBUTE_CHANGED,{}),te(),E}async function w(g){const I=await o.url(`/user-metadata/${g}`).delete().res();return te(),I.ok}async function P(g){return(await o.url(`/user-metadata/${g}`).get().json())[g]}async function _(){return await o.url("/user-metadata").get().json()}async function v(){return await o.url("/tags").get().json()}async function l(g){const I=await o.url(`/tags/${g}`).delete().res();return te(),I.ok}async function k(g){const I=await o.url("/tags").post(g).res();return J(ee.USER_ATTRIBUTE_CHANGED,{}),te(),I.ok}async function T(g){return(await a.url("/tallies").get().json())[g]}async function O(){return await a.url("/tallies").get().json()}async function A(g){const I=await a.url(`/tallies/${g}`).delete().res();return te(),I.ok}async function R(g,I){return await a.url(`/tallies/${g}/push`).post(I).json()}async function z(g){return await o.url(`/products/${g}`).get().json()}async function K(){return await _t()?await o.url("/profile").get().json():null}async function $(g){const I=await o.url("/profile").patch(g).res();return te(),I.ok}async function U(){return await o.url("/payment-issues").get().json()}async function M(){return(await o.url("/profile/spotify-link").get().json()).isSpotifyLinked}async function j(){return(await o.url("/profile/unlink-spotify").post().res()).ok}async function W(g){const I=await Ye(!1);if(!I)throw new Error("No access token available");const E=new URL(`https://spotify-oas.${me}/sesamy-callback`);E.searchParams.set("access_token",I),E.searchParams.set("state",g),window.location.href=E.toString()}async function V(g){const I=await o.url(`/products/${g}/auto-onboard`).post().json();return I.length&&te(),I}async function Ie(g,I=3600){const{shortlink:E}=await ie(ui).post({url:g,ttl:I}).json();return E}async function m(g){const I=await Ye(!1);let E;switch(g.target){case"account":E=new URL(`https://account.${me}/subscriptions/${t.clientId}`);break;case"consume":E=new URL(`https://consume.${me}/@${t.clientId}/${g.sku}`),g.episodeId&&(E.href+=`/${g.episodeId}`);break;default:throw new Error("Invalid target")}return I&&(E.hash=`#access_token=${I}`),g.shorten?Ie(E.href,g.ttl):E.href}async function y(){const g=await Ye(!1),I=new URL(`https://account.${me}/subscriptions/${t.clientId}`);g&&(I.hash=`#access_token=${g}`),window.location.href=I.toString()}return{getEntitlements:s,getEntitlement:h,getEntitlementAccess:f,getContracts:u,getContract:c,getProfile:K,updateProfile:$,getSubscriptions:p,getBills:d,getBill:b,setUserMetadata:S,deleteUserMetadata:w,getUserMetadata:P,listUserMetadata:_,getTags:v,deleteTag:l,setTag:k,getTally:T,getTallies:O,deleteTally:A,pushTally:R,getProduct:z,getPaymentIssues:U,autoOnboardProduct:V,isSpotifyLinked:M,unlinkSpotify:j,linkSpotify:W,generateLink:m,openHostedAccountPage:y}}const wn="@sesamy/sesamy-js",Pt="1.13.2";function bn(t,e,n,r,i){for(e=e.split?e.split("."):e,r=0;r<e.length;r++)t=t?t[e[r]]:i;return t===i?n:t}var Ge="undefined",kn="object",Tt=function(){},In="any",Sn="*",ye="__",Be=typeof process<"u"?process:{};Be.env&&Be.env.NODE_ENV;var H=typeof document<"u";Be.versions!=null&&Be.versions.node!=null,typeof Deno<"u"&&Deno.core,H&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent!==void 0&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function _n(t,e){return e.charAt(0)[t]()+e.slice(1)}var Oi=_n.bind(null,"toUpperCase"),ji=_n.bind(null,"toLowerCase");function Ci(t){return En(t)?Oi("null"):typeof t=="object"?Li(t):Object.prototype.toString.call(t).slice(8,-1)}function qe(t,e){e===void 0&&(e=!0);var n=Ci(t);return e?ji(n):n}function ze(t,e){return typeof e===t}var Y=ze.bind(null,"function"),se=ze.bind(null,"string"),Pe=ze.bind(null,"undefined"),xi=ze.bind(null,"boolean");ze.bind(null,"symbol");function En(t){return t===null}function Ai(t){return qe(t)==="number"&&!isNaN(t)}function Pn(t){return qe(t)==="array"}function G(t){if(!$i(t))return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function $i(t){return t&&(typeof t=="object"||t!==null)}function Li(t){return Y(t.constructor)?t.constructor.name:null}function Ui(t){return t instanceof Error||se(t.message)&&t.constructor&&Ai(t.constructor.stackTraceLimit)}function Tn(t,e){if(typeof e!="object"||En(e))return!1;if(e instanceof t)return!0;var n=qe(new t(""));if(Ui(e))for(;e;){if(qe(e)===n)return!0;e=Object.getPrototypeOf(e)}return!1}Tn.bind(null,TypeError),Tn.bind(null,SyntaxError);function Qe(t,e){var n=t instanceof Element||t instanceof HTMLDocument;return n&&e?Ni(t,e):n}function Ni(t,e){return e===void 0&&(e=""),t&&t.nodeName===e.toUpperCase()}function et(t){var e=[].slice.call(arguments,1);return function(){return t.apply(void 0,[].slice.call(arguments).concat(e))}}et(Qe,"form"),et(Qe,"button"),et(Qe,"input"),et(Qe,"select");function Ri(t){return t?Pn(t)?t:[t]:[]}function On(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return null}}function zi(){if(H){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 Mi(t){return function(e){for(var n,r=Object.create(null),i=/([^&=]+)=?([^&]*)/g;n=i.exec(e);){var o=On(n[1]),a=On(n[2]);o.substring(o.length-2)==="[]"?(r[o=o.substring(0,o.length-2)]||(r[o]=[])).push(a):r[o]=a===""||a}for(var s in r){var h=s.split("[");h.length>1&&(Zi(r,h.map(function(f){return f.replace(/[?[\]\\ ]/g,"")}),r[s]),delete r[s])}return r}(function(e){return H&&window.location.search.substring(1)}())}function Zi(t,e,n){for(var r=e.length-1,i=0;i<r;++i){var o=e[i];if(o==="__proto__"||o==="constructor")break;o in t||(t[o]={}),t=t[o]}t[e[r]]=n}function tt(){for(var t="",e=0,n=4294967295*Math.random()|0;e++<36;){var r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e-1],i=15&n;t+=r=="-"||r=="4"?r:(r=="x"?i:3&i|8).toString(16),n=e%8==0?4294967295*Math.random()|0:n>>4}return t}function Ki(t,e){var n,r,i,o=null,a=0,s=function(){a=new Date,o=null,i=t.apply(n,r)};return function(){var h=new Date;a||(a=h);var f=e-(h-a);return n=this,r=arguments,f<=0?(clearTimeout(o),o=null,a=h,i=t.apply(n,r)):o||(o=setTimeout(s,f)),i}}var De="global",Te=ye+"global"+ye,Oe=typeof self===kn&&self.self===self&&self||typeof global===kn&&global.global===global&&global||void 0;function ve(t){return Oe[Te][t]}function we(t,e){return Oe[Te][t]=e}function je(t){delete Oe[Te][t]}function Ce(t,e,n){var r;try{if(Ot(t)){var i=window[t];r=i[e].bind(i)}}catch{}return r||n}Oe[Te]||(Oe[Te]={});var nt={};function Ot(t){if(typeof nt[t]!==Ge)return nt[t];try{var e=window[t];e.setItem(Ge,Ge),e.removeItem(Ge)}catch{return nt[t]=!1}return nt[t]=!0}function C(){return C=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},C.apply(this,arguments)}var ce="function",oe="undefined",Wi="@@redux/"+Math.random().toString(36),jn=function(){return typeof Symbol===ce&&Symbol.observable||"@@observable"}(),rt=" != "+ce;function Cn(t,e,n){var r;if(typeof e===ce&&typeof n===oe&&(n=e,e=void 0),typeof n!==oe){if(typeof n!==ce)throw new Error("enhancer"+rt);return n(Cn)(t,e)}if(typeof t!==ce)throw new Error("reducer"+rt);var i=t,o=e,a=[],s=a,h=!1;function f(){s===a&&(s=a.slice())}function u(){return o}function c(d){if(typeof d!==ce)throw new Error("Listener"+rt);var b=!0;return f(),s.push(d),function(){if(b){b=!1,f();var S=s.indexOf(d);s.splice(S,1)}}}function p(d){if(!G(d))throw new Error("Act != obj");if(typeof d.type===oe)throw new Error("ActType "+oe);if(h)throw new Error("Dispatch in reducer");try{h=!0,o=i(o,d)}finally{h=!1}for(var b=a=s,S=0;S<b.length;S++)(0,b[S])();return d}return p({type:"@@redux/INIT"}),(r={dispatch:p,subscribe:c,getState:u,replaceReducer:function(d){if(typeof d!==ce)throw new Error("next reducer"+rt);i=d,p({type:"@@redux/INIT"})}})[jn]=function(){var d,b=c;return(d={subscribe:function(S){if(typeof S!="object")throw new TypeError("Observer != obj");function w(){S.next&&S.next(u())}return w(),{unsubscribe:b(w)}}})[jn]=function(){return this},d},r}function Fi(t,e){var n=e&&e.type;return"action "+(n&&n.toString()||"?")+"reducer "+t+" returns "+oe}function xe(){var t=[].slice.call(arguments);return t.length===0?function(e){return e}:t.length===1?t[0]:t.reduce(function(e,n){return function(){return e(n.apply(void 0,[].slice.call(arguments)))}})}function Hi(){var t=arguments;return function(e){return function(n,r,i){var o,a=e(n,r,i),s=a.dispatch,h={getState:a.getState,dispatch:function(f){return s(f)}};return o=[].slice.call(t).map(function(f){return f(h)}),C({},a,{dispatch:s=xe.apply(void 0,o)(a.dispatch)})}}}var ue=ye+"anon_id",be=ye+"user_id",Ae=ye+"user_traits",le="userId",$e="anonymousId",it=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],jt=["name","EVENTS","config","loaded"],x=it.reduce(function(t,e){return t[e]=e,t},{registerPluginType:function(t){return"registerPlugin:"+t},pluginReadyType:function(t){return"ready:"+t}}),xn=/^utm_/,An=/^an_prop_/,$n=/^an_trait_/;function Ji(t){var e=t.storage.setItem;return function(n){return function(r){return function(i){if(i.type===x.bootstrap){var o=i.params,a=i.user,s=i.persistedUser,h=i.initialUser,f=s.userId===a.userId;s.anonymousId!==a.anonymousId&&e(ue,a.anonymousId),f||e(be,a.userId),h.traits&&e(Ae,C({},f&&s.traits?s.traits:{},h.traits));var u=Object.keys(i.params);if(u.length){var c=o.an_uid,p=o.an_event,d=u.reduce(function(b,S){if(S.match(xn)||S.match(/^(d|g)clid/)){var w=S.replace(xn,"");b.campaign[w==="campaign"?"name":w]=o[S]}return S.match(An)&&(b.props[S.replace(An,"")]=o[S]),S.match($n)&&(b.traits[S.replace($n,"")]=o[S]),b},{campaign:{},props:{},traits:{}});n.dispatch(C({type:x.params,raw:o},d,c?{userId:c}:{})),c&&setTimeout(function(){return t.identify(c,d.traits)},0),p&&setTimeout(function(){return t.track(p,d.props)},0),Object.keys(d.campaign).length&&n.dispatch({type:x.campaign,campaign:d.campaign})}}return r(i)}}}}function Xi(t){return function(e,n){if(e===void 0&&(e={}),n===void 0&&(n={}),n.type===x.setItemEnd){if(n.key===ue)return C({},e,{anonymousId:n.value});if(n.key===be)return C({},e,{userId:n.value})}switch(n.type){case x.identify:return Object.assign({},e,{userId:n.userId,traits:C({},e.traits,n.traits)});case x.reset:return[be,ue,Ae].forEach(function(r){t.removeItem(r)}),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function Ln(t){return{userId:t.getItem(be),anonymousId:t.getItem(ue),traits:t.getItem(Ae)}}var Ct=function(t){return ye+"TEMP"+ye+t};function Vi(t){var e=t.storage,n=e.setItem,r=e.removeItem,i=e.getItem;return function(o){return function(a){return function(s){var h=s.userId,f=s.traits,u=s.options;if(s.type===x.reset&&([be,Ae,ue].forEach(function(d){r(d)}),[le,$e,"traits"].forEach(function(d){je(Ct(d))})),s.type===x.identify){i(ue)||n(ue,tt());var c=i(be),p=i(Ae)||{};c&&c!==h&&o.dispatch({type:x.userIdChanged,old:{userId:c,traits:p},new:{userId:h,traits:f},options:u}),h&&n(be,h),f&&n(Ae,C({},p,f))}return a(s)}}}}var Me={};function Un(t,e){Me[t]&&Y(Me[t])&&(Me[t](e),delete Me[t])}function Nn(t,e,n){return new Promise(function(r,i){return e()?r(t):n<1?i(C({},t,{queue:!0})):new Promise(function(o){return setTimeout(o,10)}).then(function(o){return Nn(t,e,n-10).then(r,i)})})}function Yi(t){return{abort:t}}function Rn(t,e,n){var r={},i=e(),o=t.getState(),a=o.plugins,s=o.queue,h=o.user;if(!o.context.offline&&s&&s.actions&&s.actions.length){var f=s.actions.reduce(function(c,p,d){return a[p.plugin].loaded?(c.process.push(p),c.processIndex.push(d)):(c.requeue.push(p),c.requeueIndex.push(d)),c},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(c){var p=s.actions[c],d=p.plugin,b=p.payload.type,S=i[d][b];if(S&&Y(S)){var w,P=function(l,k){return l===void 0&&(l={}),k===void 0&&(k={}),[le,$e].reduce(function(T,O){return l.hasOwnProperty(O)&&k[O]&&k[O]!==l[O]&&(T[O]=k[O]),T},l)}(p.payload,h),_=r[P.meta.rid];if(!_&&(w=S({payload:P,config:a[d].config,instance:n,abort:Yi}))&&G(w)&&w.abort)return void(r[P.meta.rid]=!0);if(!_){var v=b+":"+d;t.dispatch(C({},P,{type:v,_:{called:v,from:"queueDrain"}}))}}});var u=s.actions.filter(function(c,p){return!~f.processIndex.indexOf(p)});s.actions=u}}}var xt=function(t){var e=t.data,n=t.action,r=t.instance,i=t.state,o=t.allPlugins,a=t.allMatches,s=t.store,h=t.EVENTS;try{var f=i.plugins,u=i.context,c=n.type,p=c.match(Le),d=e.exact.map(function(w){return w.pluginName});p&&(d=a.during.map(function(w){return w.pluginName}));var b=function(w,P){return function(_,v,l){var k=v.config,T=v.name,O=T+"."+_.type;l&&(O=l.event);var A=_.type.match(Le)?function(R,z,K,$,U){return function(M,j){var W=$?$.name:R,V=j&&Ze(j)?j:K;if($&&(!(V=j&&Ze(j)?j:[R]).includes(R)||V.length!==1))throw new Error("Method "+z+" can only abort "+R+" plugin. "+JSON.stringify(V)+" input valid");return C({},U,{abort:{reason:M,plugins:V,caller:z,_:W}})}}(T,O,P,l,_):function(R,z){return function(){throw new Error(R.type+" action not cancellable. Remove abort in "+z)}}(_,O);return{payload:Gi(_),instance:w,config:k||{},abort:A}}}(r,d),S=e.exact.reduce(function(w,P){var _=P.pluginName,v=P.methodName,l=!1;return v.match(/^initialize/)||v.match(/^reset/)||(l=!f[_].loaded),u.offline&&v.match(/^(page|track|identify)/)&&(l=!0),w[""+_]=l,w},{});return Promise.resolve(e.exact.reduce(function(w,P,_){try{var v=P.pluginName;return Promise.resolve(w).then(function(l){function k(){return Promise.resolve(l)}var T=function(){if(e.namespaced&&e.namespaced[v])return Promise.resolve(e.namespaced[v].reduce(function(O,A,R){try{return Promise.resolve(O).then(function(z){return A.method&&Y(A.method)?(function(M,j){var W=Hn(M);if(W&&W.name===j){var V=Hn(W.method);throw new Error([j+" plugin is calling method "+M,"Plugins cant call self","Use "+W.method+" "+(V?"or "+V.method:"")+" in "+j+" plugin insteadof "+M].join(`
|
|
6
6
|
`))}}(A.methodName,A.pluginName),Promise.resolve(A.method({payload:z,instance:r,abort:(K=z,$=v,U=A.pluginName,function(M,j){return C({},K,{abort:{reason:M,plugins:j||[$],caller:c,from:U||$}})}),config:Mn(A.pluginName,f,o),plugins:f})).then(function(M){var j=G(M)?M:{};return Promise.resolve(C({},z,j))})):z;var K,$,U})}catch(z){return Promise.reject(z)}},Promise.resolve(n))).then(function(O){l[v]=O});l[v]=n}();return T&&T.then?T.then(k):k()})}catch(l){return Promise.reject(l)}},Promise.resolve({}))).then(function(w){return Promise.resolve(e.exact.reduce(function(P,_,v){try{var l=e.exact.length===v+1,k=_.pluginName,T=o[k];return Promise.resolve(P).then(function(O){var A=w[k]?w[k]:{};if(p&&(A=O),$t(A,k))return At({data:A,method:c,instance:r,pluginName:k,store:s}),Promise.resolve(O);if($t(O,k))return l&&At({data:O,method:c,instance:r,store:s}),Promise.resolve(O);if(S.hasOwnProperty(k)&&S[k]===!0)return s.dispatch({type:"queue",plugin:k,payload:A,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(O);var R=b(w[k],o[k]);return Promise.resolve(T[c]({abort:R.abort,payload:A,instance:r,config:Mn(k,f,o),plugins:f})).then(function(z){var K=G(z)?z:{},$=C({},O,K),U=w[k];if($t(U,k))At({data:U,method:c,instance:r,pluginName:k,store:s});else{var M=c+":"+k;(M.match(/:/g)||[]).length<2&&!c.match(zn)&&!c.match(Dn)&&r.dispatch(C({},p?$:A,{type:M,_:{called:M,from:"submethod"}}))}return Promise.resolve($)})})}catch(O){return Promise.reject(O)}},Promise.resolve(n))).then(function(P){if(!(c.match(Le)||c.match(/^registerPlugin/)||c.match(Dn)||c.match(zn)||c.match(/^params/)||c.match(/^userIdChanged/))){if(h.plugins.includes(c),P._&&P._.originalAction===c)return P;var _=C({},P,{_:{originalAction:P.type,called:P.type,from:"engineEnd"}});Wn(P,e.exact.length)&&!c.match(/End$/)&&(_=C({},_,{type:P.type+"Aborted"})),s.dispatch(_)}return P})})}catch(w){return Promise.reject(w)}},Le=/Start$/,zn=/^bootstrap/,Dn=/^ready/;function At(t){var e=t.pluginName,n=t.method+"Aborted"+(e?":"+e:"");t.store.dispatch(C({},t.data,{type:n,_:{called:n,from:"abort"}}))}function Mn(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function Zn(t,e){return e.reduce(function(n,r){return r[t]?n.concat({methodName:t,pluginName:r.name,method:r[t]}):n},[])}function Kn(t,e){var n=t.replace(Le,""),r=e?":"+e:"";return[""+t+r,""+n+r,n+"End"+r]}function $t(t,e){var n=t.abort;return!!n&&(n===!0||Fn(n,e)||n&&Fn(n.plugins,e))}function Wn(t,e){var n=t.abort;if(!n)return!1;if(n===!0||se(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 Fn(t,e){return!(!t||!Ze(t))&&t.includes(e)}function Hn(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Gi(t){return Object.keys(t).reduce(function(e,n){return n==="type"||(e[n]=G(t[n])?Object.assign({},t[n]):t[n]),e},{})}function Bi(t,e,n){var r={};return function(i){return function(o){return function(a){try{var s,h=function(l){return s?l:o(c)},f=a.type,u=a.plugins,c=a;if(a.abort)return Promise.resolve(o(a));if(f===x.enablePlugin&&i.dispatch({type:x.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:a.meta}),f===x.disablePlugin&&setTimeout(function(){return Un(a.meta.rid,{payload:a})},0),f===x.initializeEnd){var p=e(),d=Object.keys(p),b=d.filter(function(l){return u.includes(l)}).map(function(l){return p[l]}),S=[],w=[],P=a.disabled,_=b.map(function(l){var k=l.loaded,T=l.name,O=l.config;return Nn(l,function(){return k({config:O})},1e4).then(function(A){return r[T]||(i.dispatch({type:x.pluginReadyType(T),name:T,events:Object.keys(l).filter(function(R){return!jt.includes(R)})}),r[T]=!0),S=S.concat(T),l}).catch(function(A){if(A instanceof Error)throw new Error(A);return w=w.concat(A.name),A})});Promise.all(_).then(function(l){var k={plugins:S,failed:w,disabled:P};setTimeout(function(){d.length===_.length+P.length&&i.dispatch(C({},{type:x.ready},k))},0)})}var v=function(){if(f!==x.bootstrap)return/^ready:([^:]*)$/.test(f)&&setTimeout(function(){return Rn(i,e,t)},0),Promise.resolve(function(l,k,T,O,A){try{var R=Y(k)?k():k,z=l.type,K=z.replace(Le,"");if(l._&&l._.called)return Promise.resolve(l);var $=T.getState(),U=(W=R,(V=$.plugins)===void 0&&(V={}),(Ie=l.options)===void 0&&(Ie={}),Object.keys(W).filter(function(m){var y=Ie.plugins||{};return xi(y[m])?y[m]:y.all!==!1&&(!V[m]||V[m].enabled!==!1)}).map(function(m){return W[m]}));z===x.initializeStart&&l.fromEnable&&(U=Object.keys($.plugins).filter(function(m){var y=$.plugins[m];return l.plugins.includes(m)&&!y.initialized}).map(function(m){return R[m]}));var M=U.map(function(m){return m.name}),j=function(m,y,g){var I=Kn(m).map(function(E){return Zn(E,y)});return y.reduce(function(E,L){var Z=L.name,N=Kn(m,Z).map(function(Je){return Zn(Je,y)}),F=N[0],D=N[1],ne=N[2];return F.length&&(E.beforeNS[Z]=F),D.length&&(E.duringNS[Z]=D),ne.length&&(E.afterNS[Z]=ne),E},{before:I[0],beforeNS:{},during:I[1],duringNS:{},after:I[2],afterNS:{}})}(z,U);return Promise.resolve(xt({action:l,data:{exact:j.before,namespaced:j.beforeNS},state:$,allPlugins:R,allMatches:j,instance:T,store:O,EVENTS:A})).then(function(m){function y(){var E=function(){if(z.match(Le))return Promise.resolve(xt({action:C({},g,{type:K+"End"}),data:{exact:j.after,namespaced:j.afterNS},state:$,allPlugins:R,allMatches:j,instance:T,store:O,EVENTS:A})).then(function(L){L.meta&&L.meta.hasCallback&&Un(L.meta.rid,{payload:L})})}();return E&&E.then?E.then(function(){return m}):m}if(Wn(m,M.length))return m;var g,I=function(){if(z!==K)return Promise.resolve(xt({action:C({},m,{type:K}),data:{exact:j.during,namespaced:j.duringNS},state:$,allPlugins:R,allMatches:j,instance:T,store:O,EVENTS:A})).then(function(E){g=E});g=m}();return I&&I.then?I.then(y):y()})}catch(m){return Promise.reject(m)}var W,V,Ie}(a,e,t,i,n)).then(function(l){return s=1,o(l)})}();return Promise.resolve(v&&v.then?v.then(h):h(v))}catch(l){return Promise.reject(l)}}}}}function qi(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===x.setItem||i===x.removeItem){if(r.abort)return n(r);i===x.setItem?t.setItem(o,a,s):t.removeItem(o,s)}return n(r)}}}}var Qi=function(){var t=this;this.before=[],this.after=[],this.addMiddleware=function(e,n){t[n]=t[n].concat(e)},this.removeMiddleware=function(e,n){var r=t[n].findIndex(function(i){return i===e});r!==-1&&(t[n]=[].concat(t[n].slice(0,r),t[n].slice(r+1)))},this.dynamicMiddlewares=function(e){return function(n){return function(r){return function(i){var o={getState:n.getState,dispatch:function(s){return n.dispatch(s)}},a=t[e].map(function(s){return s(o)});return xe.apply(void 0,a)(r)(i)}}}}};function eo(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=Jn(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},C({},e,r)}if(/^initialize:([^:]*)$/.test(n.type)){var h=Jn(n.type,x.initialize),f=t()[h];return f&&h?(r[h]=C({},e[h],{initialized:!0,loaded:!!f.loaded({config:f.config})}),C({},e,r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=C({},e[n.name],{loaded:!0}),C({},e,r);switch(n.type){case x.disablePlugin:return C({},e,Xn(n.plugins,!1,e));case x.enablePlugin:return C({},e,Xn(n.plugins,!0,e));default:return e}}}function Jn(t,e){return t.substring(e.length+1,t.length)}function Xn(t,e,n){return t.reduce(function(r,i){return r[i]=C({},n[i],{enabled:e}),r},n)}function Vn(t){try{return JSON.parse(JSON.stringify(t))}catch{}return t}var to={last:{},history:[]};function no(t,e){t===void 0&&(t=to);var n=e.options,r=e.meta;if(e.type===x.track){var i=Vn(C({event:e.event,properties:e.properties},Object.keys(n).length&&{options:n},{meta:r}));return C({},t,{last:i,history:t.history.concat(i)})}return t}var ro={actions:[]};function io(t,e){t===void 0&&(t=ro);var n=e.payload;switch(e.type){case"queue":var r;return r=n&&n.type&&n.type===x.identify?[e].concat(t.actions):t.actions.concat(e),C({},t,{actions:r});case"dequeue":return[];default:return t}}var Yn=/#.*$/;function oo(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(Yn,""):"")}var Gn,Bn,qn,Qn,ao=function(t){if(t===void 0&&(t={}),!H)return t;var e=document,n=e.title,r=e.referrer,i=window,o=i.location,a=i.innerWidth,s=i.innerHeight,h=o.hash,f=o.search,u=function(p){var d=function(){if(H){for(var b,S=document.getElementsByTagName("link"),w=0;b=S[w];w++)if(b.getAttribute("rel")==="canonical")return b.getAttribute("href")}}();return d?d.match(/\?/)?d:d+p:window.location.href.replace(Yn,"")}(f),c={title:n,url:u,path:oo(u),hash:h,search:f,width:a,height:s};return r&&r!==""&&(c.referrer=r),C({},c,t)},so={last:{},history:[]};function co(t,e){t===void 0&&(t=so);var n=e.options;if(e.type===x.page){var r=Vn(C({properties:e.properties,meta:e.meta},Object.keys(n).length&&{options:n}));return C({},t,{last:r,history:t.history.concat(r)})}return t}Gn=function(){if(!H)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"}(),Bn=H?document.referrer:null,qn=zi(),Qn=Di();var er={initialized:!1,sessionId:tt(),app:null,version:null,debug:!1,offline:!!H&&!navigator.onLine,os:{name:Gn},userAgent:H?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.7"},timezone:Qn,locale:qn,campaign:{},referrer:Bn};function uo(t,e){t===void 0&&(t=er);var n=t.initialized,r=e.campaign;switch(e.type){case x.campaign:return C({},t,{campaign:r});case x.offline:return C({},t,{offline:!0});case x.online:return C({},t,{offline:!1});default:return n?t:C({},er,t,{initialized:!0})}}var lo=["plugins","reducers","storage"];function ho(t,e,n){if(H){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach(function(i){r(i,e)})}}function fo(t){var e=ho.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(t)});return e(!0),function(n){return e(!1)}}function tr(){return we("analytics",[]),function(t){return function(e,n,r){var i=t(e,n,r),o=i.dispatch;return Object.assign(i,{dispatch:function(a){return Oe[Te].analytics.push(a.action||a),o(a)}})}}}function nr(t){return function(){return xe(xe.apply(null,arguments),tr())}}function Lt(t){return t?Pn(t)?t:[t]:[]}function rr(t,e,n){t===void 0&&(t={});var r,i,o=tt();return e&&(Me[o]=(r=e,i=function(a){for(var s,h=a||Array.prototype.slice.call(arguments),f=0;f<h.length;f++)if(Y(h[f])){s=h[f];break}return s}(n),function(a){i&&i(a),r(a)})),C({},t,{rid:o,ts:new Date().getTime()},e?{hasCallback:!0}:{})}function po(t){t===void 0&&(t={});var e=t.reducers||{},n=t.initialUser||{},r=(t.plugins||[]).reduce(function(m,y){if(Y(y))return m.middlewares=m.middlewares.concat(y),m;if(y.NAMESPACE&&(y.name=y.NAMESPACE),!y.name)throw new Error("https://lytics.dev/errors/1");y.config||(y.config={});var g=y.EVENTS?Object.keys(y.EVENTS).map(function(L){return y.EVENTS[L]}):[];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(L,Z){var N;return L[Z]=(N=y.methods[Z],function(){for(var F=Array.prototype.slice.call(arguments),D=new Array(N.length),ne=0;ne<F.length;ne++)D[ne]=F[ne];return D[D.length]=k,N.apply({instance:k},D)}),L},{}),delete y.methods);var I=Object.keys(y).concat(g),E=new Set(m.events.concat(I));if(m.events=Array.from(E),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:ve,setItem:we,removeItem:je},o=function(m){return function(y,g,I){return g.getState("user")[y]||(I&&G(I)&&I[y]?I[y]:Ln(m)[y]||ve(Ct(y))||null)}}(i),a=r.plugins,s=r.events.filter(function(m){return!jt.includes(m)}).sort(),h=new Set(s.concat(it).filter(function(m){return!jt.includes(m)})),f=Array.from(h).sort(),u=function(){return a},c=new Qi,p=c.addMiddleware,d=c.removeMiddleware,b=c.dynamicMiddlewares,S=function(){throw new Error("Abort disabled inListener")},w=Mi(),P=Ln(i),_=C({},P,n,w.an_uid?{userId:w.an_uid}:{},w.an_aid?{anonymousId:w.an_aid}:{});_.anonymousId||(_.anonymousId=tt());var v=C({enable:function(m,y){return new Promise(function(g){j.dispatch({type:x.enablePlugin,plugins:Lt(m),_:{originalAction:x.enablePlugin}},g,[y])})},disable:function(m,y){return new Promise(function(g){j.dispatch({type:x.disablePlugin,plugins:Lt(m),_:{originalAction:x.disablePlugin}},g,[y])})}},r.methods),l=!1,k={identify:function(m,y,g,I){try{var E=se(m)?m:null,L=G(m)?m:y,Z=g||{},N=k.user();we(Ct(le),E);var F=E||L.userId||o(le,k,L);return Promise.resolve(new Promise(function(D){j.dispatch(C({type:x.identifyStart,userId:F,traits:L||{},options:Z,anonymousId:N.anonymousId},N.id&&N.id!==E&&{previousId:N.id}),D,[y,g,I])}))}catch(D){return Promise.reject(D)}},track:function(m,y,g,I){try{var E=G(m)?m.event:m;if(!E||!se(E))throw new Error("EventMissing");var L=G(m)?m:y||{},Z=G(g)?g:{};return Promise.resolve(new Promise(function(N){j.dispatch({type:x.trackStart,event:E,properties:L,options:Z,userId:o(le,k,y),anonymousId:o($e,k,y)},N,[y,g,I])}))}catch(N){return Promise.reject(N)}},page:function(m,y,g){try{var I=G(m)?m:{},E=G(y)?y:{};return Promise.resolve(new Promise(function(L){j.dispatch({type:x.pageStart,properties:ao(I),options:E,userId:o(le,k,I),anonymousId:o($e,k,I)},L,[m,y,g])}))}catch(L){return Promise.reject(L)}},user:function(m){if(m===le||m==="id")return o(le,k);if(m===$e||m==="anonId")return o($e,k);var y=k.getState("user");return m?bn(y,m):y},reset:function(m){return new Promise(function(y){j.dispatch({type:x.resetStart},y,m)})},ready:function(m){return l&&m({plugins:v,instance:k}),k.on(x.ready,function(y){m(y),l=!0})},on:function(m,y){if(!m||!Y(y))return!1;if(m===x.bootstrap)throw new Error(".on disabled for "+m);var g=/Start$|Start:/;if(m==="*"){var I=function(N){return function(F){return function(D){return D.type.match(g)&&y({payload:D,instance:k,plugins:a}),F(D)}}},E=function(N){return function(F){return function(D){return D.type.match(g)||y({payload:D,instance:k,plugins:a}),F(D)}}};return p(I,ot),p(E,at),function(){d(I,ot),d(E,at)}}var L=m.match(g)?ot:at,Z=function(N){return function(F){return function(D){return D.type===m&&y({payload:D,instance:k,plugins:a,abort:S}),F(D)}}};return p(Z,L),function(){return d(Z,L)}},once:function(m,y){if(!m||!Y(y))return!1;if(m===x.bootstrap)throw new Error(".once disabled for "+m);var g=k.on(m,function(I){y({payload:I.payload,instance:k,plugins:a,abort:S}),g()});return g},getState:function(m){var y=j.getState();return m?bn(y,m):Object.assign({},y)},dispatch:function(m){var y=se(m)?{type:m}:m;if(it.includes(y.type))throw new Error("reserved action "+y.type);var g=C({},y,{_:C({originalAction:y.type},m._||{})});j.dispatch(g)},enablePlugin:v.enable,disablePlugin:v.disable,plugins:v,storage:{getItem:i.getItem,setItem:function(m,y,g){j.dispatch({type:x.setItemStart,key:m,value:y,options:g})},removeItem:function(m,y){j.dispatch({type:x.removeItemStart,key:m,options:y})}},setAnonymousId:function(m,y){k.storage.setItem(ue,m,y)},events:{core:it,plugins:s}},T=r.middlewares.concat([function(m){return function(y){return function(g){return g.meta||(g.meta=rr()),y(g)}}},b(ot),Bi(k,u,{all:f,plugins:s}),qi(i),Ji(k),Vi(k),b(at)]),O={context:uo,user:Xi(i),page:co,track:no,plugins:eo(u),queue:io},A=xe,R=xe;if(H&&t.debug){var z=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;z&&(A=z({trace:!0,traceLimit:25})),R=function(){return arguments.length===0?tr():G(typeof arguments[0])?nr():nr().apply(null,arguments)}}var K,$=function(m){return Object.keys(m).reduce(function(y,g){return lo.includes(g)||(y[g]=m[g]),y},{})}(t),U=r.pluginsArray.reduce(function(m,y){var g=y.name,I=y.config,E=y.loaded,L=r.pluginEnabled[g];return m[g]={enabled:L,initialized:!!L&&!y.initialize,loaded:!!E({config:I}),config:I},m},{}),M={context:$,user:_,plugins:U},j=Cn(function(m){for(var y=Object.keys(m),g={},I=0;I<y.length;I++){var E=y[I];typeof m[E]===ce&&(g[E]=m[E])}var L,Z=Object.keys(g);try{(function(N){Object.keys(N).forEach(function(F){var D=N[F];if(typeof D(void 0,{type:"@@redux/INIT"})===oe||typeof D(void 0,{type:Wi})===oe)throw new Error("reducer "+F+" "+oe)})})(g)}catch(N){L=N}return function(N,F){if(N===void 0&&(N={}),L)throw L;for(var D=!1,ne={},Je=0;Je<Z.length;Je++){var ft=Z[Je],xr=N[ft],Ht=(0,g[ft])(xr,F);if(typeof Ht===oe){var na=Fi(ft,F);throw new Error(na)}ne[ft]=Ht,D=D||Ht!==xr}return D?ne:N}}(C({},O,e)),M,R(A(Hi.apply(void 0,T))));j.dispatch=(K=j.dispatch,function(m,y,g){var I=C({},m,{meta:rr(m.meta,y,Lt(g))});return K.apply(null,[I])});var W=Object.keys(a);j.dispatch({type:x.bootstrap,plugins:W,config:$,params:w,user:_,initialUser:n,persistedUser:P});var V=W.filter(function(m){return r.pluginEnabled[m]}),Ie=W.filter(function(m){return!r.pluginEnabled[m]});return j.dispatch({type:x.registerPlugins,plugins:W,enabled:r.pluginEnabled}),r.pluginsArray.map(function(m,y){var g=m.bootstrap,I=m.config,E=m.name;g&&Y(g)&&g({instance:k,config:I,payload:m}),j.dispatch({type:x.registerPluginType(E),name:E,enabled:r.pluginEnabled[E],plugin:m}),r.pluginsArray.length===y+1&&j.dispatch({type:x.initializeStart,plugins:V,disabled:Ie})}),fo(function(m){j.dispatch({type:m?x.offline:x.online})}),function(m,y,g){setInterval(function(){return Rn(m,y,g)},3e3)}(j,u,k),k}var ot="before",at="after",Ke="cookie",ke=ar(),ir=st,mo=st;function or(t){return ke?st(t,"",-1):je(t)}function ar(){if(ke!==void 0)return ke;var t="cookiecookie";try{st(t,t),ke=document.cookie.indexOf(t)!==-1,or(t)}catch{ke=!1}return ke}function st(t,e,n,r,i,o){if(typeof window<"u"){var a=arguments.length>1;return ke===!1&&(a?we(t,e):ve(t)),a?document.cookie=t+"="+encodeURIComponent(e)+(n?"; expires="+new Date(+new Date+1e3*n).toUTCString()+(r?"; path="+r:"")+(i?"; domain="+i:"")+(o?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+t+"=")[1]||"").split(";")[0])}}var We="localStorage",go=Ot.bind(null,"localStorage");Ce("localStorage","getItem",ve),Ce("localStorage","setItem",we),Ce("localStorage","removeItem",je);var Fe="sessionStorage",yo=Ot.bind(null,"sessionStorage");Ce("sessionStorage","getItem",ve),Ce("sessionStorage","setItem",we),Ce("sessionStorage","removeItem",je);function Ue(t){var e=t;try{if((e=JSON.parse(t))==="true")return!0;if(e==="false")return!1;if(G(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var vo=go(),wo=yo(),bo=ar();function sr(t,e){if(t){var n=Ut(e),r=!Dt(n),i=Nt(n)?Ue(localStorage.getItem(t)):void 0;if(r&&!Pe(i))return i;var o=Rt(n)?Ue(ir(t)):void 0;if(r&&o)return o;var a=zt(n)?Ue(sessionStorage.getItem(t)):void 0;if(r&&a)return a;var s=ve(t);return r?s:{localStorage:i,sessionStorage:a,cookie:o,global:s}}}function ko(t,e,n){if(t&&!Pe(e)){var r={},i=Ut(n),o=JSON.stringify(e),a=!Dt(i);return Nt(i)&&(r[We]=ut(We,e,Ue(localStorage.getItem(t))),localStorage.setItem(t,o),a)?r[We]:Rt(i)&&(r[Ke]=ut(Ke,e,Ue(ir(t))),mo(t,o),a)?r[Ke]:zt(i)&&(r[Fe]=ut(Fe,e,Ue(sessionStorage.getItem(t))),sessionStorage.setItem(t,o),a)?r[Fe]:(r[De]=ut(De,e,ve(t)),we(t,e),a?r[De]:r)}}function Io(t,e){if(t){var n=Ut(e),r=sr(t,Sn),i={};return!Pe(r.localStorage)&&Nt(n)&&(localStorage.removeItem(t),i[We]=r.localStorage),!Pe(r.cookie)&&Rt(n)&&(or(t),i[Ke]=r.cookie),!Pe(r.sessionStorage)&&zt(n)&&(sessionStorage.removeItem(t),i[Fe]=r.sessionStorage),!Pe(r.global)&&ct(n,De)&&(je(t),i[De]=r.global),i}}function Ut(t){return t?se(t)?t:t.storage:In}function Nt(t){return vo&&ct(t,We)}function Rt(t){return bo&&ct(t,Ke)}function zt(t){return wo&&ct(t,Fe)}function Dt(t){return t===Sn||t==="all"}function ct(t,e){return t===In||t===e||Dt(t)}function ut(t,e,n){return{location:t,current:e,previous:n}}var So={setItem:ko,getItem:sr,removeItem:Io};function _o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cr(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 ur(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cr(Object(n),!0).forEach(function(r){_o(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cr(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Eo(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e={storage:So};return po(ur(ur({},e),t))}function Po(t,e){e=e||{};var n,r,i=[],o=e.max||1/0;function a(){clearInterval(n),t(i.splice(0,o)),s()}function s(){n=setInterval(a,e.interval||1e4)}return s(),{flush:a,push:function(h){return r=i.push(h),r>=o&&a(),r},size:function(){return i.length},end:function(h){h&&a(),clearInterval(n)}}}function To(t){if(typeof window>"u")return;const{addEventListener:e,history:n,location:r}=window;let i=r.pathname;e("popstate",()=>t(r.pathname)),["push","replace"].map(o=>{const a=`${o}State`;if(a!=="pushState"&&a!=="replaceState")return;const s=n[a];n[a]=function(...h){var c;const f=((c=h[2])==null?void 0:c.toString())||"",u=jo(f);return i!==u&&(i=u,setTimeout(()=>t(f),0)),s.apply(n,h)}})}function Oo(t,e){const n=t.indexOf(e);return n>-1?t.slice(0,n):t}function jo(t){return["#","?"].forEach(e=>t=Oo(t,e)),t}function Co(){To(()=>{ae.page()})}function xo(t){if(t===void 0&&(t={}),!H)return Tt;var e=dr(),n=Mt(),r=lr(),i=lt(r,e),o=lt(n,e),a=[],s=[],h=[],f=r,u=i,c=o,p=Object.keys(t);if(!p.length)return Tt;var d=p.map(function(S){return Number(S)}),b=Ki(function(){var S=dr(),w=function($,U){return U.map(function(M){return M===100?$-5:$*(M/100)})}(S,d),P=Mt(),_=lr(),v=lt(_,S),l=lt(P,S);if(u=v>u?v:u,c=l<c?l:c,!(a.length>=d.length)){var k=f===_,T="up";k?T="initial":f<=_&&(T="down");var O=w,A=d;(T==="up"||k)&&(O=w.slice().reverse(),A=d.slice().reverse());var R=A.reduce(function($,U,M){var j=O[M];return h.includes(U)&&_<=j&&(h=h.filter(function(W){return W!==U}),$.singleFunction=U),T==="down"&&!a.includes(U)&&_>=j&&U>o?(s.push(U),$.callbacks=$.callbacks.concat(U),$):T==="up"&&!a.includes(U)&&_<=j&&U<=v?($.foundFunc=[U],$):(k&&_>=j&&$.foundFunc.length===0&&($.foundFunc=[U]),!s.includes(U)&&_>=j&&(s.push(U),$.singleFunction?h.push(U):$.singleFunction=U),$)},{foundFunc:[],singleFunction:null,callbacks:[],direction:T});if(f=_,T==="down"&&R.callbacks&&R.callbacks.forEach(function($){Y(t[$])&&(t[$]({trigger:$,direction:T,scrollMin:c,scrollMax:u,range:[c,u]}),a.push($))}),R.singleFunction){var z=R.singleFunction,K=R.direction;Y(t[z])&&t[z]({trigger:z,direction:K,scrollMin:c,scrollMax:u,range:[c,u]}),a.push(z)}}},500);return window.addEventListener("scroll",b),function(){return window.removeEventListener("scroll",b)}}function Mt(){return H?document.body.scrollTop||document.documentElement.scrollTop:0}function Ao(){return H?window.innerHeight||document.documentElement.clientHeight:0}function lr(){return Math.round(Mt()+Ao())}function dr(){if(!H)return 0;var t=document.body,e=document.documentElement;return Math.max(t.scrollHeight,t.offsetHeight,e.clientHeight,e.scrollHeight,e.offsetHeight)}function lt(t,e){return Math.round(t/e*100)}var hr="EventListener";function $o(t){return function(e,n,r,i){var o=r||Tt,a=i||!1;if(!H)return o;var s=dt(n),h=dt(e,!0);if(!h.length)throw new Error("noElements");if(!s.length)throw new Error("noEvent");var f=[];return function u(c){c&&(f=[]);for(var p=c?"add"+hr:"remove"+hr,d=0;d<h.length;d++){var b=h[d];f[d]=c?a&&a.once?Lo(o):o:f[d]||o;for(var S=0;S<s.length;S++)b[p]?b["on"+s[S]]=c?f[d]:null:b[p](s[S],f[d],a)}return u.bind(null,!c)}(t)}}function dt(t,e){if(se(t))return e?dt(document.querySelectorAll(t)):(n=t).split(n.indexOf(",")>-1?",":" ").map(function(a){return a.trim()});var n;if(NodeList.prototype.isPrototypeOf(t)){for(var r=[],i=t.length>>>0;i--;)r[i]=t[i];return r}var o=Ri(t);return e?o.map(function(a){return se(a)?dt(a,!0):a}).flat():o}function Lo(t,e){var n;return function(){return t&&(n=t.apply(this,arguments),t=null),n}}var Zt=$o("Event");function fr(t,e){return H&&Y(window[t])?(n=window[t],r=e,(i=window)===void 0&&(i=null),Y(n)?function(){n.apply(i,arguments),r.apply(i,arguments)}:r):window[t]=e;var n,r,i}fr.bind(null,"onerror"),fr.bind(null,"onload");var pr=typeof window>"u",mr="hidden";function Uo(t){if(pr)return!1;var e=No(),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 No(){var t=["webkit","moz","ms","o"];return pr||mr in document?mr:t.reduce(function(e,n){var r=n+"Hidden";return!e&&r in document?r:e},null)}var Ro=["mousemove","mousedown","touchmove","touchstart","touchend","keydown"];function zo(t,e){e===void 0&&(e={});var n=function(a,s){var h=this,f=!1;return function(u){f||(a.call(h,u),f=!0,setTimeout(function(){return f=!1},s))}}(t,e.throttle||1e4),r=[];function i(){var a=Uo(function(s){s||n({type:"tabVisible"})});return r=[a].concat(Ro.map(function(s){return Zt(document,s,n)})).concat(Zt(window,"load",n)).concat(Zt(window,"scroll",n,{capture:!0,passive:!0})),o}function o(){r.map(function(a){return a()})}return i(),function(){return o(),i}}function Do(t){var e,n,r=t.onIdle,i=t.onWakeUp,o=t.onHeartbeat,a=t.timeout,s=a===void 0?1e4:a,h=t.throttle,f=h===void 0?2e3:h,u=!1,c=!1,p=new Date,d=function(){return clearTimeout(e)};function b(w){d(),o&&!u&&o(He(p),w),i&&u&&(u=!1,i(He(n),w),p=new Date),e=setTimeout(function(){u=!0,r&&(n=new Date,r(He(p),w))},s)}var S=zo(b,{throttle:f});return{disable:function(){c=!0,u=!1,d();var w=S();return function(){return c=!1,p=new Date,b({type:"load"}),w()}},getStatus:function(){return{isIdle:u,isDisabled:c,active:u?0:He(p,c),idle:u?He(n,c):0}}}}function He(t,e){return e?0:Math.round((new Date-t)/1e3)}const gr=5e3;class Mo{constructor(e){Q(this,"element");Q(this,"isInViewport",!1);Q(this,"isAwake",!1);Q(this,"isFlushing");Q(this,"observer");Q(this,"lastEventAt",Date.now());Q(this,"registeredView",!1);Q(this,"viewCallback");Q(this,"activeDurationCallback");Q(this,"idleDurationCallback");Q(this,"scrollCallback");this.element=e.element,this.viewCallback=e.viewCallback,this.activeDurationCallback=e.activeDurationCallback,this.idleDurationCallback=e.idleDurationCallback,this.scrollCallback=e.scrollCallback,this.observer=new IntersectionObserver(n=>{n.forEach(r=>{this.handleInViewPort(r.isIntersecting)})},{threshold:0}),this.observer.observe(this.element),Do({onIdle:n=>this.handleAwake(!1,n),onWakeUp:n=>this.handleAwake(!0,n),timeout:gr}),xo({25:this.handleScroll.bind(this),50:this.handleScroll.bind(this),75:this.handleScroll.bind(this),90:this.handleScroll.bind(this),100:this.handleScroll.bind(this)})}flush(){this.isFlushing=!0,this.handleAwake(!this.isAwake)}handleInViewPort(e){e?(this.isAwake=!0,this.trackInViewport()):this.handleAwake(!1),this.isInViewport=e}handleAwake(e,n=Math.round((Date.now()-this.lastEventAt)/1e3)){this.isAwake=e,this.lastEventAt=e?Date.now()-n*gr:Date.now(),this.isInViewport&&this.trackAwake(e,n)}handleScroll(e){this.scrollCallback&&this.scrollCallback(e)}handleVisibilityChange(){this.isAwake=!1;const e=Math.round((Date.now()-this.lastEventAt)/1e3);e>1&&(this.lastEventAt=Date.now(),this.trackAwake(!1,e))}trackAwake(e,n){!e&&this.activeDurationCallback&&this.activeDurationCallback(n,this.isFlushing,this.lastEventAt),e&&this.idleDurationCallback&&this.idleDurationCallback(n,this.isFlushing,this.lastEventAt)}trackInViewport(){this.registeredView||(this.registeredView=!0,this.viewCallback&&this.viewCallback())}}const yr="sesamy_session_id";function Zo(){let t=sessionStorage.getItem(yr);return t||(t=Math.random().toString(36).slice(2,9),sessionStorage.setItem(yr,t)),t}let vr=!1,Kt,wr,ht;function Ko({clientId:t,enabled:e=!0,endpoint:n=li}){if(Kt=t,wr=e,ht=n,!wr)return;Co();const r=new Mo({element:document.body,viewCallback:()=>{ae.page()},activeDurationCallback:(i,o,a)=>{ae.track("activeDuration",{duration:i,durationStart:a,flushing:o})},idleDurationCallback:(i,o,a)=>{ae.track("idleDuration",{duration:i,durationStart:a,flushing:o})},scrollCallback:i=>{ae.track("scroll",{scroll:i.scrollMax})}});Ho(document.body,()=>{r.flush()}),Jo(document.body,()=>{r.handleVisibilityChange()}),window.addEventListener(ee.AUTHENTICATED,async i=>{const o=i;await ae.identify(o.detail.sub)}),window.addEventListener(ee.LOGOUT,async()=>{await ae.track("logout",{}),Wt.flush(),await ae.reset()})}function br(t){return JSON.stringify(t.map(e=>({...e,clientId:Kt,requestId:Math.random().toString(36).slice(2,9),sessionId:Zo(),timestamp:new Date().toISOString(),version:Pt,event:e.event,context:{page:{url:window.location.hostname,path:window.location.pathname,title:document.title,search:window.location.search,referrer:document.referrer},locale:navigator.language,library:wn,userAgent:navigator.userAgent,clientId:Kt}})))}const Wt=Po(async t=>{if(t.length>0){const e=br(t);vr?navigator.sendBeacon(ht,e):(await fetch(ht,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})).ok}},{max:10,interval:3e3});function Ft(t){var e;if(t.anonymousId)if((e=t.properties)!=null&&e.flushing){const n={...t};delete n.properties.flushing,navigator.sendBeacon(ht,br([n]))}else Wt.push(t)}const ae=Eo({app:wn,version:Pt,plugins:[{name:"custom-analytics-plugin",page:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Ft({anonymousId:n,userId:r,properties:e,event:i,type:"page"})},track:({payload:t})=>{const{properties:e,anonymousId:n,userId:r,event:i}=t;Ft({anonymousId:n,userId:r,properties:e,event:i,type:"track"})},identify:({payload:t})=>{const{properties:e,anonymousId:n,userId:r}=t;Ft({anonymousId:n,userId:r,properties:e,type:"identify"})}}]});function Wo(t,e){ae.track(t,e)}function Fo(){return vr=!0,Wt.flush()}const kr=new Map;function Ho(t,e){kr.set(t,e)}window.addEventListener("beforeunload",()=>{kr.forEach((t,e)=>{t.bind(e)()}),Fo()});const Ir=new Map;function Jo(t,e){Ir.set(t,e)}window.addEventListener("visibilitychange",()=>{document.visibilityState!=="visible"&&Ir.forEach((t,e)=>{t.bind(e)()})});const Sr="sesamySignedURLs";function _r(){const t=sessionStorage.getItem(Sr);return t?JSON.parse(t):[]}function Xo(t){const e=_r();e.push(t),sessionStorage.setItem(Sr,JSON.stringify(e))}function Vo(t){const{getEntitlement:e,getEntitlements:n,getEntitlementAccess:r,getSubscriptions:i,getContract:o,getContracts:a,getBill:s,getBills:h,getProfile:f,updateProfile:u,getTags:c,deleteTag:p,setTag:d,getUserMetadata:b,listUserMetadata:S,setUserMetadata:w,deleteUserMetadata:P,getTally:_,getTallies:v,pushTally:l,deleteTally:k,getProduct:T,getPaymentIssues:O,isSpotifyLinked:A,unlinkSpotify:R,linkSpotify:z,autoOnboardProduct:K,openHostedAccountPage:$,generateLink:U}=Ti(t),M={auth:{getUser:f,isAuthenticated:_t,loginWithRedirect:Et,logout:pi,setToken:dn},profile:{get:f,update:u,openHostedAccountPage:$,isSpotifyLinked:A,unlinkSpotify:R},analytics:{track:Wo},tags:{list:c,set:d,delete:p},entitlements:{get:e,list:n,access:r,signedLinks:_r},contracts:{get:o,list:a},bills:{get:s,list:h},userMetadata:{get:b,list:S,set:w,delete:P},tallies:{get:_,list:v,push:l,delete:k},subscriptions:{list:i},products:{get:T,autoOnboard:K,linkSpotify:z},getVersion:Yo,getPaymentIssues:O,generateLink:U,clearCache:te};return t.namespace&&(window[t.namespace]=M),M}function Yo(){return Pt}function Go(){const t=new URLSearchParams(window.location.hash.substring(1)),e=t.get("access_token");if(e){dn(e);const n=new URL(window.location.href);t.delete("access_token"),n.hash=t.toString(),window.history.replaceState(null,"",n)}}const Er="sesamy-refresh",Pr="force-refetch-entitlements";function Bo(){const t=new URLSearchParams(window.location.search),e=t.get(Pr),n=t.get(Er);if(e!==null||n!==null){const r=new URL(window.location.href);t.delete(Pr),t.delete(Er),r.search=t.toString(),te(),window.history.replaceState(null,"",r)}}function qo(){const t=new URLSearchParams(window.location.search),e=t.get("token"),n=t.get("se");if(!n||!e)return;const r=parseInt(n,10);if(Number.isNaN(r)||r<Date.now())return;Xo({url:window.location.href.split("?")[0],token:e,expiresAt:r,publisherContentId:t.get("sp")??void 0});const i=new URL(window.location.href);i.searchParams.delete("ss"),i.searchParams.delete("se"),i.searchParams.delete("sp"),i.searchParams.delete("so"),i.searchParams.delete("token"),window.history.replaceState(null,"",i)}const Tr="sesamy-user";async function Qo(){const e=new URLSearchParams(window.location.search).get(Tr);if(!e)return;const n=await fi();(n==null?void 0:n.email)!==e&&Et({authorizationParams:{email_hint:e}});const r=new URL(window.location.href);r.searchParams.delete(Tr),window.history.replaceState(null,"",r)}const Or="sesamy-purchase";function ea(){const t=new URLSearchParams(window.location.search),e=t.get(Or);if(e!==null){const n=new URL(window.location.href);t.delete(Or),n.search=t.toString(),J(ee.PURCHASE,{itemSrc:e}),te(),window.history.replaceState(null,"",n)}}const jr="sesamy-login";async function ta(){if(!new URLSearchParams(window.location.search).get(jr))return;await _t()||Et();const r=new URL(window.location.href);r.searchParams.delete(jr),window.history.replaceState(null,"",r)}async function Cr(t){Ko({clientId:t.clientId,...t.analytics}),await hi({clientId:t.clientId,organization:t.organization,...t.auth});const e=Vo({clientId:t.clientId,...t.api});return J(ee.READY,{}),Go(),Bo(),qo(),await ta(),await Qo(),ea(),e}if(typeof document<"u"){const t=document.getElementById("sesamy-js");if(t!=null&&t.textContent)try{const e=JSON.parse(t.textContent);Cr(e)}catch(e){console.error("Failed to parse config",e)}}return re.init=Cr,Object.defineProperty(re,Symbol.toStringTag,{value:"Module"}),re}({});
|
package/dist/sesamy-js.mjs
CHANGED