!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.AuthenticationService=void 0;const s=i(r(1));var a,c;!function(e){e.Success="success",e.RequiresRedirect="requiresRedirect"}(a||(a={})),function(e){e.Redirect="redirect",e.Success="success",e.Failure="failure",e.OperationCompleted="operationCompleted"}(c||(c={}));class u{constructor(e){var t,r;this._settings=e,0==(null===(r=null===(t=this._settings.auth)||void 0===t?void 0:t.knownAuthorities)||void 0===r?void 0:r.length)&&(this._settings.auth.knownAuthorities=[new URL(this._settings.auth.authority).hostname]),this._msalApplication=new s.PublicClientApplication(this._settings)}getAccount(){if(this._account)return this._account;const e=this._msalApplication.getAllAccounts();return e&&e.length?e[0]:null}async getUser(){var e;const t=this.getAccount();if(!t)return;const r=[];this._settings.defaultAccessTokenScopes&&this._settings.defaultAccessTokenScopes.length>0&&r.push(...this._settings.defaultAccessTokenScopes),this._settings.additionalScopesToConsent&&this._settings.additionalScopesToConsent.length>0&&r.push(...this._settings.additionalScopesToConsent),this._requestedScopes&&this._requestedScopes.length>0&&r.push(...this._requestedScopes);const n={redirectUri:null===(e=this._settings.auth)||void 0===e?void 0:e.redirectUri,account:t,scopes:r};try{return(await this._msalApplication.acquireTokenSilent(n)).idTokenClaims}catch(e){await this.signInCore(n)}}async getAccessToken(e){try{const t=await this.getTokenCore(null==e?void 0:e.scopes);return{status:a.Success,token:t}}catch(e){return{status:a.RequiresRedirect}}}async getTokenCore(e){var t;const r=this.getAccount();if(!r)return;this._requestedScopes=e;const n={redirectUri:null===(t=this._settings.auth)||void 0===t?void 0:t.redirectUri,account:r,scopes:e||this._settings.defaultAccessTokenScopes},o=await this._msalApplication.acquireTokenSilent(n);return{value:o.accessToken,grantedScopes:o.scopes,expires:o.expiresOn}}async signIn(e){var t,r,n;try{this.purgeState();const o={redirectUri:null===(t=this._settings.auth)||void 0===t?void 0:t.redirectUri,state:await this.saveState(e),scopes:[]};this._settings.defaultAccessTokenScopes&&this._settings.defaultAccessTokenScopes.length>0&&(o.scopes=this._settings.defaultAccessTokenScopes),this._settings.additionalScopesToConsent&&this._settings.additionalScopesToConsent.length>0&&(o.extraScopesToConsent=this._settings.additionalScopesToConsent);const i=await this.signInCore(o);if(!i)return this.redirect();if(this.isMsalError(i))return this.error(i.errorMessage);try{if((null===(r=this._settings.defaultAccessTokenScopes)||void 0===r?void 0:r.length)>0){const e=this.getAccount();if(!e)return this.error("No account to get tokens for.");const t={redirectUri:o.redirectUri,account:e,scopes:(null===(n=null==o?void 0:o.scopes)||void 0===n?void 0:n.concat(o.extraScopesToConsent||[]))||[]};await this._msalApplication.acquireTokenSilent(t)}}catch(e){return this.error(e.errorMessage)}return this.success(e)}catch(e){return this.error(e.message)}}async signInCore(e){return"redirect"===this._settings.loginMode.toLowerCase()?this.signInWithRedirect(e):this.signInWithPopup(e)}async signInWithRedirect(e){try{return await this._msalApplication.loginRedirect(e)}catch(e){return e}}async signInWithPopup(e){try{return await this._msalApplication.loginPopup(e)}catch(t){if(!this.isMsalError(t)||t.errorCode===s.BrowserAuthErrorMessage.userCancelledError.code)return t;this.signInWithRedirect(e)}}async completeSignIn(){var e=await this._redirectCallback;return e||this.operationCompleted()}async signOut(e){this.purgeState();const t=await this.saveState(e);return sessionStorage.setItem(d._infrastructureKey+".LogoutState",t),this._msalApplication.logout(),this.redirect()}async completeSignOut(e){const t=sessionStorage.getItem(d._infrastructureKey+".LogoutState"),r=new URL(e);r.search="?state="+t;const n=await this.retrieveState(r.href,null,!0);return sessionStorage.removeItem(d._infrastructureKey+".LogoutState"),n?this.success(n):this.operationCompleted()}async saveState(e){const t=await new Promise((e,t)=>{const r=new FileReader;r.onloadend=t=>{var r;return e((null===(r=null==t?void 0:t.target)||void 0===r?void 0:r.result).split(",")[1].replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,""))},r.onerror=e=>{var r,n;return t(null===(n=null===(r=e.target)||void 0===r?void 0:r.error)||void 0===n?void 0:n.message)};const n=window.crypto.getRandomValues(new Uint8Array(32));r.readAsDataURL(new Blob([n]))});return sessionStorage.setItem(`${d._infrastructureKey}.AuthorizeService.${t}`,JSON.stringify(e)),t}retrieveState(e,t=null,r=!1){let n;if(e){const t=new URL(e);n=t.searchParams&&t.searchParams.getAll("state")}const o=t||n;if(!o)return;const i=`${d._infrastructureKey}.AuthorizeService.${o}`,s=sessionStorage.getItem(i);if(s){sessionStorage.removeItem(i);return JSON.parse(s)}}purgeState(){for(let e=0;ethis.handleResult(e)).catch(e=>this.isMsalError(e)?this.error(e.errorMessage):this.error(e))}handleResult(e){return e?(this._account=e.account,this.success(this.retrieveState(null,e.state))):this.operationCompleted()}getAccountState(e){if(e){const t=e.indexOf("|");if(t>-1&&t+10&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s} /*! @azure/msal-common v2.0.0 2020-12-07 */ /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function d(e,t){function r(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var h=function(){return(h=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=t.length&&e.lastIndexOf(t)===e.length-t.length},e.queryStringToObject=function(e){var t,r=/\+/g,n=/([^&=]+)=([^&]*)/g,o=function(e){return decodeURIComponent(decodeURIComponent(e.replace(r," ")))},i={};for(t=n.exec(e);t;)i[o(t[1])]=o(t[2]),t=n.exec(e);return i},e.trimArrayEntries=function(e){return e.map((function(e){return e.trim()}))},e.removeEmptyStringsFromArray=function(t){return t.filter((function(t){return!e.isEmpty(t)}))},e.jsonParseHelper=function(e){try{return JSON.parse(e)}catch(e){return null}},e.matchPattern=function(e,t){return new RegExp(e.replace(/\*/g,"[^ ]*")).test(t)},e}();!function(e){e[e.Error=0]="Error",e[e.Warning=1]="Warning",e[e.Info=2]="Info",e[e.Verbose=3]="Verbose"}(te||(te={}));var je,Ge=function(){function e(e,t,r){this.level=te.Info;this.localCallback=e.loggerCallback||function(){},this.piiLoggingEnabled=e.piiLoggingEnabled||!1,this.level=e.logLevel||te.Info,this.packageName=t||q,this.packageVersion=r||q}return e.prototype.clone=function(t,r){return new e({loggerCallback:this.localCallback,piiLoggingEnabled:this.piiLoggingEnabled,logLevel:this.level},t,r)},e.prototype.logMessage=function(e,t){if(!(t.logLevel>this.level||!this.piiLoggingEnabled&&t.containsPii)){var r=(new Date).toUTCString(),n=(Fe.isEmpty(this.correlationId)?"["+r+"] : ":"["+r+"] : ["+this.correlationId+"]")+" : "+this.packageName+"@"+this.packageVersion+" : "+te[t.logLevel]+" - "+e;this.executeCallback(t.logLevel,n,t.containsPii||!1)}},e.prototype.executeCallback=function(e,t,r){this.localCallback&&this.localCallback(e,t,r)},e.prototype.error=function(e,t){this.logMessage(e,{logLevel:te.Error,containsPii:!1,correlationId:t||""})},e.prototype.errorPii=function(e,t){this.logMessage(e,{logLevel:te.Error,containsPii:!0,correlationId:t||""})},e.prototype.warning=function(e,t){this.logMessage(e,{logLevel:te.Warning,containsPii:!1,correlationId:t||""})},e.prototype.warningPii=function(e,t){this.logMessage(e,{logLevel:te.Warning,containsPii:!0,correlationId:t||""})},e.prototype.info=function(e,t){this.logMessage(e,{logLevel:te.Info,containsPii:!1,correlationId:t||""})},e.prototype.infoPii=function(e,t){this.logMessage(e,{logLevel:te.Info,containsPii:!0,correlationId:t||""})},e.prototype.verbose=function(e,t){this.logMessage(e,{logLevel:te.Verbose,containsPii:!1,correlationId:t||""})},e.prototype.verbosePii=function(e,t){this.logMessage(e,{logLevel:te.Verbose,containsPii:!0,correlationId:t||""})},e.prototype.isPiiLoggingEnabled=function(){return this.piiLoggingEnabled||!1},e}(),Be=function(){function e(){}return e.prototype.generateAccountId=function(){return e.generateAccountIdForCacheKey(this.homeAccountId,this.environment)},e.prototype.generateCredentialId=function(){return e.generateCredentialIdForCacheKey(this.credentialType,this.clientId,this.realm,this.familyId)},e.prototype.generateTarget=function(){return e.generateTargetForCacheKey(this.target)},e.prototype.generateCredentialKey=function(){return e.generateCredentialCacheKey(this.homeAccountId,this.environment,this.credentialType,this.clientId,this.realm,this.target,this.familyId)},e.prototype.generateType=function(){switch(this.credentialType){case G.ID_TOKEN:return z.ID_TOKEN;case G.ACCESS_TOKEN:return z.ACCESS_TOKEN;case G.REFRESH_TOKEN:return z.REFRESH_TOKEN;default:throw xe.createUnexpectedCredentialTypeError()}},e.getCredentialType=function(e){return-1!==e.indexOf(G.ACCESS_TOKEN.toLowerCase())?G.ACCESS_TOKEN:-1!==e.indexOf(G.ID_TOKEN.toLowerCase())?G.ID_TOKEN:-1!==e.indexOf(G.REFRESH_TOKEN.toLowerCase())?G.REFRESH_TOKEN:M},e.generateCredentialCacheKey=function(e,t,r,n,o,i,s){return[this.generateAccountIdForCacheKey(e,t),this.generateCredentialIdForCacheKey(r,n,o,s),this.generateTargetForCacheKey(i)].join(j.CACHE_KEY_SEPARATOR).toLowerCase()},e.generateAccountIdForCacheKey=function(e,t){return[e,t].join(j.CACHE_KEY_SEPARATOR).toLowerCase()},e.generateCredentialIdForCacheKey=function(e,t,r,n){return[e,e===G.REFRESH_TOKEN&&n||t,r||""].join(j.CACHE_KEY_SEPARATOR).toLowerCase()},e.generateTargetForCacheKey=function(e){return(e||"").toLowerCase()},e}(),ze={code:"redirect_uri_empty",desc:"A redirect URI is required for all calls, and none has been set."},We={code:"post_logout_uri_empty",desc:"A post logout redirect has not been set."},Je={code:"claims_request_parsing_error",desc:"Could not parse the given claims request object."},Qe={code:"authority_uri_insecure",desc:"Authority URIs must use https. Please see here for valid authority configuration options: https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-js-initializing-client-applications#configuration-options"},Ve={code:"url_parse_error",desc:"URL could not be parsed into appropriate segments."},Ye={code:"empty_url_error",desc:"URL was empty or null."},Xe={code:"empty_input_scopes_error",desc:"Scopes cannot be passed as null, undefined or empty array because they are required to obtain an access token."},Ze={code:"nonarray_input_scopes_error",desc:"Scopes cannot be passed as non-array."},$e={code:"clientid_input_scopes_error",desc:"Client ID can only be provided as a single scope."},et={code:"invalid_prompt_value",desc:"Supported prompt values are 'login', 'select_account', 'consent' and 'none'. Please see here for valid configuration options: https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-js-initializing-client-applications#configuration-options"},tt={code:"invalid_claims",desc:"Given claims parameter must be a stringified JSON object."},rt={code:"token_request_empty",desc:"Token request was empty and not found in cache."},nt={code:"logout_request_empty",desc:"The logout request was null or undefined."},ot={code:"invalid_code_challenge_method",desc:'code_challenge_method passed is invalid. Valid values are "plain" and "S256".'},it={code:"pkce_params_missing",desc:"Both params: code_challenge and code_challenge_method are to be passed if to be sent in the request"},st={code:"invalid_known_authorities",desc:"knownAuthorities and cloudDiscoveryMetadata cannot both be provided. Please provide cloudDiscoveryMetadata object for AAD, knownAuthorities otherwise."},at={code:"invalid_cloud_discovery_metadata",desc:"Invalid cloudDiscoveryMetadata provided. Must be a JSON object containing tenant_discovery_endpoint and metadata fields"},ct={code:"untrusted_authority",desc:"The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter."},ut={code:"resourceRequest_parameters_required",desc:"resourceRequestMethod and resourceRequestUri are required"},dt=function(e){function t(r,n){var o=e.call(this,r,n)||this;return o.name="ClientConfigurationError",Object.setPrototypeOf(o,t.prototype),o}return d(t,e),t.createRedirectUriEmptyError=function(){return new t(ze.code,ze.desc)},t.createPostLogoutRedirectUriEmptyError=function(){return new t(We.code,We.desc)},t.createClaimsRequestParsingError=function(e){return new t(Je.code,Je.desc+" Given value: "+e)},t.createInsecureAuthorityUriError=function(e){return new t(Qe.code,Qe.desc+" Given URI: "+e)},t.createUrlParseError=function(e){return new t(Ve.code,Ve.desc+" Given Error: "+e)},t.createUrlEmptyError=function(){return new t(Ye.code,Ye.desc)},t.createScopesNonArrayError=function(e){return new t(Ze.code,Ze.desc+" Given Scopes: "+e)},t.createEmptyScopesArrayError=function(e){return new t(Xe.code,Xe.desc+" Given Scopes: "+e)},t.createClientIdSingleScopeError=function(e){return new t($e.code,$e.desc+" Given Scopes: "+e)},t.createInvalidPromptError=function(e){return new t(et.code,et.desc+" Given value: "+e)},t.createInvalidClaimsRequestError=function(){return new t(tt.code,tt.desc)},t.createEmptyLogoutRequestError=function(){return new t(nt.code,nt.desc)},t.createEmptyTokenRequestError=function(){return new t(rt.code,rt.desc)},t.createInvalidCodeChallengeMethodError=function(){return new t(ot.code,ot.desc)},t.createInvalidCodeChallengeParamsError=function(){return new t(it.code,it.desc)},t.createKnownAuthoritiesCloudDiscoveryMetadataError=function(){return new t(st.code,st.desc)},t.createInvalidCloudDiscoveryMetadataError=function(){return new t(at.code,at.desc)},t.createUntrustedAuthorityError=function(){return new t(ct.code,ct.desc)},t.createResourceRequestParametersRequiredError=function(){return new t(ut.code,ut.desc)},t}(xe),ht=function(){function e(e){var t=this,r=e?Fe.trimArrayEntries(f(e)):[],n=r?Fe.removeEmptyStringsFromArray(r):[];this.validateInputScopes(n),this.scopes=new Set,n.forEach((function(e){return t.scopes.add(e)}))}return e.fromString=function(t){return new e((t=t||"").split(" "))},e.prototype.validateInputScopes=function(e){if(!e||e.length<1)throw dt.createEmptyScopesArrayError(e)},e.prototype.containsScope=function(t){var r=new e(this.printScopesLowerCase().split(" "));return!Fe.isEmpty(t)&&r.scopes.has(t.toLowerCase())},e.prototype.containsScopeSet=function(e){var t=this;return!(!e||e.scopes.size<=0)&&(this.scopes.size>=e.scopes.size&&e.asArray().every((function(e){return t.containsScope(e)})))},e.prototype.containsOnlyDefaultScopes=function(){var e=0;return this.containsScope(R)&&(e+=1),this.containsScope(b)&&(e+=1),this.containsScope(O)&&(e+=1),this.scopes.size===e},e.prototype.appendScope=function(e){Fe.isEmpty(e)||this.scopes.add(e.trim())},e.prototype.appendScopes=function(e){var t=this;try{e.forEach((function(e){return t.appendScope(e)}))}catch(e){throw xe.createAppendScopeSetError(e)}},e.prototype.removeScope=function(e){if(Fe.isEmpty(e))throw xe.createRemoveEmptyScopeFromSetError(e);this.scopes.delete(e.trim())},e.prototype.removeDefaultScopes=function(){this.scopes.delete(O),this.scopes.delete(R),this.scopes.delete(b)},e.prototype.unionScopeSets=function(e){if(!e)throw xe.createEmptyInputScopeSetError(e);var t=new Set;return e.scopes.forEach((function(e){return t.add(e.toLowerCase())})),this.scopes.forEach((function(e){return t.add(e.toLowerCase())})),t},e.prototype.intersectingScopeSets=function(e){if(!e)throw xe.createEmptyInputScopeSetError(e);var t=this.unionScopeSets(e);e.containsOnlyDefaultScopes()||e.removeDefaultScopes();var r=e.getScopeCount(),n=this.getScopeCount();return t.size0})),r.PathSegments=n,!Fe.isEmpty(r.QueryString)&&r.QueryString.endsWith("/")&&(r.QueryString=r.QueryString.substring(0,r.QueryString.length-1)),r},e.getDomainFromUrl=function(e){var t=RegExp("^([^:/?#]+://)?([^/?#]*)"),r=e.match(t);if(!r)throw dt.createUrlParseError("Given url string: "+e);return r[2]},e.getAbsoluteUrl=function(t,r){if(t[0]===L){var n=new e(r).getUrlComponents();return n.Protocol+"//"+n.HostNameAndPort+t}return t},e.parseHash=function(e){var t=e.indexOf("#"),r=e.indexOf("#/");return r>-1?e.substring(r+2):t>-1?e.substring(t+1):""},e.constructAuthorityUriFromObject=function(t){return new e(t.Protocol+"//"+t.HostNameAndPort+"/"+t.PathSegments.join("/"))},e.getDeserializedHash=function(t){if(Fe.isEmpty(t))return{};var r=e.parseHash(t),n=Fe.queryStringToObject(Fe.isEmpty(r)?t:r);if(!n)throw xe.createHashNotDeserializedError(JSON.stringify(n));return n},e.hashContainsKnownProperties=function(t){if(Fe.isEmpty(t))return!1;var r=e.getDeserializedHash(t);return!!(r.code||r.error_description||r.error||r.state)},e}(),ft=function(){function e(){}return e.setTrustedAuthoritiesFromConfig=function(e,t){if(!this.getTrustedHostList().length){if(e.length>0&&!Fe.isEmpty(t))throw dt.createKnownAuthoritiesCloudDiscoveryMetadataError();this.createCloudDiscoveryMetadataFromKnownAuthorities(e);try{if(t){var r=JSON.parse(t);this.saveCloudDiscoveryMetadata(r.metadata)}}catch(e){throw dt.createInvalidCloudDiscoveryMetadataError()}}},e.setTrustedAuthoritiesFromNetwork=function(e,t){return l(this,void 0,void 0,(function(){var r,n,o,i;return p(this,(function(s){switch(s.label){case 0:r=""+A+e.urlString+"oauth2/v2.0/authorize",s.label=1;case 1:return s.trys.push([1,3,,4]),[4,t.sendGetRequestAsync(r)];case 2:return n=s.sent(),o=n.body.metadata,this.saveCloudDiscoveryMetadata(o),[3,4];case 3:return s.sent(),[2];case 4:return i=e.getUrlComponents().HostNameAndPort,this.getTrustedHostList().length>0&&!this.IsInTrustedHostList(i)&&this.createCloudDiscoveryMetadataFromKnownAuthorities([i]),[2]}}))}))},e.saveCloudDiscoveryMetadata=function(t){t.forEach((function(t){t.aliases.forEach((function(r){e.TrustedHostList[r.toLowerCase()]=t}))}))},e.createCloudDiscoveryMetadataFromKnownAuthorities=function(e){var t=this;e.forEach((function(e){var r=pt.getDomainFromUrl(e).toLowerCase();t.TrustedHostList[r]={preferred_cache:r,preferred_network:r,aliases:[r]}}))},e.getTrustedHostList=function(){return Object.keys(this.TrustedHostList)},e.getCloudDiscoveryMetadata=function(e){return this.TrustedHostList[e.toLowerCase()]||null},e.IsInTrustedHostList=function(e){return Object.keys(this.TrustedHostList).indexOf(e.toLowerCase())>-1},e.TrustedHostList={},e}();!function(e){e.AAD="AAD",e.OIDC="OIDC"}(lt||(lt={}));var gt=function(){function e(e,t,r){this.canonicalAuthority=e,this._canonicalAuthority.validateAsUri(),this.networkInterface=t,this.authorityProtocolMode=r}return Object.defineProperty(e.prototype,"authorityType",{get:function(){var e=this.canonicalAuthorityUrlComponents.PathSegments;return e.length&&e[0].toLowerCase()===I?je.Adfs:je.Default},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocolMode",{get:function(){return this.authorityProtocolMode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canonicalAuthority",{get:function(){return this._canonicalAuthority.urlString},set:function(e){this._canonicalAuthority=new pt(e),this._canonicalAuthority.validateAsUri(),this._canonicalAuthorityUrlComponents=null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canonicalAuthorityUrlComponents",{get:function(){return this._canonicalAuthorityUrlComponents||(this._canonicalAuthorityUrlComponents=this._canonicalAuthority.getUrlComponents()),this._canonicalAuthorityUrlComponents},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tenant",{get:function(){return this.canonicalAuthorityUrlComponents.PathSegments[0]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"authorizationEndpoint",{get:function(){if(this.discoveryComplete())return this.replaceTenant(this.tenantDiscoveryResponse.authorization_endpoint);throw xe.createEndpointDiscoveryIncompleteError("Discovery incomplete.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tokenEndpoint",{get:function(){if(this.discoveryComplete())return this.replaceTenant(this.tenantDiscoveryResponse.token_endpoint);throw xe.createEndpointDiscoveryIncompleteError("Discovery incomplete.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"deviceCodeEndpoint",{get:function(){if(this.discoveryComplete())return this.tenantDiscoveryResponse.token_endpoint.replace("/token","/devicecode");throw xe.createEndpointDiscoveryIncompleteError("Discovery incomplete.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"endSessionEndpoint",{get:function(){if(this.discoveryComplete())return this.replaceTenant(this.tenantDiscoveryResponse.end_session_endpoint);throw xe.createEndpointDiscoveryIncompleteError("Discovery incomplete.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selfSignedJwtAudience",{get:function(){if(this.discoveryComplete())return this.replaceTenant(this.tenantDiscoveryResponse.issuer);throw xe.createEndpointDiscoveryIncompleteError("Discovery incomplete.")},enumerable:!0,configurable:!0}),e.prototype.replaceTenant=function(e){return e.replace(/{tenant}|{tenantid}/g,this.tenant)},Object.defineProperty(e.prototype,"defaultOpenIdConfigurationEndpoint",{get:function(){return this.authorityType===je.Adfs||this.protocolMode===lt.OIDC?this.canonicalAuthority+".well-known/openid-configuration":this.canonicalAuthority+"v2.0/.well-known/openid-configuration"},enumerable:!0,configurable:!0}),e.prototype.discoveryComplete=function(){return!!this.tenantDiscoveryResponse},e.prototype.discoverEndpoints=function(e){return l(this,void 0,void 0,(function(){return p(this,(function(t){return[2,this.networkInterface.sendGetRequestAsync(e)]}))}))},e.prototype.validateAndSetPreferredNetwork=function(){return l(this,void 0,void 0,(function(){var e,t;return p(this,(function(r){switch(r.label){case 0:return e=this.canonicalAuthorityUrlComponents.HostNameAndPort,0!==ft.getTrustedHostList().length?[3,2]:[4,ft.setTrustedAuthoritiesFromNetwork(this._canonicalAuthority,this.networkInterface)];case 1:r.sent(),r.label=2;case 2:if(!ft.IsInTrustedHostList(e))throw dt.createUntrustedAuthorityError();return t=ft.getCloudDiscoveryMetadata(e).preferred_network,e!==t&&(this.canonicalAuthority=this.canonicalAuthority.replace(e,t)),[2]}}))}))},e.prototype.resolveEndpointsAsync=function(){return l(this,void 0,void 0,(function(){var e,t;return p(this,(function(r){switch(r.label){case 0:return[4,this.validateAndSetPreferredNetwork()];case 1:return r.sent(),e=this.defaultOpenIdConfigurationEndpoint,[4,this.discoverEndpoints(e)];case 2:return t=r.sent(),this.tenantDiscoveryResponse=t.body,[2]}}))}))},e.prototype.isAuthorityAlias=function(e){return e===this.canonicalAuthorityUrlComponents.HostNameAndPort||-1!==ft.getCloudDiscoveryMetadata(this.canonicalAuthorityUrlComponents.HostNameAndPort).aliases.indexOf(e)},e.generateEnvironmentFromAuthority=function(e){var t=e.canonicalAuthorityUrlComponents.HostNameAndPort;return ft.getCloudDiscoveryMetadata(t)?ft.getCloudDiscoveryMetadata(t).preferred_cache:""},e}();function yt(e,t){if(Fe.isEmpty(e))throw xe.createClientInfoEmptyError();try{var r=t.base64Decode(e);return JSON.parse(r)}catch(e){throw xe.createClientInfoDecodingError(e)}}var mt=function(){function e(){}return e.prototype.generateAccountId=function(){return[this.homeAccountId,this.environment].join(j.CACHE_KEY_SEPARATOR).toLowerCase()},e.prototype.generateAccountKey=function(){return e.generateAccountCacheKey({homeAccountId:this.homeAccountId,environment:this.environment,tenantId:this.realm,username:this.username,localAccountId:this.localAccountId})},e.prototype.generateType=function(){switch(this.authorityType){case F.ADFS_ACCOUNT_TYPE:return z.ADFS;case F.MSAV1_ACCOUNT_TYPE:return z.MSA;case F.MSSTS_ACCOUNT_TYPE:return z.MSSTS;case F.GENERIC_ACCOUNT_TYPE:return z.GENERIC;default:throw xe.createUnexpectedAccountTypeError()}},e.prototype.getAccountInfo=function(){return{homeAccountId:this.homeAccountId,environment:this.environment,tenantId:this.realm,username:this.username,localAccountId:this.localAccountId,name:this.name,idTokenClaims:this.idTokenClaims}},e.generateAccountCacheKey=function(e){return[e.homeAccountId,e.environment||"",e.tenantId||""].join(j.CACHE_KEY_SEPARATOR).toLowerCase()},e.createAccount=function(t,r,n,o,i,s,a){var c,u,d,h,l,p,f=new e;f.authorityType=F.MSSTS_ACCOUNT_TYPE,f.clientInfo=t,f.homeAccountId=r;var g=gt.generateEnvironmentFromAuthority(n);if(Fe.isEmpty(g))throw xe.createInvalidCacheEnvironmentError();return f.environment=g,f.realm=(null===(c=null==o?void 0:o.claims)||void 0===c?void 0:c.tid)||"",f.oboAssertion=i,o&&(f.idTokenClaims=o.claims,f.localAccountId=(null===(u=null==o?void 0:o.claims)||void 0===u?void 0:u.oid)||(null===(d=null==o?void 0:o.claims)||void 0===d?void 0:d.sub)||"",f.username=(null===(h=null==o?void 0:o.claims)||void 0===h?void 0:h.preferred_username)||((null===(l=null==o?void 0:o.claims)||void 0===l?void 0:l.emails)?o.claims.emails[0]:""),f.name=null===(p=null==o?void 0:o.claims)||void 0===p?void 0:p.name),f.cloudGraphHostName=s,f.msGraphHost=a,f},e.createGenericAccount=function(t,r,n,o,i,s){var a,c,u,d,h=new e;h.authorityType=t.authorityType===je.Adfs?F.ADFS_ACCOUNT_TYPE:F.GENERIC_ACCOUNT_TYPE,h.homeAccountId=r,h.realm="",h.oboAssertion=o;var l=gt.generateEnvironmentFromAuthority(t);if(Fe.isEmpty(l))throw xe.createInvalidCacheEnvironmentError();return n&&(h.localAccountId=(null===(a=null==n?void 0:n.claims)||void 0===a?void 0:a.oid)||(null===(c=null==n?void 0:n.claims)||void 0===c?void 0:c.sub)||"",h.username=(null===(u=null==n?void 0:n.claims)||void 0===u?void 0:u.upn)||"",h.name=(null===(d=null==n?void 0:n.claims)||void 0===d?void 0:d.name)||"",h.idTokenClaims=null==n?void 0:n.claims),h.environment=l,h.cloudGraphHostName=i,h.msGraphHost=s,h},e.generateHomeAccountId=function(e,t,r,n,o){var i,s=(null===(i=null==o?void 0:o.claims)||void 0===i?void 0:i.sub)?o.claims.sub:q;if(t===je.Adfs)return s;if(e){var a=yt(e,n);if(!Fe.isEmpty(a.uid)&&!Fe.isEmpty(a.utid))return""+a.uid+j.CLIENT_INFO_SEPARATOR+a.utid}return r.verbose("No client info in response"),s},e.isAccountEntity=function(e){return!!e&&(e.hasOwnProperty("homeAccountId")&&e.hasOwnProperty("environment")&&e.hasOwnProperty("realm")&&e.hasOwnProperty("localAccountId")&&e.hasOwnProperty("username")&&e.hasOwnProperty("authorityType"))},e}(),vt=function(){function e(t,r){if(Fe.isEmpty(t))throw xe.createTokenNullOrEmptyError(t);this.rawToken=t,this.claims=e.extractTokenClaims(t,r)}return e.extractTokenClaims=function(e,t){var r=Fe.decodeAuthToken(e);try{var n=r.JWSPayload,o=t.base64Decode(n);return JSON.parse(o)}catch(e){throw xe.createTokenParsingError(e)}},e}(),Et=function(){function e(e,t){this.clientId=e,this.cryptoImpl=t}return e.prototype.getAllAccounts=function(){var t=this,r=this.getAccountsFilteredBy(),n=Object.keys(r).map((function(e){return r[e]}));return n.length<1?[]:n.map((function(r){var n=e.toObject(new mt,r).getAccountInfo(),o=t.readIdTokenFromCache(t.clientId,n);return o&&!n.idTokenClaims&&(n.idTokenClaims=new vt(o.secret,t.cryptoImpl).claims),n}))},e.prototype.saveCacheRecord=function(e){if(!e)throw xe.createNullOrUndefinedCacheRecord();e.account&&this.setAccount(e.account),e.idToken&&this.setIdTokenCredential(e.idToken),e.accessToken&&this.saveAccessToken(e.accessToken),e.refreshToken&&this.setRefreshTokenCredential(e.refreshToken),e.appMetadata&&this.setAppMetadata(e.appMetadata)},e.prototype.saveAccessToken=function(e){var t=this,r=this.getCredentialsFilteredBy({clientId:e.clientId,credentialType:G.ACCESS_TOKEN,environment:e.environment,homeAccountId:e.homeAccountId,realm:e.realm}),n=ht.fromString(e.target),o=Object.keys(r.accessTokens).map((function(e){return r.accessTokens[e]}));o&&o.forEach((function(e){ht.fromString(e.target).intersectingScopeSets(n)&&t.removeCredential(e)})),this.setAccessTokenCredential(e)},e.prototype.getAccountsFilteredBy=function(e){return this.getAccountsFilteredByInternal(e?e.homeAccountId:"",e?e.environment:"",e?e.realm:"")},e.prototype.getAccountsFilteredByInternal=function(e,t,r){var n=this,o=this.getKeys(),i={};return o.forEach((function(o){var s=n.getAccount(o);s&&(e&&!n.matchHomeAccountId(s,e)||t&&!n.matchEnvironment(s,t)||r&&!n.matchRealm(s,r)||(i[o]=s))})),i},e.prototype.getCredentialsFilteredBy=function(e){return this.getCredentialsFilteredByInternal(e.homeAccountId,e.environment,e.credentialType,e.clientId,e.familyId,e.realm,e.target,e.oboAssertion)},e.prototype.getCredentialsFilteredByInternal=function(e,t,r,n,o,i,s,a){var c=this,u=this.getKeys(),d={idTokens:{},accessTokens:{},refreshTokens:{}};return u.forEach((function(u){var h=Be.getCredentialType(u);if(h!==M){var l=c.getSpecificCredential(u,h);if(l&&(!a||c.matchOboAssertion(l,a))&&(!e||c.matchHomeAccountId(l,e))&&(!t||c.matchEnvironment(l,t))&&(!i||c.matchRealm(l,i))&&(!r||c.matchCredentialType(l,r))&&(!n||c.matchClientId(l,n))&&(!o||c.matchFamilyId(l,o))&&(!s||c.matchTarget(l,s)))switch(h){case G.ID_TOKEN:d.idTokens[u]=l;break;case G.ACCESS_TOKEN:d.accessTokens[u]=l;break;case G.REFRESH_TOKEN:d.refreshTokens[u]=l}}})),d},e.prototype.getAppMetadataFilteredBy=function(e){return this.getAppMetadataFilteredByInternal(e.environment,e.clientId)},e.prototype.getAppMetadataFilteredByInternal=function(e,t){var r=this,n=this.getKeys(),o={};return n.forEach((function(n){if(r.isAppMetadata(n)){var i=r.getAppMetadata(n);i&&(e&&!r.matchEnvironment(i,e)||t&&!r.matchClientId(i,t)||(o[n]=i))}})),o},e.prototype.removeAllAccounts=function(){var e=this;return this.getKeys().forEach((function(t){e.getAccount(t)&&e.removeAccount(t)})),!0},e.prototype.removeAccount=function(e){var t=this.getAccount(e);if(!t)throw xe.createNoAccountFoundError();return this.removeAccountContext(t)&&this.removeItem(e,B.ACCOUNT)},e.prototype.removeAccountContext=function(e){var t=this,r=this.getKeys(),n=e.generateAccountId();return r.forEach((function(e){var r=Be.getCredentialType(e);if(r!==M){var o=t.getSpecificCredential(e,r);o&&n===o.generateAccountId()&&t.removeCredential(o)}})),!0},e.prototype.removeCredential=function(e){var t=e.generateCredentialKey();return this.removeItem(t,B.CREDENTIAL)},e.prototype.removeAppMetadata=function(){var e=this;return this.getKeys().forEach((function(t){e.isAppMetadata(t)&&e.removeItem(t,B.APP_METADATA)})),!0},e.prototype.readCacheRecord=function(e,t,r,n){var o=this.readAccountFromCache(e),i=this.readIdTokenFromCache(t,e),s=this.readAccessTokenFromCache(t,e,r),a=this.readRefreshTokenFromCache(t,e,!1),c=this.readAppMetadataFromCache(n,t);return o&&i&&(o.idTokenClaims=new vt(i.secret,this.cryptoImpl).claims),{account:o,idToken:i,accessToken:s,refreshToken:a,appMetadata:c}},e.prototype.readAccountFromCache=function(e){var t=mt.generateAccountCacheKey(e);return this.getAccount(t)},e.prototype.readIdTokenFromCache=function(e,t){var r={homeAccountId:t.homeAccountId,environment:t.environment,credentialType:G.ID_TOKEN,clientId:e,realm:t.tenantId},n=this.getCredentialsFilteredBy(r),o=Object.keys(n.idTokens).map((function(e){return n.idTokens[e]})),i=o.length;if(i<1)return null;if(i>1)throw xe.createMultipleMatchingTokensInCacheError();return o[0]},e.prototype.readAccessTokenFromCache=function(e,t,r){var n={homeAccountId:t.homeAccountId,environment:t.environment,credentialType:G.ACCESS_TOKEN,clientId:e,realm:t.tenantId,target:r.printScopesLowerCase()},o=this.getCredentialsFilteredBy(n),i=Object.keys(o.accessTokens).map((function(e){return o.accessTokens[e]})),s=i.length;if(s<1)return null;if(s>1)throw xe.createMultipleMatchingTokensInCacheError();return i[0]},e.prototype.readRefreshTokenFromCache=function(e,t,r){var n=r?"1":void 0,o={homeAccountId:t.homeAccountId,environment:t.environment,credentialType:G.REFRESH_TOKEN,clientId:e,familyId:n},i=this.getCredentialsFilteredBy(o),s=Object.keys(i.refreshTokens).map((function(e){return i.refreshTokens[e]}));return s.length<1?null:s[0]},e.prototype.readAppMetadataFromCache=function(e,t){var r={environment:e,clientId:t},n=this.getAppMetadataFilteredBy(r),o=Object.keys(n).map((function(e){return n[e]})),i=o.length;if(i<1)return null;if(i>1)throw xe.createMultipleMatchingAppMetadataInCacheError();return o[0]},e.prototype.isAppMetadataFOCI=function(e,t){var r=this.readAppMetadataFromCache(e,t);return!(!r||"1"!==r.familyId)},e.prototype.matchHomeAccountId=function(e,t){return!(!e.homeAccountId||t!==e.homeAccountId)},e.prototype.matchOboAssertion=function(e,t){return!(!e.oboAssertion||t!==e.oboAssertion)},e.prototype.matchEnvironment=function(e,t){var r=ft.getCloudDiscoveryMetadata(t);return!!(r&&r.aliases.indexOf(e.environment)>-1)},e.prototype.matchCredentialType=function(e,t){return e.credentialType&&t.toLowerCase()===e.credentialType.toLowerCase()},e.prototype.matchClientId=function(e,t){return!(!e.clientId||t!==e.clientId)},e.prototype.matchFamilyId=function(e,t){return!(!e.familyId||t!==e.familyId)},e.prototype.matchRealm=function(e,t){return!(!e.realm||t!==e.realm)},e.prototype.matchTarget=function(e,t){if(e.credentialType!==G.ACCESS_TOKEN||!e.target)return!1;var r=ht.fromString(e.target),n=ht.fromString(t);return n.containsOnlyDefaultScopes()||n.removeDefaultScopes(),r.containsScopeSet(n)},e.prototype.isAppMetadata=function(e){return-1!==e.indexOf("appmetadata")},e.prototype.getSpecificCredential=function(e,t){switch(t){case G.ID_TOKEN:return this.getIdTokenCredential(e);case G.ACCESS_TOKEN:return this.getAccessTokenCredential(e);case G.REFRESH_TOKEN:return this.getRefreshTokenCredential(e);default:return null}},e.toObject=function(e,t){for(var r in t)e[r]=t[r];return e},e}(),Ct=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return d(t,e),t.prototype.setAccount=function(){throw ne.createUnexpectedError("Storage interface - setAccount() has not been implemented for the cacheStorage interface.")},t.prototype.getAccount=function(){throw ne.createUnexpectedError("Storage interface - getAccount() has not been implemented for the cacheStorage interface.")},t.prototype.setIdTokenCredential=function(){throw ne.createUnexpectedError("Storage interface - setIdTokenCredential() has not been implemented for the cacheStorage interface.")},t.prototype.getIdTokenCredential=function(){throw ne.createUnexpectedError("Storage interface - getIdTokenCredential() has not been implemented for the cacheStorage interface.")},t.prototype.setAccessTokenCredential=function(){throw ne.createUnexpectedError("Storage interface - setAccessTokenCredential() has not been implemented for the cacheStorage interface.")},t.prototype.getAccessTokenCredential=function(){throw ne.createUnexpectedError("Storage interface - getAccessTokenCredential() has not been implemented for the cacheStorage interface.")},t.prototype.setRefreshTokenCredential=function(){throw ne.createUnexpectedError("Storage interface - setRefreshTokenCredential() has not been implemented for the cacheStorage interface.")},t.prototype.getRefreshTokenCredential=function(){throw ne.createUnexpectedError("Storage interface - getRefreshTokenCredential() has not been implemented for the cacheStorage interface.")},t.prototype.setAppMetadata=function(){throw ne.createUnexpectedError("Storage interface - setAppMetadata() has not been implemented for the cacheStorage interface.")},t.prototype.getAppMetadata=function(){throw ne.createUnexpectedError("Storage interface - getAppMetadata() has not been implemented for the cacheStorage interface.")},t.prototype.setServerTelemetry=function(){throw ne.createUnexpectedError("Storage interface - setServerTelemetry() has not been implemented for the cacheStorage interface.")},t.prototype.getServerTelemetry=function(){throw ne.createUnexpectedError("Storage interface - getServerTelemetry() has not been implemented for the cacheStorage interface.")},t.prototype.setThrottlingCache=function(){throw ne.createUnexpectedError("Storage interface - setThrottlingCache() has not been implemented for the cacheStorage interface.")},t.prototype.getThrottlingCache=function(){throw ne.createUnexpectedError("Storage interface - getThrottlingCache() has not been implemented for the cacheStorage interface.")},t.prototype.removeItem=function(){throw ne.createUnexpectedError("Storage interface - removeItem() has not been implemented for the cacheStorage interface.")},t.prototype.containsKey=function(){throw ne.createUnexpectedError("Storage interface - containsKey() has not been implemented for the cacheStorage interface.")},t.prototype.getKeys=function(){throw ne.createUnexpectedError("Storage interface - getKeys() has not been implemented for the cacheStorage interface.")},t.prototype.clear=function(){throw ne.createUnexpectedError("Storage interface - clear() has not been implemented for the cacheStorage interface.")},t}(Et),Tt={tokenRenewalOffsetSeconds:300},wt={loggerCallback:function(){},piiLoggingEnabled:!1,logLevel:te.Info},St={sendGetRequestAsync:function(){return l(this,void 0,void 0,(function(){return p(this,(function(e){throw"Network interface - sendGetRequestAsync() has not been implemented",ne.createUnexpectedError("Network interface - sendGetRequestAsync() has not been implemented")}))}))},sendPostRequestAsync:function(){return l(this,void 0,void 0,(function(){return p(this,(function(e){throw"Network interface - sendPostRequestAsync() has not been implemented",ne.createUnexpectedError("Network interface - sendPostRequestAsync() has not been implemented")}))}))}},It={createNewGuid:function(){throw ne.createUnexpectedError("Crypto interface - createNewGuid() has not been implemented")},base64Decode:function(){throw ne.createUnexpectedError("Crypto interface - base64Decode() has not been implemented")},base64Encode:function(){throw ne.createUnexpectedError("Crypto interface - base64Encode() has not been implemented")},generatePkceCodes:function(){return l(this,void 0,void 0,(function(){return p(this,(function(e){throw"Crypto interface - generatePkceCodes() has not been implemented",ne.createUnexpectedError("Crypto interface - generatePkceCodes() has not been implemented")}))}))},getPublicKeyThumbprint:function(){return l(this,void 0,void 0,(function(){return p(this,(function(e){throw"Crypto interface - getPublicKeyThumbprint() has not been implemented",ne.createUnexpectedError("Crypto interface - getPublicKeyThumbprint() has not been implemented")}))}))},signJwt:function(){return l(this,void 0,void 0,(function(){return p(this,(function(e){throw"Crypto interface - signJwt() has not been implemented",ne.createUnexpectedError("Crypto interface - signJwt() has not been implemented")}))}))}},At={sku:T,version:"2.0.0",cpu:"",os:""},_t={clientSecret:"",clientAssertion:void 0};var Rt,bt=function(e){function t(r,n,o){var i=e.call(this,r,n,o)||this;return i.name="ServerError",Object.setPrototypeOf(i,t.prototype),i}return d(t,e),t}(ne),Ot=function(){function e(){}return e.generateThrottlingStorageKey=function(e){return Z+"."+JSON.stringify(e)},e.preProcess=function(t,r){var n,o=e.generateThrottlingStorageKey(r),i=t.getThrottlingCache(o);if(i){if(i.throttleTime=500&&e.status<600},e.checkResponseForRetryAfter=function(e){return!!e.headers&&(e.headers.hasOwnProperty(g.RETRY_AFTER)&&(e.status<200||e.status>=300))},e.calculateThrottleTime=function(e){e<=0&&(e=0);var t=Date.now()/1e3;return Math.floor(1e3*Math.min(t+(e||Y),t+X))},e.removeThrottle=function(e,t,r,n,o){var i={clientId:t,authority:r,scopes:n,homeAccountIdentifier:o},s=this.generateThrottlingStorageKey(i);return e.removeItem(s,B.THROTTLING)},e}(),kt=function(){function e(e,t){this.networkClient=e,this.cacheManager=t}return e.prototype.sendPostRequest=function(e,t,r){return l(this,void 0,void 0,(function(){var n;return p(this,(function(o){switch(o.label){case 0:return Ot.preProcess(this.cacheManager,e),[4,this.networkClient.sendPostRequestAsync(t,r)];case 1:return n=o.sent(),Ot.postProcess(this.cacheManager,e,n),[2,n]}}))}))},e}(),Nt=function(){function e(e){var t,r,n,o,i,s,a,c,u,d,l,p,f;this.config=(n=(t=e).authOptions,o=t.systemOptions,i=t.loggerOptions,s=t.storageInterface,a=t.networkInterface,c=t.cryptoInterface,u=t.clientCredentials,d=t.libraryInfo,l=t.serverTelemetryManager,p=t.persistencePlugin,f=t.serializableCache,{authOptions:(r=n,h({knownAuthorities:[],cloudDiscoveryMetadata:"",clientCapabilities:[],protocolMode:lt.AAD},r)),systemOptions:h(h({},Tt),o),loggerOptions:h(h({},wt),i),storageInterface:s||new Ct(n.clientId,c||It),networkInterface:a||St,cryptoInterface:c||It,clientCredentials:u||_t,libraryInfo:h(h({},At),d),serverTelemetryManager:l||null,persistencePlugin:p||null,serializableCache:f||null}),this.logger=new Ge(this.config.loggerOptions,"@azure/msal-common","2.0.0"),this.cryptoUtils=this.config.cryptoInterface,this.cacheManager=this.config.storageInterface,this.networkClient=this.config.networkInterface,this.networkManager=new kt(this.networkClient,this.cacheManager),this.serverTelemetryManager=this.config.serverTelemetryManager,ft.setTrustedAuthoritiesFromConfig(this.config.authOptions.knownAuthorities,this.config.authOptions.cloudDiscoveryMetadata),this.authority=this.config.authOptions.authority}return e.prototype.createDefaultTokenRequestHeaders=function(){var e=this.createDefaultLibraryHeaders();return e[g.CONTENT_TYPE]=P,e[g.X_MS_LIB_CAPABILITY]=g.X_MS_LIB_CAPABILITY_VALUE,this.serverTelemetryManager&&(e[g.X_CLIENT_CURR_TELEM]=this.serverTelemetryManager.generateCurrentRequestHeaderValue(),e[g.X_CLIENT_LAST_TELEM]=this.serverTelemetryManager.generateLastRequestHeaderValue()),e},e.prototype.createDefaultLibraryHeaders=function(){var e={};return e[v.X_CLIENT_SKU]=this.config.libraryInfo.sku,e[v.X_CLIENT_VER]=this.config.libraryInfo.version,e[v.X_CLIENT_OS]=this.config.libraryInfo.os,e[v.X_CLIENT_CPU]=this.config.libraryInfo.cpu,e},e.prototype.executePostToTokenEndpoint=function(e,t,r,n){return l(this,void 0,void 0,(function(){var o;return p(this,(function(i){switch(i.label){case 0:return[4,this.networkManager.sendPostRequest(n,e,{body:t,headers:r})];case 1:return o=i.sent(),this.config.serverTelemetryManager&&o.status<500&&429!==o.status&&this.config.serverTelemetryManager.clearTelemetryCache(),[2,o]}}))}))},e.prototype.updateAuthority=function(e){if(!e.discoveryComplete())throw xe.createEndpointDiscoveryIncompleteError("Updated authority has not completed endpoint discovery.");this.authority=e},e}(),Pt=function(){function e(){}return e.validateRedirectUri=function(e){if(Fe.isEmpty(e))throw dt.createRedirectUriEmptyError()},e.validatePrompt=function(e){if([H.LOGIN,H.SELECT_ACCOUNT,H.CONSENT,H.NONE].indexOf(e)<0)throw dt.createInvalidPromptError(e)},e.validateClaims=function(e){try{JSON.parse(e)}catch(e){throw dt.createInvalidClaimsRequestError()}},e.validateCodeChallengeParams=function(e,t){if(Fe.isEmpty(e)||Fe.isEmpty(t))throw dt.createInvalidCodeChallengeParamsError();this.validateCodeChallengeMethod(t)},e.validateCodeChallengeMethod=function(e){if([W.PLAIN,W.S256].indexOf(e)<0)throw dt.createInvalidCodeChallengeMethodError()},e.sanitizeEQParams=function(e,t){return e?(t.forEach((function(t,r){e[r]&&delete e[r]})),e):{}},e}(),Ut=function(){function e(){this.parameters=new Map}return e.prototype.addResponseTypeCode=function(){this.parameters.set(v.RESPONSE_TYPE,encodeURIComponent(k))},e.prototype.addResponseMode=function(e){this.parameters.set(v.RESPONSE_MODE,encodeURIComponent(e||K.QUERY))},e.prototype.addScopes=function(e,t){void 0===t&&(t=!0);var r=t?f(e||[],[R,b]):e||[],n=new ht(r);this.parameters.set(v.SCOPE,encodeURIComponent(n.printScopes()))},e.prototype.addClientId=function(e){this.parameters.set(v.CLIENT_ID,encodeURIComponent(e))},e.prototype.addRedirectUri=function(e){Pt.validateRedirectUri(e),this.parameters.set(v.REDIRECT_URI,encodeURIComponent(e))},e.prototype.addPostLogoutRedirectUri=function(e){Pt.validateRedirectUri(e),this.parameters.set(v.POST_LOGOUT_URI,encodeURIComponent(e))},e.prototype.addIdTokenHint=function(e){this.parameters.set(v.ID_TOKEN_HINT,encodeURIComponent(e))},e.prototype.addDomainHint=function(e){this.parameters.set(D.DOMAIN_HINT,encodeURIComponent(e))},e.prototype.addLoginHint=function(e){this.parameters.set(D.LOGIN_HINT,encodeURIComponent(e))},e.prototype.addSid=function(e){this.parameters.set(D.SID,encodeURIComponent(e))},e.prototype.addClaims=function(e,t){var r=this.addClientCapabilitiesToClaims(e,t);Pt.validateClaims(r),this.parameters.set(v.CLAIMS,encodeURIComponent(r))},e.prototype.addCorrelationId=function(e){this.parameters.set(v.CLIENT_REQUEST_ID,encodeURIComponent(e))},e.prototype.addLibraryInfo=function(e){this.parameters.set(v.X_CLIENT_SKU,e.sku),this.parameters.set(v.X_CLIENT_VER,e.version),this.parameters.set(v.X_CLIENT_OS,e.os),this.parameters.set(v.X_CLIENT_CPU,e.cpu)},e.prototype.addPrompt=function(e){Pt.validatePrompt(e),this.parameters.set(""+v.PROMPT,encodeURIComponent(e))},e.prototype.addState=function(e){Fe.isEmpty(e)||this.parameters.set(v.STATE,encodeURIComponent(e))},e.prototype.addNonce=function(e){this.parameters.set(v.NONCE,encodeURIComponent(e))},e.prototype.addCodeChallengeParams=function(e,t){if(Pt.validateCodeChallengeParams(e,t),!e||!t)throw dt.createInvalidCodeChallengeParamsError();this.parameters.set(v.CODE_CHALLENGE,encodeURIComponent(e)),this.parameters.set(v.CODE_CHALLENGE_METHOD,encodeURIComponent(t))},e.prototype.addAuthorizationCode=function(e){this.parameters.set(v.CODE,encodeURIComponent(e))},e.prototype.addDeviceCode=function(e){this.parameters.set(v.DEVICE_CODE,encodeURIComponent(e))},e.prototype.addRefreshToken=function(e){this.parameters.set(v.REFRESH_TOKEN,encodeURIComponent(e))},e.prototype.addCodeVerifier=function(e){this.parameters.set(v.CODE_VERIFIER,encodeURIComponent(e))},e.prototype.addClientSecret=function(e){this.parameters.set(v.CLIENT_SECRET,encodeURIComponent(e))},e.prototype.addClientAssertion=function(e){this.parameters.set(v.CLIENT_ASSERTION,encodeURIComponent(e))},e.prototype.addClientAssertionType=function(e){this.parameters.set(v.CLIENT_ASSERTION_TYPE,encodeURIComponent(e))},e.prototype.addOboAssertion=function(e){this.parameters.set(v.OBO_ASSERTION,encodeURIComponent(e))},e.prototype.addRequestTokenUse=function(e){this.parameters.set(v.REQUESTED_TOKEN_USE,encodeURIComponent(e))},e.prototype.addGrantType=function(e){this.parameters.set(v.GRANT_TYPE,encodeURIComponent(e))},e.prototype.addClientInfo=function(){this.parameters.set("client_info","1")},e.prototype.addExtraQueryParameters=function(e){var t=this;Pt.sanitizeEQParams(e,this.parameters),Object.keys(e).forEach((function(r){t.parameters.set(r,e[r])}))},e.prototype.addClientCapabilitiesToClaims=function(e,t){var r;if(e)try{r=JSON.parse(e)}catch(e){throw dt.createInvalidClaimsRequestError()}else r={};return t&&t.length>0&&(r.hasOwnProperty(E.ACCESS_TOKEN)||(r[E.ACCESS_TOKEN]={}),r[E.ACCESS_TOKEN][E.XMS_CC]={values:t}),JSON.stringify(r)},e.prototype.addUsername=function(e){this.parameters.set(V.username,e)},e.prototype.addPassword=function(e){this.parameters.set(V.password,e)},e.prototype.addPopToken=function(e){Fe.isEmpty(e)||(this.parameters.set(v.TOKEN_TYPE,J.POP),this.parameters.set(v.REQ_CNF,encodeURIComponent(e)))},e.prototype.createQueryString=function(){var e=new Array;return this.parameters.forEach((function(t,r){e.push(r+"="+t)})),e.join("&")},e}(),Mt=function(){function e(){}return e.nowSeconds=function(){return Math.round((new Date).getTime()/1e3)},e.isTokenExpired=function(t,r){var n=Number(t)||0;return e.nowSeconds()+r>n},e}(),qt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return d(t,e),t.createIdTokenEntity=function(e,r,n,o,i,s){var a=new t;return a.credentialType=G.ID_TOKEN,a.homeAccountId=e,a.environment=r,a.clientId=o,a.secret=n,a.realm=i,a.oboAssertion=s,a},t.isIdTokenEntity=function(e){return!!e&&(e.hasOwnProperty("homeAccountId")&&e.hasOwnProperty("environment")&&e.hasOwnProperty("credentialType")&&e.hasOwnProperty("realm")&&e.hasOwnProperty("clientId")&&e.hasOwnProperty("secret")&&e.credentialType===G.ID_TOKEN)},t}(Be),Lt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return d(t,e),t.createAccessTokenEntity=function(e,r,n,o,i,s,a,c,u,d){var h=new t;h.homeAccountId=e,h.credentialType=G.ACCESS_TOKEN,h.secret=n;var l=Mt.nowSeconds();return h.cachedAt=l.toString(),h.expiresOn=a.toString(),h.extendedExpiresOn=c.toString(),h.environment=r,h.clientId=o,h.realm=i,h.target=s,h.oboAssertion=d,h.tokenType=Fe.isEmpty(u)?J.BEARER:u,h},t.isAccessTokenEntity=function(e){return!!e&&(e.hasOwnProperty("homeAccountId")&&e.hasOwnProperty("environment")&&e.hasOwnProperty("credentialType")&&e.hasOwnProperty("realm")&&e.hasOwnProperty("clientId")&&e.hasOwnProperty("secret")&&e.hasOwnProperty("target")&&e.credentialType===G.ACCESS_TOKEN)},t}(Be),Dt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return d(t,e),t.createRefreshTokenEntity=function(e,r,n,o,i,s){var a=new t;return a.clientId=o,a.credentialType=G.REFRESH_TOKEN,a.environment=r,a.homeAccountId=e,a.secret=n,a.oboAssertion=s,i&&(a.familyId=i),a},t.isRefreshTokenEntity=function(e){return!!e&&(e.hasOwnProperty("homeAccountId")&&e.hasOwnProperty("environment")&&e.hasOwnProperty("credentialType")&&e.hasOwnProperty("clientId")&&e.hasOwnProperty("secret")&&e.credentialType===G.REFRESH_TOKEN)},t}(Be),Ht=["interaction_required","consent_required","login_required"],Kt=["message_only","additional_action","basic_action","user_password_expired","consent_required"],xt=function(e){function t(r,n,o){var i=e.call(this,r,n,o)||this;return i.name="InteractionRequiredAuthError",Object.setPrototypeOf(i,t.prototype),i}return d(t,e),t.isInteractionRequiredError=function(e,t,r){var n=!!e&&Ht.indexOf(e)>-1,o=!!r&&Kt.indexOf(r)>-1,i=!!t&&Ht.some((function(e){return t.indexOf(e)>-1}));return n||i||o},t}(bt),Ft=function(e,t,r,n,o){this.account=e||null,this.idToken=t||null,this.accessToken=r||null,this.refreshToken=n||null,this.appMetadata=o||null},jt=function(){function e(){}return e.setRequestState=function(t,r,n){var o=e.generateLibraryState(t,n);return Fe.isEmpty(r)?o:""+o+_+r},e.generateLibraryState=function(e,t){if(!e)throw xe.createNoCryptoObjectError("generateLibraryState");var r={id:e.createNewGuid(),ts:Mt.nowSeconds()};t&&(r.meta=t);var n=JSON.stringify(r);return e.base64Encode(n)},e.parseRequestState=function(e,t){if(!e)throw xe.createNoCryptoObjectError("parseRequestState");if(Fe.isEmpty(t))throw xe.createInvalidStateError(t,"Null, undefined or empty state");try{var r=decodeURIComponent(t).split(_),n=r[0],o=r.length>1?r.slice(1).join(_):"",i=e.base64Decode(n),s=JSON.parse(i);return{userRequestState:Fe.isEmpty(o)?"":o,libraryState:s}}catch(e){throw xe.createInvalidStateError(t,e)}},e}();!function(e){e.SW="sw",e.UHW="uhw"}(Rt||(Rt={}));var Gt,Bt,zt,Wt,Jt,Qt=function(){function e(e){this.cryptoUtils=e}return e.prototype.generateCnf=function(e,t){return l(this,void 0,void 0,(function(){var r,n;return p(this,(function(o){switch(o.label){case 0:return[4,this.cryptoUtils.getPublicKeyThumbprint(e,t)];case 1:return r=o.sent(),n={kid:r,xms_ksl:Rt.SW},[2,this.cryptoUtils.base64Encode(JSON.stringify(n))]}}))}))},e.prototype.signPopToken=function(e,t,r){var n;return l(this,void 0,void 0,(function(){var o,i,s;return p(this,(function(a){switch(a.label){case 0:if(o=vt.extractTokenClaims(e,this.cryptoUtils),i=new pt(r),s=i.getUrlComponents(),!(null===(n=null==o?void 0:o.cnf)||void 0===n?void 0:n.kid))throw xe.createTokenClaimsRequiredError();return[4,this.cryptoUtils.signJwt({at:e,ts:""+Mt.nowSeconds(),m:t.toUpperCase(),u:s.HostNameAndPort||"",nonce:this.cryptoUtils.createNewGuid(),p:s.AbsolutePath,q:[[],s.QueryString]},o.cnf.kid)];case 1:return[2,a.sent()]}}))}))},e}(),Vt=function(){function e(){}return e.prototype.generateAppMetadataKey=function(){return e.generateAppMetadataCacheKey(this.environment,this.clientId)},e.generateAppMetadataCacheKey=function(e,t){return["appmetadata",e,t].join(j.CACHE_KEY_SEPARATOR).toLowerCase()},e.createAppMetadataEntity=function(t,r,n){var o=new e;return o.clientId=t,o.environment=r,n&&(o.familyId=n),o},e.isAppMetadataEntity=function(e,t){return!!t&&(0===e.indexOf("appmetadata")&&t.hasOwnProperty("clientId")&&t.hasOwnProperty("environment"))},e}(),Yt=function(){function e(e,t){this.cache=e,this.hasChanged=t}return Object.defineProperty(e.prototype,"cacheHasChanged",{get:function(){return this.hasChanged},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tokenCache",{get:function(){return this.cache},enumerable:!0,configurable:!0}),e}(),Xt=function(){function e(e,t,r,n,o,i){this.clientId=e,this.cacheStorage=t,this.cryptoObj=r,this.logger=n,this.serializableCache=o,this.persistencePlugin=i}return e.prototype.validateServerAuthorizationCodeResponse=function(e,t,r){if(!e.state||!t)throw e.state?xe.createStateNotFoundError("Cached State"):xe.createStateNotFoundError("Server State");if(decodeURIComponent(e.state)!==decodeURIComponent(t))throw xe.createStateMismatchError();if(e.error||e.error_description||e.suberror){if(xt.isInteractionRequiredError(e.error,e.error_description,e.suberror))throw new xt(e.error||q,e.error_description,e.suberror);throw new bt(e.error||q,e.error_description,e.suberror)}e.client_info&&yt(e.client_info,r)},e.prototype.validateTokenResponse=function(e){if(e.error||e.error_description||e.suberror){if(xt.isInteractionRequiredError(e.error,e.error_description,e.suberror))throw new xt(e.error,e.error_description,e.suberror);var t=e.error_codes+" - ["+e.timestamp+"]: "+e.error_description+" - Correlation ID: "+e.correlation_id+" - Trace ID: "+e.trace_id;throw new bt(e.error,t)}},e.prototype.handleServerTokenResponse=function(t,r,n,o,i,s,a,c){return l(this,void 0,void 0,(function(){var u,d,h,l,f;return p(this,(function(p){switch(p.label){case 0:if(t.id_token&&(u=new vt(t.id_token||q,this.cryptoObj),i&&!Fe.isEmpty(i.nonce)&&u.claims.nonce!==i.nonce))throw xe.createNonceMismatchError();this.homeAccountIdentifier=mt.generateHomeAccountId(t.client_info||q,r.authorityType,this.logger,this.cryptoObj,u),i&&i.state&&(d=jt.parseRequestState(this.cryptoObj,i.state)),h=this.generateCacheRecord(t,r,u,d&&d.libraryState,s,a,i),p.label=1;case 1:return p.trys.push([1,,4,7]),this.persistencePlugin&&this.serializableCache?(this.logger.verbose("Persistence enabled, calling beforeCacheAccess"),l=new Yt(this.serializableCache,!0),[4,this.persistencePlugin.beforeCacheAccess(l)]):[3,3];case 2:p.sent(),p.label=3;case 3:return!c||!h.account||(f=h.account.generateAccountKey(),this.cacheStorage.getAccount(f))?(this.cacheStorage.saveCacheRecord(h),[3,7]):(this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache"),[2,null]);case 4:return this.persistencePlugin&&this.serializableCache&&l?(this.logger.verbose("Persistence enabled, calling afterCacheAccess"),[4,this.persistencePlugin.afterCacheAccess(l)]):[3,6];case 5:p.sent(),p.label=6;case 6:return[7];case 7:return[2,e.generateAuthenticationResult(this.cryptoObj,r,h,!1,u,d,n,o)]}}))}))},e.prototype.generateCacheRecord=function(e,t,r,n,o,i,s){var a,c,u=gt.generateEnvironmentFromAuthority(t);if(Fe.isEmpty(u))throw xe.createInvalidCacheEnvironmentError();!Fe.isEmpty(e.id_token)&&r&&(a=qt.createIdTokenEntity(this.homeAccountIdentifier,u,e.id_token||q,this.clientId,r.claims.tid||q,i),c=this.generateAccountEntity(e,r,t,i,s));var d=null;if(!Fe.isEmpty(e.access_token)){var h=e.scope?ht.fromString(e.scope):new ht(o||[]),l=Mt.nowSeconds(),p=(n?n.ts:l)+(e.expires_in||0),f=p+(e.ext_expires_in||0);d=Lt.createAccessTokenEntity(this.homeAccountIdentifier,u,e.access_token||q,this.clientId,r?r.claims.tid||q:t.tenant,h.printScopes(),p,f,e.token_type,i)}var g=null;Fe.isEmpty(e.refresh_token)||(g=Dt.createRefreshTokenEntity(this.homeAccountIdentifier,u,e.refresh_token||q,this.clientId,e.foci,i));var y=null;return Fe.isEmpty(e.foci)||(y=Vt.createAppMetadataEntity(this.clientId,u,e.foci)),new Ft(c,a,d,g,y)},e.prototype.generateAccountEntity=function(e,t,r,n,o){var i=r.authorityType,s=o?o.cloud_graph_host_name:"",a=o?o.msgraph_host:"";if(i===je.Adfs)return this.logger.verbose("Authority type is ADFS, creating ADFS account"),mt.createGenericAccount(r,this.homeAccountIdentifier,t,n,s,a);if(Fe.isEmpty(e.client_info)&&"AAD"===r.protocolMode)throw xe.createClientInfoEmptyError();return e.client_info?mt.createAccount(e.client_info,this.homeAccountIdentifier,r,t,n,s,a):mt.createGenericAccount(r,this.homeAccountIdentifier,t,n,s,a)},e.generateAuthenticationResult=function(e,t,r,n,o,i,s,a){var c,u,d;return l(this,void 0,void 0,(function(){var h,l,f,g,y,m,v,E;return p(this,(function(p){switch(p.label){case 0:if(h="",l=[],f=null,y=q,!r.accessToken)return[3,4];if(r.accessToken.tokenType!==J.POP)return[3,2];if(m=new Qt(e),!s||!a)throw dt.createResourceRequestParametersRequiredError();return[4,m.signPopToken(r.accessToken.secret,s,a)];case 1:return h=p.sent(),[3,3];case 2:h=r.accessToken.secret,p.label=3;case 3:l=ht.fromString(r.accessToken.target).asArray(),f=new Date(1e3*Number(r.accessToken.expiresOn)),g=new Date(1e3*Number(r.accessToken.extendedExpiresOn)),p.label=4;case 4:return r.appMetadata&&(y="1"===r.appMetadata.familyId?"1":q),v=(null==o?void 0:o.claims.oid)||(null==o?void 0:o.claims.sub)||q,E=(null==o?void 0:o.claims.tid)||q,[2,{authority:t.canonicalAuthority,uniqueId:v,tenantId:E,scopes:l,account:r.account?r.account.getAccountInfo():null,idToken:o?o.rawToken:q,idTokenClaims:o?o.claims:{},accessToken:h,fromCache:n,expiresOn:f,extExpiresOn:g,familyId:y,tokenType:(null===(c=r.accessToken)||void 0===c?void 0:c.tokenType)||q,state:i?i.userRequestState:q,cloudGraphHostName:(null===(u=r.account)||void 0===u?void 0:u.cloudGraphHostName)||q,msGraphHost:(null===(d=r.account)||void 0===d?void 0:d.msGraphHost)||q}]}}))}))},e}(),Zt=function(e){function t(t){return e.call(this,t)||this}return d(t,e),t.prototype.getAuthCodeUrl=function(e){return l(this,void 0,void 0,(function(){var t;return p(this,(function(r){return t=this.createAuthCodeUrlQueryString(e),[2,this.authority.authorizationEndpoint+"?"+t]}))}))},t.prototype.acquireToken=function(e,t){return l(this,void 0,void 0,(function(){var r,n;return p(this,(function(o){switch(o.label){case 0:if(this.logger.info("in acquireToken call"),!e||Fe.isEmpty(e.code))throw xe.createTokenRequestCannotBeMadeError();return[4,this.executeTokenRequest(this.authority,e)];case 1:return r=o.sent(),(n=new Xt(this.config.authOptions.clientId,this.cacheManager,this.cryptoUtils,this.logger,this.config.serializableCache,this.config.persistencePlugin)).validateTokenResponse(r.body),[4,n.handleServerTokenResponse(r.body,this.authority,e.resourceRequestMethod,e.resourceRequestUri,t)];case 2:return[2,o.sent()]}}))}))},t.prototype.handleFragmentResponse=function(e,t){var r=new Xt(this.config.authOptions.clientId,this.cacheManager,this.cryptoUtils,this.logger,null,null),n=new pt(e),o=pt.getDeserializedHash(n.getHash());if(r.validateServerAuthorizationCodeResponse(o,t,this.cryptoUtils),!o.code)throw xe.createNoAuthCodeInServerResponseError();return h(h({},o),{code:o.code})},t.prototype.getLogoutUri=function(e){if(!e)throw dt.createEmptyLogoutRequestError();e.account?this.cacheManager.removeAccount(mt.generateAccountCacheKey(e.account)):this.cacheManager.clear();var t=this.createLogoutUrlQueryString(e);return Fe.isEmpty(t)?this.authority.endSessionEndpoint:this.authority.endSessionEndpoint+"?"+t},t.prototype.executeTokenRequest=function(e,t){return l(this,void 0,void 0,(function(){var r,n,o;return p(this,(function(i){switch(i.label){case 0:return r={clientId:this.config.authOptions.clientId,authority:e.canonicalAuthority,scopes:t.scopes},[4,this.createTokenRequestBody(t)];case 1:return n=i.sent(),o=this.createDefaultTokenRequestHeaders(),[2,this.executePostToTokenEndpoint(e.tokenEndpoint,n,o,r)]}}))}))},t.prototype.createTokenRequestBody=function(e){return l(this,void 0,void 0,(function(){var t,r,n,o;return p(this,(function(i){switch(i.label){case 0:return(t=new Ut).addClientId(this.config.authOptions.clientId),t.addRedirectUri(e.redirectUri),t.addScopes(e.scopes),t.addAuthorizationCode(e.code),e.codeVerifier&&t.addCodeVerifier(e.codeVerifier),this.config.clientCredentials.clientSecret&&t.addClientSecret(this.config.clientCredentials.clientSecret),this.config.clientCredentials.clientAssertion&&(r=this.config.clientCredentials.clientAssertion,t.addClientAssertion(r.assertion),t.addClientAssertionType(r.assertionType)),t.addGrantType(x.AUTHORIZATION_CODE_GRANT),t.addClientInfo(),e.authenticationScheme===J.POP&&e.resourceRequestMethod&&e.resourceRequestUri?[4,new Qt(this.cryptoUtils).generateCnf(e.resourceRequestMethod,e.resourceRequestUri)]:[3,2];case 1:n=i.sent(),t.addPopToken(n),i.label=2;case 2:return o=e.correlationId||this.config.cryptoInterface.createNewGuid(),t.addCorrelationId(o),(!Fe.isEmpty(e.claims)||this.config.authOptions.clientCapabilities&&this.config.authOptions.clientCapabilities.length>0)&&t.addClaims(e.claims,this.config.authOptions.clientCapabilities),[2,t.createQueryString()]}}))}))},t.prototype.createAuthCodeUrlQueryString=function(e){var t=new Ut;t.addClientId(this.config.authOptions.clientId);var r=f(e.scopes||[],e.extraScopesToConsent||[]);t.addScopes(r),t.addRedirectUri(e.redirectUri);var n=e.correlationId||this.config.cryptoInterface.createNewGuid();return t.addCorrelationId(n),t.addResponseMode(e.responseMode),t.addResponseTypeCode(),t.addLibraryInfo(this.config.libraryInfo),t.addClientInfo(),e.codeChallenge&&e.codeChallengeMethod&&t.addCodeChallengeParams(e.codeChallenge,e.codeChallengeMethod),e.prompt&&t.addPrompt(e.prompt),e.domainHint&&t.addDomainHint(e.domainHint),e.sid?t.addSid(e.sid):e.loginHint?t.addLoginHint(e.loginHint):e.account&&e.account.username&&t.addLoginHint(e.account.username),e.nonce&&t.addNonce(e.nonce),e.state&&t.addState(e.state),(!Fe.isEmpty(e.claims)||this.config.authOptions.clientCapabilities&&this.config.authOptions.clientCapabilities.length>0)&&t.addClaims(e.claims,this.config.authOptions.clientCapabilities),e.extraQueryParameters&&t.addExtraQueryParameters(e.extraQueryParameters),t.createQueryString()},t.prototype.createLogoutUrlQueryString=function(e){var t=new Ut;return e.postLogoutRedirectUri&&t.addPostLogoutRedirectUri(e.postLogoutRedirectUri),e.correlationId&&t.addCorrelationId(e.correlationId),e.idTokenHint&&t.addIdTokenHint(e.idTokenHint),t.createQueryString()},t}(Nt),$t=(function(e){function t(t){return e.call(this,t)||this}d(t,e),t.prototype.acquireToken=function(e){return l(this,void 0,void 0,(function(){var t,r,n;return p(this,(function(o){switch(o.label){case 0:return[4,this.getDeviceCode(e)];case 1:return t=o.sent(),e.deviceCodeCallback(t),[4,this.acquireTokenWithDeviceCode(e,t)];case 2:return r=o.sent(),(n=new Xt(this.config.authOptions.clientId,this.cacheManager,this.cryptoUtils,this.logger,this.config.serializableCache,this.config.persistencePlugin)).validateTokenResponse(r),[4,n.handleServerTokenResponse(r,this.authority,e.resourceRequestMethod,e.resourceRequestUri)];case 3:return[2,o.sent()]}}))}))},t.prototype.getDeviceCode=function(e){return l(this,void 0,void 0,(function(){var t,r,n;return p(this,(function(o){return t=this.createQueryString(e),r=this.createDefaultTokenRequestHeaders(),n={clientId:this.config.authOptions.clientId,authority:e.authority,scopes:e.scopes},[2,this.executePostRequestToDeviceCodeEndpoint(this.authority.deviceCodeEndpoint,t,r,n)]}))}))},t.prototype.executePostRequestToDeviceCodeEndpoint=function(e,t,r,n){return l(this,void 0,void 0,(function(){var o,i,s,a,c,u,d;return p(this,(function(h){switch(h.label){case 0:return[4,this.networkManager.sendPostRequest(n,e,{body:t,headers:r})];case 1:return o=h.sent().body,i=o.user_code,s=o.device_code,a=o.verification_uri,c=o.expires_in,u=o.interval,d=o.message,[2,{userCode:i,deviceCode:s,verificationUri:a,expiresIn:c,interval:u,message:d}]}}))}))},t.prototype.createQueryString=function(e){var t=new Ut;return t.addScopes(e.scopes),t.addClientId(this.config.authOptions.clientId),(!Fe.isEmpty(e.claims)||this.config.authOptions.clientCapabilities&&this.config.authOptions.clientCapabilities.length>0)&&t.addClaims(e.claims,this.config.authOptions.clientCapabilities),t.createQueryString()},t.prototype.acquireTokenWithDeviceCode=function(e,t){return l(this,void 0,void 0,(function(){var r,n,o,i,s=this;return p(this,(function(a){return r=this.createTokenRequestBody(e,t),n=this.createDefaultTokenRequestHeaders(),o=Mt.nowSeconds()+t.expiresIn,i=1e3*t.interval,[2,new Promise((function(t,a){var c=setInterval((function(){return l(s,void 0,void 0,(function(){var i,s,u;return p(this,(function(d){switch(d.label){case 0:return d.trys.push([0,5,,6]),e.cancel?(this.logger.error("Token request cancelled by setting DeviceCodeRequest.cancel = true"),clearInterval(c),a(xe.createDeviceCodeCancelledError()),[3,4]):[3,1];case 1:return Mt.nowSeconds()>o?(this.logger.error("Device code expired. Expiration time of device code was "+o),clearInterval(c),a(xe.createDeviceCodeExpiredError()),[3,4]):[3,2];case 2:return i={clientId:this.config.authOptions.clientId,authority:e.authority,scopes:e.scopes},[4,this.executePostToTokenEndpoint(this.authority.tokenEndpoint,r,n,i)];case 3:(s=d.sent()).body&&s.body.error===U?this.logger.info(s.body.error_description||"no_error_description"):(clearInterval(c),t(s.body)),d.label=4;case 4:return[3,6];case 5:return u=d.sent(),clearInterval(c),a(u),[3,6];case 6:return[2]}}))}))}),i)}))]}))}))},t.prototype.createTokenRequestBody=function(e,t){var r=new Ut;r.addScopes(e.scopes),r.addClientId(this.config.authOptions.clientId),r.addGrantType(x.DEVICE_CODE_GRANT),r.addDeviceCode(t.deviceCode);var n=e.correlationId||this.config.cryptoInterface.createNewGuid();return r.addCorrelationId(n),r.addClientInfo(),(!Fe.isEmpty(e.claims)||this.config.authOptions.clientCapabilities&&this.config.authOptions.clientCapabilities.length>0)&&r.addClaims(e.claims,this.config.authOptions.clientCapabilities),r.createQueryString()}}(Nt),function(e){function t(t){return e.call(this,t)||this}return d(t,e),t.prototype.acquireToken=function(e){return l(this,void 0,void 0,(function(){var t,r;return p(this,(function(n){switch(n.label){case 0:return[4,this.executeTokenRequest(e,this.authority)];case 1:return t=n.sent(),(r=new Xt(this.config.authOptions.clientId,this.cacheManager,this.cryptoUtils,this.logger,this.config.serializableCache,this.config.persistencePlugin)).validateTokenResponse(t.body),[2,r.handleServerTokenResponse(t.body,this.authority,e.resourceRequestMethod,e.resourceRequestUri,void 0,[],void 0,!0)]}}))}))},t.prototype.acquireTokenByRefreshToken=function(e){return l(this,void 0,void 0,(function(){var t,r;return p(this,(function(n){if(!e)throw dt.createEmptyTokenRequestError();if(!e.account)throw xe.createNoAccountInSilentRequestError();if(this.cacheManager.isAppMetadataFOCI(e.account.environment,this.config.authOptions.clientId))try{return[2,this.acquireTokenWithCachedRefreshToken(e,!0)]}catch(n){if(t=n instanceof xe&&n.errorCode===ge.code,r=n instanceof bt&&n.errorCode===$&&n.subError===ee,t||r)return[2,this.acquireTokenWithCachedRefreshToken(e,!1)];throw n}return[2,this.acquireTokenWithCachedRefreshToken(e,!1)]}))}))},t.prototype.acquireTokenWithCachedRefreshToken=function(e,t){return l(this,void 0,void 0,(function(){var r,n;return p(this,(function(o){if(!(r=this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId,e.account,t)))throw xe.createNoTokensFoundError();return n=h(h({},e),{refreshToken:r.secret,authenticationScheme:J.BEARER}),[2,this.acquireToken(n)]}))}))},t.prototype.executeTokenRequest=function(e,t){return l(this,void 0,void 0,(function(){var r,n,o;return p(this,(function(i){switch(i.label){case 0:return[4,this.createTokenRequestBody(e)];case 1:return r=i.sent(),n=this.createDefaultTokenRequestHeaders(),o={clientId:this.config.authOptions.clientId,authority:t.canonicalAuthority,scopes:e.scopes},[2,this.executePostToTokenEndpoint(t.tokenEndpoint,r,n,o)]}}))}))},t.prototype.createTokenRequestBody=function(e){return l(this,void 0,void 0,(function(){var t,r,n,o,i,s;return p(this,(function(a){switch(a.label){case 0:if((t=new Ut).addClientId(this.config.authOptions.clientId),t.addScopes(e.scopes),t.addGrantType(x.REFRESH_TOKEN_GRANT),t.addClientInfo(),r=e.correlationId||this.config.cryptoInterface.createNewGuid(),t.addCorrelationId(r),t.addRefreshToken(e.refreshToken),this.config.clientCredentials.clientSecret&&t.addClientSecret(this.config.clientCredentials.clientSecret),this.config.clientCredentials.clientAssertion&&(n=this.config.clientCredentials.clientAssertion,t.addClientAssertion(n.assertion),t.addClientAssertionType(n.assertionType)),e.authenticationScheme!==J.POP)return[3,2];if(o=new Qt(this.cryptoUtils),!e.resourceRequestMethod||!e.resourceRequestUri)throw dt.createResourceRequestParametersRequiredError();return s=(i=t).addPopToken,[4,o.generateCnf(e.resourceRequestMethod,e.resourceRequestUri)];case 1:s.apply(i,[a.sent()]),a.label=2;case 2:return(!Fe.isEmpty(e.claims)||this.config.authOptions.clientCapabilities&&this.config.authOptions.clientCapabilities.length>0)&&t.addClaims(e.claims,this.config.authOptions.clientCapabilities),[2,t.createQueryString()]}}))}))},t}(Nt)),er=(function(e){function t(t){return e.call(this,t)||this}d(t,e),t.prototype.acquireToken=function(e){return l(this,void 0,void 0,(function(){var t;return p(this,(function(r){switch(r.label){case 0:return this.scopeSet=new ht(e.scopes||[]),e.skipCache?[4,this.executeTokenRequest(e,this.authority)]:[3,2];case 1:return[2,r.sent()];case 2:return[4,this.getCachedAuthenticationResult()];case 3:return(t=r.sent())?[2,t]:[3,4];case 4:return[4,this.executeTokenRequest(e,this.authority)];case 5:return[2,r.sent()]}}))}))},t.prototype.getCachedAuthenticationResult=function(){return l(this,void 0,void 0,(function(){var e;return p(this,(function(t){switch(t.label){case 0:return!(e=this.readAccessTokenFromCache())||Mt.isTokenExpired(e.expiresOn,this.config.systemOptions.tokenRenewalOffsetSeconds)?[2,null]:[4,Xt.generateAuthenticationResult(this.cryptoUtils,this.authority,{account:null,idToken:null,accessToken:e,refreshToken:null,appMetadata:null},!0)];case 1:return[2,t.sent()]}}))}))},t.prototype.readAccessTokenFromCache=function(){var e={homeAccountId:"",environment:this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,credentialType:G.ACCESS_TOKEN,clientId:this.config.authOptions.clientId,realm:this.authority.tenant,target:this.scopeSet.printScopesLowerCase()},t=this.cacheManager.getCredentialsFilteredBy(e),r=Object.keys(t.accessTokens).map((function(e){return t.accessTokens[e]}));if(r.length<1)return null;if(r.length>1)throw xe.createMultipleMatchingTokensInCacheError();return r[0]},t.prototype.executeTokenRequest=function(e,t){return l(this,void 0,void 0,(function(){var r,n,o,i,s;return p(this,(function(a){switch(a.label){case 0:return r=this.createTokenRequestBody(e),n=this.createDefaultTokenRequestHeaders(),o={clientId:this.config.authOptions.clientId,authority:e.authority,scopes:e.scopes},[4,this.executePostToTokenEndpoint(t.tokenEndpoint,r,n,o)];case 1:return i=a.sent(),(s=new Xt(this.config.authOptions.clientId,this.cacheManager,this.cryptoUtils,this.logger,this.config.serializableCache,this.config.persistencePlugin)).validateTokenResponse(i.body),[4,s.handleServerTokenResponse(i.body,this.authority,e.resourceRequestMethod,e.resourceRequestUri,void 0,e.scopes)];case 2:return[2,a.sent()]}}))}))},t.prototype.createTokenRequestBody=function(e){var t=new Ut;t.addClientId(this.config.authOptions.clientId),t.addScopes(e.scopes,!1),t.addGrantType(x.CLIENT_CREDENTIALS_GRANT);var r=e.correlationId||this.config.cryptoInterface.createNewGuid();if(t.addCorrelationId(r),this.config.clientCredentials.clientSecret&&t.addClientSecret(this.config.clientCredentials.clientSecret),this.config.clientCredentials.clientAssertion){var n=this.config.clientCredentials.clientAssertion;t.addClientAssertion(n.assertion),t.addClientAssertionType(n.assertionType)}return(!Fe.isEmpty(e.claims)||this.config.authOptions.clientCapabilities&&this.config.authOptions.clientCapabilities.length>0)&&t.addClaims(e.claims,this.config.authOptions.clientCapabilities),t.createQueryString()}}(Nt),function(e){function t(t){return e.call(this,t)||this}d(t,e),t.prototype.acquireToken=function(e){return l(this,void 0,void 0,(function(){var t;return p(this,(function(r){switch(r.label){case 0:return this.scopeSet=new ht(e.scopes||[]),e.skipCache?[4,this.executeTokenRequest(e,this.authority)]:[3,2];case 1:return[2,r.sent()];case 2:return[4,this.getCachedAuthenticationResult(e)];case 3:return(t=r.sent())?[2,t]:[3,4];case 4:return[4,this.executeTokenRequest(e,this.authority)];case 5:return[2,r.sent()]}}))}))},t.prototype.getCachedAuthenticationResult=function(e){return l(this,void 0,void 0,(function(){var t,r,n,o,i,s;return p(this,(function(a){switch(a.label){case 0:return!(t=this.readAccessTokenFromCache(e))||Mt.isTokenExpired(t.expiresOn,this.config.systemOptions.tokenRenewalOffsetSeconds)?[2,null]:(r=this.readIdTokenFromCache(e),o=null,r&&(n=new vt(r.secret,this.config.cryptoInterface),i=n.claims.oid?n.claims.oid:n.claims.sub,s={homeAccountId:r.homeAccountId,environment:r.environment,tenantId:r.realm,username:q,localAccountId:i||""},o=this.readAccountFromCache(s)),[4,Xt.generateAuthenticationResult(this.cryptoUtils,this.authority,{account:o,accessToken:t,idToken:r,refreshToken:null,appMetadata:null},!0,n)]);case 1:return[2,a.sent()]}}))}))},t.prototype.readAccessTokenFromCache=function(e){var t={environment:this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,credentialType:G.ACCESS_TOKEN,clientId:this.config.authOptions.clientId,realm:this.authority.tenant,target:this.scopeSet.printScopesLowerCase(),oboAssertion:e.oboAssertion},r=this.cacheManager.getCredentialsFilteredBy(t),n=Object.keys(r.accessTokens).map((function(e){return r.accessTokens[e]})),o=n.length;if(o<1)return null;if(o>1)throw xe.createMultipleMatchingTokensInCacheError();return n[0]},t.prototype.readIdTokenFromCache=function(e){var t={environment:this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,credentialType:G.ID_TOKEN,clientId:this.config.authOptions.clientId,realm:this.authority.tenant,oboAssertion:e.oboAssertion},r=this.cacheManager.getCredentialsFilteredBy(t),n=Object.keys(r.idTokens).map((function(e){return r.idTokens[e]}));return n.length<1?null:n[0]},t.prototype.readAccountFromCache=function(e){return this.cacheManager.readAccountFromCache(e)},t.prototype.executeTokenRequest=function(e,t){return l(this,void 0,void 0,(function(){var r,n,o,i,s;return p(this,(function(a){switch(a.label){case 0:return r=this.createTokenRequestBody(e),n=this.createDefaultTokenRequestHeaders(),o={clientId:this.config.authOptions.clientId,authority:e.authority,scopes:e.scopes},[4,this.executePostToTokenEndpoint(t.tokenEndpoint,r,n,o)];case 1:return i=a.sent(),(s=new Xt(this.config.authOptions.clientId,this.cacheManager,this.cryptoUtils,this.logger,this.config.serializableCache,this.config.persistencePlugin)).validateTokenResponse(i.body),[4,s.handleServerTokenResponse(i.body,this.authority,e.resourceRequestMethod,e.resourceRequestUri,void 0,e.scopes,e.oboAssertion)];case 2:return[2,a.sent()]}}))}))},t.prototype.createTokenRequestBody=function(e){var t=new Ut;t.addClientId(this.config.authOptions.clientId),t.addScopes(e.scopes),t.addGrantType(x.JWT_BEARER),t.addClientInfo();var r=e.correlationId||this.config.cryptoInterface.createNewGuid();if(t.addCorrelationId(r),t.addRequestTokenUse(v.ON_BEHALF_OF),t.addOboAssertion(e.oboAssertion),this.config.clientCredentials.clientSecret&&t.addClientSecret(this.config.clientCredentials.clientSecret),this.config.clientCredentials.clientAssertion){var n=this.config.clientCredentials.clientAssertion;t.addClientAssertion(n.assertion),t.addClientAssertionType(n.assertionType)}return t.createQueryString()}}(Nt),function(e){function t(t){return e.call(this,t)||this}return d(t,e),t.prototype.acquireToken=function(e){return l(this,void 0,void 0,(function(){var t;return p(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.acquireCachedToken(e)];case 1:return[2,r.sent()];case 2:if((t=r.sent())instanceof xe&&t.errorCode===De.code)return[2,new $t(this.config).acquireTokenByRefreshToken(e)];throw t;case 3:return[2]}}))}))},t.prototype.acquireCachedToken=function(e){return l(this,void 0,void 0,(function(){var t,r,n;return p(this,(function(o){switch(o.label){case 0:if(!e)throw dt.createEmptyTokenRequestError();if(!e.account)throw xe.createNoAccountInSilentRequestError();if(t=new ht(e.scopes||[]),r=e.authority||gt.generateEnvironmentFromAuthority(this.authority),n=this.cacheManager.readCacheRecord(e.account,this.config.authOptions.clientId,t,r),!this.isRefreshRequired(e,n.accessToken))return[3,1];throw xe.createRefreshRequiredError();case 1:return this.config.serverTelemetryManager&&this.config.serverTelemetryManager.incrementCacheHits(),[4,this.generateResultFromCacheRecord(n,e.resourceRequestMethod,e.resourceRequestUri)];case 2:return[2,o.sent()]}}))}))},t.prototype.generateResultFromCacheRecord=function(e,t,r){return l(this,void 0,void 0,(function(){var n;return p(this,(function(o){switch(o.label){case 0:return e.idToken&&(n=new vt(e.idToken.secret,this.config.cryptoInterface)),[4,Xt.generateAuthenticationResult(this.cryptoUtils,this.authority,e,!0,n,void 0,t,r)];case 1:return[2,o.sent()]}}))}))},t.prototype.isRefreshRequired=function(e,t){return!(!e.forceRefresh&&!e.claims)||!(t&&!Mt.isTokenExpired(t.expiresOn,this.config.systemOptions.tokenRenewalOffsetSeconds))},t}(Nt)),tr=(function(e){function t(t){return e.call(this,t)||this}d(t,e),t.prototype.acquireToken=function(e){return l(this,void 0,void 0,(function(){var t,r;return p(this,(function(n){switch(n.label){case 0:return this.logger.info("in acquireToken call"),[4,this.executeTokenRequest(this.authority,e)];case 1:return t=n.sent(),(r=new Xt(this.config.authOptions.clientId,this.cacheManager,this.cryptoUtils,this.logger,this.config.serializableCache,this.config.persistencePlugin)).validateTokenResponse(t.body),[2,r.handleServerTokenResponse(t.body,this.authority)]}}))}))},t.prototype.executeTokenRequest=function(e,t){return l(this,void 0,void 0,(function(){var r,n,o;return p(this,(function(i){return r={clientId:this.config.authOptions.clientId,authority:e.canonicalAuthority,scopes:t.scopes},n=this.createTokenRequestBody(t),o=this.createDefaultTokenRequestHeaders(),[2,this.executePostToTokenEndpoint(e.tokenEndpoint,n,o,r)]}))}))},t.prototype.createTokenRequestBody=function(e){var t=new Ut;t.addClientId(this.config.authOptions.clientId),t.addUsername(e.username),t.addPassword(e.password),t.addScopes(e.scopes),t.addGrantType(x.RESOURCE_OWNER_PASSWORD_GRANT),t.addClientInfo();var r=e.correlationId||this.config.cryptoInterface.createNewGuid();return t.addCorrelationId(r),(!Fe.isEmpty(e.claims)||this.config.authOptions.clientCapabilities&&this.config.authOptions.clientCapabilities.length>0)&&t.addClaims(e.claims,this.config.authOptions.clientCapabilities),t.createQueryString()}}(Nt),function(){function e(){}return e.createDiscoveredInstance=function(t,r,n){return l(this,void 0,void 0,(function(){var o,i;return p(this,(function(s){switch(s.label){case 0:if((o=e.createInstance(t,r,n)).discoveryComplete())return[2,o];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,o.resolveEndpointsAsync()];case 2:return s.sent(),[2,o];case 3:throw i=s.sent(),xe.createEndpointDiscoveryIncompleteError(i);case 4:return[2]}}))}))},e.createInstance=function(e,t,r){if(Fe.isEmpty(e))throw dt.createUrlEmptyError();return new gt(e,t,r)},e}()),rr=function(){function e(){this.failedRequests=[],this.errors=[],this.cacheHits=0}return e.isServerTelemetryEntity=function(e,t){var r=0===e.indexOf(Q.CACHE_KEY),n=!0;return t&&(n=t.hasOwnProperty("failedRequests")&&t.hasOwnProperty("errors")&&t.hasOwnProperty("cacheHits")),r&&n},e}(),nr=function(){function e(){}return e.isThrottlingEntity=function(e,t){var r=!1;e&&(r=0===e.indexOf(Z));var n=!0;return t&&(n=t.hasOwnProperty("throttleTime")),r&&n},e}(),or=function(){function e(e,t){this.cacheManager=t,this.apiId=e.apiId,this.correlationId=e.correlationId,this.forceRefresh=e.forceRefresh||!1,this.telemetryCacheKey=Q.CACHE_KEY+j.CACHE_KEY_SEPARATOR+e.clientId}return e.prototype.generateCurrentRequestHeaderValue=function(){var e=this.forceRefresh?1:0,t=""+this.apiId+Q.VALUE_SEPARATOR+e;return[Q.SCHEMA_VERSION,t,""].join(Q.CATEGORY_SEPARATOR)},e.prototype.generateLastRequestHeaderValue=function(){var t=this.getLastRequests(),r=e.maxErrorsToSend(t),n=t.failedRequests.slice(0,2*r).join(Q.VALUE_SEPARATOR),o=t.errors.slice(0,r).join(Q.VALUE_SEPARATOR),i=t.errors.length,s=[i,r>>6),i[s++]=128+(63&t)):t<65536?(i[s++]=224+(t>>>12),i[s++]=128+(t>>>6&63),i[s++]=128+(63&t)):t<2097152?(i[s++]=240+(t>>>18),i[s++]=128+(t>>>12&63),i[s++]=128+(t>>>6&63),i[s++]=128+(63&t)):t<67108864?(i[s++]=248+(t>>>24),i[s++]=128+(t>>>18&63),i[s++]=128+(t>>>12&63),i[s++]=128+(t>>>6&63),i[s++]=128+(63&t)):(i[s++]=252+(t>>>30),i[s++]=128+(t>>>24&63),i[s++]=128+(t>>>18&63),i[s++]=128+(t>>>12&63),i[s++]=128+(t>>>6&63),i[s++]=128+(63&t));return i},e.stringToArrayBuffer=function(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n251&&r<254&&o+5247&&r<252&&o+4239&&r<248&&o+3223&&r<240&&o+2191&&r<224&&o+1>>n&24),2!==n&&e.length-s!=1||(r+=String.fromCharCode(this.uint6ToB64(i>>>18&63),this.uint6ToB64(i>>>12&63),this.uint6ToB64(i>>>6&63),this.uint6ToB64(63&i)),i=0);return 0===t?r:r.substring(0,r.length-t)+(1===t?"=":"==")},e.prototype.uint6ToB64=function(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65},e}(),yr=function(){function e(){}return e.prototype.decode=function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("Invalid base64 string")}var r=this.base64DecToArr(t);return fr.utf8ArrToString(r)},e.prototype.base64DecToArr=function(e,t){for(var r=e.replace(/[^A-Za-z0-9\+\/]/g,""),n=r.length,o=t?Math.ceil((3*n+1>>>2)/t)*t:3*n+1>>>2,i=new Uint8Array(o),s=void 0,a=void 0,c=0,u=0,d=0;d>>(16>>>s&24)&255;c=0}return i},e.prototype.b64ToUint6=function(e){return e>64&&e<91?e-65:e>96&&e<123?e-71:e>47&&e<58?e+4:43===e?62:47===e?63:0},e}(),mr={pkceNotGenerated:{code:"pkce_not_created",desc:"The PKCE code challenge and verifier could not be generated."},cryptoDoesNotExist:{code:"crypto_nonexistent",desc:"The crypto object or function is not available."},httpMethodNotImplementedError:{code:"http_method_not_implemented",desc:"The HTTP method given has not been implemented in this library."},emptyNavigateUriError:{code:"empty_navigate_uri",desc:"Navigation URI is empty. Please check stack trace for more info."},hashEmptyError:{code:"hash_empty_error",desc:"Hash value cannot be processed because it is empty."},interactionInProgress:{code:"interaction_in_progress",desc:"Interaction is currently in progress. Please ensure that this interaction has been completed before calling an interactive API."},popUpWindowError:{code:"popup_window_error",desc:"Error opening popup window. This can happen if you are using IE or if popups are blocked in the browser."},emptyWindowError:{code:"empty_window_error",desc:"window.open returned null or undefined window object."},userCancelledError:{code:"user_cancelled",desc:"User cancelled the flow."},monitorPopupTimeoutError:{code:"monitor_window_timeout",desc:"Token acquisition in popup failed due to timeout."},monitorIframeTimeoutError:{code:"monitor_window_timeout",desc:"Token acquisition in iframe failed due to timeout."},redirectInIframeError:{code:"redirect_in_iframe",desc:"Code flow is not supported inside an iframe. Please ensure you are using MSAL.js in a top frame of the window if using the redirect APIs, or use the popup APIs."},blockTokenRequestsInHiddenIframeError:{code:"block_iframe_reload",desc:"Request was blocked inside an iframe because MSAL detected an authentication response. Please ensure monitorWindowForHash was called."},iframeClosedPrematurelyError:{code:"iframe_closed_prematurely",desc:"The iframe being monitored was closed prematurely."},silentSSOInsufficientInfoError:{code:"silent_sso_error",desc:"Silent SSO could not be completed - insufficient information was provided. Please provide either a loginHint or sid."},silentPromptValueError:{code:"silent_prompt_value_error",desc:"The value given for the prompt value is not valid for silent requests - must be set to 'none'."},tokenRequestCacheError:{code:"token_request_cache_error",desc:"The token request could not be fetched from the cache correctly."},invalidCacheType:{code:"invalid_cache_type",desc:"Invalid cache type"},notInBrowserEnvironment:{code:"non_browser_environment",desc:"Login and token requests are not supported in non-browser environments."}},vr=function(e){function t(r,n){var o=e.call(this,r,n)||this;return Object.setPrototypeOf(o,t.prototype),o.name="BrowserAuthError",o}return o(t,e),t.createPkceNotGeneratedError=function(e){return new t(mr.pkceNotGenerated.code,mr.pkceNotGenerated.desc+" Detail:"+e)},t.createCryptoNotAvailableError=function(e){return new t(mr.cryptoDoesNotExist.code,mr.cryptoDoesNotExist.desc+" Detail:"+e)},t.createHttpMethodNotImplementedError=function(e){return new t(mr.httpMethodNotImplementedError.code,mr.httpMethodNotImplementedError.desc+" Given Method: "+e)},t.createEmptyNavigationUriError=function(){return new t(mr.emptyNavigateUriError.code,mr.emptyNavigateUriError.desc)},t.createEmptyHashError=function(e){return new t(mr.hashEmptyError.code,mr.hashEmptyError.desc+" Given Url: "+e)},t.createInteractionInProgressError=function(){return new t(mr.interactionInProgress.code,mr.interactionInProgress.desc)},t.createPopupWindowError=function(e){var r=mr.popUpWindowError.desc;return r=Fe.isEmpty(e)?r:r+" Details: "+e,new t(mr.popUpWindowError.code,r)},t.createEmptyWindowCreatedError=function(){return new t(mr.emptyWindowError.code,mr.emptyWindowError.desc)},t.createUserCancelledError=function(){return new t(mr.userCancelledError.code,mr.userCancelledError.desc)},t.createMonitorPopupTimeoutError=function(){return new t(mr.monitorPopupTimeoutError.code,mr.monitorPopupTimeoutError.desc)},t.createMonitorIframeTimeoutError=function(){return new t(mr.monitorIframeTimeoutError.code,mr.monitorIframeTimeoutError.desc)},t.createRedirectInIframeError=function(e){return new t(mr.redirectInIframeError.code,mr.redirectInIframeError.desc+" (window.parent !== window) => "+e)},t.createBlockReloadInHiddenIframeError=function(){return new t(mr.blockTokenRequestsInHiddenIframeError.code,mr.blockTokenRequestsInHiddenIframeError.desc)},t.createIframeClosedPrematurelyError=function(){return new t(mr.iframeClosedPrematurelyError.code,mr.iframeClosedPrematurelyError.desc)},t.createSilentSSOInsufficientInfoError=function(){return new t(mr.silentSSOInsufficientInfoError.code,mr.silentSSOInsufficientInfoError.desc)},t.createSilentPromptValueError=function(e){return new t(mr.silentPromptValueError.code,mr.silentPromptValueError.desc+" Given value: "+e)},t.createTokenRequestCacheError=function(e){return new t(mr.tokenRequestCacheError.code,mr.tokenRequestCacheError.desc+" Error Detail: "+e)},t.createInvalidCacheTypeError=function(){return new t(mr.invalidCacheType.code,""+mr.invalidCacheType.desc)},t.createNonBrowserEnvironmentError=function(){return new t(mr.notInBrowserEnvironment.code,mr.notInBrowserEnvironment.desc)},t}(ne),Er=function(){function e(e){this.base64Encode=new gr,this.cryptoObj=e}return e.prototype.generateCodes=function(){return s(this,void 0,void 0,(function(){var e,t;return a(this,(function(r){switch(r.label){case 0:return e=this.generateCodeVerifier(),[4,this.generateCodeChallengeFromVerifier(e)];case 1:return t=r.sent(),[2,{verifier:e,challenge:t}]}}))}))},e.prototype.generateCodeVerifier=function(){try{var e=new Uint8Array(32);return this.cryptoObj.getRandomValues(e),this.base64Encode.urlEncodeArr(e)}catch(e){throw vr.createPkceNotGeneratedError(e)}},e.prototype.generateCodeChallengeFromVerifier=function(e){return s(this,void 0,void 0,(function(){var t,r;return a(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.cryptoObj.sha256Digest(e)];case 1:return t=n.sent(),[2,this.base64Encode.urlEncodeArr(new Uint8Array(t))];case 2:throw r=n.sent(),vr.createPkceNotGeneratedError(r);case 3:return[2]}}))}))},e}(),Cr=new Uint8Array([1,0,1]),Tr=function(){function e(){if(!this.hasCryptoAPI())throw vr.createCryptoNotAvailableError("Browser crypto or msCrypto object not available.");this._keygenAlgorithmOptions={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",modulusLength:2048,publicExponent:Cr}}return e.prototype.sha256Digest=function(e){return s(this,void 0,void 0,(function(){var t;return a(this,(function(r){return t=fr.stringToUtf8Arr(e),[2,this.hasIECrypto()?this.getMSCryptoDigest("SHA-256",t):this.getSubtleCryptoDigest("SHA-256",t)]}))}))},e.prototype.getRandomValues=function(e){var t=window.msCrypto||window.crypto;if(!t.getRandomValues)throw vr.createCryptoNotAvailableError("getRandomValues does not exist.");t.getRandomValues(e)},e.prototype.generateKeyPair=function(e,t){return s(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.hasIECrypto()?this.msCryptoGenerateKey(e,t):window.crypto.subtle.generateKey(this._keygenAlgorithmOptions,e,t)]}))}))},e.prototype.exportJwk=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.hasIECrypto()?this.msCryptoExportJwk(e):window.crypto.subtle.exportKey("jwk",e)]}))}))},e.prototype.importJwk=function(t,r,n){return s(this,void 0,void 0,(function(){var o,i;return a(this,(function(s){return o=e.getJwkString(t),i=fr.stringToArrayBuffer(o),[2,this.hasIECrypto()?this.msCryptoImportKey(i,r,n):window.crypto.subtle.importKey("jwk",t,this._keygenAlgorithmOptions,r,n)]}))}))},e.prototype.sign=function(e,t){return s(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.hasIECrypto()?this.msCryptoSign(e,t):window.crypto.subtle.sign(this._keygenAlgorithmOptions,e,t)]}))}))},e.prototype.hasCryptoAPI=function(){return this.hasIECrypto()||this.hasBrowserCrypto()},e.prototype.hasIECrypto=function(){return"msCrypto"in window},e.prototype.hasBrowserCrypto=function(){return"crypto"in window},e.prototype.getSubtleCryptoDigest=function(e,t){return s(this,void 0,void 0,(function(){return a(this,(function(r){return[2,window.crypto.subtle.digest(e,t)]}))}))},e.prototype.getMSCryptoDigest=function(e,t){return s(this,void 0,void 0,(function(){return a(this,(function(r){return[2,new Promise((function(r,n){var o=window.msCrypto.subtle.digest(e,t.buffer);o.addEventListener("complete",(function(e){r(e.target.result)})),o.addEventListener("error",(function(e){n(e)}))}))]}))}))},e.prototype.msCryptoGenerateKey=function(e,t){return s(this,void 0,void 0,(function(){var r=this;return a(this,(function(n){return[2,new Promise((function(n,o){var i=window.msCrypto.subtle.generateKey(r._keygenAlgorithmOptions,e,t);i.addEventListener("complete",(function(e){n(e.target.result)})),i.addEventListener("error",(function(e){o(e)}))}))]}))}))},e.prototype.msCryptoExportJwk=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,new Promise((function(t,r){var n=window.msCrypto.subtle.exportKey("jwk",e);n.addEventListener("complete",(function(e){var n=e.target.result,o=fr.utf8ArrToString(new Uint8Array(n)).replace(/\r/g,"").replace(/\n/g,"").replace(/\t/g,"").split(" ").join("").replace("\0","");try{t(JSON.parse(o))}catch(e){r(e)}})),n.addEventListener("error",(function(e){r(e)}))}))]}))}))},e.prototype.msCryptoImportKey=function(e,t,r){return s(this,void 0,void 0,(function(){var n=this;return a(this,(function(o){return[2,new Promise((function(o,i){var s=window.msCrypto.subtle.importKey("jwk",e,n._keygenAlgorithmOptions,t,r);s.addEventListener("complete",(function(e){o(e.target.result)})),s.addEventListener("error",(function(e){i(e)}))}))]}))}))},e.prototype.msCryptoSign=function(e,t){return s(this,void 0,void 0,(function(){var r=this;return a(this,(function(n){return[2,new Promise((function(n,o){var i=window.msCrypto.subtle.sign(r._keygenAlgorithmOptions,e,t);i.addEventListener("complete",(function(e){n(e.target.result)})),i.addEventListener("error",(function(e){o(e)}))}))]}))}))},e.getJwkString=function(e){return JSON.stringify(e,Object.keys(e).sort())},e}(),wr=function(){function e(e,t,r){this.dbName=e,this.tableName=t,this.version=r,this.dbOpen=!1}return e.prototype.open=function(){return s(this,void 0,void 0,(function(){var e=this;return a(this,(function(t){return[2,new Promise((function(t,r){var n=window.indexedDB.open(e.dbName,e.version);n.addEventListener("upgradeneeded",(function(t){t.target.result.createObjectStore(e.tableName)})),n.addEventListener("success",(function(r){e.db=r.target.result,e.dbOpen=!0,t()})),n.addEventListener("error",(function(e){return r(e)}))}))]}))}))},e.prototype.get=function(e){return s(this,void 0,void 0,(function(){var t=this;return a(this,(function(r){switch(r.label){case 0:return this.dbOpen?[3,2]:[4,this.open()];case 1:r.sent(),r.label=2;case 2:return[2,new Promise((function(r,n){var o=t.db.transaction([t.tableName],"readonly").objectStore(t.tableName).get(e);o.addEventListener("success",(function(e){return r(e.target.result)})),o.addEventListener("error",(function(e){return n(e)}))}))]}}))}))},e.prototype.put=function(e,t){return s(this,void 0,void 0,(function(){var r=this;return a(this,(function(n){switch(n.label){case 0:return this.dbOpen?[3,2]:[4,this.open()];case 1:n.sent(),n.label=2;case 2:return[2,new Promise((function(n,o){var i=r.db.transaction([r.tableName],"readwrite").objectStore(r.tableName).put(t,e);i.addEventListener("success",(function(e){return n(e.target.result)})),i.addEventListener("error",(function(e){return o(e)}))}))]}}))}))},e}(),Sr=function(){function e(){this.browserCrypto=new Tr,this.b64Encode=new gr,this.b64Decode=new yr,this.guidGenerator=new pr(this.browserCrypto),this.pkceGenerator=new Er(this.browserCrypto),this.cache=new wr(e.DB_NAME,e.TABLE_NAME,e.DB_VERSION)}return e.prototype.createNewGuid=function(){return this.guidGenerator.generateGuid()},e.prototype.base64Encode=function(e){return this.b64Encode.encode(e)},e.prototype.base64Decode=function(e){return this.b64Decode.decode(e)},e.prototype.generatePkceCodes=function(){return s(this,void 0,void 0,(function(){return a(this,(function(e){return[2,this.pkceGenerator.generateCodes()]}))}))},e.prototype.getPublicKeyThumbprint=function(t,r){return s(this,void 0,void 0,(function(){var n,o,i,s,c,u,d,h;return a(this,(function(a){switch(a.label){case 0:return[4,this.browserCrypto.generateKeyPair(e.EXTRACTABLE,e.POP_KEY_USAGES)];case 1:return n=a.sent(),[4,this.browserCrypto.exportJwk(n.publicKey)];case 2:return o=a.sent(),i={e:o.e,kty:o.kty,n:o.n},s=Tr.getJwkString(i),[4,this.browserCrypto.sha256Digest(s)];case 3:return c=a.sent(),u=this.b64Encode.urlEncodeArr(new Uint8Array(c)),[4,this.browserCrypto.exportJwk(n.privateKey)];case 4:return d=a.sent(),[4,this.browserCrypto.importJwk(d,!1,["sign"])];case 5:return h=a.sent(),this.cache.put(u,{privateKey:h,publicKey:n.publicKey,requestMethod:t,requestUri:r}),[2,u]}}))}))},e.prototype.signJwt=function(e,t){return s(this,void 0,void 0,(function(){var r,n,o,i,s,c,u,d,h,l;return a(this,(function(a){switch(a.label){case 0:return[4,this.cache.get(t)];case 1:return r=a.sent(),[4,this.browserCrypto.exportJwk(r.publicKey)];case 2:return n=a.sent(),o=Tr.getJwkString(n),i={alg:n.alg,type:"jwk"},s=this.b64Encode.urlEncode(JSON.stringify(i)),e.cnf={jwk:JSON.parse(o)},c=this.b64Encode.urlEncode(JSON.stringify(e)),u=s+"."+c,d=fr.stringToArrayBuffer(u),[4,this.browserCrypto.sign(r.privateKey,d)];case 3:return h=a.sent(),l=this.b64Encode.urlEncodeArr(new Uint8Array(h)),[2,u+"."+l]}}))}))},e.POP_KEY_USAGES=["sign","verify"],e.EXTRACTABLE=!0,e.DB_VERSION=1,e.DB_NAME="msal.db",e.TABLE_NAME=e.DB_NAME+".keys",e}(),Ir={redirectUriNotSet:{code:"redirect_uri_empty",desc:"A redirect URI is required for all calls, and none has been set."},postLogoutUriNotSet:{code:"post_logout_uri_empty",desc:"A post logout redirect has not been set."},storageNotSupportedError:{code:"storage_not_supported",desc:"Given storage configuration option was not supported."},noRedirectCallbacksSet:{code:"no_redirect_callbacks",desc:"No redirect callbacks have been set. Please call setRedirectCallbacks() with the appropriate function arguments before continuing. More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics."},invalidCallbackObject:{code:"invalid_callback_object",desc:"The object passed for the callback was invalid. More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics."},stubPcaInstanceCalled:{code:"stubbed_public_client_application_called",desc:"Stub instance of Public Client Application was called. If using msal-react, please ensure context is not used without a provider."},inMemRedirectUnavailable:{code:"in_mem_redirect_unavailable",desc:"Redirect cannot be supported. In-memory storage was selected and storeAuthStateInCookie=false, which would cause the library to be unable to handle the incoming hash. If you would like to use the redirect API, please use session/localStorage or set storeAuthStateInCookie=true."}},Ar=function(e){function t(r,n){var o=e.call(this,r,n)||this;return o.name="BrowserConfigurationAuthError",Object.setPrototypeOf(o,t.prototype),o}return o(t,e),t.createRedirectUriEmptyError=function(){return new t(Ir.redirectUriNotSet.code,Ir.redirectUriNotSet.desc)},t.createPostLogoutRedirectUriEmptyError=function(){return new t(Ir.postLogoutUriNotSet.code,Ir.postLogoutUriNotSet.desc)},t.createStorageNotSupportedError=function(e){return new t(Ir.storageNotSupportedError.code,Ir.storageNotSupportedError.desc+" Given Location: "+e)},t.createInvalidCallbackObjectError=function(e){return new t(Ir.invalidCallbackObject.code,Ir.invalidCallbackObject.desc+" Given value for callback function: "+e)},t.createRedirectCallbacksNotSetError=function(){return new t(Ir.noRedirectCallbacksSet.code,Ir.noRedirectCallbacksSet.desc)},t.createStubPcaInstanceCalledError=function(){return new t(Ir.stubPcaInstanceCalled.code,Ir.stubPcaInstanceCalled.desc)},t.createInMemoryRedirectUnavailableError=function(){return new t(Ir.inMemRedirectUnavailable.code,Ir.inMemRedirectUnavailable.desc)},t}(ne),_r=function(){function e(e){this.validateWindowStorage(e),this.cacheLocation=e}return Object.defineProperty(e.prototype,"windowStorage",{get:function(){return this._windowStorage||(this._windowStorage=window[this.cacheLocation]),this._windowStorage},enumerable:!0,configurable:!0}),e.prototype.validateWindowStorage=function(e){if(e!==Gt.LocalStorage&&e!==Gt.SessionStorage)throw Ar.createStorageNotSupportedError(e);if(!!!window[e])throw Ar.createStorageNotSupportedError(e)},e.prototype.getItem=function(e){return this.windowStorage.getItem(e)},e.prototype.setItem=function(e,t){this.windowStorage.setItem(e,t)},e.prototype.removeItem=function(e){this.windowStorage.removeItem(e)},e.prototype.getKeys=function(){return Object.keys(this.windowStorage)},e.prototype.containsKey=function(e){return this.windowStorage.hasOwnProperty(e)},e}(),Rr=function(){function e(){this.cache=new Map}return e.prototype.getItem=function(e){return this.cache.get(e)||null},e.prototype.setItem=function(e,t){this.cache.set(e,t)},e.prototype.removeItem=function(e){this.cache.delete(e)},e.prototype.getKeys=function(){var e=[];return this.cache.forEach((function(t,r){e.push(r)})),e},e.prototype.containsKey=function(e){return this.cache.has(e)},e}(),br=function(){function e(){}return e.extractBrowserRequestState=function(e,t){if(Fe.isEmpty(t))return null;try{return jt.parseRequestState(e,t).libraryState.meta}catch(e){throw xe.createInvalidStateError(t,e)}},e.parseServerResponseFromHash=function(e){if(!e)return{};var t=new pt(e);return pt.getDeserializedHash(t.getHash())},e}(),Or=function(e){function t(t,r,n,o){var i=e.call(this,t,n)||this;return i.COOKIE_LIFE_MULTIPLIER=864e5,i.cacheConfig=r,i.logger=o,i.browserStorage=i.setupBrowserStorage(r.cacheLocation),i.migrateCacheEntries(),i}return o(t,e),t.prototype.setupBrowserStorage=function(e){switch(e){case Gt.LocalStorage:case Gt.SessionStorage:try{return new _r(e)}catch(e){return this.logger.verbose(e),this.cacheConfig.cacheLocation=Gt.MemoryStorage,new Rr}case Gt.MemoryStorage:default:return new Rr}},t.prototype.migrateCacheEntries=function(){var e=this,t=w+"."+y.ID_TOKEN,r=w+"."+y.CLIENT_INFO,n=w+"."+y.ERROR,o=w+"."+y.ERROR_DESC,i=[this.browserStorage.getItem(t),this.browserStorage.getItem(r),this.browserStorage.getItem(n),this.browserStorage.getItem(o)];[y.ID_TOKEN,y.CLIENT_INFO,y.ERROR,y.ERROR_DESC].forEach((function(t,r){return e.migrateCacheEntry(t,i[r])}))},t.prototype.migrateCacheEntry=function(e,t){t&&this.setTemporaryCache(e,t,!0)},t.prototype.validateAndParseJson=function(e){try{var t=JSON.parse(e);return t&&"object"==typeof t?t:null}catch(e){return null}},t.prototype.getItem=function(e){return this.browserStorage.getItem(e)},t.prototype.setItem=function(e,t){this.browserStorage.setItem(e,t)},t.prototype.getAccount=function(e){var t=this.getItem(e);if(Fe.isEmpty(t))return null;var r=this.validateAndParseJson(t),n=Et.toObject(new mt,r);return mt.isAccountEntity(n)?n:null},t.prototype.setAccount=function(e){var t=e.generateAccountKey();this.setItem(t,JSON.stringify(e))},t.prototype.getIdTokenCredential=function(e){var t=this.getItem(e);if(Fe.isEmpty(t))return null;var r=this.validateAndParseJson(t),n=Et.toObject(new qt,r);return qt.isIdTokenEntity(n)?n:null},t.prototype.setIdTokenCredential=function(e){var t=e.generateCredentialKey();this.setItem(t,JSON.stringify(e))},t.prototype.getAccessTokenCredential=function(e){var t=this.getItem(e);if(Fe.isEmpty(t))return null;var r=this.validateAndParseJson(t),n=Et.toObject(new Lt,r);return Lt.isAccessTokenEntity(n)?n:null},t.prototype.setAccessTokenCredential=function(e){var t=e.generateCredentialKey();this.setItem(t,JSON.stringify(e))},t.prototype.getRefreshTokenCredential=function(e){var t=this.getItem(e);if(Fe.isEmpty(t))return null;var r=this.validateAndParseJson(t),n=Et.toObject(new Dt,r);return Dt.isRefreshTokenEntity(n)?n:null},t.prototype.setRefreshTokenCredential=function(e){var t=e.generateCredentialKey();this.setItem(t,JSON.stringify(e))},t.prototype.getAppMetadata=function(e){var t=this.getItem(e);if(Fe.isEmpty(t))return null;var r=this.validateAndParseJson(t),n=Et.toObject(new Vt,r);return Vt.isAppMetadataEntity(e,n)?n:null},t.prototype.setAppMetadata=function(e){var t=e.generateAppMetadataKey();this.setItem(t,JSON.stringify(e))},t.prototype.getServerTelemetry=function(e){var t=this.getItem(e);if(Fe.isEmpty(t))return null;var r=this.validateAndParseJson(t),n=Et.toObject(new rr,r);return rr.isServerTelemetryEntity(e,n)?n:null},t.prototype.setServerTelemetry=function(e,t){this.setItem(e,JSON.stringify(t))},t.prototype.getThrottlingCache=function(e){var t=this.getItem(e);if(Fe.isEmpty(t))return null;var r=this.validateAndParseJson(t),n=Et.toObject(new nr,r);return nr.isThrottlingEntity(e,n)?n:null},t.prototype.setThrottlingCache=function(e,t){this.setItem(e,JSON.stringify(t))},t.prototype.getTemporaryCache=function(e,t){var r=t?this.generateCacheKey(e):e;if(this.cacheConfig.storeAuthStateInCookie){var n=this.getItemCookie(r);if(n)return n}var o=this.getItem(r);return Fe.isEmpty(o)?null:o},t.prototype.setTemporaryCache=function(e,t,r){var n=r?this.generateCacheKey(e):e;this.setItem(n,t),this.cacheConfig.storeAuthStateInCookie&&this.setItemCookie(n,t)},t.prototype.removeItem=function(e){return this.browserStorage.removeItem(e),this.cacheConfig.storeAuthStateInCookie&&this.clearItemCookie(e),!0},t.prototype.containsKey=function(e){return this.browserStorage.containsKey(e)},t.prototype.getKeys=function(){return this.browserStorage.getKeys()},t.prototype.clear=function(){var e=this;this.removeAllAccounts(),this.removeAppMetadata(),this.browserStorage.getKeys().forEach((function(t){!e.browserStorage.containsKey(t)||-1===t.indexOf(w)&&-1===t.indexOf(e.clientId)||e.removeItem(t)}))},t.prototype.setItemCookie=function(e,t,r){var n=encodeURIComponent(e)+"="+encodeURIComponent(t)+";path=/;";r&&(n+="expires="+this.getCookieExpirationTime(r)+";");document.cookie=n},t.prototype.getItemCookie=function(e){for(var t=encodeURIComponent(e)+"=",r=document.cookie.split(";"),n=0;n=300)&&i(s.responseText);try{var e=JSON.parse(s.responseText),t={headers:n.getHeaderDict(s),body:e,status:s.status};o(t)}catch(e){i(s.responseText)}},s.onerror=function(){i(s.status)},"POST"===t&&r.body)s.send(r.body);else{if("GET"!==t)throw vr.createHttpMethodNotImplementedError(t);s.send()}}))},e.prototype.setXhrHeaders=function(e,t){t&&t.headers&&Object.keys(t.headers).forEach((function(r){e.setRequestHeader(r,t.headers[r])}))},e.prototype.getHeaderDict=function(e){var t=e.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};return t.forEach((function(e){var t=e.split(": "),n=t.shift(),o=t.join(": ");r[n]=o})),r},e}(),Pr=function(){function e(){}return e.navigateWindow=function(e,t,r,n){return n?window.location.replace(e):window.location.assign(e),new Promise((function(e){setTimeout((function(){r.warning("Expected to navigate away from the current page but timeout occurred."),e()}),t)}))},e.clearHash=function(){"function"==typeof history.replaceState?history.replaceState(null,null,""+window.location.pathname+window.location.search):window.location.hash=""},e.replaceHash=function(e){var t=e.split("#");t.shift(),window.location.hash=t.length>0?t.join("#"):""},e.isInIframe=function(){return window.parent!==window},e.getCurrentUri=function(){return window.location.href.split("?")[0].split("#")[0]},e.getHomepage=function(){var e=new pt(window.location.href).getUrlComponents();return e.Protocol+"//"+e.HostNameAndPort+"/"},e.getBrowserNetworkClient=function(){return window.fetch&&window.Headers?new kr:new Nr},e.blockReloadInHiddenIframes=function(){if(pt.hashContainsKnownProperties(window.location.hash)&&e.isInIframe())throw vr.createBlockReloadInHiddenIframeError()},e.blockRedirectInIframe=function(t,r){var n=e.isInIframe();if(t===Jt.Redirect&&n&&!r)throw vr.createRedirectInIframeError(n)},e.blockNonBrowserEnvironment=function(e){if(!e)throw vr.createNonBrowserEnvironmentError()},e.detectIEOrEdge=function(){var e=window.navigator.userAgent,t=e.indexOf("MSIE "),r=e.indexOf("Trident/"),n=e.indexOf("Edge/");return t>0||r>0||n>0},e}();var Ur,Mr=function(){function e(e,t){this.authModule=e,this.browserStorage=t}return e.prototype.handleCodeResponse=function(e,t,r){return s(this,void 0,void 0,(function(){var n,o,i,s,c,u,d;return a(this,(function(a){switch(a.label){case 0:if(Fe.isEmpty(e))throw vr.createEmptyHashError(e);return n=br.parseServerResponseFromHash(e),o=this.browserStorage.generateStateKey(n.state),i=this.browserStorage.getTemporaryCache(o),s=this.authModule.handleFragmentResponse(e,i),c=this.browserStorage.generateNonceKey(i),u=this.browserStorage.getTemporaryCache(c),this.authCodeRequest.code=s.code,s.cloud_instance_host_name?[4,this.updateTokenEndpointAuthority(s.cloud_instance_host_name,t,r)]:[3,2];case 1:a.sent(),a.label=2;case 2:return s.nonce=u,s.state=i,[4,this.authModule.acquireToken(this.authCodeRequest,s)];case 3:return d=a.sent(),this.browserStorage.cleanRequestByState(n.state),[2,d]}}))}))},e.prototype.updateTokenEndpointAuthority=function(e,t,r){return s(this,void 0,void 0,(function(){var n,o;return a(this,(function(i){switch(i.label){case 0:return t.isAuthorityAlias(e)?[3,2]:(n="https://"+e+"/"+t.tenant+"/",[4,tr.createDiscoveredInstance(n,r,t.protocolMode)]);case 1:o=i.sent(),this.authModule.updateAuthority(o),i.label=2;case 2:return[2]}}))}))},e}(),qr=function(e){function t(t,r,n){var o=e.call(this,t,r)||this;return o.browserCrypto=n,o}return o(t,e),t.prototype.initiateAuthRequest=function(e,t,r){if(Fe.isEmpty(e))throw this.authModule.logger.info("Navigate url is empty"),vr.createEmptyNavigationUriError();return r.redirectStartPage&&this.browserStorage.setTemporaryCache(zt.ORIGIN_URI,r.redirectStartPage,!0),this.browserStorage.setTemporaryCache(zt.INTERACTION_STATUS_KEY,ir,!0),this.browserStorage.cacheCodeRequest(t,this.browserCrypto),this.authModule.logger.infoPii("Navigate to:"+e),"function"==typeof r.onRedirectNavigate?(this.authModule.logger.verbose("Invoking onRedirectNavigate callback"),!1!==r.onRedirectNavigate(e)?(this.authModule.logger.verbose("onRedirectNavigate did not return false, navigating"),Pr.navigateWindow(e,r.redirectTimeout,this.authModule.logger)):(this.authModule.logger.verbose("onRedirectNavigate returned false, stopping navigation"),Promise.resolve())):(this.authModule.logger.verbose("Navigating window to navigate url"),Pr.navigateWindow(e,r.redirectTimeout,this.authModule.logger))},t.prototype.handleCodeResponse=function(e,t,r,n){return s(this,void 0,void 0,(function(){var o,i,s,c,u,d,h;return a(this,(function(a){switch(a.label){case 0:if(Fe.isEmpty(e))throw vr.createEmptyHashError(e);return this.browserStorage.removeItem(this.browserStorage.generateCacheKey(zt.INTERACTION_STATUS_KEY)),o=br.parseServerResponseFromHash(e),i=this.browserStorage.generateStateKey(o.state),s=this.browserStorage.getTemporaryCache(i),c=this.authModule.handleFragmentResponse(e,s),u=this.browserStorage.generateNonceKey(s),d=this.browserStorage.getTemporaryCache(u),this.authCodeRequest=this.browserStorage.getCachedRequest(s,this.browserCrypto),this.authCodeRequest.code=c.code,c.cloud_instance_host_name?[4,this.updateTokenEndpointAuthority(c.cloud_instance_host_name,t,r)]:[3,2];case 1:a.sent(),a.label=2;case 2:return c.nonce=d,c.state=s,n&&Ot.removeThrottle(this.browserStorage,n,this.authCodeRequest.authority,this.authCodeRequest.scopes),[4,this.authModule.acquireToken(this.authCodeRequest,c)];case 3:return h=a.sent(),this.browserStorage.cleanRequestByState(o.state),[2,h]}}))}))},t}(Mr),Lr=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.unloadWindow=n.unloadWindow.bind(n),n}return o(t,e),t.prototype.initiateAuthRequest=function(e,t,r){if(Fe.isEmpty(e))throw this.authModule.logger.error("Navigate url is empty"),vr.createEmptyNavigationUriError();return this.authCodeRequest=t,this.browserStorage.setTemporaryCache(zt.INTERACTION_STATUS_KEY,ir,!0),this.authModule.logger.infoPii("Navigate to:"+e),this.openPopup(e,r.popup)},t.prototype.monitorPopupForHash=function(e,t){var r=this;return new Promise((function(n,o){t<6e4&&r.authModule.logger.warning("system.loadFrameTimeout or system.windowHashTimeout set to lower ("+t+"ms) than the default (60000ms). This may result in timeouts.");var i=t/ur,s=0,a=setInterval((function(){if(e.closed)return r.cleanPopup(),clearInterval(a),void o(vr.createUserCancelledError());var t;try{t=e.location.href}catch(e){}if(!Fe.isEmpty(t)&&"about:blank"!==t){s++;var c=e.location.hash;return pt.hashContainsKnownProperties(c)?(r.cleanPopup(e),clearInterval(a),void n(c)):s>i?(r.cleanPopup(e),clearInterval(a),void o(vr.createMonitorPopupTimeoutError())):void 0}}),ur)}))},t.prototype.openPopup=function(e,r){try{var n=void 0;if(r?(n=r).location.assign(e):void 0===r&&(n=t.openSizedPopup(e)),!n)throw vr.createEmptyWindowCreatedError();return n.focus&&n.focus(),this.currentWindow=n,window.addEventListener("beforeunload",this.unloadWindow),n}catch(e){throw this.authModule.logger.error("error opening popup "+e.message),this.browserStorage.removeItem(this.browserStorage.generateCacheKey(zt.INTERACTION_STATUS_KEY)),vr.createPopupWindowError(e.toString())}},t.openSizedPopup=function(e){void 0===e&&(e="about:blank");var t=window.screenLeft?window.screenLeft:window.screenX,r=window.screenTop?window.screenTop:window.screenY,n=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,o=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,i=Math.max(0,n/2-ar/2+t),s=Math.max(0,o/2-cr/2+r);return window.open(e,C,"width="+ar+", height="+cr+", top="+s+", left="+i)},t.prototype.unloadWindow=function(e){this.browserStorage.cleanRequestByInteractionType(Jt.Popup),this.currentWindow.close(),delete e.returnValue},t.prototype.cleanPopup=function(e){e&&e.close(),window.removeEventListener("beforeunload",this.unloadWindow),this.browserStorage.removeItem(this.browserStorage.generateCacheKey(zt.INTERACTION_STATUS_KEY))},t}(Mr),Dr=function(e){function t(t,r,n){var o=e.call(this,t,r)||this;return o.navigateFrameWait=n,o}return o(t,e),t.prototype.initiateAuthRequest=function(e,t){return s(this,void 0,void 0,(function(){var r;return a(this,(function(n){switch(n.label){case 0:if(Fe.isEmpty(e))throw this.authModule.logger.info("Navigate url is empty"),vr.createEmptyNavigationUriError();return this.authCodeRequest=t,this.navigateFrameWait?[4,this.loadFrame(e)]:[3,2];case 1:return r=n.sent(),[3,3];case 2:r=this.loadFrameSync(e),n.label=3;case 3:return[2,r]}}))}))},t.prototype.monitorIframeForHash=function(e,t){var r=this;return new Promise((function(n,o){t<6e3&&r.authModule.logger.warning("system.loadFrameTimeout or system.iframeHashTimeout set to lower ("+t+"ms) than the default (6000ms). This may result in timeouts.");var i=window.performance.now()+t,s=setInterval((function(){if(window.performance.now()>i)return r.removeHiddenIframe(e),clearInterval(s),void o(vr.createMonitorIframeTimeoutError());var t;try{t=e.contentWindow.location.href}catch(e){}if(!Fe.isEmpty(t)){var a=e.contentWindow.location.hash;return pt.hashContainsKnownProperties(a)?(r.removeHiddenIframe(e),clearInterval(s),void n(a)):void 0}}),ur)}))},t.prototype.loadFrame=function(e){var t=this;return new Promise((function(r,n){var o=t.createHiddenIframe();setTimeout((function(){o?(o.src=e,r(o)):n("Unable to load iframe")}),t.navigateFrameWait)}))},t.prototype.loadFrameSync=function(e){var t=this.createHiddenIframe();return t.src=e,t},t.prototype.createHiddenIframe=function(){var e=document.createElement("iframe");return e.style.visibility="hidden",e.style.position="absolute",e.style.width=e.style.height="0",e.style.border="0",e.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms"),document.getElementsByTagName("body")[0].appendChild(e),e},t.prototype.removeHiddenIframe=function(e){document.body===e.parentNode&&document.body.removeChild(e)},t}(Mr);!function(e){e.LOGIN_START="msal:loginStart",e.LOGIN_SUCCESS="msal:loginSuccess",e.LOGIN_FAILURE="msal:loginFailure",e.ACQUIRE_TOKEN_START="msal:acquireTokenStart",e.ACQUIRE_TOKEN_SUCCESS="msal:acquireTokenSuccess",e.ACQUIRE_TOKEN_FAILURE="msal:acquireTokenFailure",e.ACQUIRE_TOKEN_NETWORK_START="msal:acquireTokenFromNetworkStart",e.SSO_SILENT_START="msal:ssoSilentStart",e.SSO_SILENT_SUCCESS="msal:ssoSilentSuccess",e.SSO_SILENT_FAILURE="msal:ssoSilentFailure",e.HANDLE_REDIRECT_START="msal:handleRedirectStart",e.HANDLE_REDIRECT_END="msal:handleRedirectEnd",e.LOGOUT_START="msal:logoutStart",e.LOGOUT_SUCCESS="msal:logoutSuccess",e.LOGOUT_FAILURE="msal:logoutFailure"}(Ur||(Ur={}));var Hr=function(e){function t(t){return e.call(this,t)||this}return o(t,e),t.prototype.loginRedirect=function(e){return s(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.acquireTokenRedirect(e||hr)]}))}))},t.prototype.loginPopup=function(e){return this.acquireTokenPopup(e||hr)},t.prototype.acquireTokenSilent=function(e){return s(this,void 0,void 0,(function(){var t,r,n,o,s;return a(this,(function(a){switch(a.label){case 0:this.preflightBrowserEnvironmentCheck(Jt.Silent),t=i(i(i({},e),this.initializeBaseRequest(e)),{forceRefresh:e.forceRefresh||!1}),this.emitEvent(Ur.ACQUIRE_TOKEN_START,Jt.Silent,e),a.label=1;case 1:return a.trys.push([1,4,,9]),r=this.initializeServerTelemetryManager(Wt.acquireTokenSilent_silentFlow,t.correlationId),[4,this.createSilentFlowClient(r,t.authority)];case 2:return[4,a.sent().acquireCachedToken(t)];case 3:return n=a.sent(),this.emitEvent(Ur.ACQUIRE_TOKEN_SUCCESS,Jt.Silent,n),[2,n];case 4:a.sent(),a.label=5;case 5:return a.trys.push([5,7,,8]),[4,this.acquireTokenByRefreshToken(t)];case 6:return o=a.sent(),this.emitEvent(Ur.ACQUIRE_TOKEN_SUCCESS,Jt.Silent,o),[2,o];case 7:throw s=a.sent(),this.emitEvent(Ur.ACQUIRE_TOKEN_FAILURE,Jt.Silent,null,s),s;case 8:return[3,9];case 9:return[2]}}))}))},t}(function(){function e(e){var t,r,n,o,s,a,c,u;(this.isBrowserEnvironment="undefined"!=typeof window,this.isBrowserEnvironment)&&(this.config=(r=(t=e).auth,n=t.cache,o=t.system,s={clientId:"",authority:""+S,knownAuthorities:[],cloudDiscoveryMetadata:"",redirectUri:"",postLogoutRedirectUri:"",navigateToLoginRequestUrl:!0,clientCapabilities:[],protocolMode:lt.AAD},a={cacheLocation:Gt.SessionStorage,storeAuthStateInCookie:!1},c={loggerCallback:function(){},logLevel:te.Info,piiLoggingEnabled:!1},u=i(i({},Tt),{loggerOptions:c,networkClient:Pr.getBrowserNetworkClient(),loadFrameTimeout:0,windowHashTimeout:o&&o.loadFrameTimeout||6e4,iframeHashTimeout:o&&o.loadFrameTimeout||6e3,navigateFrameWait:Pr.detectIEOrEdge()?500:0,redirectNavigationTimeout:3e4,asyncPopups:!1,allowRedirectInIframe:!1}),{auth:i(i({},s),r),cache:i(i({},a),n),system:i(i({},u),o)}),this.browserCrypto=new Sr,this.networkClient=this.config.system.networkClient,this.logger=new Ge(this.config.system.loggerOptions,"@azure/msal-browser","2.8.0"),this.browserStorage=new Or(this.config.auth.clientId,this.config.cache,this.browserCrypto,this.logger),this.eventCallbacks=new Map,ft.setTrustedAuthoritiesFromConfig(this.config.auth.knownAuthorities,this.config.auth.cloudDiscoveryMetadata),this.defaultAuthority=null)}return e.prototype.handleRedirectPromise=function(e){return s(this,void 0,void 0,(function(){var t,r=this;return a(this,(function(n){return this.emitEvent(Ur.HANDLE_REDIRECT_START,Jt.Redirect),t=this.getAllAccounts(),this.isBrowserEnvironment?[2,this.handleRedirectResponse(e).then((function(e){e&&(t.length0?r.emitEvent(Ur.ACQUIRE_TOKEN_FAILURE,Jt.Redirect,null,e):r.emitEvent(Ur.LOGIN_FAILURE,Jt.Redirect,null,e),r.emitEvent(Ur.HANDLE_REDIRECT_END,Jt.Redirect),e}))]:[2,null]}))}))},e.prototype.handleRedirectResponse=function(e){return s(this,void 0,void 0,(function(){var t,r,n,o,i,s;return a(this,(function(a){switch(a.label){case 0:return this.interactionInProgress()?(t=this.getRedirectResponseHash(e||window.location.hash),Fe.isEmpty(t)?[2,null]:(r=this.browserStorage.getTemporaryCache(zt.ORIGIN_URI,!0),n=pt.removeHashFromUrl(r||""),o=pt.removeHashFromUrl(window.location.href),n===o&&this.config.auth.navigateToLoginRequestUrl?[4,this.handleHash(t)]:[3,2])):(this.logger.info("handleRedirectPromise called but there is no interaction in progress, returning null."),[2,null]);case 1:return i=a.sent(),r.indexOf("#")>-1&&Pr.replaceHash(r),[2,i];case 2:return this.config.auth.navigateToLoginRequestUrl?[3,3]:[2,this.handleHash(t)];case 3:return Pr.isInIframe()?[3,7]:(this.browserStorage.setTemporaryCache(zt.URL_HASH,t,!0),r&&"null"!==r?[3,5]:(s=Pr.getHomepage(),this.browserStorage.setTemporaryCache(zt.ORIGIN_URI,s,!0),this.logger.warning("Unable to get valid login request url from cache, redirecting to home page"),[4,Pr.navigateWindow(s,this.config.system.redirectNavigationTimeout,this.logger,!0)]));case 4:return a.sent(),[3,7];case 5:return[4,Pr.navigateWindow(r,this.config.system.redirectNavigationTimeout,this.logger,!0)];case 6:a.sent(),a.label=7;case 7:return[2,null]}}))}))},e.prototype.getRedirectResponseHash=function(e){var t=pt.hashContainsKnownProperties(e),r=this.browserStorage.getTemporaryCache(zt.URL_HASH,!0);this.browserStorage.removeItem(this.browserStorage.generateCacheKey(zt.URL_HASH));var n=t?e:r;if(n){var o=pt.getDeserializedHash(n);return br.extractBrowserRequestState(this.browserCrypto,o.state).interactionType!==Jt.Redirect?null:(Pr.clearHash(),n)}return this.browserStorage.cleanRequestByInteractionType(Jt.Redirect),null},e.prototype.handleHash=function(e){return s(this,void 0,void 0,(function(){var t,r,n,o,i,s,c;return a(this,(function(a){switch(a.label){case 0:t=this.browserStorage.getTemporaryCache(zt.REQUEST_PARAMS,!0),r=JSON.parse(this.browserCrypto.base64Decode(t)),n=this.initializeServerTelemetryManager(Wt.handleRedirectPromise,r.correlationId),o=br.parseServerResponseFromHash(e),a.label=1;case 1:return a.trys.push([1,4,,5]),i=this.browserStorage.getCachedAuthority(o.state),[4,this.createAuthCodeClient(n,i)];case 2:return s=a.sent(),[4,new qr(s,this.browserStorage,this.browserCrypto).handleCodeResponse(e,s.authority,this.networkClient,this.config.auth.clientId)];case 3:return[2,a.sent()];case 4:throw c=a.sent(),n.cacheFailedRequest(c),this.browserStorage.cleanRequestByInteractionType(Jt.Redirect),c;case 5:return[2]}}))}))},e.prototype.acquireTokenRedirect=function(e){return s(this,void 0,void 0,(function(){var t,r,n,o,i,s,c,u,d;return a(this,(function(a){switch(a.label){case 0:this.preflightBrowserEnvironmentCheck(Jt.Redirect),(t=this.getAllAccounts().length>0)?this.emitEvent(Ur.ACQUIRE_TOKEN_START,Jt.Redirect,e):this.emitEvent(Ur.LOGIN_START,Jt.Redirect,e),r=this.preflightInteractiveRequest(e,Jt.Redirect),n=this.initializeServerTelemetryManager(Wt.acquireTokenRedirect,r.correlationId),a.label=1;case 1:return a.trys.push([1,5,,6]),[4,this.initializeAuthorizationCodeRequest(r)];case 2:return o=a.sent(),[4,this.createAuthCodeClient(n,r.authority)];case 3:return i=a.sent(),s=new qr(i,this.browserStorage,this.browserCrypto),[4,i.getAuthCodeUrl(r)];case 4:return c=a.sent(),u=e&&e.redirectStartPage||window.location.href,[2,s.initiateAuthRequest(c,o,{redirectTimeout:this.config.system.redirectNavigationTimeout,redirectStartPage:u,onRedirectNavigate:e.onRedirectNavigate})];case 5:throw d=a.sent(),t?this.emitEvent(Ur.ACQUIRE_TOKEN_FAILURE,Jt.Redirect,null,d):this.emitEvent(Ur.LOGIN_FAILURE,Jt.Redirect,null,d),n.cacheFailedRequest(d),this.browserStorage.cleanRequestByState(r.state),d;case 6:return[2]}}))}))},e.prototype.acquireTokenPopup=function(e){try{this.preflightBrowserEnvironmentCheck(Jt.Popup)}catch(e){return Promise.reject(e)}if(this.config.system.asyncPopups)return this.acquireTokenPopupAsync(e);var t=Lr.openSizedPopup();return this.acquireTokenPopupAsync(e,t)},e.prototype.acquireTokenPopupAsync=function(e,t){return s(this,void 0,void 0,(function(){var r,n,o,i,s,c,u,d,h,l,p,f;return a(this,(function(a){switch(a.label){case 0:(r=this.getAllAccounts()).length>0?this.emitEvent(Ur.ACQUIRE_TOKEN_START,Jt.Popup,e):this.emitEvent(Ur.LOGIN_START,Jt.Popup,e),n=this.preflightInteractiveRequest(e,Jt.Popup),o=this.initializeServerTelemetryManager(Wt.acquireTokenPopup,n.correlationId),a.label=1;case 1:return a.trys.push([1,7,,8]),[4,this.initializeAuthorizationCodeRequest(n)];case 2:return i=a.sent(),[4,this.createAuthCodeClient(o,n.authority)];case 3:return[4,(s=a.sent()).getAuthCodeUrl(n)];case 4:return c=a.sent(),u=new Lr(s,this.browserStorage),d={popup:t},h=u.initiateAuthRequest(c,i,d),[4,u.monitorPopupForHash(h,this.config.system.windowHashTimeout)];case 5:return l=a.sent(),Ot.removeThrottle(this.browserStorage,this.config.auth.clientId,i.authority,i.scopes),[4,u.handleCodeResponse(l,s.authority,this.networkClient)];case 6:return p=a.sent(),r.length0?this.emitEvent(Ur.ACQUIRE_TOKEN_FAILURE,Jt.Popup,null,f):this.emitEvent(Ur.LOGIN_FAILURE,Jt.Popup,null,f),o.cacheFailedRequest(f),this.browserStorage.cleanRequestByState(n.state),f;case 8:return[2]}}))}))},e.prototype.ssoSilent=function(e){return s(this,void 0,void 0,(function(){var t,r;return a(this,(function(n){switch(n.label){case 0:this.preflightBrowserEnvironmentCheck(Jt.Silent),this.emitEvent(Ur.SSO_SILENT_START,Jt.Silent,e),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.acquireTokenByIframe(e)];case 2:return t=n.sent(),this.emitEvent(Ur.SSO_SILENT_SUCCESS,Jt.Silent,t),[2,t];case 3:throw r=n.sent(),this.emitEvent(Ur.SSO_SILENT_FAILURE,Jt.Silent,null,r),r;case 4:return[2]}}))}))},e.prototype.acquireTokenByIframe=function(e){return s(this,void 0,void 0,(function(){var t,r,n,o,s,c;return a(this,(function(a){switch(a.label){case 0:if(Fe.isEmpty(e.loginHint)&&Fe.isEmpty(e.sid)&&(!e.account||Fe.isEmpty(e.account.username)))throw vr.createSilentSSOInsufficientInfoError();if(e.prompt&&e.prompt!==H.NONE)throw vr.createSilentPromptValueError(e.prompt);t=this.initializeAuthorizationRequest(i(i({},e),{prompt:H.NONE}),Jt.Silent),r=this.initializeServerTelemetryManager(Wt.ssoSilent,t.correlationId),a.label=1;case 1:return a.trys.push([1,6,,7]),[4,this.initializeAuthorizationCodeRequest(t)];case 2:return n=a.sent(),[4,this.createAuthCodeClient(r,t.authority)];case 3:return[4,(o=a.sent()).getAuthCodeUrl(t)];case 4:return s=a.sent(),[4,this.silentTokenHelper(s,n,o)];case 5:return[2,a.sent()];case 6:throw c=a.sent(),r.cacheFailedRequest(c),this.browserStorage.cleanRequestByState(t.state),c;case 7:return[2]}}))}))},e.prototype.acquireTokenByRefreshToken=function(e){return s(this,void 0,void 0,(function(){var t,r,n,o,s,c;return a(this,(function(a){switch(a.label){case 0:this.emitEvent(Ur.ACQUIRE_TOKEN_NETWORK_START,Jt.Silent,e),Pr.blockReloadInHiddenIframes(),t=i(i({},e),this.initializeBaseRequest(e)),r=this.initializeServerTelemetryManager(Wt.acquireTokenSilent_silentFlow,t.correlationId),a.label=1;case 1:return a.trys.push([1,4,,7]),[4,this.createRefreshTokenClient(r,t.authority)];case 2:return[4,a.sent().acquireTokenByRefreshToken(t)];case 3:return[2,a.sent()];case 4:return n=a.sent(),r.cacheFailedRequest(n),o=n instanceof bt,s=n instanceof xt,c=n.errorCode===sr,o&&c&&!s?[4,this.acquireTokenByIframe(e)]:[3,6];case 5:return[2,a.sent()];case 6:throw n;case 7:return[2]}}))}))},e.prototype.silentTokenHelper=function(e,t,r){return s(this,void 0,void 0,(function(){var n,o,i;return a(this,(function(s){switch(s.label){case 0:return[4,(n=new Dr(r,this.browserStorage,this.config.system.navigateFrameWait)).initiateAuthRequest(e,t)];case 1:return o=s.sent(),[4,n.monitorIframeForHash(o,this.config.system.iframeHashTimeout)];case 2:return i=s.sent(),[2,n.handleCodeResponse(i,r.authority,this.networkClient)]}}))}))},e.prototype.logout=function(e){return s(this,void 0,void 0,(function(){var t,r,n,o;return a(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.preflightBrowserEnvironmentCheck(Jt.Redirect),this.emitEvent(Ur.LOGOUT_START,Jt.Redirect,e),t=this.initializeLogoutRequest(e),[4,this.createAuthCodeClient(null,e&&e.authority)];case 1:return r=i.sent(),n=r.getLogoutUri(t),this.emitEvent(Ur.LOGOUT_SUCCESS,Jt.Redirect,t),e&&"function"==typeof e.onRedirectNavigate?!1!==e.onRedirectNavigate(n)?(this.logger.verbose("Logout onRedirectNavigate did not return false, navigating"),[2,Pr.navigateWindow(n,this.config.system.redirectNavigationTimeout,this.logger)]):(this.logger.verbose("Logout onRedirectNavigate returned false, stopping navigation"),[3,3]):[2,Pr.navigateWindow(n,this.config.system.redirectNavigationTimeout,this.logger)];case 2:throw o=i.sent(),this.emitEvent(Ur.LOGOUT_FAILURE,Jt.Redirect,null,o),o;case 3:return[2]}}))}))},e.prototype.getAllAccounts=function(){return this.isBrowserEnvironment?this.browserStorage.getAllAccounts():[]},e.prototype.getAccountByUsername=function(e){var t=this.getAllAccounts();return!Fe.isEmpty(e)&&t&&t.length&&t.filter((function(t){return t.username.toLowerCase()===e.toLowerCase()}))[0]||null},e.prototype.getAccountByHomeId=function(e){var t=this.getAllAccounts();return!Fe.isEmpty(e)&&t&&t.length&&t.filter((function(t){return t.homeAccountId===e}))[0]||null},e.prototype.getAccountByLocalId=function(e){var t=this.getAllAccounts();return!Fe.isEmpty(e)&&t&&t.length&&t.filter((function(t){return t.localAccountId===e}))[0]||null},e.prototype.getRedirectUri=function(e){var t=e||this.config.auth.redirectUri||Pr.getCurrentUri();return pt.getAbsoluteUrl(t,Pr.getCurrentUri())},e.prototype.getPostLogoutRedirectUri=function(e){var t=e||this.config.auth.postLogoutRedirectUri||Pr.getCurrentUri();return pt.getAbsoluteUrl(t,Pr.getCurrentUri())},e.prototype.getDiscoveredDefaultAuthority=function(){return s(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return this.defaultAuthority?[3,2]:(e=this,[4,tr.createDiscoveredInstance(this.config.auth.authority,this.config.system.networkClient,this.config.auth.protocolMode)]);case 1:e.defaultAuthority=t.sent(),t.label=2;case 2:return[2,this.defaultAuthority]}}))}))},e.prototype.interactionInProgress=function(){return this.browserStorage.getTemporaryCache(zt.INTERACTION_STATUS_KEY,!0)===ir},e.prototype.createAuthCodeClient=function(e,t){return s(this,void 0,void 0,(function(){var r;return a(this,(function(n){switch(n.label){case 0:return[4,this.getClientConfiguration(e,t)];case 1:return r=n.sent(),[2,new Zt(r)]}}))}))},e.prototype.createSilentFlowClient=function(e,t){return s(this,void 0,void 0,(function(){var r;return a(this,(function(n){switch(n.label){case 0:return[4,this.getClientConfiguration(e,t)];case 1:return r=n.sent(),[2,new er(r)]}}))}))},e.prototype.createRefreshTokenClient=function(e,t){return s(this,void 0,void 0,(function(){var r;return a(this,(function(n){switch(n.label){case 0:return[4,this.getClientConfiguration(e,t)];case 1:return r=n.sent(),[2,new $t(r)]}}))}))},e.prototype.getClientConfiguration=function(e,t){return s(this,void 0,void 0,(function(){var r,n;return a(this,(function(o){switch(o.label){case 0:return Fe.isEmpty(t)||t===this.config.auth.authority?[3,2]:[4,tr.createDiscoveredInstance(t,this.config.system.networkClient,this.config.auth.protocolMode)];case 1:return n=o.sent(),[3,4];case 2:return[4,this.getDiscoveredDefaultAuthority()];case 3:n=o.sent(),o.label=4;case 4:return r=n,[2,{authOptions:{clientId:this.config.auth.clientId,authority:r,knownAuthorities:this.config.auth.knownAuthorities,cloudDiscoveryMetadata:this.config.auth.cloudDiscoveryMetadata,clientCapabilities:this.config.auth.clientCapabilities,protocolMode:this.config.auth.protocolMode},systemOptions:{tokenRenewalOffsetSeconds:this.config.system.tokenRenewalOffsetSeconds},loggerOptions:{loggerCallback:this.config.system.loggerOptions.loggerCallback,piiLoggingEnabled:this.config.system.loggerOptions.piiLoggingEnabled},cryptoInterface:this.browserCrypto,networkInterface:this.networkClient,storageInterface:this.browserStorage,serverTelemetryManager:e,libraryInfo:{sku:dr,version:"2.8.0",cpu:"",os:""}}]}}))}))},e.prototype.preflightInteractiveRequest=function(e,t){if(Pr.blockReloadInHiddenIframes(),this.interactionInProgress())throw vr.createInteractionInProgressError();return this.initializeAuthorizationRequest(e,t)},e.prototype.preflightBrowserEnvironmentCheck=function(e){if(Pr.blockNonBrowserEnvironment(this.isBrowserEnvironment),Pr.blockRedirectInIframe(e,this.config.system.allowRedirectInIframe),Pr.blockReloadInHiddenIframes(),e===Jt.Redirect&&this.config.cache.cacheLocation===Gt.MemoryStorage&&!this.config.cache.storeAuthStateInCookie)throw Ar.createInMemoryRedirectUnavailableError()},e.prototype.initializeBaseRequest=function(e){var t=e.authority;Fe.isEmpty(t)&&(t=this.config.auth.authority);var r=function(){for(var e=[],t=0;t