"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[330],{7176:(e,t,n)=>{let r,i,o,a,s,c,l,u,h,d;n.d(t,{WB:()=>sQ,y2:()=>sB});var p,f,m,y,g,w,v,b,_,k,S,T,C,P,E,A,R,x,O,I,j,W,N,U,M,L,z,K,J,D,H,Z,F,G,V,X,q,Y,B,Q,$,ee,et,en,er,ei,eo,ea,es,ec,el,eu,eh,ed,ep,ef,em,ey,eg,ew,ev,eb,e_=n(2115),ek=function(e,t){return(ek=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)},eS=function(){return(eS=Object.assign||function(e){for(var t,n=1,r=arguments.length;nt.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);it.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function eC(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(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 eP(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[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){var l=[s,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&l[0]?r.return:l[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,l[1])).done)return i;switch(r=0,i&&(l=[2&l[0],i.value]),l[0]){case 0:case 1:i=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===l[0]||2===l[0])){o=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);it.indexOf(r[i])&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function eA(e,t,n,r){if("a"===n&&!r)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function eR(e,t,n,r,i){if("m"===r)throw TypeError("Private method is not writable");if("a"===r&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(e,n):i?i.value=n:t.set(e,n),n}function ex(e,t){this.v=e,this.k=t}function eO(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);nDate.now(),eB="default";class eQ extends Error{static fromPayload(e){return new eQ(e.error,e.error_description)}constructor(e,t,n){super(t),this.error=e,this.error_description=t,this.data=n,Object.setPrototypeOf(this,eQ.prototype)}}class e$ extends eQ{constructor(e,t){super("invalid_configuration","".concat(e," ").concat(t)),this.suggestion=t,Object.setPrototypeOf(this,e$.prototype)}}class e0 extends eQ{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,e0.prototype)}}class e1 extends eQ{constructor(e,t,n,r){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;super(e,t),this.connection=n,this.state=r,this.appState=i,Object.setPrototypeOf(this,e1.prototype)}}class e2 extends eQ{constructor(){super("timeout","Timeout"),Object.setPrototypeOf(this,e2.prototype)}}class e5 extends e2{constructor(e){super(),this.popup=e,Object.setPrototypeOf(this,e5.prototype)}}class e3 extends eQ{constructor(e){super("cancelled","Popup closed"),this.popup=e,Object.setPrototypeOf(this,e3.prototype)}}class e9 extends eQ{constructor(){super("popup_open","Unable to open a popup for loginWithPopup - window.open returned `null`"),Object.setPrototypeOf(this,e9.prototype)}}class e4 extends eQ{constructor(e,t,n,r){super(e,t),this.mfa_token=n,this.mfa_requirements=r,Object.setPrototypeOf(this,e4.prototype)}}class e6 extends eQ{constructor(e){super("verification_required","Identifier verification is required before passkey creation. Collect OTP codes for each identifier and call passkey.continueSignup()."),this.verificationRequired=e,Object.setPrototypeOf(this,e6.prototype)}}class e8 extends eQ{constructor(e,t){super("missing_refresh_token","Missing Refresh Token (audience: '".concat(tt(e,["default"]),"', scope: '").concat(tt(t),"')")),this.audience=e,this.scope=t,Object.setPrototypeOf(this,e8.prototype)}}class e7 extends eQ{constructor(e,t){super("missing_scopes","Missing requested scopes after refresh (audience: '".concat(tt(e,["default"]),"', missing scope: '").concat(tt(t),"')")),this.audience=e,this.scope=t,Object.setPrototypeOf(this,e7.prototype)}}class te extends eQ{constructor(e){super("use_dpop_nonce","Server rejected DPoP proof: wrong nonce"),this.newDpopNonce=e,Object.setPrototypeOf(this,te.prototype)}}function tt(e){return e&&!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).includes(e)?e:""}let tn=()=>window.crypto,tr=()=>{let e="";for(;e.length<43;)for(let t of tn().getRandomValues(new Uint8Array(43-e.length)))e.length<43&&t<198&&(e+="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~."[t%66]);return e},ti=e=>btoa(e),to=[{key:"name",type:["string"]},{key:"version",type:["string","number"]},{key:"env",type:["object"]}],ta=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 i=to.find(e=>e.key===r);return i&&i.type.includes(typeof e[r])&&(n[r]=e[r]),n},{})},ts=e=>new URLSearchParams((e=>Object.keys(e).filter(t=>void 0!==e[t]).reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:e[n]}),{}))(Object.assign({client_id:e.clientId},eE(e,["clientId"])))).toString(),tc=async e=>{let t=tn().subtle.digest({name:"SHA-256"},(new TextEncoder).encode(e));return await t},tl=e=>decodeURIComponent(atob(e.replace(/_/g,"/").replace(/-/g,"+")).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")),tu=e=>{let t=new Uint8Array(e);return(e=>{let t={"+":"-","/":"_","=":""};return e.replace(/[+/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(t))))};var th="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{},td={},tp={};Object.defineProperty(tp,"__esModule",{value:!0});var tf=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}();tp.default=function(){return tf.getInstance()};var tm=th&&th.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(a,s)}c((r=r.apply(e,t||[])).next())})},ty=th&&th.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){var c=[o,s];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]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().forEach(function(e){return e()})},e.prototype.releaseLock=function(e){return tm(this,void 0,void 0,function(){return ty(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 tm(this,void 0,void 0,function(){var n,r,i,o;return ty(this,function(a){switch(a.label){case 0:return n=void 0===this.storageHandler?tw:this.storageHandler,r=tg+"-"+t,null===(i=n.getItemSync(r))?[2]:(o=JSON.parse(i)).id!==this.id?[3,2]:[4,tp.default().lock(o.iat)];case 1:a.sent(),this.acquiredIatSet.delete(o.iat),n.removeItemSync(r),tp.default().unlock(o.iat),e.notifyWaiters(),a.label=2;case 2:return[2]}})})},e.lockCorrector=function(t){for(var n=Date.now()-5e3,r=[],i=0;;){var o=t.keySync(i);if(null===o)break;r.push(o),i++}for(var a=!1,s=0;sr.abort(),t);try{return await navigator.locks.request(e,{mode:"exclusive",signal:r.signal},async e=>{if(clearTimeout(i),!e)throw Error("Lock not available");return await n()})}catch(e){if(clearTimeout(i),r.signal.aborted&&"AbortError"===(null==e?void 0:e.name))throw new e2;throw e}}}class tS{async runWithLock(e,t,n){let r=!1;for(let n=0;n<10&&!r;n++)r=await this.lock.acquireLock(e,t);if(!r)throw new e2;this.activeLocks.add(e),1===this.activeLocks.size&&"undefined"!=typeof window&&window.addEventListener("pagehide",this.pagehideHandler);try{return await n()}finally{this.activeLocks.delete(e),await this.lock.releaseLock(e),0===this.activeLocks.size&&"undefined"!=typeof window&&window.removeEventListener("pagehide",this.pagehideHandler)}}constructor(){this.activeLocks=new Set,this.lock=new t_,this.pagehideHandler=()=>{this.activeLocks.forEach(e=>this.lock.releaseLock(e)),this.activeLocks.clear()}}}let tT=null;function tC(){var e;return tT||(tT="undefined"!=typeof navigator&&"function"==typeof(null==(e=navigator.locks)?void 0:e.request)?new tk:new tS),tT}let tP={},tE=new TextEncoder,tA=new TextDecoder;function tR(e){return"string"==typeof e?tE.encode(e):tA.decode(e)}function tx(e){if("number"!=typeof e.modulusLength||e.modulusLength<2048)throw new tj("".concat(e.name," modulusLength must be at least 2048 bits"))}async function tO(e,t,n){var i,o,a;if(!1===n.usages.includes("sign"))throw TypeError('private CryptoKey instances used for signing assertions must include "sign" in their "usages"');let s="".concat((i=tR(JSON.stringify(e)),r(i)),".").concat((o=tR(JSON.stringify(t)),r(o)));return"".concat(s,".").concat((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 tx(e.algorithm),{name:e.algorithm.name,saltLength:32};case"RSASSA-PKCS1-v1_5":return tx(e.algorithm),{name:e.algorithm.name};case"Ed25519":return{name:e.algorithm.name}}throw new tI}(n),n,tR(s)),r(a)))}r=Uint8Array.prototype.toBase64?e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0})):e=>{e instanceof ArrayBuffer&&(e=new Uint8Array(e));let t=[];for(let n=0;nnew Promise(function(n,r){let i=new MessageChannel;i.port1.onmessage=function(e){e.data.error?r(Error(e.data.error)):n(e.data),i.port1.close()},t.postMessage(e,[i.port2])}),tJ=(e,t,n)=>{let r,i=new AbortController;return t.signal=i.signal,Promise.race([fetch(e,t),new Promise((e,t)=>{r=setTimeout(()=>{i.abort(),t(Error("Timeout when executing 'fetch'"))},n)})]).finally(()=>{clearTimeout(r)})},tD=async function(e,t,n,r,i,o){let a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1e4;return i?(async(e,t,n,r,i,o,a,s,c,l)=>tK({type:"refresh",auth:{audience:t,scope:n},timeout:i,fetchUrl:e,fetchOptions:r,useFormData:a,useMrrt:s,skipTokenStorage:c,preserveRefreshToken:l},o))(e,t,n,r,a,i,o,arguments.length>7?arguments[7]:void 0,arguments.length>8?arguments[8]:void 0,arguments.length>9?arguments[9]:void 0):(async(e,t,n)=>{let r=await tJ(e,t,n);return{ok:r.ok,json:await r.json(),headers:[...r.headers].reduce((e,t)=>{let n=eD(t,2),r=n[0],i=n[1];return e[r]=i,e},{})}})(e,r,a)};async function tH(e,t,n,r,i,o,a,s,c,l,u,h){let d;if(c){let t=await c.generateProof({url:e,method:i.method||"GET",nonce:await c.getNonce()});i.headers=Object.assign(Object.assign({},i.headers),{dpop:t})}let p,f=null;for(let c=0;c<3;c++)try{p=await tD(e,n,r,i,o,a,t,s,u,h),f=null;break}catch(e){f=e}if(f)throw f;let m=p.json,y=m.error,g=m.error_description,w=eE(m,["error","error_description"]),v=p,b=v.headers,_=v.ok;if(c&&(d=b[tL])&&await c.setNonce(d),!_){let p=g||"HTTP error. Unable to fetch ".concat(e);if("mfa_required"===y)throw new e4(y,p,w.mfa_token,w.mfa_requirements);if("missing_refresh_token"===y)throw new e8(n,r);if("use_dpop_nonce"===y){if(!c||!d||l)throw new te(d);return tH(e,t,n,r,i,o,a,s,c,!0,u,h)}throw new eQ(y||"request_error",p,w)}return w}async function tZ(e,t,n){var r,i=e.baseUrl,o=e.timeout,a=e.audience,s=e.scope,c=e.auth0Client,l=e.useFormData,u=e.useMrrt,h=e.dpop,d=e.preserveRefreshToken,p=eE(e,["baseUrl","timeout","audience","scope","auth0Client","useFormData","useMrrt","dpop","preserveRefreshToken"]);let f="urn:ietf:params:oauth:grant-type:token-exchange"===p.grant_type,m="urn:okta:params:oauth:grant-type:webauthn"===p.grant_type,y="refresh_token"===p.grant_type&&u,g=f||m||y,w=Object.assign(Object.assign(Object.assign({},p),g&&a&&{audience:a}),g&&s&&{scope:s}),v=m||!l,b=v?JSON.stringify(w):ts(w),_=(r=p.grant_type,tz.includes(r));return await tH("".concat(i,"/oauth/token"),o,a||eB,s,{method:"POST",body:b,headers:{"Content-Type":v?"application/json":"application/x-www-form-urlencoded","Auth0-Client":btoa(JSON.stringify(ta(c||eq)))}},t,l,u,_?h:void 0,void 0,n,d)}let tF=function(){for(var e=arguments.length,t=Array(e),n=0;n{let r;return n&&(r=e[n]),r||(r=e[eB]),tF(r,t)},tV="@@auth0spajs@@",tX="@@user@@";class tq{toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join("::")}static fromKey(e){let t=eD(e.split("::"),4),n=t[0],r=t[1],i=t[2];return new tq({clientId:r,scope:t[3],audience:i},n)}static fromCacheEntry(e){let t=e.scope;return new tq({scope:t,audience:e.audience,clientId:e.client_id})}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tV,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}}class tY{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(tV))}}class tB{constructor(){this.enclosedCache=function(){let e={};return{set(t,n){e[t]=n},get(t){let n=e[t];if(n)return n},remove(t){delete e[t]},allKeys:()=>Object.keys(e)}}()}}class tQ{async setIdToken(e,t,n){var r;let i=this.getIdTokenCacheKey(e);await this.cache.set(i,{id_token:t,decodedToken:n}),await (null==(r=this.keyManifest)?void 0:r.add(i))}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],i=arguments.length>3?arguments[3]:void 0,o=await this.cache.get(e.toKey()),a=e;if(!o){let t=await this.getCacheKeys();if(!t)return;let n=this.matchExistingCacheKey(e,t);if(n&&(o=await this.cache.get(n),a=tq.fromKey(n)),!o&&r&&"cache-only"!==i)return this.getEntryWithRefreshToken(e,t)}if(!o)return;let s=Math.floor(await this.nowProvider()/1e3);return o.expiresAt-n!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.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.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new tq({clientId:e},tV,tX).toKey()}matchExistingCacheKey(e,t){return t.filter(t=>{var n;let r=tq.fromKey(t),i=new Set(r.scope&&r.scope.split(" ")),o=(null==(n=e.scope)?void 0:n.split(" "))||[],a=r.scope&&o.reduce((e,t)=>e&&i.has(t),!0);return r.prefix===tV&&r.clientId===e.clientId&&r.audience===e.audience&&a})[0]}async getEntryWithRefreshToken(e,t){var n;for(let r of t){let t=tq.fromKey(r);if(t.prefix===tV&&t.clientId===e.clientId){let e=await this.cache.get(r);if(null==(n=null==e?void 0:e.body)?void 0:n.refresh_token)return{refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope}}}}async getRefreshTokensByAudience(e,t){var n;let r=await this.getCacheKeys();if(!r)return[];let i=new Set;for(let o of r){let r=tq.fromKey(o);if(r.prefix===tV&&r.clientId===t&&r.audience===e){let e=await this.cache.get(o);(null==(n=null==e?void 0:e.body)?void 0:n.refresh_token)&&i.add(e.body.refresh_token)}}return Array.from(i)}async updateEntry(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=await this.getCacheKeys();if(i)for(let o of i){if(tq.fromKey(o).clientId!==n)continue;let i=await this.cache.get(o);if(!(null==i?void 0:i.body))continue;let a=i.body.refresh_token;a&&(r||a===e)&&(i.body.refresh_token=t,await this.cache.set(o,i))}}constructor(e,t,n){this.cache=e,this.keyManifest=t,this.nowProvider=n||eY}}class t${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})}constructor(e,t,n){this.storage=e,this.clientId=t,this.cookieDomain=n,this.storageKey="".concat("a0.spajs.txs",".").concat(this.clientId)}}let t0=["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"];var t1=th&&th.__assign||function(){return(t1=Object.assign||function(e){for(var t,n=1,r=arguments.length;nt9.get(e)||t9.get("".concat(t4).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),t5("".concat(t4).concat(e),JSON.stringify(t),r),t9.save(e,t,n)},remove(e,t){let n={};(null==t?void 0:t.cookieDomain)&&(n.domain=t.cookieDomain),t3(e,n),t9.remove(e,t),t9.remove("".concat(t4).concat(e),t)}},t8={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)}};!function(e){e.Code="code",e.ConnectCode="connect_code"}(t7||(t7={}));var t7,ne,nt=function(e){var t,n,r;return new Worker(ne=ne||(n=(t=function(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),i=0,o=n.length;i0?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(tV,"::").concat(e)}constructor(e,t){this.cache=e,this.clientId=t,this.manifestKey=this.createManifestKeyFrom(this.clientId)}}let nr="auth0.is.authenticated",ni={memory:()=>(new tB).enclosedCache,localstorage:()=>new tY},no=e=>ni[e],na=e=>{let t=e.openUrl,n=e.onRedirect;return Object.assign(Object.assign({},eE(e,["openUrl","onRedirect"])),{openUrl:!1===t||t?t:n})},ns={NONCE:"nonce",KEYPAIR:"keypair"};class nc{getVersion(){return 1}createDbHandle(){let e=window.indexedDB.open("auth0-spa-js",this.getVersion());return new Promise((t,n)=>{e.onupgradeneeded=()=>Object.values(ns).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(ns.NONCE,this.buildKey(t),e)}setKeyPair(e){return this.save(ns.KEYPAIR,this.buildKey(),e)}async save(e,t,n){await this.executeDbRequest(e,"readwrite",e=>e.put(n,t))}findNonce(e){return this.find(ns.NONCE,this.buildKey(e))}findKeyPair(){return this.find(ns.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());await Promise.all((null==n?void 0: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(ns.NONCE,this.clientId)}clearKeyPairs(){return this.deleteByClientId(ns.KEYPAIR,this.clientId)}constructor(e){this.clientId=e}}class nl{getNonce(e){return this.storage.findNonce(e)}setNonce(e,t){return this.storage.setNonce(e,t)}async getOrGenerateKeyPair(){let e=await this.storage.findKeyPair();return e||(e=await 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 tI}return crypto.subtle.generateKey(r,null!=(n=null==t?void 0:t.extractable)&&n,["sign","verify"])}("ES256",{extractable:!1}),await this.storage.setKeyPair(e)),e}async generateProof(e){var t;let n,r,i,o,a;return n=(t=Object.assign({keyPair:await this.getOrGenerateKeyPair()},e)).keyPair,r=t.url,i=t.method,o=t.nonce,a=t.accessToken,tU(n,function(e){let t=new URL(e);return t.search="",t.hash="",t.href}(r),i,o,a)}async calculateThumbprint(){return async function(e){var t;let n;if(!tN(e))throw TypeError('"publicKey" must be a public CryptoKey');if(!0!==e.extractable)throw TypeError('"publicKey.extractable" must be true');let i=await tM(e);switch(i.kty){case"EC":n={crv:i.crv,kty:i.kty,x:i.x,y:i.y};break;case"OKP":n={crv:i.crv,kty:i.kty,x:i.x};break;case"RSA":n={e:i.e,kty:i.kty,n:i.n};break;default:throw new tI("unsupported JWK kty")}return t=await crypto.subtle.digest({name:"SHA-256"},tR(JSON.stringify(n))),r(t)}((await this.getOrGenerateKeyPair()).publicKey)}async clear(){await Promise.all([this.storage.clearNonces(),this.storage.clearKeyPairs()])}constructor(e){this.storage=new nc(e)}}!function(e){e.Bearer="Bearer",e.DPoP="DPoP"}(p||(p={}));class nu{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]:p.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,i=await this.getAccessToken(t);if(void 0===i)throw new eQ("missing_access_token","No access token available");"string"==typeof i?(n=this.config.dpopNonceId?p.DPoP:p.Bearer,r=i):(n=i.token_type,r=i.access_token),this.setAuthorizationHeader(e,r,n),n===p.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,tL);if(n&&await this.hooks.setDpopNonce(n),!this.hasUseDpopNonceError(e))return e;if(!n||!t.onUseDpopNonceError)throw new te(n);return t.onUseDpopNonceError()}async internalFetchWithAuth(e,t,n,r){let i=this.buildBaseRequest(e,t);await this.prepareRequest(i,r);let o=await this.config.fetch(i);return this.handleResponse(o,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)}constructor(e,t){this.hooks=t,this.config=Object.assign(Object.assign({},e),{fetch:e.fetch||("undefined"==typeof window?fetch:window.fetch.bind(window))})}}class nh{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)},{scope:["create:me:connected_accounts"]});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)},{scope:["create:me:connected_accounts"]});return this._handleResponse(t)}async getFactors(){let e=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/factors"),{method:"GET"},{scope:["read:me:factors"]});return(await this._handleResponse(e)).factors}async getAuthenticationMethods(e){let t=e?"?".concat(new URLSearchParams({type:e})):"",n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods").concat(t),{method:"GET"},{scope:["read:me:authentication_methods"]});return(await this._handleResponse(n)).authentication_methods}async getAuthenticationMethod(e){let t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"GET"},{scope:["read:me:authentication_methods"]});return this._handleResponse(t)}async deleteAuthenticationMethod(e){let t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"DELETE"},{scope:["delete:me:authentication_methods"]});t.ok||await this._handleResponse(t)}async updateAuthenticationMethod(e,t){let n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods/").concat(encodeURIComponent(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},{scope:["update:me:authentication_methods"]});return this._handleResponse(n)}async enrollmentChallenge(e){var t;let n=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/authentication-methods"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["create:me:authentication_methods"]}),r=await this._handleResponse(n),i=null!=(t=n.headers.get("location"))?t:"",o=decodeURIComponent(i.split("/").pop()||"");return Object.assign(Object.assign({},r),{id:o,location:i})}async enrollmentVerify(e){let t=e.location;e.type;let n=eE(e,["location","type"]),r=await this.myAccountFetcher.fetchWithAuth("".concat(t,"/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},{scope:["create:me:authentication_methods"]});return this._handleResponse(r)}async getUserProfile(e){var t;let n=new URLSearchParams;(null==(t=null==e?void 0:e.fields)?void 0:t.length)&&n.set("fields",e.fields.join(",")),!1===(null==e?void 0:e.includeFields)&&n.set("include_fields","false");let r=n.toString()?"?".concat(n):"",i=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/profile").concat(r),{method:"GET"},{scope:["read:me:profile"]});return this._handleResponse(i)}async updateUserProfile(e){let t=await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase,"v1/profile"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)},{scope:["update:me:profile"]});return this._handleResponse(t)}async _handleResponse(e){let t;try{t=await e.text(),t=JSON.parse(t)}catch(n){throw new nd({type:"invalid_json",status:e.status,title:"Invalid JSON response",detail:t||String(n)})}if(e.ok)return t;throw new nd(t)}constructor(e,t){this.myAccountFetcher=e,this.apiBase=t}}class nd extends Error{constructor(e){let t=e.type,n=e.status,r=e.title,i=e.detail,o=e.validation_errors;super(i),this.name="MyAccountApiError",this.type=t,this.status=n,this.title=r,this.detail=i,this.validation_errors=o,Object.setPrototypeOf(this,nd.prototype)}}let np={otp:{authenticatorTypes:["otp"]},sms:{authenticatorTypes:["oob"],oobChannels:["sms"]},email:{authenticatorTypes:["oob"],oobChannels:["email"]},push:{authenticatorTypes:["oob"],oobChannels:["auth0"]},voice:{authenticatorTypes:["oob"],oobChannels:["voice"]}};function nf(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}}"undefined"!=typeof navigator&&null!=(f=navigator.userAgent)&&null!=(m=f.startsWith)&&m.call(f,"Mozilla/5.0 ")||(i="".concat("oauth4webapi","/").concat("v3.8.6"));let nm="ERR_INVALID_ARG_VALUE",ny="ERR_INVALID_ARG_TYPE";function ng(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}let nw=Symbol(),nv=Symbol(),nb=Symbol(),n_=Symbol(),nk=Symbol(),nS=Symbol(),nT=new TextEncoder,nC=new TextDecoder;function nP(e){return"string"==typeof e?nT.encode(e):nC.decode(e)}function nE(e){return"string"==typeof e?a(e):o(e)}o=Uint8Array.prototype.toBase64?e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0})):e=>{e instanceof ArrayBuffer&&(e=new Uint8Array(e));let t=[];for(let n=0;n{try{return Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch(e){throw ng("The input to be decoded is not correctly encoded.",nm,e)}}:e=>{try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"")),n=new Uint8Array(t.length);for(let e=0;e{switch(null==t?void 0:t.algorithm){case void 0:case"oidc":e.pathname=nW("".concat(e.pathname,"/").concat(".well-known/openid-configuration"));break;case"oauth2":!function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];"/"===e.pathname?e.pathname=t:e.pathname=nW("".concat(t,"/").concat(n?e.pathname:e.pathname.replace(/(\/)$/,"")))}(e,".well-known/oauth-authorization-server");break;default:throw ng('"options.algorithm" must be "oidc" (default), or "oauth2"',nm)}return e},t)}function nU(e,t,n,r,i){try{if("number"!=typeof e||!Number.isFinite(e))throw ng("".concat(n," must be a number"),ny,i);if(e>0)return;if(t){if(0!==e)throw ng("".concat(n," must be a non-negative number"),nm,i);return}throw ng("".concat(n," must be a positive number"),nm,i)}catch(e){if(r)throw nx(e.message,r,i);throw e}}function nM(e,t,n,r){try{if("string"!=typeof e)throw ng("".concat(t," must be a string"),ny,r);if(0===e.length)throw ng("".concat(t," must not be empty"),nm,r)}catch(e){if(n)throw nx(e.message,n,r);throw e}}function nL(e){var t="application/json";if(n8(e)!==t)throw function(e){let t='"response" content-type must be ';for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i2){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 nx(t,rC,e)}(e,t)}function nz(){return nE(crypto.getRandomValues(new Uint8Array(32)))}function nK(e){let t=null==e?void 0:e[nv];return"number"==typeof t&&Number.isFinite(t)?t:0}function nJ(e){let t=null==e?void 0:e[nb];return"number"==typeof t&&Number.isFinite(t)&&-1!==Math.sign(t)?t:30}function nD(){return Math.floor(Date.now()/1e3)}function nH(e){if("object"!=typeof e||null===e)throw ng('"as" must be an object',ny);nM(e.issuer,'"as.issuer"')}function nZ(e){if("object"!=typeof e||null===e)throw ng('"client" must be an object',ny);nM(e.client_id,'"client.client_id"')}function nF(e){return nM(e,'"clientSecret"'),(t,n,r,i)=>{r.set("client_id",n.client_id),r.set("client_secret",e)}}let nG=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch(e){return null}};function nV(e,t){if(t&&"https:"!==e.protocol)throw nx("only requests to HTTPS are allowed",rE,e);if("https:"!==e.protocol&&"http:"!==e.protocol)throw nx("only HTTP and HTTPS requests are allowed",rA,e)}function nX(e,t,n,r){let i;if("string"!=typeof e||!(i=nG(e)))throw nx("authorization server metadata does not contain a valid ".concat(n?'"as.mtls_endpoint_aliases.'.concat(t,'"'):'"as.'.concat(t,'"')),void 0===e?rI:rj,{attribute:n?"mtls_endpoint_aliases.".concat(t):t});return nV(i,r),i}function nq(e,t,n,r){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?nX(e.mtls_endpoint_aliases[t],t,n,r):nX(e[t],t,n,r)}class nY extends Error{constructor(e,t){var n;super(e,t),eL(this,"cause",void 0),eL(this,"code",void 0),eL(this,"error",void 0),eL(this,"status",void 0),eL(this,"error_description",void 0),eL(this,"response",void 0),this.name=this.constructor.name,this.code=rv,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)||n.call(Error,this,this.constructor)}}class nB extends Error{constructor(e,t){var n,r;super(e,t),eL(this,"cause",void 0),eL(this,"code",void 0),eL(this,"error",void 0),eL(this,"error_description",void 0),this.name=this.constructor.name,this.code=r_,this.cause=t.cause,this.error=t.cause.get("error"),this.error_description=null!=(n=t.cause.get("error_description"))?n:void 0,null==(r=Error.captureStackTrace)||r.call(Error,this,this.constructor)}}class nQ extends Error{constructor(e,t){var n;super(e,t),eL(this,"cause",void 0),eL(this,"code",void 0),eL(this,"response",void 0),eL(this,"status",void 0),this.name=this.constructor.name,this.code=rw,this.cause=t.cause,this.status=t.response.status,this.response=t.response,Object.defineProperty(this,"response",{enumerable:!1}),null==(n=Error.captureStackTrace)||n.call(Error,this,this.constructor)}}let n$="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",n0=RegExp("^[,\\s]*("+n$+")"),n1=RegExp("^[,\\s]*("+n$+')\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"[,\\s]*(.*)'),n2=RegExp("^[,\\s]*"+("("+n$+")\\s*=\\s*(")+n$+")[,\\s]*(.*)"),n5=RegExp("^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)");async function n3(e,t,n){if(e.status!==t){var r;let t;if(ra(e),t=await async function(e){if(e.status>399&&e.status<500){rN(e),nL(e);try{let t=await e.clone().json();if(nO(t)&&"string"==typeof t.error&&t.error.length)return t}catch(e){}}}(e))throw await (null==(r=e.body)?void 0:r.cancel()),new nY("server responded with an error in the response body",{cause:t,response:e});throw nx('"response" is not a conform '.concat(n," response (unexpected HTTP status code)"),rP,e)}}function n9(e){if(!rh.has(e))throw ng('"options.DPoP" is not a valid DPoPHandle',nm)}async function n4(e,t,n,r){nH(e),nZ(t);let i=nq(e,"userinfo_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==r?void 0:r[nw])),o=nI(null==r?void 0:r.headers);return t.userinfo_signed_response_alg?o.set("accept","application/jwt"):(o.set("accept","application/json"),o.append("accept","application/jwt")),async function(e,t,n,r,i,o){var a;if(nM(e,'"accessToken"'),!(n instanceof URL))throw ng('"url" must be an instance of URL',ny);nV(n,!0!==(null==o?void 0:o[nw])),r=nI(r),null!=o&&o.DPoP&&(n9(o.DPoP),await o.DPoP.addProof(n,r,"GET",e)),r.set("authorization","".concat(r.has("dpop")?"DPoP":"Bearer"," ").concat(e));let s=await ((null==o?void 0:o[n_])||fetch)(n.href,{duplex:nf(null,ReadableStream)?"half":void 0,body:null,headers:Object.fromEntries(r.entries()),method:"GET",redirect:"manual",signal:nj(n,null==o?void 0:o.signal)});return null==o||null==(a=o.DPoP)||a.cacheNonce(s,n),s}(n,"GET",i,o,null,eK(eK({},r),{},{[nv]:nK(t)}))}let n6=Symbol();function n8(e){var t;return null==(t=e.headers.get("content-type"))?void 0:t.split(";")[0]}async function n7(e,t,n,r,i){let o;if(nH(e),nZ(t),!nf(r,Response))throw ng('"response" must be an instance of Response',ny);if(ra(r),200!==r.status)throw nx('"response" is not a conform UserInfo Endpoint response (unexpected HTTP status code)',rP,r);if(rN(r),"application/jwt"===n8(r)){let n=await rM(await r.text(),rz.bind(void 0,t.userinfo_signed_response_alg,e.userinfo_signing_alg_values_supported,void 0),nK(t),nJ(t),null==i?void 0:i[nS]).then(rs.bind(void 0,t.client_id)).then(rl.bind(void 0,e)),a=n.claims,s=n.jwt;rr.set(r,s),o=a}else{if(t.userinfo_signed_response_alg)throw nx("JWT UserInfo Response expected",rk,r);o=await rH(r)}if(nM(o.sub,'"response" body "sub" property',rT,{body:o}),n===n6);else if(nM(n,'"expectedSubject"'),o.sub!==n)throw nx('unexpected "response" body "sub" property value',rO,{expected:n,body:o,attribute:"sub"});return o}async function re(e,t,n,r,i,o,a){return await n(e,t,i,o),o.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),((null==a?void 0:a[n_])||fetch)(r.href,{body:i,headers:Object.fromEntries(o.entries()),method:"POST",redirect:"manual",signal:nj(r,null==a?void 0:a.signal)})}async function rt(e,t,n,r,i,o){var a;let s=nq(e,"token_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==o?void 0:o[nw]));i.set("grant_type",r);let c=nI(null==o?void 0:o.headers);c.set("accept","application/json"),void 0!==(null==o?void 0:o.DPoP)&&(n9(o.DPoP),await o.DPoP.addProof(s,c,"POST"));let l=await re(e,t,n,s,i,c,o);return null==o||null==(a=o.DPoP)||a.cacheNonce(l,s),l}let rn=new WeakMap,rr=new WeakMap;function ri(e){if(!e.id_token)return;let t=rn.get(e);if(!t)throw ng('"ref" was already garbage collected or did not resolve from the proper sources',nm);return t}async function ro(e,t,n,r,i,o){if(nH(e),nZ(t),!nf(n,Response))throw ng('"response" must be an instance of Response',ny);await n3(n,200,"Token Endpoint"),rN(n);let a=await rH(n);if(nM(a.access_token,'"response" body "access_token" property',rT,{body:a}),nM(a.token_type,'"response" body "token_type" property',rT,{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;nU(e,!0,'"response" body "expires_in" property',rT,{body:a}),a.expires_in=e}if(void 0!==a.refresh_token&&nM(a.refresh_token,'"response" body "refresh_token" property',rT,{body:a}),void 0!==a.scope&&"string"!=typeof a.scope)throw nx('"response" body "scope" property must be a string',rT,{body:a});if(void 0!==a.id_token){nM(a.id_token,'"response" body "id_token" property',rT,{body:a});let o=["aud","exp","iat","iss","sub"];!0===t.require_auth_time&&o.push("auth_time"),void 0!==t.default_max_age&&(nU(t.default_max_age,!0,'"client.default_max_age"'),o.push("auth_time")),null!=r&&r.length&&o.push(...r);let s=await rM(a.id_token,rz.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,"RS256"),nK(t),nJ(t),i).then(rf.bind(void 0,o)).then(ru.bind(void 0,e)).then(rc.bind(void 0,t.client_id)),c=s.claims,l=s.jwt;if(Array.isArray(c.aud)&&1!==c.aud.length){if(void 0===c.azp)throw nx('ID Token "aud" (audience) claim includes additional untrusted audiences',rx,{claims:c,claim:"aud"});if(c.azp!==t.client_id)throw nx('unexpected ID Token "azp" (authorized party) claim value',rx,{expected:t.client_id,claims:c,claim:"azp"})}void 0!==c.auth_time&&nU(c.auth_time,!0,'ID Token "auth_time" (authentication time)',rT,{claims:c}),rr.set(n,l),rn.set(a,c)}if(void 0!==(null==o?void 0:o[a.token_type]))o[a.token_type](n,a);else if("dpop"!==a.token_type&&"bearer"!==a.token_type)throw new nA("unsupported `token_type` value",{cause:{body:a}});return a}function ra(e){let t;if(t=function(e){if(!nf(e,Response))throw ng('"response" must be an instance of Response',ny);let t=e.headers.get("www-authenticate");if(null===t)return;let n=[],r=t;for(;r;){let e,t=r.match(n0),c=null==(i=t)?void 0:i[1].toLowerCase();if(!c)return;let l=r.substring(t[0].length);if(l&&!l.match(/^[\s,]/))return;let u=l.match(/^\s+(.*)$/),h=!!u;r=u?u[1]:void 0;let d={};if(h)for(;r;){let n,c;if(t=r.match(n1)){var i,o=eD(t,4);if(n=o[1],c=o[2],r=o[3],c.includes("\\"))try{c=JSON.parse('"'.concat(c,'"'))}catch(e){}d[n.toLowerCase()]=c}else{if(!(t=r.match(n2))){if(t=r.match(n5)){if(Object.keys(d).length)break;var a=eD(t,3);e=a[1],r=a[2];break}return}var s=eD(t,4);n=s[1],c=s[2],r=s[3],d[n.toLowerCase()]=c}}else r=l||void 0;let p={scheme:c,parameters:d};e&&(p.token68=e),n.push(p)}return n.length?n:void 0}(e))throw new nQ("server responded with a challenge in the WWW-Authenticate HTTP Header",{cause:t,response:e})}function rs(e,t){return void 0!==t.claims.aud?rc(e,t):t}function rc(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw nx('unexpected JWT "aud" (audience) claim value',rx,{expected:e,claims:t.claims,claim:"aud"})}else if(t.claims.aud!==e)throw nx('unexpected JWT "aud" (audience) claim value',rx,{expected:e,claims:t.claims,claim:"aud"});return t}function rl(e,t){return void 0!==t.claims.iss?ru(e,t):t}function ru(e,t){var n,r;let i=null!=(n=null==(r=e[rF])?void 0:r.call(e,t))?n:e.issuer;if(t.claims.iss!==i)throw nx('unexpected JWT "iss" (issuer) claim value',rx,{expected:i,claims:t.claims,claim:"iss"});return t}let rh=new WeakSet,rd=Symbol(),rp={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 rf(e,t){for(let n of e)if(void 0===t.claims[n])throw nx('JWT "'.concat(n,'" (').concat(rp[n],") claim missing"),rT,{claims:t.claims});return t}let rm=Symbol(),ry=Symbol();async function rg(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,i,o,a){let s=[];switch(r){case void 0:r=rm;break;case rm:break;default:nM(r,'"expectedNonce" argument'),s.push("nonce")}switch(null!=i||(i=t.default_max_age),i){case void 0:i=ry;break;case ry:break;default:nU(i,!0,'"maxAge" argument'),s.push("auth_time")}let c=await ro(e,t,n,s,o,a);nM(c.id_token,'"response" body "id_token" property',rT,{body:c});let l=ri(c);if(i!==ry){let e=nD()+nK(t),n=nJ(t);if(l.auth_time+id+r)throw nx('unexpected JWT "nbf" (not before) claim value',rR,{claims:a,now:d,tolerance:r,claim:"nbf"})}if(void 0!==a.aud&&"string"!=typeof a.aud&&!Array.isArray(a.aud))throw nx('unexpected JWT "aud" (audience) claim type',rT,{claims:a});return{header:o,claims:a,jwt:e}}async function rL(e){if("POST"!==e.method)throw ng("form_post responses are expected to use the POST method",nm,{cause:e});if("application/x-www-form-urlencoded"!==n8(e))throw ng("form_post responses are expected to use the application/x-www-form-urlencoded content-type",nm,{cause:e});return async function(e){if(e.bodyUsed)throw ng("form_post Request instances must contain a readable body",nm,{cause:e});return e.text()}(e)}function rz(e,t,n,r){if(void 0===e)if(Array.isArray(t)){if(!t.includes(r.alg))throw nx('unexpected JWT "alg" header parameter',rT,{header:r,expected:t,reason:"authorization server metadata"})}else{if(void 0===n)throw nx('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 nx('unexpected JWT "alg" header parameter',rT,{header:r,expected:n,reason:"default value"})}else if("string"==typeof e?r.alg!==e:!e.includes(r.alg))throw nx('unexpected JWT "alg" header parameter',rT,{header:r,expected:e,reason:"client configuration"})}function rK(e,t){let n=e.getAll(t),r=n[0];if(n.length>1)throw nx('"'.concat(t,'" parameter must be provided only once'),rT);return r}let rJ=Symbol(),rD=Symbol();async function rH(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nL;try{t=await e.json()}catch(t){throw n(e),nx('failed to parse "response" body as JSON',rS,t)}if(!nO(t))throw nx('"response" body must be a top level object',rT,{body:t});return t}let rZ=Symbol(),rF=Symbol(),rG=new TextEncoder,rV=new TextDecoder,rX=new TextDecoder("utf-8",{fatal:!0});function rq(){for(var e=arguments.length,t=Array(e),n=0;ne+t.length,0)),i=0;for(let e of t)r.set(e,i),i+=e.length;return r}let rY=/[^\x00-\x7f]/;function rB(e){if("string"==typeof e&&e.length>=128){if(rY.test(e))throw TypeError("non-ASCII string encountered in encode()");return rG.encode(e)}let t=new Uint8Array(e.length);for(let n=0;n127)throw TypeError("non-ASCII string encountered in encode()");t[n]=r}return t}function rQ(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e,{alphabet:t?"base64url":"base64"});if(t){if(e.includes("+")||e.includes("/"))throw TypeError("Invalid base64url");e=e.replace(/-/g,"+").replace(/_/g,"/")}let n=atob(e),r=new Uint8Array(n.length);for(let e=0;e2&&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}}),eL(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED"),eL(this,"claim",void 0),eL(this,"reason",void 0),eL(this,"payload",void 0),this.claim=n,this.reason=r,this.payload=t}}eL(r0,"code","ERR_JWT_CLAIM_VALIDATION_FAILED");class r1 extends r${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}}),eL(this,"code","ERR_JWT_EXPIRED"),eL(this,"claim",void 0),eL(this,"reason",void 0),eL(this,"payload",void 0),this.claim=n,this.reason=r,this.payload=t}}eL(r1,"code","ERR_JWT_EXPIRED");class r2 extends r${constructor(){super(...arguments),eL(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}}eL(r2,"code","ERR_JOSE_ALG_NOT_ALLOWED");class r5 extends r${constructor(){super(...arguments),eL(this,"code","ERR_JOSE_NOT_SUPPORTED")}}eL(r5,"code","ERR_JOSE_NOT_SUPPORTED"),eL(class extends r${constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"decryption operation failed",arguments.length>1?arguments[1]:void 0),eL(this,"code","ERR_JWE_DECRYPTION_FAILED")}},"code","ERR_JWE_DECRYPTION_FAILED"),eL(class extends r${constructor(){super(...arguments),eL(this,"code","ERR_JWE_INVALID")}},"code","ERR_JWE_INVALID");class r3 extends r${constructor(){super(...arguments),eL(this,"code","ERR_JWS_INVALID")}}eL(r3,"code","ERR_JWS_INVALID");class r9 extends r${constructor(){super(...arguments),eL(this,"code","ERR_JWT_INVALID")}}eL(r9,"code","ERR_JWT_INVALID"),eL(class extends r${constructor(){super(...arguments),eL(this,"code","ERR_JWK_INVALID")}},"code","ERR_JWK_INVALID");class r4 extends r${constructor(){super(...arguments),eL(this,"code","ERR_JWKS_INVALID")}}eL(r4,"code","ERR_JWKS_INVALID");class r6 extends r${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),eL(this,"code","ERR_JWKS_NO_MATCHING_KEY")}}eL(r6,"code","ERR_JWKS_NO_MATCHING_KEY");class r8 extends r${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),eL(this,Symbol.asyncIterator,eH(function*(){})),eL(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}}eL(r8,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");class r7 extends r${constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"request timed out",arguments.length>1?arguments[1]:void 0),eL(this,"code","ERR_JWKS_TIMEOUT")}}eL(r7,"code","ERR_JWKS_TIMEOUT");class ie extends r${constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"signature verification failed",arguments.length>1?arguments[1]:void 0),eL(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}}function it(e){try{return rQ("string"==typeof e?e:rV.decode(e),!0)}catch(e){throw TypeError("The input to be decoded is not correctly encoded.",{cause:e})}}function ir(e){return function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(Uint8Array.prototype.toBase64)return e.toBase64({alphabet:t?"base64url":"base64",omitPadding:t});let n=[];for(let t=0;t"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let o=void 0===n?t:eK(eK({__proto__:null},n),t);for(let t of r.crit){if(!(t in o))throw new r5('Extension Header Parameter "'.concat(t,'" is not recognized'));if(!Object.hasOwn(i,t)||void 0===i[t])throw new e('Extension Header Parameter "'.concat(t,'" is missing'));if(o[t]&&(!Object.hasOwn(r,t)||void 0===r[t]))throw new e('Extension Header Parameter "'.concat(t,'" MUST be integrity protected'))}return r.crit}function iu(e,t){if(t.includes("b64")){let t=e.b64;if("boolean"!=typeof t)throw new r3('The "b64" (base64url-encode payload) Header Parameter must be a boolean');return t}return!0}function ih(e,t){let n,r;try{n=JSON.stringify(t),r=JSON.parse(n)}catch(t){throw new e("JOSE Header is not valid JSON",{cause:t})}if(!ii(r))throw new e("JOSE Header is not a JSON object");return[r,n]}async function id(e,t,n){var r,i,o,a;let c,l,u=e.alg,h=e.secret,d="decrypt"===n||"sign"===n;if(h&&t instanceof Uint8Array)return t;if(ii(t)){if("string"!=typeof(c=function(e){let t=ib(e);if(void 0!==t.ext&&"boolean"!=typeof t.ext)throw TypeError('"ext" (Extractable) Parameter must be a boolean');if(void 0!==t.key_ops){let e=t.key_ops,n=Array.isArray(e)?[...e]:void 0;if(!n||n.some(e=>"string"!=typeof e)||new Set(n).size!==n.length)throw TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');t.key_ops=n}return t}(t)).kty)throw ig(u,t,h);if(!(h?"oct"===c.kty&&"string"==typeof c.k:"oct"!==c.kty&&(d?"AKP"===c.kty&&"string"==typeof c.priv||"string"==typeof c.d:void 0===c.d&&void 0===c.priv)))throw TypeError(h?'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present':"JSON Web Key for this operation must be a ".concat(d?"private":"public"," JWK"));if(((e,t,n)=>{let r=e.alg;if(void 0!==t.use){let e="sign"===n||"verify"===n?"sig":"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!==r)throw TypeError('Invalid key for this operation, its "alg" must be "'.concat(r,'" when present'));if(Array.isArray(t.key_ops)){var i;let r="encrypt"===n||"decrypt"===n?null==(i=e.ops)?void 0:i[+("encrypt"!==n)]:n;if(r&&!t.key_ops.includes(r))throw TypeError('Invalid key for this operation, its "key_ops" must include "'.concat(r,'" when present'))}})(e,c,n),"oct"===c.kty)return it(c.k);if(!Object.isFrozen(t)){let e=t.key_ops;Array.isArray(e)&&Object.freeze(e),Object.freeze(t)}}else{if(!iy(t))throw ig(u,t,h);let e=h?"secret":d?"private":"public";if(t.type!==e&&(h||["secret","public","private"].includes(t.type)))throw TypeError("".concat(t[Symbol.toStringTag],' instances must be of type "').concat(e,'" for the ').concat(u," algorithm"));if(im(t))return t;if("secret"===(l=t).type)return l.export()}s||(s=new WeakMap);let p=s.get(t);if(null!=(r=p)&&r[u])return p[u];if(p||s.set(t,p={}),l&&"function"==typeof l.toCryptoKey){let t="public"===l.type,n=ip[null==(i=l.asymmetricKeyDetails)?void 0:i.namedCurve],r=null!=(o=null==(a=e.resolve)?void 0:a.call(e,{crv:n,asymmetricKeyType:l.asymmetricKeyType}))?o:e.subtle;return p[u]=l.toCryptoKey(r,t,e.usages[+!t])}return null!=c||(c=l.export({format:"jwk"})),c.alg=u,p[u]=await i_(e,c)}let ip={__proto__:null,prime256v1:"P-256",secp384r1:"P-384",secp521r1:"P-521"},im=e=>{if("CryptoKey"===(null==e?void 0:e[Symbol.toStringTag]))return!0;try{return e instanceof CryptoKey}catch(e){return!1}},iy=e=>im(e)||(e=>"KeyObject"===(null==e?void 0:e[Symbol.toStringTag]))(e);function ig(e,t,n){let r=["CryptoKey","KeyObject","JSON Web Key"];return n&&r.push("Uint8Array"),TypeError(function(e,t){for(var n,r=arguments.length,i=Array(r>2?r-2:0),o=2;o2){let t=i.pop();e+="one of type ".concat(i.join(", "),", or ").concat(t,".")}else 2===i.length?e+="one of type ".concat(i[0]," or ").concat(i[1],"."):e+="of type ".concat(i[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.name)&&(e+=" Received an instance of ".concat(t.constructor.name)),e}("Key for the ".concat(e," algorithm must be "),t,...r))}let iw=function(e){return TypeError("CryptoKey does not support this operation, its ".concat(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"algorithm.name"," must be ").concat(e))};function iv(e,t){let n=t.algorithm.modulusLength;if("number"!=typeof n||n<2048)throw TypeError("".concat(e," requires key modulusLength to be 2048 bits or larger"))}function ib(e){return eK({__proto__:null},e)}async function i_(e,t,n){var r,i,o,a;if(!e.kty.includes(t.kty))throw new r5('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');let s=null!=(r=null==(i=e.resolve)?void 0:i.call(e,{kty:t.kty,crv:t.crv}))?r:e.subtle,c=!(!t.d&&!t.priv),l=eK(eK({},t),{},{ext:null!=n?n:t.ext});return"AKP"!==l.kty&&delete l.alg,delete l.use,crypto.subtle.importKey("jwk",l,s,null!=(o=l.ext)?o:!c,null!=(a=t.key_ops)?a:e.usages[+!!c])}async function ik(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return e instanceof Uint8Array&&(e=await crypto.subtle.importKey("raw",e,t,r,[n])),function(e,t,n){var r;let i=e.algorithm;if(i.name!==t.name)throw iw(t.name);if(t.hash&&(null==(r=i.hash)?void 0:r.name)!==t.hash)throw iw(t.hash,"algorithm.hash");if(t.namedCurve&&i.namedCurve!==t.namedCurve)throw iw(t.namedCurve,"algorithm.namedCurve");if(void 0!==t.length&&i.length!==t.length)throw iw(t.length,"algorithm.length");if(n&&!e.usages.includes(n))throw TypeError("CryptoKey does not support this operation, its usages must include ".concat(n,"."))}(e,t,n),e}function iS(e){let t={__proto__:null};for(let n in e)t[n]=eK(eK({},e[n]),{},{alg:n});return t}let iT=[["encrypt","wrapKey"],["decrypt","unwrapKey"]],iC=[[],["deriveBits"]],iP=[[],[]];function iE(e){return{kty:["RSA"],mode:"key-encryption",subtle:{name:"RSA-OAEP",hash:"SHA-".concat(e)},usages:iT,ops:["wrapKey","unwrapKey"]}}function iA(e){return{kty:["EC","OKP"],mode:e,subtle:{name:"ECDH"},resolve:e=>{let t=e.kty,n=e.crv,r=e.asymmetricKeyType;if("X25519"===n||"x25519"===r)return{name:"X25519"};if("OKP"===t)throw new r5('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');return{name:"ECDH",namedCurve:n}},usages:iC,ops:[void 0,"deriveBits"]}}function iR(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return{kty:["oct"],mode:"key-wrapping",secret:!0,subtle:{name:t?"AES-GCM":"AES-KW",length:e},usages:iP,ops:t?["encrypt","decrypt"]:["wrapKey","unwrapKey"]}}function ix(){return{kty:["oct"],mode:"key-wrapping",secret:!0,subtle:{name:"PBKDF2"},usages:iP,ops:["deriveBits","deriveBits"]}}let iO=iS({dir:{kty:["oct"],mode:"direct-encryption",secret:!0,subtle:{name:"AES-GCM"},usages:iP,ops:["encrypt","decrypt"]},"RSA-OAEP":iE(1),"RSA-OAEP-256":iE(256),"RSA-OAEP-384":iE(384),"RSA-OAEP-512":iE(512),"ECDH-ES":iA("direct-key-agreement"),"ECDH-ES+A128KW":iA("key-agreement-with-key-wrapping"),"ECDH-ES+A192KW":iA("key-agreement-with-key-wrapping"),"ECDH-ES+A256KW":iA("key-agreement-with-key-wrapping"),A128KW:iR(128),A192KW:iR(192),A256KW:iR(256),A128GCMKW:iR(128,!0),A192GCMKW:iR(192,!0),A256GCMKW:iR(256,!0),"PBES2-HS256+A128KW":ix(),"PBES2-HS384+A192KW":ix(),"PBES2-HS512+A256KW":ix()}),iI=["encrypt","decrypt"];function ij(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return{kty:["oct"],secret:!0,subtle:{name:t?"AES-CBC":"AES-GCM",length:e},usages:iP,ops:iI,cekBits:e,ivBits:t?128:96,cbc:t}}iS({A128GCM:ij(128),A192GCM:ij(192),A256GCM:ij(256),"A128CBC-HS256":ij(256,!0),"A192CBC-HS384":ij(384,!0),"A256CBC-HS512":ij(512,!0)}),"undefined"!=typeof navigator&&null!=(y=navigator.userAgent)&&null!=(g=y.startsWith)&&g.call(y,"Mozilla/5.0 ")||(c={"user-agent":"".concat("openid-client","/").concat("v6.8.4")});let iW=e=>l.get(e);function iN(e){return void 0!==e?nF(e):(u||(u=new WeakMap),(e,t,n,r)=>{let i;return(i=u.get(t))||(!function(e,t){if("string"!=typeof e)throw iL("".concat(t," must be a string"),iM);if(0===e.length)throw iL("".concat(t," must not be empty"),iU)}(t.client_secret,'"metadata.client_secret"'),i=nF(t.client_secret),u.set(t,i)),i(e,t,n,r)})}let iU="ERR_INVALID_ARG_VALUE",iM="ERR_INVALID_ARG_TYPE";function iL(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}class iz extends Error{constructor(e,t){var n;super(e,t),eL(this,"code",void 0),this.name=this.constructor.name,this.code=null==t?void 0:t.code,null==(n=Error.captureStackTrace)||n.call(Error,this,this.constructor)}}function iK(e,t,n){return new iz(e,{cause:t,code:n})}function iJ(e){if(e instanceof TypeError||e instanceof iz||e instanceof nY||e instanceof nB||e instanceof nQ)throw e;if(e instanceof nR)switch(e.code){case rE:throw iK("only requests to HTTPS are allowed",e,e.code);case rA:throw iK("only requests to HTTP or HTTPS are allowed",e,e.code);case rP:throw iK("unexpected HTTP response status code",e.cause,e.code);case rC:throw iK("unexpected response content-type",e.cause,e.code);case rS:throw iK("parsing error occured",e,e.code);case rT:throw iK("invalid response encountered",e,e.code);case rx:throw iK("unexpected JWT claim value encountered",e,e.code);case rO:throw iK("unexpected JSON attribute value encountered",e,e.code);case rR:throw iK("JWT timestamp claim value failed validation",e,e.code);default:throw iK(e.message,e,e.code)}if(e instanceof nA)throw iK("unsupported operation",e,e.code);if(e instanceof DOMException)switch(e.name){case"OperationError":throw iK("runtime operation error",e,rb);case"NotSupportedError":throw iK("runtime unsupported operation",e,rb);case"TimeoutError":throw iK("operation timed out",e,"OAUTH_TIMEOUT");case"AbortError":throw iK("operation aborted",e,"OAUTH_ABORT")}throw new iz("something went wrong",{cause:e})}async function iD(e,t,n,r,i){let o=new iZ(await async function(e,t){var n,r,i;if(!(e instanceof URL))throw iL('"server" must be an instance of URL',iM);let o=!e.href.includes("/.well-known/"),a=null!=(n=null==t?void 0:t.timeout)?n:30,s=AbortSignal.timeout(1e3*a),l=await (o?nN(e,{algorithm:null==t?void 0:t.algorithm,[n_]:null==t?void 0:t[n_],[nw]:null==t||null==(r=t.execute)?void 0:r.includes(iY),signal:s,headers:new Headers(c)}):((null==t?void 0:t[n_])||fetch)((nV(e,null==t||null==(i=t.execute)||!i.includes(iY)),e.href),{headers:Object.fromEntries(new Headers(eK({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!==rZ)throw ng('"expectedIssuerIdentifier" must be an instance of URL',ny);if(!nf(t,Response))throw ng('"response" must be an instance of Response',ny);if(200!==t.status)throw nx('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)',rP,t);rN(t);let n=await rH(t);if(nM(n.issuer,'"response" body "issuer" property',rT,{body:n}),e!==rZ&&new URL(n.issuer).href!==e.href)throw nx('"response" body "issuer" property does not match the expected value',rO,{expected:e.href,body:n,attribute:"issuer"});return n})(rZ,e)).catch(iJ);return o&&new URL(l.issuer).href!==e.href&&("https://login.microsoftonline.com"!==e.origin||null!=t&&t.algorithm&&"oidc"!==t.algorithm||(l[iH]=!0,0))&&(!e.hostname.endsWith(".b2clogin.com")||null!=t&&t.algorithm&&"oidc"!==t.algorithm)&&(()=>{throw new iz("discovered metadata issuer does not match the expected issuer",{code:rO,cause:{expected:e.href,body:l,attribute:"issuer"}})})(),l}(e,i),t,n,r),a=iW(o);if(null!=i&&i[n_]&&(a.fetch=i[n_]),null!=i&&i.timeout&&(a.timeout=i.timeout),null!=i&&i.execute)for(let e of i.execute)e(o);return o}new TextDecoder;let iH=Symbol();class iZ{serverMetadata(){let e=structuredClone(iW(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.includes(n))}}}),e}clientMetadata(){return structuredClone(iW(this).c)}get timeout(){return iW(this).timeout}set timeout(e){iW(this).timeout=e}get[n_](){return iW(this).fetch}set[n_](e){iW(this).fetch=e}constructor(e,t,n,r){var i,o,a,s,c;let u;if("string"!=typeof t||!t.length)throw iL('"clientId" must be a non-empty string',iM);if("string"==typeof n&&(n={client_secret:n}),void 0!==(null==(i=n)?void 0:i.client_id)&&t!==n.client_id)throw iL('"clientId" and "metadata.client_id" must be the same',iU);let h=eK(eK({},structuredClone(n)),{},{client_id:t});h[nv]=null!=(o=null==(a=n)?void 0:a[nv])?o:0,h[nb]=null!=(s=null==(c=n)?void 0:c[nb])?s:30,u=r||("string"==typeof h.client_secret&&h.client_secret.length?iN(h.client_secret):(e,t,n,r)=>{n.set("client_id",t.client_id)});let d=Object.freeze(h),p=structuredClone(e);iH in e&&(p[rF]=t=>{let n=t.claims.tid;return e.issuer.replace("{tenantid}",n)});let f=Object.freeze(p);l||(l=new WeakMap),l.set(this,{__proto__:null,as:f,c:d,auth:u,tlsOnly:!0,jwksCache:{}})}}function iF(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()}return{expiresIn:{__proto__:null,value(){if(t){let e=Date.now();return t>e?Math.floor((t-e)/1e3):0}}},claims:{__proto__:null,value(){try{return ri(this)}catch(e){return}}}}}(e))}async function iG(e,t,n){var r;let i,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=null==(r=e.headers.get("retry-after"))?void 0:r.trim();if(void 0!==a){if(/^\d+$/.test(a))i=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&&(i=Math.ceil(n/1e3))}}if(o&&!Number.isFinite(i))throw new nR("invalid Retry-After header value",{cause:e});i>t&&await iV(i-t,n)}}function iV(e,t){return new Promise((n,r)=>{let i=e=>{try{t.throwIfAborted()}catch(e){return void r(e)}if(e<=0)return void n();let o=Math.min(e,5);setTimeout(()=>i(e-o),1e3*o)};i(e)})}async function iX(e,t){i2(e);let n=iW(e),r=n.as,i=n.c,o=n.auth,a=n.fetch,s=n.tlsOnly,l=n.timeout;return(async function(e,t,n,r,i){nH(e),nZ(t);let o=nq(e,"backchannel_authentication_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==i?void 0:i[nw])),a=new URLSearchParams(r);a.set("client_id",t.client_id);let s=nI(null==i?void 0:i.headers);return s.set("accept","application/json"),re(e,t,n,o,a,s,i)})(r,i,o,t,{[n_]:a,[nw]:!s,headers:new Headers(c),signal:i5(l)}).then(e=>(async function(e,t,n){if(nH(e),nZ(t),!nf(n,Response))throw ng('"response" must be an instance of Response',ny);await n3(n,200,"Backchannel Authentication Endpoint"),rN(n);let r=await rH(n);nM(r.auth_req_id,'"response" body "auth_req_id" property',rT,{body:r});let i="number"!=typeof r.expires_in?parseFloat(r.expires_in):r.expires_in;return nU(i,!0,'"response" body "expires_in" property',rT,{body:r}),r.expires_in=i,void 0!==r.interval&&nU(r.interval,!1,'"response" body "interval" property',rT,{body:r}),r})(r,i,e)).catch(iJ)}async function iq(e,t,n,r){var i,o,a;let s;i2(e),n=new URLSearchParams(n);let l=null!=(i=t.interval)?i:5,u=null!=(o=null==r?void 0:r.signal)?o:AbortSignal.timeout(1e3*t.expires_in);try{await iV(l,u)}catch(e){iJ(e)}let h=iW(e),d=h.as,p=h.c,f=h.auth,m=h.fetch,y=h.tlsOnly,g=h.nonRepudiation,w=h.timeout,v=h.decrypt,b=(i,o)=>iq(e,eK(eK({},t),{},{interval:i}),n,eK(eK({},r),{},{signal:u,flag:o})),_=function(e,t){let n=i5(t);if(!n)return{signal:e,cleanup(){}};let r=new AbortController,i=e=>{let t=e.target;r.abort(t.reason)};return e.aborted?r.abort(e.reason):n.aborted?r.abort(n.reason):(e.addEventListener("abort",i,{once:!0}),n.addEventListener("abort",i,{once:!0})),{signal:r.signal,cleanup(){e.removeEventListener("abort",i),n.removeEventListener("abort",i)}}}(u,w),k=await (async function(e,t,n,r,i){nH(e),nZ(t),nM(r,'"authReqId"');let o=new URLSearchParams(null==i?void 0:i.additionalParameters);return o.set("auth_req_id",r),rt(e,t,n,"urn:openid:params:grant-type:ciba",o,i)})(d,p,f,t.auth_req_id,{[n_]:m,[nw]:!y,additionalParameters:n,DPoP:null==r?void 0:r.DPoP,headers:new Headers(c),signal:_.signal}).catch(iJ).finally(_.cleanup);if(503===k.status&&k.headers.has("retry-after"))return await iG(k,l,u,!0),await (null==(a=k.body)?void 0:a.cancel()),b(l);let S=async function(e,t,n,r){return ro(e,t,n,void 0,null==r?void 0:r[nS],null==r?void 0:r.recognizedTokenTypes)}(d,p,k,{[nS]:v});try{s=await S}catch(e){if(i9(e,r))return b(l,i4);if(e instanceof nY)switch(e.error){case"slow_down":l+=5;case"authorization_pending":return await iG(e.response,l,u),b(l)}iJ(e)}return s.id_token&&await (null==g?void 0:g(k)),iF(s),s}function iY(e){iW(e).tlsOnly=!1}async function iB(e,t,n,r,i){let o,a,s;if(i2(e),!((null==i?void 0:i.flag)===i4||t instanceof URL||function(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch(e){return!1}}(t,"Request")))throw iL('"currentUrl" must be an instance of URL, or Request',iM);let l=iW(e),u=l.as,h=l.c,d=l.auth,p=l.fetch,f=l.tlsOnly,m=l.jarm,y=l.hybrid,g=l.nonRepudiation,w=l.timeout,v=l.decrypt,b=l.implicit;if((null==i?void 0:i.flag)===i4)o=i.authResponse,a=i.redirectUri;else{if(!(t instanceof URL)){let e=t;switch(t=new URL(t.url),e.method){case"GET":break;case"POST":let n=new URLSearchParams(await rL(e));if(y)t.hash=n.toString();else for(let e of n.entries()){var _,k=eD(e,2);let n=k[0],r=k[1];t.searchParams.append(n,r)}break;default:throw iL("unexpected Request HTTP method",iU)}}switch((_=new URL(_=t)).search="",_.hash="",a=_.href,!0){case!!m:o=await m(t,null==n?void 0:n.expectedState);break;case!!y:o=await y(t,null==n?void 0:n.expectedNonce,null==n?void 0:n.expectedState,null==n?void 0:n.maxAge);break;case!!b:throw TypeError("authorizationCodeGrant() cannot be used by response_type=id_token clients");default:try{o=function(e,t,n,r){var i;if(nH(e),nZ(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw ng('"parameters" must be an instance of URLSearchParams, or URL',ny);if(rK(n,"response"))throw nx('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()',rT,{parameters:n});let o=rK(n,"iss"),a=rK(n,"state");if(!o&&e.authorization_response_iss_parameter_supported)throw nx('response parameter "iss" (issuer) missing',rT,{parameters:n});if(o&&o!==e.issuer)throw nx('unexpected "iss" (issuer) response parameter value',rT,{expected:e.issuer,parameters:n});switch(r){case void 0:case rD:if(void 0!==a)throw nx('unexpected "state" response parameter encountered',rT,{expected:void 0,parameters:n});break;case rJ:break;default:if(nM(r,'"expectedState" argument'),a!==r)throw nx(void 0===a?'response parameter "state" missing':'unexpected "state" response parameter value',rT,{expected:r,parameters:n})}if(rK(n,"error"))throw new nB("authorization response from the server is an error",{cause:n});let s=rK(n,"id_token"),c=rK(n,"token");if(void 0!==s||void 0!==c)throw new nA("implicit and hybrid flows are not supported");return i=new URLSearchParams(n),rh.add(i),i}(u,h,t.searchParams,null==n?void 0:n.expectedState)}catch(e){iJ(e)}}}let S=await (async function(e,t,n,r,i,o,a){if(nH(e),nZ(t),!rh.has(r))throw ng('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()',nm);nM(i,'"redirectUri"');let s=rK(r,"code");if(!s)throw nx('no authorization code in "callbackParameters"',rT);let c=new URLSearchParams(null==a?void 0:a.additionalParameters);return c.set("redirect_uri",i),c.set("code",s),o!==rd&&(nM(o,'"codeVerifier"'),c.set("code_verifier",o)),rt(e,t,n,"authorization_code",c,a)})(u,h,d,o,a,(null==n?void 0:n.pkceCodeVerifier)||rd,{additionalParameters:r,[n_]:p,[nw]:!f,DPoP:null==i?void 0:i.DPoP,headers:new Headers(c),signal:i5(w)}).catch(iJ);"string"!=typeof(null==n?void 0:n.expectedNonce)&&"number"!=typeof(null==n?void 0:n.maxAge)||(n.idTokenExpected=!0);let T=rg(u,h,S,{expectedNonce:null==n?void 0:n.expectedNonce,maxAge:null==n?void 0:n.maxAge,requireIdToken:null==n?void 0:n.idTokenExpected,[nS]:v});try{s=await T}catch(t){if(i9(t,i))return iB(e,void 0,n,r,eK(eK({},i),{},{flag:i4,authResponse:o,redirectUri:a}));iJ(t)}return s.id_token&&await (null==g?void 0:g(S)),iF(s),s}async function iQ(e,t,n,r){let i;i2(e),n=new URLSearchParams(n);let o=iW(e),a=o.as,s=o.c,l=o.auth,u=o.fetch,h=o.tlsOnly,d=o.nonRepudiation,p=o.timeout,f=o.decrypt,m=await (async function(e,t,n,r,i){nH(e),nZ(t),nM(r,'"refreshToken"');let o=new URLSearchParams(null==i?void 0:i.additionalParameters);return o.set("refresh_token",r),rt(e,t,n,"refresh_token",o,i)})(a,s,l,t,{[n_]:u,[nw]:!h,additionalParameters:n,DPoP:null==r?void 0:r.DPoP,headers:new Headers(c),signal:i5(p)}).catch(iJ),y=async function(e,t,n,r){return ro(e,t,n,void 0,null==r?void 0:r[nS],null==r?void 0:r.recognizedTokenTypes)}(a,s,m,{[nS]:f});try{i=await y}catch(i){if(i9(i,r))return iQ(e,t,n,eK(eK({},r),{},{flag:i4}));iJ(i)}return i.id_token&&await (null==d?void 0:d(m)),iF(i),i}async function i$(e,t,n){let r;i2(e),t=new URLSearchParams(t);let i=iW(e),o=i.as,a=i.c,s=i.auth,l=i.fetch,u=i.tlsOnly,h=i.timeout,d=await (async function(e,t,n,r,i){return nH(e),nZ(t),rt(e,t,n,"client_credentials",new URLSearchParams(r),i)})(o,a,s,t,{[n_]:l,[nw]:!u,DPoP:null==n?void 0:n.DPoP,headers:new Headers(c),signal:i5(h)}).catch(iJ),p=async function(e,t,n,r){return ro(e,t,n,void 0,void 0,void 0)}(o,a,d);try{r=await p}catch(r){if(i9(r,n))return i$(e,t,eK(eK({},n),{},{flag:i4}));iJ(r)}return iF(r),r}function i0(e,t){i2(e);let n=iW(e),r=n.as,i=n.c,o=n.tlsOnly,a=n.hybrid,s=n.jarm,c=n.implicit,l=nq(r,"authorization_endpoint",!1,o);if((t=new URLSearchParams(t)).has("client_id")||t.set("client_id",i.client_id),!t.has("request_uri")&&!t.has("request")){if(t.has("response_type")||t.set("response_type",a?"code id_token":c?"id_token":"code"),c&&!t.has("nonce"))throw iL("response_type=id_token clients must provide a nonce parameter in their authorization request parameters",iU);s&&t.set("response_mode","jwt")}for(let e of t.entries()){var u=eD(e,2);let t=u[0],n=u[1];l.searchParams.append(t,n)}return l}async function i1(e,t,n){let r;i2(e);let i=i0(e,t),o=iW(e),a=o.as,s=o.c,l=o.auth,u=o.fetch,h=o.tlsOnly,d=o.timeout,p=await (async function(e,t,n,r,i){var o;nH(e),nZ(t);let a=nq(e,"pushed_authorization_request_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==i?void 0:i[nw])),s=new URLSearchParams(r);s.set("client_id",t.client_id);let c=nI(null==i?void 0:i.headers);c.set("accept","application/json"),void 0!==(null==i?void 0:i.DPoP)&&(n9(i.DPoP),await i.DPoP.addProof(a,c,"POST"));let l=await re(e,t,n,a,s,c,i);return null==i||null==(o=i.DPoP)||o.cacheNonce(l,a),l})(a,s,l,i.searchParams,{[n_]:u,[nw]:!h,DPoP:null==n?void 0:n.DPoP,headers:new Headers(c),signal:i5(d)}).catch(iJ),f=async function(e,t,n){if(nH(e),nZ(t),!nf(n,Response))throw ng('"response" must be an instance of Response',ny);await n3(n,201,"Pushed Authorization Request Endpoint"),rN(n);let r=await rH(n);nM(r.request_uri,'"response" body "request_uri" property',rT,{body:r});let i="number"!=typeof r.expires_in?parseFloat(r.expires_in):r.expires_in;return nU(i,!0,'"response" body "expires_in" property',rT,{body:r}),r.expires_in=i,r}(a,s,p);try{r=await f}catch(r){if(i9(r,n))return i1(e,t,eK(eK({},n),{},{flag:i4}));iJ(r)}return i0(e,{request_uri:r.request_uri})}function i2(e){if(!(e instanceof iZ))throw iL('"config" must be an instance of Configuration',iM);if(Object.getPrototypeOf(e)!==iZ.prototype)throw iL("subclassing Configuration is not allowed",iU)}function i5(e){return e?AbortSignal.timeout(1e3*e):void 0}async function i3(e,t,n,r){i2(e);let i=iW(e),o=i.as,a=i.c,s=i.fetch,l=i.tlsOnly,u=i.nonRepudiation,h=i.timeout,d=i.decrypt,p=await n4(o,a,t,{[n_]:s,[nw]:!l,DPoP:null==r?void 0:r.DPoP,headers:new Headers(c),signal:i5(h)}).catch(iJ),f,m=n7(o,a,n,p,{[nS]:d});try{f=await m}catch(i){if(i9(i,r))return i3(e,t,n,eK(eK({},r),{},{flag:i4}));iJ(i)}return"application/jwt"===n8(p)&&await (null==u?void 0:u(p)),f}function i9(e,t){return!(null==t||!t.DPoP||t.flag===i4)&&function(e){if(e instanceof nQ){let t=e.cause,n=t[0];return 1===t.length&&"dpop"===n.scheme&&"use_dpop_nonce"===n.parameters.error}return e instanceof nY&&"use_dpop_nonce"===e.error}(e)}Object.freeze(iZ.prototype);let i4=Symbol();async function i6(e,t,n,r){let i,o;i2(e);let a=iW(e),s=a.as,l=a.c,u=a.auth,h=a.fetch,d=a.tlsOnly,p=a.timeout,f=a.decrypt,m=a.nonRepudiation,y=await (async function(e,t,n,r,i,o){return nH(e),nZ(t),nM(r,'"grantType"'),rt(e,t,n,r,new URLSearchParams(i),o)})(s,l,u,t,new URLSearchParams(n),{[n_]:h,[nw]:!d,DPoP:null==r?void 0:r.DPoP,headers:new Headers(c),signal:i5(p)}).catch(iJ);"urn:ietf:params:oauth:grant-type:token-exchange"===t&&(i={n_a:()=>{}});let g=async function(e,t,n,r){return ro(e,t,n,void 0,null==r?void 0:r[nS],null==r?void 0:r.recognizedTokenTypes)}(s,l,y,{[nS]:f,recognizedTokenTypes:i});try{o=await g}catch(i){if(i9(i,r))return i6(e,t,n,eK(eK({},r),{},{flag:i4}));iJ(i)}return o.id_token&&await (null==m?void 0:m(y)),iF(o),o}async function i8(e,t,n){i2(e);let r=iW(e),i=r.as,o=r.c,a=r.auth,s=r.fetch,l=r.tlsOnly,u=r.timeout;return(async function(e,t,n,r,i){nH(e),nZ(t),nM(r,'"token"');let o=nq(e,"revocation_endpoint",t.use_mtls_endpoint_aliases,!0!==(null==i?void 0:i[nw])),a=new URLSearchParams(null==i?void 0:i.additionalParameters);a.set("token",r);let s=nI(null==i?void 0:i.headers);return s.delete("accept"),re(e,t,n,o,a,s,i)})(i,o,a,t,{[n_]:s,[nw]:!l,additionalParameters:new URLSearchParams(n),headers:new Headers(c),signal:i5(u)}).then(rW).catch(iJ)}let i7=[["verify"],["sign"]];function oe(e){let t={name:"HMAC",hash:"SHA-".concat(e)};return{kty:["oct"],secret:!0,subtle:t,signing:t,usages:i7}}function ot(e,t){let n={name:t?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:"SHA-".concat(e)};return{kty:["RSA"],subtle:n,signing:t?eK(eK({},n),{},{saltLength:t}):n,usages:i7,minRsaBits:2048}}function on(e,t){return{kty:["EC"],crv:e,subtle:{name:"ECDSA",namedCurve:e},signing:{name:"ECDSA",hash:"SHA-".concat(t)},usages:i7}}function or(){let e={name:"Ed25519"};return{kty:["OKP"],crv:"Ed25519",subtle:e,signing:e,usages:i7}}function oi(e){let t={name:"ML-DSA-".concat(e)};return{kty:["AKP"],subtle:t,signing:t,usages:i7}}let oo=iS({HS256:oe(256),HS384:oe(384),HS512:oe(512),RS256:ot(256),RS384:ot(384),RS512:ot(512),PS256:ot(256,32),PS384:ot(384,48),PS512:ot(512,64),ES256:on("P-256",256),ES384:on("P-384",384),ES512:on("P-521",512),EdDSA:or(),Ed25519:or(),"ML-DSA-44":oi(44),"ML-DSA-65":oi(65),"ML-DSA-87":oi(87)});function oa(e){let t="string"==typeof e?oo[e]:void 0;if(!t)throw new r5("alg ".concat(e," is not supported either by JOSE or your javascript runtime"));return t}function os(e){try{return rB(e)}catch(e){throw new r3("JWS Compact Serialization payload must use only ASCII characters",{cause:e})}}async function oc(e,t,n,r,i){var o;let a=e.protected,s=e.header,c=e.payload,l=null!=i?i:void 0===a?{}:function(e,t,n){let r;try{r=JSON.parse(rX.decode(it(e)))}catch(e){throw new t(n,{cause:e})}if(!ii(r))throw new t(n);return r}(a,r3,"JWS Protected Header is invalid");if(!ia(l,s))throw new r3("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let u=eK(eK({},l),s),h=iu(l,il(r3,ic,t[1],l,u)),d=u.alg;if("string"!=typeof d||!d)throw new r3('JWS "alg" (Algorithm) Header Parameter missing or invalid');if(t[0]&&!t[0].has(d))throw new r2('"alg" (Algorithm) Header Parameter value not allowed');if(h){if("string"!=typeof c)throw new r3("JWS Payload must be a string")}else if("string"!=typeof c&&!(c instanceof Uint8Array))throw new r3("JWS Payload must be a string or an Uint8Array instance");let p=h||"string"!=typeof c?c:r(c),f=!1;"function"==typeof n&&(n=await n(l,e),f=!0);let m=oa(d),y=rq(void 0!==a?rB(a):new Uint8Array,rB("."),"string"==typeof p?null!=(o=t[2])?o:t[2]=function(e,t,n){try{return rB(e)}catch(e){throw new n("The ".concat(t," is not a valid base64url string"),{cause:e})}}(p,"payload",r3):p),g=is(e.signature,"signature",r3),w=await id(m,n,"verify"),v=await ik(w,m.subtle,"verify");m.minRsaBits&&iv(m.alg,v);let b=!1;try{b=await crypto.subtle.verify(m.signing,v,g,y)}catch(e){throw new ie(void 0,{cause:e})}if(!b)throw new ie;let _={payload:"string"==typeof p?is(p,"payload",r3):p};return void 0!==a&&(_.protectedHeader=l),void 0!==s&&(_.unprotectedHeader=s),f?[eK(eK({},_),{},{key:w}),h]:[_,h]}let ol=e=>Math.floor(e.getTime()/1e3),ou={s:1,m:60,h:3600,d:86400,w:604800,y:0x1e187e0},oh=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,od="check_failed";function op(){throw TypeError("Invalid time period format")}function of(e){"string"!=typeof e&&op();let t=oh.exec(e);(!t||t[4]&&t[1])&&op();let n=Math.round(parseFloat(t[2])*ou[t[3][0].toLowerCase()]);return Number.isFinite(n)||op(),"-"===t[1]||"ago"===t[4]?-n:n}function om(e,t){if(!Number.isFinite(t))throw TypeError("Invalid ".concat(e," input"));return t}function oy(e,t){if("string"!=typeof t)throw TypeError('"'.concat(e,'" claim must be a string'))}function og(e,t){return"number"==typeof e?om(t,e):e instanceof Date?om(t,ol(e)):ol(new Date)+of(e)}let ow=e=>{let t=e.toLowerCase();return e.includes("/")?t:"application/".concat(t)};function ov(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e[t];if(void 0!==r||n){if("number"!=typeof r)throw new r0('"'.concat(t,'" claim must be a number'),e,t,"invalid");return r}}function ob(e,t){throw new r0('unexpected "'.concat(t,'" claim value'),e,t,od)}function o_(e){return h.get(e)}async function ok(e,t,n){let r=eD(await async function(e,t,n){if(e instanceof Uint8Array&&(e=rV.decode(e)),"string"!=typeof e)throw new r3("Compact JWS must be a string or Uint8Array");let r=e.split("."),i=r[0],o=r[1],a=r[2];if(3!==r.length)throw new r3("Invalid Compact JWS");return oc({payload:o,protected:i,signature:a},t,n,os)}(e,[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'));return void 0===t?void 0:new Set(t)}("algorithms",n.algorithms),null==n?void 0:n.crit],t),2),i=r[0];if(!r[1])throw new r9("JWTs MUST NOT use unencoded payload");let o=function(e,t){var n,r;let i,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{i=JSON.parse(rX.decode(t))}catch(e){throw new r9("JWT Claims Set must be a top-level JSON object",{cause:e})}if(!ii(i))throw new r9("JWT Claims Set must be a top-level JSON object");let a=o.typ;if(void 0!==a&&("string"!=typeof e.typ||ow(e.typ)!==ow(a)))throw new r0('unexpected "typ" JWT header value',i,"typ",od);let s=o.requiredClaims,c=o.issuer,l=o.subject,u=o.audience,h=o.maxTokenAge,d=[...void 0===s?[]:s];for(let e of(void 0!==h&&d.push("iat"),void 0!==u&&d.push("aud"),void 0!==l&&d.push("sub"),void 0!==c&&d.push("iss"),new Set(d.reverse())))if(!Object.hasOwn(i,e))throw new r0('missing required "'.concat(e,'" claim'),i,e,"missing");void 0===c||(Array.isArray(c)?c:[c]).includes(i.iss)||ob(i,"iss"),void 0!==l&&i.sub!==l&&ob(i,"sub"),void 0===u||(n=i.aud,r="string"==typeof u?[u]:u,"string"==typeof n?r.includes(n):Array.isArray(n)&&r.some(e=>n.includes(e)))||ob(i,"aud");let p=o.clockTolerance,f=0;if("string"==typeof p)f=of(p);else if(void 0!==p){if("number"!=typeof p)throw TypeError("Invalid clockTolerance option type");f=p}om("clockTolerance option",f);let m=o.currentDate,y=om("currentDate option",ol(void 0===m?new Date:m)),g=ov(i,"iat",void 0!==h),w=ov(i,"nbf");if(void 0!==w&&w>y+f)throw new r0('"nbf" claim timestamp check failed',i,"nbf",od);let v=ov(i,"exp");if(void 0!==v&&v<=y-f)throw new r1('"exp" claim timestamp check failed',i,"exp",od);if(void 0!==h){let e=y-g;if(e-f>om("maxTokenAge option","number"==typeof h?h:of(h)))throw new r1('"iat" claim timestamp check failed (too far in the past)',i,"iat",od);if(e<-f)throw new r0('"iat" claim timestamp check failed (it should be in the past)',i,"iat",od)}return i}(i.protectedHeader,i.payload,n);return eK(eK({},i),{},{payload:o})}async function oS(e,t,n){let r=eD(e,4),i=r[0],o=r[1],a=r[2],s=r[3],c="";if(void 0!==o){let e=ih(r3,o);o=e[0],c=ir(e[1])}if(void 0!==a&&(a=ih(r3,a)[0]),!o&&!a)throw new r3("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!ia(o,a))throw new r3("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let l=eK(eK({},o),a);var u,h,d=o;let p=(null!=d?d:{}).crit;if(Array.isArray(p)&&new Set(p).size!==p.length)throw new r3('"crit" (Critical) Header Parameter MUST NOT contain duplicate values');let f=iu(o,il(r3,ic,s,o,l));f||null==n||n();let m=l.alg;if("string"!=typeof m||!m)throw new r3('JWS "alg" (Algorithm) Header Parameter missing or invalid');let y=oa(m),g,w="",v=i;if(f){let t=e[4];t?(w=null!=(u=t[0])?u:t[0]=ir(i),v=null!=(h=t[1])?h:t[1]=rB(w)):(w=ir(i),g=rG.encode("".concat(c,".").concat(w)))}null!=g||(g=rq(rB(c),rB("."),v));let b=await ik(await id(y,t,"sign"),y.subtle,"sign");y.minRsaBits&&iv(y.alg,b);let _={signature:ir(new Uint8Array(await crypto.subtle.sign(y.signing,b,g))),payload:w};return o&&(_.protected=c),a&&(_.header=a),[_,f]}let oT=class{setIssuer(e){return oy("iss",e),o_(this).iss=e,this}setSubject(e){return oy("sub",e),o_(this).sub=e,this}setAudience(e){return function(e){if("string"!=typeof e&&(!Array.isArray(e)||Array.from(e).some(e=>"string"!=typeof e)))throw TypeError('"aud" claim must be a string or an array of strings')}(e),o_(this).aud=e,this}setJti(e){return oy("jti",e),o_(this).jti=e,this}setNotBefore(e){return o_(this).nbf=og(e,"setNotBefore"),this}setExpirationTime(e){return o_(this).exp=og(e,"setExpirationTime"),this}setIssuedAt(e){return o_(this).iat=void 0===e?ol(new Date):"string"==typeof e?om("setIssuedAt",ol(new Date)+of(e)):og(e,"setIssuedAt"),this}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!ii(e))throw TypeError("JWT Claims Set MUST be an object");(h||(h=new WeakMap)).set(this,structuredClone(e))}};var oC=new WeakMap;class oP extends oT{setProtectedHeader(e){return function(e,t){if(void 0!==e)throw TypeError("".concat(t," can only be called once"))}(eW(oC,this),"setProtectedHeader"),eU(oC,this,e),this}async sign(e,t){return async function(e,t,n,r,i){let o=eD(await oS([e,t,void 0,n],r,i),1)[0];return"".concat(o.protected,".").concat(o.payload,".").concat(o.signature)}(function(e){let t=o_(e);for(let e of["iat","nbf","exp"]){let n=t[e];if("number"==typeof n&&!Number.isFinite(n))throw TypeError('"'.concat(e,'" claim must be a finite number'))}return rG.encode(JSON.stringify(t))}(this),eW(oC,this),null==t?void 0:t.crit,e,()=>{throw new r9("JWTs MUST NOT use unencoded payload")})}constructor(){super(...arguments),eN(this,oC,void 0)}}let oE='"alg" (Algorithm)';function oA(){throw new r5("Invalid or unsupported ".concat(arguments.length>0&&void 0!==arguments[0]?arguments[0]:'JWK "alg" (Algorithm) Parameter'," value"))}let oR=(e,t)=>{if(e.byteLength!==t.length)return!1;for(let n=0;n{let t=e.data[e.pos++];if(void 0===t)throw Error("Unexpected end of ASN.1 input");return t},oO=e=>{let t=ox(e);if(128&t){let n=127&t,r=0;for(let t=0;t{if(ox(e)!==t)throw Error(n)},oj=(e,t)=>{if(t<0||e.pos+t>e.data.length)throw Error("Unexpected end of ASN.1 input");let n=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,n},oW=async(e,t,n,r)=>{let i,o=function(e){if(void 0!==e&&"boolean"!=typeof e)throw TypeError('"extractable" option must be a boolean');return e}(null==r?void 0:r.extractable),a=function(e,t){var n,r;return null!=(n="string"==typeof e?null!=(r=oo[e])?r:iO[e]:void 0)?n:oA(t)}(n,oE);a.secret&&oA(oE);let s="spki"===e;if(a.resolve)try{let n={data:t,pos:0};(function(e,t){if(oI(e,48,"Invalid ".concat("spki"===t?"SPKI":"PKCS#8"," structure")),oO(e),"pkcs8"===t){oI(e,2,"Expected version field");let t=oO(e);e.pos+=t}oI(e,48,"Expected algorithm identifier"),oO(e)})(n,e),i=a.resolve({crv:(e=>{let t=(e=>{oI(e,6,"Expected algorithm OID");let t=oO(e);return oj(e,t)})(e);if(oR(t,[43,101,110]))return"X25519";if(!oR(t,[42,134,72,206,61,2,1]))throw Error("Unsupported key algorithm");oI(e,6,"Expected curve OID");let n=oO(e),r=oj(e,n);if(oR(r,[42,134,72,206,61,3,1,7]))return"P-256";if(oR(r,[43,129,4,0,34]))return"P-384";if(oR(r,[43,129,4,0,35]))return"P-521";throw Error("Unsupported named curve")})(n)})}catch(e){throw new r5("Invalid or unsupported key format",{cause:e})}else i=a.subtle;return crypto.subtle.importKey(e,t,i,null!=o?o:s,a.usages[+!s])};async function oN(e,t,n){let r=e.get(t)||e.set(t,{}).get(t),i=n.alg;if(void 0===r[i]){let e=i_(n,t,!0).then(e=>{if("public"!==e.type)throw new r4("JSON Web Key Set members must be public keys");return r[i]=e,e}).catch(t=>{throw r[i]===e&&delete r[i],t});r[i]=e}return r[i]}function oU(e){let t;try{t=structuredClone(e)}catch(e){throw new r4("JSON Web Key Set malformed",{cause:e})}if(!io(t))throw new r4("JSON Web Key Set malformed");let n=t.keys.map(e=>{let t=ib(e);return Array.isArray(t.key_ops)&&(t.key_ops=[...t.key_ops]),t}),r=new WeakMap;return Object.defineProperty(async(e,i)=>{let o=eK(eK({},e),null==i?void 0:i.header),a=o.alg,s=o.kid,c="string"==typeof a?oo[a]:void 0;if(!c||c.secret)throw new r5('Unsupported "alg" value for a JSON Web Key Set');let l=t.keys.filter((e,t)=>(function(e,t,n,r){let i=e.kty,o=e.key_ops,a=e.ext,s=e.kid,c=e.alg,l=e.use,u=e.crv;return(void 0===a||"boolean"==typeof a)&&(void 0===o||Array.isArray(o)&&o.every((e,t)=>"string"==typeof e&&o.indexOf(e)===t)&&o.includes("verify"))&&t.kty.includes(i)&&(void 0===r||"string"==typeof r&&r===s)&&(void 0===c?"AKP"!==i:n===c)&&(void 0===l||"sig"===l)&&(!t.crv||u===t.crv)})(n[t],c,a,s)),u=l[0],h=l.length;if(!h)throw new r6;if(1!==h){let e=new r8;throw e[Symbol.asyncIterator]=eH(function*(){for(let t of l)try{var e;yield yield(e=oN(r,t,c),new ex(e,0))}catch(e){}}),e}return oN(r,u,c)},"jwks",{value:()=>structuredClone(t)})}(typeof navigator>"u"||null==(w=navigator.userAgent)||null==(v=w.startsWith)||!v.call(w,"Mozilla/5.0 "))&&(d="jose/v6.2.13");let oM=Symbol(),oL=Symbol();function oz(e,t){return Number.isFinite(e)&&Date.now()void 0!==eD(e,2)[1]).reduce((e,t)=>eK(eK({},e),{},{[t[0]]:t[1]}),{})}function ai(e){if(!e.trim())throw new o8("organization must not be blank")}function ao(e,t){if(!e)return;let n=t.trim();if(n.startsWith("org_")){let t=e.org_id;if("string"!=typeof t)throw new o8("Organization Id (org_id) claim must be a string present in the ID token");if(t!==n)throw new o8('Organization Id (org_id) claim value mismatch in the ID token; expected "'.concat(n,'", found "').concat(t,'"'))}else{let t=e.org_name;if("string"!=typeof t)throw new o8("Organization Name (org_name) claim must be a string present in the ID token");if(t.toLowerCase()!==n.toLowerCase())throw new o8('Organization Name (org_name) claim value mismatch in the ID token; expected "'.concat(n,'", found "').concat(t,'"'))}}var aa=class extends Error{constructor(e,t,n){super(t),eL(this,"cause",void 0),eL(this,"code",void 0),eL(this,"statusCode",void 0),eL(this,"headers",void 0),eL(this,"body",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};let r=oZ(n);this.statusCode=r.statusCode,this.headers=r.headers,this.body=r.body}},as=class extends aa{constructor(e,t){super("mfa_list_authenticators_error",e,t),this.name="MfaListAuthenticatorsError"}},ac=class extends aa{constructor(e,t){super("mfa_enrollment_error",e,t),this.name="MfaEnrollmentError"}},al=class extends aa{constructor(e,t){super("mfa_delete_authenticator_error",e,t),this.name="MfaDeleteAuthenticatorError"}},au=class extends aa{constructor(e,t){super("mfa_challenge_error",e,t),this.name="MfaChallengeError"}},ah=class extends aa{constructor(e,t){super("mfa_verify_error",e,t),this.name="MfaVerifyError"}};function ad(e){return{id:e.id,authenticatorType:e.authenticator_type,active:e.active,name:e.name,oobChannels:e.oob_channels,type:e.type}}var ap=class e{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}constructor(e,t,n,r,i,o,a){eL(this,"accessToken",void 0),eL(this,"idToken",void 0),eL(this,"refreshToken",void 0),eL(this,"expiresAt",void 0),eL(this,"scope",void 0),eL(this,"claims",void 0),eL(this,"authorizationDetails",void 0),eL(this,"tokenType",void 0),eL(this,"issuedTokenType",void 0),eL(this,"recoveryCode",void 0),eL(this,"act",void 0),this.accessToken=e,this.idToken=n,this.refreshToken=r,this.expiresAt=t,this.scope=i,this.claims=o,this.authorizationDetails=a}};function af(e,t){if(!1===t.enabled)return e;let n=btoa(JSON.stringify({name:t.name,version:t.version}));return async(t,r)=>{let i=t instanceof Request?new Headers(t.headers):new Headers;return null!=r&&r.headers&&new Headers(r.headers).forEach((e,t)=>{i.set(t,e)}),i.set("Auth0-Client",n),e(t,eK(eK({},r),{},{headers:i}))}}function am(e){var t,n;return!1===(null==e?void 0:e.enabled)?e:{enabled:!0,name:null!=(t=null==e?void 0:e.name)?t:"@auth0/auth0-auth-js",version:null!=(n=null==e?void 0:e.version)?n:"1.18.0"}}function ay(e){let t,n=async(n,r)=>{let i=await e(n,r);return t=i.clone(),i};return n.getCapturedResponse=()=>t,n}function ag(e,t,n){if(!t)return e;let r=t.signal,i=t.headers,o=t.customFetch,a=o?af(o,n):e;return r||i?async(e,t)=>{let n=i?new Headers(e instanceof Request?e.headers:void 0):void 0;if(n&&null!=t&&t.headers&&new Headers(t.headers).forEach((e,t)=>n.set(t,e)),i)for(let e of Object.entries(i)){var o,s=eD(e,2);let t=s[0],r=s[1],i=t.toLowerCase();"authorization"!==i&&"auth0-client"!==i&&n.set(t,r)}let c=function(e,t){if(!e)return{signal:null!=t?t:void 0};if(!t)return{signal:e};if("undefined"!=typeof AbortSignal&&"function"==typeof AbortSignal.any)return{signal:AbortSignal.any([e,t])};let n=new AbortController,r=[e,t],i=r.find(e=>e.aborted);if(i)return n.abort(i.reason),{signal:n.signal};let o=[],a=()=>{r.forEach((e,t)=>{let n=o[t];n&&e.removeEventListener("abort",n)})};return r.forEach((e,t)=>{let r=()=>{a(),n.abort(e.reason)};o[t]=r,e.addEventListener("abort",r,{once:!0})}),{signal:n.signal,cleanup:a}}(r,null==t?void 0:t.signal);try{return await a(e,eK(eK(eK({},t),n&&{headers:n}),{},{signal:c.signal}))}finally{null==(o=c.cleanup)||o.call(c)}}:a}var aw={otp:"http://auth0.com/oauth/grant-type/mfa-otp",oob:"http://auth0.com/oauth/grant-type/mfa-oob","recovery-code":"http://auth0.com/oauth/grant-type/mfa-recovery-code"},av=(b=new WeakMap,_=new WeakMap,k=new WeakMap,S=new WeakMap,T=new WeakMap,C=new WeakMap,P=new WeakMap,E=new WeakSet,class{async listAuthenticators(e,t){let n="".concat(eW(b,this),"/mfa/authenticators"),r=e.mfaToken,i=await eI(E,this,ab).call(this,t)(n,{method:"GET",headers:{Authorization:"Bearer ".concat(r),"Content-Type":"application/json"}});if(!i.ok){let e,t=await i.clone().text(),n=i.status,r=at(i.headers);try{e=JSON.parse(t)}catch(e){throw new as("Failed to list authenticators",{error:"unknown_error",error_description:"Failed to list authenticators",statusCode:n,headers:r,body:t})}throw new as(e.error_description||"Failed to list authenticators",eK(eK({},e),{},{statusCode:n,headers:r,body:t}))}return(await i.json()).map(ad)}async enrollAuthenticator(e,t){let n="".concat(eW(b,this),"/mfa/associate"),r=e.mfaToken,i=eJ(e,oD),o={authenticator_types:i.authenticatorTypes};"oobChannels"in i&&(o.oob_channels=i.oobChannels),"phoneNumber"in i&&i.phoneNumber&&(o.phone_number=i.phoneNumber),"email"in i&&i.email&&(o.email=i.email);let a=await eI(E,this,ab).call(this,t)(n,{method:"POST",headers:{Authorization:"Bearer ".concat(r),"Content-Type":"application/json"},body:JSON.stringify(o)});if(!a.ok){let e,t=await a.clone().text(),n=a.status,r=at(a.headers);try{e=JSON.parse(t)}catch(e){throw new ac("Failed to enroll authenticator",{error:"unknown_error",error_description:"Failed to enroll authenticator",statusCode:n,headers:r,body:t})}throw new ac(e.error_description||"Failed to enroll authenticator",eK(eK({},e),{},{statusCode:n,headers:r,body:t}))}var s=await a.json();if("otp"===s.authenticator_type)return{authenticatorType:"otp",secret:s.secret,barcodeUri:s.barcode_uri,recoveryCodes:s.recovery_codes,id:s.id};if("oob"===s.authenticator_type)return{authenticatorType:"oob",oobChannel:s.oob_channel,oobCode:s.oob_code,bindingMethod:s.binding_method,id:s.id,barcodeUri:s.barcode_uri,recoveryCodes:s.recovery_codes};throw Error("Unexpected authenticator type: ".concat(s.authenticator_type))}async deleteAuthenticator(e,t){let n=e.authenticatorId,r=e.mfaToken,i="".concat(eW(b,this),"/mfa/authenticators/").concat(encodeURIComponent(n)),o=await eI(E,this,ab).call(this,t)(i,{method:"DELETE",headers:{Authorization:"Bearer ".concat(r),"Content-Type":"application/json"}});if(!o.ok){let e,t=await o.clone().text(),n=o.status,r=at(o.headers);try{e=JSON.parse(t)}catch(e){throw new al("Failed to delete authenticator",{error:"unknown_error",error_description:"Failed to delete authenticator",statusCode:n,headers:r,body:t})}throw new al(e.error_description||"Failed to delete authenticator",eK(eK({},e),{},{statusCode:n,headers:r,body:t}))}}async challengeAuthenticator(e,t){let n="".concat(eW(b,this),"/mfa/challenge"),r=e.mfaToken,i=eJ(e,oH),o={mfa_token:r,client_id:eW(_,this),challenge_type:i.challengeType};eW(k,this)&&(o.client_secret=eW(k,this)),i.authenticatorId&&(o.authenticator_id=i.authenticatorId);let a=await eI(E,this,ab).call(this,t)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!a.ok){let e,t=await a.clone().text(),n=a.status,r=at(a.headers);try{e=JSON.parse(t)}catch(e){throw new au("Failed to challenge authenticator",{error:"unknown_error",error_description:"Failed to challenge authenticator",statusCode:n,headers:r,body:t})}throw new au(e.error_description||"Failed to challenge authenticator",eK(eK({},e),{},{statusCode:n,headers:r,body:t}))}var s=await a.json();let c={challengeType:s.challenge_type};return void 0!==s.oob_code&&(c.oobCode=s.oob_code),void 0!==s.binding_method&&(c.bindingMethod=s.binding_method),c}async verify(e,t){var n,r,i,o,a,s,c;if(!eW(C,this))throw Error("MFA verify requires a configuration provider (getConfiguration was not set)");let l={mfa_token:e.mfaToken};if(e.audience&&(l.audience=e.audience),"otp"===e.factorType?l.otp=e.otp:"oob"===e.factorType?(l.oob_code=e.oobCode,e.bindingCode&&(l.binding_code=e.bindingCode)):"recovery-code"===e.factorType&&(l.recovery_code=e.recoveryCode),e.fullResponse){if(!eW(P,this))throw Error("MFA verify fullResponse requires a capture-config factory (createCaptureConfiguration was not set)");let a=ay(null!=(n=(await eW(C,this).call(this,t))[n_])?n:fetch),s=await eW(P,this).call(this,a);try{let t=await i6(s,aw[e.factorType],l),n=ap.fromTokenEndpointResponse(t);t.recovery_code&&(n.recoveryCode=t.recovery_code);let r=a.getCapturedResponse();if(!r)throw new o7;return{data:n,response:r}}catch(t){if(t instanceof o7||t instanceof ah)throw t;let e=new ah(t.error_description||t.message||"Failed to verify MFA challenge",{error:null!=(r=t.error)?r:"mfa_verify_error",error_description:null!=(i=null!=(o=t.error_description)?o:t.message)?i:"Failed to verify MFA challenge"});throw an(e,t,a.getCapturedResponse()),e}}let u=await eW(C,this).call(this,t);try{let t=await i6(u,aw[e.factorType],l),n=ap.fromTokenEndpointResponse(t);return t.recovery_code&&(n.recoveryCode=t.recovery_code),n}catch(t){if(t instanceof ah)throw t;let e=new ah(t.error_description||t.message||"Failed to verify MFA challenge",{error:null!=(a=t.error)?a:"mfa_verify_error",error_description:null!=(s=null!=(c=t.error_description)?c:t.message)?s:"Failed to verify MFA challenge"});throw an(e,t),e}}constructor(e){var t,n;eM(this,E),eN(this,b,void 0),eN(this,_,void 0),eN(this,k,void 0),eN(this,S,void 0),eN(this,T,void 0),eN(this,C,void 0),eN(this,P,void 0),eU(b,this,"https://".concat(e.domain)),eU(_,this,e.clientId),eU(k,this,e.clientSecret),eU(S,this,null!=(t=e.customFetch)?t:function(){return fetch(...arguments)}),eU(T,this,null!=(n=e.telemetryConfig)?n:am()),eU(C,this,e.getConfiguration),eU(P,this,e.createCaptureConfiguration)}});function ab(e){return ag(eW(S,this),e,eW(T,this))}var a_=class extends Error{constructor(e,t,n){super(t),eL(this,"cause",void 0),eL(this,"code",void 0),eL(this,"statusCode",void 0),eL(this,"headers",void 0),eL(this,"body",void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};let r=oZ(n);this.statusCode=r.statusCode,this.headers=r.headers,this.body=r.body}},ak=class extends a_{constructor(e,t){super("passkey_register_error",e,t),this.name="PasskeyRegisterError"}},aS=class extends a_{constructor(e,t){super("passkey_challenge_error",e,t),this.name="PasskeyChallengeError"}},aT=class extends a_{constructor(e,t){super("passkey_get_token_error",e,t),eL(this,"isRetryable",void 0),eL(this,"verificationRequired",void 0),eL(this,"authSession",void 0),this.name="PasskeyGetTokenError",this.cause=t&&{error:t.error,error_description:t.error_description,message:t.message,mfa_token:t.mfa_token,mfa_requirements:t.mfa_requirements,verification_required:t.verification_required,auth_session:t.auth_session},this.isRetryable="invalid_grant"===(null==t?void 0:t.error)&&null!=(null==t?void 0:t.auth_session),this.verificationRequired=null==t?void 0:t.verification_required,this.authSession=null==t?void 0:t.auth_session}};function aC(e){return e.useMtls?{}:e.clientSecret?{client_secret:e.clientSecret}:{}}var aP="urn:okta:params:oauth:grant-type:webauthn",aE=(A=new WeakMap,R=new WeakMap,x=new WeakMap,O=new WeakMap,I=new WeakMap,j=new WeakMap,W=new WeakSet,class{async register(e,t){let n="".concat(eW(A,this),"/passkey/register"),r=eK(eK(eK(eK(eK(eK(eK(eK({},e.email&&{email:e.email}),e.name&&{name:e.name}),e.phoneNumber&&{phone_number:e.phoneNumber}),e.username&&{username:e.username}),e.givenName&&{given_name:e.givenName}),e.familyName&&{family_name:e.familyName}),e.nickname&&{nickname:e.nickname}),e.picture&&{picture:e.picture}),i=eK(eK({client_id:eW(R,this)},aC(eW(x,this))),{},{user_profile:r});e.realm&&(i.realm=e.realm),e.organization&&(i.organization=e.organization),e.userMetadata&&(i.user_metadata=e.userMetadata),e.deliveryMethod&&(i.delivery_method=e.deliveryMethod);let o=await eI(W,this,aA).call(this,t)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!o.ok){let e=await eI(W,this,aR).call(this,o),t=new ak(e.error_description||"Failed to request signup challenge",e);throw t.statusCode=o.status,t.headers=at(o.headers),t}let a=await o.json();return eK({authSession:a.auth_session,authnParamsPublicKey:eK({},a.authn_params_public_key)},a.verification_required&&{verificationRequired:a.verification_required})}async challenge(e,t){let n="".concat(eW(A,this),"/passkey/challenge"),r=eK({client_id:eW(R,this)},aC(eW(x,this)));null!=e&&e.realm&&(r.realm=e.realm),null!=e&&e.organization&&(r.organization=e.organization);let i=await eI(W,this,aA).call(this,t)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok){let e=await eI(W,this,aR).call(this,i),t=new aS(e.error_description||"Failed to request login challenge",e);throw t.statusCode=i.status,t.headers=at(i.headers),t}let o=await i.json();return{authSession:o.auth_session,authnParamsPublicKey:eK({},o.authn_params_public_key)}}async getTokenByPasskey(e,t){let n;void 0!==e.organization&&ai(e.organization);let r=new URLSearchParams({auth_session:e.authSession,authn_response:JSON.stringify(e.credential)});if(e.realm&&r.append("realm",e.realm),e.scope&&r.append("scope",e.scope),e.audience&&r.append("audience",e.audience),e.organization&&r.append("organization",e.organization),e.verification){let t=Object.fromEntries(Object.entries(e.verification).filter(e=>eD(e,2)[1]));Object.keys(t).length>0&&r.append("verification",JSON.stringify(t))}try{n=await eW(j,this).call(this,aP,r,t,e.fullResponse)}catch(r){if(r instanceof o7)throw r;let e=null==r?void 0:r.cause,t=oF(r),n=new aT(t.error_description||"Failed to exchange passkey credential for tokens.",eK(eK({},t),{},{verification_required:null==e?void 0:e.verification_required,auth_session:null==e?void 0:e.auth_session}));throw an(n,r),n}if(e.fullResponse){let t=n;return e.organization&&ao(t.data.claims,e.organization),t}let i=n;return e.organization&&ao(i.claims,e.organization),i}constructor(e){var t,n;eM(this,W),eN(this,A,void 0),eN(this,R,void 0),eN(this,x,void 0),eN(this,O,void 0),eN(this,I,void 0),eN(this,j,void 0),eU(A,this,"https://".concat(e.domain)),eU(R,this,e.clientId),eU(x,this,{clientSecret:e.clientSecret,useMtls:e.useMtls}),eU(O,this,null!=(t=e.customFetch)?t:function(){return fetch(...arguments)}),eU(I,this,null!=(n=e.telemetryConfig)?n:am()),eU(j,this,e.grantRequest)}});function aA(e){return ag(eW(O,this),e,eW(I,this))}async function aR(e){let t=await e.clone().text();try{return eK(eK({},JSON.parse(t)),{},{statusCode:e.status,headers:e.headers,body:t})}catch(n){return{error:"unknown_error",error_description:429===e.status?"Too many requests. Please try again later.":"HTTP ".concat(e.status," ").concat(e.statusText),statusCode:e.status,headers:e.headers,body:t}}}var ax=class extends Error{constructor(e,t,n){super(t),eL(this,"cause",void 0),eL(this,"code",void 0),eL(this,"statusCode",void 0),eL(this,"headers",void 0),eL(this,"body",void 0),Object.setPrototypeOf(this,new.target.prototype),this.code=e,this.cause=n&&(n.error||n.error_description)?{error:n.error,error_description:n.error_description,message:n.message,mfa_token:n.mfa_token,mfa_requirements:n.mfa_requirements}:void 0;let r=oZ(n);this.statusCode=r.statusCode,this.headers=r.headers,this.body=r.body}},aO=class extends ax{constructor(e,t){super("passwordless_start_error",e,t),this.name="PasswordlessStartError"}},aI=class extends ax{constructor(e,t){super("passwordless_verify_error",e,t),this.name="PasswordlessVerifyError"}},aj=class extends ax{constructor(e,t){super("passwordless_db_get_token_error",e,t),this.name="PasswordlessDbGetTokenError"}},aW=class extends ax{constructor(e,t,n,r,i){super("passwordless_challenge_error",e,n),eL(this,"statusCode",void 0),eL(this,"validationErrors",void 0),this.name="PasswordlessChallengeError",this.statusCode=t,this.validationErrors=r,this.headers=null!=i?i:this.headers}};function aN(e){return/^\+[1-9]\d{1,14}$/.test(e)}async function aU(e,t,n){if(e.useMtls)return{};if(e.clientAssertionSigningKey){var r;let i=null!=(r=e.clientAssertionSigningAlg)?r:"RS256",o=e.clientAssertionSigningKey instanceof CryptoKey?e.clientAssertionSigningKey:await oJ(e.clientAssertionSigningKey,i);return{client_assertion:await new oP({}).setProtectedHeader({alg:i}).setIssuer(t).setSubject(t).setAudience("https://".concat(n,"/")).setJti(crypto.randomUUID()).setIssuedAt().setExpirationTime("".concat(120,"s")).sign(o),client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"}}if(e.clientSecret)return{client_secret:e.clientSecret};throw new o6}var aM=(N=new WeakMap,U=new WeakMap,M=new WeakMap,L=new WeakMap,z=new WeakMap,K=new WeakMap,J=new WeakMap,D=new WeakSet,class{async sendEmail(e,t){let n=await eI(D,this,az).call(this,function(e){var t;let n=null!=(t=e.send)?t:"code",r={email:e.email,connection:"email",send:n};return"link"===n&&e.authParams&&(r.authParams=e.authParams),r}(e),"Failed to send passwordless email",e.language,t);if(e.fullResponse)return{data:void 0,response:n}}async sendSms(e,t){if(!aN(e.phoneNumber))throw new aO("Phone number must be in E.164 format (e.g. +14155550100).");let n=await eI(D,this,az).call(this,{phone_number:e.phoneNumber,connection:"sms"},"Failed to send passwordless SMS",e.language,t);if(e.fullResponse)return{data:void 0,response:n}}async challengeWithEmail(e,t){var n;let r={email:e.email,connection:e.connection,allow_signup:null!=(n=e.allowSignup)&&n};return eI(D,this,aK).call(this,r,"Failed to request email OTP challenge",t)}async challengeWithPhoneNumber(e,t){if(!aN(e.phoneNumber))throw new aW("Phone number must be in E.164 format (e.g. +14155550100).",0,void 0,void 0);let n=function(e){var t;let n={phone_number:e.phoneNumber,connection:e.connection,allow_signup:null!=(t=e.allowSignup)&&t};return e.deliveryMethod&&(n.delivery_method=e.deliveryMethod),n}(e);return eI(D,this,aK).call(this,n,"Failed to request phone OTP challenge",t)}async getTokenByPasswordlessDbConnection(e,t){let n=new URLSearchParams({auth_session:e.authSession,otp:e.otp});if(e.scope&&n.append("scope",e.scope),e.audience&&n.append("audience",e.audience),!eW(J,this))throw new aj("Missing grant request delegate.",oF(Error("missing grantRequest")));try{return await eW(J,this).call(this,"http://auth0.com/oauth/grant-type/passwordless/otp",n,t,e.fullResponse)}catch(t){if(t instanceof o7)throw t;let e=new aj("There was an error while trying to request a token.",oF(t));throw e.statusCode=t._statusCode,e.headers=t._headers,e}}constructor(e){var t,n;eM(this,D),eN(this,N,void 0),eN(this,U,void 0),eN(this,M,void 0),eN(this,L,void 0),eN(this,z,void 0),eN(this,K,void 0),eN(this,J,void 0),eU(U,this,e.domain),eU(N,this,"https://".concat(e.domain)),eU(M,this,e.clientId),eU(L,this,null!=(t=e.customFetch)?t:function(){return fetch(...arguments)}),eU(z,this,null!=(n=e.telemetryConfig)?n:am()),eU(K,this,{clientSecret:e.clientSecret,clientAssertionSigningKey:e.clientAssertionSigningKey,clientAssertionSigningAlg:e.clientAssertionSigningAlg,useMtls:e.useMtls}),eU(J,this,e.grantRequest)}});function aL(e){return ag(eW(L,this),e,eW(z,this))}async function az(e,t,n,r){var i;let o,a,s=await aU(eW(K,this),eW(M,this),eW(U,this)),c=eK(eK({client_id:eW(M,this)},e),s);try{o=await eI(D,this,aL).call(this,r)("".concat(eW(N,this),"/passwordless/start"),{method:"POST",headers:eK({"Content-Type":"application/json"},n?{"x-request-language":n}:{}),body:JSON.stringify(c)})}catch(e){throw new aO("".concat(t,": a network error occurred."))}if(o.ok)return o;let l=await o.clone().text();if(204!==o.status)try{a=JSON.parse(l)}catch(e){a=void 0}let u=new aO((null==(i=a)?void 0:i.error_description)||t,a);throw u.statusCode=o.status,u.headers=at(o.headers),u.body=l,u}async function aK(e,t,n){var r,i;let o,a,s=await aU(eW(K,this),eW(M,this),eW(U,this)),c=eK(eK({client_id:eW(M,this)},e),s);try{o=await eI(D,this,aL).call(this,n)("".concat(eW(N,this),"/otp/challenge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})}catch(e){throw new aW("challenge error: a network error occurred.",0,void 0,void 0)}if(o.ok){let e;try{e=await o.json()}catch(e){throw new aW("".concat(t,": could not parse the response body."),o.status,void 0,void 0,at(o.headers))}return{authSession:e.auth_session}}let l=await o.clone().text();try{a=JSON.parse(l)}catch(e){a=void 0}let u=a?eK(eK({},a),{},{statusCode:o.status,headers:o.headers,body:l}):{error:"",error_description:"",statusCode:o.status,headers:o.headers,body:l};throw new aW((null==(r=a)?void 0:r.error_description)||t,o.status,u,null==(i=a)?void 0:i.validation_errors,at(o.headers))}var aJ=class extends Error{constructor(e,t,n){super(t),eL(this,"cause",void 0),eL(this,"code",void 0),eL(this,"statusCode",void 0),eL(this,"headers",void 0),eL(this,"body",void 0),Object.setPrototypeOf(this,new.target.prototype),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message};let r=oZ(n);this.statusCode=r.statusCode,this.headers=r.headers,this.body=r.body}},aD=class extends aJ{constructor(e,t){super("signup_error",e,t),this.name="SignUpError"}},aH=class extends aJ{constructor(e,t){super("change_password_error",e,t),this.name="ChangePasswordError"}};function aZ(e,t,n){for(let r of t)if(null===e[r]||void 0===e[r]||""===e[r])throw new n('Required parameter "'.concat(String(r),'" was null, undefined, or empty.'))}function aF(e){var t,n;return{id:null!=(t=null!=(n=e._id)?n:e.user_id)?t:e.id,email:"string"==typeof e.email?e.email:"",emailVerified:!!e.email_verified,username:e.username,givenName:e.given_name,familyName:e.family_name,name:e.name,nickname:e.nickname,picture:e.picture,userMetadata:e.user_metadata}}var aG=(H=new WeakMap,Z=new WeakMap,F=new WeakMap,G=new WeakMap,V=new WeakSet,class{async signUp(e,t){var n;aZ(e,["email","password","connection"],aD);let r=eK({client_id:null!=(n=e.clientId)?n:eW(Z,this)},function(e){let t={email:e.email,password:e.password,connection:e.connection};return void 0!==e.username&&(t.username=e.username),void 0!==e.givenName&&(t.given_name=e.givenName),void 0!==e.familyName&&(t.family_name=e.familyName),void 0!==e.name&&(t.name=e.name),void 0!==e.nickname&&(t.nickname=e.nickname),void 0!==e.picture&&(t.picture=e.picture),void 0!==e.userMetadata&&(t.user_metadata=e.userMetadata),t}(e)),i=await eI(V,this,aV).call(this,"/dbconnections/signup",r,aD,"Failed to sign up",t);if(e.fullResponse){let e=i.clone();return{data:aF(await i.json()),response:e}}return aF(await i.json())}async changePassword(e,t){var n;if(aZ(e,["connection"],aH),!e.email&&!e.username)throw new aH('Either "email" or "username" is required.');let r=eK({client_id:null!=(n=e.clientId)?n:eW(Z,this)},function(e){let t={connection:e.connection};return void 0!==e.email&&(t.email=e.email),void 0!==e.username&&(t.username=e.username),void 0!==e.organization&&(t.organization=e.organization),t}(e)),i=await eI(V,this,aV).call(this,"/dbconnections/change_password",r,aH,"Failed to request a password change",t);if(e.fullResponse){let e=i.clone();return{data:await i.text(),response:e}}return i.text()}constructor(e){var t,n;eM(this,V),eN(this,H,void 0),eN(this,Z,void 0),eN(this,F,void 0),eN(this,G,void 0),eU(H,this,"https://".concat(e.domain)),eU(Z,this,e.clientId),eU(F,this,null!=(t=e.customFetch)?t:function(){return fetch(...arguments)}),eU(G,this,null!=(n=e.telemetryConfig)?n:am())}});async function aV(e,t,n,r,i){let o,a=ag(eW(F,this),i,eW(G,this));try{o=await a("".concat(eW(H,this)).concat(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch(e){throw new n("".concat(r,": a network error occurred."))}if(o.ok)return o;let s=await o.clone().text(),c=await async function(e){let t;try{t=await e.json()}catch(e){return}return"string"==typeof t.error?t:"string"==typeof t.code?{error:t.code,error_description:"string"==typeof t.description?t.description:""}:void 0}(o.clone()),l=new n((null==c?void 0:c.error_description)||r,null!=c?c:{error:"unknown_error",error_description:r});throw l.statusCode=o.status,l.headers=at(o.headers),l.body=s,l}var aX=class extends Error{constructor(e,t,n){super(t),eL(this,"code",void 0),eL(this,"cause",void 0),this.name="AnonymousSessionError",this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}};async function aq(e,t,n){if(e.useMtls)return{};if(e.clientAssertionSigningKey){var r;let i=null!=(r=e.clientAssertionSigningAlg)?r:"RS256",o=e.clientAssertionSigningKey instanceof CryptoKey?e.clientAssertionSigningKey:await oJ(e.clientAssertionSigningKey,i);return{client_assertion:await new oP({}).setProtectedHeader({alg:i}).setIssuer(t).setSubject(t).setAudience("https://".concat(n,"/")).setJti(crypto.randomUUID()).setIssuedAt().setExpirationTime("".concat(120,"s")).sign(o),client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"}}return e.clientSecret?{client_secret:e.clientSecret}:{}}async function aY(e){let t="Request failed with status ".concat(e.status),n={};try{n=await e.json()}catch(e){}return{error:"string"==typeof n.error?n.error:"server_error",error_description:"string"==typeof n.error_description?n.error_description:t}}var aB=(X=new WeakMap,q=new WeakMap,Y=new WeakMap,B=new WeakMap,Q=new WeakMap,$=new WeakMap,ee=new WeakMap,et=new WeakMap,en=new WeakSet,class{async createSession(e){let t={client_id:eW(Y,this)};null!=e&&e.audience&&(t.audience=e.audience),null!=e&&e.scope&&(t.scope=e.scope),null!=e&&e.metadata&&(t.metadata=e.metadata);let n=await eI(en,this,a$).call(this,t);if(!n.sessionToken)throw new aX("server_error","session_token missing from create session response");return{sessionToken:n.sessionToken,accessToken:n.accessToken,expiresAt:n.expiresAt,sessionTokenExpiresAt:n.sessionTokenExpiresAt,scope:n.scope}}async getAccessToken(e){return null!=e&&e.sessionToken?eI(en,this,aQ).call(this,e.sessionToken,e):this.createSession({audience:null==e?void 0:e.audience,scope:null==e?void 0:e.scope})}async logout(){let e="".concat(eW(q,this),"/anonymous/logout"),t={client_id:eW(Y,this)},n=await eW(et,this).call(this,e,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",redirect:"error",body:JSON.stringify(t)});if(!n.ok){let e=await aY(n);throw new aX(e.error,e.error_description||"Failed to end anonymous session",e)}}async mintTransferToken(e){let t="".concat(eW(q,this),"/anonymous/token"),n={client_id:eW(Y,this),session_token:e,audience:"urn:auth0:anon_transfer"};try{let e=await aq({clientSecret:eW(B,this),clientAssertionSigningKey:eW(Q,this),clientAssertionSigningAlg:eW($,this),useMtls:eW(ee,this)},eW(Y,this),eW(X,this));Object.assign(n,e);let r=await eW(et,this).call(this,t,{method:"POST",headers:{"Content-Type":"application/json"},redirect:"error",body:JSON.stringify(n)});if(!r.ok)return null;let i=await r.json();return"string"==typeof i.anon_transfer_token?i.anon_transfer_token:null}catch(e){return null}}constructor(e){var t;eM(this,en),eN(this,X,void 0),eN(this,q,void 0),eN(this,Y,void 0),eN(this,B,void 0),eN(this,Q,void 0),eN(this,$,void 0),eN(this,ee,void 0),eN(this,et,void 0),eU(X,this,e.domain),eU(q,this,"https://".concat(e.domain)),eU(Y,this,e.clientId),eU(B,this,e.clientSecret),eU(Q,this,e.clientAssertionSigningKey),eU($,this,e.clientAssertionSigningAlg),eU(ee,this,e.useMtls),eU(et,this,null!=(t=e.customFetch)?t:function(){return fetch(...arguments)})}});async function aQ(e,t){let n={client_id:eW(Y,this),session_token:e};null!=t&&t.audience&&(n.audience=t.audience),null!=t&&t.scope&&(n.scope=t.scope);let r=await eI(en,this,a$).call(this,n);return{sessionToken:e,accessToken:r.accessToken,expiresAt:r.expiresAt,sessionTokenExpiresAt:r.sessionTokenExpiresAt,scope:r.scope}}async function a$(e){let t,n="".concat(eW(q,this),"/anonymous/token");Object.assign(e,await aq({clientSecret:eW(B,this),clientAssertionSigningKey:eW(Q,this),clientAssertionSigningAlg:eW($,this),useMtls:eW(ee,this)},eW(Y,this),eW(X,this)));let r=await eW(et,this).call(this,n,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",redirect:"error",body:JSON.stringify(e)});if(!r.ok){let e=await aY(r);throw new aX(e.error,e.error_description||"Anonymous token request failed",e)}try{t=await r.json()}catch(e){throw new aX("server_error","Invalid response from anonymous token endpoint")}var i=t;let o=Math.floor(Date.now()/1e3);if("string"!=typeof i.access_token||!i.access_token)throw new aX("server_error","access_token missing or invalid in anonymous token response");let a=i.expires_in;if("number"!=typeof a||!Number.isFinite(a))throw new aX("server_error","expires_in missing or invalid in anonymous token response");return{accessToken:i.access_token,expiresAt:o+a,scope:i.scope,sessionToken:i.session_token,sessionTokenExpiresAt:"number"==typeof i.session_expires_in&&Number.isFinite(i.session_expires_in)?o+i.session_expires_in:void 0}}var a0=(er=new WeakMap,ei=new WeakMap,eo=new WeakMap,class{get(e){let t=eW(er,this).get(e);if(t){if(!(Date.now()>=t.expiresAt))return eW(er,this).delete(e),eW(er,this).set(e,t),t.value;eW(er,this).delete(e)}}set(e,t,n){eW(er,this).has(e)&&eW(er,this).delete(e);let r=null!=n&&Number.isFinite(n)&&n>0?n:eW(ei,this);for(eW(er,this).set(e,{value:t,expiresAt:Date.now()+r});eW(er,this).size>eW(eo,this);){let e=eW(er,this).keys().next().value;if(void 0===e)break;eW(er,this).delete(e)}}constructor(e,t){eN(this,er,new Map),eN(this,ei,void 0),eN(this,eo,void 0),eU(eo,this,Math.max(1,Math.floor(e))),eU(ei,this,Math.max(0,Math.floor(t)))}}),a1=new Map;function a2(e){return{ttlMs:1e3*("number"==typeof(null==e?void 0:e.ttl)?e.ttl:600),maxEntries:"number"==typeof(null==e?void 0:e.maxEntries)&&e.maxEntries>0?e.maxEntries:100}}var a5=class{static createDiscoveryCache(e){var t,n;let r=(t=e.maxEntries,n=e.ttlMs,"".concat(t,":").concat(n)),i=a1.get(r);return i||(i=new a0(e.maxEntries,e.ttlMs),a1.set(r,i)),i}static createJwksCache(){return{}}},a3="openid profile email offline_access",a9=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 a4(e){if(null==e)throw new o$("subject_token is required");if("string"!=typeof e)throw new o$("subject_token must be a string");if(0===e.trim().length)throw new o$("subject_token cannot be blank or whitespace");if(e!==e.trim())throw new o$("subject_token must not include leading or trailing whitespace");if(/^bearer\s+/i.test(e))throw new o$("subject_token must not include the 'Bearer ' prefix")}function a6(e,t){if(t)for(let r of Object.entries(t)){var n=eD(r,2);let t=n[0],i=n[1];if(!a9.has(t))if(Array.isArray(i)){if(i.length>20)throw new o$("Parameter '".concat(t,"' exceeds maximum array size of ").concat(20));i.forEach(n=>{e.append(t,n)})}else e.append(t,i)}}var a8="urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token",a7="urn:ietf:params:oauth:grant-type:token-exchange",se="urn:ietf:params:oauth:token-type:access_token";function st(e,t){return(n,r)=>{let i=null==r?void 0:r.body;if(t!==aP||!(i instanceof URLSearchParams))return e(n,r);let o={};for(let e of i){var a=eD(e,2);let t=a[0],n=a[1];o[t]="authn_response"===t||"verification"===t?JSON.parse(n):n}let s=new Headers(null==r?void 0:r.headers);return s.set("Content-Type","application/json"),e(n,eK(eK({},r),{},{headers:s,body:JSON.stringify(o)}))}}var sn=(ea=new WeakMap,es=new WeakMap,ec=new WeakMap,el=new WeakMap,eu=new WeakMap,eh=new WeakMap,ed=new WeakMap,ep=new WeakMap,ef=new WeakMap,em=new WeakMap,ey=new WeakMap,eg=new WeakSet,class{async getServerMetadata(){return(await eI(eg,this,ss).call(this)).serverMetadata}async buildAuthorizationUrl(e){let t=(await eI(eg,this,ss).call(this)).serverMetadata;if(null!=e&&e.pushedAuthorizationRequests&&!t.pushed_authorization_request_endpoint)throw new oG("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 eI(eg,this,sf).call(this,e)}catch(e){throw new o3(e)}}async buildLinkUserUrl(e){try{let t=await eI(eg,this,sf).call(this,{authorizationParams:eK(eK({},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 o9(e)}}async buildUnlinkUserUrl(e){try{let t=await eI(eg,this,sf).call(this,{authorizationParams:eK(eK({},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 o4(e)}}async backchannelAuthentication(e,t){var n,r;let i=await eI(eg,this,sa).call(this,t),o=i.configuration,a=i.serverMetadata,s=ar(eK(eK({},eW(eu,this).authorizationParams),null==e?void 0:e.authorizationParams)),c=new URLSearchParams(eK(eK({scope:a3},s),{},{client_id:eW(eu,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:a.issuer,sub:e.loginHint.sub})}));if(e.requestedExpiry&&c.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&c.append("authorization_details",JSON.stringify(e.authorizationDetails)),e.fullResponse){let e=ay(null!=(r=o[n_])?r:eW(eh,this)),t=await eI(eg,this,si).call(this,o.serverMetadata(),e);try{let n=await iX(o,c),r=await iq(t,n),i=e.getCapturedResponse();if(!i)throw new o7;return{data:ap.fromTokenEndpointResponse(r),response:i}}catch(n){if(n instanceof o7)throw n;let t=new o5(n);throw an(t,n,e.getCapturedResponse()),t}}let l=ay(null!=(n=o[n_])?n:eW(eh,this)),u=await eI(eg,this,si).call(this,o.serverMetadata(),l);try{let e=await iX(o,c),t=await iq(u,e);return ap.fromTokenEndpointResponse(t)}catch(t){let e=new o5(t);throw an(e,t,l.getCapturedResponse()),e}}async initiateBackchannelAuthentication(e,t){var n;let r=await eI(eg,this,sa).call(this,t),i=r.configuration,o=r.serverMetadata,a=ar(eK(eK({},eW(eu,this).authorizationParams),null==e?void 0:e.authorizationParams)),s=new URLSearchParams(eK(eK({scope:a3},a),{},{client_id:eW(eu,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:"iss_sub",iss:o.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&s.append("requested_expiry",e.requestedExpiry.toString()),e.authorizationDetails&&s.append("authorization_details",JSON.stringify(e.authorizationDetails));let c=ay(null!=(n=i[n_])?n:eW(eh,this)),l=await eI(eg,this,si).call(this,i.serverMetadata(),c);try{let e=await iX(l,s);return{authReqId:e.auth_req_id,expiresIn:e.expires_in,interval:e.interval}}catch(n){let e=new o5(n),t=c.getCapturedResponse();throw e.statusCode=null==t?void 0:t.status,e.headers=t?at(t.headers):void 0,e}}async backchannelAuthenticationGrant(e,t){var n;let r=e.authReqId,i=(await eI(eg,this,sa).call(this,t)).configuration,o=new URLSearchParams({auth_req_id:r}),a=ay(null!=(n=i[n_])?n:eW(eh,this)),s=await eI(eg,this,si).call(this,i.serverMetadata(),a);try{let e=await i6(s,"urn:openid:params:grant-type:ciba",o);return ap.fromTokenEndpointResponse(e)}catch(n){let e=new o5(n),t=a.getCapturedResponse();throw e.statusCode=null==t?void 0:t.status,e.headers=t?at(t.headers):void 0,e}}async getTokenForConnection(e,t){var n;if(e.refreshToken&&e.accessToken)throw new oQ("Either a refresh or access token should be specified, but not both.");let r=null!=(n=e.accessToken)?n:e.refreshToken;if(!r)throw new oQ("Either a refresh or access token must be specified.");try{return await this.exchangeToken(eK({connection:e.connection,subjectToken:r,subjectTokenType:e.accessToken?se:"urn:ietf:params:oauth:token-type:refresh_token",loginHint:e.loginHint},e.fullResponse?{fullResponse:!0}:{}),t)}catch(e){if(e instanceof o$){let t=new oQ(e.message,e.cause);throw t.statusCode=e.statusCode,t.headers=e.headers,t}throw e}}async exchangeToken(e,t){return e.fullResponse?"connection"in e?eI(eg,this,sl).call(this,e,t,!0):eI(eg,this,sh).call(this,e,t,!0):"connection"in e?eI(eg,this,sl).call(this,e,t):eI(eg,this,sh).call(this,e,t)}async getTokenByCode(e,t,n){var r,i;let o,a=(await eI(eg,this,sa).call(this,n)).configuration;if(void 0!==t.organization&&ai(t.organization),t.fullResponse){let n,r,o=ay(null!=(i=a[n_])?i:eW(eh,this)),s=await eI(eg,this,si).call(this,a.serverMetadata(),o);try{let i=await iB(s,e,{pkceCodeVerifier:t.codeVerifier});if(n=ap.fromTokenEndpointResponse(i),!(r=o.getCapturedResponse()))throw new o7}catch(n){if(n instanceof o7)throw n;let e=new oX("There was an error while trying to request a token.",oF(n)),t=o.getCapturedResponse();throw e.statusCode=null==t?void 0:t.status,e.headers=t?at(t.headers):void 0,e}return t.organization&&ao(n.claims,t.organization),{data:n,response:r}}let s=ay(null!=(r=a[n_])?r:eW(eh,this)),c=await eI(eg,this,si).call(this,a.serverMetadata(),s);try{let n=await iB(c,e,{pkceCodeVerifier:t.codeVerifier});o=ap.fromTokenEndpointResponse(n)}catch(n){let e=new oX("There was an error while trying to request a token.",oF(n)),t=s.getCapturedResponse();throw e.statusCode=null==t?void 0:t.status,e.headers=t?at(t.headers):void 0,e}return t.organization&&ao(o.claims,t.organization),o}async getTokenByMagicLinkCode(e,t,n){var r,i;let o=(await eI(eg,this,sa).call(this,n)).configuration;if(null!=t&&t.fullResponse){let n=ay(null!=(i=o[n_])?i:eW(eh,this)),r=await eI(eg,this,si).call(this,o.serverMetadata(),n);try{let i=await iB(r,e,{expectedState:null==t?void 0:t.expectedState}),o=ap.fromTokenEndpointResponse(i),a=n.getCapturedResponse();if(!a)throw new o7;return{data:o,response:a}}catch(r){if(r instanceof o7)throw r;let e=new oX(r instanceof Error&&r.message?r.message:"There was an error while trying to request a token.",r),t=n.getCapturedResponse();throw e.statusCode=null==t?void 0:t.status,e.headers=t?at(t.headers):void 0,e}}let a=ay(null!=(r=o[n_])?r:eW(eh,this)),s=await eI(eg,this,si).call(this,o.serverMetadata(),a);try{let n=await iB(s,e,{expectedState:null==t?void 0:t.expectedState});return ap.fromTokenEndpointResponse(n)}catch(n){let e=new oX(n instanceof Error&&n.message?n.message:"There was an error while trying to request a token.",n),t=a.getCapturedResponse();throw e.statusCode=null==t?void 0:t.status,e.headers=t?at(t.headers):void 0,e}}async getTokenByRefreshToken(e,t){var n,r;let i=(await eI(eg,this,sa).call(this,t)).configuration,o=new URLSearchParams;if(e.audience&&o.append("audience",e.audience),e.scope&&o.append("scope",e.scope),e.fullResponse){let t=ay(null!=(r=i[n_])?r:eW(eh,this)),n=await eI(eg,this,si).call(this,i.serverMetadata(),t);try{let r=await iQ(n,e.refreshToken,o),i=ap.fromTokenEndpointResponse(r),a=t.getCapturedResponse();if(!a)throw new o7;return{data:i,response:a}}catch(r){if(r instanceof o7)throw r;let e=new oY("The access token has expired and there was an error while trying to refresh it.",oF(r)),n=t.getCapturedResponse();throw e.statusCode=null==n?void 0:n.status,e.headers=n?at(n.headers):void 0,e}}let a=ay(null!=(n=i[n_])?n:eW(eh,this)),s=await eI(eg,this,si).call(this,i.serverMetadata(),a);try{let t=await iQ(s,e.refreshToken,o);return ap.fromTokenEndpointResponse(t)}catch(n){let e=new oY("The access token has expired and there was an error while trying to refresh it.",oF(n)),t=a.getCapturedResponse();throw e.statusCode=null==t?void 0:t.status,e.headers=t?at(t.headers):void 0,e}}async revokeToken(e,t){var n;let r=(await eI(eg,this,sa).call(this,t)).configuration,i={};e.tokenTypeHint&&(i.token_type_hint=e.tokenTypeHint);let o=ay(null!=(n=r[n_])?n:eW(eh,this)),a=await eI(eg,this,si).call(this,r.serverMetadata(),o);try{await i8(a,e.token,i)}catch(n){let e=new o0("An error occurred while trying to revoke the token.",oF(n)),t=o.getCapturedResponse();throw e.statusCode=null==t?void 0:t.status,e.headers=t?at(t.headers):void 0,e}}async getUserInfo(e,t){let n=(await eI(eg,this,sa).call(this,t,!0)).configuration;try{var r;return await i3(n,e.accessToken,null!=(r=e.expectedSubject)?r:n6)}catch(e){throw new o1("There was an error while trying to retrieve the user info.",oF(e))}}async getTokenByPassword(e,t){var n,r;let i=(await eI(eg,this,sa).call(this,t)).configuration,o=new URLSearchParams({username:e.username,password:e.password});e.audience&&o.append("audience",e.audience),e.scope&&o.append("scope",e.scope),e.realm&&o.append("realm",e.realm);let a=i;if(e.auth0ForwardedFor){let t=await eI(eg,this,sp).call(this);a=new iZ(i.serverMetadata(),eW(eu,this).clientId,{client_secret:eW(eu,this).clientSecret,use_mtls_endpoint_aliases:eW(eu,this).useMtls},t);let n=i[n_];a[n_]=(t,r)=>n(t,eK(eK({},r),{},{headers:eK(eK({},r.headers),{},{"auth0-forwarded-for":e.auth0ForwardedFor})}))}if(e.fullResponse){let e=ay(null!=(r=a[n_])?r:eW(eh,this)),t=await eI(eg,this,si).call(this,a.serverMetadata(),e);try{let n=await i6(t,"password",o),r=ap.fromTokenEndpointResponse(n),i=e.getCapturedResponse();if(!i)throw new o7;return{data:r,response:i}}catch(r){if(r instanceof o7)throw r;let t=new oB("There was an error while trying to request a token.",oF(r)),n=e.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?at(n.headers):void 0,t}}let s=ay(null!=(n=a[n_])?n:eW(eh,this)),c=await eI(eg,this,si).call(this,a.serverMetadata(),s);try{let e=await i6(c,"password",o);return ap.fromTokenEndpointResponse(e)}catch(n){let e=new oB("There was an error while trying to request a token.",oF(n)),t=s.getCapturedResponse();throw e.statusCode=null==t?void 0:t.status,e.headers=t?at(t.headers):void 0,e}}async getTokenByPasswordlessEmail(e,t){let n=new URLSearchParams({username:e.email,otp:e.code,realm:"email"});return e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),eI(eg,this,sd).call(this,n,t,e.fullResponse)}async getTokenByPasswordlessSms(e,t){if(!aN(e.phoneNumber))throw new aI("Phone number must be in E.164 format (e.g. +14155550100).");let n=new URLSearchParams({username:e.phoneNumber,otp:e.code,realm:"sms"});return e.audience&&n.append("audience",e.audience),e.scope&&n.append("scope",e.scope),eI(eg,this,sd).call(this,n,t,e.fullResponse)}async getTokenByClientCredentials(e,t){var n,r;let i=function(e){if(null==e)return;let t="string"==typeof e?e.split(/\s+/).filter(Boolean):[];if(0===t.length)throw new ae;return t.join(" ")}(e.scope),o=(await eI(eg,this,sa).call(this,t)).configuration;if(e.fullResponse){let t=ay(null!=(r=o[n_])?r:eW(eh,this)),n=await eI(eg,this,si).call(this,o.serverMetadata(),t),a=new URLSearchParams({audience:e.audience});e.organization&&a.append("organization",e.organization),void 0!==i&&a.append("scope",i);try{let e=await i$(n,a),r=ap.fromTokenEndpointResponse(e),i=t.getCapturedResponse();if(!i)throw new o7;return{data:r,response:i}}catch(r){if(r instanceof o7)throw r;let e=new oq("There was an error while trying to request a token.",oF(r)),n=t.getCapturedResponse();throw e.statusCode=null==n?void 0:n.status,e.headers=n?at(n.headers):void 0,e}}let a=ay(null!=(n=o[n_])?n:eW(eh,this)),s=await eI(eg,this,si).call(this,o.serverMetadata(),a);try{let t=new URLSearchParams({audience:e.audience});e.organization&&t.append("organization",e.organization),void 0!==i&&t.append("scope",i);let n=await i$(s,t);return ap.fromTokenEndpointResponse(n)}catch(n){let e=new oq("There was an error while trying to request a token.",oF(n)),t=a.getCapturedResponse();throw e.statusCode=null==t?void 0:t.status,e.headers=t?at(t.headers):void 0,e}}async buildLogoutUrl(e){let t=await eI(eg,this,ss).call(this),n=t.configuration;if(!t.serverMetadata.end_session_endpoint){let t=new URL("https://".concat(eW(eu,this).domain,"/v2/logout"));return t.searchParams.set("returnTo",e.returnTo),t.searchParams.set("client_id",eW(eu,this).clientId),e.federated&&t.searchParams.set("federated",""),t}let r={post_logout_redirect_uri:e.returnTo};return e.federated&&(r.federated=""),function(e,t){i2(e);let n=iW(e),r=n.as,i=n.c,o=nq(r,"end_session_endpoint",!1,n.tlsOnly);for(let e of((t=new URLSearchParams(t)).has("client_id")||t.set("client_id",i.client_id),t.entries())){var a=eD(e,2);let t=a[0],n=a[1];o.searchParams.append(t,n)}return o}(n,r)}async verifyLogoutToken(e){let t=(await eI(eg,this,ss).call(this)).serverMetadata,n=a2(eW(eu,this).discoveryCache),r=t.jwks_uri;eW(ep,this)||eU(ep,this,function(e,t){if(!(e instanceof URL))throw TypeError("url must be an instance of URL");let n=new URL(e.href).href,r=null!=t?t:{},i=r.timeoutDuration;if("number"==typeof i&&(!Number.isInteger(i)||i<0))throw TypeError('"timeoutDuration" option must be a non-negative integer');let o="number"==typeof i?i:5e3,a=oK(r.cooldownDuration,3e4,"cooldownDuration"),s=oK(r.cacheMaxAge,6e5,"cacheMaxAge"),c=new Headers(r.headers);d&&!c.has("User-Agent")&&c.set("User-Agent",d),c.has("accept")||c.set("accept","application/json, application/jwk-set+json");let l=r[oM],u=r[oL],h,p,f,m=0,y=0;if(u&&"object"==typeof u){let e=u.uat,t=u.jwks;oz(e,s)&&io(t)&&(h=e,f=oU(t))}let g=async()=>{if(p&&("u">typeof WebSocketPair||"u">typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"u">typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&(p=void 0),!p){let e=++m,t=p=(async function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:fetch,i=await r(e,{method:"GET",signal:n,redirect:"manual",headers:t}).catch(e=>{throw"TimeoutError"===e.name?new r7(void 0,{cause:e}):e});if(200!==i.status)throw new r$("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await i.json()}catch(e){throw new r$("Failed to parse the JSON Web Key Set HTTP response as JSON",{cause:e})}})(n,c,AbortSignal.timeout(o),l).then(t=>{let n=oU(t);if(e<=y)return;f=n;let r=Date.now();u&&(u.uat=r,u.jwks=t),h=r,y=e}).finally(()=>{p===t&&(p=void 0)})}await p};return Object.defineProperties(async(e,t)=>{f&&oz(h,s)||await g();try{return await f(e,t)}catch(n){if(n instanceof r6&&!oz(h,a))return await g(),f(e,t);throw n}},{coolingDown:{get:()=>oz(h,a),enumerable:!0},fresh:{get:()=>oz(h,s),enumerable:!0},reload:{value:g,enumerable:!0},reloading:{get:()=>!!p,enumerable:!0},jwks:{value:()=>{var e;return null==(e=f)?void 0:e.jwks()},enumerable:!0}})}(new URL(r),{cacheMaxAge:n.ttlMs,[oM]:eW(eh,this),[oL]:eW(ey,this)}));let i=(await ok(e.logoutToken,eW(ep,this),{issuer:t.issuer,audience:eW(eu,this).clientId,algorithms:["RS256"],requiredClaims:["iat"]})).payload;if(!("sid"in i)&&!("sub"in i))throw new o2('either "sid" or "sub" (or both) claims must be present');if("sid"in i&&"string"!=typeof i.sid)throw new o2('"sid" claim must be a string');if("sub"in i&&"string"!=typeof i.sub)throw new o2('"sub" claim must be a string');if("nonce"in i)throw new o2('"nonce" claim is prohibited');if(!("events"in i))throw new o2('"events" claim is missing');if("object"!=typeof i.events||null===i.events)throw new o2('"events" claim must be an object');if(!("http://schemas.openid.net/event/backchannel-logout"in i.events))throw new o2('"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim');if("object"!=typeof i.events["http://schemas.openid.net/event/backchannel-logout"])throw new o2('"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object');return{sid:i.sid,sub:i.sub}}constructor(e){var t;if(eM(this,eg),eN(this,ea,void 0),eN(this,es,void 0),eN(this,ec,void 0),eN(this,el,void 0),eN(this,eu,void 0),eN(this,eh,void 0),eN(this,ed,void 0),eN(this,ep,void 0),eN(this,ef,void 0),eN(this,em,void 0),eN(this,ey,void 0),eL(this,"mfa",void 0),eL(this,"passkey",void 0),eL(this,"passwordless",void 0),eL(this,"database",void 0),eL(this,"anonymous",void 0),eU(eu,this,e),e.useMtls&&!e.customFetch)throw new oG("mtls_without_custom_fetch_not_supported","Using mTLS without a custom fetch implementation is not supported");eU(ed,this,am(e.telemetry)),eU(eh,this,af(null!=(t=e.customFetch)?t:function(){return fetch(...arguments)},eW(ed,this)));let n=a2(e.discoveryCache);eU(ef,this,a5.createDiscoveryCache(n)),eU(em,this,new Map),eU(ey,this,a5.createJwksCache()),this.mfa=new av({domain:eW(eu,this).domain,clientId:eW(eu,this).clientId,clientSecret:eW(eu,this).clientSecret,customFetch:eW(eh,this),telemetryConfig:eW(ed,this),getConfiguration:async e=>(await eI(eg,this,sa).call(this,e)).configuration,createCaptureConfiguration:async e=>{let t=(await eI(eg,this,ss).call(this)).serverMetadata;return eI(eg,this,si).call(this,t,e)}}),this.passkey=new aE({domain:eW(eu,this).domain,clientId:eW(eu,this).clientId,clientSecret:eW(eu,this).clientSecret,useMtls:eW(eu,this).useMtls,customFetch:eW(eh,this),telemetryConfig:eW(ed,this),grantRequest:async(e,t,n,r)=>{let i=(await eI(eg,this,ss).call(this)).serverMetadata,o=eI(eg,this,so).call(this,n);if(r){let n=ay(o),r=await eI(eg,this,si).call(this,i,n);r[n_]=st(n,e);let a=await i6(r,e,t),s=ap.fromTokenEndpointResponse(a),c=n.getCapturedResponse();if(!c)throw new o7;return{data:s,response:c}}let a=await eI(eg,this,si).call(this,i);a[n_]=st(o,e);let s=await i6(a,e,t);return ap.fromTokenEndpointResponse(s)}}),this.passwordless=new aM({domain:eW(eu,this).domain,clientId:eW(eu,this).clientId,customFetch:eW(eh,this),telemetryConfig:eW(ed,this),clientSecret:eW(eu,this).clientSecret,clientAssertionSigningKey:eW(eu,this).clientAssertionSigningKey,clientAssertionSigningAlg:eW(eu,this).clientAssertionSigningAlg,useMtls:eW(eu,this).useMtls,grantRequest:async(e,t,n,r)=>{let i=(await eI(eg,this,sa).call(this,n)).configuration;if(r){var o;let n=ay(null!=(o=i[n_])?o:eW(eh,this)),r=await eI(eg,this,si).call(this,i.serverMetadata(),n),a=await i6(r,e,t),s=ap.fromTokenEndpointResponse(a),c=n.getCapturedResponse();if(!c)throw new o7;return{data:s,response:c}}try{let n=await i6(i,e,t);return ap.fromTokenEndpointResponse(n)}catch(t){let e={};throw an(e,t),t._statusCode=e.statusCode,t._headers=e.headers,t}}}),this.database=new aG({domain:eW(eu,this).domain,clientId:eW(eu,this).clientId,customFetch:eW(eh,this),telemetryConfig:eW(ed,this)}),this.anonymous=new aB({domain:eW(eu,this).domain,clientId:eW(eu,this).clientId,clientSecret:eW(eu,this).clientSecret,clientAssertionSigningKey:eW(eu,this).clientAssertionSigningKey,clientAssertionSigningAlg:eW(eu,this).clientAssertionSigningAlg,useMtls:eW(eu,this).useMtls,customFetch:eW(eh,this)})}});function sr(){let e=eW(eu,this).domain.toLowerCase();return"".concat(e,"|mtls:").concat(eW(eu,this).useMtls?"1":"0")}async function si(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=await eI(eg,this,sp).call(this,n),i=new iZ(e,eW(eu,this).clientId,{client_secret:eW(eu,this).clientSecret,use_mtls_endpoint_aliases:eW(eu,this).useMtls},r);return i[n_]=null!=t?t:eW(eh,this),i}function so(e){return ag(eW(eh,this),e,eW(ed,this))}async function sa(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=await eI(eg,this,ss).call(this,t),r=n.configuration,i=n.serverMetadata;if(!e)return{configuration:r,serverMetadata:i};let o=eI(eg,this,so).call(this,e);return{configuration:await eI(eg,this,si).call(this,i,o,t),serverMetadata:i}}async function ss(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=eW(e?es:ea,this);if(t&&eW(ec,this))return{configuration:t,serverMetadata:eW(ec,this)};let n=eI(eg,this,sr).call(this);e||await eI(eg,this,sp).call(this,!1);let r=eW(ef,this).get(n);if(r)return eI(eg,this,sc).call(this,r.serverMetadata,e);let i=eW(em,this).get(n);if(i){let t=await i;return eI(eg,this,sc).call(this,t.serverMetadata,e)}let o=(async()=>{let e=(await iD(new URL("https://".concat(eW(eu,this).domain)),eW(eu,this).clientId,{use_mtls_endpoint_aliases:eW(eu,this).useMtls},(e,t,n,r)=>{n.set("client_id",t.client_id)},{[n_]:eW(eh,this)})).serverMetadata();return eW(ef,this).set(n,{serverMetadata:e}),{serverMetadata:e}})();o.catch(()=>{}),eW(em,this).set(n,o);try{let t=(await o).serverMetadata;return eI(eg,this,sc).call(this,t,e)}finally{eW(em,this).delete(n)}}async function sc(e,t){let n=await eI(eg,this,si).call(this,e,void 0,t);return eU(ec,this,e),eU(t?es:ea,this,n),{configuration:n,serverMetadata:e}}async function sl(e,t,n){var r,i,o,a;let s=(await eI(eg,this,sa).call(this,t)).configuration;if("audience"in e||"resource"in e)throw new o$("audience and resource parameters are not supported for Token Vault exchanges");a4(e.subjectToken);let c=new URLSearchParams({connection:e.connection,subject_token:e.subjectToken,subject_token_type:null!=(r=e.subjectTokenType)?r:se,requested_token_type:null!=(i=e.requestedTokenType)?i:"http://auth0.com/oauth/token-type/federated-connection-access-token"});if(e.loginHint&&c.append("login_hint",e.loginHint),e.scope&&c.append("scope",e.scope),a6(c,e.extra),n){let t=ay(null!=(a=s[n_])?a:eW(eh,this)),n=await eI(eg,this,si).call(this,s.serverMetadata(),t);try{let e=await i6(n,a8,c),r=ap.fromTokenEndpointResponse(e),i=t.getCapturedResponse();if(!i)throw new o7;return{data:r,response:i}}catch(i){if(i instanceof o7)throw i;let n=new o$("Failed to exchange token for connection '".concat(e.connection,"'."),oF(i)),r=t.getCapturedResponse();throw n.statusCode=null==r?void 0:r.status,n.headers=r?at(r.headers):void 0,n}}let l=ay(null!=(o=s[n_])?o:eW(eh,this)),u=await eI(eg,this,si).call(this,s.serverMetadata(),l);try{let e=await i6(u,a8,c);return ap.fromTokenEndpointResponse(e)}catch(r){let t=new o$("Failed to exchange token for connection '".concat(e.connection,"'."),oF(r)),n=l.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?at(n.headers):void 0,t}}function su(e,t,n){var r;if(n.organization&&ao(e.claims,n.organization),n.actorToken)if(null!=(r=e.claims)&&r.act)e.act=e.claims.act;else try{e.act=function(e){let t,n;if("string"!=typeof e)throw new r9("JWTs must use Compact JWS serialization, JWT must be a string");let r=e.split("."),i=r[1],o=r.length;if(5===o)throw new r9("Only JWTs using Compact JWS serialization can be decoded");if(3!==o)throw new r9("Invalid JWT");if(!i)throw new r9("JWTs must contain a payload");try{t=it(i)}catch(e){throw new r9("Failed to base64url decode the payload",{cause:e})}try{n=JSON.parse(rX.decode(t))}catch(e){throw new r9("Failed to parse the decoded payload as JSON",{cause:e})}if(!ii(n))throw new r9("Invalid JWT Claims Set");return n}(t.access_token).act}catch(e){}return e}async function sh(e,t,n){var r,i;let o,a,s=(await eI(eg,this,sa).call(this,t)).configuration;if(a4(e.subjectToken),void 0!==e.organization&&ai(e.organization),void 0!==e.actorToken&&void 0===e.actorTokenType)throw new o$("actorTokenType is required when actorToken is provided");let c=new URLSearchParams({subject_token_type:e.subjectTokenType,subject_token:e.subjectToken});if(e.audience&&c.append("audience",e.audience),e.scope&&c.append("scope",e.scope),e.requestedTokenType&&c.append("requested_token_type",e.requestedTokenType),e.organization&&c.append("organization",e.organization),e.actorToken&&c.append("actor_token",e.actorToken),e.actorTokenType&&c.append("actor_token_type",e.actorTokenType),a6(c,e.extra),n){let t,n,r,o=ay(null!=(i=s[n_])?i:eW(eh,this)),a=await eI(eg,this,si).call(this,s.serverMetadata(),o);try{if(n=await i6(a,a7,c),t=ap.fromTokenEndpointResponse(n),!(r=o.getCapturedResponse()))throw new o7}catch(r){if(r instanceof o7)throw r;let t=new o$("Failed to exchange token of type '".concat(e.subjectTokenType,"'").concat(e.audience?" for audience '".concat(e.audience,"'"):"","."),oF(r)),n=o.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?at(n.headers):void 0,t}return eI(eg,this,su).call(this,t,n,e),{data:t,response:r}}let l=ay(null!=(r=s[n_])?r:eW(eh,this)),u=await eI(eg,this,si).call(this,s.serverMetadata(),l);try{a=await i6(u,a7,c),o=ap.fromTokenEndpointResponse(a)}catch(r){let t=new o$("Failed to exchange token of type '".concat(e.subjectTokenType,"'").concat(e.audience?" for audience '".concat(e.audience,"'"):"","."),oF(r)),n=l.getCapturedResponse();throw t.statusCode=null==n?void 0:n.status,t.headers=n?at(n.headers):void 0,t}return eI(eg,this,su).call(this,o,a,e),o}async function sd(e,t,n){var r,i;let o=(await eI(eg,this,sa).call(this,t)).configuration;if(n){let t=ay(null!=(i=o[n_])?i:eW(eh,this)),n=await eI(eg,this,si).call(this,o.serverMetadata(),t);try{let r=await i6(n,"http://auth0.com/oauth/grant-type/passwordless/otp",e),i=ap.fromTokenEndpointResponse(r),o=t.getCapturedResponse();if(!o)throw new o7;return{data:i,response:o}}catch(r){if(r instanceof o7)throw r;let e=new aI("There was an error while trying to request a token.",oF(r)),n=t.getCapturedResponse();throw e.statusCode=null==n?void 0:n.status,e.headers=n?at(n.headers):void 0,e}}let a=ay(null!=(r=o[n_])?r:eW(eh,this)),s=await eI(eg,this,si).call(this,o.serverMetadata(),a);try{let t=await i6(s,"http://auth0.com/oauth/grant-type/passwordless/otp",e);return ap.fromTokenEndpointResponse(t)}catch(n){let e=new aI("There was an error while trying to request a token.",oF(n)),t=a.getCapturedResponse();throw e.statusCode=null==t?void 0:t.status,e.headers=t?at(t.headers):void 0,e}}async function sp(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=!!eW(eu,this).clientSecret||!!eW(eu,this).clientAssertionSigningKey||!!eW(eu,this).useMtls;return e&&!t?(e,t,n,r)=>{n.set("client_id",t.client_id)}:(eW(el,this)||eU(el,this,(async()=>{if(!eW(eu,this).clientSecret&&!eW(eu,this).clientAssertionSigningKey&&!eW(eu,this).useMtls)throw new o6;if(eW(eu,this).useMtls)return(e,t,n,r)=>{n.set("client_id",t.client_id)};let e=eW(eu,this).clientAssertionSigningKey;return!e||e instanceof CryptoKey||(e=await oJ(e,eW(eu,this).clientAssertionSigningAlg||"RS256")),e?function(e,t){var n=void 0;let r=e instanceof CryptoKey?{key:e}:(null==e?void 0:e.key)instanceof CryptoKey?(void 0!==e.kid&&nM(e.kid,'"kid"'),{key:e.key,kid:e.kid}):{},i=r.key,o=r.kid;return function(e,t){if(function(e,t){if(!(e instanceof CryptoKey))throw ng("".concat(t," must be a CryptoKey"),ny)}(e,t),"private"!==e.type)throw ng("".concat(t," must be a private CryptoKey"),nm)}(i,'"clientPrivateKey.key"'),async(e,t,r,a)=>{var s;let c={alg:function(e){switch(e.algorithm.name){case"RSA-PSS":switch(e.algorithm.hash.name){case"SHA-256":return"PS256";case"SHA-384":return"PS384";case"SHA-512":return"PS512";default:throw new nA("unsupported RsaHashedKeyAlgorithm hash name",{cause:e})}case"RSASSA-PKCS1-v1_5":switch(e.algorithm.hash.name){case"SHA-256":return"RS256";case"SHA-384":return"RS384";case"SHA-512":return"RS512";default:throw new nA("unsupported RsaHashedKeyAlgorithm hash name",{cause:e})}case"ECDSA":switch(e.algorithm.namedCurve){case"P-256":return"ES256";case"P-384":return"ES384";case"P-521":return"ES512";default:throw new nA("unsupported EcKeyAlgorithm namedCurve",{cause: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 nA("unsupported CryptoKey algorithm name",{cause:e})}}(i),kid:o},l=function(e,t){let n=nD()+nK(t);return{jti:nz(),aud:e.issuer,exp:n+60,iat:n,nbf:n,iss:t.client_id,sub:t.client_id}}(e,t);null==n||null==(s=n[nk])||s.call(n,c,l),r.set("client_id",t.client_id),r.set("client_assertion_type","urn:ietf:params:oauth:client-assertion-type:jwt-bearer"),r.set("client_assertion",await async function(e,t,n){if(!n.usages.includes("sign"))throw ng('CryptoKey instances used for signing assertions must include "sign" in their "usages"',nm);let r="".concat(nE(nP(JSON.stringify(e))),".").concat(nE(nP(JSON.stringify(t)))),i=nE(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case"ECDSA":return{name:e.algorithm.name,hash:function(e){switch(e.algorithm.namedCurve){case"P-256":return"SHA-256";case"P-384":return"SHA-384";case"P-521":return"SHA-512";default:throw new nA("unsupported ECDSA namedCurve",{cause:e})}}(e)};case"RSA-PSS":switch(rU(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 nA("unsupported RSA-PSS hash name",{cause:e})}case"RSASSA-PKCS1-v1_5":return rU(e),e.algorithm.name;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":case"Ed25519":return e.algorithm.name}throw new nA("unsupported CryptoKey algorithm name",{cause:e})}(n),n,nP(r)));return"".concat(r,".").concat(i)}(c,l,i))}}(e):iN(eW(eu,this).clientSecret)})().catch(e=>{throw eU(el,this,void 0),e})),eW(el,this))}async function sf(e){let t=(await eI(eg,this,ss).call(this)).configuration,n=nz(),r=await async function(e){return nM(e,"codeVerifier"),nE(await crypto.subtle.digest("SHA-256",nP(e)))}(n),i=ar(eK(eK({},eW(eu,this).authorizationParams),null==e?void 0:e.authorizationParams)),o=new URLSearchParams(eK(eK({scope:a3},i),{},{client_id:eW(eu,this).clientId,code_challenge:r,code_challenge_method:"S256"}));return{authorizationUrl:null!=e&&e.pushedAuthorizationRequests?await i1(t,o):await i0(t,o),codeVerifier:n}}new a0(1e3,6e4);class sm extends eQ{static fromPayload(e){return new sm(e.error,e.error_description)}constructor(e,t){super(e,t),Object.setPrototypeOf(this,sm.prototype)}}class sy extends sm{constructor(e,t){super(e,t),Object.setPrototypeOf(this,sy.prototype)}}class sg extends sm{constructor(e,t){super(e,t),Object.setPrototypeOf(this,sg.prototype)}}class sw extends sm{constructor(e,t){super(e,t),Object.setPrototypeOf(this,sw.prototype)}}class sv extends sm{constructor(e,t){super(e,t),Object.setPrototypeOf(this,sv.prototype)}}class sb extends sm{constructor(e,t){super(e,t),Object.setPrototypeOf(this,sb.prototype)}}class s_{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 n of this.contexts){var t=eD(n,2);let r=t[0];e-t[1].createdAt>this.ttlMs&&this.contexts.delete(r)}}get size(){return this.contexts.size}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6e5;this.contexts=new Map,this.ttlMs=e}}class sk{setMFAAuthDetails(e,t,n,r){this.contextManager.set(e,{scope:t,audience:n,mfaRequirements:r})}async getAuthenticators(e){var t,n,r;let i=this.contextManager.get(e);if(!i)throw new sy("invalid_request","MFA context not found for this MFA token");let o=null==(n=null==(t=i.mfaRequirements)?void 0:t.challenge)?void 0:n.map(e=>e.type);try{let t=await this.authJsMfaClient.listAuthenticators({mfaToken:e});return o&&0!==o.length?t.filter(e=>!!e.type&&o.includes(e.type)):t}catch(e){if(e instanceof as)throw new sy(null==(r=e.cause)?void 0:r.error,e.message);throw e}}async enroll(e){var t;let n=function(e){let t=np[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 ac)throw new sg(null==(t=e.cause)?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 au)throw new sw(null==(t=e.cause)?void 0:t.error,e.message);throw e}}async getEnrollmentFactors(e){let t=this.contextManager.get(e);if(!t||!t.mfaRequirements)throw new sb("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 sv("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-recovery-code":void 0;if(!n)throw new sv("invalid_request","Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.");let r=t.scope,i=t.audience;try{let t=await this.auth0Client._requestTokenForMfa({grant_type:n,mfaToken:e.mfaToken,scope:r,audience:i,otp:e.otp,oob_code:e.oobCode,binding_code:e.bindingCode,recovery_code:e.recoveryCode});return this.contextManager.remove(e.mfaToken),t}catch(e){if(e instanceof sv)throw new sv(e.error,e.error_description);throw e}}constructor(e,t){this.authJsMfaClient=e,this.auth0Client=t,this.contextManager=new s_}}class sS extends Error{constructor(e,t,n){super(t),this.name="PasskeyError",this.code=e,this.cause=n,Object.setPrototypeOf(this,sS.prototype)}}class sT{async signup(e){if(!window.PublicKeyCredential)throw new sS("passkey_not_supported","WebAuthn is not supported in this browser.");eR(this,eb,null,"f");let t=e.scope,n=e.audience,r=eE(e,["scope","audience"]),i=await eA(this,ew,"f").register(r);if(i.verificationRequired&&i.verificationRequired.length>0)throw eR(this,eb,{authSession:i.authSession,publicKey:sE(i.authnParamsPublicKey),verificationRequired:i.verificationRequired,realm:r.realm,organization:r.organization,scope:t,audience:n},"f"),new e6(i.verificationRequired);let o=sE(i.authnParamsPublicKey),a=await navigator.credentials.create({publicKey:o});if(!a)throw new sS("passkey_cancelled","Passkey creation was cancelled or no credential was returned.");let s=sR(a);return eA(this,ev,"f")._requestTokenForPasskey({authSession:i.authSession,credential:s,realm:r.realm,organization:r.organization,scope:t,audience:n})}async login(e){if(!window.PublicKeyCredential)throw new sS("passkey_not_supported","WebAuthn is not supported in this browser.");let t=e||{},n=t.scope,r=t.audience,i=eE(t,["scope","audience"]),o=await eA(this,ew,"f").challenge(Object.keys(i).length>0?i:void 0),a=sA(o.authnParamsPublicKey),s=await navigator.credentials.get({publicKey:a});if(!s)throw new sS("passkey_cancelled","Passkey authentication was cancelled or no credential was returned.");let c=sx(s);return eA(this,ev,"f")._requestTokenForPasskey({authSession:o.authSession,credential:c,realm:i.realm,organization:i.organization,scope:n,audience:r})}async getSignupChallenge(e){if(!window.PublicKeyCredential)throw new sS("passkey_not_supported","WebAuthn is not supported in this browser.");let t=await eA(this,ew,"f").register(e);return Object.assign({authSession:t.authSession,publicKey:sE(t.authnParamsPublicKey)},t.verificationRequired&&{verificationRequired:t.verificationRequired})}async getLoginChallenge(e){if(!window.PublicKeyCredential)throw new sS("passkey_not_supported","WebAuthn is not supported in this browser.");let t=await eA(this,ew,"f").challenge(e);return{authSession:t.authSession,publicKey:sA(t.authnParamsPublicKey)}}async getTokenWithPasskey(e){let t;if(!window.PublicKeyCredential)throw new sS("passkey_not_supported","WebAuthn is not supported in this browser.");let n=e.authSession,r=e.credential,i=e.realm,o=e.organization,a=e.scope,s=e.audience,c=e.verification,l=null!=c?c:{};if(Object.keys(l).some(e=>""===l[e]))throw new sS("missing_verification_code","OTP codes in verification must not be empty.");let u=r.response;if(u instanceof AuthenticatorAttestationResponse)t=sR(r);else{if(!(u instanceof AuthenticatorAssertionResponse))throw new sS("passkey_invalid_credential","The provided credential is not a valid attestation or assertion response.");t=sx(r)}return eA(this,ev,"f")._requestTokenForPasskey({authSession:n,credential:t,realm:i,organization:o,scope:a,audience:s,verification:c})}async continueSignup(e){if(!eA(this,eb,"f"))throw new sS("no_pending_signup","No pending signup found. Call signup() first and catch PasskeyVerificationRequiredError.");let t=eA(this,eb,"f").verificationRequired.filter(t=>!(null==e?void 0:e[t]));if(t.length>0)throw new sS("missing_verification_code","Missing OTP code for: ".concat(t.join(", "),". Pass a code for each identifier in verificationRequired."));let n=eA(this,eb,"f");eR(this,eb,null,"f");let r=n.authSession,i=n.publicKey,o=n.realm,a=n.organization,s=n.scope,c=n.audience,l=n.credential;if(!l){let e;try{e=await navigator.credentials.create({publicKey:i})}catch(e){throw eR(this,eb,n,"f"),e}if(!e)throw eR(this,eb,n,"f"),new sS("passkey_cancelled","Passkey creation was cancelled or no credential was returned.");l=sR(e)}try{return await eA(this,ev,"f")._requestTokenForPasskey({authSession:r,credential:l,realm:o,organization:a,scope:s,audience:c,verification:e})}catch(e){throw e instanceof aT&&e.isRetryable&&eR(this,eb,Object.assign(Object.assign({},n),{authSession:e.authSession,verificationRequired:e.verificationRequired,credential:l}),"f"),e}}constructor(e,t){ew.set(this,void 0),ev.set(this,void 0),eb.set(this,null),eR(this,ew,e,"f"),eR(this,ev,t,"f")}}function sC(e){return btoa(Array.from(new Uint8Array(e),e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function sP(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n=atob(t+"=".repeat((4-t.length%4)%4)),r=new Uint8Array(n.length);for(let e=0;ee,set:t=>{e=t},remove:()=>{e=null}}}ew=new WeakMap,ev=new WeakMap,eb=new WeakMap;class sj{getStore(e,t){let n="".concat(this.baseKey,"::").concat(JSON.stringify([null!=e?e:"",null!=t?t:""]));return this.slots.has(n)||this.slots.set(n,this.useLocalStorage?sO(n):sI()),this.slots.get(n)}getSessionToken(){return this.sessionStore.get()}setSessionToken(e){this.sessionStore.set(e),this.expiredStore.remove()}isSessionExpired(){return!!this.expiredStore.get()}markSessionExpired(){this.expiredStore.set(!0)}removeAll(){if(this.sessionStore.remove(),this.expiredStore.remove(),this.slots.forEach(e=>e.remove()),this.slots.clear(),this.useLocalStorage)try{let e=this.baseKey+"::",t=[];for(let n=0;nwindow.localStorage.removeItem(e))}catch(e){}}constructor(e,t){this.slots=new Map,this.baseKey="".concat("@@auth0spajs@@","::").concat(e,"::anonymous");try{this.useLocalStorage="localStorage"===t&&"undefined"!=typeof window&&!!window.localStorage}catch(e){this.useLocalStorage=!1}this.sessionKey="".concat(this.baseKey,"::").concat("session"),this.sessionStore=this.useLocalStorage?sO(this.sessionKey):sI();let n="".concat(this.baseKey,"::").concat("session_expired");this.expiredStore=this.useLocalStorage?sO(n):sI()}}class sW{async createSession(e){let t=await this.authJsClient.createSession(e);return this.cache.setSessionToken(Object.assign({sessionToken:t.sessionToken},void 0!==t.sessionTokenExpiresAt&&{sessionTokenExpiresAt:t.sessionTokenExpiresAt})),this.cache.getStore(null==e?void 0:e.audience,null==e?void 0:e.scope).set(Object.assign({accessToken:t.accessToken,expiresAt:t.expiresAt},void 0!==t.scope&&{scope:t.scope})),t}async getTokenSilently(e){let t=this.cache.getStore(null==e?void 0:e.audience,null==e?void 0:e.scope),n=t.get();return n&&n.expiresAt-60>Date.now()/1e3?n:this.lockManager.runWithLock("anonymous::".concat(this.clientId),5e3,async()=>{var n;let r;if(this.cache.isSessionExpired())throw new aX("session_expired","The anonymous session has expired. Call createSession() to start a new one.");let i=t.get();if(i&&i.expiresAt-60>Date.now()/1e3)return i;let o=null==(n=this.cache.getSessionToken())?void 0:n.sessionToken;try{r=await this.authJsClient.getAccessToken(Object.assign(Object.assign({},e),{sessionToken:o}))}catch(e){throw e instanceof aX&&("session_expired"===e.code||"invalid_session_token"===e.code)&&(this.cache.removeAll(),this.cache.markSessionExpired()),e}return this.cache.getStore(null==e?void 0:e.audience,null==e?void 0:e.scope).set(Object.assign({accessToken:r.accessToken,expiresAt:r.expiresAt},void 0!==r.scope&&{scope:r.scope})),this.cache.getSessionToken()||this.cache.setSessionToken(Object.assign({sessionToken:r.sessionToken},void 0!==r.sessionTokenExpiresAt&&{sessionTokenExpiresAt:r.sessionTokenExpiresAt})),Object.assign({accessToken:r.accessToken,expiresAt:r.expiresAt},void 0!==r.scope&&{scope:r.scope})})}async mintTransferToken(){let e=this.cache.getSessionToken();return(null==e?void 0:e.sessionToken)?this.authJsClient.mintTransferToken(e.sessionToken):null}async logout(){await this.authJsClient.logout(),this.cache.removeAll()}hasSession(){var e;return!!(null==(e=this.cache.getSessionToken())?void 0:e.sessionToken)}getClaims(){return null}constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"localStorage",r=arguments.length>3?arguments[3]:void 0;this.authJsClient=e,this.clientId=t,this.cache=new sj(t,n),this.lockManager=null!=r?r:tC()}}class sN{resolveOnlineAccess(e){if("online"!==e.refreshTokenMode)return!1;if(!0!==e.useRefreshTokens)throw new e$('`refreshTokenMode: "online"` requires the refresh-token grant.',"Set `useRefreshTokens: true`.");if(!0!==e.useDpop)throw new e$('`refreshTokenMode: "online"` requires DPoP, which is missing or disabled.',"Set `useDpop: true` (DPoP is mandatory for online access).");return!0}warnEnterpriseConnectConfig(e){var t,n;if(!0!==e.enterpriseConnect)return;let r=null==(t=e.authorizationParams)?void 0:t.scope;(!0===e.useRefreshTokens||"string"==typeof r&&r.includes("offline_access"))&&console.warn("Enterprise Connect issues no refresh token; `useRefreshTokens` and `offline_access` in `scope` have no effect."),(null==(n=e.authorizationParams)?void 0:n.organization)&&console.warn("Enterprise Connect resolves the organization from the email domain (Home Realm Discovery); a static `organization` breaks multi-customer setups.")}getConfiguration(){return Object.freeze({domain:this.options.domain,clientId:this.options.clientId})}_url(e){let t=encodeURIComponent(btoa(JSON.stringify(ta(this.options.auth0Client||eq,!0))));return"".concat(this.domainUrl).concat(e,"&auth0Client=").concat(t)}_authorizeUrl(e){return this._url("/authorize?".concat(ts(e)))}async _verifyIdToken(e,t,n,r){let i=await this.nowProvider();return(e=>{if(!e.id_token)throw Error("ID token is required but missing");let t=(e=>{let t=e.split("."),n=eD(t,3),r=n[0],i=n[1],o=n[2];if(3!==t.length||!r||!i||!o)throw Error("ID token could not be decoded");let a=JSON.parse(tl(i)),s={__raw:e},c={};return Object.keys(a).forEach(e=>{s[e]=a[e],t0.includes(e)||(c[e]=a[e])}),{encoded:{header:r,payload:i,signature:o},header:JSON.parse(tl(r)),claims:s,user:c}})(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(null!=e.max_age&&"number"!=typeof 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||"number"!=typeof t.claims.exp)throw Error("Expiration Time (exp) claim must be a number present in the ID token");if("number"!=typeof t.claims.iat)throw Error("Issued At (iat) claim must be a number present in the ID token");let n=e.leeway||60,r=new Date(e.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(t.claims.exp+n),r>i)throw Error("Expiration Time (exp) claim error in the ID token; current time (".concat(r,") is after expiration time (").concat(i,")"));if(null!=t.claims.nbf&&"number"==typeof t.claims.nbf){let e=new Date(0);if(e.setUTCSeconds(t.claims.nbf-n),ri)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(i))}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})({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:t,organization:n,leeway:this.options.leeway,max_age:(e=>{if("string"!=typeof e)return e;let t=parseInt(e,10);return isNaN(t)?void 0:t})(null!=r?r:this.options.authorizationParams.max_age),now:i})}_processOrgHint(e){e?this.cookieStorage.save(this.orgHintCookieName,e,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}_extractSessionTransferToken(e){return new URLSearchParams(window.location.search).get(e)||void 0}_clearSessionTransferTokenFromUrl(e){try{let t=new URL(window.location.href);t.searchParams.has(e)&&(t.searchParams.delete(e),window.history.replaceState({},"",t.toString()))}catch(e){}}_applySessionTransferToken(e){let t=this.options.sessionTransferTokenQueryParamName;if(!t||e.session_transfer_token)return e;let n=this._extractSessionTransferToken(t);return n?(this._clearSessionTransferTokenFromUrl(t),Object.assign(Object.assign({},e),{session_transfer_token:n})):e}async _applyAnonTransferToken(e){let t=await this.anonymous.mintTransferToken();return t?Object.assign(Object.assign({},e),{anon_transfer_token:t}):e}async _prepareAuthorizeUrl(e,t,n){var r;let i,o,a,s,c=ti(tr()),l=ti(tr()),u=tr(),h=tu(await tc(u)),d=await (null==(r=this.dpop)?void 0:r.calculateThumbprint()),p=(i=this.options,o=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:i.clientId},i.authorizationParams),e),{scope:tG(o,e.scope,e.audience),response_type:"code",response_mode:s||"query",state:c,nonce:l,redirect_uri:a||i.authorizationParams.redirect_uri,code_challenge:h,code_challenge_method:"S256",dpop_jkt:d})),f=this._authorizeUrl(p);return{nonce:l,code_verifier:u,scope:p.scope,audience:p.audience||eB,redirect_uri:p.redirect_uri,state:c,url:f,max_age:p.max_age}}async loginWithPopup(e,t){var n;let r,i;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 e9;let o=await this._applyAnonTransferToken(this._applySessionTransferToken(e.authorizationParams||{})),a=await this._prepareAuthorizeUrl(o,{response_mode:"web_message"},window.location.origin);t.popup.location.href=a.url;let s=await (r=Object.assign(Object.assign({},t),{timeoutInSeconds:t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),i=new URL(a.url).origin,new Promise((e,t)=>{let n,o=setInterval(()=>{r.popup&&r.popup.closed&&(clearInterval(o),clearTimeout(a),window.removeEventListener("message",n,!1),t(new e3(r.popup)))},1e3),a=setTimeout(()=>{clearInterval(o),t(new e5(r.popup)),window.removeEventListener("message",n,!1)},1e3*(r.timeoutInSeconds||60));n=function(s){if(s.origin===i&&s.data&&"authorization_response"===s.data.type){if(clearTimeout(a),clearInterval(o),window.removeEventListener("message",n,!1),!1!==r.closePopup&&r.popup.close(),s.data.response.error)return t(eQ.fromPayload(s.data.response));e(s.data.response)}},window.addEventListener("message",n)}));if(a.state!==s.state)throw new eQ("state_mismatch","Invalid state");let c=(null==(n=e.authorizationParams)?void 0:n.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:a.audience,scope:a.scope,code_verifier:a.code_verifier,grant_type:"authorization_code",code:s.code,redirect_uri:a.redirect_uri},{nonceIn:a.nonce,organization:c,max_age:a.max_age})}async getUser(){var e;if(await this._isSessionCeilingReached())return;let t=await this._getIdTokenFromCache();return null==(e=null==t?void 0:t.decodedToken)?void 0:e.user}async getIdTokenClaims(){var e;if(await this._isSessionCeilingReached())return;let t=await this._getIdTokenFromCache();return null==(e=null==t?void 0:t.decodedToken)?void 0:e.claims}async loginWithRedirect(){var e;let t=na(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),n=t.openUrl,r=t.fragment,i=t.appState,o=eE(t,["openUrl","fragment","appState"]),a=(null==(e=o.authorizationParams)?void 0:e.organization)||this.options.authorizationParams.organization,s=await this._applyAnonTransferToken(this._applySessionTransferToken(o.authorizationParams||{})),c=await this._prepareAuthorizeUrl(s),l=c.url,u=eE(c,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},u),{appState:i,response_type:t7.Code}),a&&{organization:a}));let h=r?"".concat(l,"#").concat(r):l;n?await n(h):window.location.assign(h)}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 eQ("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===t7.ConnectCode?this._handleConnectAccountRedirectCallback(n,t):this._handleLoginRedirectCallback(n,t)}async _handleLoginRedirectCallback(e,t){let n=e.code,r=e.state,i=e.error,o=e.error_description;if(i)throw new e0(i,o||i,r,t.appState);if(!t.code_verifier||t.state&&t.state!==r)throw new eQ("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,max_age:t.max_age}),{appState:t.appState,response_type:t7.Code}}async _handleConnectAccountRedirectCallback(e,t){let n=e.connect_code,r=e.state,i=e.error,o=e.error_description;if(i)throw new e1(i,o||i,t.connection,r,t.appState);if(!n)throw new eQ("missing_connect_code","Missing connect code");if(!(t.code_verifier&&t.state&&t.auth_session&&t.redirect_uri&&t.state===r))throw new eQ("state_mismatch","Invalid state");return Object.assign(Object.assign({},await this.myAccount.completeAccount({auth_session:t.auth_session,connect_code:n,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier})),{appState:t.appState,response_type:t7.ConnectCode})}async _maybeCreateAnonymousSession(){if(this.options.createAnonymousSessionOnFailedSilentAuth&&!this.anonymous.hasSession())try{await this.anonymous.getTokenSilently()}catch(e){console.debug("[auth0-spa-js] Anonymous session creation failed",e)}}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get(nr))return void await this._maybeCreateAnonymousSession();this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(nr)}try{await this.getTokenSilently(e)}catch(e){e instanceof eQ&&"login_required"===e.error&&e.error_description!==eV&&await this._maybeCreateAnonymousSession()}}async getTokenSilently(){var e,t,n,r;let i,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=Object.assign(Object.assign({cacheMode:"on"},o),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),o.authorizationParams),{scope:tG(this.scope,null==(e=o.authorizationParams)?void 0:e.scope,(null==(t=o.authorizationParams)?void 0:t.audience)||this.options.authorizationParams.audience)})}),s=await (n=()=>this._getTokenSilently(a),(i=tP[r="".concat(this.options.clientId,"::").concat(a.authorizationParams.audience,"::").concat(a.authorizationParams.scope,"::").concat(a.cacheMode)])||(i=n().finally(()=>{delete tP[r],i=null}),tP[r]=i),i);return o.detailedResponse?s:null==s?void 0:s.access_token}async _getTokenSilently(e){var t,n;let r=e.cacheMode,i=eE(e,["cacheMode"]);if(await this._isSessionCeilingReached())return;if("off"!==r){let e=await this._getEntryFromCache({scope:i.authorizationParams.scope,audience:i.authorizationParams.audience||eB,clientId:this.options.clientId,cacheMode:r});if(e)return e}if("cache-only"===r)return;let o=(t=this.options.clientId,n=i.authorizationParams.audience||"default","".concat("auth0.lock.getTokenSilently",".").concat(t,".").concat(n));try{return await this.lockManager.runWithLock(o,5e3,async()=>{if("off"!==r){let e=await this._getEntryFromCache({scope:i.authorizationParams.scope,audience:i.authorizationParams.audience||eB,clientId:this.options.clientId});if(e)return e}let e=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(i):await this._getTokenFromIFrame(i),t=e.id_token,n=e.token_type,o=e.access_token,a=e.oauthTokenScope,s=e.expires_in;return Object.assign(Object.assign({id_token:t,token_type:n,access_token:o},a?{scope:a}:null),{expires_in:s})})}catch(e){if(this._isInteractiveError(e)&&"popup"===this.options.interactiveErrorHandler)return await this._handleInteractiveErrorWithPopup(i);throw e}}_isInteractiveError(e){return e instanceof e4||e instanceof eQ&&this._isIframeMfaError(e)}_isIframeMfaError(e){return"login_required"===e.error&&e.error_description===eV}async _handleInteractiveErrorWithPopup(e){try{await this.loginWithPopup({authorizationParams:e.authorizationParams});let t=await this._getEntryFromCache({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||eB,clientId:this.options.clientId});if(!t)throw new eQ("interactive_handler_cache_miss","Token not found in cache after interactive authentication");return t}catch(e){throw e}}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]:{},i=Object.assign(Object.assign({},n),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),n.authorizationParams),{scope:tG(this.scope,null==(e=n.authorizationParams)?void 0:e.scope,(null==(t=n.authorizationParams)?void 0:t.audience)||this.options.authorizationParams.audience)})});return r=Object.assign(Object.assign({},eF),r),await this.loginWithPopup(i,r),(await this.cacheManager.get(new tq({scope:i.authorizationParams.scope,audience:i.authorizationParams.audience||eB,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||{},n=t.federated,r=eE(t,["federated"]);return this._url("/v2/logout?".concat(ts(Object.assign({clientId:e.clientId},r))))+(n?"&federated":"")}async revokeRefreshToken(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.options.useRefreshTokens)return;let t=e.audience||this.options.authorizationParams.audience||eB,n=await this.cacheManager.getRefreshTokensByAudience(t,this.options.clientId);await async function(e,t){let n=e.baseUrl,r=e.timeout,i=e.auth0Client,o=e.useFormData,a=e.refreshTokens,s=e.audience,c=e.client_id,l=e.onRefreshTokenRevoked,u=r||1e4,h="refresh_token",d="".concat(n,"/oauth/revoke"),p={"Content-Type":o?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(ta(i||eq)))};if(t){let e={client_id:c,token_type_hint:h},n=o?ts(e):JSON.stringify(e);try{return await tK({type:"revoke",timeout:u,fetchUrl:d,fetchOptions:{method:"POST",body:n,headers:p},useFormData:o,auth:{audience:null!=s?s:eB}},t)}catch(e){throw new eQ("revoke_error",e.message)}}for(let e of a){let t={client_id:c,token_type_hint:h,token:e},n=o?ts(t):JSON.stringify(t),r=await tJ(d,{method:"POST",body:n,headers:p},u);if(!r.ok){let e,t;try{var f=JSON.parse(await r.text());e=f.error,t=f.error_description}catch(e){}throw new eQ(e||"revoke_error",t||"HTTP error ".concat(r.status))}await (null==l?void 0:l(e))}}({baseUrl:this.domainUrl,timeout:this.httpTimeoutMs,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,client_id:this.options.clientId,refreshTokens:n,audience:t,onRefreshTokenRevoked:e=>this.cacheManager.stripRefreshToken(e)},this.worker),this.onlineAccess&&await this._clearLocalSession()}async logout(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options.enterpriseConnect&&!0!==(null==(e=t.logoutParams)?void 0:e.federated)&&console.warn("Enterprise Connect logout without `federated: true` leaves the enterprise IdP session alive; the next login may silently reuse the previous user.");let n=na(t),r=n.openUrl,i=eE(n,["openUrl"]);await this._clearLocalSession(t.clientId);let o=this._buildLogoutUrl(i);r?await r(o):!1!==r&&window.location.assign(o)}async _getTokenFromIFrame(e){var t;let n=(t=this.options.clientId,"".concat("auth0.lock.getTokenFromIFrame",".").concat(t));try{return await this.lockManager.runWithLock(n,5e3,async()=>{let t,n=Object.assign(Object.assign({},e.authorizationParams),{prompt:"none"}),r=this.cookieStorage.get(this.orgHintCookieName);r&&!n.organization&&(n.organization=r);let i=await this._prepareAuthorizeUrl(n,{response_mode:"web_message"},window.location.origin),o=i.url,a=i.state,s=i.nonce,c=i.code_verifier,l=i.redirect_uri,u=i.scope,h=i.audience,d=i.max_age;if(window.crossOriginIsolated)throw new eQ("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");let p=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds;try{t=new URL(this.domainUrl).origin}catch(e){t=this.domainUrl}let f=await function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60;return new Promise((r,i)=>{let o,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",o,!1))},c=setTimeout(()=>{i(new e2),s()},1e3*n);o=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?i(eQ.fromPayload(e.data.response)):r(e.data.response),clearTimeout(c),window.removeEventListener("message",o,!1),setTimeout(s,2e3)},window.addEventListener("message",o,!1),window.document.body.appendChild(a),a.setAttribute("src",e)})}(o,t,p);if(a!==f.state)throw new eQ("state_mismatch","Invalid state");let m=await this._requestToken(Object.assign(Object.assign({},e.authorizationParams),{code_verifier:c,code:f.code,grant_type:"authorization_code",redirect_uri:l,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:s,organization:n.organization,max_age:d});return Object.assign(Object.assign({},m),{scope:u,oauthTokenScope:m.scope,audience:h})})}catch(e){throw"login_required"===e.error&&(e instanceof eQ&&this._isIframeMfaError(e)&&"popup"===this.options.interactiveErrorHandler||this.logout({openUrl:!1})),e}}async _getTokenUsingRefreshToken(e){var t,n,r,i;let o=await this.cacheManager.get(new tq({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||eB,clientId:this.options.clientId}),void 0,this.options.useMrrt);if(!(o&&o.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw new e8(e.authorizationParams.audience||eB,e.authorizationParams.scope)}let a=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,s="number"==typeof e.timeoutInSeconds?1e3*e.timeoutInSeconds:null,c=((e,t,n,r)=>{var i;if(e&&n&&r){if(t.audience!==n)return t.scope;let e=r.split(" "),o=(null==(i=t.scope)?void 0:i.split(" "))||[],a=o.every(t=>e.includes(t));return e.length>=o.length&&a?r:t.scope}return t.scope})(this.options.useMrrt,e.authorizationParams,null==o?void 0:o.audience,null==o?void 0:o.scope);try{let l=await this._requestToken(Object.assign(Object.assign(Object.assign({},e.authorizationParams),{grant_type:"refresh_token",refresh_token:o&&o.refresh_token,redirect_uri:a}),s&&{timeout:s}),{scopesToRequest:c});if(await this._propagateRotatedRefreshToken(null==o?void 0:o.refresh_token,l.refresh_token),this.options.useMrrt&&(t=null==o?void 0:o.audience,n=null==o?void 0:o.scope,r=e.authorizationParams.audience,i=e.authorizationParams.scope,t!==r||!((e,t)=>{let n=(null==t?void 0:t.split(" "))||[];return((null==e?void 0:e.split(" "))||[]).every(e=>n.includes(e))})(i,n))){let t=((e,t,n)=>{let r=(null==e?void 0:e.split(" "))||[],i=n?r.filter(e=>e!==eX):r,o=(null==t?void 0:t.split(" "))||[];return i.filter(e=>-1==o.indexOf(e)).join(",")})(c,l.scope,this.onlineAccess);if(t){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw await this.cacheManager.remove(this.options.clientId,e.authorizationParams.audience||eB,e.authorizationParams.scope),new e7(e.authorizationParams.audience||"default",t)}}return Object.assign(Object.assign({},l),{scope:e.authorizationParams.scope,oauthTokenScope:l.scope,audience:e.authorizationParams.audience||eB})}catch(t){if(t.message){if(t.message.includes("user is blocked"))throw await this.logout({openUrl:!1}),t;if((t.message.includes("Missing Refresh Token")||t.message.includes("invalid refresh token"))&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e)}throw t}}async _propagateRotatedRefreshToken(e,t){!this.onlineAccess&&t&&e&&await this.cacheManager.updateEntry(e,t,this.options.clientId,this.options.useMrrt)}async _saveEntryInCache(e){let t=e.decodedToken.claims,n=t.session_expiry,r=t.iat;if(void 0!==n){if("number"!=typeof n)throw new eQ("invalid_token","Invalid session_expiry: value must be a number.");if(n>=1e10)throw new eQ("invalid_token","Invalid session_expiry: value appears to be in milliseconds; expected a Unix timestamp in seconds.");if(void 0===r||n<=r)throw new eQ("invalid_token","Invalid session_expiry: session ceiling is before or at the token issue time.")}let i=e.id_token,o=e.decodedToken,a=eE(e,["id_token","decodedToken"]);this.userCache.set(tX,{id_token:i,decodedToken:o}),await this.cacheManager.setIdToken(this.options.clientId,e.id_token,e.decodedToken),await this.cacheManager.set(a)}async _clearLocalSession(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.clientId;null===t?await this.cacheManager.clear():await this.cacheManager.clear(t),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove(tX);try{await (null==(e=this.dpop)?void 0:e.clear())}catch(e){}if(this.worker)try{await tK({type:"clear"},this.worker)}catch(e){}}async _isSessionCeilingReached(){var e,t;let n=this.userCache.get(tX),r=null!=n?n:await this.cacheManager.getIdToken(new tq({clientId:this.options.clientId})),i=null==(t=null==(e=null==r?void 0:r.decodedToken)?void 0:e.claims)?void 0:t.session_expiry;return void 0!==i&&Math.floor(await this.nowProvider()/1e3)>=i-30&&(await this._clearLocalSession(),!0)}async _getIdTokenFromCache(){let e=this.options.authorizationParams.audience||eB,t=this.scope[e],n=await this.cacheManager.getIdToken(new tq({clientId:this.options.clientId,audience:e,scope:t})),r=this.userCache.get(tX);return n&&n.id_token===(null==r?void 0:r.id_token)?r:(this.userCache.set(tX,n),n)}async _getEntryFromCache(e){let t=e.scope,n=e.audience,r=e.clientId,i=e.cacheMode,o=await this.cacheManager.get(new tq({scope:t,audience:n,clientId:r}),60,this.options.useMrrt,i);if(o&&o.access_token){let e=o.token_type,t=o.access_token,n=o.oauthTokenScope,r=o.expires_in,i=await this._getIdTokenFromCache();return i&&Object.assign(Object.assign({id_token:i.id_token,token_type:e||"Bearer",access_token:t},n?{scope:n}:null),{expires_in:r})}}_storeMfaContext(e,t,n){e instanceof e4&&this.mfa.setMFAAuthDetails(e.mfa_token,t,n,e.mfa_requirements)}async _requestToken(e,t){var n,r,i,o,a,s;let c=t||{},l=c.nonceIn,u=c.organization,h=c.scopesToRequest,d=c.max_age;try{let t=await tZ(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,preserveRefreshToken:this.onlineAccess},e),{scope:h||e.scope}),this.worker),c=await this._verifyIdToken(t.id_token,l,u,d);if("authorization_code"===e.grant_type){let e=await this._getIdTokenFromCache();(null==(r=null==(n=null==e?void 0:e.decodedToken)?void 0:n.claims)?void 0:r.sub)&&e.decodedToken.claims.sub!==c.claims.sub&&(await this.cacheManager.clear(this.options.clientId),this.userCache.remove(tX))}if("authorization_code"!==e.grant_type){let e=await this._getIdTokenFromCache(),t=null==(o=null==(i=null==e?void 0:e.decodedToken)?void 0:i.claims)?void 0:o.session_expiry;void 0!==t&&(c=Object.assign(Object.assign({},c),{claims:Object.assign(Object.assign({},c.claims),{session_expiry:t})}))}return!t.refresh_token&&this.onlineAccess&&(t.refresh_token=null!=(a=e.refresh_token)?a:null==(s=await this.cacheManager.get(new tq({scope:h||e.scope,audience:e.audience||eB,clientId:this.options.clientId}),void 0,this.options.useMrrt))?void 0:s.refresh_token),await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},t),{decodedToken:c,scope:e.scope,audience:e.audience||eB}),t.scope?{oauthTokenScope:t.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(u||c.claims.org_id),Object.assign(Object.assign({},t),{decodedToken:c})}catch(t){throw"authorization_code"!==e.grant_type&&this._storeMfaContext(t,h||e.scope,e.audience),t}}_buildTokenExchangeParams(e){return Object.assign(Object.assign(Object.assign(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}),e.actor_token&&{actor_token:e.actor_token}),e.actor_token_type&&{actor_token_type:e.actor_token_type}),{scope:tG(this.scope,e.scope,e.audience||this.options.authorizationParams.audience),audience:e.audience||this.options.authorizationParams.audience,organization:e.organization||this.options.authorizationParams.organization})}async loginWithCustomTokenExchange(e){let t=this._buildTokenExchangeParams(e);return this._requestToken(t,{organization:t.organization})}async customTokenExchange(e){let t=this._buildTokenExchangeParams(e);try{let n=await tZ(Object.assign(Object.assign({},t),{baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,dpop:this.dpop}),this.worker,!0);return n.id_token&&await this._verifyIdToken(n.id_token,void 0,e.organization),n}catch(e){throw this._storeMfaContext(e,t.scope,t.audience),e}}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 nu(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.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 t=e.openUrl,n=e.appState,r=e.connection,i=e.scopes,o=e.authorization_params,a=e.redirectUri,s=void 0===a?this.options.authorizationParams.redirect_uri||window.location.origin:a;if(!r)throw Error("connection is required");let c=ti(tr()),l=tr(),u=tu(await tc(l)),h=await this.myAccount.connectAccount({connection:r,scopes:i,redirect_uri:s,state:c,code_challenge:u,code_challenge_method:"S256",authorization_params:o}),d=h.connect_uri,p=h.connect_params,f=h.auth_session;this.transactionManager.create({state:c,code_verifier:l,auth_session:f,redirect_uri:s,appState:n,connection:r,response_type:t7.ConnectCode});let m=new URL(d);m.searchParams.set("ticket",p.ticket),t?await t(m.toString()):window.location.assign(m)}async _requestTokenForPasskey(e){var t;let n=e.audience||this.options.authorizationParams.audience,r=e.organization||this.options.authorizationParams.organization,i=!!e.verification&&Object.keys(e.verification).length>0;try{return await this._requestToken(Object.assign(Object.assign(Object.assign(Object.assign({grant_type:"urn:okta:params:oauth:grant-type:webauthn",auth_session:e.authSession,authn_response:e.credential},e.realm&&{realm:e.realm}),r&&{organization:r}),i&&{verification:e.verification}),{scope:tG(this.scope,e.scope,n),audience:n}))}catch(e){if(e instanceof eQ&&(null==(t=e.data)?void 0:t.auth_session)&&e.data.verification_required)throw new aT(e.error_description,{error:e.error,error_description:e.error_description,auth_session:e.data.auth_session,verification_required:e.data.verification_required});throw e}}async _requestTokenForMfa(e,t){let n=e.mfaToken,r=eE(e,["mfaToken"]),i=await this.cacheManager.get(new tq({scope:r.scope,audience:r.audience||eB,clientId:this.options.clientId}),void 0,this.options.useMrrt),o=await this._requestToken(Object.assign(Object.assign({},r),{mfa_token:n}),t);return await this._propagateRotatedRefreshToken(null==i?void 0:i.refresh_token,o.refresh_token),o}constructor(e){var t,n;let r,i,o;if(this.userCache=(new tB).enclosedCache,this.defaultOptions={authorizationParams:{scope:"openid profile email"},useRefreshTokensFallback:!1,useFormData:!0,refreshTokenMode:"offline",anonymousSessionsCacheMode:"localStorage"},this.onlineAccess=this.resolveOnlineAccess(e),this.warnEnterpriseConnectConfig(e),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(!tn())throw Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(void 0===tn().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 ")})(),this.lockManager=tC(),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)i=e.cache;else{if(!no(r=e.cacheLocation||eG))throw Error('Invalid cache location "'.concat(r,'"'));i=no(r)()}this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=!1===e.legacySameSiteCookie?t9:t6,this.orgHintCookieName=(t=this.options.clientId,"auth0.".concat(t,".organization_hint")),this.isAuthenticatedCookieName=(o=this.options.clientId,"auth0.".concat(o,".is.authenticated")),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;let a=e.useCookiesForTransactions?this.cookieStorage:t8,s="";this.onlineAccess?s=eX:this.options.useRefreshTokens&&(s="offline_access"),this.scope=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i{let i=e[n];o[n]=tF(t,i,...r)}),o}(this.options.authorizationParams.scope,"openid",s),this.transactionManager=new t$(a,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||eY,this.cacheManager=new tQ(i,i.allKeys?void 0:new nn(i,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new nl(this.options.clientId):void 0,this.domainUrl=(n=this.options.domain,/^https?:\/\//.test(n)?n:"https://".concat(n)),this.tokenIssuer=((e,t)=>e?e.startsWith("https://")?e:"https://".concat(e,"/"):"".concat(t,"/"))(this.options.issuer,this.domainUrl);let c="".concat(this.domainUrl,"/me/"),l=this.createFetcher(Object.assign(Object.assign({},this.options.useDpop&&{dpopNonceId:"__auth0_my_account_api__"}),{getAccessToken:e=>{var t;return this.getTokenSilently({authorizationParams:{scope:null==(t=null==e?void 0:e.scope)?void 0:t.join(" "),audience:c},detailedResponse:!0})}}));this.myAccount=new nh(l,c),this.authJsClient=new sn({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new sk(this.authJsClient.mfa,this),this.anonymous=new sW(this.authJsClient.anonymous,this.options.clientId,this.options.anonymousSessionsCacheMode,this.lockManager),this.passkey=new sT(this.authJsClient.passkey,this),"undefined"!=typeof window&&window.Worker&&this.options.useRefreshTokens&&r===eG&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new nt,this.worker.postMessage({type:"init",allowedBaseUrl:this.domainUrl}))}}var sU={isAuthenticated:!1,isLoading:!0,error:void 0,user:void 0},sM=function(){throw Error("You forgot to wrap your component in .")},sL=eS(eS({},sU),{buildAuthorizeUrl:sM,buildLogoutUrl:sM,getAccessTokenSilently:sM,getAccessTokenWithPopup:sM,getIdTokenClaims:sM,loginWithCustomTokenExchange:sM,customTokenExchange:sM,exchangeToken:sM,loginWithRedirect:sM,loginWithPopup:sM,connectAccountWithRedirect:sM,logout:sM,revokeRefreshToken:sM,handleRedirectCallback:sM,getDpopNonce:sM,setDpopNonce:sM,generateDpopProof:sM,createFetcher:sM,getConfiguration:sM,mfa:{getAuthenticators:sM,enroll:sM,challenge:sM,verify:sM,getEnrollmentFactors:sM},passkey:{signup:sM,login:sM,continueSignup:sM,getSignupChallenge:sM,getLoginChallenge:sM,getTokenWithPasskey:sM},myAccount:{getUserProfile:sM,updateUserProfile:sM,getFactors:sM,getAuthenticationMethods:sM,getAuthenticationMethod:sM,updateAuthenticationMethod:sM,deleteAuthenticationMethod:sM,enrollmentChallenge:sM,enrollmentVerify:sM},anonymous:{createSession:sM,getTokenSilently:sM,logout:sM,hasSession:sM,getClaims:sM,mintTransferToken:sM}}),sz=(0,e_.createContext)(sL),sK=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=n}function n(t,r){var i=e.call(this,null!=r?r:t)||this;return i.error=t,i.error_description=r,Object.setPrototypeOf(i,n.prototype),i}return ek(n,e),n.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t),n}(Error),sJ=/[?&](?:connect_)?code=[^&]+/,sD=/[?&]state=[^&]+/,sH=/[?&]error=[^&]+/,sZ=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 sK(t.error,t.error_description):new sK(t.error):Error(e)}},sF=sZ("Login failed"),sG=sZ("Get access token failed"),sV=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)?t:{},e.authorizationParams.redirect_uri=e.redirectUri,delete e.redirectUri),(null==(n=null==e?void 0:e.authorizationParams)?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)},sX=function(e,t){switch(t.type){case"LOGIN_POPUP_STARTED":return eS(eS({},e),{isLoading:!0});case"LOGIN_POPUP_COMPLETE":case"INITIALISED":return eS(eS({},e),{isAuthenticated:!!t.user,user:t.user,isLoading:!1,error:void 0});case"HANDLE_REDIRECT_COMPLETE":case"GET_ACCESS_TOKEN_COMPLETE":case"SYNC_USER":if(e.user===t.user)return e;return eS(eS({},e),{isAuthenticated:!!t.user,user:t.user});case"LOGOUT":return eS(eS({},e),{isAuthenticated:!1,user:void 0});case"ERROR":return eS(eS({},e),{isLoading:!1,error:t.error})}},sq=function(e){var t;window.history.replaceState({},document.title,null!=(t=e.returnTo)?t:window.location.pathname)},sY=function(){var e,t,n=new Promise(function(n,r){e=n,t=r});return n.catch(function(){}),{promise:n,resolve:e,reject:t}},sB=function(e){var t=e.children,n=e.skipRedirectCallback,r=e.onRedirectCallback,i=void 0===r?sq:r,o=e.context,a=void 0===o?sz:o,s=e.client,c=eT(e,["children","skipRedirectCallback","onRedirectCallback","context","client"]);s&&(c.domain||c.clientId)&&console.warn("Auth0Provider: the `client` prop takes precedence over `domain`/`clientId` and other configuration options. Remove `domain`, `clientId`, and any other Auth0Client configuration props when using the `client` prop.");var l=(0,e_.useState)(function(){return null!=s?s:new sN((sV(c),eS(eS({},c),{auth0Client:{name:"auth0-react",version:"2.30.0"}})))})[0],u=(0,e_.useReducer)(sX,sU),h=u[0],d=u[1],p=(0,e_.useState)(sY),f=p[0],m=p[1],y=(0,e_.useState)(!1),g=y[0],w=y[1],v=(0,e_.useRef)(!1),b=(0,e_.useRef)(!1),_=(0,e_.useCallback)(function(e){return d({type:"ERROR",error:e}),e},[]),k=(0,e_.useCallback)(function(e,t){return eC(void 0,void 0,void 0,function(){var r,o,a,s,c,u,h;return eP(this,function(p){switch(p.label){case 0:var f;if(p.trys.push([0,7,,8]),r=void 0,!(t&&(void 0===f&&(f=window.location.search),(sJ.test(f)||sH.test(f))&&sD.test(f))&&!n))return[3,3];return[4,l.handleRedirectCallback()];case 1:return s=void 0===(a=(o=p.sent()).appState)?{}:a,c=o.response_type,u=eT(o,["appState","response_type"]),[4,l.getUser()];case 2:return r=p.sent(),s.response_type=c,c===t7.ConnectCode&&(s.connectedAccount=u),i(s,r),[3,6];case 3:return[4,l.checkSession()];case 4:return p.sent(),[4,l.getUser()];case 5:r=p.sent(),p.label=6;case 6:return d({type:"INITIALISED",user:r}),e.resolve(),[3,8];case 7:return _(h=sF(p.sent())),w(!0),e.reject(h),[3,8];case 8:return[2]}})})},[l,i,n,_]);(0,e_.useEffect)(function(){b.current||(b.current=!0,k(f,!0))},[k,f]),(0,e_.useEffect)(function(){if(g&&!v.current&&h.isAuthenticated){v.current=!0;var e=sY();m(e),k(e,!1)}},[g,h.isAuthenticated,k]);var S=(0,e_.useCallback)(function(e){return sV(e),l.loginWithRedirect(e)},[l]),T=(0,e_.useCallback)(function(e,t){return eC(void 0,void 0,void 0,function(){return eP(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,l.loginWithPopup(e,t)];case 2:return n.sent(),[3,4];case 3:return _(sF(n.sent())),[2];case 4:return[4,l.getUser()];case 5:return d({type:"LOGIN_POPUP_COMPLETE",user:n.sent()}),[2]}})})},[l,_]),C=(0,e_.useCallback)(function(){for(var e=[],t=0;t