1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4170],{5074:function(e,t,n){let r,o,i,a,s,c,u,l,d;n.r(t),n.d(t,{Auth0Context:function(){return oQ},Auth0Provider:function(){return o7},AuthenticationError:function(){return D},ConnectError:function(){return L},GenericError:function(){return j},InMemoryCache:function(){return eS},LocalStorageCache:function(){return ek},MfaRequiredError:function(){return z},MissingRefreshTokenError:function(){return H},OAuthError:function(){return o$},PopupCancelledError:function(){return N},PopupTimeoutError:function(){return K},ResponseType:function(){return eN},TimeoutError:function(){return U},UseDpopNonceError:function(){return J},User:function(){return eU},initialContext:function(){return oY},useAuth0:function(){return ie},withAuth0:function(){return it},withAuthenticationRequired:function(){return ii}});var h=n(2265),p=function(e,t){return(p=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])})(e,t)},f=function(){return(f=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function m(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)0>t.indexOf(r[o])&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function y(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})}function g(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function w(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)0>t.indexOf(r[o])&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}"function"==typeof SuppressedError&&SuppressedError,"function"==typeof SuppressedError&&SuppressedError;var v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{},b={},_={};Object.defineProperty(_,"__esModule",{value:!0});var k=function(){function e(){var e=this;this.locked=new Map,this.addToLocked=function(t,n){var r=e.locked.get(t);void 0===r?void 0===n?e.locked.set(t,[]):e.locked.set(t,[n]):void 0!==n&&(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(void 0!==n&&0!==n.length){var r=n.pop();e.locked.set(t,n),void 0!==r&&setTimeout(r,0)}else e.locked.delete(t)}}return e.getInstance=function(){return void 0===e.instance&&(e.instance=new e),e.instance},e}();_.default=function(){return k.getInstance()};
1var S=v&&v.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}c((r=r.apply(e,t||[])).next())})},E=v&&v.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(b,"__esModule",{value:!0});var T={key:function(e){return S(v,void 0,void 0,function(){return E(this,function(e){throw Error("Unsupported")})})},getItem:function(e){return S(v,void 0,void 0,function(){return E(this,function(e){throw Error("Unsupported")})})},clear:function(){return S(v,void 0,void 0,function(){return E(this,function(e){return[2,window.localStorage.clear()]})})},removeItem:function(e){return S(v,void 0,void 0,function(){return E(this,function(e){throw Error("Unsupported")})})},setItem:function(e,t){return S(v,void 0,void 0,function(){return E(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 A(e){return new Promise(function(t){return setTimeout(t,e)})}function P(e){for(var t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",n="",r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}var R=function(){function e(t){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+P(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=t,void 0===e.waiters&&(e.waiters=[])}return e.prototype.acquireLock=function(t,n){return void 0===n&&(n=5e3),S(this,void 0,void 0,function(){var r,o,i,a,s,c,u;return E(this,function(l){switch(l.label){case 0:r=Date.now()+P(4),o=Date.now()+n,i="browser-tabs-lock-key-"+t,a=void 0===this.storageHandler?T:this.storageHandler,l.label=1;case 1:return Date.now()<o?[4,A(30)]:[3,8];case 2:return l.sent(),null!==a.getItemSync(i)?[3,5]:(s=this.id+"-"+t+"-"+r,[4,A(Math.floor(25*Math.random()))]);case 3:return l.sent(),a.setItemSync(i,JSON.stringify({id:this.id,iat:r,timeoutKey:s,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,A(30)];case 4:return l.sent(),null!==(c=a.getItemSync(i))&&(u=JSON.parse(c)).id===this.id&&u.iat===r?(this.acquiredIatSet.add(r),this.refreshLockWhileAcquired(i,r),[2,!0]):[3,7];case 5:return e.lockCorrector(void 0===this.storageHandler?T:this.storageHandler),[4,this.waitForSomethingToChange(o)];case 6:l.sent(),l.label=7;case 7:return r=Date.now()+P(4),[3,1];case 8:return[2,!1]}})})},e.prototype.refreshLockWhileAcquired=function(e,t){return S(this,void 0,void 0,function(){var n=this;return E(this,function(r){return setTimeout(function(){return S(n,void 0,void 0,function(){var n,r,o;return E(this,function(i){switch(i.label){case 0:return[4,_.default().lock(t)];case 1:return i.sent(),this.acquiredIatSet.has(t)?null===(r=(n=void 0===this.storageHandler?T:this.storageHandler).getItemSync(e))?_.default().unlock(t):((o=JSON.parse(r)).timeRefreshed=Date.now(),n.setItemSync(e,JSON.stringify(o)),_.default().unlock(t),this.refreshLockWhileAcquired(e,t)):_.default().unlock(t),[2]}})})},1e3),[2]})})},e.prototype.waitForSomethingToChange=function(t){return S(this,void 0,void 0,function(){return E(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){var r=!1,o=Date.now(),i=!1;function a(){if(i||(window.removeEventListener("storage",a),e.removeFromWaiting(a),clearTimeout(s),i=!0),!r){r=!0;var t=50-(Date.now()-o);t>0?setTimeout(n,t):n(null)}}window.addEventListener("storage",a),e.addToWaiting(a);var s=setTimeout(a,Math.max(0,t-Date.now()))})];case 1:return n.sent(),[2]}})})},e.addToWaiting=function(t){this.removeFromWaiting(t),void 0!==e.waiters&&e.waiters.push(t)},e.removeFromWaiting=function(t){void 0!==e.waiters&&(e.waiters=e.waiters.filter(function(e){return e!==t}))},e.notifyWaiters=function(){void 0!==e.waiters&&e.waiters.slice().forEac
1h(function(e){return e()})},e.prototype.releaseLock=function(e){return S(this,void 0,void 0,function(){return E(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 S(this,void 0,void 0,function(){var n,r,o,i;return E(this,function(a){switch(a.label){case 0:return n=void 0===this.storageHandler?T:this.storageHandler,r="browser-tabs-lock-key-"+t,null===(o=n.getItemSync(r))?[2]:(i=JSON.parse(o)).id!==this.id?[3,2]:[4,_.default().lock(i.iat)];case 1:a.sent(),this.acquiredIatSet.delete(i.iat),n.removeItemSync(r),_.default().unlock(i.iat),e.notifyWaiters(),a.label=2;case 2:return[2]}})})},e.lockCorrector=function(t){for(var n=Date.now()-5e3,r=[],o=0;;){var i=t.keySync(o);if(null===i)break;r.push(i),o++}for(var a=!1,s=0;s<r.length;s++){var c=r[s];if(c.includes("browser-tabs-lock-key")){var u=t.getItemSync(c);if(null!==u){var l=JSON.parse(u);(void 0===l.timeRefreshed&&l.timeAcquired<n||void 0!==l.timeRefreshed&&l.timeRefreshed<n)&&(t.removeItemSync(c),a=!0)}}}a&&e.notifyWaiters()},e.waiters=void 0,e}(),I=b.default=R;let O={timeoutInSeconds:60},C={name:"auth0-spa-js",version:"2.14.0"},x=()=>Date.now();class j extends Error{constructor(e,t){super(t),this.error=e,this.error_description=t,Object.setPrototypeOf(this,j.prototype)}static fromPayload(e){let{error:t,error_description:n}=e;return new j(t,n)}}class D extends j{constructor(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;super(e,t),this.state=n,this.appState=r,Object.setPrototypeOf(this,D.prototype)}}class L extends j{constructor(e,t,n,r){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;super(e,t),this.connection=n,this.state=r,this.appState=o,Object.setPrototypeOf(this,L.prototype)}}class U extends j{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,U.prototype)}}class K extends U{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,K.prototype)}}class N extends j{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,N.prototype)}}class W extends j{constructor(){super("popup_open","Unable to open a popup for loginWithPopup - window.open returned `null`"),Object.setPrototypeOf(this,W.prototype)}}class z extends j{constructor(e,t,n,r){super(e,t),this.mfa_token=n,this.mfa_requirements=r,Object.setPrototypeOf(this,z.prototype)}}class H extends j{constructor(e,t){super("missing_refresh_token","Missing Refresh Token (audience: '".concat(V(e,["default"]),"', scope: '").concat(V(t),"')")),this.audience=e,this.scope=t,Object.setPrototypeOf(this,H.prototype)}}class M extends j{constructor(e,t){super("missing_scopes","Missing requested scopes after refresh (audience: '".concat(V(e,["default"]),"', missing scope: '").concat(V(t),"')")),this.audience=e,this.scope=t,Object.setPrototypeOf(this,M.prototype)}}class J extends j{constructor(e){super("use_dpop_nonce","Server rejected DPoP proof: wrong nonce"),this.newDpopNonce=e,Object.setPrototypeOf(this,J.prototype)}}function V(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e&&!t.includes(e)?e:""}let G=()=>window.crypto,F=()=>{let e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.",t="";return Array.from(G().getRandomValues(new Uint8Array(43))).forEach(n=>t+=e[n%e.length]),t},Z=e=>btoa(e),q=[{key:"name",type:["string"]},{key:"version",type:["string","number"]},{key:"env",type:["object"]}],B=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Object.keys(e).reduce((n,r)=>{if(t&&"env"===r)return n;let o=q.find(e=>e.key===r);return o&&o.type.includes(typeof e[r])&&(n[r]=e[r]),n},{})},X=e=>{let t;var{clientId:n}=e;return new URLSearchParams(Object.keys(t=Object.assign({client_id:n},w(e,["clientId"]))).filter(e=>void 0!==t[e]).reduce((e,n)=>Object.assign(Object.assign({},e),{[n]:t[n]}),{})).toString()},Y=async e=>{let t=G().subtle.digest({name:"SHA-256"},(new TextEncoder).encode(e));return await t},Q=e=>decodeURIComponent(atob(e.replace(/_/g,"/").replace(/-/g,"+")).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")),$=e=>{let t=new Uint8Array(e);return(e=>{let t={"+":"-","/":"_","=":""};return e.replace(/[+/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(t))))},ee=new TextEncoder,et=new TextDecoder;function en(e){return"string"==typeof e?ee.encode(e):et.decode(e)}function er(e){if("number"!=typeof e.modulusLength||e.modulusLength<2048)throw new ea(`${e.name} modulusLength must be at least 2048 bits`)}async function eo(e,t,n){var o,i,a;if(!1===n.usages.includes("sign"))throw TypeError('private CryptoKey instances used for signing assertions must include "sign" in their "usages"');let s=`${(o=en(JSON.stringify(e)),r(o))}.${(i=en(JSON.stringify(t)),r(i))}`;return`${s}.${a=await crypto.subtle.sign(function(e){switch(e.algorithm.name){case"ECDSA":return{name:e.algorithm.name,hash:"SHA-256"};case"RSA-PSS":return er(e.algorithm),{name:e.algorithm.name,saltLength:32};case"RSASSA-PKCS1-v1_5":return er(e.algorithm),{name:e.algorithm.name};case"Ed25519":return{name:e.algorithm.name}}throw new ei}(n),n,en(s)),r(a)}`}Uint8Array.prototype.toBase64?r=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0})):r=e=>{e instanceof ArrayBuffer&&(e=new Uint8Array(e));let t=[];for(let n=0;n<e.byteLength;n+=32768)t.push(String.fromCharCode.apply(null,e.subarray(n,n+32768)));return btoa(t.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};
1class ei extends Error{constructor(e){var t;super(null!=e?e:"operation not supported"),this.name=this.constructor.name,null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,this,this.constructor)}}class ea extends Error{constructor(e){var t;super(e),this.name=this.constructor.name,null===(t=Error.captureStackTrace)||void 0===t||t.call(Error,this,this.constructor)}}function es(e){return e instanceof CryptoKey}function ec(e){return es(e)&&"public"===e.type}async function eu(e,t,n,o,i,a){var s;let c=null==e?void 0:e.privateKey,u=null==e?void 0:e.publicKey;if(!es(c)||"private"!==c.type)throw TypeError('"keypair.privateKey" must be a private CryptoKey');if(!ec(u))throw TypeError('"keypair.publicKey" must be a public CryptoKey');if(!0!==u.extractable)throw TypeError('"keypair.publicKey.extractable" must be true');if("string"!=typeof t)throw TypeError('"htu" must be a string');if("string"!=typeof n)throw TypeError('"htm" must be a string');if(void 0!==o&&"string"!=typeof o)throw TypeError('"nonce" must be a string or undefined');if(void 0!==i&&"string"!=typeof i)throw TypeError('"accessToken" must be a string or undefined');if(void 0!==a&&("object"!=typeof a||null===a||Array.isArray(a)))throw TypeError('"additional" must be an object');return eo({alg:function(e){switch(e.algorithm.name){case"RSA-PSS":return function(e){if("SHA-256"===e.algorithm.hash.name)return"PS256";throw new ei("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"RSASSA-PKCS1-v1_5":return function(e){if("SHA-256"===e.algorithm.hash.name)return"RS256";throw new ei("unsupported RsaHashedKeyAlgorithm hash name")}(e);case"ECDSA":return function(e){if("P-256"===e.algorithm.namedCurve)return"ES256";throw new ei("unsupported EcKeyAlgorithm namedCurve")}(e);case"Ed25519":return"Ed25519";default:throw new ei("unsupported CryptoKey algorithm name")}}(c),typ:"dpop+jwt",jwk:await el(u)},Object.assign(Object.assign({},a),{iat:Math.floor(Date.now()/1e3),jti:crypto.randomUUID(),htm:n,nonce:o,htu:t,ath:i?(s=await crypto.subtle.digest("SHA-256",en(i)),r(s)):void 0}),c)}async function el(e){let{kty:t,e:n,n:r,x:o,y:i,crv:a}=await crypto.subtle.exportKey("jwk",e);return{kty:t,crv:a,e:n,n:r,x:o,y:i}}let ed=["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-rec
1overy-code"],eh=async(e,t)=>{let n=await fetch(e,t);return{ok:n.ok,json:await n.json(),headers:[...n.headers].reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{})}},ep=async(e,t,n)=>{let r;let o=new AbortController;return t.signal=o.signal,Promise.race([eh(e,t),new Promise((e,t)=>{r=setTimeout(()=>{o.abort(),t(Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(r)})},ef=async(e,t,n,r,o,i,a,s)=>{let c;return c={auth:{audience:t,scope:n},timeout:o,fetchUrl:e,fetchOptions:r,useFormData:a,useMrrt:s},new Promise(function(e,t){let n=new MessageChannel;n.port1.onmessage=function(r){r.data.error?t(Error(r.data.error)):e(r.data),n.port1.close()},i.postMessage(c,[n.port2])})},em=async function(e,t,n,r,o,i){let a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1e4,s=arguments.length>7?arguments[7]:void 0;return o?ef(e,t,n,r,a,o,i,s):ep(e,r,a)};async function ey(e,t,n,r,o,i,a,s,c,u){let l;if(c){let t=await c.generateProof({url:e,method:o.method||"GET",nonce:await c.getNonce()});o.headers=Object.assign(Object.assign({},o.headers),{dpop:t})}let d,h=null;for(let c=0;c<3;c++)try{d=await em(e,n,r,o,i,a,t,s),h=null;break}catch(e){h=e}if(h)throw h;let p=d.json,{error:f,error_description:m}=p,y=w(p,["error","error_description"]),{headers:g,ok:v}=d;if(c&&(l=g["dpop-nonce"])&&await c.setNonce(l),!v){let d=m||"HTTP error. Unable to fetch ".concat(e);if("mfa_required"===f)throw new z(f,d,y.mfa_token,y.mfa_requirements);if("missing_refresh_token"===f)throw new H(n,r);if("use_dpop_nonce"===f){if(!c||!l||u)throw new J(l);return ey(e,t,n,r,o,i,a,s,c,!0)}throw new j(f||"request_error",d)}return y}async function eg(e,t){var n,{baseUrl:r,timeout:o,audience:i,scope:a,auth0Client:s,useFormData:c,useMrrt:u,dpop:l}=e,d=w(e,["baseUrl","timeout","audience","scope","auth0Client","useFormData","useMrrt","dpop"]);let h="urn:ietf:params:oauth:grant-type:token-exchange"===d.grant_type,p="refresh_token"===d.grant_type&&u,f=Object.assign(Object.assign(Object.assign(Object.assign({},d),h&&i&&{audience:i}),h&&a&&{scope:a}),p&&{audience:i,scope:a}),m=c?X(f):JSON.stringify(f),y=(n=d.grant_type,ed.includes(n));return await ey("".concat(r,"/oauth/token"),o,i||"default",a,{method:"POST",body:m,headers:{"Content-Type":c?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(B(s||C)))}},t,c,u,y?l:void 0)}let ew=e=>Array.from(new Set(e)),ev=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return ew(t.filter(Boolean).join(" ").trim().split(/\s+/)).join(" ")},eb=(e,t,n)=>{let r;return n&&(r=e[n]),r||(r=e.default),ev(r,t)};class e_{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"@@auth0spajs@@",n=arguments.length>2?arguments[2]:void 0;this.prefix=t,this.suffix=n,this.clientId=e.clientId,this.scope=e.scope,this.audience=e.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join("::")}static fromKey(e){let[t,n,r,o]=e.split("::");return new e_({clientId:n,scope:o,audience:r},t)}static fromCacheEntry(e){let{scope:t,audience:n,client_id:r}=e;return new e_({scope:t,audience:n,clientId:r})}}class ek{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(e){return}}remove(e){localStorage.removeItem(e)}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith("@@auth0spajs@@"))}}class eS{constructor(){let e;this.enclosedCache=(e={},{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)})}}class eE{constructor(e,t,n){this.cache=e,this.keyManifest=t,this.nowProvider=n||x}async setIdToken(e,t,n){var r;let o=this.getIdTokenCacheKey(e);await this.cache.set(o,{id_token:t,decodedToken:n}),await (null===(r=this.keyManifest)||void 0===r?void 0:r.add(o))}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);if(!t||!t.id_token||!t.decodedToken)return;return{id_token:t.id_token,decodedToken:t.decodedToken}}if(t)return{id_token:t.id_token,decodedToken:t.decodedToken}}async get(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=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 n=this.matchExistingCacheKey(e,t);if(n&&(i=await this.cache.get(n)),!i&&r&&"cache-only"!==o)return this.getEntryWithRefreshToken(e,t)}if(!i)return;let a=await this.nowProvider();return i.expiresAt-n<Math.floor(a/1e3)?i.body.refresh_token?this.modifiedCachedEntry(i,e):(await this.cache.remove(e.toKey()),void await (null===(t=this.keyManifest)||void 0===t?void 0:t.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){var t;let n=new e_({clientId:e.client_id,scope:e.scope,audience:e.audience}),r=await this.wrapCacheEntry(e);await this.cache.set(n.toKey(),r),await (null===(t=this.keyManifest)||void 0===t?void 0:t.add(n.toKey()))}async remove(e,t,n){let r=new e_({clientId:e,scope:n,audience:t});await this.cache.remove(r.toKey())}async clear(e){var t;let n=await this.getCacheKeys();n&&(await n.filter(t=>!e||t.includes(e)).reduce(async(e,t)=>{await e,await this.cache.remove(t)},Promise.resolve()),await (null===(t=this.keyManifest)||void 0===t?void 0:t.clear()))}async wrapCacheEntry(e){return{body:e,expiresAt:Math.floor(await this.nowProvider()/1e3)+e.expires_in}}async getCacheKeys(){var e;return this.keyManifest?null===(e=await this.keyManifest.get())||void 0===e?void 0:e.keys:this.cache.allKe
1ys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new e_({clientId:e},"@@auth0spajs@@","@@user@@").toKey()}matchExistingCacheKey(e,t){return t.filter(t=>{var n;let r=e_.fromKey(t),o=new Set(r.scope&&r.scope.split(" ")),i=(null===(n=e.scope)||void 0===n?void 0:n.split(" "))||[],a=r.scope&&i.reduce((e,t)=>e&&o.has(t),!0);return"@@auth0spajs@@"===r.prefix&&r.clientId===e.clientId&&r.audience===e.audience&&a})[0]}async getEntryWithRefreshToken(e,t){var n;for(let r of t){let t=e_.fromKey(r);if("@@auth0spajs@@"===t.prefix&&t.clientId===e.clientId){let t=await this.cache.get(r);if(null===(n=null==t?void 0:t.body)||void 0===n?void 0:n.refresh_token)return this.modifiedCachedEntry(t,e)}}}async updateEntry(e,t){var n;let r=await this.getCacheKeys();if(r)for(let o of r){let r=await this.cache.get(o);if((null===(n=null==r?void 0:r.body)||void 0===n?void 0:n.refresh_token)===e){let e=Object.assign(Object.assign({},r.body),{refresh_token:t});await this.set(e)}}}}class eT{constructor(e,t,n){this.storage=e,this.clientId=t,this.cookieDomain=n,this.storageKey="".concat("a0.spajs.txs",".").concat(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})}}let eA=e=>"number"==typeof e,eP=["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"],eR=e=>{if(!e.id_token)throw Error("ID token is required but missing");let t=(e=>{let t=e.split("."),[n,r,o]=t;if(3!==t.length||!n||!r||!o)throw Error("ID token could not be decoded");let i=JSON.parse(Q(r)),a={__raw:e},s={};
1return Object.keys(i).forEach(e=>{a[e]=i[e],eP.includes(e)||(s[e]=i[e])}),{encoded:{header:n,payload:r,signature:o},header:JSON.parse(Q(n)),claims:a,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 "'.concat(e.iss,'", found "').concat(t.claims.iss,'"'));if(!t.user.sub)throw Error("Subject (sub) claim must be a string present in the ID token");if("RS256"!==t.header.alg)throw Error('Signature algorithm of "'.concat(t.header.alg,'" is not supported. Expected the ID token to be signed with "RS256".'));if(!t.claims.aud||"string"!=typeof t.claims.aud&&!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 "'.concat(e.aud,'" but was not one of "').concat(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 "'.concat(e.aud,'", found "').concat(t.claims.azp,'"'))}}else if(t.claims.aud!==e.aud)throw Error('Audience (aud) claim mismatch in the ID token; expected "'.concat(e.aud,'" but found "').concat(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 "'.concat(e.nonce,'", found "').concat(t.claims.nonce,'"'))}if(e.max_age&&!eA(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(null==t.claims.exp||!eA(t.claims.exp))throw Error("Expiration Time (exp) claim must be a number present in the ID token");if(!eA(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()),o=new Date(0);if(o.setUTCSeconds(t.claims.exp+n),r>o)throw Error("Expiration Time (exp) claim error in the ID token; current time (".concat(r,") is after expiration time (").concat(o,")"));if(null!=t.claims.nbf&&eA(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 (".concat(r,") is before ").concat(e))}if(null!=t.claims.auth_time&&eA(t.claims.auth_time)){let o=new Date(0);if(o.setUTCSeconds(parseInt(t.claims.auth_time)+e.max_age+n),r>o)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 (".concat(r,") is after last auth at ").concat(o))}if(e.organization){let n=e.organization.trim();if(n.startsWith("org_")){if(!t.claims.org_id)throw Error("Organization ID (org_id) claim must be a string present in the ID token");if(n!==t.claims.org_id)throw Error('Organization ID (org_id) claim mismatch in the ID token; expected "'.concat(n,'", found "').concat(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 "'.concat(e,'", found "').concat(t.claims.org_name,'"'))}}return t};var eI=v&&v.__assign||function(){return(eI=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function eO(e,t){if(!t)return"";var n="; "+e;return!0===t?n:n+"="+t}function eC(e,t,n){var r;document.cookie=(r=eI({path:"/"},n),encodeURIComponent(e).replace(/%(23|24|26|2B|5E|60|7C)/g,decode
1URIComponent).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("number"==typeof e.expires){var t=new Date;t.setMilliseconds(t.getMilliseconds()+864e5*e.expires),e.expires=t}return eO("Expires",e.expires?e.expires.toUTCString():"")+eO("Domain",e.domain)+eO("Path",e.path)+eO("Secure",e.secure)+eO("SameSite",e.sameSite)}(r))}var ex=function(e,t){eC(e,"",eI(eI({},t),{expires:-1}))};let ej={get(e){let t=function(e){for(var t={},n=e?e.split("; "):[],r=/(%[\dA-F]{2})+/gi,o=0;o<n.length;o++){var i=n[o].split("="),a=i.slice(1).join("=");'"'===a.charAt(0)&&(a=a.slice(1,-1));try{t[i[0].replace(r,decodeURIComponent)]=a.replace(r,decodeURIComponent)}catch(e){}}return t}(document.cookie)[e];if(void 0!==t)return JSON.parse(t)},save(e,t,n){let r={};"https:"===window.location.protocol&&(r={secure:!0,sameSite:"none"}),(null==n?void 0:n.daysUntilExpire)&&(r.expires=n.daysUntilExpire),(null==n?void 0:n.cookieDomain)&&(r.domain=n.cookieDomain),eC(e,JSON.stringify(t),r)},remove(e,t){let n={};(null==t?void 0:t.cookieDomain)&&(n.domain=t.cookieDomain),ex(e,n)}},eD={get:e=>ej.get(e)||ej.get("".concat("_legacy_").concat(e)),save(e,t,n){let r={};"https:"===window.location.protocol&&(r={secure:!0}),(null==n?void 0:n.daysUntilExpire)&&(r.expires=n.daysUntilExpire),(null==n?void 0:n.cookieDomain)&&(r.domain=n.cookieDomain),eC("".concat("_legacy_").concat(e),JSON.stringify(t),r),ej.save(e,t,n)},remove(e,t){let n={};(null==t?void 0:t.cookieDomain)&&(n.domain=t.cookieDomain),ex(e,n),ej.remove(e,t),ej.remove("".concat("_legacy_").concat(e),t)}},eL={get(e){if("undefined"==typeof sessionStorage)return;let t=sessionStorage.getItem(e);return null!=t?JSON.parse(t):void 0},save(e,t){sessionStorage.setItem(e,JSON.stringify(t))},remove(e){sessionStorage.removeItem(e)}};(eK=eN||(eN={})).Code="code",eK.ConnectCode="connect_code";class eU{}var eK,eN,eW,ez,eH=(eW="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHQpe2xldHtlcnJvcjpyLGVycm9yX2Rlc2NyaXB0aW9uOnN9PXQ7cmV0dXJuIG5ldyBlKHIscyl9fWNsYXNzIHQgZXh0ZW5kcyBle2NvbnN0cnVjdG9yKGUscyl7c3VwZXIoIm1pc3NpbmdfcmVmcmVzaF90b2tlbiIsIk1pc3NpbmcgUmVmcmVzaCBUb2tlbiAoYXVkaWVuY2U6ICciLmNvbmNhdChyKGUsWyJkZWZhdWx0Il0pLCInLCBzY29wZTogJyIpLmNvbmNhdChyKHMpLCInKSIpKSx0aGlzLmF1ZGllbmNlPWUsdGhpcy5zY29wZT1zLE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLHQucHJvdG90eXBlKX19ZnVuY3Rpb24gcihlKXtsZXQgdD1hcmd1bWVudHMubGVuZ3RoPjEmJnZvaWQgMCE9PWFyZ3VtZW50c1sxXT9hcmd1bWVudHNbMV06W107cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+IiIuY29uY2F0KGUsInwiKS5jb25jYXQodCk7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jIGU9PntsZXQgcixjLHtkYXRhOnt0aW1lb3V0OmksYXV0aDphLGZldGNoVXJsOmYsZmV0Y2hPcHRpb25zOmwsdXNlRm9ybURhdGE6cCx1c2VNcnJ0Omh9LHBvcnRzOlt1XX09ZSxkPXt9O2NvbnN0e2F1ZGllbmNlOmcsc2NvcGU6eX09YXx8e307dHJ5e2NvbnN0IGU9cD8oZT0+e2NvbnN0IHQ9bmV3IFVSTFNlYXJjaFBhcmFtcyhlKSxyPXt9O3JldHVybiB0LmZvckVhY2goKChlLHQpPT57clt0XT1lfSkpLHJ9KShsLmJvZHkpOkpTT04ucGFyc2UobC5ib2R5KTtpZighZS5yZWZyZXNoX3Rva2VuJiYicmVmcmVzaF90b2tlbiI9PT1lLmdyYW50X3R5cGUpe2lmKGM9KChlLHQpPT5vW24oZSx0KV0pKGcseSksIWMmJmgpe2NvbnN0IGU9by5sYXRlc3RfcmVmcmVzaF90b2tlbix0PSgoZSx0KT0+e2NvbnN0IHI9T2JqZWN0LmtleXMobykuZmluZCgocj0+e2lmKCJsYXRlc3RfcmVmcmVzaF90b2tlbiIhPT1yKXtjb25zdCBzPSgoZSx0KT0+dC5zdGFydHNXaXRoKCIiLmNvbmNhdChlLCJ8IikpKSh0LHIpLG89ci5zcGxpdCgifCIpWzFdLnNwbGl0KCIgIiksbj1lLnNwbGl0KCIgIikuZXZlcnkoKGU9Pm8uaW5jbHVkZXMoZSkpKTtyZXR1cm4gcyYmbn19KSk7cmV0dXJuISFyfSkoeSxnKTtlJiYhdCYmKGM9ZSl9aWYoIWMpdGhyb3cgbmV3IHQoZyx5KTtsLmJvZHk9cD9zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fS
1xlKSx7cmVmcmVzaF90b2tlbjpjfSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpjfSkpfWxldCBhLGs7ImZ1bmN0aW9uIj09dHlwZW9mIEFib3J0Q29udHJvbGxlciYmKGE9bmV3IEFib3J0Q29udHJvbGxlcixsLnNpZ25hbD1hLnNpZ25hbCk7dHJ5e2s9YXdhaXQgUHJvbWlzZS5yYWNlKFsoaj1pLG5ldyBQcm9taXNlKChlPT5zZXRUaW1lb3V0KGUsaikpKSksZmV0Y2goZixPYmplY3QuYXNzaWduKHt9LGwpKV0pfWNhdGNoKGUpe3JldHVybiB2b2lkIHUucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZX0pfWlmKCFrKXJldHVybiBhJiZhLmFib3J0KCksdm9pZCB1LnBvc3RNZXNzYWdlKHtlcnJvcjoiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIn0pO189ay5oZWFkZXJzLGQ9Wy4uLl9dLnJlZHVjZSgoKGUsdCk9PntsZXRbcixzXT10O3JldHVybiBlW3JdPXMsZX0pLHt9KSxyPWF3YWl0IGsuanNvbigpLHIucmVmcmVzaF90b2tlbj8oaCYmKG8ubGF0ZXN0X3JlZnJlc2hfdG9rZW49ci5yZWZyZXNoX3Rva2VuLE89YyxiPXIucmVmcmVzaF90b2tlbixPYmplY3QuZW50cmllcyhvKS5mb3JFYWNoKChlPT57bGV0W3Qscl09ZTtyPT09TyYmKG9bdF09Yil9KSkpLCgoZSx0LHIpPT57b1tuKHQscildPWV9KShyLnJlZnJlc2hfdG9rZW4sZyx5KSxkZWxldGUgci5yZWZyZXNoX3Rva2VuKTooKGUsdCk9PntkZWxldGUgb1tuKGUsdCldfSkoZyx5KSx1LnBvc3RNZXNzYWdlKHtvazprLm9rLGpzb246cixoZWFkZXJzOmR9KX1jYXRjaChlKXt1LnBvc3RNZXNzYWdlKHtvazohMSxqc29uOntlcnJvcjplLmVycm9yLGVycm9yX2Rlc2NyaXB0aW9uOmUubWVzc2FnZX0saGVhZGVyczpkfSl9dmFyIE8sYixfLGp9KSl9KCk7Cgo=",function(e){var t,n,r;return new Worker(ez=ez||(n=(t=function(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),o=0,i=n.length;o<i;++o)r[o]=n.charCodeAt(o);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}(eW,!1)).indexOf("\n",10)+1,r=new Blob([t.substring(n)+""],{type:"application/javascript"}),URL.createObjectURL(r)),e)});let eM={},eJ=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;for(let n=0;n<t;n++)if(await e())return!0;return!1};class eV{constructor(e,t){this.cache=e,this.clientId=t,this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(e){var t;let n=new Set((null===(t=await this.cache.get(this.manifestKey))||void 0===t?void 0:t.keys)||[]);n.add(e),await this.cache.set(this.manifestKey,{keys:[...n]})}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"".concat("@@auth0spajs@@","::").concat(e)}}let eG={memory:()=>(new eS).enclosedCache,localstorage:()=>new ek},eF=e=>eG[e],eZ=e=>{let{openUrl:t,onRedirect:n}=e;return Object.assign(Object.assign({},w(e,["openUrl","onRedirect"])),{openUrl:!1===t||t?t:n})},eq=(e,t)=>{let n=(null==t?void 0:t.split(" "))||[];return((null==e?void 0:e.split(" "))||[]).every(e=>n.includes(e))},eB={NONCE:"nonce",KEYPAIR:"keypair"};class eX{constructor(e){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(eB).forEach(t=>e.result.createObjectStore(t)),e.onerror=()=>n(e.error),e.onsuccess=()=>t(e.result)})}async getDbHandle(){return this.dbHandle||(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){return"".concat(this.clientId,"::").concat(e?"_".concat(e):"auth0")}setNonce(e,t){return this.save(eB.NONCE,this.buildKey(t),e)}setKeyPair(e){return this.save(eB.KEYPAIR,this.buildKey(),e)}async save(e,t,n){await this.executeDbRequest(e,"readwrite",e=>e.put(n,t))}findNonce(e){return this.find(eB.NONCE,this.buildKey(e))}findKeyPair(){return this.find(eB.KEYPAIR,this.buildKey())}find(e,t){return this.executeDbRequest(e,"readonly",e=>e.get(t))}async deleteBy(e,t){let n=await this.executeDbRequest(e,"readonly",e=>e.getAllKeys());null==n||n.filter(t).map(t=>this.executeDbRequest(e,"readwrite",e=>e.delete(t)))}deleteByClientId(e,t){return this.deleteBy(e,e=>"string"==typeof e&&e.startsWith("".concat(t,"::")))}clearNonces(){return this.deleteByClientId(eB.NONCE,this.clientId)}clearKeyPairs(){return this.deleteByClientId(eB.KEYPAIR,this.clientId)}}class eY{constructor(e){this.storage=new eX(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();
1return e||(e=await async function(e,t){var n;let r;if("string"!=typeof e||0===e.length)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 ei}return crypto.subtle.generateKey(r,null!==(n=null==t?void 0:t.extractable)&&void 0!==n&&n,["sign","verify"])}("ES256",{extractable:!1}),await this.storage.setKeyPair(e)),e}async generateProof(e){return function(e){let{keyPair:t,url:n,method:r,nonce:o,accessToken:i}=e;return eu(t,function(e){let t=new URL(e);return t.search="",t.hash="",t.href}(n),r,o,i)}(Object.assign({keyPair:await this.getOrGenerateKeyPair()},e))}async calculateThumbprint(){return async function(e){var t;let n;if(!ec(e))throw TypeError('"publicKey" must be a public CryptoKey');if(!0!==e.extractable)throw TypeError('"publicKey.extractable" must be true');let o=await el(e);switch(o.kty){case"EC":n={crv:o.crv,kty:o.kty,x:o.x,y:o.y};break;case"OKP":n={crv:o.crv,kty:o.kty,x:o.x};break;case"RSA":n={e:o.e,kty:o.kty,n:o.n};break;default:throw new ei("unsupported JWK kty")}return t=await crypto.subtle.digest({name:"SHA-256"},en(JSON.stringify(n))),r(t)}((await this.getOrGenerateKeyPair()).publicKey)}async clear(){await Promise.all([this.storage.clearNonces(),this.storage.clearKeyPairs()])}}(rL=rU||(rU={})).Bearer="Bearer",rL.DPoP="DPoP";class eQ{constructor(e,t){this.hooks=t,this.config=Object.assign(Object.assign({},e),{fetch:e.fetch||("undefined"==typeof window?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"".concat(e.replace(/\/?\/$/,""),"/").concat(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"string"==typeof e?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&&void 0!==arguments[2]?arguments[2]:rU.Bearer;e.headers.set("authorization","".concat(n," ").concat(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,r;let o=await this.getAccessToken(t);"string"==typeof o?(n=this.config.dpopNonceId?rU.DPoP:rU.Bearer,r=o):(n=o.token_type,r=o.access_token),this.setAuthorizationHeader(e,r,n),n===rU.DPoP&&await this.setDpopProofHeader(e,r)}getHeader(e,t){return Array.isArray(e)?new Headers(e).get(t)||"":"function"==typeof e.get?e.get(t)||"":e[t]||""}hasUseDpopNonceError(e){if(401!==e.status)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,"dpop-nonce");if(n&&await this.hooks.setDpopNonce(n),!this.hasUseDpopNonceError(e))return e;if(!n||!t.onUseDpopNonceError)throw new J(n);return t.onUseDpopNonceError()}async internalFetchWithAuth(e,t,n,r){let o=this.buildBaseRequest(e,t);await this.prepareRequest(o,r);let i=await this.config.fetch(o);return this.handleResponse(i,n)}fetchWithAuth(e,t,n){let r={onUseDpopNonceError:()=>this.internalFetchWithAuth(e,t,Object.assign(Object.assign({},r),{onUseDpopNonceError:void 0}),n)};return this.internalFetchWithAuth(e,t,r,n)}}class e${constructor(e,t){this.myAccountFetcher=e,this.apiBase=t}async connectAccount(e){let t=await this.myAccountFetcher.fetchWithAuth("".concat(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("".concat(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 e0({type:"invalid_json",status:e.status,title:"Invalid JSON response",detail:t||String(n)})}if(e.ok)return t;throw new e0(t)}}
1class e0 extends Error{constructor(e){let{type:t,status:n,title:r,detail:o,validation_errors:i}=e;super(o),this.name="MyAccountApiError",this.type=t,this.status=n,this.title=r,this.detail=o,this.validation_errors=i,Object.setPrototypeOf(this,e0.prototype)}}let e1={otp:{authenticatorTypes:["otp"]},sms:{authenticatorTypes:["oob"],oobChannels:["sms"]},email:{authenticatorTypes:["oob"],oobChannels:["email"]},push:{authenticatorTypes:["oob"],oobChannels:["auth0"]},voice:{authenticatorTypes:["oob"],oobChannels:["voice"]}};function e2(e,t){this.v=e,this.k=t}function e5(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError("Private element is not present on this object")}function e3(e,t){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object")}function e4(e,t){return e.get(e5(e,t))}function e6(e,t,n){e3(e,t),t.set(e,n)}function e9(e,t,n){return e.set(e5(e,t),n),n}function e8(e,t,n){var r;return(t="symbol"==typeof(r=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?r:r+"")in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function e7(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 te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?e7(Object(n),!0).forEach(function(t){e8(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):e7(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function tt(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&({}).propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function tn(e){var t,n;function r(t,n){try{var i=e[t](n),a=i.value,s=a instanceof e2;Promise.resolve(s?a.v:a).then(function(n){if(s){var c="return"===t?"return":"next";if(!a.k||n.done)return r(c,n);n=e[c](n).value}o(i.done?"return":"normal",n)},function(e){r("throw",e)})}catch(e){o("throw",e)}}function o(e,o){switch(e){case"return":t.resolve({value:o,done:!0});break;case"throw":t.reject(o);break;default:t.resolve({value:o,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,o){return new Promise(function(i,a){var s={key:e,arg:o,resolve:i,reject:a,next:null};n?n=n.next=s:(t=n=s,r(e,o))})},"function"!=typeof e.return&&(this.return=void 0)}function tr(e,t){if(null==e)return!1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch(e){return!1}}function to(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}tn.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},tn.prototype.next=function(e){return this._invoke("next",e)},tn.prototype.throw=function(e){return this._invoke("throw",e)},tn.prototype.return=function(e){return this._invoke("return",e)},"undefined"!=typeof navigator&&null!==(rK=navigator.userAgent)&&void 0!==rK&&null!==(rN=rK.startsWith)&&void 0!==rN&&rN.call(rK,"Mozilla/5.0 ")||(o="".concat("oauth4webapi","/").concat("v3.8.3"));let ti=Symbol(),ta=Symbol(),ts=Symbol(),tc=Symbol(),tu=Symbol(),tl=Symbol(),td=new TextEncoder,th=new TextDecoder;function tp(e){return"string"==typeof e?td.encode(e):th.decode(e)}function tf(e){return"string"==typeof e?a(e):i(e)}Uint8Array.prototype.toBase64?i=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0})):i=e=>{e instanceof ArrayBuffer&&(e=new Uint8Array(e));let t=[];for(let n=0;n<e.byteLength;n+=32768)t.push(String.fromCharCode.apply(null,e.subarray(n,n+32768)));return btoa(t.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},a=Uint8Array.fromBase64?e=>{try{return Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch(e){throw to("The input to be decoded is not correctly encoded.","ERR_INVALID_ARG_VALUE",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 to("The input to be decoded is not correctly encoded.","ERR_INVALID_ARG_VALUE",e)}};
1class tm extends Error{constructor(e,t){var n;super(e,t),e8(this,"code",void 0),this.name=this.constructor.name,this.code=ne,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor)}}class ty extends Error{constructor(e,t){var n;super(e,t),e8(this,"code",void 0),this.name=this.constructor.name,null!=t&&t.code&&(this.code=null==t?void 0:t.code),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor)}}function tg(e,t,n){return new ty(e,{code:t,cause:n})}function tw(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function tv(e){tr(e,Headers)&&(e=Object.fromEntries(e.entries()));let t=new Headers(null!=e?e:{});if(o&&!t.has("user-agent")&&t.set("user-agent",o),t.has("authorization"))throw to('"options.headers" must not include the "authorization" header name',"ERR_INVALID_ARG_VALUE");return t}function tb(e,t){if(void 0!==t){if("function"==typeof t&&(t=t(e.href)),!(t instanceof AbortSignal))throw to('"options.signal" must return or be an instance of AbortSignal',"ERR_INVALID_ARG_TYPE");return t}}function t_(e){return e.includes("//")?e.replace("//","/"):e}async function tk(e,t){return async function(e,t,n,r){if(!(e instanceof URL))throw to('"'.concat(t,'" must be an instance of URL'),"ERR_INVALID_ARG_TYPE");tD(e,!0!==(null==r?void 0:r[ti]));let o=n(new URL(e.href)),i=tv(null==r?void 0:r.headers);return i.set("accept","application/json"),((null==r?void 0:r[tc])||fetch)(o.href,{body:void 0,headers:Object.fromEntries(i.entries()),method:"GET",redirect:"manual",signal:tb(o,null==r?void 0:r.signal)}
1)}(e,"issuerIdentifier",e=>{switch(null==t?void 0:t.algorithm){case void 0:case"oidc":var n;n=".well-known/openid-configuration",e.pathname=t_("".concat(e.pathname,"/").concat(n));break;case"oauth2":!function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];"/"===e.pathname?e.pathname=t:e.pathname=t_("".concat(t,"/").concat(n?e.pathname:e.pathname.replace(/(\/)$/,"")))}(e,".well-known/oauth-authorization-server");break;default:throw to('"options.algorithm" must be "oidc" (default), or "oauth2"',"ERR_INVALID_ARG_VALUE")}return e},t)}function tS(e,t,n,r,o){try{if("number"!=typeof e||!Number.isFinite(e))throw to("".concat(n," must be a number"),"ERR_INVALID_ARG_TYPE",o);if(e>0)return;if(t){if(0!==e)throw to("".concat(n," must be a non-negative number"),"ERR_INVALID_ARG_VALUE",o);return}throw to("".concat(n," must be a positive number"),"ERR_INVALID_ARG_VALUE",o)}catch(e){if(r)throw tg(e.message,r,o);throw e}}function tE(e,t,n,r){try{if("string"!=typeof e)throw to("".concat(t," must be a string"),"ERR_INVALID_ARG_TYPE",r);if(0===e.length)throw to("".concat(t," must not be empty"),"ERR_INVALID_ARG_VALUE",r)}catch(e){if(n)throw tg(e.message,n,r);throw e}}function tT(e){!function(e,t){if(tF(e)!==t)throw function(e){let t='"response" content-type must be ';for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];if(r.length>2){let e=r.pop();t+="".concat(r.join(", "),", or ").concat(e)}else 2===r.length?t+="".concat(r[0]," or ").concat(r[1]):t+=r[0];return tg(t,no,e)}(e,t)}(e,"application/json")}function tA(){return tf(crypto.getRandomValues(new Uint8Array(32)))}function tP(e){let t=null==e?void 0:e[ta];return"number"==typeof t&&Number.isFinite(t)?t:0}function tR(e){let t=null==e?void 0:e[ts];return"number"==typeof t&&Number.isFinite(t)&&-1!==Math.sign(t)?t:30}function tI(){return Math.floor(Date.now()/1e3)}function tO(e){if("object"!=typeof e||null===e)throw to('"as" must be an object',"ERR_INVALID_ARG_TYPE");tE(e.issuer,'"as.issuer"')}function tC(e){if("object"!=typeof e||null===e)throw to('"client" must be an object',"ERR_INVALID_ARG_TYPE");tE(e.client_id,'"client.client_id"')}function tx(e){return tE(e,'"clientSecret"'),(t,n,r,o)=>{r.set("client_id",n.client_id),r.set("client_secret",e)}}let tj=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch(e){return null}};function tD(e,t){if(t&&"https:"!==e.protocol)throw tg("only requests to HTTPS are allowed",na,e);if("https:"!==e.protocol&&"http:"!==e.protocol)throw tg("only HTTP and HTTPS requests are allowed",ns,e)}function tL(e,t,n,r){let o;if("string"!=typeof e||!(o=tj(e)))throw tg("authorization server metadata does not contain a valid ".concat(n?'"as.mtls_endpoint_aliases.'.concat(t,'"'):'"as.'.concat(t,'"')),void 0===e?nd:nh,{attribute:n?"mtls_endpoint_aliases.".concat(t):t});return tD(o,r),o}function tU(e,t,n,r){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?tL(e.mtls_endpoint_aliases[t],t,n,r):tL(e[t],t,n,r)}class tK extends Error{constructor(e,t){var n;super(e,t),e8(this,"cause",void 0),e8(this,"code",void 0),e8(this,"error",void 0),e8(this,"status",void 0),e8(this,"error_description",void 0),e8(this,"response",void 0),this.name=this.constructor.name,this.code=t7,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}),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor)}}class tN extends Error{constructor(e,t){var n,r;super(e,t),e8(this,"cause",void 0),e8(this,"code",void 0),e8(this,"error",void 0),e8(this,"error_description",void 0),this.name=this.constructor.name,this.code=nt,this.cause=t.cause,this.error=t.cause.get("error"),this.error_description=null!==(n=t.cause.get("error_description"))&&void 0!==n?n:void 0,null===(r=Error.captureStackTrace)||void 0===r||r.call(Error,this,this.constructor)}}class tW extends Error{constructor(e,t){var n;super(e,t),e8(this,"cause",void 0),e8(this,"code",void 0),e8(this,"response",void 0),e8(this,"status",void 0),this.name=this.constructor.name,this.co
1de=t8,this.cause=t.cause,this.status=t.response.status,this.response=t.response,Object.defineProperty(this,"response",{enumerable:!1}),null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor)}}let tz=RegExp("^[,\\s]*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)"),tH=RegExp('^[,\\s]*([a-zA-Z0-9!#$%&\\\'\\*\\+\\-\\.\\^_`\\|~]+)\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"[,\\s]*(.*)'),tM=RegExp("^[,\\s]*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)[,\\s]*(.*)"),tJ=RegExp("^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)");async function tV(e,t,n){if(e.status!==t){var r;let t;if(function(e){let t;if(t=function(e){if(!tr(e,Response))throw to('"response" must be an instance of Response',"ERR_INVALID_ARG_TYPE");let t=e.headers.get("www-authenticate");if(null===t)return;let n=[],r=t;for(;r;){var o;let e;let t=r.match(tz),i=null===(o=t)||void 0===o?void 0:o[1].toLowerCase();if(!i)return;let a=r.substring(t[0].length);if(a&&!a.match(/^[\s,]/))return;let s=a.match(/^\s+(.*)$/),c=!!s;r=s?s[1]:void 0;let u={};if(c)for(;r;){let n,o;if(t=r.match(tH)){if([,n,o,r]=t,o.includes("\\"))try{o=JSON.parse('"'.concat(o,'"'))}catch(e){}u[n.toLowerCase()]=o}else{if(!(t=r.match(tM))){if(t=r.match(tJ)){if(Object.keys(u).length)break;[,e,r]=t;break}return}[,n,o,r]=t,u[n.toLowerCase()]=o}}else r=a||void 0;let l={scheme:i,parameters:u};e&&(l.token68=e),n.push(l)}return n.length?n:void 0}(e))throw new tW("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){np(e),tT(e);try{let t=await e.clone().json();if(tw(t)&&"string"==typeof t.error&&t.error.length)return t}catch(e){}}}(e))throw await (null===(r=e.body)||void 0===r?void 0:r.cancel()),new tK("server responded with an error in the response body",{cause:t,response:e});throw tg('"response" is not a conform '.concat(n," response (unexpected HTTP status code)"),ni,e)}}function tG(e){if(!t1.has(e))throw to('"options.DPoP" is not a valid DPoPHandle',"ERR_INVALID_ARG_VALUE")}function tF(e){var t;return null===(t=e.headers.get("content-type"))||void 0===t?void 0:t.split(";")[0]}async function tZ(e,t,n,r,o,i,a){return await n(e,t,o,i),i.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),((null==a?void 0:a[tc])||fetch)(r.href,{body:o,headers:Object.fromEntries(i.entries()),method:"POST",redirect:"manual",signal:tb(r,null==a?void 0:a.signal)})}async function tq(e,t,n,r,o,i){var a;let s=tU(e,"token_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==i?void 0:i[ti]));o.set("grant_type",r);let c=tv(null==i?void 0:i.headers);c.set("accept","application/json"),void 0!==(null==i?void 0:i.DPoP)&&(tG(i.DPoP),await i.DPoP.addProof(s,c,"POST"));let u=await tZ(e,t,n,s,o,c,i);return null==i||null===(a=i.DPoP)||void 0===a||a.cacheNonce(u,s),u}let tB=new WeakMap,tX=new WeakMap;function tY(e){if(!e.id_token)return;let t=tB.get(e);if(!t)throw to('"ref" was already garbage collected or did not resolve from the proper sources',"ERR_INVALID_ARG_VALUE");return t}async function tQ(e,t,n,r,o,i){if(tO(e),tC(t),!tr(n,Response))throw to('"response" must be an instance of Response',"ERR_INVALID_ARG_TYPE");await tV(n,200,"Token Endpoint"),np(n);let a=await nb(n);if(tE(a.access_token,'"response" body "access_token" property',nr,{body:a}),tE(a.token_type,'"response" body "token_type" property',nr,{body:a}),a.token_type=a.token_type.toLowerCase(),void 0!==a.expires_in){let e="number"!=typeof a.expires_in?parseFloat(a.expires_in):a.expires_in;tS(e,!0,'"response" body "expires_in" property',nr,{body:a}),a.expires_in=e}if(void 0!==a.refresh_token&&tE(a.refresh_token,'"response" body "refresh_token" property',nr,{body:a}),void 0!==a.scope&&"string"!=typeof a.scope)throw tg('"response" body "scope" property must be a string',nr,{body:a});if(void 0!==a.id_token){tE(a.id_token,'"response" body "id_token" property',nr,{body:a});let i=["aud","exp","iat","iss","sub"];!0===t.require_auth_time&&i.push("auth_time"),void 0!==t.default_max_age&&(tS(t.default_max_age,!0,'"client.default_max_age"'),i.push("auth_time")),null!=r&&r.length&&i.push(...r);let{claims:s,jwt:c}=await (async function(e,t,n,r,o){let i,a,{0:s,1:c,length:u}=e.split(".");if(5===u){if(void 0===o)throw new tm("JWE decryption is not configured",{cause:e});e=await o(e),{0:s,1:c,length:u}=e.split(".")}if(3!==u)throw tg("Invalid JWT",nr,e);try{i=JSON.parse(tp(tf(s)))}catch(e){throw tg("failed to parse JWT Header body as base64url encoded JSON",nn,e)}if(!tw(i))throw tg("JWT Header must be a top level object",nr,e);if(t(i),void 0!==i.crit)throw new tm('no JWT "crit" header parameter extensions are supported',{cause:{header:i}});try{a=JSON.parse(tp(tf(c)))}catch(e){throw tg("failed to parse JWT Payload body as base64url encoded JSON",nn,e)}if(!tw(a))throw tg("JWT Payload must be a top level object",nr,e);let l=tI()+n;if(void 0!==a.exp){if("number"!=typeof a.exp)throw tg('unexpected JWT "exp" (expiration time) claim type',nr,{claims:a});if(a.exp<=l-r)throw tg('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp',nc,{claims:a,now:l,tolerance:r,claim:"exp"})}if(void 0!==a.iat&&"number"!=typeof a.iat)throw tg('unexpected JWT "iat" (issued at) claim type',nr,{claims:a});if(void 0!==a.iss&&"string"!=typeof a.iss)throw tg('unexpected JWT "iss" (issuer) claim type',nr,{claims:a});if(void 0!==a.nbf){if("number"!=typeof a.nbf)throw tg('unexpected JWT "nbf" (not before) claim type',nr,{claims:a});if(a.nbf>l+r)throw tg('unexpected JWT "nbf" (not before) claim value',nc,{claims:a,now:l,tolerance:r,claim:"nbf"})}if(void 0!==a.aud&&"string"!=typeof a.aud&&!Array.isArray(a.aud))throw tg('unexpected JWT "aud" (audience) claim type',nr,{claims:a});return{header:i,claims:a,jwt:e}})(a.id_token,ny.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,"RS256"),tP(t),tR(t),o).then(t3.bind(void 0,i)).then(t0.bind(void 0,e)).then(t$.bind(void 0,t.client_id));if(Array.isArray(s.aud)&&1!==s.aud.length){if(void 0===s.azp)throw tg('ID Token "aud" (audience) claim includes additional untrusted audiences',nu,{claims:s,claim:"aud"});if(s.azp!==t.client_id)throw tg('unexpected ID Token "azp" (authorized party) claim value',nu,{expected:t.client_id,claims:s,claim:"azp"})}void 0!==s.auth_time&&tS(s.auth_time,!0,'ID Token "auth_time" (authentication time)',nr,{claims:s}),tX.set(n,c),tB.set(a,s)}if(void 0!==(null==i?void 0:i[a.token_type]))i[a.token_type](n,a);else if("dpop"!==a.token_type&&"bearer"!==a.token_type)throw new tm("unsupported `token_type` value",{cause:{body:a}});return a}function t$(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw tg('unexpected JWT "aud" (audience) claim value',nu,{expected:e,claims:t.claims,claim:"aud"})}else if(t.claims.aud!==e)throw tg('unexpected JWT "aud" (audience) claim value',nu,{expected:e,claims:t.claims,claim:"aud"});return t}function t0(e,t){var n,r;let o=null!==(n=null===(r=e[nk])||void 0===r?void 0:r.call(e,t))&&void 0!==n?n:e.issuer;if(t.claims.iss!==o)throw tg('unexpected JWT "iss" (issuer) claim value',nu,{expected:o,claims:t.claims,claim:"iss"});return t}let t1=new WeakSet,t2=Symbol(),t5={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 t3(e,t){for(let n of e)if(void 0===t.claims[n])throw tg('JWT "'.concat(n,'" (').concat(t5[n],") claim missing"),nr,{claims:t.claims});return t}let t4=Symbol(),t6=Symbol();async function t9(e,t,n,r){return"string"==typeof(null==r?void 0:r.expectedNonce)||"number"==typeof(null==r?void 0:r.maxAge)||null!=r&&r.requireIdToken?async function(e,t,n,r,o,i,a){let s=[];switch(r){case void 0:r=t4;break;case t4:break;default:tE(r,'"expectedNonce" argument'),s.push("nonce")}switch(null!=o||(o=t.default_max_age),o){case void 0:o=t6;break;case t6:break;default:tS(o,!0,'"maxAge" argument'),s.push("auth_time")}let c=await tQ(e,t,n,s,i,a);tE(c.id_token,'"response" body "id_token" property',nr,{body:c});let u=tY(c);if(o!==t6){let e=tI()+tP(t),n=tR(t);if(u.auth_time+o<e-n)throw tg("too much time has elapsed since the last End-User authentication",nc,{claims:u,now:e,tolerance:n,claim:"auth_time"})}if(r===t4){if(void 0!==u.nonce)throw tg('unexpected ID Token "nonce" claim value',nu,{expected:void 0,claims:u,claim:"nonce"})}else if(u.nonce!==r)throw tg('unexpected ID Token "nonce" claim value',nu,{expected:r,claims:u,claim:"nonce"});return c}(e,t,n,r.expectedNonce,r.maxAge,r[tl],r.recognizedTokenTypes):async function(e,t,n,r,o){let i=await tQ(e,t,n,void 0,r,o),a=tY(i);if(a){if(void 0!==t.default_max_age){tS(t.default_max_age,!0,'"client.default_max_age"');let e=tI()+tP(t),n=tR(t);if(a.auth_time+t.default_max_age<e-n)throw tg("too much time has elapsed since the last End-User authentication",nc,{claims:a,now:e,tolerance:n,claim:"auth_time"})}if(void 0!==a.nonce)throw tg('unexpected ID Token "nonce" claim value',nu,{expected:void 0,claims:a,claim:"nonce"})}return i}(e,t,n,null==r?void 0:r[tl],null==r?void 0:r.recognizedTokenTypes)}let t8="OAUTH_WWW_AUTHENTICATE_CHALLENGE",t7="OAUTH_RESPONSE_BODY_ERROR",ne="OAUTH_UNSUPPORTED_OPERATION",nt="OAUTH_AUTHORIZATION_RESPONSE_E
1RROR",nn="OAUTH_PARSE_ERROR",nr="OAUTH_INVALID_RESPONSE",no="OAUTH_RESPONSE_IS_NOT_JSON",ni="OAUTH_RESPONSE_IS_NOT_CONFORM",na="OAUTH_HTTP_REQUEST_FORBIDDEN",ns="OAUTH_REQUEST_PROTOCOL_FORBIDDEN",nc="OAUTH_JWT_TIMESTAMP_CHECK_FAILED",nu="OAUTH_JWT_CLAIM_COMPARISON_FAILED",nl="OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED",nd="OAUTH_MISSING_SERVER_METADATA",nh="OAUTH_INVALID_SERVER_METADATA";function np(e){if(e.bodyUsed)throw to('"response" body has been used already',"ERR_INVALID_ARG_VALUE")}function nf(e){let{algorithm:t}=e;if("number"!=typeof t.modulusLength||t.modulusLength<2048)throw new tm("unsupported ".concat(t.name," modulusLength"),{cause:e})}async function nm(e){if("POST"!==e.method)throw to("form_post responses are expected to use the POST method","ERR_INVALID_ARG_VALUE",{cause:e});if("application/x-www-form-urlencoded"!==tF(e))throw to("form_post responses are expected to use the application/x-www-form-urlencoded content-type","ERR_INVALID_ARG_VALUE",{cause:e});return async function(e){if(e.bodyUsed)throw to("form_post Request instances must contain a readable body","ERR_INVALID_ARG_VALUE",{cause:e});return e.text()}(e)}function ny(e,t,n,r){if(void 0===e){if(Array.isArray(t)){if(!t.includes(r.alg))throw tg('unexpected JWT "alg" header parameter',nr,{header:r,expected:t,reason:"authorization server metadata"})}else{if(void 0===n)throw tg('missing client or server configuration to verify used JWT "alg" header parameter',void 0,{client:e,issuer:t,fallback:n});if("string"==typeof n?r.alg!==n:"function"==typeof n?!n(r.alg):!n.includes(r.alg))throw tg('unexpected JWT "alg" header parameter',nr,{header:r,expected:n,reason:"default value"})}}else if("string"==typeof e?r.alg!==e:!e.includes(r.alg))throw tg('unexpected JWT "alg" header parameter',nr,{header:r,expected:e,reason:"client configuration"})}function ng(e,t){let{0:n,length:r}=e.getAll(t);if(r>1)throw tg('"'.concat(t,'" parameter must be provided only once'),nr);return n}let nw=Symbol(),nv=Symbol();async function nb(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tT;try{t=await e.json()}catch(t){throw n(e),tg('failed to parse "response" body as JSON',nn,t)}if(!tw(t))throw tg('"response" body must be a top level object',nr,{body:t});return t}let n_=Symbol(),nk=Symbol(),nS=new TextEncoder,nE=new TextDecoder;function nT(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 nA(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 nP(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64("string"==typeof e?e:nE.decode(e),{alphabet:"base64url"});let t=e;t instanceof Uint8Array&&(t=nE.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/");try{return nA(t)}catch(e){throw TypeError("The input to be decoded is not correctly encoded.")}}class nR extends Error{constructor(e,t){var n;super(e,t),e8(this,"code","ERR_JOSE_GENERIC"),this.name=this.constructor.name,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor)}}e8(nR,"code","ERR_JOSE_GENERIC");class nI extends nR{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unspecified",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:r,payload:t}}),e8(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED"),e8(this,"claim",void 0),e8(this,"reason",void 0),e8(this,"payload",void 0),this.claim=n,this.reason=r,this.payload=t}}e8(nI,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");class nO extends nR{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unspecified",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:r,payload:t}}),e8(this,"code","ERR_JWT_EXPIRED"),e8(this,"claim",void 0),e8(this,"reason",void 0),e8(this,"payload",void 0),this.claim=n,this.reason=r,this.payload=t}}e8(nO,"code","ERR_JWT_EXPIRED");class nC extends nR{constructor(){super(...arguments),e8(this,"code","
1ERR_JOSE_ALG_NOT_ALLOWED")}}e8(nC,"code","ERR_JOSE_ALG_NOT_ALLOWED");class nx extends nR{constructor(){super(...arguments),e8(this,"code","ERR_JOSE_NOT_SUPPORTED")}}e8(nx,"code","ERR_JOSE_NOT_SUPPORTED"),e8(class extends nR{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"decryption operation failed",arguments.length>1?arguments[1]:void 0),e8(this,"code","ERR_JWE_DECRYPTION_FAILED")}},"code","ERR_JWE_DECRYPTION_FAILED"),e8(class extends nR{constructor(){super(...arguments),e8(this,"code","ERR_JWE_INVALID")}},"code","ERR_JWE_INVALID");class nj extends nR{constructor(){super(...arguments),e8(this,"code","ERR_JWS_INVALID")}}e8(nj,"code","ERR_JWS_INVALID");class nD extends nR{constructor(){super(...arguments),e8(this,"code","ERR_JWT_INVALID")}}e8(nD,"code","ERR_JWT_INVALID"),e8(class extends nR{constructor(){super(...arguments),e8(this,"code","ERR_JWK_INVALID")}},"code","ERR_JWK_INVALID");class nL extends nR{constructor(){super(...arguments),e8(this,"code","ERR_JWKS_INVALID")}}e8(nL,"code","ERR_JWKS_INVALID");class nU extends nR{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"no applicable key found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),e8(this,"code","ERR_JWKS_NO_MATCHING_KEY")}}e8(nU,"code","ERR_JWKS_NO_MATCHING_KEY");class nK extends nR{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"multiple matching keys found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),e8(this,Symbol.asyncIterator,void 0),e8(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}}e8(nK,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");class nN extends nR{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"request timed out",arguments.length>1?arguments[1]:void 0),e8(this,"code","ERR_JWKS_TIMEOUT")}}e8(nN,"code","ERR_JWKS_TIMEOUT");class nW extends nR{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"signature verification failed",arguments.length>1?arguments[1]:void 0),e8(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}}e8(nW,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");let nz=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"algorithm.name";return TypeError("CryptoKey does not support this operation, its ".concat(t," must be ").concat(e))},nH=(e,t)=>e.name===t;function nM(e){return parseInt(e.name.slice(4),10)}function nJ(e,t){for(var n,r=arguments.length,o=Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];if((o=o.filter(Boolean)).length>2){let t=o.pop();e+="one of type ".concat(o.join(", "),", or ").concat(t,".")}else 2===o.length?e+="one of type ".concat(o[0]," or ").concat(o[1],"."):e+="of type ".concat(o[0],".");return null==t?e+=" Received ".concat(t):"function"==typeof t&&t.name?e+=" Received function ".concat(t.name):"object"==typeof t&&null!=t&&null!==(n=t.constructor)&&void 0!==n&&n.name&&(e+=" Received an instance of ".concat(t.constructor.name)),e}let nV=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];return nJ("Key for the ".concat(e," algorithm must be "),t,...r)},nG=e=>{if("CryptoKey"===(null==e?void 0:e[Symbol.toStringTag]))return!0;try{return e instanceof CryptoKey}catch(e){return!1}},nF=e=>"KeyObject"===(null==e?void 0:e[Symbol.toStringTag]),nZ=e=>nG(e)||nF(e);function nq(e){if("object"!=typeof e||null===e||"[object Object]"!==Object.prototype.toString.call(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}let nB=(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},nX=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},nY=(e,t,n)=>{if(e.data[e.pos++]!==t)throw Error(n)},nQ=(e,t)=>{let n=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,n},n$=e=>{let t=(e=>{nY(e,6,"Expected algorithm OID");let t=nX(e);return nQ(e,t)})(e);if(nB(t,[43,101,110]))return"X25519";if(!nB(t,[42,134,72,206,61,2,1]))throw Error("Unsupported key algorithm");nY(e,6,"Expected curve OID");let n=nX(e),r=nQ(e,n);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(nB(r,t))return e;throw Error("Unsupported named curve")},n0=async(e,t,n,r)=>{var o;let i,a;let s="spki"===e,c=()=>s?["verify"]:["sign"];switch(n){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:"SHA-".concat(n.slice(-3))},a=c();break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:"SHA-".concat(n.slice(-3))},a=c();break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":i={name:"RSA-OAEP",hash:"SHA-".concat(parseInt(n.slice(-3),10)||1)},a=s?["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=c();break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":try{let e=r.getNamedCurve(t);i="X25519"===e?{name:"X25519"}:{name:"ECDH",namedCurve:e}}catch(e){throw new nx("Invalid or unsupported key format")}a=s?[]:["deriveBits"];break;
1case"Ed25519":case"EdDSA":i={name:"Ed25519"},a=c();break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":i={name:n},a=c();break;default:throw new nx('Invalid or unsupported "alg" (Algorithm) value')}return crypto.subtle.importKey(e,t,i,null!==(o=null==r?void 0:r.extractable)&&void 0!==o?o:!!s,a)},n1=(e,t,n)=>{var r;let o;let i=(o=/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,nA(e.replace(o,""))),a=n;return null!=t&&null!==(r=t.startsWith)&&void 0!==r&&r.call(t,"ECDH-ES")&&(a||(a={}),a.getNamedCurve=e=>{let t={data:e,pos:0};return function(e){nY(e,48,"Invalid PKCS#8 structure"),nX(e),nY(e,2,"Expected version field");let t=nX(e);e.pos+=t,nY(e,48,"Expected algorithm identifier"),nX(e),e.pos}(t),n$(t)}),n0("pkcs8",i,t,a)};async function n2(e){var t,n;if(!e.alg)throw TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:r,keyUsages:o}=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 nx('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:"SHA-".concat(e.alg.slice(-3))},n=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:"SHA-".concat(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-".concat(parseInt(e.alg.slice(-3),10)||1)},n=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new nx('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"EC":switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},n=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},n=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},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 nx('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;
1case"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 nx('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;default:throw new nx('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:n}}(e),i=te({},e);return"AKP"!==i.kty&&delete i.alg,delete i.use,crypto.subtle.importKey("jwk",i,r,null!==(t=e.ext)&&void 0!==t?t:!e.d&&!e.priv,null!==(n=e.key_ops)&&void 0!==n?n:o)}let n5=e=>nq(e)&&"string"==typeof e.kty,n3=async function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];s||(s=new WeakMap);let o=s.get(e);if(null!=o&&o[n])return o[n];let i=await n2(te(te({},t),{},{alg:n}));return r&&Object.freeze(e),o?o[n]=i:s.set(e,{[n]:i}),i};async function n4(e,t){if(e instanceof Uint8Array||nG(e))return e;if(nF(e)){if("secret"===e.type)return e.export();if("toCryptoKey"in e&&"function"==typeof e.toCryptoKey)try{return((e,t)=>{let n;s||(s=new WeakMap);let r=s.get(e);if(null!=r&&r[t])return r[t];let o="public"===e.type,i=!!o;if("x25519"===e.asymmetricKeyType){switch(t){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw TypeError("given KeyObject instance cannot be used for this algorithm")}n=e.toCryptoKey(e.asymmetricKeyType,i,o?[]:["deriveBits"])}if("ed25519"===e.asymmetricKeyType){if("EdDSA"!==t&&"Ed25519"!==t)throw TypeError("given KeyObject instance cannot be used for this algorithm");n=e.toCryptoKey(e.asymmetricKeyType,i,[o?"verify":"sign"])}switch(e.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":if(t!==e.asymmetricKeyType.toUpperCase())throw TypeError("given KeyObject instance cannot be used for this algorithm");n=e.toCryptoKey(e.asymmetricKeyType,i,[o?"verify":"sign"])}if("rsa"===e.asymmetricKeyType){let r;switch(t){case"RSA-OAEP":r="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":r="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":r="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":r="SHA-512";break;default:throw TypeError("given KeyObject instance cannot be used for this algorithm")}if(t.startsWith("RSA-OAEP"))return e.toCryptoKey({name:"RSA-OAEP",hash:r},i,o?["encrypt"]:["decrypt"]);n=e.toCryptoKey({name:t.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:r},i,[o?"verify":"sign"])}if("ec"===e.asymmetricKeyType){var a;let r=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(null===(a=e.asymmetricKeyDetails)||void 0===a?void 0:a.namedCurve);if(!r)throw TypeError("given KeyObject instance cannot be used for this algorithm");"ES256"===t&&"P-256"===r&&(n=e.toCryptoKey({name:"ECDSA",namedCurve:r},i,[o?"verify":"sign"])),"ES384"===t&&"P-384"===r&&(n=e.toCryptoKey({name:"ECDSA",namedCurve:r},i,[o?"verify":"sign"])),"ES512"===t&&"P-521"===r&&(n=e.toCryptoKey({name:"ECDSA",namedCurve:r},i,[o?"verify":"sign"])),t.startsWith("ECDH-ES")&&(n=e.toCryptoKey({name:"ECDH",namedCurve:r},i,o?[]:["deriveBits"]))}if(!n)throw TypeError("given KeyObject instance cannot be used for this algorithm");return r?r[t]=n:s.set(e,{[t]:n}),n})(e,t)}catch(e){if(e instanceof TypeError)throw e}let n=e.export({format:"jwk"});return n3(e,n,t)}if(n5(e))return e.k?nP(e.k):n3(e,e,t,!0);throw Error("unreachable")}let n6=e=>null==e?void 0:e[Symbol.toStringTag],n9=(e,t,n)=>{if(void 0!==t.use){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 "'.concat(e,'" when present'))}if(void 0!==t.alg&&t.alg!==e)throw TypeError('Invalid key for this operation, its "alg" must be "'.concat(e,'" when present'));if(Array.isArray(t.key_ops)){var r,o;let i;switch(!0){case"sign"===n||"verify"===n:case"dir"===e:case e.includes("CBC-HS"):i=n;break;case e.startsWith("PBES2"):i="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):i=!e.includes("GCM")&&e.endsWith("KW")?"encrypt"===n?"wrapKey":"unwrapKey":n;break;case"encrypt"===n&&e.startsWith("RSA"):i="wrapKey";break;case"decrypt"===n:i=e.startsWith("RSA")?"unwrapKey":"deriveBits"}if(i&&!1===(null===(r=t.key_ops)||void 0===r||null===(o=r.includes)||void 0===o?void 0:o.call(r,i)))throw TypeError('Invalid key for this operation, its "key_ops" must include "'.concat(i,'" when present'))}return!0};"undefined"!=typeof navigator&&null!==(rW=navigator.userAgent)&&void 0!==rW&&null!==(rz=rW.startsWith)&&void 0!==rz&&rz.call(rW,"Mozilla/5.0 ")||(c={"user-agent":"".concat("openid-client","/").concat("v6.8.1")});let n8=e=>u.get(e);function n7(e){return void 0!==e?tx(e):(l||(l=new WeakMap),(e,t,n,r)=>{let o;return(o=l.get(t))||(function(e,t){if("string"!=typeof e)throw rn("".concat(t," must be a string"),rt);if(0===e.length)throw rn("".concat(t," must not be empty"),re)}(t.client_secret,'"metadata.client_secret"'),o=tx(t.client_secret),l.set(t,o)),o(e,t,n,r)})}let re="ERR_INVALID_ARG_VALUE",rt="ERR_INVALID_ARG_TYPE";function rn(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}
1class rr extends Error{constructor(e,t){var n;super(e,t),e8(this,"code",void 0),this.name=this.constructor.name,this.code=null==t?void 0:t.code,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor)}}function ro(e,t,n){return new rr(e,{cause:t,code:n})}function ri(e){if(e instanceof TypeError||e instanceof rr||e instanceof tK||e instanceof tN||e instanceof tW)throw e;if(e instanceof ty)switch(e.code){case na:throw ro("only requests to HTTPS are allowed",e,e.code);case ns:throw ro("only requests to HTTP or HTTPS are allowed",e,e.code);case ni:throw ro("unexpected HTTP response status code",e.cause,e.code);case no:throw ro("unexpected response content-type",e.cause,e.code);case nn:throw ro("parsing error occured",e,e.code);case nr:throw ro("invalid response encountered",e,e.code);case nu:throw ro("unexpected JWT claim value encountered",e,e.code);case nl:throw ro("unexpected JSON attribute value encountered",e,e.code);case nc:throw ro("JWT timestamp claim value failed validation",e,e.code);default:throw ro(e.message,e,e.code)}if(e instanceof tm)throw ro("unsupported operation",e,e.code);if(e instanceof DOMException)switch(e.name){case"OperationError":throw ro("runtime operation error",e,ne);case"NotSupportedError":throw ro("runtime unsupported operation",e,ne);case"TimeoutError":throw ro("operation timed out",e,"OAUTH_TIMEOUT");case"AbortError":throw ro("operation aborted",e,"OAUTH_ABORT")}throw new rr("something went wrong",{cause:e})}async function ra(e,t,n,r,o){let i=new rc(await async function(e,t){var n,r,o;if(!(e instanceof URL))throw rn('"server" must be an instance of URL',rt);let i=!e.href.includes("/.well-known/"),a=null!==(n=null==t?void 0:t.timeout)&&void 0!==n?n:30,s=AbortSignal.timeout(1e3*a),u=await (i?tk(e,{algorithm:null==t?void 0:t.algorithm,[tc]:null==t?void 0:t[tc],[ti]:null==t||null===(r=t.execute)||void 0===r?void 0:r.includes(rf),signal:s,headers:new Headers(c)}):((null==t?void 0:t[tc])||fetch)((tD(e,null==t||null===(o=t.execute)||void 0===o||!o.includes(rf)),e.href),{headers:Object.fromEntries(new Headers(te({accept:"application/json"},c)).entries()),body:void 0,method:"GET",redirect:"manual",signal:s})).then(e=>(async function(e,t){if(!(e instanceof URL)&&e!==n_)throw to('"expectedIssuerIdentifier" must be an instance of URL',"ERR_INVALID_ARG_TYPE");if(!tr(t,Response))throw to('"response" must be an instance of Response',"ERR_INVALID_ARG_TYPE");if(200!==t.status)throw tg('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)',ni,t);np(t);let n=await nb(t);if(tE(n.issuer,'"response" body "issuer" property',nr,{body:n}),e!==n_&&new URL(n.issuer).href!==e.href)throw tg('"response" body "issuer" property does not match the expected value',nl,{expected:e.href,body:n,attribute:"issuer"});return n})(n_,e)).catch(ri);return!i||new URL(u.issuer).href===e.href||("https://login.microsoftonline.com"!==e.origin||null!=t&&t.algorithm&&"oidc"!==t.algorithm||(u[rs]=!0,0))&&(!e.hostname.endsWith(".b2clogin.com")||null!=t&&t.algorithm&&"oidc"!==t.algorithm)&&(()=>{throw new rr("discovered metadata issuer does not match the expected issuer",{code:nl,cause:{expected:e.href,body:u,attribute:"issuer"}})})(),u}(e,o),t,n,r),a=n8(i);if(null!=o&&o[tc]&&(a.fetch=o[tc]),null!=o&&o.timeout&&(a.timeout=o.timeout),null!=o&&o.execute)for(let e of o.execute)e(i);return i}new TextDecoder;let rs=Symbol();class rc{constructor(e,t,n,r){var o,i,a,s,c;let l;if("string"!=typeof t||!t.length)throw rn('"clientId" must be a non-empty string',rt);if("string"==typeof n&&(n={client_secret:n}),void 0!==(null===(o=n)||void 0===o?void 0:o.client_id)&&t!==n.client_id)throw rn('"clientId" and "metadata.client_id" must be the same',re);let d=te(te({},structuredClone(n)),{},{client_id:t});d[ta]=null!==(i=null===(a=n)||void 0===a?void 0:a[ta])&&void 0!==i?i:0,d[ts]=null!==(s=null===(c=n)||void 0===c?void 0:c[ts])&&void 0!==s?s:30,l=r||("string"==typeof d.client_secret&&d.client_secret.length?n7(d.client_secret):(e,t,n,r)=>{n.set("client_id",t.client_id)});let h=Object.freeze(d),p=structuredClone(e);rs in e&&(p[nk]=t=>{let{claims:{tid:n}}=t;return e.issuer.replace("{tenantid}",n)});let f=Object.freeze(p);u||(u=new WeakMap),u.set(this,{__proto__:null,as:f,c:h,auth:l,tlsOnly:!0,jwksCache:{}})}serverMetadata(){let e=structuredClone(n8(this).as);return Object.defineProperties(e,{supportsPKCE:{__proto__:null,value(){var t;let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"S256";return!0===(null===(t=e.code_challenge_methods_supported)||void 0===t?void 0:t.includes(n))}}}),e}clientMetadata(){return structuredClone(n8(this).c)}get timeout(){return n8(this).timeout}set timeout(e){n8(this).timeout=e}get[tc](){return n8(this).fetch}set[tc](e){n8(this).fetch=e}}function ru(e){Object.defineProperties(e,function(e){let t;if(void 0!==e.expires_in){let n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime()}
1return{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 tY(this)}catch(e){return}}}}}(e))}async function rl(e,t,n){var r;let o;let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=null===(r=e.headers.get("retry-after"))||void 0===r?void 0:r.trim();if(void 0!==a){if(/^\d+$/.test(a))o=parseInt(a,10);else{let e=new Date(a);if(Number.isFinite(e.getTime())){let t=new Date,n=e.getTime()-t.getTime();n>0&&(o=Math.ceil(n/1e3))}}if(i&&!Number.isFinite(o))throw new ty("invalid Retry-After header value",{cause:e});o>t&&await rd(o-t,n)}}function rd(e,t){return new Promise((n,r)=>{let o=e=>{try{t.throwIfAborted()}catch(e){return void r(e)}if(e<=0)return void n();let i=Math.min(e,5);setTimeout(()=>o(e-i),1e3*i)};o(e)})}async function rh(e,t){rb(e);let{as:n,c:r,auth:o,fetch:i,tlsOnly:a,timeout:s}=n8(e);return(async function(e,t,n,r,o){tO(e),tC(t);let i=tU(e,"backchannel_authentication_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==o?void 0:o[ti])),a=new URLSearchParams(r);a.set("client_id",t.client_id);let s=tv(null==o?void 0:o.headers);return s.set("accept","application/json"),tZ(e,t,n,i,a,s,o)})(n,r,o,t,{[tc]:i,[ti]:!a,headers:new Headers(c),signal:r_(s)}).then(e=>(async function(e,t,n){if(tO(e),tC(t),!tr(n,Response))throw to('"response" must be an instance of Response',"ERR_INVALID_ARG_TYPE");await tV(n,200,"Backchannel Authentication Endpoint"),np(n);let r=await nb(n);tE(r.auth_req_id,'"response" body "auth_req_id" property',nr,{body:r});let o="number"!=typeof r.expires_in?parseFloat(r.expires_in):r.expires_in;return tS(o,!0,'"response" body "expires_in" property',nr,{body:r}),r.expires_in=o,void 0!==r.interval&&tS(r.interval,!1,'"response" body "interval" property',nr,{body:r}),r})(n,r,e)).catch(ri)}async function rp(e,t,n,r){var o,i,a;let s;rb(e),n=new URLSearchParams(n);let u=null!==(o=t.interval)&&void 0!==o?o:5,l=null!==(i=null==r?void 0:r.signal)&&void 0!==i?i:AbortSignal.timeout(1e3*t.expires_in);try{await rd(u,l)}catch(e){ri(e)}let{as:d,c:h,auth:p,fetch:f,tlsOnly:m,nonRepudiation:y,timeout:g,decrypt:w}=n8(e),v=(o,i)=>rp(e,te(te({},t),{},{interval:o}),n,te(te({},r),{},{signal:l,flag:i})),b=await (async function(e,t,n,r,o){tO(e),tC(t),tE(r,'"authReqId"');let i=new URLSearchParams(null==o?void 0:o.additionalParameters);return i.set("auth_req_id",r),tq(e,t,n,"urn:openid:params:grant-type:ciba",i,o)})(d,h,p,t.auth_req_id,{[tc]:f,[ti]:!m,additionalParameters:n,DPoP:null==r?void 0:r.DPoP,headers:new Headers(c),signal:l.aborted?l:r_(g)}).catch(ri);if(503===b.status&&b.headers.has("retry-after"))return await rl(b,u,l,!0),await (null===(a=b.body)||void 0===a?void 0:a.cancel()),v(u);let _=async function(e,t,n,r){return tQ(e,t,n,void 0,null==r?void 0:r[tl],null==r?void 0:r.recognizedTokenTypes)}(d,h,b,{[tl]:w});try{s=await _}catch(e){if(rk(e,r))return v(u,rS);if(e instanceof tK)switch(e.error){case"slow_down":u+=5;case"authorization_pending":return await rl(e.response,u,l),v(u)}ri(e)}return s.id_token&&await (null==y?void 0:y(b)),ru(s),s}function rf(e){n8(e).tlsOnly=!1}async function rm(e,t,n,r,o){let i,a,s;if(rb(e),!((null==o?void 0:o.flag)===rS||t instanceof URL||function(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch(e){return!1}}(t,"Request")))throw rn('"currentUrl" must be an instance of URL, or Request',rt);let{as:u,c:l,auth:d,fetch:h,tlsOnly:p,jarm:f,hybrid:m,nonRepudiation:y,timeout:g,decrypt:w,implicit:v}=n8(e);if((null==o?void 0:o.flag)===rS)i=o.authResponse,a=o.redirectUri;else{var b;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 nm(e));if(m)t.hash=n.toString();else for(let[e,r]of n.entries())t.searchParams.append(e,r);break;default:throw rn("unexpected Request HTTP method",re)}}switch((b=new URL(b=t)).search="",b.hash="",a=b.href,!0){case!!f:i=await f(t,null==n?void 0:n.expectedState);break;case!!m:i=await m(t,null==n?void 0:n.expectedNonce,null==n?void 0:n.expectedState,null==n?void 0:n.maxAge);break;case!!v:throw TypeError("authorizationCodeGrant() cannot be used by response_type=id_token clients");default:try{i=function(e,t,n,r){var o;if(tO(e),tC(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw to('"parameters" must be an instance of URLSearchParams, or URL',"ERR_INVALID_ARG_TYPE");if(ng(n,"response"))throw tg('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()',nr,{parameters:n});let i=ng(n,"iss"),a=ng(n,"state");if(!i&&e.authorization_response_iss_parameter_supported)throw tg('response parameter "iss" (issuer) missing',nr,{parameters:n});if(i&&i!==e.issuer)throw tg('unexpected "iss" (issuer) response parameter value',nr,{expected:e.issuer,parameters:n});switch(r){case void 0:case nv:if(void 0!==a)throw tg('unexpected "state" response parameter encountered',nr,{expected:void 0,parameters:n});break;case nw:break;default:if(tE(r,'"expectedState" argument'),a!==r)throw tg(void 0===a?'response parameter "state" missing':'unexpected "state" response parameter value',nr,{expected:r,parameters:n})}if(ng(n,"error"))throw new tN("authorization response from the server is an error",{cause:n});let s=ng(n,"id_token"),c=ng(n,"token");if(void 0!==s||void 0!==c)throw new tm("implicit and hybrid flows are not supported");return o=new URLSearchParams(n),t1.add(o),o}(u,l,t.searchParams,null==n?void 0:n.expectedState)}catch(e){ri(e)}}}let _=await (async function(e,t,n,r,o,i,a){if(tO(e),tC(t),!t1.has(r))throw to('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()',"E
1RR_INVALID_ARG_VALUE");tE(o,'"redirectUri"');let s=ng(r,"code");if(!s)throw tg('no authorization code in "callbackParameters"',nr);let c=new URLSearchParams(null==a?void 0:a.additionalParameters);return c.set("redirect_uri",o),c.set("code",s),i!==t2&&(tE(i,'"codeVerifier"'),c.set("code_verifier",i)),tq(e,t,n,"authorization_code",c,a)})(u,l,d,i,a,(null==n?void 0:n.pkceCodeVerifier)||t2,{additionalParameters:r,[tc]:h,[ti]:!p,DPoP:null==o?void 0:o.DPoP,headers:new Headers(c),signal:r_(g)}).catch(ri);"string"!=typeof(null==n?void 0:n.expectedNonce)&&"number"!=typeof(null==n?void 0:n.maxAge)||(n.idTokenExpected=!0);let k=t9(u,l,_,{expectedNonce:null==n?void 0:n.expectedNonce,maxAge:null==n?void 0:n.maxAge,requireIdToken:null==n?void 0:n.idTokenExpected,[tl]:w});try{s=await k}catch(t){if(rk(t,o))return rm(e,void 0,n,r,te(te({},o),{},{flag:rS,authResponse:i,redirectUri:a}));ri(t)}return s.id_token&&await (null==y?void 0:y(_)),ru(s),s}async function ry(e,t,n,r){let o;rb(e),n=new URLSearchParams(n);let{as:i,c:a,auth:s,fetch:u,tlsOnly:l,nonRepudiation:d,timeout:h,decrypt:p}=n8(e),f=await (async function(e,t,n,r,o){tO(e),tC(t),tE(r,'"refreshToken"');let i=new URLSearchParams(null==o?void 0:o.additionalParameters);return i.set("refresh_token",r),tq(e,t,n,"refresh_token",i,o)})(i,a,s,t,{[tc]:u,[ti]:!l,additionalParameters:n,DPoP:null==r?void 0:r.DPoP,headers:new Headers(c),signal:r_(h)}).catch(ri),m=async function(e,t,n,r){return tQ(e,t,n,void 0,null==r?void 0:r[tl],null==r?void 0:r.recognizedTokenTypes)}(i,a,f,{[tl]:p});try{o=await m}catch(o){if(rk(o,r))return ry(e,t,n,te(te({},r),{},{flag:rS}));ri(o)}return o.id_token&&await (null==d?void 0:d(f)),ru(o),o}async function rg(e,t,n){let r;rb(e),t=new URLSearchParams(t);let{as:o,c:i,auth:a,fetch:s,tlsOnly:u,timeout:l}=n8(e),d=await (async function(e,t,n,r,o){return tO(e),tC(t),tq(e,t,n,"client_credentials",new URLSearchParams(r),o)})(o,i,a,t,{[tc]:s,[ti]:!u,DPoP:null==n?void 0:n.DPoP,headers:new Headers(c),signal:r_(l)}).catch(ri),h=async function(e,t,n,r){return tQ(e,t,n,void 0,void 0,void 0)}(o,i,d);try{r=await h}catch(r){if(rk(r,n))return rg(e,t,te(te({},n),{},{flag:rS}));ri(r)}return ru(r),r}function rw(e,t){rb(e);let{as:n,c:r,tlsOnly:o,hybrid:i,jarm:a,implicit:s}=n8(e),c=tU(n,"authorization_endpoint",!1,o);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",i?"code id_token":s?"id_token":"code"),s&&!t.has("nonce"))throw rn("response_type=id_token clients must provide a nonce parameter in their authorization request parameters",re);a&&t.set("response_mode","jwt")}for(let[e,n]of t.entries())c.searchParams.append(e,n);return c}async function rv(e,t,n){let r;rb(e);let o=rw(e,t),{as:i,c:a,auth:s,fetch:u,tlsOnly:l,timeout:d}=n8(e),h=await (async function(e,t,n,r,o){var i;tO(e),tC(t);let a=tU(e,"pushed_authorization_request_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==o?void 0:o[ti])),s=new URLSearchParams(r);s.set("client_id",t.client_id);let c=tv(null==o?void 0:o.headers);c.set("accept","application/json"),void 0!==(null==o?void 0:o.DPoP)&&(tG(o.DPoP),await o.DPoP.addProof(a,c,"POST"));let u=await tZ(e,t,n,a,s,c,o);return null==o||null===(i=o.DPoP)||void 0===i||i.cacheNonce(u,a),u})(i,a,s,o.searchParams,{[tc]:u,[ti]:!l,DPoP:null==n?void 0:n.DPoP,headers:new Headers(c),signal:r_(d)}).catch(ri),p=async function(e,t,n){if(tO(e),tC(t),!tr(n,Response))throw to('"response" must be an instance of Response',"ERR_INVALID_ARG_TYPE");await tV(n,201,"Pushed Authorization Request Endpoint"),np(n);let r=await nb(n);tE(r.request_uri,'"response" body "request_uri" property',nr,{body:r});let o="number"!=typeof r.expires_in?parseFloat(r.expires_in):r.expires_in;return tS(o,!0,'"response" body "expires_in" property',nr,{body:r}),r.expires_in=o,r}(i,a,h);try{r=await p}catch(r){if(rk(r,n))return rv(e,t,te(te({},n),{},{flag:rS}));ri(r)}return rw(e,{request_uri:r.request_uri})}function rb(e){if(!(e instanceof rc))throw rn('"config" must be an instance of Configuration',rt);if(Object.getPrototypeOf(e)!==rc.prototype)throw rn("subclassing Configuration is not allowed",re)}function r_(e){return e?AbortSignal.timeout(1e3*e):void 0}function rk(e,t){return!(null==t||!t.DPoP||t.flag===rS)&&function(e){if(e instanceof tW){let{0:t,length:n}=e.cause;return 1===n&&"dpop"===t.scheme&&"use_dpop_nonce"===t.parameters.error}return e instanceof tK&&"use_dpop_nonce"===e.error}(e)}Object.freeze(rc.prototype);let rS=Symbol();async function rE(e,t,n,r){rb(e);let{as:o,c:i,auth:a,fetch:s,tlsOnly:u,timeout:l,decrypt:d}=n8(e),h=await (async function(e,t,n,r,o,i){return tO(e),tC(t),tE(r,'"grantType"'),tq(e,t,n,r,new URLSearchParams(o),i)})(o,i,a,t,new URLSearchParams(n),{[tc]:s,[ti]:!u,DPoP:null==r?void 0:r.DPoP,headers:new Headers(c),signal:r_(l)}).then(e=>{let n;return"urn:ietf:params:oauth:grant-type:token-exchange"===t&&(n={n_a:()=>{}}),async function(e,t,n,r){return tQ(e,t,n,void 0,null==r?void 0:r[tl],null==r?void 0:r.recognizedTokenTypes)}(o,i,e,{[tl]:d,recognizedTokenTypes:n})}).catch(ri);return ru(h),h}async function rT(e,t,n){if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw TypeError(function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return nJ("Key must be ",e,...n)}(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:"SHA-".concat(e.slice(-3)),name:"HMAC"},!1,[n])}
1return function(e,t,n){switch(t){case"HS256":case"HS384":case"HS512":{if(!nH(e.algorithm,"HMAC"))throw nz("HMAC");let n=parseInt(t.slice(2),10);if(nM(e.algorithm.hash)!==n)throw nz("SHA-".concat(n),"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!nH(e.algorithm,"RSASSA-PKCS1-v1_5"))throw nz("RSASSA-PKCS1-v1_5");let n=parseInt(t.slice(2),10);if(nM(e.algorithm.hash)!==n)throw nz("SHA-".concat(n),"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!nH(e.algorithm,"RSA-PSS"))throw nz("RSA-PSS");let n=parseInt(t.slice(2),10);if(nM(e.algorithm.hash)!==n)throw nz("SHA-".concat(n),"algorithm.hash");break}case"Ed25519":case"EdDSA":if(!nH(e.algorithm,"Ed25519"))throw nz("Ed25519");break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":if(!nH(e.algorithm,t))throw nz(t);break;case"ES256":case"ES384":case"ES512":{if(!nH(e.algorithm,"ECDSA"))throw nz("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 nz(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 ".concat(t,"."))}(e,n)}(t,e,n),t}async function rA(e,t,n,r){let o=await rT(e,t,"verify");!function(e,t){if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:n}=t.algorithm;if("number"!=typeof n||n<2048)throw TypeError("".concat(e," requires key modulusLength to be 2048 bits or larger"))}}(e,o);let i=function(e,t){let n="SHA-".concat(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};
1case"Ed25519":case"EdDSA":return{name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return{name:e};default:throw new nx("alg ".concat(e," is not supported either by JOSE or your javascript runtime"))}}(e,o.algorithm);try{return await crypto.subtle.verify(i,o,n,r)}catch(e){return!1}}async function rP(e,t,n){let r,o;if(!nq(e))throw new nj("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new nj('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new nj("JWS Protected Header incorrect type");if(void 0===e.payload)throw new nj("JWS Payload missing");if("string"!=typeof e.signature)throw new nj("JWS Signature missing or incorrect type");if(void 0!==e.header&&!nq(e.header))throw new nj("JWS Unprotected Header incorrect type");let i={};if(e.protected)try{let t=nP(e.protected);i=JSON.parse(nE.decode(t))}catch(e){throw new nj("JWS Protected Header is invalid")}if(!function(){let e;for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];let o=n.filter(Boolean);if(0===o.length||1===o.length)return!0;for(let t of o){let n=Object.keys(t);if(e&&0!==e.size)for(let t of n){if(e.has(t))return!1;e.add(t)}else e=new Set(n)}return!0}(i,e.header))throw new nj("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let a=te(te({},i),e.header),s=function(e,t,n,r,o){let i;if(void 0!==o.crit&&void 0===(null==r?void 0:r.crit))throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!r||void 0===r.crit)return new Set;if(!Array.isArray(r.crit)||0===r.crit.length||r.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');for(let a of(i=void 0!==n?new Map([...Object.entries(n),...t.entries()]):t,r.crit)){if(!i.has(a))throw new nx('Extension Header Parameter "'.concat(a,'" is not recognized'));if(void 0===o[a])throw new e('Extension Header Parameter "'.concat(a,'" is missing'));if(i.get(a)&&void 0===r[a])throw new e('Extension Header Parameter "'.concat(a,'" MUST be integrity protected'))}return new Set(r.crit)}(nj,new Map([["b64",!0]]),null==n?void 0:n.crit,i,a),c=!0;if(s.has("b64")&&"boolean"!=typeof(c=i.b64))throw new nj('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:u}=a;if("string"!=typeof u||!u)throw new nj('JWS "alg" (Algorithm) Header Parameter missing or invalid');let l=n&&function(e,t){if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw TypeError('"'.concat(e,'" option must be an array of strings'));if(t)return new Set(t)}("algorithms",n.algorithms);if(l&&!l.has(u))throw new nC('"alg" (Algorithm) Header Parameter value not allowed');if(c){if("string"!=typeof e.payload)throw new nj("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new nj("JWS Payload must be a string or an Uint8Array instance");let d=!1;"function"==typeof t&&(t=await t(i,e),d=!0),function(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(n5(t)){if("oct"===t.kty&&"string"==typeof t.k&&n9(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(!nZ(t))throw TypeError(nV(e,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if("secret"!==t.type)throw TypeError("".concat(n6(t),' instances for symmetric algorithms must be of type "secret"'))}})(e,t,n);break;default:((e,t,n)=>{if(n5(t))switch(n){case"decrypt":case"sign":if("oct"!==t.kty&&("AKP"===t.kty&&"string"==typeof t.priv||"string"==typeof t.d)&&n9(e,t,n))return;throw TypeError("JSON Web Key for this operation must be a private JWK");case"encrypt":case"verify":if("oct"!==t.kty&&void 0===t.d&&void 0===t.priv&&n9(e,t,n))return;throw TypeError("JSON Web Key for this operation must be a public JWK")}if(!nZ(t))throw TypeError(nV(e,t,"CryptoKey","KeyObject","JSON Web Key"));if("secret"===t.type)throw TypeError("".concat(n6(t),' instances for asymmetric algorithms must not be of type "secret"'));if("public"===t.type)switch(n){case"sign":throw TypeError("".concat(n6(t),' instances for asymmetric algorithm signing must be of type "private"'));case"decrypt":throw TypeError("".concat(n6(t),' instances for asymmetric algorithm decryption must be of type "private"'))}if("private"===t.type)switch(n){case"verify":throw TypeError("".concat(n6(t),' instances for asymmetric algorithm verifying must be of type "public"'));case"encrypt":throw TypeError("".concat(n6(t),' instances for asymmetric algorithm encryption must be of type "public"'))}})(e,t,n)}}(u,t,"verify");let h=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let r=new Uint8Array(t.reduce((e,t)=>
1{let{length:n}=t;return e+n},0)),o=0;for(let e of t)r.set(e,o),o+=e.length;return r}(void 0!==e.protected?nT(e.protected):new Uint8Array,nT("."),"string"==typeof e.payload?c?nT(e.payload):nS.encode(e.payload):e.payload);try{r=nP(e.signature)}catch(e){throw new nj("Failed to base64url decode the signature")}let p=await n4(t,u);if(!await rA(u,p,r,h))throw new nW;if(c)try{o=nP(e.payload)}catch(e){throw new nj("Failed to base64url decode the payload")}else o="string"==typeof e.payload?nS.encode(e.payload):e.payload;let f={payload:o};return void 0!==e.protected&&(f.protectedHeader=i),void 0!==e.header&&(f.unprotectedHeader=e.header),d?te(te({},f),{},{key:p}):f}let rR=e=>Math.floor(e.getTime()/1e3),rI=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function rO(e){let t;let n=rI.exec(e);if(!n||n[4]&&n[1])throw TypeError("Invalid time period format");let r=parseFloat(n[2]);switch(n[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":t=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":t=Math.round(60*r);break;case"hour":case"hours":case"hr":case"hrs":case"h":t=Math.round(3600*r);break;case"day":case"days":case"d":t=Math.round(86400*r);break;case"week":case"weeks":case"w":t=Math.round(604800*r);break;default:t=Math.round(31557600*r)}return"-"===n[1]||"ago"===n[4]?-t:t}let rC=e=>e.includes("/")?e.toLowerCase():"application/".concat(e.toLowerCase()),rx=(e,t)=>"string"==typeof e?t.includes(e):!!Array.isArray(e)&&t.some(Set.prototype.has.bind(new Set(e)));async function rj(e,t,n){var r;let o=await async function(e,t,n){if(e instanceof Uint8Array&&(e=nE.decode(e)),"string"!=typeof e)throw new nj("Compact JWS must be a string or Uint8Array");let{0:r,1:o,2:i,length:a}=e.split(".");if(3!==a)throw new nj("Invalid Compact JWS");let s=await rP({payload:o,protected:r,signature:i},t,n),c={payload:s.payload,protectedHeader:s.protectedHeader};return"function"==typeof t?te(te({},c),{},{key:s.key}):c}(e,t,n);if(null!==(r=o.protectedHeader.crit)&&void 0!==r&&r.includes("b64")&&!1===o.protectedHeader.b64)throw new nD("JWTs MUST NOT use unencoded payload");let i={payload:function(e,t){let n,r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{r=JSON.parse(nE.decode(t))}catch(e){}if(!nq(r))throw new nD("JWT Claims Set must be a top-level JSON object");let{typ:i}=o;if(i&&("string"!=typeof e.typ||rC(e.typ)!==rC(i)))throw new nI('unexpected "typ" JWT header value',r,"typ","check_failed");let{requiredClaims:a=[],issuer:s,subject:c,audience:u,maxTokenAge:l}=o,d=[...a];for(let e of(void 0!==l&&d.push("iat"),void 0!==u&&d.push("aud"),void 0!==c&&d.push("sub"),void 0!==s&&d.push("iss"),new Set(d.reverse())))if(!(e in r))throw new nI('missing required "'.concat(e,'" claim'),r,e,"missing");if(s&&!(Array.isArray(s)?s:[s]).includes(r.iss))throw new nI('unexpected "iss" claim value',r,"iss","check_failed");if(c&&r.sub!==c)throw new nI('unexpected "sub" claim value',r,"sub","check_failed");if(u&&!rx(r.aud,"string"==typeof u?[u]:u))throw new nI('unexpected "aud" claim value',r,"aud","check_failed");switch(typeof o.clockTolerance){case"string":n=rO(o.clockTolerance);break;case"number":n=o.clockTolerance;break;case"undefined":n=0;break;default:throw TypeError("Invalid clockTolerance option type")}let{currentDate:h}=o,p=rR(h||new Date);if((void 0!==r.iat||l)&&"number"!=typeof r.iat)throw new nI('"iat" claim must be a number',r,"iat","invalid");if(void 0!==r.nbf){if("number"!=typeof r.nbf)throw new nI('"nbf" claim must be a number',r,"nbf","invalid");if(r.nbf>p+n)throw new nI('"nbf" claim timestamp check failed',r,"nbf","check_failed")}if(void 0!==r.exp){if("number"!=typeof r.exp)throw new nI('"exp" claim must be a number',r,"exp","invalid");if(r.exp<=p-n)throw new nO('"exp" claim timestamp check failed',r,"exp","check_failed")}if(l){let e=p-r.iat;if(e-n>("number"==typeof l?l:rO(l)))throw new nO('"iat" claim timestamp check failed (too far in the past)',r,"iat","check_failed");if(e<0-n)throw new nI('"iat" claim timestamp check failed (it should be in the past)',r,"iat","check_failed")}return r}(o.protectedHeader,o.payload,n),protectedHeader:o.protectedHeader};return"function"==typeof t?te(te({},i),{},{key:o.key}):i}function rD(e){return nq(e)}var rL,rU,rK,rN,rW,rz,rH,rM,rJ=new WeakMap,rV=new WeakMap;class rG{constructor(e){if(e6(this,rJ,void 0),e6(this,rV,new WeakMap),!(e&&"object"==typeof e&&Array.isArray(e.keys)&&e.keys.every(rD)))throw new nL("JSON Web Key Set malformed");e9(rJ,this,structuredClone(e))}jwks(){return e4(rJ,this)}async getKey(e,t){let{alg:n,kid:r}=te(te({},e),null==t?void 0:t.header),o=function(e){switch("string"==typeof e&&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 nx('Unsupported "alg" value for a JSON Web Key Set')}}(n),i=e4(rJ,this).keys.filter(e=>
1{let t=o===e.kty;if(t&&"string"==typeof r&&(t=r===e.kid),t&&("string"==typeof e.alg||"AKP"===o)&&(t=n===e.alg),t&&"string"==typeof e.use&&(t="sig"===e.use),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes("verify")),t)switch(n){case"ES256":t="P-256"===e.crv;break;case"ES384":t="P-384"===e.crv;break;case"ES512":t="P-521"===e.crv;break;case"Ed25519":case"EdDSA":t="Ed25519"===e.crv}return t}),{0:a,length:s}=i;if(0===s)throw new nU;if(1!==s){var c;let e=new nK,t=e4(rV,this);throw e[Symbol.asyncIterator]=(c=function*(){for(let r of i)try{var e;yield yield(e=rF(t,r,n),new e2(e,0))}catch(e){}},function(){return new tn(c.apply(this,arguments))}),e}return rF(e4(rV,this),a,n)}}async function rF(e,t,n){let r=e.get(t)||e.set(t,{}).get(t);if(void 0===r[n]){let e=await async function(e,t,n){let r;if(!nq(e))throw TypeError("JWK must be an object");switch(null!=t||(t=e.alg),null!=r||(r=e.ext),e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw TypeError('missing "k" (Key Value) Parameter value');return nP(e.k);case"RSA":if("oth"in e&&void 0!==e.oth)throw new nx('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');return n2(te(te({},e),{},{alg:t,ext:r}));case"AKP":if("string"!=typeof e.alg||!e.alg)throw TypeError('missing "alg" (Algorithm) Parameter value');if(void 0!==t&&t!==e.alg)throw TypeError("JWK alg and alg option value mismatch");return n2(te(te({},e),{},{ext:r}));case"EC":case"OKP":return n2(te(te({},e),{},{alg:t,ext:r}));default:throw new nx('Unsupported "kty" (Key Type) Parameter value')}}(te(te({},t),{},{ext:!0}),n);if(e instanceof Uint8Array||"public"!==e.type)throw new nL("JSON Web Key Set members must be public keys");r[n]=e}return r[n]}function rZ(e){let t=new rG(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}"undefined"!=typeof navigator&&null!==(rH=navigator.userAgent)&&void 0!==rH&&null!==(rM=rH.startsWith)&&void 0!==rM&&rM.call(rH,"Mozilla/5.0 ")||(d="".concat("jose","/").concat("v6.1.3"));let rq=Symbol(),rB=Symbol();var rX=new WeakMap,rY=new WeakMap,rQ=new WeakMap,r$=new WeakMap,r0=new WeakMap,r1=new WeakMap,r2=new WeakMap,r5=new WeakMap,r3=new WeakMap,r4=new WeakMap;class r6{constructor(e,t){var n,r;if(e6(this,rX,void 0),e6(this,rY,void 0),e6(this,rQ,void 0),e6(this,r$,void 0),e6(this,r0,void 0),e6(this,r1,void 0),e6(this,r2,void 0),e6(this,r5,void 0),e6(this,r3,void 0),e6(this,r4,void 0),!(e instanceof URL))throw TypeError("url must be an instance of URL");e9(rX,this,new URL(e.href)),e9(rY,this,"number"==typeof(null==t?void 0:t.timeoutDuration)?null==t?void 0:t.timeoutDuration:5e3),e9(rQ,this,"number"==typeof(null==t?void 0:t.cooldownDuration)?null==t?void 0:t.cooldownDuration:3e4),e9(r$,this,"number"==typeof(null==t?void 0:t.cacheMaxAge)?null==t?void 0:t.cacheMaxAge:6e5),e9(r2,this,new Headers(null==t?void 0:t.headers)),d&&!e4(r2,this).has("User-Agent")&&e4(r2,this).set("User-Agent",d),e4(r2,this).has("accept")||(e4(r2,this).set("accept","application/json"),e4(r2,this).append("accept","application/jwk-set+json")),e9(r5,this,null==t?void 0:t[rq]),void 0!==(null==t?void 0:t[rB])&&(e9(r4,this,null==t?void 0:t[rB]),n=null==t?void 0:t[rB],r=e4(r$,this),"object"==typeof n&&null!==n&&"uat"in n&&"number"==typeof n.uat&&!(Date.now()-n.uat>=r)&&"jwks"in n&&nq(n.jwks)&&Array.isArray(n.jwks.keys)&&Array.prototype.every.call(n.jwks.keys,nq)&&(e9(r0,this,e4(r4,this).uat),e9(r3,this,rZ(e4(r4,this).jwks))))}pendingFetch(){return!!e4(r1,this)}coolingDown(){return"number"==typeof e4(r0,this)&&Date.now()<e4(r0,this)+e4(rQ,this)}fresh(){return"number"==typeof e4(r0,this)&&Date.now()<e4(r0,this)+e4(r$,this)}jwks(){var e;return null===(e=e4(r3,this))||void 0===e?void 0:e.jwks()}async getKey(e,t){e4(r3,this)&&this.fresh()||await this.reload();try{return await e4(r3,this).call(this,e,t)}catch(n){if(n instanceof nU&&!1===this.coolingDown())return await this.reload(),e4(r3,this).call(this,e,t);throw n}}async reload(){e4(r1,this)&&("undefined"!=typeof WebSocketPair||"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"undefined"!=typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&e9(r1,this,void 0),e4(r1,this)||e9(r1,this,(async function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:fetch,o=await r(e,{method:"GET",signal:n,redirect:"manual",headers:t}).catch(e=>{if("TimeoutError"===e.name)throw new nN;throw e});if(200!==o.status)throw new nR("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await o.json()}catch(e){throw new nR("Failed to parse the JSON Web Key Set HTTP response as JSON")}})(e4(rX,this).href,e4(r2,this),AbortSignal.timeout(e4(rY,this)),e4(r5,this)).then(e=>{e9(r3,this,rZ(e)),e4(r4,this)&&(e4(r4,this).uat=Date.now(),e4(r4,this).jwks=e),e9(r0,this,Date.now()),e9(r1,this,void 0)}).catch(e=>{throw e9(r1,this,void 0),e})),await e4(r1,this)}}let r9=["mfaToken"],r8=["mfaToken"];
1var r7,oe,ot,on,or,oo,oi,oa,os=class extends Error{constructor(e,t){super(t),e8(this,"code",void 0),this.name="NotSupportedError",this.code=e}},oc=class extends Error{constructor(e,t,n){super(t),e8(this,"cause",void 0),e8(this,"code",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},ou=class extends oc{constructor(e,t){super("token_by_code_error",e,t),this.name="TokenByCodeError"}},ol=class extends oc{constructor(e,t){super("token_by_client_credentials_error",e,t),this.name="TokenByClientCredentialsError"}},od=class extends oc{constructor(e,t){super("token_by_refresh_token_error",e,t),this.name="TokenByRefreshTokenError"}},oh=class extends oc{constructor(e,t){super("token_for_connection_error",e,t),this.name="TokenForConnectionErrorCode"}},op=class extends oc{constructor(e,t){super("token_exchange_error",e,t),this.name="TokenExchangeError"}},of=class extends Error{constructor(e){super(e),e8(this,"code","verify_logout_token_error"),this.name="VerifyLogoutTokenError"}},om=class extends oc{constructor(e){super("backchannel_authentication_error","There was an error when trying to use Client-Initiated Backchannel Authentication.",e),e8(this,"code","backchannel_authentication_error"),this.name="BackchannelAuthenticationError"}},oy=class extends oc{constructor(e){super("build_authorization_url_error","There was an error when trying to build the authorization URL.",e),this.name="BuildAuthorizationUrlError"}},og=class extends oc{constructor(e){super("build_link_user_url_error","There was an error when trying to build the Link User URL.",e),this.name="BuildLinkUserUrlError"}},ow=class extends oc{constructor(e){super("build_unlink_user_url_error","There was an error when trying to build the Unlink User URL.",e),this.name="BuildUnlinkUserUrlError"}},ov=class extends Error{constructor(){super("The client secret or client assertion signing key must be provided."),e8(this,"code","missing_client_auth_error"),this.name="MissingClientAuthError"}};function ob(e){return Object.entries(e).filter(e=>{let[,t]=e;return void 0!==t}).reduce((e,t)=>te(te({},e),{},{[t[0]]:t[1]}),{})}var o_=class extends Error{constructor(e,t,n){super(t),e8(this,"cause",void 0),e8(this,"code",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},ok=class extends o_{constructor(e,t){super("mfa_list_authenticators_error",e,t),this.name="MfaListAuthenticatorsError"}},oS=class extends o_{constructor(e,t){super("mfa_enrollment_error",e,t),this.name="MfaEnrollmentError"}},oE=class extends o_{constructor(e,t){super("mfa_delete_authenticator_error",e,t),this.name="MfaDeleteAuthenticatorError"}},oT=class extends o_{constructor(e,t){super("mfa_challenge_error",e,t),this.name="MfaChallengeError"}};function oA(e){return{id:e.id,authenticatorType:e.authenticator_type,active:e.active,name:e.name,oobChannels:e.oob_channels,type:e.type}}var oP=(r7=new WeakMap,oe=new WeakMap,ot=new WeakMap,class{constructor(e){var t;e6(this,r7,void 0),e6(this,oe,void 0),e6(this,ot,void 0),e9(r7,this,"https://".concat(e.domain)),e9(oe,this,e.clientId),e9(ot,this,null!==(t=e.customFetch)&&void 0!==t?t:function(){return fetch(...arguments)})}async listAuthenticators(e){let t="".concat(e4(r7,this),"/mfa/authenticators"),{mfaToken:n}=e,r=await e4(ot,this).call(this,t,{method:"GET",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"}});if(!r.ok){let e=await r.json();throw new ok(e.error_description||"Failed to list authenticators",e)}return(await r.json()).map(oA)}async enrollAuthenticator(e){let t="".concat(e4(r7,this),"/mfa/associate"),{mfaToken:n}=e,r=tt(e,r9),o={authenticator_types:r.authenticatorTypes};"oobChannels"in r&&(o.oob_channels=r.oobChannels),"phoneNumber"in r&&r.phoneNumber&&(o.phone_number=r.phoneNumber),"email"in r&&r.email&&(o.email=r.email);let i=await e4(ot,this).call(this,t,{method:"POST",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"},body:JSON.stringify(o)});if(!i.ok){let e=await i.json();throw new oS(e.error_description||"Failed to enroll authenticator",e)}return function(e){if("otp"===e.authenticator_type)return{authenticatorType:"otp",secret:e.secret,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes,id:e.id};if("oob"===e.authenticator_type)return{authenticatorType:"oob",oobChannel:e.oob_channel,oobCode:e.oob_code,bindingMethod:e.binding_method,id:e.id};throw Error("Unexpected authenticator type: ".concat(e.authenticator_type))}(await i.json())}async deleteAuthenticator(e){let{authenticatorId:t,mfaToken:n}=e,r="".concat(e4(r7,this),"/mfa/authenticators/").concat(encodeURIComponent(t)),o=await e4(ot,this).call(this,r,{method:"DELETE",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"}});if(!o.ok){let e=await o.json();throw new oE(e.error_description||"Failed to delete authenticator",e)}}async challengeAuthenticator(e){let t="".concat(e4(r7,this),"/mfa/challenge"),{mfaToken:n}=e,r=tt(e,r8),o={mfa_token:n,client_id:e4(oe,this),challenge_type:r.challengeType};r.authenticatorId&&(o.authenticator_id=r.authenticatorId);let i=await e4(ot,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!i.ok){let e=await i.json();throw new oT(e.error_description||"Failed to challenge authenticator",e)}return function(e){let t={challengeType:e.challenge_type};return void 0!==e.oob_code&&(t.oobCode=e.oob_code),void 0!==e.binding_method&&(t.bindingMethod=e.binding_method),t}(await i.json())}}),oR=class e{constructor(e,t,n,r,o,i,a){e8(this,"accessToken",void 0),e8(this,"idToken",void 0),e8(this,"refreshToken",void 0),e8(this,"expiresAt",void 0),e8(this,"scope",void 0),e8(this,"claims",void 0),e8(this,"authorizationDetail
1s",void 0),e8(this,"tokenType",void 0),e8(this,"issuedTokenType",void 0),this.accessToken=e,this.idToken=n,this.refreshToken=r,this.expiresAt=t,this.scope=o,this.claims=i,this.authorizationDetails=a}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}},oI="openid profile email offline_access",oO=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 oC(e){if(null==e)throw new op("subject_token is required");if("string"!=typeof e)throw new op("subject_token must be a string");if(0===e.trim().length)throw new op("subject_token cannot be blank or whitespace");if(e!==e.trim())throw new op("subject_token must not include leading or trailing whitespace");if(/^bearer\s+/i.test(e))throw new op("subject_token must not include the 'Bearer ' prefix")}function ox(e,t){if(t){for(let[n,r]of Object.entries(t))if(!oO.has(n)){if(Array.isArray(r)){if(r.length>20)throw new op("Parameter '".concat(n,"' exceeds maximum array size of ").concat(20));r.forEach(t=>{e.append(n,t)})}else e.append(n,r)}}}var oj=(on=new WeakMap,or=new WeakMap,oo=new WeakMap,oi=new WeakMap,oa=new WeakSet,class{constructor(e){if(e3(this,oa),oa.add(this),e6(this,on,void 0),e6(this,or,void 0),e6(this,oo,void 0),e6(this,oi,void 0),e8(this,"mfa",void 0),e9(oo,this,e),e.useMtls&&!e.customFetch)throw new os("mtls_without_custom_fetch_not_supported","Using mTLS without a custom fetch implementation is not supported");this.mfa=new oP({domain:e4(oo,this).domain,clientId:e4(oo,this).clientId,customFetch:e4(oo,this).customFetch})}async buildAuthorizationUrl(e){let{serverMetadata:t}=await e5(oa,this,oD).call(this);if(null!=e&&e.pushedAuthorizationRequests&&!t.pushed_authorization_request_endpoint)throw new os("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 e5(oa,this,oN).call(this,e)}catch(e){throw new oy(e)}}async buildLinkUserUrl(e){try{let t=await e5(oa,this,oN).call(this,{authorizationParams:te(te({},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 og(e)}}async buildUnlinkUserUrl(e){try{let t=await e5(oa,this,oN).call(this,{authorizationParams:te(te({},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 ow(e)}}async backchannelAuthentication(e){let{configuration:t,serverMetadata:n}=await e5(oa,this,oD).call(this),r=ob(te(te({},e4(oo,this).authorizationParams),null==e?void 0:e.authorizationParams)),o=new URLSearchParams(te(te({scope:oI},r),{},{client_id:e4(oo,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:n.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&o.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&o.append("authorization_details",JSON.stringify(e.authorizationDetails));try{let e=await rh(t,o),n=await rp(t,e);return oR.fromTokenEndpointResponse(n)}catch(e){throw new om(e)}}async initiateBackchannelAuthentication(e){let{configuration:t,serverMetadata:n}=await e5(oa,this,oD).call(this),r=ob(te(te({},e4(oo,this).authorizationParams),null==e?void 0:e.authorizationParams)),o=new URLSearchParams(te(te({scope:oI},r),{},{client_id:e4(oo,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:n.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&o.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetail
1s&&o.append("authorization_details",JSON.stringify(e.authorizationDetails));try{let e=await rh(t,o);return{authReqId:e.auth_req_id,expiresIn:e.expires_in,interval:e.interval}}catch(e){throw new om(e)}}async backchannelAuthenticationGrant(e){let{authReqId:t}=e,{configuration:n}=await e5(oa,this,oD).call(this),r=new URLSearchParams({auth_req_id:t});try{let e=await rE(n,"urn:openid:params:grant-type:ciba",r);return oR.fromTokenEndpointResponse(e)}catch(e){throw new om(e)}}async getTokenForConnection(e){var t;if(e.refreshToken&&e.accessToken)throw new oh("Either a refresh or access token should be specified, but not both.");let n=null!==(t=e.accessToken)&&void 0!==t?t:e.refreshToken;if(!n)throw new oh("Either a refresh or access token must be specified.");try{return await this.exchangeToken({connection:e.connection,subjectToken:n,subjectTokenType:e.accessToken?"urn:ietf:params:oauth:token-type:access_token":"urn:ietf:params:oauth:token-type:refresh_token",loginHint:e.loginHint})}catch(e){if(e instanceof op)throw new oh(e.message,e.cause);throw e}}async exchangeToken(e){return"connection"in e?e5(oa,this,oL).call(this,e):e5(oa,this,oU).call(this,e)}async getTokenByCode(e,t){let{configuration:n}=await e5(oa,this,oD).call(this);try{let r=await rm(n,e,{pkceCodeVerifier:t.codeVerifier});return oR.fromTokenEndpointResponse(r)}catch(e){throw new ou("There was an error while trying to request a token.",e)}}async getTokenByRefreshToken(e){let{configuration:t}=await e5(oa,this,oD).call(this);try{let n=await ry(t,e.refreshToken);return oR.fromTokenEndpointResponse(n)}catch(e){throw new od("The access token has expired and there was an error while trying to refresh it.",e)}}async getTokenByClientCredentials(e){let{configuration:t}=await e5(oa,this,oD).call(this);try{let n=new URLSearchParams({audience:e.audience});e.organization&&n.append("organization",e.organization);let r=await rg(t,n);return oR.fromTokenEndpointResponse(r)}catch(e){throw new ol("There was an error while trying to request a token.",e)}}async buildLogoutUrl(e){let{configuration:t,serverMetadata:n}=await e5(oa,this,oD).call(this);if(!n.end_session_endpoint){let t=new URL("https://".concat(e4(oo,this).domain,"/v2/logout"));return t.searchParams.set("returnTo",e.returnTo),t.searchParams.set("client_id",e4(oo,this).clientId),t}return function(e,t){rb(e);let{as:n,c:r,tlsOnly:o}=n8(e),i=tU(n,"end_session_endpoint",!1,o);for(let[e,n]of((t=new URLSearchParams(t)).has("client_id")||t.set("client_id",r.client_id),t.entries()))i.searchParams.append(e,n);return i}(t,{post_logout_redirect_uri:e.returnTo})}async verifyLogoutToken(e){let{serverMetadata:t}=await e5(oa,this,oD).call(this);e4(oi,this)||e9(oi,this,function(e,t){let n=new r6(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(t.jwks_uri),{[rq]:e4(oo,this).customFetch}));let{payload:n}=await rj(e.logoutToken,e4(oi,this),{issuer:t.issuer,audience:e4(oo,this).clientId,algorithms:["RS256"],requiredClaims:["iat"]});if(!("sid"in n)&&!("sub"in n))throw new of('either "sid" or "sub" (or both) claims must be present');if("sid"in n&&"string"!=typeof n.sid)throw new of('"sid" claim must be a string');if("sub"in n&&"string"!=typeof n.sub)throw new of('"sub" claim must be a string');if("nonce"in n)throw new of('"nonce" claim is prohibited');if(!("events"in n))throw new of('"events" claim is missing');if("object"!=typeof n.events||null===n.events)throw new of('"events" claim must be an object');if(!("http://schemas.openid.net/event/backchannel-logout"in n.events))throw new of('"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim');if("object"!=typeof n.events["http://schemas.openid.net/event/backchannel-logout"])throw new of('"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object');return{sid:n.sid,sub:n.sub}}});async function oD(){if(e4(on,this)&&e4(or,this))return{configuration:e4(on,this),serverMetadata:e4(or,this)};let e=await e5(oa,this,oK).call(this);return e9(on,this,await ra(new URL("https://".concat(e4(oo,this).domain)),e4(oo,this).clientId,{use_mtls_endpoint_aliases:e4(oo,this).useMtls},e,{[tc]:e4(oo,this).customFetch})),e9(or,this,e4(on,this).serverMetadata()),e4(on,this)[tc]=e4(oo,this).customFetch||fetch,{configuration:e4(on,this),serverMetadata:e4(or,this)}}async function oL(e){var t,n;let{configuration:r}=await e5(oa,this,oD).call(this);if("audience"in e||"resource"in e)throw new op("audience and resource parameters are not supported for Token Vault exchanges");oC(e.subjectToken);let o=new URLSearchParams({connection:e.connection,subject_token:e.subjectToken,subject_token_type:null!==(t=e.subjectTokenType)&&void 0!==t?t:"urn:ietf:params:oauth:token-type:access_token",requested_token_type:null!==(n=e.requestedTokenType)&&void 0!==n?n:"http://auth0.com/oauth/token-type/federated-connection-access-token"});e.loginHint&&o.append("login_hint",e.loginHint),e.scope&&o.append("scope",e.scope),ox(o,e.extra);try{let e=await rE(r,"urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token",o);return oR.fromTokenEndpointResponse(e)}catch(t){throw new op("Failed to exchange token for connection '".concat(e.connection,"'."),t)}}
1async function oU(e){let{configuration:t}=await e5(oa,this,oD).call(this);oC(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),ox(n,e.extra);try{let e=await rE(t,"urn:ietf:params:oauth:grant-type:token-exchange",n);return oR.fromTokenEndpointResponse(e)}catch(t){throw new op("Failed to exchange token of type '".concat(e.subjectTokenType,"'").concat(e.audience?" for audience '".concat(e.audience,"'"):"","."),t)}}async function oK(){if(!e4(oo,this).clientSecret&&!e4(oo,this).clientAssertionSigningKey&&!e4(oo,this).useMtls)throw new ov;if(e4(oo,this).useMtls)return(e,t,n,r)=>{n.set("client_id",t.client_id)};let e=e4(oo,this).clientAssertionSigningKey;return!e||e instanceof CryptoKey||(e=await async function(e,t,n){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw TypeError('"pkcs8" must be PKCS#8 formatted string');return n1(e,t,void 0)}(e,e4(oo,this).clientAssertionSigningAlg||"RS256")),e?function(e,t){let{key:n,kid:r}=e instanceof CryptoKey?{key:e}:(null==e?void 0:e.key)instanceof CryptoKey?(void 0!==e.kid&&tE(e.kid,'"kid"'),{key:e.key,kid:e.kid}):{};return function(e,t){if(function(e,t){if(!(e instanceof CryptoKey))throw to("".concat(t," must be a CryptoKey"),"ERR_INVALID_ARG_TYPE")}(e,t),"private"!==e.type)throw to("".concat(t," must be a private CryptoKey"),"ERR_INVALID_ARG_VALUE")}(n,'"clientPrivateKey.key"'),async(e,o,i,a)=>{var s;let c={alg:function(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 tm("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 tm("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 tm("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 tm("unsupported CryptoKey algorithm name",{cause:e})}}(n),kid:r},u=function(e,t){let n=tI()+tP(t);return{jti:tA(),aud:e.issuer,exp:n+60,iat:n,nbf:n,iss:t.client_id,sub:t.client_id}}(e,o);null==t||null===(s=t[tu])||void 0===s||s.call(t,c,u),i.set("client_id",o.client_id),i.set("client_assertion_type","urn:ietf:params:oauth:client-assertion-type:jwt-bearer"),i.set("client_assertion",await async function(e,t,n){if(!n.usages.includes("sign"))throw to('CryptoKey instances used for signing assertions must include "sign" in their "usages"',"ERR_INVALID_ARG_VALUE");let r="".concat(tf(tp(JSON.stringify(e))),".").concat(tf(tp(JSON.stringify(t)))),o=tf(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case"ECDSA":return{name:e.algorithm.name,hash:function(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 tm("unsupported ECDSA namedCurve",{cause:e})}}(e)};case"RSA-PSS":switch(nf(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 tm("unsupported RSA-PSS hash name",{cause:e})}case"RSASSA-PKCS1-v1_5":return nf(e),e.algorithm.name;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":case"Ed25519":return e.algorithm.name}throw new tm("unsupported CryptoKey algorithm name",{cause:e})}(n),n,tp(r)));return"".concat(r,".").concat(o)}(c,u,n))}}(e,void 0):n7(e4(oo,this).clientSecret)}async function oN(e){let{configuration:t}=await e5(oa,this,oD).call(this),n=tA(),r=await async function(e){return tE(e,"codeVerifier"),tf(await crypto.subtle.digest("SHA-256",tp(e)))}(n),o=ob(te(te({},e4(oo,this).authorizationParams),null==e?void 0:e.authorizationParams)),i=new URLSearchParams(te(te({scope:oI},o),{},{client_id:e4(oo,this).clientId,code_challenge:r,code_challenge_method:"S256"}));return{authorizationUrl:null!=e&&e.pushedAuthorizationRequests?await rv(t,i):await rw(t,i),codeVerifier:n}}class oW extends j{constructor(e,t){super(e,t),Object.setPrototypeOf(this,oW.prototype)}static fromPayload(e){let{error:t,error_description:n}=e;return new oW(t,n)}}class oz extends oW{constructor(e,t){super(e,t),Object.setPrototypeOf(this,oz.prototype)}}class oH extends oW{constructor(e,t){super(e,t),Object.setPrototypeOf(this,oH.prototype)}}class oM extends oW{constructor(e,t){super(e,t),Object.setPrototypeOf(this,oM.prototype)}}class oJ extends oW{constructor(e,t){super(e,t),Object.setPrototypeOf(this,oJ.prototype)}}class oV extends oW{constructor(e,t){super(e,t),Object.setPrototypeOf(this,oV.prototype)}}class oG{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6e5;this.contexts=new Map,this.ttlMs=e}set(e,t){this.cleanup(),this.contexts.set(e,Object.assign(Object.assign({},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}}class oF{constructor(e,t){this.authJsMfaClient=e,this.auth0Client=t,this.contextManager=new oG}
1setMFAAuthDetails(e,t,n,r){this.contextManager.set(e,{scope:t,audience:n,mfaRequirements:r})}async getAuthenticators(e){var t,n;let r=this.contextManager.get(e);if(!(null===(t=null==r?void 0:r.mfaRequirements)||void 0===t?void 0:t.challenge)||0===r.mfaRequirements.challenge.length)throw new oz("invalid_request","challengeType is required and must contain at least one challenge type, please check mfa_required error payload");let o=r.mfaRequirements.challenge.map(e=>e.type);try{return(await this.authJsMfaClient.listAuthenticators({mfaToken:e})).filter(e=>!!e.type&&o.includes(e.type))}catch(e){if(e instanceof ok)throw new oz(null===(n=e.cause)||void 0===n?void 0:n.error,e.message);throw e}}async enroll(e){var t;let n=function(e){let t=e1[e.factorType];return Object.assign(Object.assign(Object.assign({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(n)}catch(e){if(e instanceof oS)throw new oH(null===(t=e.cause)||void 0===t?void 0:t.error,e.message);throw e}}async challenge(e){var t;try{let t={challengeType:e.challengeType,mfaToken:e.mfaToken};return e.authenticatorId&&(t.authenticatorId=e.authenticatorId),await this.authJsMfaClient.challengeAuthenticator(t)}catch(e){if(e instanceof oT)throw new oM(null===(t=e.cause)||void 0===t?void 0:t.error,e.message);throw e}}async getEnrollmentFactors(e){let t=this.contextManager.get(e);if(!t||!t.mfaRequirements)throw new oV("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&&0!==t.mfaRequirements.enroll.length?t.mfaRequirements.enroll:[]}async verify(e){let t=this.contextManager.get(e.mfaToken);if(!t)throw new oJ("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="otp"in e&&e.otp?"http://auth0.com/oauth/grant-type/mfa-otp":"oobCode"in e&&e.oobCode?"http://auth0.com/oauth/grant-type/mfa-oob":"recoveryCode"in e&&e.recoveryCode?"http://auth0.com/oauth/grant-type/mfa-rec
1overy-code":void 0;if(!n)throw new oJ("invalid_request","Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.");let r=t.scope,o=t.audience;try{let t=await this.auth0Client._requestTokenForMfa({grant_type:n,mfaToken:e.mfaToken,scope:r,audience:o,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 z)this.setMFAAuthDetails(e.mfa_token,r,o,e.mfa_requirements);else if(e instanceof oJ)throw new oJ(e.error,e.error_description);throw e}}}let oZ=new I;class oq{constructor(e){var t,n;let r,o,i,a,s;if(this.userCache=(new eS).enclosedCache,this.activeLockKeys=new Set,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0},this._releaseLockOnPageHide=async()=>{for(let e of Array.from(this.activeLockKeys))await oZ.releaseLock(e);this.activeLockKeys.clear(),window.removeEventListener("pagehide",this._releaseLockOnPageHide)},this.options=Object.assign(Object.assign(Object.assign({},this.defaultOptions),e),{authorizationParams:Object.assign(Object.assign({},this.defaultOptions.authorizationParams),e.authorizationParams)}),"undefined"!=typeof window&&(()=>{if(!G())throw Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(void 0===G().subtle)throw Error("\n 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.\n ")})(),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)o=e.cache;else{if(!eF(r=e.cacheLocation||"memory"))throw Error('Invalid cache location "'.concat(r,'"'));o=eF(r)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=!1===e.legacySameSiteCookie?ej:eD,this.orgHintCookieName=(t=this.options.clientId,"auth0.".concat(t,".organization_hint")),this.isAuthenticatedCookieName=(i=this.options.clientId,"auth0.".concat(i,".is.authenticated")),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;let c=e.useCookiesForTransactions?this.cookieStorage:eL;this.scope=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];if("object"!=typeof e)return{default:ev(t,e,...r)};let i={default:ev(t,...r)};return Object.keys(e).forEach(n=>{let o=e[n];i[n]=ev(t,o,...r)}),i}(this.options.authorizationParams.scope,"openid",this.options.useRefreshTokens?"offline_access":""),this.transactionManager=new eT(c,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||x,this.cacheManager=new eE(o,o.allKeys?void 0:new eV(o,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new eY(this.options.clientId):void 0,this.domainUrl=(n=this.options.domain,/^https?:\/\//.test(n)?n:"https://".concat(n)),this.tokenIssuer=(a=this.options.issuer,s=this.domainUrl,a?a.startsWith("https://")?a:"https://".concat(a,"/"):"".concat(s,"/"));let u="".concat(this.domainUrl,"/me/"),l=this.createFetcher(Object.assign(Object.assign({},this.options.useDpop&&{dpopNonceId:"__auth0_my_account_api__"}),{getAccessToken:()=>this.getTokenSilently({authorizationParams:{scope:"create:me:connected_accounts",audience:u},detailedResponse:!0})}));this.myAccountApi=new e$(l,u),this.authJsClient=new oj({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new oF(this.authJsClient.mfa,this),"undefined"!=typeof window&&window.Worker&&this.options.useRefreshTokens&&"memory"===r&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new eH)}getConfiguration(){return Object.freeze({domain:this.options.domain,clientId:this.options.clientId})}_url(e){let t=encodeURIComponent(btoa(JSON.stringify(B(this.options.auth0Client||C,!0))));return"".concat(this.domainUrl).concat(e,"&auth0Client=").concat(t)}_authorizeUrl(e){return this._url("/authorize?".concat(X(e)))}async _verifyIdToken(e,t,n){var r;let o=await this.nowProvider();return eR({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:t,organization:n,leeway:this.options.leeway,max_age:"string"!=typeof(r=this.options.authorizationParams.max_age)?r:parseInt(r,10)||void 0,now:o})}_processOrgHint(e){e?this.cookieStorage.save(this.orgHintCookieName,e,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}async _prepareAuthorizeUrl(e,t,n){var r;let o,i,a,s;let c=Z(F()),u=Z(F()),l=F(),d=$(await Y(l)),h=await (null===(r=this.dpop)||void 0===r?void 0:r.calculateThumbprint()),p=(o=this.options,i=this.scope,a=e.redirect_uri||this.options.authorizationParams.redirect_uri||n,s=null==t?void 0:t.response_mode,Object.assign(Object.assign(Object.assign({client_id:o.clientId}
1,o.authorizationParams),e),{scope:eb(i,e.scope,e.audience),response_type:"code",response_mode:s||"query",state:c,nonce:u,redirect_uri:a||o.authorizationParams.redirect_uri,code_challenge:d,code_challenge_method:"S256",dpop_jkt:h})),f=this._authorizeUrl(p);return{nonce:u,code_verifier:l,scope:p.scope,audience:p.audience||"default",redirect_uri:p.redirect_uri,state:c,url:f}}async loginWithPopup(e,t){var n;let r;if(e=e||{},!(t=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=".concat(t,",top=").concat(n,",width=").concat(400,",height=").concat(600,",resizable,scrollbars=yes,status=1"))})(""),!t.popup))throw new W;let o=await this._prepareAuthorizeUrl(e.authorizationParams||{},{response_mode:"web_message"},window.location.origin);t.popup.location.href=o.url;let i=await (r=Object.assign(Object.assign({},t),{timeoutInSeconds:t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),new Promise((e,t)=>{let n;let o=setInterval(()=>{r.popup&&r.popup.closed&&(clearInterval(o),clearTimeout(i),window.removeEventListener("message",n,!1),t(new N(r.popup)))},1e3),i=setTimeout(()=>{clearInterval(o),t(new K(r.popup)),window.removeEventListener("message",n,!1)},1e3*(r.timeoutInSeconds||60));n=function(a){if(a.data&&"authorization_response"===a.data.type){if(clearTimeout(i),clearInterval(o),window.removeEventListener("message",n,!1),!1!==r.closePopup&&r.popup.close(),a.data.response.error)return t(j.fromPayload(a.data.response));e(a.data.response)}},window.addEventListener("message",n)}));if(o.state!==i.state)throw new j("state_mismatch","Invalid state");let a=(null===(n=e.authorizationParams)||void 0===n?void 0:n.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:o.audience,scope:o.scope,code_verifier:o.code_verifier,grant_type:"authorization_code",code:i.code,redirect_uri:o.redirect_uri},{nonceIn:o.nonce,organization:a})}async getUser(){var e;let t=await this._getIdTokenFromCache();return null===(e=null==t?void 0:t.decodedToken)||void 0===e?void 0:e.user}async getIdTokenClaims(){var e;let t=await this._getIdTokenFromCache();return null===(e=null==t?void 0:t.decodedToken)||void 0===e?void 0:e.claims}async loginWithRedirect(){var e;let t=eZ(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{openUrl:n,fragment:r,appState:o}=t,i=w(t,["openUrl","fragment","appState"]),a=(null===(e=i.authorizationParams)||void 0===e?void 0:e.organization)||this.options.authorizationParams.organization,s=await this._prepareAuthorizeUrl(i.authorizationParams||{}),{url:c}=s,u=w(s,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},u),{appState:o,response_type:eN.Code}),a&&{organization:a}));let l=r?"".concat(c,"#").concat(r):c;n?await n(l):window.location.assign(l)}async handleRedirectCallback(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location.href).split("?").slice(1);if(0===e.length)throw Error("There are no query params available for parsing.");let t=this.transactionManager.get();if(!t)throw new j("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===eN.ConnectCode?this._handleConnectAccountRedirectCallback(n,t):this._handleLoginRedirectCallback(n,t)}async _handleLoginRedirectCallback(e,t){let{code:n,state:r,error:o,error_description:i}=e;if(o)throw new D(o,i||o,r,t.appState);if(!t.code_verifier||t.state&&t.state!==r)throw new j("state_mismatch","Invalid state");let a=t.organization,s=t.nonce,c=t.redirect_uri;return await this._requestToken(Object.assign({audience:t.audience,scope:t.scope,code_verifier:t.code_verifier,grant_type:"authorization_code",code:n},c?{redirect_uri:c}:{}),{nonceIn:s,organization:a}),{appState:t.appState,response_type:eN.Code}}
1async _handleConnectAccountRedirectCallback(e,t){let{connect_code:n,state:r,error:o,error_description:i}=e;if(o)throw new L(o,i||o,t.connection,r,t.appState);if(!n)throw new j("missing_connect_code","Missing connect code");if(!(t.code_verifier&&t.state&&t.auth_session&&t.redirect_uri&&t.state===r))throw new j("state_mismatch","Invalid state");return Object.assign(Object.assign({},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:eN.ConnectCode})}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get("auth0.is.authenticated"))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove("auth0.is.authenticated")}try{await this.getTokenSilently(e)}catch(e){}}async getTokenSilently(){var e,t,n,r;let o;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=Object.assign(Object.assign({cacheMode:"on"},i),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),i.authorizationParams),{scope:eb(this.scope,null===(e=i.authorizationParams)||void 0===e?void 0:e.scope,(null===(t=i.authorizationParams)||void 0===t?void 0:t.audience)||this.options.authorizationParams.audience)})}),s=await (n=()=>this._getTokenSilently(a),(o=eM[r="".concat(this.options.clientId,"::").concat(a.authorizationParams.audience,"::").concat(a.authorizationParams.scope)])||(o=n().finally(()=>{delete eM[r],o=null}),eM[r]=o),o);return i.detailedResponse?s:null==s?void 0:s.access_token}async _getTokenSilently(e){var t,n;let{cacheMode:r}=e,o=w(e,["cacheMode"]);if("off"!==r){let e=await this._getEntryFromCache({scope:o.authorizationParams.scope,audience:o.authorizationParams.audience||"default",clientId:this.options.clientId,cacheMode:r});if(e)return e}if("cache-only"===r)return;let i=(t=this.options.clientId,n=o.authorizationParams.audience||"default","".concat("auth0.lock.getTokenSilently",".").concat(t,".").concat(n));if(!await eJ(()=>oZ.acquireLock(i,5e3),10))throw new U;this.activeLockKeys.add(i),1===this.activeLockKeys.size&&window.addEventListener("pagehide",this._releaseLockOnPageHide);try{if("off"!==r){let e=await this._getEntryFromCache({scope:o.authorizationParams.scope,audience:o.authorizationParams.audience||"default",clientId:this.options.clientId});if(e)return e}let{id_token:e,token_type:t,access_token:n,oauthTokenScope:i,expires_in:a}=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(o):await this._getTokenFromIFrame(o);return Object.assign(Object.assign({id_token:e,token_type:t,access_token:n},i?{scope:i}:null),{expires_in:a})}finally{await oZ.releaseLock(i),this.activeLockKeys.delete(i),0===this.activeLockKeys.size&&window.removeEventListener("pagehide",this._releaseLockOnPageHide)}}async getTokenWithPopup(){var e,t;let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=Object.assign(Object.assign({},n),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),n.authorizationParams),{scope:eb(this.scope,null===(e=n.authorizationParams)||void 0===e?void 0:e.scope,(null===(t=n.authorizationParams)||void 0===t?void 0:t.audience)||this.options.authorizationParams.audience)})});return r=Object.assign(Object.assign({},O),r),await this.loginWithPopup(o,r),(await this.cacheManager.get(new e_({scope:o.authorizationParams.scope,audience:o.authorizationParams.audience||"default",clientId:this.options.clientId}),void 0,this.options.useMrrt)).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(e){null!==e.clientId?e.clientId=e.clientId||this.options.clientId:delete e.clientId;let t=e.logoutParams||{},{federated:n}=t,r=w(t,["federated"]);return this._url("/v2/logout?".concat(X(Object.assign({clientId:e.clientId},r))))+(n?"&federated":"")}async logout(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=eZ(t),{openUrl:r}=n,o=w(n,["openUrl"]);null===t.clientId?await this.cacheManager.clear():await this.cacheManager.clear(t.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove("@@user@@"),await (null===(e=this.dpop)||void 0===e?void 0:e.clear());let i=this._buildLogoutUrl(o);r?await r(i):!1!==r&&window.location.assign(i)}async _getTokenFromIFrame(e){var t;let n=(t=this.options.clientId,"".concat("auth0.lock.getTokenFromIFrame",".").concat(t));if(!await eJ(()=>oZ.acquireLock(n,5e3),10))throw new U;try{let t;let n=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),r=this.cookieStorage.get(this.orgHintCookieName);r&&!n.organization&&(n.organization=r);let{url:o,state:i,nonce:a,code_verifier:s,redirect_uri:c,scope:u,audience:l}=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin);if(window.crossOriginIsolated)throw new j("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");let d=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds;try{t=new URL(this.domainUrl).origin}catch(e){t=this.domainUrl}let h=await function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60;return new Promise((r,o)=>{let i;let a=window.document.createElement("iframe");a.setAttribute("width","0"),a.setAttribute("height","0"),a.style.display="none";let s=()=>{window.document.body.contains(a)&&(window.document.body.removeChild(a),window.removeEventListener("message",i,!1))},c=setTimeout(()=>{o(new U),s()},1e3*n);i=function(e){if(e.origin!=t||!e.data||"authorization_response"!==e.data.type)return;let n=e.source;n&&n.close(),e.data.response.error?o(j.fromPayload(e.data.response)):r(e.data.response),clearTimeout(c),window.removeEventListener("message",i,!1),setTimeout(s,2e3)},window.addEventListener("message",i,!1),window.document.body.appendChild(a),a.setAttribute("src",e)})}(o,t,d);if(i!==h.state)throw new j("state_mismatch","Invalid state");let p=await this._requestToken(Object.assign(Object.assign({}
1,e.authorizationParams),{code_verifier:s,code:h.code,grant_type:"authorization_code",redirect_uri:c,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:n.organization});return Object.assign(Object.assign({},p),{scope:u,oauthTokenScope:p.scope,audience:l})}catch(e){throw"login_required"===e.error&&this.logout({openUrl:!1}),e}finally{await oZ.releaseLock(n)}}async _getTokenUsingRefreshToken(e){var t,n,r,o,i,a;let s=await this.cacheManager.get(new e_({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||"default",clientId:this.options.clientId}),void 0,this.options.useMrrt);if(!(s&&s.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw new H(e.authorizationParams.audience||"default",e.authorizationParams.scope)}let c=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,u="number"==typeof e.timeoutInSeconds?1e3*e.timeoutInSeconds:null,l=((e,t,n,r)=>{var o;if(e&&n&&r){if(t.audience!==n)return t.scope;let e=r.split(" "),i=(null===(o=t.scope)||void 0===o?void 0:o.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,null==s?void 0:s.audience,null==s?void 0:s.scope);try{let t=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:"refresh_token",refresh_token:s&&s.refresh_token,redirect_uri:c}),u&&{timeout:u}),{scopesToRequest:l});if(t.refresh_token&&(null==s?void 0:s.refresh_token)&&await this.cacheManager.updateEntry(s.refresh_token,t.refresh_token),this.options.useMrrt&&(r=null==s?void 0:s.audience,o=null==s?void 0:s.scope,i=e.authorizationParams.audience,a=e.authorizationParams.scope,(r!==i||!eq(a,o))&&!eq(l,t.scope))){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);await this.cacheManager.remove(this.options.clientId,e.authorizationParams.audience,e.authorizationParams.scope);let n=((e,t)=>{let n=(null==e?void 0:e.split(" "))||[],r=(null==t?void 0:t.split(" "))||[];return n.filter(e=>-1==r.indexOf(e)).join(",")})(l,t.scope);throw new M(e.authorizationParams.audience||"default",n)}return Object.assign(Object.assign({},t),{scope:e.authorizationParams.scope,oauthTokenScope:t.scope,audience:e.authorizationParams.audience||"default"})}catch(r){if(r.message){if(r.message.includes("user is blocked"))throw await this.logout({openUrl:!1}),r;if((r.message.includes("Missing Refresh Token")||r.message.includes("invalid refresh token"))&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e)}throw r instanceof z&&this.mfa.setMFAAuthDetails(r.mfa_token,null===(t=e.authorizationParams)||void 0===t?void 0:t.scope,null===(n=e.authorizationParams)||void 0===n?void 0:n.audience,r.mfa_requirements),r}}async _saveEntryInCache(e){let{id_token:t,decodedToken:n}=e,r=w(e,["id_token","decodedToken"]);this.userCache.set("@@user@@",{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||"default",t=this.scope[e],n=await this.cacheManager.getIdToken(new e_({clientId:this.options.clientId,audience:e,scope:t})),r=this.userCache.get("@@user@@");return n&&n.id_token===(null==r?void 0:r.id_token)?r:(this.userCache.set("@@user@@",n),n)}async _getEntryFromCache(e){let{scope:t,audience:n,clientId:r,cacheMode:o}=e,i=await this.cacheManager.get(new e_({scope:t,audience:n,clientId:r}),60,this.options.useMrrt,o);if(i&&i.access_token){let{token_type:e,access_token:t,oauthTokenScope:n,expires_in:r}=i,o=await this._getIdTokenFromCache();return o&&Object.assign(Object.assign({id_token:o.id_token,token_type:e||"Bearer",access_token:t},n?{scope:n}:null),{expires_in:r})}}async _requestToken(e,t){var n,r;let{nonceIn:o,organization:i,scopesToRequest:a}=t||{},s=await eg(Object.assign(Object.assign({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:a||e.scope}),this.worker),c=await this._verifyIdToken(s.id_token,o,i);if("authorization_code"===e.grant_type){let e=await this._getIdTokenFromCache();(null===(r=null===(n=null==e?void 0:e.decodedToken)||void 0===n?void 0:n.claims)||void 0===r?void 0:r.sub)&&e.decodedToken.claims.sub!==c.claims.sub&&(await this.cacheManager.clear(this.options.clientId),this.userCache.remove("@@user@@"))}return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},s),{decodedToken:c,scope:e.scope,audience:e.audience||"default"}),s.scope?{oauthTokenScope:s.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(i||c.claims.org_id),Object.assign(Object.assign({},s),{decodedToken:c})}async loginWithCustomTokenExchange(e){return this._requestToken(Object.assign(Object.assign({},e),{grant_type:"urn:ietf:params:oauth:grant-type:token-exchange",subject_token:e.subject_token,subject_token_type:e.subject_token_type,scope:eb(this.scope,e.scope,e.audie
1nce||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&&void 0!==arguments[0]?arguments[0]:{};return new eQ(e,{isDpopEnabled:()=>!!this.options.useDpop,getAccessToken:e=>{var t;return this.getTokenSilently({authorizationParams:{scope:null===(t=null==e?void 0:e.scope)||void 0===t?void 0:t.join(" "),audience:null==e?void 0: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:o,authorization_params:i,redirectUri:a=this.options.authorizationParams.redirect_uri||window.location.origin}=e;if(!r)throw Error("connection is required");let s=Z(F()),c=F(),u=$(await Y(c)),{connect_uri:l,connect_params:d,auth_session:h}=await this.myAccountApi.connectAccount({connection:r,scopes:o,redirect_uri:a,state:s,code_challenge:u,code_challenge_method:"S256",authorization_params:i});this.transactionManager.create({state:s,code_verifier:c,auth_session:h,redirect_uri:a,appState:n,connection:r,response_type:eN.ConnectCode});let p=new URL(l);p.searchParams.set("ticket",d.ticket),t?await t(p.toString()):window.location.assign(p)}async _requestTokenForMfa(e,t){let{mfaToken:n}=e,r=w(e,["mfaToken"]);return this._requestToken(Object.assign(Object.assign({},r),{mfa_token:n}),t)}}var oB={isAuthenticated:!1,isLoading:!0,error:void 0,user:void 0},oX=function(){throw Error("You forgot to wrap your component in <Auth0Provider>.")},oY=f(f({},oB),{buildAuthorizeUrl:oX,buildLogoutUrl:oX,getAccessTokenSilently:oX,getAccessTokenWithPopup:oX,getIdTokenClaims:oX,loginWithCustomTokenExchange:oX,exchangeToken:oX,loginWithRedirect:oX,loginWithPopup:oX,connectAccountWithRedirect:oX,logout:oX,handleRedirectCallback:oX,getDpopNonce:oX,setDpopNonce:oX,generateDpopProof:oX,createFetcher:oX,getConfiguration:oX}),oQ=(0,h.createContext)(oY),o$=function(e){function t(n,r){var o=e.call(this,null!=r?r:n)||this;return o.error=n,o.error_description=r,Object.setPrototypeOf(o,t.prototype),o}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}p(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t}(Error),o0=/[?&](?:connect_)?code=[^&]+/,o1=/[?&]state=[^&]+/,o2=/[?&]error=[^&]+/,o5=function(e){return function(t){return t instanceof Error?t:null!==t&&"object"==typeof t&&"error"in t&&"string"==typeof t.error?"error_description"in t&&"string"==typeof t.error_description?new o$(t.error,t.error_description):new o$(t.error):Error(e)}},o3=o5("Login failed"),o4=o5("Get access token failed"),o6=function(e){var t,n;(null==e?void 0: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=null!==(t=e.authorizationParams)&&void 0!==t?t:{},e.authorizationParams.redirect_uri=e.redirectUri,delete e.redirectUri),(null===(n=null==e?void 0:e.authorizationParams)||void 0===n?void 0:n.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)},o9=function(e,t){switch(t.type){case"LOGIN_POPUP_STARTED":return f(f({},e),{isLoading:!0});case"LOGIN_POPUP_COMPLETE":case"INITIALISED":return f(f({},e),{isAuthenticated:!!t.user,user:t.user,isLoading:!1,error:void 0});case"HANDLE_REDIRECT_COMPLETE":case"GET_ACCESS_TOKEN_COMPLETE":if(e.user===t.user)return e;return f(f({},e),{isAuthenticated:!!t.user,user:t.user});case"LOGOUT":return f(f({},e),{isAuthenticated:!1,user:void 0});case"ERROR":return f(f({},e),{isLoading:!1,error:t.error})}},o8=function(e){var t;window.history.replaceState({},document.title,null!==(t=e.returnTo)&&void 0!==t?t:window.location.pathname)},o7=function(e){var t=e.children,n=e.skipRedirectCallback,r=e.onRedirectCallback,o=void 0===r?o8:r,i=e.context,a=void 0===i?oQ:i,s=m(e,["children","skipRedirectCallback","onRedirectCallback","context"]),c=(0,h.useState)(function(){return new oq((o6(s),f(f({},s),{auth0Client:{name:"auth0-react",version:"2.13.0"}})))})[0],u=(0,h.useReducer)(o9,oB),l=u[0],d=u[1],p=(0,h.useRef)(!1),w=(0,h.useCallback)(function(e){return d({type:"ERROR",error:e}),e},[]);(0,h.useEffect)(function(){p.current||(p.current=!0,y(void 0,void 0,void 0,function(){var e,t,r,i,a,s;return g(this,function(u){switch(u.label){case 0:var l;if(u.trys.push([0,7,,8]),e=void 0,void 0===l&&(l=window.location.search),!((o0.test(l)||o2.test(l))&&o1.test(l))||n)return[3,3];return[4,c.handleRedirectCallback()];case 1:return i=void 0===(r=(t=u.sent()).appState)?{}:r,a=t.response_type,s=m(t,["appState","response_type"]),[4,c.getUser()];case 2:return e=u.sent(),i.response_type=a,a===eN.ConnectCode&&(i.connectedAccount=s),o(i,e),[3,6];case 3:return[4,c.checkSession()];case 4:return u.sent(),[4,c.getUser()];case 5:e=u.sent(),u.label=6;case 6:return d({type:"INITIALISED",user:e}),[3,8];case 7:return w(o3(u.sent())),[3,8];case 8:return[2]}})}))},[c,o,n,w]);var v=(0,h.useCallback)(function(e){return o6(e),c.loginWithRedirect(e)},[c]),b=(0,h.useCallback)(function(e,t){return y(void 0,void 0,void 0,function(){return g(this,function(n){switch(n.label){case 0:d({type:"LOGIN_POPUP_STARTED"}),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,c.loginWithPopup(e,t)];case 2:return n.sent(),[3,4];case 3:return w(o3(n.sent())),[2];case 4:return[4,c.getUser()];case 5:return d({type:"LOGIN_POPUP_COMPLETE",user:n.sent()}),[2]}})})},[c,w]),_=(0,h.useCallback)(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return y(void 0,function(e,t,n){if(n||2==arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([],e,!0),void 0,function(e){return void 0===e&&(e={}),g(this,function(t){switch(t.label){case 0:return[4,c.logout(e)];case 1:return t.sent(),(e.openUrl||!1===e.openUrl)&&d({type:"LOGOUT"}),[2]}})})},[c]),k=(0,h.useCallback)(function(e){return y(void 0,void 0,void 0,function(){var t,n,r;return g(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,3,5]),[4,c.getTokenSilently(e)];case 1:return t=o.sent(),[3,5];case 2:throw o4(o.sent());case 3:return n=d,r={type:"GET_ACCESS_TOKEN_COMPLETE"},[4,c.getUser()];case 4:return n.apply(void 0,[(r.user=o.sent(),r)]),[7];case 5:return[2,t]}})})},[c]),S=(0,h.useCallback)(function(e,t){return y(void 0,void 0,void 0,function(){var n,r,o;return g(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,3,5]),[4,c.getTokenWithPopup(e,t)];case 1:return n=i.sent(),[3,5];case 2:throw o4(i.sent());case 3:return r=d,o={type:"GET_ACCESS_TOKEN_COMPLETE"},[4,c.getUser()];case 4:return r.apply(void 0,[(o.user=i.sent(),o)]),[7];case 5:return[2,n]}})})},[c]),E=(0,h.useCallback)(function(e){return c.connectAccountWithRedirect(e)},[c]),T=(0,h.useCallback)(function(){return c.getIdTokenClaims()},[c]),A=(0,h.useCallback)(function(e){return y(void 0,void 0,void 0,function(){var t,n,r;return g(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,3,5]),[4,c.loginWithCustomTokenExchange(e)];case 1:return t=o.sent(),[3,5];case 2:throw o4(o.sent());case 3:return n=d,r={type:"GET_ACCESS_TOKEN_COMPLETE"},[4,c.getUser()];case 4:return n.apply(void 0,[(r.user=o.sent(),r)]),[7];case 5:return[2,t]}})})},[c]),P=(0,h.useCallback)(function(e){return y(void 0,void 0,void 0,function(){return g(this,function(t){return[2,A(e)]})})},[A]),R=(0,h.useCallback)(function(e){return y(void 0,void 0,void 0,function(){var t,n;return g(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,3,5]),[4,c.handleRedirectCallback(e)];case 1:return[2,r.sent()];case 2:throw o4(r.sent());case 3:return t=d,n={type:"HANDLE_REDIRECT_COMPLETE"},[4,c.getUser()];case 4:return t.apply(void 0,[(n.user=r.sent(),n)]),[7];case 5:return[2]}})})},[c]),I=(0,h.useCallback)(function(e){return c.getDpopNonce(e)},[c]),O=(0,h.useCallback)(function(e,t){return c.setDpopNonce(e,t)},[c]),C=(0,h.useCallback)(function(e){return c.generateDpopProof(e)},[c]),x=(0,h.useCallback)(function(e){return c.createFetcher(e)},[c]),j=(0,h.useCallback)(function(){return c.getConfiguration()},[c]),D=(0,h.useMemo)(function(){return f(f({},l),{getAccessTokenSilently:k,getAccessTokenWithPopup:S,getIdTokenClaims:T,loginWithCustomTokenExchange:A,exchangeToken:P,loginWithRedirect:v,loginWithPopup:b,connectAccountWithRedirect:E,logout:_,handleRedirectCallback:R,getDpopNonce:I,setDpopNonce:O,generateDpopProof:C,createFetcher:x,getConfiguration:j})},[l,k,S,T,A,P,v,b,E,_,R,I,O,C,x,j]);return h.createElement(a.Provider,{value:D},t)},ie=function(e){return void 0===e&&(e=oQ),(0,h.useContext)(e)},it=function(e,t){return void 0===t&&(t=oQ),function(n){return h.createElement(t.Consumer,null,function(t){return h.createElement(e,f({},n,{auth0:t}))})}},ir=function(){return y(void 0,void 0,void 0,function(){return g(this,function(e){return[2]})})},io=function(){return"".concat(window.location.pathname).concat(window.location.search)},ii=function(e,t){return void 0===t&&(t={}),function(n){var r=this,o=t.returnTo,i=void 0===o?io:o,a=t.onRedirecting,s=t.onBeforeAuthentication,c=void 0===s?ir:s,u=t.loginOptions,l=t.context,d=ie(void 0===l?oQ:l),p=d.isAuthenticated,m=d.isLoading,w=d.loginWithRedirect;
1return(0,h.useEffect)(function(){if(!m&&!p){var e=f(f({},u),{appState:f(f({},null==u?void 0:u.appState),{returnTo:"function"==typeof i?i():i})});y(r,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,c()];case 1:return t.sent(),[4,w(e)];case 2:return t.sent(),[2]}})})}},[m,p,w,c,u,i]),p?h.createElement(e,f({},n)):(void 0===a?function(){return h.createElement(h.Fragment,null)}:a)()}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.