@accounter/client
Version:
Accounter client application
4 lines • 167 kB
JavaScript
import{s as e}from"./dist-BbgEzppd.js";import{o as t}from"./utils-BUNz070n.js";import{n,t as r}from"./dist-CgECp_RN.js";n();var i=e(t()),a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},a(e,t)};function o(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);a(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var s=function(){return s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},s.apply(this,arguments)};function c(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function l(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function u(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function d(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function f(e,t){this.v=e,this.k=t}function p(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function m(e){return new f(e,0)}function h(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function g(e,t){return e.get(p(e,t))}function _(e,t,n){h(e,t),t.set(e,n)}function v(e,t,n){return e.set(p(e,t),n),n}function y(e,t,n){return(t=function(e){var t=function(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}(e,`string`);return typeof t==`symbol`?t:t+``}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function b(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ee(Object(n),!0).forEach(function(t){y(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ee(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function x(e,t){if(e==null)return{};var n,r,i=function(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function te(e){return function(){return new ne(e.apply(this,arguments))}}function ne(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof f;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}ne.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},ne.prototype.next=function(e){return this._invoke(`next`,e)},ne.prototype.throw=function(e){return this._invoke(`throw`,e)},ne.prototype.return=function(e){return this._invoke(`return`,e)};var re={timeoutInSeconds:60},ie=`memory`,ae={name:`auth0-spa-js`,version:`2.18.3`},oe=()=>Date.now(),S=`default`,C=class e extends Error{constructor(t,n){super(n),this.error=t,this.error_description=n,Object.setPrototypeOf(this,e.prototype)}static fromPayload(t){let{error:n,error_description:r}=t;return new e(n,r)}},se=class e extends C{constructor(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;super(t,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,e.prototype)}},ce=class e extends C{constructor(t,n,r,i){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null;super(t,n),this.connection=r,this.state=i,this.appState=a,Object.setPrototypeOf(this,e.prototype)}},le=class e extends C{constructor(){super(`timeout`,`Timeout`),Object.setPrototypeOf(this,e.prototype)}},ue=class e extends le{constructor(t){super(),this.popup=t,Object.setPrototypeOf(this,e.prototype)}},de=class e extends C{constructor(t){super(`cancelled`,`Popup closed`),this.popup=t,Object.setPrototypeOf(this,e.prototype)}},fe=class e extends C{constructor(){super(`popup_open`,"Unable to open a popup for loginWithPopup - window.open returned `null`"),Object.setPrototypeOf(this,e.prototype)}},pe=class e extends C{constructor(t,n,r,i){super(t,n),this.mfa_token=r,this.mfa_requirements=i,Object.setPrototypeOf(this,e.prototype)}},me=class e extends C{constructor(t,n){super(`missing_refresh_token`,`Missing Refresh Token (audience: '${_e(t,[`default`])}', scope: '${_e(n)}')`),this.audience=t,this.scope=n,Object.setPrototypeOf(this,e.prototype)}},he=class e extends C{constructor(t,n){super(`missing_scopes`,`Missing requested scopes after refresh (audience: '${_e(t,[`default`])}', missing scope: '${_e(n)}')`),this.audience=t,this.scope=n,Object.setPrototypeOf(this,e.prototype)}},ge=class e extends C{constructor(t){super(`use_dpop_nonce`,`Server rejected DPoP proof: wrong nonce`),this.newDpopNonce=t,Object.setPrototypeOf(this,e.prototype)}};function _e(e){return e&&!(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).includes(e)?e:``}var ve=[`clientId`],ye=()=>window.crypto,be=()=>{let e=``;for(;e.length<43;){let t=ye().getRandomValues(new Uint8Array(43-e.length));for(let n of t)e.length<43&&n<198&&(e+=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.`[n%66])}return e},xe=e=>btoa(e),Se=[{key:`name`,type:[`string`]},{key:`version`,type:[`string`,`number`]},{key:`env`,type:[`object`]}],Ce=function(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return Object.keys(e).reduce((n,r)=>{if(t&&r===`env`)return n;let i=Se.find(e=>e.key===r);return i&&i.type.includes(typeof e[r])&&(n[r]=e[r]),n},{})},we=e=>{let{clientId:t}=e,n=x(e,ve);return new URLSearchParams((e=>Object.keys(e).filter(t=>e[t]!==void 0).reduce((t,n)=>b(b({},t),{},{[n]:e[n]}),{}))(b({client_id:t},n))).toString()},Te=async e=>await ye().subtle.digest({name:`SHA-256`},new TextEncoder().encode(e)),Ee=e=>(e=>decodeURIComponent(atob(e).split(``).map(e=>`%`+(`00`+e.charCodeAt(0).toString(16)).slice(-2)).join(``)))(e.replace(/_/g,`/`).replace(/-/g,`+`)),De=e=>{let t=new Uint8Array(e);return(e=>{let t={"+":`-`,"/":`_`,"=":``};return e.replace(/[+/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(t))))},Oe=typeof globalThis<`u`?globalThis:typeof window<`u`?window:r===void 0?typeof self<`u`?self:{}:r,ke={},Ae={};Object.defineProperty(Ae,`__esModule`,{value:!0});var je=function(){function e(){var e=this;this.locked=new Map,this.addToLocked=function(t,n){var r=e.locked.get(t);r===void 0?n===void 0?e.locked.set(t,[]):e.locked.set(t,[n]):n!==void 0&&(r.unshift(n),e.locked.set(t,r))},this.isLocked=function(t){return e.locked.has(t)},this.lock=function(t){return new Promise(function(n,r){e.isLocked(t)?e.addToLocked(t,n):(e.addToLocked(t),n())})},this.unlock=function(t){var n=e.locked.get(t);if(n!==void 0&&n.length!==0){var r=n.pop();e.locked.set(t,n),r!==void 0&&setTimeout(r,0)}else e.locked.delete(t)}}return e.getInstance=function(){return e.instance===void 0&&(e.instance=new e),e.instance},e}();Ae.default=function(){return je.getInstance()};var w=Oe&&Oe.__awaiter||function(e,t,n,r){return new(n||=Promise)(function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(o,s)}c((r=r.apply(e,t||[])).next())})},T=Oe&&Oe.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw TypeError(`Generator is already executing.`);for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!((i=i.length>0&&i[i.length-1])||a[0]!==6&&a[0]!==2)){o=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(a[0]===6&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}},Me=Oe;Object.defineProperty(ke,`__esModule`,{value:!0});var Ne=Ae,Pe=`browser-tabs-lock-key`,Fe={key:function(e){return w(Me,void 0,void 0,function(){return T(this,function(e){throw Error(`Unsupported`)})})},getItem:function(e){return w(Me,void 0,void 0,function(){return T(this,function(e){throw Error(`Unsupported`)})})},clear:function(){return w(Me,void 0,void 0,function(){return T(this,function(e){return[2,window.localStorage.clear()]})})},removeItem:function(e){return w(Me,void 0,void 0,function(){return T(this,function(e){throw Error(`Unsupported`)})})},setItem:function(e,t){return w(Me,void 0,void 0,function(){return T(this,function(e){throw Error(`Unsupported`)})})},keySync:function(e){return window.localStorage.key(e)},getItemSync:function(e){return window.localStorage.getItem(e)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(e){return window.localStorage.removeItem(e)},setItemSync:function(e,t){return window.localStorage.setItem(e,t)}};function Ie(e){return new Promise(function(t){return setTimeout(t,e)})}function Le(e){for(var t=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz`,n=``,r=0;r<e;r++)n+=t[Math.floor(61*Math.random())];return n}var Re=ke.default=function(){function e(t){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+Le(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=t,e.waiters===void 0&&(e.waiters=[])}return e.prototype.acquireLock=function(t,n){return n===void 0&&(n=5e3),w(this,void 0,void 0,function(){var r,i,a,o,s,c,l;return T(this,function(u){switch(u.label){case 0:r=Date.now()+Le(4),i=Date.now()+n,a=Pe+`-`+t,o=this.storageHandler===void 0?Fe:this.storageHandler,u.label=1;case 1:return Date.now()<i?[4,Ie(30)]:[3,8];case 2:return u.sent(),o.getItemSync(a)===null?(s=this.id+`-`+t+`-`+r,[4,Ie(Math.floor(25*Math.random()))]):[3,5];case 3:return u.sent(),o.setItemSync(a,JSON.stringify({id:this.id,iat:r,timeoutKey:s,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,Ie(30)];case 4:return u.sent(),(c=o.getItemSync(a))!==null&&(l=JSON.parse(c)).id===this.id&&l.iat===r?(this.acquiredIatSet.add(r),this.refreshLockWhileAcquired(a,r),[2,!0]):[3,7];case 5:return e.lockCorrector(this.storageHandler===void 0?Fe:this.storageHandler),[4,this.waitForSomethingToChange(i)];case 6:u.sent(),u.label=7;case 7:return r=Date.now()+Le(4),[3,1];case 8:return[2,!1]}})})},e.prototype.refreshLockWhileAcquired=function(e,t){return w(this,void 0,void 0,function(){var n=this;return T(this,function(r){return setTimeout(function(){return w(n,void 0,void 0,function(){var n,r,i;return T(this,function(a){switch(a.label){case 0:return[4,Ne.default().lock(t)];case 1:return a.sent(),this.acquiredIatSet.has(t)?(n=this.storageHandler===void 0?Fe:this.storageHandler,(r=n.getItemSync(e))===null?(Ne.default().unlock(t),[2]):((i=JSON.parse(r)).timeRefreshed=Date.now(),n.setItemSync(e,JSON.stringify(i)),Ne.default().unlock(t),this.refreshLockWhileAcquired(e,t),[2])):(Ne.default().unlock(t),[2])}})})},1e3),[2]})})},e.prototype.waitForSomethingToChange=function(t){return w(this,void 0,void 0,function(){return T(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){var r=!1,i=Date.now(),a=!1;function o(){if(a||=(window.removeEventListener(`storage`,o),e.removeFromWaiting(o),clearTimeout(s),!0),!r){r=!0;var t=50-(Date.now()-i);t>0?setTimeout(n,t):n(null)}}window.addEventListener(`storage`,o),e.addToWaiting(o);var s=setTimeout(o,Math.max(0,t-Date.now()))})];case 1:return n.sent(),[2]}})})},e.addToWaiting=function(t){this.removeFromWaiting(t),e.waiters!==void 0&&e.waiters.push(t)},e.removeFromWaiting=function(t){e.waiters!==void 0&&(e.waiters=e.waiters.filter(function(e){return e!==t}))},e.notifyWaiters=function(){e.waiters!==void 0&&e.waiters.slice().forEach(function(e){return e()})},e.prototype.releaseLock=function(e){return w(this,void 0,void 0,function(){return T(this,function(t){switch(t.label){case 0:return[4,this.releaseLock__private__(e)];case 1:return[2,t.sent()]}})})},e.prototype.releaseLock__private__=function(t){return w(this,void 0,void 0,function(){var n,r,i,a;return T(this,function(o){switch(o.label){case 0:return n=this.storageHandler===void 0?Fe:this.storageHandler,r=Pe+`-`+t,(i=n.getItemSync(r))===null?[2]:(a=JSON.parse(i)).id===this.id?[4,Ne.default().lock(a.iat)]:[3,2];case 1:o.sent(),this.acquiredIatSet.delete(a.iat),n.removeItemSync(r),Ne.default().unlock(a.iat),e.notifyWaiters(),o.label=2;case 2:return[2]}})})},e.lockCorrector=function(t){for(var n=Date.now()-5e3,r=t,i=[],a=0;;){var o=r.keySync(a);if(o===null)break;i.push(o),a++}for(var s=!1,c=0;c<i.length;c++){var l=i[c];if(l.includes(Pe)){var u=r.getItemSync(l);if(u!==null){var d=JSON.parse(u);(d.timeRefreshed===void 0&&d.timeAcquired<n||d.timeRefreshed!==void 0&&d.timeRefreshed<n)&&(r.removeItemSync(l),s=!0)}}}s&&e.notifyWaiters()},e.waiters=void 0,e}(),ze=class{async runWithLock(e,t,n){let r=new AbortController,i=setTimeout(()=>r.abort(),t);try{return await navigator.locks.request(e,{mode:`exclusive`,signal:r.signal},async e=>{if(clearTimeout(i),!e)throw Error(`Lock not available`);return await n()})}catch(e){throw clearTimeout(i),e?.name===`AbortError`?new le:e}}},Be=class{constructor(){y(this,`lock`,void 0),y(this,`activeLocks`,new Set),y(this,`pagehideHandler`,void 0),this.lock=new Re,this.pagehideHandler=()=>{this.activeLocks.forEach(e=>this.lock.releaseLock(e)),this.activeLocks.clear()}}async runWithLock(e,t,n){let r=!1;for(let n=0;n<10&&!r;n++)r=await this.lock.acquireLock(e,t);if(!r)throw new le;this.activeLocks.add(e),this.activeLocks.size===1&&typeof window<`u`&&window.addEventListener(`pagehide`,this.pagehideHandler);try{return await n()}finally{this.activeLocks.delete(e),await this.lock.releaseLock(e),this.activeLocks.size===0&&typeof window<`u`&&window.removeEventListener(`pagehide`,this.pagehideHandler)}}};function Ve(){return typeof navigator<`u`&&typeof(e=navigator.locks)?.request==`function`?new ze:new Be;var e}var He=null,Ue=new TextEncoder,We=new TextDecoder;function Ge(e){return typeof e==`string`?Ue.encode(e):We.decode(e)}function Ke(e){if(typeof e.modulusLength!=`number`||e.modulusLength<2048)throw new Ze(`${e.name} modulusLength must be at least 2048 bits`)}async function qe(e,t,n){if(!1===n.usages.includes(`sign`))throw TypeError(`private CryptoKey instances used for signing assertions must include "sign" in their "usages"`);let r=`${Ye(Ge(JSON.stringify(e)))}.${Ye(Ge(JSON.stringify(t)))}`;return`${r}.${Ye(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case`ECDSA`:return{name:e.algorithm.name,hash:`SHA-256`};case`RSA-PSS`:return Ke(e.algorithm),{name:e.algorithm.name,saltLength:32};case`RSASSA-PKCS1-v1_5`:return Ke(e.algorithm),{name:e.algorithm.name};case`Ed25519`:return{name:e.algorithm.name}}throw new Xe}(n),n,Ge(r)))}`}var Je;if(Uint8Array.prototype.toBase64)Je=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:`base64url`,omitPadding:!0}));else{let e=32768;Je=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=e)n.push(String.fromCharCode.apply(null,t.subarray(r,r+e)));return btoa(n.join(``)).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}}function Ye(e){return Je(e)}var Xe=class extends Error{constructor(e){var t;super(e??`operation not supported`),this.name=this.constructor.name,(t=Error.captureStackTrace)==null||t.call(Error,this,this.constructor)}},Ze=class extends Error{constructor(e){var t;super(e),this.name=this.constructor.name,(t=Error.captureStackTrace)==null||t.call(Error,this,this.constructor)}};function Qe(e){switch(e.algorithm.name){case`RSA-PSS`:return function(e){if(e.algorithm.hash.name===`SHA-256`)return`PS256`;throw new Xe(`unsupported RsaHashedKeyAlgorithm hash name`)}(e);case`RSASSA-PKCS1-v1_5`:return function(e){if(e.algorithm.hash.name===`SHA-256`)return`RS256`;throw new Xe(`unsupported RsaHashedKeyAlgorithm hash name`)}(e);case`ECDSA`:return function(e){if(e.algorithm.namedCurve===`P-256`)return`ES256`;throw new Xe(`unsupported EcKeyAlgorithm namedCurve`)}(e);case`Ed25519`:return`Ed25519`;default:throw new Xe(`unsupported CryptoKey algorithm name`)}}function $e(e){return e instanceof CryptoKey}function et(e){return $e(e)&&e.type===`public`}async function tt(e,t,n,r,i,a){let o=e?.privateKey,s=e?.publicKey;if(!$e(c=o)||c.type!==`private`)throw TypeError(`"keypair.privateKey" must be a private CryptoKey`);var c;if(!et(s))throw TypeError(`"keypair.publicKey" must be a public CryptoKey`);if(!0!==s.extractable)throw TypeError(`"keypair.publicKey.extractable" must be true`);if(typeof t!=`string`)throw TypeError(`"htu" must be a string`);if(typeof n!=`string`)throw TypeError(`"htm" must be a string`);if(r!==void 0&&typeof r!=`string`)throw TypeError(`"nonce" must be a string or undefined`);if(i!==void 0&&typeof i!=`string`)throw TypeError(`"accessToken" must be a string or undefined`);if(a!==void 0&&(typeof a!=`object`||!a||Array.isArray(a)))throw TypeError(`"additional" must be an object`);return qe({alg:Qe(o),typ:`dpop+jwt`,jwk:await nt(s)},Object.assign(Object.assign({},a),{iat:Math.floor(Date.now()/1e3),jti:crypto.randomUUID(),htm:n,nonce:r,htu:t,ath:i?Ye(await crypto.subtle.digest(`SHA-256`,Ge(i))):void 0}),o)}async function nt(e){let{kty:t,e:n,n:r,x:i,y:a,crv:o}=await crypto.subtle.exportKey(`jwk`,e);return{kty:t,crv:o,e:n,n:r,x:i,y:a}}var rt=`dpop-nonce`,it=[`authorization_code`,`refresh_token`,`urn:ietf:params:oauth:grant-type:token-exchange`,`http://auth0.com/oauth/grant-type/mfa-oob`,`http://auth0.com/oauth/grant-type/mfa-otp`,`http://auth0.com/oauth/grant-type/mfa-recovery-code`];function at(){return async function(e,t){var n;let r;if(typeof e!=`string`||e.length===0)throw TypeError(`"alg" must be a non-empty string`);switch(e){case`PS256`:r={name:`RSA-PSS`,hash:`SHA-256`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case`RS256`:r={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case`ES256`:r={name:`ECDSA`,namedCurve:`P-256`};break;case`Ed25519`:r={name:`Ed25519`};break;default:throw new Xe}return crypto.subtle.generateKey(r,(n=t?.extractable)!=null&&n,[`sign`,`verify`])}(`ES256`,{extractable:!1})}function ot(e){return async function(e){if(!et(e))throw TypeError(`"publicKey" must be a public CryptoKey`);if(!0!==e.extractable)throw TypeError(`"publicKey.extractable" must be true`);let t=await nt(e),n;switch(t.kty){case`EC`:n={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case`OKP`:n={crv:t.crv,kty:t.kty,x:t.x};break;case`RSA`:n={e:t.e,kty:t.kty,n:t.n};break;default:throw new Xe(`unsupported JWK kty`)}return Ye(await crypto.subtle.digest({name:`SHA-256`},Ge(JSON.stringify(n))))}(e.publicKey)}function st(e){let{keyPair:t,url:n,method:r,nonce:i,accessToken:a}=e;return tt(t,function(e){let t=new URL(e);return t.search=``,t.hash=``,t.href}(n),r,i,a)}var ct=[`error`,`error_description`],lt=async(e,t)=>{let n=await fetch(e,t);return{ok:n.ok,json:await n.json(),headers:(r=n.headers,[...r].reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{}))};var r},ut=async(e,t,n)=>{let r=new AbortController,i;return t.signal=r.signal,Promise.race([lt(e,t),new Promise((e,t)=>{i=setTimeout(()=>{r.abort(),t(Error(`Timeout when executing 'fetch'`))},n)})]).finally(()=>{clearTimeout(i)})},dt=async(e,t,n,r,i,a,o,s)=>((e,t)=>new Promise(function(n,r){let i=new MessageChannel;i.port1.onmessage=function(e){e.data.error?r(Error(e.data.error)):n(e.data),i.port1.close()},t.postMessage(e,[i.port2])}))({auth:{audience:t,scope:n},timeout:i,fetchUrl:e,fetchOptions:r,useFormData:o,useMrrt:s},a),ft=async function(e,t,n,r,i,a){let o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:1e4;return i?dt(e,t,n,r,o,i,a,arguments.length>7?arguments[7]:void 0):ut(e,r,o)};async function pt(e,t,n,r,i,a,o,s,c,l){if(c){let t=await c.generateProof({url:e,method:i.method||`GET`,nonce:await c.getNonce()});i.headers=b(b({},i.headers),{},{dpop:t})}let u,d=null;for(let c=0;c<3;c++)try{u=await ft(e,n,r,i,a,o,t,s),d=null;break}catch(e){d=e}if(d)throw d;let{json:{error:f,error_description:p},headers:m,ok:h}=u,g=x(u.json,ct),_;if(c&&(_=m[rt],_&&await c.setNonce(_)),!h){let u=p||`HTTP error. Unable to fetch ${e}`;if(f===`mfa_required`)throw new pe(f,u,g.mfa_token,g.mfa_requirements);if(f===`missing_refresh_token`)throw new me(n,r);if(f===`use_dpop_nonce`){if(!c||!_||l)throw new ge(_);return pt(e,t,n,r,i,a,o,s,c,!0)}throw new C(f||`request_error`,u)}return g}var mt=[`baseUrl`,`timeout`,`audience`,`scope`,`auth0Client`,`useFormData`,`useMrrt`,`dpop`];async function ht(e,t){let{baseUrl:n,timeout:r,audience:i,scope:a,auth0Client:o,useFormData:s,useMrrt:c,dpop:l}=e,u=x(e,mt),d=u.grant_type===`urn:ietf:params:oauth:grant-type:token-exchange`,f=u.grant_type===`refresh_token`&&c,p=b(b(b(b({},u),d&&i&&{audience:i}),d&&a&&{scope:a}),f&&{audience:i,scope:a}),m=s?we(p):JSON.stringify(p),h=(g=u.grant_type,it.includes(g));var g;return await pt(`${n}/oauth/token`,r,i||S,a,{method:`POST`,body:m,headers:{"Content-Type":s?`application/x-www-form-urlencoded`:`application/json`,"Auth0-Client":btoa(JSON.stringify(Ce(o||ae)))}},t,s,c,h?l:void 0)}var gt=function(){return(e=[...arguments].filter(Boolean).join(` `).trim().split(/\s+/),Array.from(new Set(e))).join(` `);var e},_t=(e,t,n)=>{let r;return n&&(r=e[n]),r||=e[S],gt(r,t)},vt=`@@auth0spajs@@`,yt=`@@user@@`,bt=class e{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vt,n=arguments.length>2?arguments[2]:void 0;this.prefix=t,this.suffix=n,y(this,`clientId`,void 0),y(this,`scope`,void 0),y(this,`audience`,void 0),this.clientId=e.clientId,this.scope=e.scope,this.audience=e.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join(`::`)}static fromKey(t){let[n,r,i,a]=t.split(`::`);return new e({clientId:r,scope:a,audience:i},n)}static fromCacheEntry(t){let{scope:n,audience:r,client_id:i}=t;return new e({scope:n,audience:r,clientId:i})}},xt=class{set(e,t){localStorage.setItem(e,JSON.stringify(t))}get(e){let t=window.localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch{return}}remove(e){localStorage.removeItem(e)}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith(vt))}},St=class{constructor(){y(this,`enclosedCache`,function(){let e={};return{set(t,n){e[t]=n},get(t){let n=e[t];if(n)return n},remove(t){delete e[t]},allKeys:()=>Object.keys(e)}}())}},Ct=class{constructor(e,t,n){this.cache=e,this.keyManifest=t,y(this,`nowProvider`,void 0),this.nowProvider=n||oe}async setIdToken(e,t,n){let r=this.getIdTokenCacheKey(e);await this.cache.set(r,{id_token:t,decodedToken:n}),await this.keyManifest?.add(r)}async getIdToken(e){let t=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!t&&e.scope&&e.audience){let t=await this.get(e);return!t||!t.id_token||!t.decodedToken?void 0:{id_token:t.id_token,decodedToken:t.decodedToken}}if(t)return{id_token:t.id_token,decodedToken:t.decodedToken}}async get(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=arguments.length>3?arguments[3]:void 0,i=await this.cache.get(e.toKey());if(!i){let t=await this.getCacheKeys();if(!t)return;let a=this.matchExistingCacheKey(e,t);if(a&&(i=await this.cache.get(a)),!i&&n&&r!==`cache-only`)return this.getEntryWithRefreshToken(e,t)}if(!i)return;let a=await this.nowProvider(),o=Math.floor(a/1e3);return i.expiresAt-t<o?i.body.refresh_token?this.modifiedCachedEntry(i,e):(await this.cache.remove(e.toKey()),void await this.keyManifest?.remove(e.toKey())):i.body}async modifiedCachedEntry(e,t){return e.body={refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope},await this.cache.set(t.toKey(),e),{refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope}}async set(e){let t=new bt({clientId:e.client_id,scope:e.scope,audience:e.audience}),n=await this.wrapCacheEntry(e);await this.cache.set(t.toKey(),n),await this.keyManifest?.add(t.toKey())}async remove(e,t,n){let r=new bt({clientId:e,scope:n,audience:t});await this.cache.remove(r.toKey())}async clear(e){let t=await this.getCacheKeys();t&&(await t.filter(t=>!e||t.includes(e)).reduce(async(e,t)=>{await e,await this.cache.remove(t)},Promise.resolve()),await this.keyManifest?.clear())}async wrapCacheEntry(e){let t=await this.nowProvider();return{body:e,expiresAt:Math.floor(t/1e3)+e.expires_in}}async getCacheKeys(){return this.keyManifest?(await this.keyManifest.get())?.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new bt({clientId:e},vt,yt).toKey()}matchExistingCacheKey(e,t){return t.filter(t=>{let n=bt.fromKey(t),r=new Set(n.scope&&n.scope.split(` `)),i=e.scope?.split(` `)||[],a=n.scope&&i.reduce((e,t)=>e&&r.has(t),!0);return n.prefix===vt&&n.clientId===e.clientId&&n.audience===e.audience&&a})[0]}async getEntryWithRefreshToken(e,t){for(let r of t){let t=bt.fromKey(r);if(t.prefix===vt&&t.clientId===e.clientId){var n;let t=await this.cache.get(r);if(t!=null&&(n=t.body)!=null&&n.refresh_token)return this.modifiedCachedEntry(t,e)}}}async updateEntry(e,t){let n=await this.getCacheKeys();if(n)for(let i of n){var r;let n=await this.cache.get(i);(n==null||(r=n.body)==null?void 0:r.refresh_token)===e&&(n.body.refresh_token=t,await this.cache.set(i,n))}}},wt=class{constructor(e,t,n){this.storage=e,this.clientId=t,this.cookieDomain=n,y(this,`storageKey`,void 0),this.storageKey=`a0.spajs.txs.${this.clientId}`}create(e){this.storage.save(this.storageKey,e,{daysUntilExpire:1,cookieDomain:this.cookieDomain})}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain})}},Tt=e=>typeof e==`number`,Et=`iss.aud.exp.nbf.iat.jti.azp.nonce.auth_time.at_hash.c_hash.acr.amr.sub_jwk.cnf.sip_from_tag.sip_date.sip_callid.sip_cseq_num.sip_via_branch.orig.dest.mky.events.toe.txn.rph.sid.vot.vtm`.split(`.`),Dt=e=>{if(!e.id_token)throw Error(`ID token is required but missing`);let t=(e=>{let t=e.split(`.`),[n,r,i]=t;if(t.length!==3||!n||!r||!i)throw Error(`ID token could not be decoded`);let a=JSON.parse(Ee(r)),o={__raw:e},s={};return Object.keys(a).forEach(e=>{o[e]=a[e],Et.includes(e)||(s[e]=a[e])}),{encoded:{header:n,payload:r,signature:i},header:JSON.parse(Ee(n)),claims:o,user:s}})(e.id_token);if(!t.claims.iss)throw Error(`Issuer (iss) claim must be a string present in the ID token`);if(t.claims.iss!==e.iss)throw Error(`Issuer (iss) claim mismatch in the ID token; expected "${e.iss}", found "${t.claims.iss}"`);if(!t.user.sub)throw Error(`Subject (sub) claim must be a string present in the ID token`);if(t.header.alg!==`RS256`)throw Error(`Signature algorithm of "${t.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);if(!t.claims.aud||typeof t.claims.aud!=`string`&&!Array.isArray(t.claims.aud))throw Error(`Audience (aud) claim must be a string or array of strings present in the ID token`);if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e.aud))throw Error(`Audience (aud) claim mismatch in the ID token; expected "${e.aud}" but was not one of "${t.claims.aud.join(`, `)}"`);if(t.claims.aud.length>1){if(!t.claims.azp)throw Error(`Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values`);if(t.claims.azp!==e.aud)throw Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${e.aud}", found "${t.claims.azp}"`)}}else if(t.claims.aud!==e.aud)throw Error(`Audience (aud) claim mismatch in the ID token; expected "${e.aud}" but found "${t.claims.aud}"`);if(e.nonce){if(!t.claims.nonce)throw Error(`Nonce (nonce) claim must be a string present in the ID token`);if(t.claims.nonce!==e.nonce)throw Error(`Nonce (nonce) claim mismatch in the ID token; expected "${e.nonce}", found "${t.claims.nonce}"`)}if(e.max_age&&!Tt(t.claims.auth_time))throw Error(`Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified`);if(t.claims.exp==null||!Tt(t.claims.exp))throw Error(`Expiration Time (exp) claim must be a number present in the ID token`);if(!Tt(t.claims.iat))throw Error(`Issued At (iat) claim must be a number present in the ID token`);let n=e.leeway||60,r=new Date(e.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(t.claims.exp+n),r>i)throw Error(`Expiration Time (exp) claim error in the ID token; current time (${r}) is after expiration time (${i})`);if(t.claims.nbf!=null&&Tt(t.claims.nbf)){let e=new Date(0);if(e.setUTCSeconds(t.claims.nbf-n),r<e)throw Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${r}) is before ${e}`)}if(t.claims.auth_time!=null&&Tt(t.claims.auth_time)){let i=new Date(0);if(i.setUTCSeconds(parseInt(t.claims.auth_time)+e.max_age+n),r>i)throw Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${r}) is after last auth at ${i}`)}if(e.organization){let n=e.organization.trim();if(n.startsWith(`org_`)){let e=n;if(!t.claims.org_id)throw Error(`Organization ID (org_id) claim must be a string present in the ID token`);if(e!==t.claims.org_id)throw Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${e}", found "${t.claims.org_id}"`)}else{let e=n.toLowerCase();if(!t.claims.org_name)throw Error(`Organization Name (org_name) claim must be a string present in the ID token`);if(e!==t.claims.org_name)throw Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${e}", found "${t.claims.org_name}"`)}}return t},Ot=Oe&&Oe.__assign||function(){return Ot=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ot.apply(this,arguments)};function kt(e,t){if(!t)return``;var n=`; `+e;return!0===t?n:n+`=`+t}function At(e,t,n){return encodeURIComponent(e).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,`%28`).replace(/\)/g,`%29`)+`=`+encodeURIComponent(t).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(e){if(typeof e.expires==`number`){var t=new Date;t.setMilliseconds(t.getMilliseconds()+864e5*e.expires),e.expires=t}return kt(`Expires`,e.expires?e.expires.toUTCString():``)+kt(`Domain`,e.domain)+kt(`Path`,e.path)+kt(`Secure`,e.secure)+kt(`SameSite`,e.sameSite)}(n)}function jt(){return function(e){for(var t={},n=e?e.split(`; `):[],r=/(%[\dA-F]{2})+/gi,i=0;i<n.length;i++){var a=n[i].split(`=`),o=a.slice(1).join(`=`);o.charAt(0)===`"`&&(o=o.slice(1,-1));try{t[a[0].replace(r,decodeURIComponent)]=o.replace(r,decodeURIComponent)}catch{}}return t}(document.cookie)}var Mt=function(e){return jt()[e]};function Nt(e,t,n){document.cookie=At(e,t,Ot({path:`/`},n))}var Pt=Nt,Ft=function(e,t){Nt(e,``,Ot(Ot({},t),{expires:-1}))},It={get(e){let t=Mt(e);if(t!==void 0)return JSON.parse(t)},save(e,t,n){let r={};window.location.protocol===`https:`&&(r={secure:!0,sameSite:`none`}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Pt(e,JSON.stringify(t),r)},remove(e,t){let n={};t!=null&&t.cookieDomain&&(n.domain=t.cookieDomain),Ft(e,n)}},Lt=`_legacy_`,Rt={get(e){return It.get(e)||It.get(`${Lt}${e}`)},save(e,t,n){let r={};window.location.protocol===`https:`&&(r={secure:!0}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Pt(`${Lt}${e}`,JSON.stringify(t),r),It.save(e,t,n)},remove(e,t){let n={};t!=null&&t.cookieDomain&&(n.domain=t.cookieDomain),Ft(e,n),It.remove(e,t),It.remove(`${Lt}${e}`,t)}},zt={get(e){if(typeof sessionStorage>`u`)return;let t=sessionStorage.getItem(e);return t==null?void 0:JSON.parse(t)},save(e,t){sessionStorage.setItem(e,JSON.stringify(t))},remove(e){sessionStorage.removeItem(e)}},Bt=function(e){return e.Code=`code`,e.ConnectCode=`connect_code`,e}({});function Vt(e,t,n){var r=t===void 0?null:t,i=function(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),i=0,a=n.length;i<a;++i)r[i]=n.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}(e,n!==void 0&&n),a=i.indexOf(`
`,10)+1,o=i.substring(a)+(r?`//# sourceMappingURL=`+r:``),s=new Blob([o],{type:`application/javascript`});return URL.createObjectURL(s)}var Ht,Ut,Wt,Gt,Kt=(Ht=`Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7ZnVuY3Rpb24gZShlLHIsdCl7cmV0dXJuKHI9ZnVuY3Rpb24oZSl7dmFyIHI9ZnVuY3Rpb24oZSxyKXtpZigib2JqZWN0IiE9dHlwZW9mIGV8fCFlKXJldHVybiBlO3ZhciB0PWVbU3ltYm9sLnRvUHJpbWl0aXZlXTtpZih2b2lkIDAhPT10KXt2YXIgbj10LmNhbGwoZSxyfHwiZGVmYXVsdCIpO2lmKCJvYmplY3QiIT10eXBlb2YgbilyZXR1cm4gbjt0aHJvdyBuZXcgVHlwZUVycm9yKCJAQHRvUHJpbWl0aXZlIG11c3QgcmV0dXJuIGEgcHJpbWl0aXZlIHZhbHVlLiIpfXJldHVybigic3RyaW5nIj09PXI/U3RyaW5nOk51bWJlcikoZSl9KGUsInN0cmluZyIpO3JldHVybiJzeW1ib2wiPT10eXBlb2Ygcj9yOnIrIiJ9KHIpKWluIGU/T2JqZWN0LmRlZmluZVByb3BlcnR5KGUscix7dmFsdWU6dCxlbnVtZXJhYmxlOiEwLGNvbmZpZ3VyYWJsZTohMCx3cml0YWJsZTohMH0pOmVbcl09dCxlfWZ1bmN0aW9uIHIoZSxyKXt2YXIgdD1PYmplY3Qua2V5cyhlKTtpZihPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbj1PYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpO3ImJihuPW4uZmlsdGVyKGZ1bmN0aW9uKHIpe3JldHVybiBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKGUscikuZW51bWVyYWJsZX0pKSx0LnB1c2guYXBwbHkodCxuKX1yZXR1cm4gdH1mdW5jdGlvbiB0KHQpe2Zvcih2YXIgbj0xO248YXJndW1lbnRzLmxlbmd0aDtuKyspe3ZhciBvPW51bGwhPWFyZ3VtZW50c1tuXT9hcmd1bWVudHNbbl06e307biUyP3IoT2JqZWN0KG8pLCEwKS5mb3JFYWNoKGZ1bmN0aW9uKHIpe2UodCxyLG9bcl0pfSk6T2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcnM/T2JqZWN0LmRlZmluZVByb3BlcnRpZXModCxPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9ycyhvKSk6cihPYmplY3QobykpLmZvckVhY2goZnVuY3Rpb24oZSl7T2JqZWN0LmRlZmluZVByb3BlcnR5KHQsZSxPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKG8sZSkpfSl9cmV0dXJuIHR9Y2xhc3MgbiBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKGUscil7c3VwZXIociksdGhpcy5lcnJvcj1lLHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxuLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKGUpe2xldHtlcnJvcjpyLGVycm9yX2Rlc2NyaXB0aW9uOnR9PWU7cmV0dXJuIG5ldyBuKHIsdCl9fWNsYXNzIG8gZXh0ZW5kcyBue2NvbnN0cnVjdG9yKGUscil7c3VwZXIoIm1pc3NpbmdfcmVmcmVzaF90b2tlbiIsIk1pc3NpbmcgUmVmcmVzaCBUb2tlbiAoYXVkaWVuY2U6ICciLmNvbmNhdChzKGUsWyJkZWZhdWx0Il0pLCInLCBzY29wZTogJyIpLmNvbmNhdChzKHIpLCInKSIpKSx0aGlzLmF1ZGllbmNlPWUsdGhpcy5zY29wZT1yLE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLG8ucHJvdG90eXBlKX19ZnVuY3Rpb24gcyhlKXtyZXR1cm4gZSYmIShhcmd1bWVudHMubGVuZ3RoPjEmJnZvaWQgMCE9PWFyZ3VtZW50c1sxXT9hcmd1bWVudHNbMV06W10pLmluY2x1ZGVzKGUpP2U6IiJ9Y29uc3QgaT1bImNsaWVudElkIl0sYz1lPT57bGV0e2NsaWVudElkOnJ9PWUsbj1mdW5jdGlvbihlLHIpe2lmKG51bGw9PWUpcmV0dXJue307dmFyIHQsbixvPWZ1bmN0aW9uKGUscil7aWYobnVsbD09ZSlyZXR1cm57fTt2YXIgdD17fTtmb3IodmFyIG4gaW4gZSlpZih7fS5oYXNPd25Qcm9wZXJ0eS5jYWxsKGUsbikpe2lmKC0xIT09ci5pbmRleE9mKG4pKWNvbnRpbnVlO3Rbbl09ZVtuXX1yZXR1cm4gdH0oZSxyKTtpZihPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgcz1PYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpO2ZvcihuPTA7bjxzLmxlbmd0aDtuKyspdD1zW25dLC0xPT09ci5pbmRleE9mKHQpJiZ7fS5wcm9wZXJ0eUlzRW51bWVyYWJsZS5jYWxsKGUsdCkmJihvW3RdPWVbdF0pfXJldHVybiBvfShlLGkpO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIocj0+dm9pZCAwIT09ZVtyXSkucmVkdWNlKChyLG4pPT50KHQoe30scikse30se1tuXTplW25dfSkse30pKSh0KHtjbGllbnRfaWQ6cn0sbikpKS50b1N0cmluZygpfTtsZXQgYT17fSxsPW51bGw7Y29uc3QgdT0oZSxyKT0+IiIuY29uY2F0KGUsInwiKS5jb25jYXQociksZj1hc3luYyBlPT57bGV0IHIsbix7ZGF0YTp7dGltZW91dDpzLGF1dGg6aSxmZXRjaFVybDpsLGZldGNoT3B0aW9uczpmLHVzZUZvcm1EYXRhOnAsdXNlTXJydDpofSxwb3J0czpbZF19PWUseT17fTtjb25zdHthdWRpZW5jZTpiLHNjb3BlOk99PWl8fHt9O3RyeXtjb25zdCBlPXA/KGU9Pntjb25zdCByPW5ldyBVUkxTZWFyY2hQYXJhbXMoZSksdD17fTtyZXR1cm4gci5mb3JFYWNoKChlLHIpPT57dFtyXT1lfSksdH0pKGYuYm9keSk6SlNPTi5wYXJzZShmLmJvZHkpO2lmKCFlLnJlZnJlc2hfdG9rZW4mJiJyZWZyZXNoX3Rva2VuIj09PWUuZ3JhbnRfdHlwZSl7aWYobj0oKGUscik9PmFbdShlLHIpXSkoYixPKSwhbiYmaCl7Y29uc3QgZT1hLmxhdGVzdF9yZWZyZXNoX3Rva2VuLHI9KChlLHIpPT57Y29uc3QgdD1PYmplY3Qua2V5cyhhKS5maW5kKHQ9PntpZigibGF0ZXN0X3JlZnJlc2hfdG9rZW4iIT09dCl7Y29uc3Qgbj0oKGUscik9PnIuc3RhcnRzV2l0aCgiIi5jb25jYXQoZSwifCIpKSkocix0KSxvPXQuc3BsaXQoInwiKVsxXS5zcGxpdCgiICIpLHM9ZS5zcGxpdCgiICIpLmV2ZXJ5KGU9Pm8uaW5jbHVkZXMoZSkpO3JldHVybiBuJiZzfX0pO3JldHVybiEhdH0pKE8sYik7ZSYmIXImJihuPWUpfWlmKCFuKXRocm93IG5ldyBvKGIsTyk7Zi5ib2R5PXA/Yyh0KHQoe30sZSkse30se3JlZnJlc2hfdG9rZW46bn0pKTpKU09OLnN0cmluZ2lmeSh0KHQoe30sZSkse30se3JlZnJlc2hfdG9rZW46bn0pKX1sZXQgaSx2OyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihpPW5ldyBBYm9ydENvbnRyb2xsZXIsZi5zaWduYWw9aS5zaWduYWwpO3RyeXt2PWF3YWl0IFByb21pc2UucmFjZShbKGo9cyxuZXcgUHJvbWlzZShlPT5zZXRUaW1lb3V0KGUsaikpKSxmZXRjaChsLHQoe30sZikpXSl9Y2F0Y2goZSl7cmV0dXJuIHZvaWQgZC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZS5tZXNzYWdlfSl9aWYoIXYpcmV0dXJuIGkmJmkuYWJvcnQoKSx2b2lkIGQucG9zdE1lc3NhZ2Uoe2Vycm9yOiJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCcifSk7dz12LmhlYWRlcnMseT1bLi4ud10ucmVkdWNlKChlLHIpPT57bGV0W3Qsbl09cjtyZXR1cm4gZVt0XT1uLGV9LHt9KSxyPWF3YWl0IHYuanNvbigpLHIucmVmcmVzaF90b2tlbj8oaCYmKGEubGF0ZXN0X3JlZnJlc2hfdG9rZW49ci5yZWZyZXNoX3Rva2VuLGc9bixtPXIucmVmcmVzaF90b2tlbixPYmplY3QuZW50cmllcyhhKS5mb3JFYWNoKGU9PntsZXRbcix0XT1lO3Q9PT1nJiYoYVtyXT1tKX0pKSwoKGUscix0KT0+e2FbdShyLHQpXT1lfSkoci5yZWZyZXNoX3Rva2VuLGIsTyksZGVsZXRlIHIucmVmcmVzaF90b2tlbik6KChlLHIpPT57ZGVsZXRlIGFbdShlLHIpXX0pKGIsTyksZC5wb3N0TWVzc2FnZSh7b2s6di5vayxqc29uOnIsaGVhZGVyczp5fSl9Y2F0Y2goZSl7ZC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9LGhlYWRlcnM6eX0pfXZhciBnLG0sdyxqfTthZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixlPT57Y29uc3R7ZGF0YTpyLHBvcnRzOnR9PWUsW25dPXQ7aWYoInR5cGUiaW4gciYmImluaXQiPT09ci50eXBlKXtpZihudWxsPT09bCl0cnl7bmV3IFVSTChyLmFsbG93ZWRCYXNlVXJsKSxsPXIuYWxsb3dlZEJhc2VVcmx9Y2F0Y2goZSl7cmV0dXJufX1lbHNlImZldGNoVXJsImluIHImJihlPT57aWYoIWwpcmV0dXJuITE7dHJ5e2NvbnN0IHI9bmV3IFVSTChsKS5vcmlnaW4sdD1uZXcgVVJMKGUuZmV0Y2hVcmwpO3JldHVybiB0Lm9yaWdpbj09PXImJiIvb2F1dGgvdG9rZW4iPT09dC5wYXRobmFtZX1jYXRjaChlKXtyZXR1cm4hMX19KShyKT9mKGUpOm51bGw9PW58fG4ucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOiJpbnZhbGlkX2ZldGNoX3VybCIsZXJyb3JfZGVzY3JpcHRpb246IlVuYXV0aG9yaXplZCBmZXRjaCBVUkwifSxoZWFkZXJzOnt9fSl9KX0oKTsKCg==`,Ut=null,Wt=!1,function(e){return Gt||=Vt(Ht,Ut,Wt),new Worker(Gt,e)}),qt={},Jt=class{constructor(e,t){this.cache=e,this.clientId=t,y(this,`manifestKey`,void 0),this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(e){let t=new Set((await this.cache.get(this.manifestKey))?.keys||[]);t.add(e),await this.cache.set(this.manifestKey,{keys:[...t]})}async remove(e){let t=await this.cache.get(this.manifestKey);if(t){let n=new Set(t.keys);return n.delete(e),n.size>0?await this.cache.set(this.manifestKey,{keys:[...n]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(e){return`${vt}::${e}`}},Yt=[`openUrl`,`onRedirect`],Xt=`auth0.is.authenticated`,Zt={memory:()=>new St().enclosedCache,localstorage:()=>new xt},Qt=e=>Zt[e],$t=e=>{let{openUrl:t,onRedirect:n}=e;return b(b({},x(e,Yt)),{},{openUrl:!1===t||t?t:n})},en=(e,t)=>{let n=t?.split(` `)||[];return(e?.split(` `)||[]).every(e=>n.includes(e))},tn={NONCE:`nonce`,KEYPAIR:`keypair`},nn=class{constructor(e){y(this,`clientId`,void 0),y(this,`dbHandle`,void 0),this.clientId=e}getVersion(){return 1}createDbHandle(){let e=window.indexedDB.open(`auth0-spa-js`,this.getVersion());return new Promise((t,n)=>{e.onupgradeneeded=()=>Object.values(tn).forEach(t=>e.result.createObjectStore(t)),e.onerror=()=>n(e.error),e.onsuccess=()=>t(e.result)})}async getDbHandle(){return this.dbHandle||=await this.createDbHandle(),this.dbHandle}async executeDbRequest(e,t,n){let r=n((await this.getDbHandle()).transaction(e,t).objectStore(e));return new Promise((e,t)=>{r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)})}buildKey(e){let t=e?`_${e}`:`auth0`;return`${this.clientId}::${t}`}setNonce(e,t){return this.save(tn.NONCE,this.buildKey(t),e)}setKeyPair(e){return this.save(tn.KEYPAIR,this.buildKey(),e)}async save(e,t,n){await this.executeDbRequest(e,`readwrite`,e=>e.put(n,t))}findNonce(e){return this.find(tn.NONCE,this.buildKey(e))}findKeyPair(){return this.find(tn.KEYPAIR,this.buildKey())}find(e,t){return this.executeDbRequest(e,`readonly`,e=>e.get(t))}async deleteBy(e,t){(await this.executeDbRequest(e,`readonly`,e=>e.getAllKeys()))?.filter(t).map(t=>this.executeDbRequest(e,`readwrite`,e=>e.delete(t)))}deleteByClientId(e,t){return this.deleteBy(e,e=>typeof e==`string`&&e.startsWith(`${t}::`))}clearNonces(){return this.deleteByClientId(tn.NONCE,this.clientId)}clearKeyPairs(){return this.deleteByClientId(tn.KEYPAIR,this.clientId)}},rn=class{constructor(e){y(this,`storage`,void 0),this.storage=new nn(e)}getNonce(e){return this.storage.findNonce(e)}setNonce(e,t){return this.storage.setNonce(e,t)}async getOrGenerateKeyPair(){let e=await this.storage.findKeyPair();return e||(e=await at(),await this.storage.setKeyPair(e)),e}async generateProof(e){return st(b({keyPair:await this.getOrGenerateKeyPair()},e))}async calculateThumbprint(){return ot(await this.getOrGenerateKeyPair())}async clear(){await Promise.all([this.storage.clearNonces(),this.storage.clearKeyPairs()])}},an=function(e){return e.Bearer=`Bearer`,e.DPoP=`DPoP`,e}(an||{}),on=class{constructor(e,t){y(this,`config`,void 0),y(this,`hooks`,void 0),this.hooks=t,this.config=b(b({},e),{},{fetch:e.fetch||(typeof window>`u`?fetch:window.fetch.bind(window))})}isAbsoluteUrl(e){return/^(https?:)?\/\//i.test(e)}buildUrl(e,t){if(t){if(this.isAbsoluteUrl(t))return t;if(e)return`${e.replace(/\/?\/$/,``)}/${t.replace(/^\/+/,``)}`}throw TypeError("`url` must be absolute or `baseUrl` non-empty.")}getAccessToken(e){return this.config.getAccessToken?this.config.getAccessToken(e):this.hooks.getAccessToken(e)}extractUrl(e){return typeof e==`string`?e:e instanceof URL?e.href:e.url}buildBaseRequest(e,t){if(!this.config.baseUrl)return new Request(e,t);let n=this.buildUrl(this.config.baseUrl,this.extractUrl(e)),r=e instanceof Request?new Request(n,e):n;return new Request(r,t)}setAuthorizationHeader(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:an.Bearer;e.headers.set(`authorization`,`${n} ${t}`)}async setDpopProofHeader(e,t){if(!this.config.dpopNonceId)return;let n=await this.hooks.getDpopNonce(),r=await this.hooks.generateDpopProof({accessToken:t,method:e.method,nonce:n,url:e.url});e.headers.set(`dpop`,r)}async prepareRequest(e,t){let n=await this.getAccessToken(t),r,i;typeof n==`string`?(r=this.config.dpopNonceId?an.DPoP:an.Bearer,i=n):(r=n.token_type,i=n.access_token),this.setAuthorizationHeader(e,i,r),r===an.DPoP&&await this.setDpopProofHeader(e,i)}getHeader(e,t){return Array.isArray(e)?new Headers(e).get(t)||``:typeof e.get==`function`?e.get(t)||``:e[t]||``}hasUseDpopNonceError(e){if(e.status!==401)return!1;let t=this.getHeader(e.headers,`www-authenticate`);return t.includes(`invalid_dpop_nonce`)||t.includes(`use_dpop_nonce`)}async handleResponse(e,t){let n=this.getHeader(e.headers,rt);if(n&&await this.hooks.setDpopNonce(n),!this.hasUseDpopNonceError(e))return e;if(!n||!t.onUseDpopNonceError)throw new ge(n);return t.onUseDpopNonceError()}async internalFetchWithAuth(e,t,n,r){let i=this.buildBaseRequest(e,t);await this.prepareRequest(i,r);let a=await this.config.fetch(i);return this.handleResponse(a,n)}fetchWithAuth(e,t,n){let r={onUseDpopNonceError:()=>this.internalFetchWithAuth(e,t,b(b({},r),{},{onUseDpopNonceError:void 0}),n)};return this.internalFetchWithAuth(e,t,r,n)}},sn=class{constructor(e,t){this.myAccountFetcher=e,this.apiBase=t}async connectAccount(e){let t=await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/connect`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return this._handleResponse(t)}async completeAccount(e){let t=await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/complete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return this._handleResponse(t)}async _handleResponse(e){let t;try{t=await e.text(),t=JSON.parse(t)}catch(n){throw new cn({type:`invalid_json`,status:e.status,title:`Invalid JSON response`,detail:t||String(n)})}if(e.ok)return t;throw new cn(t)}},cn=class e extends Error{constructor(t){let{type:n,status:r,title:i,detail:a,validation_errors:o}=t;super(a),y(this,`type`,void 0),y(this,`status`,void 0),y(this,`title`,void 0),y(this,`detail`,void 0),y(this,`validation_errors`,void 0),this.name=`MyAccountApiError`,this.type=n,this.status=r,this.title=i,this.detail=a,this.validation_errors=o,Object.setPrototypeOf(this,e.prototype)}},ln={otp:{authenticatorTypes:[`otp`]},sms:{authenticatorTypes:[`oob`],oobChannels:[`sms`]},email:{authenticatorTypes:[`oob`],oobChannels:[`email`]},push:{authenticatorTypes:[`oob`],oobChannels:[`auth0`]},voice:{authenticatorTypes:[`oob`],oobChannels:[`voice`]}},un=`http://auth0.com/oauth/grant-type/mfa-otp`,dn=`http://auth0.com/oauth/grant-type/mfa-oob`,fn=`http://auth0.com/oauth/grant-type/mfa-recovery-code`,pn,mn,hn;(typeof navigator>`u`||(pn=navigator.userAgent)==null||(mn=pn.startsWith)==null||!mn.call(pn,`Mozilla/5.0 `))&&(hn=`oauth4webapi/v3.8.5`);function gn(e,t){if(e==null)return!1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch{return!1}}var E=`ERR_INVALID_ARG_VALUE`,D=`ERR_INVALID_ARG_TYPE`;function O(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}var k=Symbol(),_n=Symbol(),vn=Symbol(),A=Symbol(),yn=Symbol(),j=Symbol(),bn=new TextEncoder,xn=new TextDecoder;function Sn(e){return typeof e==`string`?bn.encode(e):xn.decode(e)}var Cn,wn;if(Uint8Array.prototype.toBase64)Cn=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:`base64url`,omitPadding:!0}));else{let e=32768;Cn=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=e)n.push(String.fromCharCode.apply(null,t.subarray(r,r+e)));return btoa(n.join(``)).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}}function Tn(e){return typeof e==`string`?wn(e):Cn(e)}wn=Uint8Array.fromBase64?e=>{try{return Uint8Array.fromBase64(e,{alphabet:`base64url`})}catch(e){throw O(`The input to be decoded is not correctly encoded.`,E,e)}}:e=>{try{let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`).replace(/\s/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch(e){throw O(`The input to be decoded is not correctly encoded.`,E,e)}};var M=class extends Error{constructor(e,t){var n;super(e,t),y(this,`code`,void 0),this.name=this.constructor.name,this.code=Sr,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},En=class extends Error{constructor(e,t){var n;super(e,t),y(this,`code`,void 0),this.name=this.constructor.name,t!=null&&t.code&&(this.code=t?.code),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};function N(e,t,n){return new En(e,{code:t,cause:n})}function Dn(e,t){if(function(e,t){if(!(e instanceof CryptoKey))throw O(`${t} must be a CryptoKey`,D)}(e,t),e.type!==`private`)throw O(`${t} must be a private CryptoKey`,E)}function On(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kn(e){gn(e,Headers)&&(e=Object.fromEntries(e.entries()));let t=new Headers(e??{});if(hn&&!t.has(`user-agent`)&&t.set(`user-agent`,hn),t.has(`authorization`))throw O(`"options.headers" must not include the "authorization" header name`,E);return t}function An(e,t){if(t!==void 0){if(typeof t==`function`&&(t=t(e.href)),!(t instanceof AbortSignal))throw O(`"options.signal" must return or be an instance of AbortSignal`,D);return t}}function jn(e){return e.includes(`//`)?e.replace(`//`,`/`):e}async function Mn(e,t){return async function(e,t,n,r){if(!(e instanceof URL))throw O(`"${t}" must be an instance of URL`,D);Un(e,!0!==r?.[k]);let i=n(new URL(e.href)),a=kn(r?.headers);return a.set(`accept`,`application/json`),(r?.[A]||fetch)(i.href,{body:void 0,headers:Object.fromEntries(a.entries()),method:`GET`,redirect:`manual`,signal:An(i,r?.signal)})}(e,`issuerIdentifier`,e=>{switch(t?.algorithm){case void 0:case`oidc`:(function(e,t){e.pathname=jn(`${e.pathname}/${t}`)})(e,`.well-known/openid-configuration`);break;case`oauth2`:(function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2];e.pathname===`/`?e.pathname=t:e.pathname=jn(`${t}/${n?e.pathname:e.pathname.replace(/(\/)$/,``)}`)})(e,`.well-known/oauth-authorization-server`);break;default:throw O(`"options.algorithm" must be "oidc" (default), or "oauth2"`,E)}return e},t)}function Nn(e,t,n,r,i){try{if(typeof e!=`number`||!Number.isFinite(e))throw O(`${n} must be a number`,D,i);if(e>0)return;if(t){if(e!==0)throw O(`${n} must be a non-negative number`,E,i);return}throw O(`${n} must be a positive number`,E,i)}catch(e){throw r?N(e.message,r,i):e}}function P(e,t,n,r){try{if(typeof e!=`string`)throw O(`${t} must be a string`,D,r);if(e.length===0)throw O(`${t} must not be empty`,E,r)}catch(e){throw n?N(e.message,n,r):e}}function Pn(e){(function(e,t){if(ir(e)!==t)throw function(e){let t=`"response" content-type must be `;var n=[...arguments].slice(1);if(n.length>2){let e=n.pop();t+=`${n.join(`, `)}, or ${e}`}else n.length===2?t+=`${n[0]} or ${n[1]}`:t+=n[0];return N(t,Tr,e)}(e,t)})(e,`application/json`)}function Fn(){return Tn(crypto.getRandomValues(new Uint8Array(32)))}function In(e){switch(e.algorithm.name){case`RSA-PSS`:return function(e){switch(e.algorithm.hash.name){case`SHA-256`:return`PS256`;case`SHA-384`:return`PS384`;case`SHA-512`:return`PS512`;default:throw new M(`unsupported RsaHashedKeyAlgorithm hash name`,{cause:e})}}(e);case`RSASSA-PKCS1-v1_5`:return function(e){switch(e.algorithm.hash.name){case`SHA-256`:return`RS256`;case`SHA-384`:return`RS384`;case`SHA-512`:return`RS512`;default:throw new M(`unsupported RsaHashedKeyAlgorithm hash name`,{cause:e})}}(e);case`ECDSA`:return function(e){switch(e.algorithm.namedCurve){case`P-256`:return`ES256`;case`P-384`:return`ES384`;case`P-521`:return`ES512`;default:throw new M(`unsupported EcKeyAlgorithm namedCurve`,{cause:e})}}(e);case`Ed25519`:case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:return e.algorithm.name;case`EdDSA`:return`Ed25519`;default:throw new M(`unsupported CryptoKey algorithm name`,{cause:e})}}function Ln(e){let t=e?.[_n];return typeof t==`number`&&Number.isFinite(t)?t:0}function Rn(e){let t=e?.[vn];return typeof t==`number`&&Number.isFinite(t)&&Math.sign(t)!==-1?t:30}function zn(){return Math.floor(Date.now()/1e3)}function F(e){if(typeof e!=`object`||!e)throw O(`"as" must be an object`,D);P(e.issuer,`"as.issuer"`)}function I(e){if(typeof e!=`object`||!e)throw O(`"client" must be an object`,D);P(e.client_id,`"client.client_id"`)}function Bn(e){return P(e,`"clientSecret"`),(t,n,r,i)=>{r.set(`client_id`,n.client_id),r.set(`client_secret`,e)}}function Vn(e,t){let{key:n,kid:r}=(i=e)instanceof CryptoKey?{key:i}:i?.key instanceof CryptoKey?(i.kid!==void 0&&P(i.kid,`"kid"`),{key:i.key,kid:i.kid}):{};var i;return Dn(n,`"clientPrivateKey.key"`),async(e,i,a,o)=>{var s;let c={alg:In(n),kid:r},l=function(e,t){let n=zn()+Ln(t);return{jti:Fn(),aud:e.issuer,exp:n+60,iat:n,nbf:n,iss:t.client_id,sub:t.client_id}}(e,i);t==null||(s=t[yn])==null||s.call(t,c,l),a.set(`client_id`,i.client_id),a.set(`client_assertion_type`,`urn:ietf:params:oauth:client-assertion-type:jwt-bearer`),a.set(`client_assertion`,await async function(e,t,n){if(!n.usages.includes(`sign`))throw O(`CryptoKey instances used for signing assertions must include "sign" in their "usages"`,E);let r=`${Tn(Sn(JSON.stringify(e)))}.${Tn(Sn(JSON.stringify(t)))}`;return`${r}.${Tn(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case`ECDSA`:return{name:e.algorithm.name,hash:Ir(e)};case`RSA-PSS`:switch(Fr(e),e.algorithm.hash.name){case`SHA-256`:case`SHA-384`:case`SHA-512`:return{name:e.algorithm.name,saltLength:parseInt(e.algorithm.hash.name.slice(-3),10)>>3};default:throw new M(`unsupported RSA-PSS hash name`,{cause:e})}case`RSASSA-PKCS1-v1_5`:return Fr(e),e.algorithm.name;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:case`Ed25519`:return e.algorithm.name}throw new M(`unsupported CryptoKey algorithm name`,{cause:e})}(n),n,Sn(r)))}`}(c,l,n))}}var Hn=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch{return null}};function Un(e,t){if(t&&e.protocol!==`https:`)throw N(`only requests to HTTPS are allowed`,Dr,e);if(e.protocol!==`https:`&&e.protocol!==`http:`)throw N(`only HTTP and HTTPS requests are allowed`,Or,e)}function Wn(e,t,n,r){let i;if(typeof e!=`string`||!(i=Hn(e)))throw N(`authorization server metadata does not contain a valid ${n?`"as.mtls_endpoint_aliases.${t}"`:`"as.${t}"`}`,e===void 0?Mr:Nr,{attribute:n?`mtls_endpoint_aliases.${t}`:t});return Un(i,r),i}function Gn(e,t,n,r){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?Wn(e.mtls_endpoint_aliases[t],t,n,r):Wn(e[t],t,n,r)}var Kn=class extends Error{constructor(e,t){var n;super(e,t),y(this,`cause`,void 0),y(this,`code`,void 0),y(this,`error`,void 0),y(this,`status`,void 0),y(this,`error_description`,void 0),y(this,`response`,void 0),this.name=this.constructor.name,this.code=xr,this.cause=t.cause,this.error=t.cause.error,this.status=t.response.status,this.error_description=t.cause.error_description,Object.defineProperty(this,`response`,{enumerable:!1,value:t.response}),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},qn=class extends Error{constructor(e,t){var n;super(e,t),y(this,`cause`,void 0),y(this,`code`,void 0),y(this,`error`,void 0),y(this,`error_description`,void 0),this.name=this.constructor.name,this.code=Cr,this.cause=t.cause,this.error=t.cause.get(`error`),this.error_description=t.cause.get(`error_description`)??void 0,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},Jn=class extends Error{constructor(e,t){var n;super(e,t),y(this,`cause`,void 0),y(this,`code`,void 0),y(this,`response`,void 0),y(this,`status`,void 0),this.name=this.constructor.name,this.code=br,this.cause=t.cause,this.status=t.response.status,this.response=t.response,Object.defineProperty(this,`response`,{enumerable:!1}),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},Yn="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",Xn=`(`+Yn+`)\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"`,Zn=`(`+Yn+")\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)",Qn=RegExp(`^[,\\s]*(`+Yn+`)`),$n=RegExp(`^[,\\s]*`+Xn+`[,\\s]*(.*)`),er=RegExp(`^[,\\s]*`+Zn+`[,\\s]*(.*)`),tr=RegExp(`^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)`);async function nr(e,t,n){if(e.status!==t){let t;throw function(e){let t;if(t=function(e){if(!gn(e,Response))throw O(`"response" must be an instance of Response`,D);let t=e.headers.get(`www-authenticate`);if(t===null)return;let n=[],r=t;for(;r;){let e=r.match(Qn),t=e?.[1].toLowerCase();if(!t)return;let i=r.substring(e[0].length);if(i&&!i.match(/^[\s,]/))return;let a=i.match(/^\s+(.*)$/),o=!!a;r=a?a[1]:void 0;let s={},c;if(o)for(;r;){let t,n;if(e=r.match($n)){if([,t,n,r]=e,n.includes(`\\`))try{n=JSON.parse(`"${n}"`)}catch{}s[t.toLowerCase()]=n}else{if(!(e=r.match(er))){if(e=r.match(tr)){if(Object.keys(s).length)break;[,c,r]=e;break}return}[,t,n,r]=e,s[t.toLowerCase()]=n}}else r=i||void 0;let l={scheme:t,parameters:s};c&&(l.token68=c),n.push(l)}return n.length?n:void 0}(e))throw new Jn(`server responded with a challenge in the WWW-Authenticate HTTP Header`,{cause:t,response:e})}(e),(t=await async function(e){if(e.status>399&&e.status<500){Pr(e),Pn(e);try{let t=await e.clone().json();if(On(t)&&typeof t.error==`string`&&t.error.length)return t}catch{}}}(e))?(await e.body?.cancel(),new Kn(`server responded with an error in the response body`,{cause:t,response:e})):N(`"response" is not a conform ${n} response (unexpected HTTP status code)`,Er,e)}}function rr(e){if(!pr.has(e))throw O(`"options.DPoP" is not a valid DPoPHandle`,E)}function ir(e){return e.headers.get(`content-type`)?.split(`;`)[0]}async function ar(e,t,n,r,i,a,o){return await n(e,t,i,a),a.set(`content-type`,`application/x-www-form-urlencoded;charset=UTF-8`),(o?.[A]||fetch)(r.href,{body:i,headers:Object.fromEntries(a.entries()),method:`POST`,redirect:`manual`,signal:An(r,o?.signal)})}async function or(e,t,n,r,i,a){var o;let s=Gn(e,`token_endpoint`,t.use_mtls_endpoint_aliases,!0!==a?.[k]);i.set(`grant_type`,r);let c=kn(a?.headers);c.set(`accept`,`application/json`),a?.DPoP!==void 0&&(rr(a.DPoP),await a.DPoP.addProof(s,c,`POST`));let l=await ar(e,t,n,s,i,c,a);return a==null||(o=a.DPoP)==null||o.cacheNonce(l,s),l}var sr=new WeakMap,cr=new WeakMap;function lr(e){if(!e.id_token)return;let t=sr.get(e);if(!t)throw O(`"ref" was already garbage collected or did not resolve from the proper sources`,E);return t}async function ur(e,t,n,r,i,a){if(F(e),I(t),!gn(n,Response))throw O(`"response" must be an instance of Response`,D);await nr(n,200,`Token Endpoint`),Pr(n);let o=await Ur(n);if(P(o.access_token,`"response" body "access_token" property`,L,{body:o}),P(o.token_type,`"response" body "token_type" property`,L,{body:o}),o.token_type=o.token_type.toLowerCase(),o.expires_in!==void 0){let e=typeof o.expires_in==`number`?o.expires_in:parseFloat(o.expires_in);Nn(e,!0,`"response" body "expires_in" property`,L,{body:o}),o.expires_in=e}if(o.refresh_token!==void 0&&P(o.refresh_token,`"response" body "refresh_token" property`,L,{body:o}),o.scope!==void 0&&typeof o.scope!=`string`)throw N(`"response" body "scope" property must be a string`,L,{body:o});if(o.id_token!==void 0){P(o.id_token,`"response" body "id_token" property`,L,{body:o});let a=[`aud`,`exp`,`iat`,`iss`,`sub`];!0===t.require_auth_time&&a.push(`auth_time`),t.default_max_age!==void 0&&(Nn(t.default_max_age,!0,`"client.default_max_age"`),a.push(`auth_time`)),r!=null&&r.length&&a.push(...r);let{claims:s,jwt:c}=await async function(e,t,n,r,i){let a,o,{0:s,1:c,length:l}=e.split(`.`);if(l===5){if(i===void 0)throw new M(`JWE decryption is not configured`,{cause:e});e=await i(e),{0:s,1:c,length:l}=e.split(`.`)}if(l!==3)throw N(`Invalid JWT`,L,e);try{a=JSON.parse(Sn(Tn(s)))}catch(e){throw N(`failed to parse JWT Header body as base64url encoded JSON`,wr,e)}if(!On(a))throw N(`JWT Header must be a top level object`,L,e);if(t(a),a.crit!==void 0)throw new M(`no JWT "crit" header parameter extensions are supported`,{cause:{header:a}});try{o=JSON.parse(Sn(Tn(c)))}catch(e){throw N(`failed to parse JWT Payload body as base64url encoded JSON`,wr,e)}if(!On(o))throw N(`JWT Payload must be a top level object`,L,e);let u=zn()+n;if(o.exp!==void 0){if(typeof o.exp!=`number`)throw N(`unexpected JWT "exp" (expiration time) claim type`,L,{claims:o});if(o.exp<=u-r)throw N(`unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp`,kr,{claims:o,now:u,tolerance:r,claim:`exp`})}if(o.iat!==void 0&&typeof o.iat!=`number`)throw N(`unexpected JWT "iat" (issued at) claim type`,L,{claims:o});if(o.iss!==void 0&&typeof o.iss!=`string`)throw N(`unexpected JWT "iss" (issuer) claim type`,L,{claims:o});if(o.nbf!==void 0){if(typeof o.nbf!=`number`)throw N(`unexpected JWT "nbf" (not before) claim type`,L,{claims:o});if(o.nbf>u+r)throw N(`unexpected JWT "nbf" (not before) claim value`,kr,{claims:o,now:u,tolerance:r,claim:`nbf`})}if(o.aud!==void 0&&typeof o.aud!=`string`&&!Array.isArray(o.aud))throw N(`unexpected JWT "aud" (audience) claim type`,L,{claims:o});return{header:a,claims:o,jwt:e}}(o.id_token,Rr.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,`RS256`),Ln(t),Rn(t),i).then(gr.bind(void 0,a)).then(fr.bind(void 0,e)).then(dr.bind(void 0,t.client_id));if(Array.isArray(s.aud)&&s.aud.length!==1){if(s.azp===void 0)throw N(`ID Token "aud" (audience) claim includes additional untrusted audiences`,Ar,{claims:s,claim:`aud`});if(s.azp!==t.client_id)throw N(`unexpected ID Token "azp" (authorized party) claim value`,Ar,{expected:t.client_id,claims:s,claim:`azp`})}s.auth_time!==void 0&&Nn(s.auth_time,!0,`ID Token "auth_time" (authentication time)`,L,{claims:s}),cr.set(n,c),sr.set(o,s)}if(a?.[o.token_type]!==void 0)a[o.token_type](n,o);else if(o.token_type!==`dpop`&&o.token_type!==`bearer`)throw new M("unsupported `token_type` value",{cause:{body:o}});return o}function dr(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw N(`unexpected JWT "aud" (audience) claim value`,Ar,{expected:e,claims:t.claims,claim:`aud`})}else if(t.claims.aud!==e)throw N(`unexpected JWT "aud" (audience) claim value`,Ar,{expected:e,claims:t.claims,claim:`aud`});return t}function fr(e,t){let n=e[Gr]?.call(e,t)??e.issuer;if(t.claims.iss!==n)throw N(`unexpected JWT "iss" (issuer) claim value`,Ar,{expected:n,claims:t.claims,claim:`iss`});return t}var pr=new WeakSet,mr=Symbol(),hr={aud:`audience`,c_hash:`code hash`,client_id:`client id`,exp:`expiration time`,iat:`issued at`,iss:`issuer`,jti:`jwt id`,nonce:`nonce`,s_hash:`state hash`,sub:`subject`,ath:`access token hash`,htm:`http method`,htu:`http uri`,cnf:`confirmation`,auth_time:`authentication time`};function gr(e,t){for(let n of e)if(t.claims[n]===void 0)throw N(`JWT "${n}" (${hr[n]}) claim missing`,L,{claims:t.claims});return t}var _r=Symbol(),vr=Symbol();async function yr(e,t,n,r){return typeof r?.expectedNonce==`string`||typeof r?.maxAge==`number`||r!=null&&r.requireIdToken?async function(e,t,n,r,i,a,o){let s=[];switch(r){case void 0:r=_r;break;case _r:break;default:P(r,`"expectedNonce" argument`),s.push(`nonce`)}switch(i??=t.default_max_age,i){case void 0:i=vr;break;case vr:break;default:Nn(i,!0,`"maxAge" argument`),s.push(`auth_time`)}let c=await ur(e,t,n,s,a,o);P(c.id_token,`"response" body "id_token" property`,L,{body:c});let l=lr(c);if(i!==vr){let e=zn()+Ln(t),n=Rn(t);if(l.auth_time+i<e-n)throw N(`too much time has elapsed since the last End-User authentication`,kr,{claims:l,now:e,tolerance:n,claim:`auth_time`})}if(r===_r){if(l.nonce!==void 0)throw N(`unexpected ID Token "nonce" claim value`,Ar,{expected:void 0,claims:l,claim:`nonce`})}else if(l.nonce!==r)throw N(`unexpected ID Token "nonce" claim value`,Ar,{expected:r,claims:l,claim:`nonce`});return c}(e,t,n,r.expectedNonce,r.maxAge,r[j],r.recognizedTokenTypes):async function(e,t,n,r,i){let a=await ur(e,t,n,void 0,r,i),o=lr(a);if(o){if(t.default_max_age!==void 0){Nn(t.default_max_age,!0,`"client.default_max_age"`);let e=zn()+Ln(t),n=Rn(t);if(o.auth_time+t.default_max_age<e-n)throw N(`too much time has elapsed since the last End-User authentication`,kr,{claims:o,now:e,tolerance:n,claim:`auth_time`})}if(o.nonce!==void 0)throw N(`unexpected ID Token "nonce" claim value`,Ar,{expected:void 0,claims:o,claim:`nonce`})}return a}(e,t,n,r?.[j],r?.recognizedTokenTypes)}var br=`OAUTH_WWW_AUTHENTICATE_CHALLENGE`,xr=`OAUTH_RESPONSE_BODY_ERROR`,Sr=`OAUTH_UNSUPPORTED_OPERATION`,Cr=`OAUTH_AUTHORIZATION_RESPONSE_ERROR`,wr=`OAUTH_PARSE_ERROR`,L=`OAUTH_INVALID_RESPONSE`,Tr=`OAUTH_RESPONSE_IS_NOT_JSON`,Er=`OAUTH_RESPONSE_IS_NOT_CONFORM`,Dr=`OAUTH_HTTP_REQUEST_FORBIDDEN`,Or=`OAUTH_REQUEST_PROTOCOL_FORBIDDEN`,kr=`OAUTH_JWT_TIMESTAMP_CHECK_FAILED`,Ar=`OAUTH_JWT_CLAIM_COMPARISON_FAILED`,jr=`OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED`,Mr=`OAUTH_MISSING_SERVER_METADATA`,Nr=`OAUTH_INVALID_SERVER_METADATA`;function Pr(e){if(e.bodyUsed)throw O(`"response" body has been used already`,E)}function Fr(e){let{algorithm:t}=e;if(typeof t.modulusLength!=`number`||t.modulusLength<2048)throw new M(`unsupported ${t.name} modulusLength`,{cause:e})}function Ir(e){let{algorithm:t}=e;switch(t.namedCurve){case`P-256`:return`SHA-256`;case`P-384`:return`SHA-384`;case`P-521`:return`SHA-512`;default:throw new M(`unsupported ECDSA namedCurve`,{cause:e})}}async function Lr(e){if(e.method!==`POST`)throw O(`form_post responses are expected to use the POST method`,E,{cause:e});if(ir(e)!==`application/x-www-form-urlencoded`)throw O(`form_post responses are expected to use the application/x-www-form-urlencoded content-type`,E,{cause:e});return async function(e){if(e.bodyUsed)throw O(`form_post Request instances must contain a readable body`,E,{cause:e});return e.text()}(e)}function Rr(e,t,n,r){if(e===void 0)if(Array.isArray(t)){if(!t.includes(r.alg))throw N(`unexpected JWT "alg" header parameter`,L,{header:r,expected:t,reason:`authorization server metadata`})}else{if(n===void 0)throw N(`missing client or server configuration to verify used JWT "alg" header parameter`,void 0,{client:e,issuer:t,fallback:n});if(typeof n==`string`?r.alg!==n:typeof n==`function`?!n(r.alg):!n.includes(r.alg))throw N(`unexpected JWT "alg" header parameter`,L,{header:r,expected:n,reason:`default value`})}else if(typeof e==`string`?r.alg!==e:!e.includes(r.alg))throw N(`unexpected JWT "alg" header parameter`,L,{header:r,expected:e,reason:`client configuration`})}function zr(e,t){let{0:n,length:r}=e.getAll(t);if(r>1)throw N(`"${t}" parameter must be provided only once`,L);return n}var Br=Symbol(),Vr=Symbol();function Hr(e,t,n,r){if(F(e),I(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw O(`"parameters" must be an instance of URLSearchParams, or URL`,D);if(zr(n,`response`))throw N(`"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()`,L,{parameters:n});let i=zr(n,`iss`),a=zr(n,`state`);if(!i&&e.authorization_response_iss_parameter_supported)throw N(`response parameter "iss" (issuer) missing`,L,{parameters:n});if(i&&i!==e.issuer)throw N(`unexpected "iss" (issuer) response parameter value`,L,{expected:e.issuer,parameters:n});switch(r){case void 0:case Vr:if(a!==void 0)throw N(`unexpected "state" response parameter encountered`,L,{expected:void 0,parameters:n});break;case Br:break;default:if(P(r,`"expectedState" argument`),a!==r)throw N(a===void 0?`response parameter "state" missing`:`unexpected "state" response parameter value`,L,{expected:r,parameters:n})}if(zr(n,`error`))throw new qn(`authorization response from the server is an error`,{cause:n});let o=zr(n,`id_token`),s=zr(n,`token`);if(o!==void 0||s!==void 0)throw new M(`implicit and hybrid flows are not supported`);return c=new URLSearchParams(n),pr.add(c),c;var c}async function Ur(e){let t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Pn;try{t=await e.json()}catch(t){throw n(e),N(`failed to parse "response" body as JSON`,wr,t)}if(!On(t))throw N(`"response" body must be a top level object`,L,{body:t});return t}var Wr=Symbol(),Gr=Symbol(),Kr=new TextEncoder,qr=new TextDecoder;function Jr(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>127)throw TypeError(`non-ASCII string encountered in encode()`);t[n]=r}return t}function Yr(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Xr(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:qr.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=qr.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return Yr(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}var Zr=function(e){return TypeError(`CryptoKey does not support this operation, its ${arguments.length>1&&arguments[1]!==void 0?arguments[1]:`algorithm.name`} must be ${e}`)},Qr=(e,t)=>e.name===t;function $r(e,t){var n;if((n=e.hash,parseInt(n.name.slice(4),10))!==t)throw Zr(`SHA-${t}`,`algorithm.hash`)}function ei(e,t,n){switch(t){case`HS256`:case`HS384`:case`HS512`:if(!Qr(e.algorithm,`HMAC`))throw Zr(`HMAC`);$r(e.algorithm,parseInt(t.slice(2),10));break;case`RS256`:case`RS384`:case`RS512`:if(!Qr(e.algorithm,`RSASSA-PKCS1-v1_5`))throw Zr(`RSASSA-PKCS1-v1_5`);$r(e.algorithm,parseInt(t.slice(2),10));break;case`PS256`:case`PS384`:case`PS512`:if(!Qr(e.algorithm,`RSA-PSS`))throw Zr(`RSA-PSS`);$r(e.algorithm,parseInt(t.slice(2),10));break;case`Ed25519`:case`EdDSA`:if(!Qr(e.algorithm,`Ed25519`))throw Zr(`Ed25519`);break;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:if(!Qr(e.algorithm,t))throw Zr(t);break;case`ES256`:case`ES384`:case`ES512`:{if(!Qr(e.algorithm,`ECDSA`))throw Zr(`ECDSA`);let n=function(e){switch(e){case`ES256`:return`P-256`;case`ES384`:return`P-384`;case`ES512`:return`P-521`;default:throw Error(`unreachable`)}}(t);if(e.algorithm.namedCurve!==n)throw Zr(n,`algorithm.namedCurve`);break}default:throw TypeError(`CryptoKey does not support this operation`)}(function(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)})(e,n)}function ti(e,t){var n=[...arguments].slice(2);if((n=n.filter(Boolean)).length>2){let t=n.pop();e+=`one of type ${n.join(`, `)}, or ${t}.`}else n.length===2?e+=`one of type ${n[0]} or ${n[1]}.`:e+=`of type ${n[0]}.`;if(t==null)e+=` Received ${t}`;else if(typeof t==`function`&&t.name)e+=` Received function ${t.name}`;else if(typeof t==`object`&&t){var r;(r=t.constructor)!=null&&r.name&&(e+=` Received an instance of ${t.constructor.name}`)}return e}var ni=function(e,t){var n=[...arguments].slice(2);return ti(`Key for the ${e} algorithm must be `,t,...n)},R=class extends Error{constructor(e,t){var n;super(e,t),y(this,`code`,`ERR_JOSE_GENERIC`),this.name=this.constructor.name,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};y(R,`code`,`ERR_JOSE_GENERIC`);var z=class extends R{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`unspecified`,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`unspecified`;super(e,{cause:{claim:n,reason:r,payload:t}}),y(this,`code`,`ERR_JWT_CLAIM_VALIDATION_FAILED`),y(this,`claim`,void 0),y(this,`reason`,void 0),y(this,`payload`,void 0),this.claim=n,this.reason=r,this.payload=t}};y(z,`code`,`ERR_JWT_CLAIM_VALIDATION_FAILED`);var ri=class extends R{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`unspecified`,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`unspecified`;super(e,{cause:{claim:n,reason:r,payload:t}}),y(this,`code`,`ERR_JWT_EXPIRED`),y(this,`claim`,void 0),y(this,`reason`,void 0),y(this,`payload`,void 0),this.claim=n,this.reason=r,this.payload=t}};y(ri,`code`,`ERR_JWT_EXPIRED`);var ii=class extends R{constructor(){super(...arguments),y(this,`code`,`ERR_JOSE_ALG_NOT_ALLOWED`)}};y(ii,`code`,`ERR_JOSE_ALG_NOT_ALLOWED`);var B=class extends R{constructor(){super(...arguments),y(this,`code`,`ERR_JOSE_NOT_SUPPORTED`)}};y(B,`code`,`ERR_JOSE_NOT_SUPPORTED`),y(class extends R{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`decryption operation failed`,arguments.length>1?arguments[1]:void 0),y(this,`code`,`ERR_JWE_DECRYPTION_FAILED`)}},`code`,`ERR_JWE_DECRYPTION_FAILED`),y(class extends R{constructor(){super(...arguments),y(this,`code`,`ERR_JWE_INVALID`)}},`code`,`ERR_JWE_INVALID`);var V=class extends R{constructor(){super(...arguments),y(this,`code`,`ERR_JWS_INVALID`)}};y(V,`code`,`ERR_JWS_INVALID`);var ai=class extends R{constructor(){super(...arguments),y(this,`code`,`ERR_JWT_INVALID`)}};y(ai,`code`,`ERR_JWT_INVALID`),y(class extends R{constructor(){super(...arguments),y(this,`code`,`ERR_JWK_INVALID`)}},`code`,`ERR_JWK_INVALID`);var oi=class extends R{constructor(){super(...arguments),y(this,`code`,`ERR_JWKS_INVALID`)}};y(oi,`code`,`ERR_JWKS_INVALID`);var si=class extends R{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`no applicable key found in the JSON Web Key Set`,arguments.length>1?arguments[1]:void 0),y(this,`code`,`ERR_JWKS_NO_MATCHING_KEY`)}};y(si,`code`,`ERR_JWKS_NO_MATCHING_KEY`);var ci=class extends R{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`multiple matching keys found in the JSON Web Key Set`,arguments.length>1?arguments[1]:void 0),y(this,Symbol.asyncIterator,void 0),y(this,`code`,`ERR_JWKS_MULTIPLE_MATCHING_KEYS`)}};y(ci,`code`,`ERR_JWKS_MULTIPLE_MATCHING_KEYS`);var li=class extends R{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`request timed out`,arguments.length>1?arguments[1]:void 0),y(this,`code`,`ERR_JWKS_TIMEOUT`)}};y(li,`code`,`ERR_JWKS_TIMEOUT`);var ui=class extends R{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`signature verification failed`,arguments.length>1?arguments[1]:void 0),y(this,`code`,`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`)}};y(ui,`code`,`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`);var di=e=>{if(e?.[Symbol.toStringTag]===`CryptoKey`)return!0;try{return e instanceof CryptoKey}catch{return!1}},fi=e=>e?.[Symbol.toStringTag]===`KeyObject`,pi=e=>di(e)||fi(e);function mi(e,t,n){try{return Xr(e)}catch{throw new n(`Failed to base64url decode the ${t}`)}}function hi(e){if(typeof(t=e)!=`object`||t===null||Object.prototype.toString.call(e)!==`[object Object]`)return!1;var t;if(Object.getPrototypeOf(e)===null)return!0;let n=e;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}var gi=e=>hi(e)&&typeof e.kty==`string`;async function _i(e,t,n){if(t instanceof Uint8Array){if(!e.startsWith(`HS`))throw TypeError(function(e){return ti(`Key must be `,e,...[...arguments].slice(1))}(t,`CryptoKey`,`KeyObject`,`JSON Web Key`));return crypto.subtle.importKey(`raw`,t,{hash:`SHA-${e.slice(-3)}`,name:`HMAC`},!1,[n])}return ei(t,e,n),t}async function vi(e,t,n,r){let i=await _i(e,t,`verify`);(function(e,t){if(e.startsWith(`RS`)||e.startsWith(`PS`)){let{modulusLength:n}=t.algorithm;if(typeof n!=`number`||n<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}})(e,i);let a=function(e,t){let n=`SHA-${e.slice(-3)}`;switch(e){case`HS256`:case`HS384`:case`HS512`:return{hash:n,name:`HMAC`};case`PS256`:case`PS384`:case`PS512`:return{hash:n,name:`RSA-PSS`,saltLength:parseInt(e.slice(-3),10)>>3};case`RS256`:case`RS384`:case`RS512`:return{hash:n,name:`RSASSA-PKCS1-v1_5`};case`ES256`:case`ES384`:case`ES512`:return{hash:n,name:`ECDSA`,namedCurve:t.namedCurve};case`Ed25519`:case`EdDSA`:return{name:`Ed25519`};case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:return{name:e};default:throw new B(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}(e,i.algorithm);try{return await crypto.subtle.verify(a,i,n,r)}catch{return!1}}var yi=`Invalid or unsupported JWK "alg" (Algorithm) Parameter value`;async function bi(e){if(!e.alg)throw TypeError(`"alg" argument is required when "jwk.alg" is not present`);let{algorithm:t,keyUsages:n}=function(e){let t,n;switch(e.kty){case`AKP`:switch(e.alg){case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:t={name:e.alg},n=e.priv?[`sign`]:[`verify`];break;default:throw new B(yi)}break;case`RSA`:switch(e.alg){case`PS256`:case`PS384`:case`PS512`:t={name:`RSA-PSS`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RS256`:case`RS384`:case`RS512`:t={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:t={name:`RSA-OAEP`,hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},n=e.d?[`decrypt`,`unwrapKey`]:[`encrypt`,`wrapKey`];break;default:throw new B(yi)}break;case`EC`:switch(e.alg){case`ES256`:case`ES384`:case`ES512`:t={name:`ECDSA`,namedCurve:{ES256:`P-256`,ES384:`P-384`,ES512:`P-521`}[e.alg]},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:`ECDH`,namedCurve:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new B(yi)}break;case`OKP`:switch(e.alg){case`Ed25519`:case`EdDSA`:t={name:`Ed25519`},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new B(yi)}break;default:throw new B(`Invalid or unsupported JWK "kty" (Key Type) Parameter value`)}return{algorithm:t,keyUsages:n}}(e),r=b({},e);return r.kty!==`AKP`&&delete r.alg,delete r.use,crypto.subtle.importKey(`jwk`,r,t,e.ext??(!e.d&&!e.priv),e.key_ops??n)}var xi=`given KeyObject instance cannot be used for this algorithm`,Si,Ci=async function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0&&arguments[3];Si||=new WeakMap;let i=Si.get(e);if(i!=null&&i[n])return i[n];let a=await bi(b(b({},t),{},{alg:n}));return r&&Object.freeze(e),i?i[n]=a:Si.set(e,{[n]:a}),a};async function wi(e,t){if(e instanceof Uint8Array||di(e))return e;if(fi(e)){if(e.type===`secret`)return e.export();if(`toCryptoKey`in e&&typeof e.toCryptoKey==`function`)try{return((e,t)=>{Si||=new WeakMap;let n=Si.get(e);if(n!=null&&n[t])return n[t];let r=e.type===`public`,i=!!r,a;if(e.asymmetricKeyType===`x25519`){switch(t){case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:break;default:throw TypeError(xi)}a=e.toCryptoKey(e.asymmetricKeyType,i,r?[]:[`deriveBits`])}if(e.asymmetricKeyType===`ed25519`){if(t!==`EdDSA`&&t!==`Ed25519`)throw TypeError(xi);a=e.toCryptoKey(e.asymmetricKeyType,i,[r?`verify`:`sign`])}switch(e.asymmetricKeyType){case`ml-dsa-44`:case`ml-dsa-65`:case`ml-dsa-87`:if(t!==e.asymmetricKeyType.toUpperCase())throw TypeError(xi);a=e.toCryptoKey(e.asymmetricKeyType,i,[r?`verify`:`sign`])}if(e.asymmetricKeyType===`rsa`){let n;switch(t){case`RSA-OAEP`:n=`SHA-1`;break;case`RS256`:case`PS256`:case`RSA-OAEP-256`:n=`SHA-256`;break;case`RS384`:case`PS384`:case`RSA-OAEP-384`:n=`SHA-384`;break;case`RS512`:case`PS512`:case`RSA-OAEP-512`:n=`SHA-512`;break;default:throw TypeError(xi)}if(t.startsWith(`RSA-OAEP`))return e.toCryptoKey({name:`RSA-OAEP`,hash:n},i,r?[`encrypt`]:[`decrypt`]);a=e.toCryptoKey({name:t.startsWith(`PS`)?`RSA-PSS`:`RSASSA-PKCS1-v1_5`,hash:n},i,[r?`verify`:`sign`])}if(e.asymmetricKeyType===`ec`){let n=new Map([[`prime256v1`,`P-256`],[`secp384r1`,`P-384`],[`secp521r1`,`P-521`]]).get(e.asymmetricKeyDetails?.namedCurve);if(!n)throw TypeError(xi);let o={ES256:`P-256`,ES384:`P-384`,ES512:`P-521`};o[t]&&n===o[t]&&(a=e.toCryptoKey({name:`ECDSA`,namedCurve:n},i,[r?`verify`:`sign`])),t.startsWith(`ECDH-ES`)&&(a=e.toCryptoKey({name:`ECDH`,namedCurve:n},i,r?[]:[`deriveBits`]))}if(!a)throw TypeError(xi);return n?n[t]=a:Si.set(e,{[t]:a}),a})(e,t)}catch(e){if(e instanceof TypeError)throw e}return Ci(e,e.export({format:`jwk`}),t)}if(gi(e))return e.k?Xr(e.k):Ci(e,e,t,!0);throw Error(`unreachable`)}var Ti=(e,t)=>{if(e.byteLength!==t.length)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0},Ei=e=>{let t=e.data[e.pos++];if(128&t){let n=127&t,r=0;for(let t=0;t<n;t++)r=r<<8|e.data[e.pos++];return r}return t},Di=(e,t,n)=>{if(e.data[e.pos++]!==t)throw Error(n)},Oi=(e,t)=>{let n=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,n},ki=e=>{let t=(e=>(Di(e,6,`Expected algorithm OID`),Oi(e,Ei(e))))(e);if(Ti(t,[43,101,110]))return`X25519`;if(!Ti(t,[42,134,72,206,61,2,1]))throw Error(`Unsupported key algorithm`);Di(e,6,`Expected curve OID`);let n=Oi(e,Ei(e));for(let{name:e,oid:t}of[{name:`P-256`,oid:[42,134,72,206,61,3,1,7]},{name:`P-384`,oid:[43,129,4,0,34]},{name:`P-521`,oid:[43,129,4,0,35]}])if(Ti(n,t))return e;throw Error(`Unsupported named curve`)},Ai=async(e,t,n,r)=>{let i,a,o=e===`spki`,s=()=>o?[`verify`]:[`sign`];switch(n){case`PS256`:case`PS384`:case`PS512`:i={name:`RSA-PSS`,hash:`SHA-${n.slice(-3)}`},a=s();break;case`RS256`:case`RS384`:case`RS512`:i={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${n.slice(-3)}`},a=s();break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:i={name:`RSA-OAEP`,hash:`SHA-${parseInt(n.slice(-3),10)||1}`},a=o?[`encrypt`,`wrapKey`]:[`decrypt`,`unwrapKey`];break;case`ES256`:case`ES384`:case`ES512`:i={name:`ECDSA`,namedCurve:{ES256:`P-256`,ES384:`P-384`,ES512:`P-521`}[n]},a=s();break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:try{let e=r.getNamedCurve(t);i=e===`X25519`?{name:`X25519`}:{name:`ECDH`,namedCurve:e}}catch{throw new B(`Invalid or unsupported key format`)}a=o?[]:[`deriveBits`];break;case`Ed25519`:case`EdDSA`:i={name:`Ed25519`},a=s();break;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:i={name:n},a=s();break;default:throw new B(`Invalid or unsupported "alg" (Algorithm) value`)}return crypto.subtle.importKey(e,t,i,r?.extractable??!!o,a)},ji=(e,t,n)=>{var r;let i=((e,t)=>Yr(e.replace(t,``)))(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g),a=n;return t!=null&&(r=t.startsWith)!=null&&r.call(t,`ECDH-ES`)&&(a||={},a.getNamedCurve=e=>{let t={data:e,pos:0};return function(e){Di(e,48,`Invalid PKCS#8 structure`),Ei(e),Di(e,2,`Expected version field`);let t=Ei(e);e.pos+=t,Di(e,48,`Expected algorithm identifier`),Ei(e),e.pos}(t),ki(t)}),Ai(`pkcs8`,i,t,a)},Mi=e=>e?.[Symbol.toStringTag],Ni=(e,t,n)=>{if(t.use!==void 0){let e;switch(n){case`sign`:case`verify`:e=`sig`;break;case`encrypt`:case`decrypt`:e=`enc`}if(t.use!==e)throw TypeError(`Invalid key for this operation, its "use" must be "${e}" when present`)}if(t.alg!==void 0&&t.alg!==e)throw TypeError(`Invalid key for this operation, its "alg" must be "${e}" when present`);if(Array.isArray(t.key_ops)){var r,i;let a;switch(!0){case n===`sign`||n===`verify`:case e===`dir`:case e.includes(`CBC-HS`):a=n;break;case e.startsWith(`PBES2`):a=`deriveBits`;break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):a=!e.includes(`GCM`)&&e.endsWith(`KW`)?n===`encrypt`?`wrapKey`:`unwrapKey`:n;break;case n===`encrypt`&&e.startsWith(`RSA`):a=`wrapKey`;break;case n===`decrypt`:a=e.startsWith(`RSA`)?`unwrapKey`:`deriveBits`}if(a&&!1===((r=t.key_ops)==null||(i=r.includes)==null?void 0:i.call(r,a)))throw TypeError(`Invalid key for this operation, its "key_ops" must include "${a}" when present`)}return!0};function Pi(e,t,n){switch(e.substring(0,2)){case`A1`:case`A2`:case`di`:case`HS`:case`PB`:((e,t,n)=>{if(!(t instanceof Uint8Array)){if(gi(t)){if((e=>e.kty===`oct`&&typeof e.k==`string`)(t)&&Ni(e,t,n))return;throw TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`)}if(!pi(t))throw TypeError(ni(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`,`Uint8Array`));if(t.type!==`secret`)throw TypeError(`${Mi(t)} instances for symmetric algorithms must be of type "secret"`)}})(e,t,n);break;default:((e,t,n)=>{if(gi(t))switch(n){case`decrypt`:case`sign`:if((e=>e.kty!==`oct`&&(e.kty===`AKP`&&typeof e.priv==`string`||typeof e.d==`string`))(t)&&Ni(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a private JWK`);case`encrypt`:case`verify`:if((e=>e.kty!==`oct`&&e.d===void 0&&e.priv===void 0)(t)&&Ni(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a public JWK`)}if(!pi(t))throw TypeError(ni(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`));if(t.type===`secret`)throw TypeError(`${Mi(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.type===`public`)switch(n){case`sign`:throw TypeError(`${Mi(t)} instances for asymmetric algorithm signing must be of type "private"`);case`decrypt`:throw TypeError(`${Mi(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.type===`private`)switch(n){case`verify`:throw TypeError(`${Mi(t)} instances for asymmetric algorithm verifying must be of type "public"`);case`encrypt`:throw TypeError(`${Mi(t)} instances for asymmetric algorithm encryption must be of type "public"`)}})(e,t,n)}}var Fi,Ii,H,Li;(typeof navigator>`u`||(Fi=navigator.userAgent)==null||(Ii=Fi.startsWith)==null||!Ii.call(Fi,`Mozilla/5.0 `))&&(Li=`openid-client/v6.8.2`,H={"user-agent":Li});var U=e=>Ri.get(e),Ri,zi;function Bi(e){return e===void 0?(zi||=new WeakMap,(e,t,n,r)=>{let i;return(i=zi.get(t))||(function(e,t){if(typeof e!=`string`)throw G(`${t} must be a string`,Hi);if(e.length===0)throw G(`${t} must not be empty`,Vi)}(t.client_secret,`"metadata.client_secret"`),i=Bn(t.client_secret),zi.set(t,i)),i(e,t,n,r)}):Bn(e)}var W=A,Vi=`ERR_INVALID_ARG_VALUE`,Hi=`ERR_INVALID_ARG_TYPE`;function G(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}function Ui(e){return async function(e){return P(e,`codeVerifier`),Tn(await crypto.subtle.digest(`SHA-256`,Sn(e)))}(e)}function Wi(){return Fn()}var Gi=class extends Error{constructor(e,t){var n;super(e,t),y(this,`code`,void 0),this.name=this.constructor.name,this.code=t?.code,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};function K(e,t,n){return new Gi(e,{cause:t,code:n})}function q(e){if(e instanceof TypeError||e instanceof Gi||e instanceof Kn||e instanceof qn||e instanceof Jn)throw e;if(e instanceof En)switch(e.code){case Dr:throw K(`only requests to HTTPS are allowed`,e,e.code);case Or:throw K(`only requests to HTTP or HTTPS are allowed`,e,e.code);case Er:throw K(`unexpected HTTP response status code`,e.cause,e.code);case Tr:throw K(`unexpected response content-type`,e.cause,e.code);case wr:throw K(`parsing error occured`,e,e.code);case L:throw K(`invalid response encountered`,e,e.code);case Ar:throw K(`unexpected JWT claim value encountered`,e,e.code);case jr:throw K(`unexpected JSON attribute value encountered`,e,e.code);case kr:throw K(`JWT timestamp claim value failed validation`,e,e.code);default:throw K(e.message,e,e.code)}if(e instanceof M)throw K(`unsupported operation`,e,e.code);if(e instanceof DOMException)switch(e.name){case`OperationError`:throw K(`runtime operation error`,e,Sr);case`NotSupportedError`:throw K(`runtime unsupported operation`,e,Sr);case`TimeoutError`:throw K(`operation timed out`,e,`OAUTH_TIMEOUT`);case`AbortError`:throw K(`operation aborted`,e,`OAUTH_ABORT`)}throw new Gi(`something went wrong`,{cause:e})}async function Ki(e,t,n,r,i){let a=new Ji(await async function(e,t){var n;if(!(e instanceof URL))throw G(`"server" must be an instance of URL`,Hi);let r=!e.href.includes(`/.well-known/`),i=t?.timeout??30,a=AbortSignal.timeout(1e3*i),o=await(r?Mn(e,{algorithm:t?.algorithm,[A]:t?.[W],[k]:t==null||(n=t.execute)==null?void 0:n.includes(ea),signal:a,headers:new Headers(H)}):(t?.[W]||fetch)((Un(e,t==null||(s=t.execute)==null||!s.includes(ea)),e.href),{headers:Object.fromEntries(new Headers(b({accept:`application/json`},H)).entries()),body:void 0,method:`GET`,redirect:`manual`,signal:a})).then(e=>async function(e,t){let n=e;if(!(n instanceof URL)&&n!==Wr)throw O(`"expectedIssuerIdentifier" must be an instance of URL`,D);if(!gn(t,Response))throw O(`"response" must be an instance of Response`,D);if(t.status!==200)throw N(`"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)`,Er,t);Pr(t);let r=await Ur(t);if(P(r.issuer,`"response" body "issuer" property`,L,{body:r}),n!==Wr&&new URL(r.issuer).href!==n.href)throw N(`"response" body "issuer" property does not match the expected value`,jr,{expected:n.href,body:r,attribute:`issuer`});return r}(Wr,e)).catch(q);var s;return r&&new URL(o.issuer).href!==e.href&&(function(e,t,n){return!(e.origin!==`https://login.microsoftonline.com`||n!=null&&n.algorithm&&n.algorithm!==`oidc`||(t[qi]=!0,0))}(e,o,t)||function(e,t){return!(!e.hostname.endsWith(`.b2clogin.com`)||t!=null&&t.algorithm&&t.algorithm!==`oidc`)}(e,t)||(()=>{throw new Gi(`discovered metadata issuer does not match the expected issuer`,{code:jr,cause:{expected:e.href,body:o,attribute:`issuer`}})})()),o}(e,i),t,n,r),o=U(a);if(i!=null&&i[W]&&(o.fetch=i[W]),i!=null&&i.timeout&&(o.timeout=i.timeout),i!=null&&i.execute)for(let e of i.execute)e(a);return a}new TextDecoder;var qi=Symbol(),Ji=class{constructor(e,t,n,r){if(typeof t!=`string`||!t.length)throw G(`"clientId" must be a non-empty string`,Hi);if(typeof n==`string`&&(n={client_secret:n}),n?.client_id!==void 0&&t!==n.client_id)throw G(`"clientId" and "metadata.client_id" must be the same`,Vi);let i=b(b({},structuredClone(n)),{},{client_id:t}),a;i[_n]=n?.[_n]??0,i[vn]=n?.[vn]??30,a=r||(typeof i.client_secret==`string`&&i.client_secret.length?Bi(i.client_secret):(e,t,n,r)=>{n.set(`client_id`,t.client_id)});let o=Object.freeze(i),s=structuredClone(e);qi in e&&(s[Gr]=t=>{let{claims:{tid:n}}=t;return e.issuer.replace(`{tenantid}`,n)});let c=Object.freeze(s);Ri||=new WeakMap,Ri.set(this,{__proto__:null,as:c,c:o,auth:a,tlsOnly:!0,jwksCache:{}})}serverMetadata(){let e=structuredClone(U(this).as);return function(e){Object.defineProperties(e,function(e){return{supportsPKCE:{__proto__:null,value(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`S256`;return!0===e.code_challenge_methods_supported?.includes(t)}}}}(e))}(e),e}clientMetadata(){return structuredClone(U(this).c)}get timeout(){return U(this).timeout}set timeout(e){U(this).timeout=e}get[W](){return U(this).fetch}set[W](e){U(this).fetch=e}};function Yi(e){Object.defineProperties(e,function(e){let t;if(e.expires_in!==void 0){let n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime()}return{expiresIn:{__proto__:null,value(){if(t){let e=Date.now();return t>e?Math.floor((t-e)/1e3):0}}},claims:{__proto__:null,value(){try{return lr(this)}catch{return}}}}}(e))}async function Xi(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0&&arguments[3],i=e.headers.get(`retry-after`)?.trim();if(i===void 0)return;let a;if(/^\d+$/.test(i))a=parseInt(i,10);else{let e=new Date(i);if(Number.isFinite(e.getTime())){let t=new Date,n=e.getTime()-t.getTime();n>0&&(a=Math.ceil(n/1e3))}}if(r&&!Number.isFinite(a))throw new En(`invalid Retry-After header value`,{cause:e});a>t&&await Zi(a-t,n)}function Zi(e,t){return new Promise((n,r)=>{let i=e=>{try{t.throwIfAborted()}catch(e){r(e);return}if(e<=0)return void n();let a=Math.min(e,5);setTimeout(()=>i(e-a),1e3*a)};i(e)})}async function Qi(e,t){oa(e);let{as:n,c:r,auth:i,fetch:a,tlsOnly:o,timeout:s}=U(e);return async function(e,t,n,r,i){F(e),I(t);let a=Gn(e,`backchannel_authentication_endpoint`,t.use_mtls_endpoint_aliases,!0!==i?.[k]),o=new URLSearchParams(r);o.set(`client_id`,t.client_id);let s=kn(i?.headers);return s.set(`accept`,`application/json`),ar(e,t,n,a,o,s,i)}(n,r,i,t,{[A]:a,[k]:!o,headers:new Headers(H),signal:sa(s)}).then(e=>async function(e,t,n){if(F(e),I(t),!gn(n,Response))throw O(`"response" must be an instance of Response`,D);await nr(n,200,`Backchannel Authentication Endpoint`),Pr(n);let r=await Ur(n);P(r.auth_req_id,`"response" body "auth_req_id" property`,L,{body:r});let i=typeof r.expires_in==`number`?r.expires_in:parseFloat(r.expires_in);return Nn(i,!0,`"response" body "expires_in" property`,L,{body:r}),r.expires_in=i,r.interval!==void 0&&Nn(r.interval,!1,`"response" body "interval" property`,L,{body:r}),r}(n,r,e)).catch(q)}async function $i(e,t,n,r){oa(e),n=new URLSearchParams(n);let i=t.interval??5,a=r?.signal??AbortSignal.timeout(1e3*t.expires_in);try{await Zi(i,a)}catch(e){q(e)}let{as:o,c:s,auth:c,fetch:l,tlsOnly:u,nonRepudiation:d,timeout:f,decrypt:p}=U(e),m=(i,o)=>$i(e,b(b({},t),{},{interval:i}),n,b(b({},r),{},{signal:a,flag:o})),h=await async function(e,t,n,r,i){F(e),I(t),P(r,`"authReqId"`);let a=new URLSearchParams(i?.additionalParameters);return a.set(`auth_req_id`,r),or(e,t,n,`urn:openid:params:grant-type:ciba`,a,i)}(o,s,c,t.auth_req_id,{[A]:l,[k]:!u,additionalParameters:n,DPoP:r?.DPoP,headers:new Headers(H),signal:a.aborted?a:sa(f)}).catch(q);if(h.status===503&&h.headers.has(`retry-after`))return await Xi(h,i,a,!0),await h.body?.cancel(),m(i);let g=async function(e,t,n,r){return ur(e,t,n,void 0,r?.[j],r?.recognizedTokenTypes)}(o,s,h,{[j]:p}),_;try{_=await g}catch(e){if(ca(e,r))return m(i,la);if(e instanceof Kn)switch(e.error){case`slow_down`:i+=5;case`authorization_pending`:return await Xi(e.response,i,a),m(i)}q(e)}return _.id_token&&await d?.(h),Yi(_),_}function ea(e){U(e).tlsOnly=!1}async function ta(e,t,n,r,i){if(oa(e),!(i?.flag===la||t instanceof URL||function(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch{return!1}}(t,`Request`)))throw G(`"currentUrl" must be an instance of URL, or Request`,Hi);let a,o,{as:s,c,auth:l,fetch:u,tlsOnly:d,jarm:f,hybrid:p,nonRepudiation:m,timeout:h,decrypt:g,implicit:_}=U(e);if(i?.flag===la)a=i.authResponse,o=i.redirectUri;else{if(!(t instanceof URL)){let e=t;switch(t=new URL(t.url),e.method){case`GET`:break;case`POST`:let n=new URLSearchParams(await Lr(e));if(p)t.hash=n.toString();else for(let[e,r]of n.entries())t.searchParams.append(e,r);break;default:throw G(`unexpected Request HTTP method`,Vi)}}switch(o=function(e){return(e=new URL(e)).search=``,e.hash=``,e.href}(t),!0){case!!f:a=await f(t,n?.expectedState);break;case!!p:a=await p(t,n?.expectedNonce,n?.expectedState,n?.maxAge);break;case!!_:throw TypeError(`authorizationCodeGrant() cannot be used by response_type=id_token clients`);default:try{a=Hr(s,c,t.searchParams,n?.expectedState)}catch(e){q(e)}}}let v=await async function(e,t,n,r,i,a,o){if(F(e),I(t),!pr.has(r))throw O(`"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()`,E);P(i,`"redirectUri"`);let s=zr(r,`code`);if(!s)throw N(`no authorization code in "callbackParameters"`,L);let c=new URLSearchParams(o?.additionalParameters);return c.set(`redirect_uri`,i),c.set(`code`,s),a!==mr&&(P(a,`"codeVerifier"`),c.set(`code_verifier`,a)),or(e,t,n,`authorization_code`,c,o)}(s,c,l,a,o,n?.pkceCodeVerifier||mr,{additionalParameters:r,[A]:u,[k]:!d,DPoP:i?.DPoP,headers:new Headers(H),signal:sa(h)}).catch(q);typeof n?.expectedNonce!=`string`&&typeof n?.maxAge!=`number`||(n.idTokenExpected=!0);let y=yr(s,c,v,{expectedNonce:n?.expectedNonce,maxAge:n?.maxAge,requireIdToken:n?.idTokenExpected,[j]:g}),ee;try{ee=await y}catch(t){if(ca(t,i))return ta(e,void 0,n,r,b(b({},i),{},{flag:la,authResponse:a,redirectUri:o}));q(t)}return ee.id_token&&await m?.(v),Yi(ee),ee}async function na(e,t,n,r){oa(e),n=new URLSearchParams(n);let{as:i,c:a,auth:o,fetch:s,tlsOnly:c,nonRepudiation:l,timeout:u,decrypt:d}=U(e),f=await async function(e,t,n,r,i){F(e),I(t),P(r,`"refreshToken"`);let a=new URLSearchParams(i?.additionalParameters);return a.set(`refresh_token`,r),or(e,t,n,`refresh_token`,a,i)}(i,a,o,t,{[A]:s,[k]:!c,additionalParameters:n,DPoP:r?.DPoP,headers:new Headers(H),signal:sa(u)}).catch(q),p=async function(e,t,n,r){return ur(e,t,n,void 0,r?.[j],r?.recognizedTokenTypes)}(i,a,f,{[j]:d}),m;try{m=await p}catch(i){if(ca(i,r))return na(e,t,n,b(b({},r),{},{flag:la}));q(i)}return m.id_token&&await l?.(f),Yi(m),m}async function ra(e,t,n){oa(e),t=new URLSearchParams(t);let{as:r,c:i,auth:a,fetch:o,tlsOnly:s,timeout:c}=U(e),l=async function(e,t,n,r){return ur(e,t,n,void 0,r?.[j],r?.recognizedTokenTypes)}(r,i,await async function(e,t,n,r,i){return F(e),I(t),or(e,t,n,`client_credentials`,new URLSearchParams(r),i)}(r,i,a,t,{[A]:o,[k]:!s,DPoP:n?.DPoP,headers:new Headers(H),signal:sa(c)}).catch(q)),u;try{u=await l}catch(r){if(ca(r,n))return ra(e,t,b(b({},n),{},{flag:la}));q(r)}return Yi(u),u}function ia(e,t){oa(e);let{as:n,c:r,tlsOnly:i,hybrid:a,jarm:o,implicit:s}=U(e),c=Gn(n,`authorization_endpoint`,!1,i);if((t=new URLSearchParams(t)).has(`client_id`)||t.set(`client_id`,r.client_id),!t.has(`request_uri`)&&!t.has(`request`)){if(t.has(`response_type`)||t.set(`response_type`,a?`code id_token`:s?`id_token`:`code`),s&&!t.has(`nonce`))throw G(`response_type=id_token clients must provide a nonce parameter in their authorization request parameters`,Vi);o&&t.set(`response_mode`,`jwt`)}for(let[e,n]of t.entries())c.searchParams.append(e,n);return c}async function aa(e,t,n){oa(e);let r=ia(e,t),{as:i,c:a,auth:o,fetch:s,tlsOnly:c,timeout:l}=U(e),u=async function(e,t,n){if(F(e),I(t),!gn(n,Response))throw O(`"response" must be an instance of Response`,D);await nr(n,201,`Pushed Authorization Request Endpoint`),Pr(n);let r=await Ur(n);P(r.request_uri,`"response" body "request_uri" property`,L,{body:r});let i=typeof r.expires_in==`number`?r.expires_in:parseFloat(r.expires_in);return Nn(i,!0,`"response" body "expires_in" property`,L,{body:r}),r.expires_in=i,r}(i,a,await async function(e,t,n,r,i){var a;F(e),I(t);let o=Gn(e,`pushed_authorization_request_endpoint`,t.use_mtls_endpoint_aliases,!0!==i?.[k]),s=new URLSearchParams(r);s.set(`client_id`,t.client_id);let c=kn(i?.headers);c.set(`accept`,`application/json`),i?.DPoP!==void 0&&(rr(i.DPoP),await i.DPoP.addProof(o,c,`POST`));let l=await ar(e,t,n,o,s,c,i);return i==null||(a=i.DPoP)==null||a.cacheNonce(l,o),l}(i,a,o,r.searchParams,{[A]:s,[k]:!c,DPoP:n?.DPoP,headers:new Headers(H),signal:sa(l)}).catch(q)),d;try{d=await u}catch(r){if(ca(r,n))return aa(e,t,b(b({},n),{},{flag:la}));q(r)}return ia(e,{request_uri:d.request_uri})}function oa(e){if(!(e instanceof Ji))throw G(`"config" must be an instance of Configuration`,Hi);if(Object.getPrototypeOf(e)!==Ji.prototype)throw G(`subclassing Configuration is not allowed`,Vi)}function sa(e){return e?AbortSignal.timeout(1e3*e):void 0}function ca(e,t){return!(t==null||!t.DPoP||t.flag===la)&&function(e){if(e instanceof Jn){let{0:t,length:n}=e.cause;return n===1&&t.scheme===`dpop`&&t.parameters.error===`use_dpop_nonce`}return e instanceof Kn&&e.error===`use_dpop_nonce`}(e)}Object.freeze(Ji.prototype);var la=Symbol();async function ua(e,t,n,r){oa(e);let{as:i,c:a,auth:o,fetch:s,tlsOnly:c,timeout:l,decrypt:u}=U(e),d=await async function(e,t,n,r,i,a){return F(e),I(t),P(r,`"grantType"`),or(e,t,n,r,new URLSearchParams(i),a)}(i,a,o,t,new URLSearchParams(n),{[A]:s,[k]:!c,DPoP:r?.DPoP,headers:new Headers(H),signal:sa(l)}).then(e=>{let n;return t===`urn:ietf:params:oauth:grant-type:token-exchange`&&(n={n_a:()=>{}}),async function(e,t,n,r){return ur(e,t,n,void 0,r?.[j],r?.recognizedTokenTypes)}(i,a,e,{[j]:u,recognizedTokenTypes:n})}).catch(q);return Yi(d),d}async function da(e,t,n){if(!hi(e))throw new V(`Flattened JWS must be an object`);if(e.protected===void 0&&e.header===void 0)throw new V(`Flattened JWS must have either of the "protected" or "header" members`);if(e.protected!==void 0&&typeof e.protected!=`string`)throw new V(`JWS Protected Header incorrect type`);if(e.payload===void 0)throw new V(`JWS Payload missing`);if(typeof e.signature!=`string`)throw new V(`JWS Signature missing or incorrect type`);if(e.header!==void 0&&!hi(e.header))throw new V(`JWS Unprotected Header incorrect type`);let r={};if(e.protected)try{let t=Xr(e.protected);r=JSON.parse(qr.decode(t))}catch{throw new V(`JWS Protected Header is invalid`)}if(!function(){let e=[...arguments].filter(Boolean);if(e.length===0||e.length===1)return!0;let t;for(let n of e){let e=Object.keys(n);if(t&&t.size!==0)for(let n of e){if(t.has(n))return!1;t.add(n)}else t=new Set(e)}return!0}(r,e.header))throw new V(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);let i=b(b({},r),e.header),a=function(e,t,n,r,i){if(i.crit!==void 0&&r?.crit===void 0)throw new e(`"crit" (Critical) Header Parameter MUST be integrity protected`);if(!r||r.crit===void 0)return new Set;if(!Array.isArray(r.crit)||r.crit.length===0||r.crit.some(e=>typeof e!=`string`||e.length===0))throw new e(`"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present`);let a;a=n===void 0?t:new Map([...Object.entries(n),...t.entries()]);for(let t of r.crit){if(!a.has(t))throw new B(`Extension Header Parameter "${t}" is not recognized`);if(i[t]===void 0)throw new e(`Extension Header Parameter "${t}" is missing`);if(a.get(t)&&r[t]===void 0)throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}return new Set(r.crit)}(V,new Map([[`b64`,!0]]),n?.crit,r,i),o=!0;if(a.has(`b64`)&&(o=r.b64,typeof o!=`boolean`))throw new V(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:s}=i;if(typeof s!=`string`||!s)throw new V(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);let c=n&&function(e,t){if(t!==void 0&&(!Array.isArray(t)||t.some(e=>typeof e!=`string`)))throw TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)}(`algorithms`,n.algorithms);if(c&&!c.has(s))throw new ii(`"alg" (Algorithm) Header Parameter value not allowed`);if(o){if(typeof e.payload!=`string`)throw new V(`JWS Payload must be a string`)}else if(typeof e.payload!=`string`&&!(e.payload instanceof Uint8Array))throw new V(`JWS Payload must be a string or an Uint8Array instance`);let l=!1;typeof t==`function`&&(t=await t(r,e),l=!0),Pi(s,t,`verify`);let u=function(){var e=[...arguments];let t=e.reduce((e,t)=>{let{length:n}=t;return e+n},0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}(e.protected===void 0?new Uint8Array:Jr(e.protected),Jr(`.`),typeof e.payload==`string`?o?Jr(e.payload):Kr.encode(e.payload):e.payload),d=mi(e.signature,`signature`,V),f=await wi(t,s);if(!await vi(s,f,d,u))throw new ui;let p;p=o?mi(e.payload,`payload`,V):typeof e.payload==`string`?Kr.encode(e.payload):e.payload;let m={payload:p};return e.protected!==void 0&&(m.protectedHeader=r),e.header!==void 0&&(m.unprotectedHeader=e.header),l?b(b({},m),{},{key:f}):m}var fa=86400,pa=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function ma(e){let t=pa.exec(e);if(!t||t[4]&&t[1])throw TypeError(`Invalid time period format`);let n=parseFloat(t[2]),r;switch(t[3].toLowerCase()){case`sec`:case`secs`:case`second`:case`seconds`:case`s`:r=Math.round(n);break;case`minute`:case`minutes`:case`min`:case`mins`:case`m`:r=Math.round(60*n);break;case`hour`:case`hours`:case`hr`:case`hrs`:case`h`:r=Math.round(3600*n);break;case`day`:case`days`:case`d`:r=Math.round(n*fa);break;case`week`:case`weeks`:case`w`:r=Math.round(604800*n);break;default:r=Math.round(31557600*n)}return t[1]===`-`||t[4]===`ago`?-r:r}var ha=e=>e.includes(`/`)?e.toLowerCase():`application/${e.toLowerCase()}`;function ga(e,t){let n,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};try{n=JSON.parse(qr.decode(t))}catch{}if(!hi(n))throw new ai(`JWT Claims Set must be a top-level JSON object`);let{typ:i}=r;if(i&&(typeof e.typ!=`string`||ha(e.typ)!==ha(i)))throw new z(`unexpected "typ" JWT header value`,n,`typ`,`check_failed`);let{requiredClaims:a=[],issuer:o,subject:s,audience:c,maxTokenAge:l}=r,u=[...a];l!==void 0&&u.push(`iat`),c!==void 0&&u.push(`aud`),s!==void 0&&u.push(`sub`),o!==void 0&&u.push(`iss`);for(let e of new Set(u.reverse()))if(!(e in n))throw new z(`missing required "${e}" claim`,n,e,`missing`);if(o&&!(Array.isArray(o)?o:[o]).includes(n.iss))throw new z(`unexpected "iss" claim value`,n,`iss`,`check_failed`);if(s&&n.sub!==s)throw new z(`unexpected "sub" claim value`,n,`sub`,`check_failed`);if(c&&(d=n.aud,f=typeof c==`string`?[c]:c,!(typeof d==`string`?f.includes(d):Array.isArray(d)&&f.some(Set.prototype.has.bind(new Set(d))))))throw new z(`unexpected "aud" claim value`,n,`aud`,`check_failed`);var d,f;let p;switch(typeof r.clockTolerance){case`string`:p=ma(r.clockTolerance);break;case`number`:p=r.clockTolerance;break;case`undefined`:p=0;break;default:throw TypeError(`Invalid clockTolerance option type`)}let{currentDate:m}=r,h=(g=m||new Date,Math.floor(g.getTime()/1e3));var g;if((n.iat!==void 0||l)&&typeof n.iat!=`number`)throw new z(`"iat" claim must be a number`,n,`iat`,`invalid`);if(n.nbf!==void 0){if(typeof n.nbf!=`number`)throw new z(`"nbf" claim must be a number`,n,`nbf`,`invalid`);if(n.nbf>h+p)throw new z(`"nbf" claim timestamp check failed`,n,`nbf`,`check_failed`)}if(n.exp!==void 0){if(typeof n.exp!=`number`)throw new z(`"exp" claim must be a number`,n,`exp`,`invalid`);if(n.exp<=h-p)throw new ri(`"exp" claim timestamp check failed`,n,`exp`,`check_failed`)}if(l){let e=h-n.iat;if(e-p>(typeof l==`number`?l:ma(l)))throw new ri(`"iat" claim timestamp check failed (too far in the past)`,n,`iat`,`check_failed`);if(e<0-p)throw new z(`"iat" claim timestamp check failed (it should be in the past)`,n,`iat`,`check_failed`)}return n}async function _a(e,t,n){var r;let i=await async function(e,t,n){if(e instanceof Uint8Array&&(e=qr.decode(e)),typeof e!=`string`)throw new V(`Compact JWS must be a string or Uint8Array`);let{0:r,1:i,2:a,length:o}=e.split(`.`);if(o!==3)throw new V(`Invalid Compact JWS`);let s=await da({payload:i,protected:r,signature:a},t,n),c={payload:s.payload,protectedHeader:s.protectedHeader};return typeof t==`function`?b(b({},c),{},{key:s.key}):c}(e,t,n);if((r=i.protectedHeader.crit)!=null&&r.includes(`b64`)&&!1===i.protectedHeader.b64)throw new ai(`JWTs MUST NOT use unencoded payload`);let a={payload:ga(i.protectedHeader,i.payload,n),protectedHeader:i.protectedHeader};return typeof t==`function`?b(b({},a),{},{key:i.key}):a}function va(e){return hi(e)}var ya,ba,xa=new WeakMap,Sa=new WeakMap,Ca=class{constructor(e){if(_(this,xa,void 0),_(this,Sa,new WeakMap),!function(e){return e&&typeof e==`object`&&Array.isArray(e.keys)&&e.keys.every(va)}(e))throw new oi(`JSON Web Key Set malformed`);v(xa,this,structuredClone(e))}jwks(){return g(xa,this)}async getKey(e,t){let{alg:n,kid:r}=b(b({},e),t?.header),i=function(e){switch(typeof e==`string`&&e.slice(0,2)){case`RS`:case`PS`:return`RSA`;case`ES`:return`EC`;case`Ed`:return`OKP`;case`ML`:return`AKP`;default:throw new B(`Unsupported "alg" value for a JSON Web Key Set`)}}(n),a=g(xa,this).keys.filter(e=>{let t=i===e.kty;if(t&&typeof r==`string`&&(t=r===e.kid),!t||typeof e.alg!=`string`&&i!==`AKP`||(t=n===e.alg),t&&typeof e.use==`string`&&(t=e.use===`sig`),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes(`verify`)),t)switch(n){case`ES256`:t=e.crv===`P-256`;break;case`ES384`:t=e.crv===`P-384`;break;case`ES512`:t=e.crv===`P-521`;break;case`Ed25519`:case`EdDSA`:t=e.crv===`Ed25519`}return t}),{0:o,length:s}=a;if(s===0)throw new si;if(s!==1){let e=new ci,t=g(Sa,this);throw e[Symbol.asyncIterator]=te(function*(){for(let e of a)try{yield yield m(wa(t,e,n))}catch{}}),e}return wa(g(Sa,this),o,n)}};async function wa(e,t,n){let r=e.get(t)||e.set(t,{}).get(t);if(r[n]===void 0){let e=await async function(e,t,n){if(!hi(e))throw TypeError(`JWK must be an object`);let r;switch(t??=e.alg,r??=n?.extractable??e.ext,e.kty){case`oct`:if(typeof e.k!=`string`||!e.k)throw TypeError(`missing "k" (Key Value) Parameter value`);return Xr(e.k);case`RSA`:if(`oth`in e&&e.oth!==void 0)throw new B(`RSA JWK "oth" (Other Primes Info) Parameter value is not supported`);return bi(b(b({},e),{},{alg:t,ext:r}));case`AKP`:if(typeof e.alg!=`string`||!e.alg)throw TypeError(`missing "alg" (Algorithm) Parameter value`);if(t!==void 0&&t!==e.alg)throw TypeError(`JWK alg and alg option value mismatch`);return bi(b(b({},e),{},{ext:r}));case`EC`:case`OKP`:return bi(b(b({},e),{},{alg:t,ext:r}));default:throw new B(`Unsupported "kty" (Key Type) Parameter value`)}}(b(b({},t),{},{ext:!0}),n);if(e instanceof Uint8Array||e.type!==`public`)throw new oi(`JSON Web Key Set members must be public keys`);r[n]=e}return r[n]}function Ta(e){let t=new Ca(e),n=async(e,n)=>t.getKey(e,n);return Object.defineProperties(n,{jwks:{value:()=>structuredClone(t.jwks()),enumerable:!1,configurable:!1,writable:!1}}),n}var Ea;(typeof navigator>`u`||(ya=navigator.userAgent)==null||(ba=ya.startsWith)==null||!ba.call(ya,`Mozilla/5.0 `))&&(Ea=`jose/v6.2.2`);var Da=Symbol(),Oa=Symbol(),ka=new WeakMap,Aa=new WeakMap,ja=new WeakMap,Ma=new WeakMap,Na=new WeakMap,Pa=new WeakMap,Fa=new WeakMap,Ia=new WeakMap,La=new WeakMap,Ra=new WeakMap,za=class{constructor(e,t){if(_(this,ka,void 0),_(this,Aa,void 0),_(this,ja,void 0),_(this,Ma,void 0),_(this,Na,void 0),_(this,Pa,void 0),_(this,Fa,void 0),_(this,Ia,void 0),_(this,La,void 0),_(this,Ra,void 0),!(e instanceof URL))throw TypeError(`url must be an instance of URL`);var n,r;v(ka,this,new URL(e.href)),v(Aa,this,typeof t?.timeoutDuration==`number`?t?.timeoutDuration:5e3),v(ja,this,typeof t?.cooldownDuration==`number`?t?.cooldownDuration:3e4),v(Ma,this,typeof t?.cacheMaxAge==`number`?t?.cacheMaxAge:6e5),v(Fa,this,new Headers(t?.headers)),Ea&&!g(Fa,this).has(`User-Agent`)&&g(Fa,this).set(`User-Agent`,Ea),g(Fa,this).has(`accept`)||(g(Fa,this).set(`accept`,`application/json`),g(Fa,this).append(`accept`,`application/jwk-set+json`)),v(Ia,this,t?.[Da]),t?.[Oa]!==void 0&&(v(Ra,this,t?.[Oa]),n=t?.[Oa],r=g(Ma,this),typeof n==`object`&&n&&`uat`in n&&typeof n.uat==`number`&&!(Date.now()-n.uat>=r)&&`jwks`in n&&hi(n.jwks)&&Array.isArray(n.jwks.keys)&&Array.prototype.every.call(n.jwks.keys,hi)&&(v(Na,this,g(Ra,this).uat),v(La,this,Ta(g(Ra,this).jwks))))}pendingFetch(){return!!g(Pa,this)}coolingDown(){return typeof g(Na,this)==`number`&&Date.now()<g(Na,this)+g(ja,this)}fresh(){return typeof g(Na,this)==`number`&&Date.now()<g(Na,this)+g(Ma,this)}jwks(){return g(La,this)?.jwks()}async getKey(e,t){g(La,this)&&this.fresh()||await this.reload();try{return await g(La,this).call(this,e,t)}catch(n){if(n instanceof si&&!1===this.coolingDown())return await this.reload(),g(La,this).call(this,e,t);throw n}}async reload(){g(Pa,this)&&(typeof WebSocketPair<`u`||typeof navigator<`u`&&navigator.userAgent===`Cloudflare-Workers`||typeof EdgeRuntime<`u`&&EdgeRuntime===`vercel`)&&v(Pa,this,void 0),g(Pa,this)||v(Pa,this,async function(e,t,n){let r=await(arguments.length>3&&arguments[3]!==void 0?arguments[3]:fetch)(e,{method:`GET`,signal:n,redirect:`manual`,headers:t}).catch(e=>{throw e.name===`TimeoutError`?new li:e});if(r.status!==200)throw new R(`Expected 200 OK from the JSON Web Key Set HTTP response`);try{return await r.json()}catch{throw new R(`Failed to parse the JSON Web Key Set HTTP response as JSON`)}}(g(ka,this).href,g(Fa,this),AbortSignal.timeout(g(Aa,this)),g(Ia,this)).then(e=>{v(La,this,Ta(e)),g(Ra,this)&&(g(Ra,this).uat=Date.now(),g(Ra,this).jwks=e),v(Na,this,Date.now()),v(Pa,this,void 0)}).catch(e=>{throw v(Pa,this,void 0),e})),await g(Pa,this)}},Ba=[`mfaToken`],Va=[`mfaToken`],Ha,Ua,Wa,J,Ga,Ka,Y,qa,Ja,X,Ya,Xa,Za,Qa,$a,Z,eo=class extends Error{constructor(e,t){super(t),y(this,`code`,void 0),this.name=`NotSupportedError`,this.code=e}},to=class extends Error{constructor(e,t,n){super(t),y(this,`cause`,void 0),y(this,`code`,void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},no=class extends to{constructor(e,t){super(`token_by_code_error`,e,t),this.name=`TokenByCodeError`}},ro=class extends to{constructor(e,t){super(`token_by_client_credentials_error`,e,t),this.name=`TokenByClientCredentialsError`}},io=class extends to{constructor(e,t){super(`token_by_refresh_token_error`,e,t),this.name=`TokenByRefreshTokenError`}},ao=class extends to{constructor(e,t){super(`token_by_password_error`,e,t),this.name=`TokenByPasswordError`}},oo=class extends to{constructor(e,t){super(`token_for_connection_error`,e,t),this.name=`TokenForConnectionErrorCode`}},so=class extends to{constructor(e,t){super(`token_exchange_error`,e,t),this.name=`TokenExchangeError`}},co=class extends Error{constructor(e){super(e),y(this,`code`,`verify_logout_token_error`),this.name=`VerifyLogoutTokenError`}},lo=class extends to{constructor(e){super(`backchannel_authentication_error`,`There was an error when trying to use Client-Initiated Backchannel Authentication.`,e),y(this,`code`,`backchannel_authentication_error`),this.name=`BackchannelAuthenticationError`}},uo=class extends to{constructor(e){super(`build_authorization_url_error`,`There was an error when trying to build the authorization URL.`,e),this.name=`BuildAuthorizationUrlError`}},fo=class extends to{constructor(e){super(`build_link_user_url_error`,`There was an error when trying to build the Link User URL.`,e),this.name=`BuildLinkUserUrlError`}},po=class extends to{constructor(e){super(`build_unlink_user_url_error`,`There was an error when trying to build the Unlink User URL.`,e),this.name=`BuildUnlinkUserUrlError`}},mo=class extends Error{constructor(){super(`The client secret or client assertion signing key must be provided.`),y(this,`code`,`missing_client_auth_error`),this.name=`MissingClientAuthError`}};function ho(e){return Object.entries(e).filter(e=>{let[,t]=e;return t!==void 0}).reduce((e,t)=>b(b({},e),{},{[t[0]]:t[1]}),{})}var go=class extends Error{constructor(e,t,n){super(t),y(this,`cause`,void 0),y(this,`code`,void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},_o=class extends go{constructor(e,t){super(`mfa_list_authenticators_error`,e,t),this.name=`MfaListAuthenticatorsError`}},vo=class extends go{constructor(e,t){super(`mfa_enrollment_error`,e,t),this.name=`MfaEnrollmentError`}},yo=class extends go{constructor(e,t){super(`mfa_delete_authenticator_error`,e,t),this.name=`MfaDeleteAuthenticatorError`}},bo=class extends go{constructor(e,t){super(`mfa_challenge_error`,e,t),this.name=`MfaChallengeError`}};function xo(e){return{id:e.id,authenticatorType:e.authenticator_type,active:e.active,name:e.name,oobChannels:e.oob_channels,type:e.type}}var So=(Ha=new WeakMap,Ua=new WeakMap,Wa=new WeakMap,class{constructor(e){_(this,Ha,void 0),_(this,Ua,void 0),_(this,Wa,void 0),v(Ha,this,`https://${e.domain}`),v(Ua,this,e.clientId),v(Wa,this,e.customFetch??function(){return fetch(...arguments)})}async listAuthenticators(e){let t=`${g(Ha,this)}/mfa/authenticators`,{mfaToken:n}=e,r=await g(Wa,this).call(this,t,{method:`GET`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`}});if(!r.ok){let e=await r.json();throw new _o(e.error_description||`Failed to list authenticators`,e)}return(await r.json()).map(xo)}async enrollAuthenticator(e){let t=`${g(Ha,this)}/mfa/associate`,{mfaToken:n}=e,r=x(e,Ba),i={authenticator_types:r.authenticatorTypes};`oobChannels`in r&&(i.oob_channels=r.oobChannels),`phoneNumber`in r&&r.phoneNumber&&(i.phone_number=r.phoneNumber),`email`in r&&r.email&&(i.email=r.email);let a=await g(Wa,this).call(this,t,{method:`POST`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`},body:JSON.stringify(i)});if(!a.ok){let e=await a.json();throw new vo(e.error_description||`Failed to enroll authenticator`,e)}return function(e){if(e.authenticator_type===`otp`)return{authenticatorType:`otp`,secret:e.secret,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes,id:e.id};if(e.authenticator_type===`oob`)return{authenticatorType:`oob`,oobChannel:e.oob_channel,oobCode:e.oob_code,bindingMethod:e.binding_method,id:e.id,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes};throw Error(`Unexpected authenticator type: ${e.authenticator_type}`)}(await a.json())}async deleteAuthenticator(e){let{authenticatorId:t,mfaToken:n}=e,r=`${g(Ha,this)}/mfa/authenticators/${encodeURIComponent(t)}`,i=await g(Wa,this).call(this,r,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`}});if(!i.ok){let e=await i.json();throw new yo(e.error_description||`Failed to delete authenticator`,e)}}async challengeAuthenticator(e){let t=`${g(Ha,this)}/mfa/challenge`,{mfaToken:n}=e,r=x(e,Va),i={mfa_token:n,client_id:g(Ua,this),challenge_type:r.challengeType};r.authenticatorId&&(i.authenticator_id=r.authenticatorId);let a=await g(Wa,this).call(this,t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)});if(!a.ok){let e=await a.json();throw new bo(e.error_description||`Failed to challenge authenticator`,e)}return function(e){let t={challengeType:e.challenge_type};return e.oob_code!==void 0&&(t.oobCode=e.oob_code),e.binding_method!==void 0&&(t.bindingMethod=e.binding_method),t}(await a.json())}}),Co=class e{constructor(e,t,n,r,i,a,o){y(this,`accessToken`,void 0),y(this,`idToken`,void 0),y(this,`refreshToken`,void 0),y(this,`expiresAt`,void 0),y(this,`scope`,void 0),y(this,`claims`,void 0),y(this,`authorizationDetails`,void 0),y(this,`tokenType`,void 0),y(this,`issuedTokenType`,void 0),this.accessToken=e,this.idToken=n,this.refreshToken=r,this.expiresAt=t,this.scope=i,this.claims=a,this.authorizationDetails=o}static fromTokenEndpointResponse(t){let n=t.id_token?t.claims():void 0,r=new e(t.access_token,Math.floor(Date.now()/1e3)+Number(t.expires_in),t.id_token,t.refresh_token,t.scope,n,t.authorization_details);return r.tokenType=t.token_type,r.issuedTokenType=t.issued_token_type,r}},wo=(J=new WeakMap,Ga=new WeakMap,Ka=new WeakMap,class{constructor(e,t){_(this,J,new Map),_(this,Ga,void 0),_(this,Ka,void 0),v(Ka,this,Math.max(1,Math.floor(e))),v(Ga,this,Math.max(0,Math.floor(t)))}get(e){let t=g(J,this).get(e);if(t){if(!(Date.now()>=t.expiresAt))return g(J,this).delete(e),g(J,this).set(e,t),t.value;g(J,this).delete(e)}}set(e,t){for(g(J,this).has(e)&&g(J,this).delete(e),g(J,this).set(e,{value:t,expiresAt:Date.now()+g(Ga,this)});g(J,this).size>g(Ka,this);){let e=g(J,this).keys().next().value;if(e===void 0)break;g(J,this).delete(e)}}}),To=new Map;function Eo(e){return{ttlMs:1e3*(typeof e?.ttl==`number`?e.ttl:600),maxEntries:typeof e?.maxEntries==`number`&&e.maxEntries>0?e.maxEntries:100}}var Do=class{static createDiscoveryCache(e){let t=(n=e.maxEntries,r=e.ttlMs,`${n}:${r}`);var n,r;let i=(a=t,To.get(a));var a;return i||(i=new wo(e.maxEntries,e.ttlMs),To.set(t,i)),i}static createJwksCache(){return{}}},Oo=`openid profile email offline_access`,ko=Object.freeze(new Set([`grant_type`,`client_id`,`client_secret`,`client_assertion`,`client_assertion_type`,`subject_token`,`subject_token_type`,`requested_token_type`,`actor_token`,`actor_token_type`,`audience`,`aud`,`resource`,`resources`,`resource_indicator`,`scope`,`connection`,`login_hint`,`organization`,`assertion`]));function Ao(e){if(e==null)throw new so(`subject_token is required`);if(typeof e!=`string`)throw new so(`subject_token must be a string`);if(e.trim().length===0)throw new so(`subject_token cannot be blank or whitespace`);if(e!==e.trim())throw new so(`subject_token must not include leading or trailing whitespace`);if(/^bearer\s+/i.test(e))throw new so(`subject_token must not include the 'Bearer ' prefix`)}function jo(e,t){if(t){for(let[n,r]of Object.entries(t))if(!ko.has(n))if(Array.isArray(r)){if(r.length>20)throw new so(`Parameter '${n}' exceeds maximum array size of 20`);r.forEach(t=>{e.append(n,t)})}else e.append(n,r)}}var Mo=`urn:ietf:params:oauth:token-type:access_token`,No=(Y=new WeakMap,qa=new WeakMap,Ja=new WeakMap,X=new WeakMap,Ya=new WeakMap,Xa=new WeakMap,Za=new WeakMap,Qa=new WeakMap,$a=new WeakMap,Z=new WeakSet,class{constructor(e){var t;if(function(e,t){h(e,t),t.add(e)}(this,Z),_(this,Y,void 0),_(this,qa,void 0),_(this,Ja,void 0),_(this,X,void 0),_(this,Ya,void 0),_(this,Xa,void 0),_(this,Za,void 0),_(this,Qa,void 0),_(this,$a,void 0),y(this,`mfa`,void 0),v(X,this,e),e.useMtls&&!e.customFetch)throw new eo(`mtls_without_custom_fetch_not_supported`,`Using mTLS without a custom fetch implementation is not supported`);v(Ya,this,function(e,t){if(!1===t.enabled)return e;let n={name:t.name,version:t.version},r=btoa(JSON.stringify(n));return async(t,n)=>{let i=t instanceof Request?new Headers(t.headers):new Headers;return n!=null&&n.headers&&new Headers(n.headers).forEach((e,t)=>{i.set(t,e)}),i.set(`Auth0-Client`,r),e(t,b(b({},n),{},{headers:i}))}}(e.customFetch??function(){return fetch(...arguments)},!1===(t=e.telemetry)?.enabled?t:{enabled:!0,name:t?.name??`@auth0/auth0-auth-js`,version:t?.version??`1.6.0`}));let n=Eo(e.discoveryCache);v(Za,this,Do.createDiscoveryCache(n)),v(Qa,this,new Map),v($a,this,Do.createJwksCache()),this.mfa=new So({domain:g(X,this).domain,clientId:g(X,this).clientId,customFetch:g(Ya,this)})}async getServerMetadata(){let{serverMetadata:e}=await p(Z,this,Q).call(this);return e}async buildAuthorizationUrl(e){let{serverMetadata:t}=await p(Z,this,Q).call(this);if(e!=null&&e.pushedAuthorizationRequests&&!t.pushed_authorization_request_endpoint)throw new eo(`par_not_supported_error`,`The Auth0 tenant does not have pushed authorization requests enabled. Learn how to enable it here: https://auth0.com/docs/get-started/applications/configure-par`);try{return await p(Z,this,zo).call(this,e)}catch(e){throw new uo(e)}}async buildLinkUserUrl(e){try{let t=await p(Z,this,zo).call(this,{authorizationParams:b(b({},e.authorizationParams),{},{requested_connection:e.connection,requested_connection_scope:e.connectionScope,scope:`openid link_account offline_access`,id_token_hint:e.idToken})});return{linkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(e){throw new fo(e)}}async buildUnlinkUserUrl(e){try{let t=await p(Z,this,zo).call(this,{authorizationParams:b(b({},e.authorizationParams),{},{requested_connection:e.connection,scope:`openid unlink_account`,id_token_hint:e.idToken})});return{unlinkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(e){throw new po(e)}}async backchannelAuthentication(e){let{configuration:t,serverMetadata:n}=await p(Z,this,Q).call(this),r=ho(b(b({},g(X,this).authorizationParams),e?.authorizationParams)),i=new URLSearchParams(b(b({scope:Oo},r),{},{client_id:g(X,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:`iss_sub`,iss:n.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&i.append(`requested_expiry`,e.requestedExpiry.toString()),e.authorizationDetails&&i.append(`authorization_details`,JSON.stringify(e.authorizationDetails));try{let e=await $i(t,await Qi(t,i));return Co.fromTokenEndpointResponse(e)}catch(e){throw new lo(e)}}async initiateBackchannelAuthentication(e){let{configuration:t,serverMetadata:n}=await p(Z,this,Q).call(this),r=ho(b(b({},g(X,this).authorizationParams),e?.authorizationParams)),i=new URLSearchParams(b(b({scope:Oo},r),{},{client_id:g(X,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:`iss_sub`,iss:n.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&i.append(`requested_expiry`,e.requestedExpiry.toString()),e.authorizationDetails&&i.append(`authorization_details`,JSON.stringify(e.authorizationDetails));try{let e=await Qi(t,i);return{authReqId:e.auth_req_id,expiresIn:e.expires_in,interval:e.interval}}catch(e){throw new lo(e)}}async backchannelAuthenticationGrant(e){let{authReqId:t}=e,{configuration:n}=await p(Z,this,Q).call(this),r=new URLSearchParams({auth_req_id:t});try{let e=await ua(n,`urn:openid:params:grant-type:ciba`,r);return Co.fromTokenEndpointResponse(e)}catch(e){throw new lo(e)}}async getTokenForConnection(e){if(e.refreshToken&&e.accessToken)throw new oo(`Either a refresh or access token should be specified, but not both.`);let t=e.accessToken??e.refreshToken;if(!t)throw new oo(`Either a refresh or access token must be specified.`);try{return await this.exchangeToken({connection:e.connection,subjectToken:t,subjectTokenType:e.accessToken?Mo:`urn:ietf:params:oauth:token-type:refresh_token`,loginHint:e.loginHint})}catch(e){throw e instanceof so?new oo(e.message,e.cause):e}}async exchangeToken(e){return`connection`in e?p(Z,this,Io).call(this,e):p(Z,this,Lo).call(this,e)}async getTokenByCode(e,t){let{configuration:n}=await p(Z,this,Q).call(this);try{let r=await ta(n,e,{pkceCodeVerifier:t.codeVerifier});return Co.fromTokenEndpointResponse(r)}catch(e){throw new no(`There was an error while trying to request a token.`,e)}}async getTokenByRefreshToken(e){let{configuration:t}=await p(Z,this,Q).call(this),n=new URLSearchParams;e.audience&&n.append(`audience`,e.audience),e.scope&&n.append(`scope`,e.scope);try{let r=await na(t,e.refreshToken,n);return Co.fromTokenEndpointResponse(r)}catch(e){throw new io(`The access token has expired and there was an error while trying to refresh it.`,e)}}async getTokenByPassword(e){let{configuration:t}=await p(Z,this,Q).call(this),n=new URLSearchParams({username:e.username,password:e.password});e.audience&&n.append(`audience`,e.audience),e.scope&&n.append(`scope`,e.scope),e.realm&&n.append(`realm`,e.realm);let r=t;if(e.auth0ForwardedFor){let n=await p(Z,this,Ro).call(this);r=new Ji(t.serverMetadata(),g(X,this).clientId,g(X,this).clientSecret,n),r[W]=(t,n)=>g(Ya,this).call(this,t,b(b({},n),{},{headers:b(b({},n.headers),{},{"auth0-forwarded-for":e.auth0ForwardedFor})}))}try{let e=await ua(r,`password`,n);return Co.fromTokenEndpointResponse(e)}catch(e){throw new ao(`There was an error while trying to request a token.`,e)}}async getTokenByClientCredentials(e){let{configuration:t}=await p(Z,this,Q).call(this);try{let n=new URLSearchParams({audience:e.audience});e.organization&&n.append(`organization`,e.organization);let r=await ra(t,n);return Co.fromTokenEndpointResponse(r)}catch(e){throw new ro(`There was an error while trying to request a token.`,e)}}async buildLogoutUrl(e){let{configuration:t,serverMetadata:n}=await p(Z,this,Q).call(this);if(!n.end_session_endpoint){let t=new URL(`https://${g(X,this).domain}/v2/logout`);return t.searchParams.set(`returnTo`,e.returnTo),t.searchParams.set(`client_id`,g(X,this).clientId),t}return function(e,t){oa(e);let{as:n,c:r,tlsOnly:i}=U(e),a=Gn(n,`end_session_endpoint`,!1,i);(t=new URLSearchParams(t)).has(`client_id`)||t.set(`client_id`,r.client_id);for(let[e,n]of t.entries())a.searchParams.append(e,n);return a}(t,{post_logout_redirect_uri:e.returnTo})}async verifyLogoutToken(e){let{serverMetadata:t}=await p(Z,this,Q).call(this),n=Eo(g(X,this).discoveryCache),r=t.jwks_uri;g(Xa,this)||v(Xa,this,function(e,t){let n=new za(e,t),r=async(e,t)=>n.getKey(e,t);return Object.defineProperties(r,{coolingDown:{get:()=>n.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>n.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>n.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>n.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>n.jwks(),enumerable:!0,configurable:!1,writable:!1}}),r}(new URL(r),{cacheMaxAge:n.ttlMs,[Da]:g(Ya,this),[Oa]:g($a,this)}));let{payload:i}=await _a(e.logoutToken,g(Xa,this),{issuer:t.issuer,audience:g(X,this).clientId,algorithms:[`RS256`],requiredClaims:[`iat`]});if(!(`sid`in i)&&!(`sub`in i))throw new co(`either "sid" or "sub" (or both) claims must be present`);if(`sid`in i&&typeof i.sid!=`string`)throw new co(`"sid" claim must be a string`);if(`sub`in i&&typeof i.sub!=`string`)throw new co(`"sub" claim must be a string`);if(`nonce`in i)throw new co(`"nonce" claim is prohibited`);if(!(`events`in i))throw new co(`"events" claim is missing`);if(typeof i.events!=`object`||i.events===null)throw new co(`"events" claim must be an object`);if(!(`http://schemas.openid.net/event/backchannel-logout`in i.events))throw new co(`"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim`);if(typeof i.events[`http://schemas.openid.net/event/backchannel-logout`]!=`object`)throw new co(`"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object`);return{sid:i.sid,sub:i.sub}}});function Po(){return`${g(X,this).domain.toLowerCase()}|mtls:${g(X,this).useMtls?`1`:`0`}`}async function Fo(e){let t=await p(Z,this,Ro).call(this),n=new Ji(e,g(X,this).clientId,g(X,this).clientSecret,t);return n[W]=g(Ya,this),n}async function Q(){if(g(Y,this)&&g(qa,this))return{configuration:g(Y,this),serverMetadata:g(qa,this)};let e=p(Z,this,Po).call(this),t=g(Za,this).get(e);if(t)return v(qa,this,t.serverMetadata),v(Y,this,await p(Z,this,Fo).call(this,t.serverMetadata)),{configuration:g(Y,this),serverMetadata:g(qa,this)};let n=g(Qa,this).get(e);if(n){let e=await n;return v(qa,this,e.serverMetadata),v(Y,this,await p(Z,this,Fo).call(this,e.serverMetadata)),{configuration:g(Y,this),serverMetadata:g(qa,this)}}let r=(async()=>{let t=await p(Z,this,Ro).call(this),n=await Ki(new URL(`https://${g(X,this).domain}`),g(X,this).clientId,{use_mtls_endpoint_aliases:g(X,this).useMtls},t,{[W]:g(Ya,this)}),r=n.serverMetadata();return g(Za,this).set(e,{serverMetadata:r}),{configuration:n,serverMetadata:r}})(),i=r.then(e=>{let{serverMetadata:t}=e;return{serverMetadata:t}});i.catch(()=>{}),g(Qa,this).set(e,i);try{let{configuration:e,serverMetadata:t}=await r;v(Y,this,e),v(qa,this,t),g(Y,this)[W]=g(Ya,this)}finally{g(Qa,this).delete(e)}return{configuration:g(Y,this),serverMetadata:g(qa,this)}}async function Io(e){let{configuration:t}=await p(Z,this,Q).call(this);if(`audience`in e||`resource`in e)throw new so(`audience and resource parameters are not supported for Token Vault exchanges`);Ao(e.subjectToken);let n=new URLSearchParams({connection:e.connection,subject_token:e.subjectToken,subject_token_type:e.subjectTokenType??Mo,requested_token_type:e.requestedTokenType??`http://auth0.com/oauth/token-type/federated-connection-access-token`});e.loginHint&&n.append(`login_hint`,e.loginHint),e.scope&&n.append(`scope`,e.scope),jo(n,e.extra);try{let e=await ua(t,`urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token`,n);return Co.fromTokenEndpointResponse(e)}catch(t){throw new so(`Failed to exchange token for connection '${e.connection}'.`,t)}}async function Lo(e){let{configuration:t}=await p(Z,this,Q).call(this);Ao(e.subjectToken);let n=new URLSearchParams({subject_token_type:e.subjectTokenType,subject_token:e.subjectToken});e.audience&&n.append(`audience`,e.audience),e.scope&&n.append(`scope`,e.scope),e.requestedTokenType&&n.append(`requested_token_type`,e.requestedTokenType),e.organization&&n.append(`organization`,e.organization),jo(n,e.extra);try{let e=await ua(t,`urn:ietf:params:oauth:grant-type:token-exchange`,n);return Co.fromTokenEndpointResponse(e)}catch(t){throw new so(`Failed to exchange token of type '${e.subjectTokenType}'${e.audience?` for audience '${e.audience}'`:``}.`,t)}}async function Ro(){return g(Ja,this)||v(Ja,this,(async()=>{if(!g(X,this).clientSecret&&!g(X,this).clientAssertionSigningKey&&!g(X,this).useMtls)throw new mo;if(g(X,this).useMtls)return(e,t,n,r)=>{n.set(`client_id`,t.client_id)};let e=g(X,this).clientAssertionSigningKey;return!e||e instanceof CryptoKey||(e=await async function(e,t,n){if(typeof e!=`string`||e.indexOf(`-----BEGIN PRIVATE KEY-----`)!==0)throw TypeError(`"pkcs8" must be PKCS#8 formatted string`);return ji(e,t,n)}(e,g(X,this).clientAssertionSigningAlg||`RS256`)),e?function(e,t){return Vn(e,t)}(e):Bi(g(X,this).clientSecret)})().catch(e=>{throw v(Ja,this,void 0),e})),g(Ja,this)}async function zo(e){let{configuration:t}=await p(Z,this,Q).call(this),n=Wi(),r=await Ui(n),i=ho(b(b({},g(X,this).authorizationParams),e?.authorizationParams)),a=new URLSearchParams(b(b({scope:Oo},i),{},{client_id:g(X,this).clientId,code_challenge:r,code_challenge_method:`S256`}));return{authorizationUrl:e!=null&&e.pushedAuthorizationRequests?await aa(t,a):await ia(t,a),codeVerifier:n}}var Bo=class e extends C{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}static fromPayload(t){let{error:n,error_description:r}=t;return new e(n,r)}},Vo=class e extends Bo{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},Ho=class e extends Bo{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},Uo=class e extends Bo{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},Wo=class e extends Bo{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},Go=class e extends Bo{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},Ko=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:6e5;y(this,`contexts`,new Map),y(this,`ttlMs`,void 0),this.ttlMs=e}set(e,t){this.cleanup(),this.contexts.set(e,b(b({},t),{},{createdAt:Date.now()}))}get(e){let t=this.contexts.get(e);if(t){if(!(Date.now()-t.createdAt>this.ttlMs))return t;this.contexts.delete(e)}}remove(e){this.contexts.delete(e)}cleanup(){let e=Date.now();for(let[t,n]of this.contexts)e-n.createdAt>this.ttlMs&&this.contexts.delete(t)}get size(){return this.contexts.size}},qo=class{constructor(e,t){y(this,`authJsMfaClient`,void 0),y(this,`auth0Client`,void 0),y(this,`contextManager`,void 0),this.authJsMfaClient=e,this.auth0Client=t,this.contextManager=new Ko}setMFAAuthDetails(e,t,n,r){this.contextManager.set(e,{scope:t,audience:n,mfaRequirements:r})}async getAuthenticators(e){var t;let n=this.contextManager.get(e);if(n==null||(t=n.mfaRequirements)==null||!t.challenge||n.mfaRequirements.challenge.length===0)throw new Vo(`invalid_request`,`challengeType is required and must contain at least one challenge type, please check mfa_required error payload`);let r=n.mfaRequirements.challenge.map(e=>e.type);try{return(await this.authJsMfaClient.listAuthenticators({mfaToken:e})).filter(e=>!!e.type&&r.includes(e.type))}catch(e){throw e instanceof _o?new Vo(e.cause?.error,e.message):e}}async enroll(e){let t=function(e){let t=ln[e.factorType];return b(b(b({mfaToken:e.mfaToken,authenticatorTypes:t.authenticatorTypes},t.oobChannels&&{oobChannels:t.oobChannels}),`phoneNumber`in e&&{phoneNumber:e.phoneNumber}),`email`in e&&{email:e.email})}(e);try{return await this.authJsMfaClient.enrollAuthenticator(t)}catch(e){throw e instanceof vo?new Ho(e.cause?.error,e.message):e}}async challenge(e){try{let t={challengeType:e.challengeType,mfaToken:e.mfaToken};return e.authenticatorId&&(t.authenticatorId=e.authenticatorId),await this.authJsMfaClient.challengeAuthenticator(t)}catch(e){throw e instanceof bo?new Uo(e.cause?.error,e.message):e}}async getEnrollmentFactors(e){let t=this.contextManager.get(e);if(!t||!t.mfaRequirements)throw new Go(`mfa_context_not_found`,`MFA context not found for this MFA token. Please retry the original request to get a new MFA token.`);return t.mfaRequirements.enroll&&t.mfaRequirements.enroll.length!==0?t.mfaRequirements.enroll:[]}async verify(e){let t=this.contextManager.get(e.mfaToken);if(!t)throw new Wo(`mfa_context_not_found`,`MFA context not found for this MFA token. Please retry the original request to get a new MFA token.`);let n=function(e){return`otp`in e&&e.otp?un:`oobCode`in e&&e.oobCode?dn:`recoveryCode`in e&&e.recoveryCode?fn:void 0}(e);if(!n)throw new Wo(`invalid_request`,`Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.`);let r=t.scope,i=t.audience;try{let t=await this.auth0Client._requestTokenForMfa({grant_type:n,mfaToken:e.mfaToken,scope:r,audience:i,otp:e.otp,oob_code:e.oobCode,binding_code:e.bindingCode,recovery_code:e.recoveryCode});return this.contextManager.remove(e.mfaToken),t}catch(e){if(e instanceof pe)this.setMFAAuthDetails(e.mfa_token,r,i,e.mfa_requirements);else if(e instanceof Wo)throw new Wo(e.error,e.error_description);throw e}}},Jo=[`openUrl`,`fragment`,`appState`],Yo=[`url`],Xo=[`cacheMode`],Zo=[`federated`],Qo=[`openUrl`],$o=[`id_token`,`decodedToken`],es=[`mfaToken`],ts=class{constructor(e){let t,n;if(y(this,`transactionManager`,void 0),y(this,`cacheManager`,void 0),y(this,`lockManager`,void 0),y(this,`domainUrl`,void 0),y(this,`tokenIssuer`,void 0),y(this,`scope`,void 0),y(this,`cookieStorage`,void 0),y(this,`dpop`,void 0),y(this,`sessionCheckExpiryDays`,void 0),y(this,`orgHintCookieName`,void 0),y(this,`isAuthenticatedCookieName`,void 0),y(this,`nowProvider`,void 0),y(this,`httpTimeoutMs`,void 0),y(this,`options`,void 0),y(this,`userCache`,new St().enclosedCache),y(this,`myAccountApi`,void 0),y(this,`mfa`,void 0),y(this,`worker`,void 0),y(this,`authJsClient`,void 0),y(this,`defaultOptions`,{authorizationParams:{scope:`openid profile email`},useRefreshTokensFallback:!1,useFormData:!0}),this.options=b(b(b({},this.defaultOptions),e),{},{authorizationParams:b(b({},this.defaultOptions.authorizationParams),e.authorizationParams)}),typeof window<`u`&&(()=>{if(!ye())throw Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(ye().subtle===void 0)throw Error(`
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.
`)})(),this.lockManager=(He||=Ve(),He),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)n=e.cache;else{if(t=e.cacheLocation||ie,!Qt(t))throw Error(`Invalid cache location "${t}"`);n=Qt(t)()}var r;this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=!1===e.legacySameSiteCookie?It:Rt,this.orgHintCookieName=(r=this.options.clientId,`auth0.${r}.organization_hint`),this.isAuthenticatedCookieName=(e=>`auth0.${e}.is.authenticated`)(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;let i=e.useCookiesForTransactions?this.cookieStorage:zt;var a;this.scope=function(e,t){var n=[...arguments].slice(2);if(typeof e!=`object`)return{[S]:gt(t,e,...n)};let r={[S]:gt(t,...n)};return Object.keys(e).forEach(i=>{let a=e[i];r[i]=gt(t,a,...n)}),r}(this.options.authorizationParams.scope,`openid`,this.options.useRefreshTokens?`offline_access`:``),this.transactionManager=new wt(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||oe,this.cacheManager=new Ct(n,n.allKeys?void 0:new Jt(n,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new rn(this.options.clientId):void 0,this.domainUrl=(a=this.options.domain,/^https?:\/\//.test(a)?a:`https://${a}`),this.tokenIssuer=((e,t)=>e?e.startsWith(`https://`)?e:`https://${e}/`:`${t}/`)(this.options.issuer,this.domainUrl);let o=`${this.domainUrl}/me/`;this.myAccountApi=new sn(this.createFetcher(b(b({},this.options.useDpop&&{dpopNonceId:`__auth0_my_account_api__`}),{},{getAccessToken:()=>this.getTokenSilently({authorizationParams:{scope:`create:me:connected_accounts`,audience:o},detailedResponse:!0})})),o),this.authJsClient=new No({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new qo(this.authJsClient.mfa,this),typeof window<`u`&&window.Worker&&this.options.useRefreshTokens&&t===ie&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new Kt,this.worker.postMessage({type:`init`,allowedBaseUrl:this.domainUrl}))}getConfiguration(){return Object.freeze({domain:this.options.domain,clientId:this.options.clientId})}_url(e){let t=Ce(this.options.auth0Client||ae,!0),n=encodeURIComponent(btoa(JSON.stringify(t)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${we(e)}`)}async _verifyIdToken(e,t,n){let r=await this.nowProvider();return Dt({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:t,organization:n,leeway:this.options.leeway,max_age:(i=this.options.authorizationParams.max_age,typeof i==`string`?parseInt(i,10)||void 0:i),now:r});var i}_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})}_extractSessionTransferToken(e){return new URLSearchParams(window.location.search).get(e)||void 0}_clearSessionTransferTokenFromUrl(e){try{let t=new URL(window.location.href);t.searchParams.has(e)&&(t.searchParams.delete(e),window.history.replaceState({},``,t.toString()))}catch{}}_applySessionTransferToken(e){let t=this.options.sessionTransferTokenQueryParamName;if(!t||e.session_transfer_token)return e;let n=this._extractSessionTransferToken(t);return n?(this._clearSessionTransferTokenFromUrl(t),b(b({},e),{},{session_transfer_token:n})):e}async _prepareAuthorizeUrl(e,t,n){let r=xe(be()),i=xe(be()),a=be(),o=De(await Te(a)),s=await this.dpop?.calculateThumbprint(),c=((e,t,n,r,i,a,o,s,c)=>b(b(b({client_id:e.clientId},e.authorizationParams),n),{},{scope:_t(t,n.scope,n.audience),response_type:`code`,response_mode:s||`query`,state:r,nonce:i,redirect_uri:o||e.authorizationParams.redirect_uri,code_challenge:a,code_challenge_method:`S256`,dpop_jkt:c}))(this.options,this.scope,e,r,i,o,e.redirect_uri||this.options.authorizationParams.redirect_uri||n,t?.response_mode,s),l=this._authorizeUrl(c);return{nonce:i,code_verifier:a,scope:c.scope,audience:c.audience||S,redirect_uri:c.redirect_uri,state:r,url:l}}async loginWithPopup(e,t){if(e||={},!(t||={}).popup&&(t.popup=(e=>{let t=window.screenX+(window.innerWidth-400)/2,n=window.screenY+(window.innerHeight-600)/2;return window.open(e,`auth0:authorize:popup`,`left=${t},top=${n},width=400,height=600,resizable,scrollbars=yes,status=1`)})(``),!t.popup))throw new fe;let n=this._applySessionTransferToken(e.authorizationParams||{}),r=await this._prepareAuthorizeUrl(n,{response_mode:`web_message`},window.location.origin);t.popup.location.href=r.url;let i=await((e,t)=>new Promise((n,r)=>{let i,a=setInterval(()=>{e.popup&&e.popup.closed&&(clearInterval(a),clearTimeout(o),window.removeEventListener(`message`,i,!1),r(new de(e.popup)))},1e3),o=setTimeout(()=>{clearInterval(a),r(new ue(e.popup)),window.removeEventListener(`message`,i,!1)},1e3*(e.timeoutInSeconds||60));i=function(s){if(s.origin===t&&s.data&&s.data.type===`authorization_response`){if(clearTimeout(o),clearInterval(a),window.removeEventListener(`message`,i,!1),!1!==e.closePopup&&e.popup.close(),s.data.response.error)return r(C.fromPayload(s.data.response));n(s.data.response)}},window.addEventListener(`message`,i)}))(b(b({},t),{},{timeoutInSeconds:t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),new URL(r.url).origin);if(r.state!==i.state)throw new C(`state_mismatch`,`Invalid state`);let a=e.authorizationParams?.organization||this.options.authorizationParams.organization;await this._requestToken({audience:r.audience,scope:r.scope,code_verifier:r.code_verifier,grant_type:`authorization_code`,code:i.code,redirect_uri:r.redirect_uri},{nonceIn:r.nonce,organization:a})}async getUser(){var e;let t=await this._getIdTokenFromCache();return t==null||(e=t.decodedToken)==null?void 0:e.user}async getIdTokenClaims(){var e;let t=await this._getIdTokenFromCache();return t==null||(e=t.decodedToken)==null?void 0:e.claims}async loginWithRedirect(){let e=$t(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),{openUrl:t,fragment:n,appState:r}=e,i=x(e,Jo),a=i.authorizationParams?.organization||this.options.authorizationParams.organization,o=this._applySessionTransferToken(i.authorizationParams||{}),s=await this._prepareAuthorizeUrl(o),{url:c}=s,l=x(s,Yo);this.transactionManager.create(b(b({},l),{},{appState:r,response_type:Bt.Code},a&&{organization:a}));let u=n?`${c}#${n}`:c;t?await t(u):window.location.assign(u)}async handleRedirectCallback(){let e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.location.href).split(`?`).slice(1);if(e.length===0)throw Error(`There are no query params available for parsing.`);let t=this.transactionManager.get();if(!t)throw new C(`missing_transaction`,`Invalid state`);this.transactionManager.remove();let n=(e=>{e.indexOf(`#`)>-1&&(e=e.substring(0,e.indexOf(`#`)));let t=new URLSearchParams(e);return{state:t.get(`state`),code:t.get(`code`)||void 0,connect_code:t.get(`connect_code`)||void 0,error:t.get(`error`)||void 0,error_description:t.get(`error_description`)||void 0}})(e.join(``));return t.response_type===Bt.ConnectCode?this._handleConnectAccountRedirectCallback(n,t):this._handleLoginRedirectCallback(n,t)}async _handleLoginRedirectCallback(e,t){let{code:n,state:r,error:i,error_description:a}=e;if(i)throw new se(i,a||i,r,t.appState);if(!t.code_verifier||t.state&&t.state!==r)throw new C(`state_mismatch`,`Invalid state`);let o=t.organization,s=t.nonce,c=t.redirect_uri;return await this._requestToken(b({audience:t.audience,scope:t.scope,code_verifier:t.code_verifier,grant_type:`authorization_code`,code:n},c?{redirect_uri:c}:{}),{nonceIn:s,organization:o}),{appState:t.appState,response_type:Bt.Code}}async _handleConnectAccountRedirectCallback(e,t){let{connect_code:n,state:r,error:i,error_description:a}=e;if(i)throw new ce(i,a||i,t.connection,r,t.appState);if(!n)throw new C(`missing_connect_code`,`Missing connect code`);if(!(t.code_verifier&&t.state&&t.auth_session&&t.redirect_uri&&t.state===r))throw new C(`state_mismatch`,`Invalid state`);return b(b({},await this.myAccountApi.completeAccount({auth_session:t.auth_session,connect_code:n,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier})),{},{appState:t.appState,response_type:Bt.ConnectCode})}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get(Xt))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(Xt)}try{await this.getTokenSilently(e)}catch{}}async getTokenSilently(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=b(b({cacheMode:`on`},e),{},{authorizationParams:b(b(b({},this.options.authorizationParams),e.authorizationParams),{},{scope:_t(this.scope,e.authorizationParams?.scope,e.authorizationParams?.audience||this.options.authorizationParams.audience)})}),n=await((e,t)=>{let n=qt[t];return n||(n=e().finally(()=>{delete qt[t],n=null}),qt[t]=n),n})(()=>this._getTokenSilently(t),`${this.options.clientId}::${t.authorizationParams.audience}::${t.authorizationParams.scope}`);return e.detailedResponse?n:n?.access_token}async _getTokenSilently(e){let{cacheMode:t}=e,n=x(e,Xo);if(t!==`off`){let e=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||S,clientId:this.options.clientId,cacheMode:t});if(e)return e}if(t===`cache-only`)return;let r=(i=this.options.clientId,a=n.authorizationParams.audience||`default`,`auth0.lock.getTokenSilently.${i}.${a}`);var i,a;try{return await this.lockManager.runWithLock(r,5e3,async()=>{if(t!==`off`){let e=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||S,clientId:this.options.clientId});if(e)return e}let{id_token:e,token_type:r,access_token:i,oauthTokenScope:a,expires_in:o}=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(n):await this._getTokenFromIFrame(n);return b(b({id_token:e,token_type:r,access_token:i},a?{scope:a}:null),{},{expires_in:o})})}catch(e){if(this._isInteractiveError(e)&&this.options.interactiveErrorHandler===`popup`)return await this._handleInteractiveErrorWithPopup(n);throw e}}_isInteractiveError(e){return e instanceof pe||e instanceof C&&this._isIframeMfaError(e)}_isIframeMfaError(e){return e.error===`login_required`&&e.error_description===`Multifactor authentication required`}async _handleInteractiveErrorWithPopup(e){try{await this.loginWithPopup({authorizationParams:e.authorizationParams});let t=await this._getEntryFromCache({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||S,clientId:this.options.clientId});if(!t)throw new C(`interactive_handler_cache_miss`,`Token not found in cache after interactive authentication`);return t}catch(e){throw e}}async getTokenWithPopup(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=b(b({},e),{},{authorizationParams:b(b(b({},this.options.authorizationParams),e.authorizationParams),{},{scope:_t(this.scope,e.authorizationParams?.scope,e.authorizationParams?.audience||this.options.authorizationParams.audience)})});return t=b(b({},re),t),await this.loginWithPopup(n,t),(await this.cacheManager.get(new bt({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||S,clientId:this.options.clientId}),void 0,this.options.useMrrt)).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(e){e.clientId===null?delete e.clientId:e.clientId=e.clientId||this.options.clientId;let t=e.logoutParams||{},{federated:n}=t,r=x(t,Zo),i=n?`&federated`:``;return this._url(`/v2/logout?${we(b({clientId:e.clientId},r))}`)+i}async logout(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=$t(e),{openUrl:n}=t,r=x(t,Qo);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(yt),await this.dpop?.clear();let i=this._buildLogoutUrl(r);n?await n(i):!1!==n&&window.location.assign(i)}async _getTokenFromIFrame(e){let t=(n=this.options.clientId,`auth0.lock.getTokenFromIFrame.${n}`);var n;try{return await this.lockManager.runWithLock(t,5e3,async()=>{let t=b(b({},e.authorizationParams),{},{prompt:`none`}),n=this.cookieStorage.get(this.orgHintCookieName);n&&!t.organization&&(t.organization=n);let{url:r,state:i,nonce:a,code_verifier:o,redirect_uri:s,scope:c,audience:l}=await this._prepareAuthorizeUrl(t,{response_mode:`web_message`},window.location.origin);if(window.crossOriginIsolated)throw new C(`login_required`,`The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.`);let u=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,d;try{d=new URL(this.domainUrl).origin}catch{d=this.domainUrl}let f=await function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:60;return new Promise((r,i)=>{let a=window.document.createElement(`iframe`);a.setAttribute(`width`,`0`),a.setAttribute(`height`,`0`),a.style.display=`none`;let o=()=>{window.document.body.contains(a)&&(window.document.body.removeChild(a),window.removeEventListener(`message`,s,!1))},s,c=setTimeout(()=>{i(new le),o()},1e3*n);s=function(e){if(e.origin!=t||!e.data||e.data.type!==`authorization_response`)return;let n=e.source;n&&n.close(),e.data.response.error?i(C.fromPayload(e.data.response)):r(e.data.response),clearTimeout(c),window.removeEventListener(`message`,s,!1),setTimeout(o,2e3)},window.addEventListener(`message`,s,!1),window.document.body.appendChild(a),a.setAttribute(`src`,e)})}(r,d,u);if(i!==f.state)throw new C(`state_mismatch`,`Invalid state`);let p=await this._requestToken(b(b({},e.authorizationParams),{},{code_verifier:o,code:f.code,grant_type:`authorization_code`,redirect_uri:s,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:t.organization});return b(b({},p),{},{scope:c,oauthTokenScope:p.scope,audience:l})})}catch(e){throw e.error===`login_required`&&(e instanceof C&&this._isIframeMfaError(e)&&this.options.interactiveErrorHandler===`popup`||this.logout({openUrl:!1})),e}}async _getTokenUsingRefreshToken(e){let t=await this.cacheManager.get(new bt({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||S,clientId:this.options.clientId}),void 0,this.options.useMrrt);if(!(t&&t.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw new me(e.authorizationParams.audience||S,e.authorizationParams.scope)}let n=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,r=typeof e.timeoutInSeconds==`number`?1e3*e.timeoutInSeconds:null,i=((e,t,n,r)=>{if(e&&n&&r){if(t.audience!==n)return t.scope;let e=r.split(` `),i=t.scope?.split(` `)||[],a=i.every(t=>e.includes(t));return e.length>=i.length&&a?r:t.scope}return t.scope})(this.options.useMrrt,e.authorizationParams,t?.audience,t?.scope);try{let l=await this._requestToken(b(b({},e.authorizationParams),{},{grant_type:`refresh_token`,refresh_token:t&&t.refresh_token,redirect_uri:n},r&&{timeout:r}),{scopesToRequest:i});if(l.refresh_token&&t!=null&&t.refresh_token&&await this.cacheManager.updateEntry(t.refresh_token,l.refresh_token),this.options.useMrrt&&(a=t?.audience,o=t?.scope,s=e.authorizationParams.audience,c=e.authorizationParams.scope,(a!==s||!en(c,o))&&!en(i,l.scope))){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);await this.cacheManager.remove(this.options.clientId,e.authorizationParams.audience,e.authorizationParams.scope);let t=((e,t)=>{let n=e?.split(` `)||[],r=t?.split(` `)||[];return n.filter(e=>r.indexOf(e)==-1).join(`,`)})(i,l.scope);throw new he(e.authorizationParams.audience||`default`,t)}return b(b({},l),{},{scope:e.authorizationParams.scope,oauthTokenScope:l.scope,audience:e.authorizationParams.audience||S})}catch(t){if(t.message){if(t.message.includes(`user is blocked`))throw await this.logout({openUrl:!1}),t;if((t.message.includes(`Missing Refresh Token`)||t.message.includes(`invalid refresh token`))&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e)}throw t instanceof pe&&this.mfa.setMFAAuthDetails(t.mfa_token,e.authorizationParams?.scope,e.authorizationParams?.audience,t.mfa_requirements),t}var a,o,s,c}async _saveEntryInCache(e){let{id_token:t,decodedToken:n}=e,r=x(e,$o);this.userCache.set(yt,{id_token:t,decodedToken:n}),await this.cacheManager.setIdToken(this.options.clientId,e.id_token,e.decodedToken),await this.cacheManager.set(r)}async _getIdTokenFromCache(){let e=this.options.authorizationParams.audience||S,t=this.scope[e],n=await this.cacheManager.getIdToken(new bt({clientId:this.options.clientId,audience:e,scope:t})),r=this.userCache.get(yt);return n&&n.id_token===r?.id_token?r:(this.userCache.set(yt,n),n)}async _getEntryFromCache(e){let{scope:t,audience:n,clientId:r,cacheMode:i}=e,a=await this.cacheManager.get(new bt({scope:t,audience:n,clientId:r}),60,this.options.useMrrt,i);if(a&&a.access_token){let{token_type:e,access_token:t,oauthTokenScope:n,expires_in:r}=a,i=await this._getIdTokenFromCache();return i&&b(b({id_token:i.id_token,token_type:e||`Bearer`,access_token:t},n?{scope:n}:null),{},{expires_in:r})}}async _requestToken(e,t){let{nonceIn:n,organization:r,scopesToRequest:i}=t||{},a=await ht(b(b({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,useMrrt:this.options.useMrrt,dpop:this.dpop},e),{},{scope:i||e.scope}),this.worker),o=await this._verifyIdToken(a.id_token,n,r);if(e.grant_type===`authorization_code`){var s;let e=await this._getIdTokenFromCache();e!=null&&(s=e.decodedToken)!=null&&(s=s.claims)!=null&&s.sub&&e.decodedToken.claims.sub!==o.claims.sub&&(await this.cacheManager.clear(this.options.clientId),this.userCache.remove(yt))}return await this._saveEntryInCache(b(b(b({},a),{},{decodedToken:o,scope:e.scope,audience:e.audience||S},a.scope?{oauthTokenScope:a.scope}:null),{},{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(r||o.claims.org_id),b(b({},a),{},{decodedToken:o})}async loginWithCustomTokenExchange(e){return this._requestToken(b(b({},e),{},{grant_type:`urn:ietf:params:oauth:grant-type:token-exchange`,subject_token:e.subject_token,subject_token_type:e.subject_token_type,scope:_t(this.scope,e.scope,e.audience||this.options.authorizationParams.audience),audience:e.audience||this.options.authorizationParams.audience,organization:e.organization||this.options.authorizationParams.organization}))}async exchangeToken(e){return this.loginWithCustomTokenExchange(e)}_assertDpop(e){if(!e)throw Error("`useDpop` option must be enabled before using DPoP.")}getDpopNonce(e){return this._assertDpop(this.dpop),this.dpop.getNonce(e)}setDpopNonce(e,t){return this._assertDpop(this.dpop),this.dpop.setNonce(e,t)}generateDpopProof(e){return this._assertDpop(this.dpop),this.dpop.generateProof(e)}createFetcher(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new on(e,{isDpopEnabled:()=>!!this.options.useDpop,getAccessToken:e=>{var t;return this.getTokenSilently({authorizationParams:{scope:e==null||(t=e.scope)==null?void 0:t.join(` `),audience:e?.audience},detailedResponse:!0})},getDpopNonce:()=>this.getDpopNonce(e.dpopNonceId),setDpopNonce:t=>this.setDpopNonce(t,e.dpopNonceId),generateDpopProof:e=>this.generateDpopProof(e)})}async connectAccountWithRedirect(e){let{openUrl:t,appState:n,connection:r,scopes:i,authorization_params:a,redirectUri:o=this.options.authorizationParams.redirect_uri||window.location.origin}=e;if(!r)throw Error(`connection is required`);let s=xe(be()),c=be(),l=De(await Te(c)),{connect_uri:u,connect_params:d,auth_session:f}=await this.myAccountApi.connectAccount({connection:r,scopes:i,redirect_uri:o,state:s,code_challenge:l,code_challenge_method:`S256`,authorization_params:a});this.transactionManager.create({state:s,code_verifier:c,auth_session:f,redirect_uri:o,appState:n,connection:r,response_type:Bt.ConnectCode});let p=new URL(u);p.searchParams.set(`ticket`,d.ticket),t?await t(p.toString()):window.location.assign(p)}async _requestTokenForMfa(e,t){let{mfaToken:n}=e,r=x(e,es);return this._requestToken(b(b({},r),{},{mfa_token:n}),t)}},ns={isAuthenticated:!1,isLoading:!0,error:void 0,user:void 0},$=function(){throw Error(`You forgot to wrap your component in <Auth0Provider>.`)},rs=s(s({},ns),{buildAuthorizeUrl:$,buildLogoutUrl:$,getAccessTokenSilently:$,getAccessTokenWithPopup:$,getIdTokenClaims:$,loginWithCustomTokenExchange:$,exchangeToken:$,loginWithRedirect:$,loginWithPopup:$,connectAccountWithRedirect:$,logout:$,handleRedirectCallback:$,getDpopNonce:$,setDpopNonce:$,generateDpopProof:$,createFetcher:$,getConfiguration:$,mfa:{getAuthenticators:$,enroll:$,challenge:$,verify:$,getEnrollmentFactors:$}}),is=(0,i.createContext)(rs),as=function(e){o(t,e);function t(n,r){var i=e.call(this,r??n)||this;return i.error=n,i.error_description=r,Object.setPrototypeOf(i,t.prototype),i}return t}(Error),os=/[?&](?:connect_)?code=[^&]+/,ss=/[?&]state=[^&]+/,cs=/[?&]error=[^&]+/,ls=function(e){return e===void 0&&(e=window.location.search),(os.test(e)||cs.test(e))&&ss.test(e)},us=function(e){return function(t){if(t instanceof Error)return t;if(typeof t==`object`&&t&&`error`in t&&typeof t.error==`string`){if(`error_description`in t&&typeof t.error_description==`string`){var n=t;return new as(n.error,n.error_description)}return new as(t.error)}return Error(e)}},ds=us(`Login failed`),fs=us(`Get access token failed`),ps=function(e){e?.redirectUri&&(console.warn("Using `redirectUri` has been deprecated, please use `authorizationParams.redirect_uri` instead as `redirectUri` will be no longer supported in a future version"),e.authorizationParams=e.authorizationParams??{},e.authorizationParams.redirect_uri=e.redirectUri,delete e.redirectUri),e?.authorizationParams?.redirectUri&&(console.warn("Using `authorizationParams.redirectUri` has been deprecated, please use `authorizationParams.redirect_uri` instead as `authorizationParams.redirectUri` will be removed in a future version"),e.authorizationParams.redirect_uri=e.authorizationParams.redirectUri,delete e.authorizationParams.redirectUri)},ms=function(e,t){switch(t.type){case`LOGIN_POPUP_STARTED`:return s(s({},e),{isLoading:!0});case`LOGIN_POPUP_COMPLETE`:case`INITIALISED`:return s(s({},e),{isAuthenticated:!!t.user,user:t.user,isLoading:!1,error:void 0});case`HANDLE_REDIRECT_COMPLETE`:case`GET_ACCESS_TOKEN_COMPLETE`:return e.user===t.user?e:s(s({},e),{isAuthenticated:!!t.user,user:t.user});case`LOGOUT`:return s(s({},e),{isAuthenticated:!1,user:void 0});case`ERROR`:return s(s({},e),{isLoading:!1,error:t.error})}},hs=function(e){return ps(e),s(s({},e),{auth0Client:{name:`auth0-react`,version:`2.16.1`}})},gs=function(e){window.history.replaceState({},document.title,e.returnTo??window.location.pathname)},_s=function(e){var t=e,n=t.children,r=t.skipRedirectCallback,a=t.onRedirectCallback,o=a===void 0?gs:a,f=t.context,p=f===void 0?is:f,m=t.client,h=c(t,[`children`,`skipRedirectCallback`,`onRedirectCallback`,`context`,`client`]);m&&(h.domain||h.clientId)&&console.warn("Auth0Provider: the `client` prop takes precedence over `domain`/`clientId` and other configuration options. Remove `domain`, `clientId`, and any other Auth0Client configuration props when using the `client` prop.");var g=(0,i.useState)(function(){return m??new ts(hs(h))})[0],_=(0,i.useReducer)(ms,ns),v=_[0],y=_[1],ee=(0,i.useRef)(!1),b=(0,i.useCallback)(function(e){return y({type:`ERROR`,error:e}),e},[]);(0,i.useEffect)(function(){ee.current||(ee.current=!0,(function(){return l(void 0,void 0,void 0,function(){var e,t,n,i,a,s,l;return u(this,function(u){switch(u.label){case 0:return u.trys.push([0,7,,8]),e=void 0,ls()&&!r?[4,g.handleRedirectCallback()]:[3,3];case 1:return t=u.sent(),n=t.appState,i=n===void 0?{}:n,a=t.response_type,s=c(t,[`appState`,`response_type`]),[4,g.getUser()];case 2:return e=u.sent(),i.response_type=a,a===Bt.ConnectCode&&(i.connectedAccount=s),o(i,e),[3,6];case 3:return[4,g.checkSession()];case 4:return u.sent(),[4,g.getUser()];case 5:e=u.sent(),u.label=6;case 6:return y({type:`INITIALISED`,user:e}),[3,8];case 7:return l=u.sent(),b(ds(l)),[3,8];case 8:return[2]}})})})())},[g,o,r,b]);var x=(0,i.useCallback)(function(e){return ps(e),g.loginWithRedirect(e)},[g]),te=(0,i.useCallback)(function(e,t){return l(void 0,void 0,void 0,function(){var n,r;return u(this,function(i){switch(i.label){case 0:y({type:`LOGIN_POPUP_STARTED`}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,g.loginWithPopup(e,t)];case 2:return i.sent(),[3,4];case 3:return n=i.sent(),b(ds(n)),[2];case 4:return[4,g.getUser()];case 5:return r=i.sent(),y({type:`LOGIN_POPUP_COMPLETE`,user:r}),[2]}})})},[g,b]),ne=(0,i.useCallback)(function(){return l(void 0,d([],[...arguments],!0),void 0,function(e){return e===void 0&&(e={}),u(this,function(t){switch(t.label){case 0:return[4,g.logout(e)];case 1:return t.sent(),(e.openUrl||e.openUrl===!1)&&y({type:`LOGOUT`}),[2]}})})},[g]),re=(0,i.useCallback)(function(e){return l(void 0,void 0,void 0,function(){var t,n,r,i;return u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,3,5]),[4,g.getTokenSilently(e)];case 1:return t=a.sent(),[3,5];case 2:throw n=a.sent(),fs(n);case 3:return r=y,i={type:`GET_ACCESS_TOKEN_COMPLETE`},[4,g.getUser()];case 4:return r.apply(void 0,[(i.user=a.sent(),i)]),[7];case 5:return[2,t]}})})},[g]),ie=(0,i.useCallback)(function(e,t){return l(void 0,void 0,void 0,function(){var n,r,i,a;return u(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,3,5]),[4,g.getTokenWithPopup(e,t)];case 1:return n=o.sent(),[3,5];case 2:throw r=o.sent(),fs(r);case 3:return i=y,a={type:`GET_ACCESS_TOKEN_COMPLETE`},[4,g.getUser()];case 4:return i.apply(void 0,[(a.user=o.sent(),a)]),[7];case 5:return[2,n]}})})},[g]),ae=(0,i.useCallback)(function(e){return g.connectAccountWithRedirect(e)},[g]),oe=(0,i.useCallback)(function(){return g.getIdTokenClaims()},[g]),S=(0,i.useCallback)(function(e){return l(void 0,void 0,void 0,function(){var t,n,r,i;return u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,3,5]),[4,g.loginWithCustomTokenExchange(e)];case 1:return t=a.sent(),[3,5];case 2:throw n=a.sent(),fs(n);case 3:return r=y,i={type:`GET_ACCESS_TOKEN_COMPLETE`},[4,g.getUser()];case 4:return r.apply(void 0,[(i.user=a.sent(),i)]),[7];case 5:return[2,t]}})})},[g]),C=(0,i.useCallback)(function(e){return l(void 0,void 0,void 0,function(){return u(this,function(t){return[2,S(e)]})})},[S]),se=(0,i.useCallback)(function(e){return l(void 0,void 0,void 0,function(){var t,n,r;return u(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,3,5]),[4,g.handleRedirectCallback(e)];case 1:return[2,i.sent()];case 2:throw t=i.sent(),fs(t);case 3:return n=y,r={type:`HANDLE_REDIRECT_COMPLETE`},[4,g.getUser()];case 4:return n.apply(void 0,[(r.user=i.sent(),r)]),[7];case 5:return[2]}})})},[g]),ce=(0,i.useCallback)(function(e){return g.getDpopNonce(e)},[g]),le=(0,i.useCallback)(function(e,t){return g.setDpopNonce(e,t)},[g]),ue=(0,i.useCallback)(function(e){return g.generateDpopProof(e)},[g]),de=(0,i.useCallback)(function(e){return g.createFetcher(e)},[g]),fe=(0,i.useCallback)(function(){return g.getConfiguration()},[g]),pe=(0,i.useMemo)(function(){return g.mfa},[g]),me=(0,i.useMemo)(function(){return s(s({},v),{getAccessTokenSilently:re,getAccessTokenWithPopup:ie,getIdTokenClaims:oe,loginWithCustomTokenExchange:S,exchangeToken:C,loginWithRedirect:x,loginWithPopup:te,connectAccountWithRedirect:ae,logout:ne,handleRedirectCallback:se,getDpopNonce:ce,setDpopNonce:le,generateDpopProof:ue,createFetcher:de,getConfiguration:fe,mfa:pe})},[v,re,ie,oe,S,C,x,te,ae,ne,se,ce,le,ue,de,fe,pe]);return i.createElement(p.Provider,{value:me},n)},vs=function(e){return e===void 0&&(e=is),(0,i.useContext)(e)};export{vs as n,_s as t};