UNPKG

piral-adal

Version:

Plugin to integrate AAD authentication in Piral.

1 lines • 110 kB
(()=>{function ht(o){return e=>(e.on("before-fetch",o.extendHeaders),{getAccessToken(){return o.token()}})}var Se=function(o,e){return Se=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)r.hasOwnProperty(n)&&(t[n]=r[n])},Se(o,e)};function O(o,e){Se(o,e);function t(){this.constructor=o}o.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var S=function(){return S=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},S.apply(this,arguments)};function G(o,e,t,r){function n(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function s(h){try{u(r.next(h))}catch(T){a(T)}}function c(h){try{u(r.throw(h))}catch(T){a(T)}}function u(h){h.done?i(h.value):n(h.value).then(s,c)}u((r=r.apply(o,e||[])).next())})}function W(o,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,n,i,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(u){return function(h){return c([u,h])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;t;)try{if(r=1,n&&(i=u[0]&2?n.return:u[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,u[1])).done)return i;switch(n=0,i&&(u=[u[0]&2,i.value]),u[0]){case 0:case 1:i=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,n=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){t.label=u[1];break}if(u[0]===6&&t.label<i[1]){t.label=i[1],i=u;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(u);break}i[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(o,t)}catch(h){u=[6,h],n=0}finally{r=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function U(){for(var o=0,e=0,t=arguments.length;e<t;e++)o+=arguments[e].length;for(var r=Array(o),n=0,e=0;e<t;e++)for(var i=arguments[e],a=0,s=i.length;a<s;a++,n++)r[n]=i[a];return r}var b=(function(){function o(){}return o.createNewGuid=function(){var e=window.crypto;if(e&&e.getRandomValues){var t=new Uint8Array(16);return e.getRandomValues(t),t[6]|=64,t[6]&=79,t[8]|=128,t[8]&=191,o.decimalToHex(t[0])+o.decimalToHex(t[1])+o.decimalToHex(t[2])+o.decimalToHex(t[3])+"-"+o.decimalToHex(t[4])+o.decimalToHex(t[5])+"-"+o.decimalToHex(t[6])+o.decimalToHex(t[7])+"-"+o.decimalToHex(t[8])+o.decimalToHex(t[9])+"-"+o.decimalToHex(t[10])+o.decimalToHex(t[11])+o.decimalToHex(t[12])+o.decimalToHex(t[13])+o.decimalToHex(t[14])+o.decimalToHex(t[15])}else{for(var r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",n="0123456789abcdef",i=0,a="",s=0;s<36;s++)r[s]!=="-"&&r[s]!=="4"&&(i=Math.random()*16|0),r[s]==="x"?a+=n[i]:r[s]==="y"?(i&=3,i|=8,a+=n[i]):a+=r[s];return a}},o.isGuid=function(e){var t=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;return t.test(e)},o.decimalToHex=function(e){for(var t=e.toString(16);t.length<2;)t="0"+t;return t},o.base64Encode=function(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(r,n){return String.fromCharCode(+("0x"+n))}))},o.base64Decode=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")}return decodeURIComponent(atob(t).split("").map(function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)}).join(""))},o.deserialize=function(e){var t,r=/\+/g,n=/([^&=]+)=([^&]*)/g,i=function(s){return decodeURIComponent(s.replace(r," "))},a={};for(t=n.exec(e);t;)a[i(t[1])]=i(t[2]),t=n.exec(e);return a},o})();var l=(function(){function o(){}return Object.defineProperty(o,"libraryName",{get:function(){return"Msal.js"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"claims",{get:function(){return"claims"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"clientId",{get:function(){return"clientId"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"adalIdToken",{get:function(){return"adal.idtoken"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"cachePrefix",{get:function(){return"msal"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"scopes",{get:function(){return"scopes"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"no_account",{get:function(){return"NO_ACCOUNT"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"upn",{get:function(){return"upn"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"domain_hint",{get:function(){return"domain_hint"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"prompt_select_account",{get:function(){return"&prompt=select_account"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"prompt_none",{get:function(){return"&prompt=none"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"prompt",{get:function(){return"prompt"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"response_mode_fragment",{get:function(){return"&response_mode=fragment"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"resourceDelimiter",{get:function(){return"|"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"cacheDelimiter",{get:function(){return"."},enumerable:!1,configurable:!0}),Object.defineProperty(o,"popUpWidth",{get:function(){return this._popUpWidth},set:function(e){this._popUpWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(o,"popUpHeight",{get:function(){return this._popUpHeight},set:function(e){this._popUpHeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(o,"login",{get:function(){return"LOGIN"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"renewToken",{get:function(){return"RENEW_TOKEN"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"unknown",{get:function(){return"UNKNOWN"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"ADFS",{get:function(){return"adfs"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"homeAccountIdentifier",{get:function(){return"homeAccountIdentifier"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"common",{get:function(){return"common"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"openidScope",{get:function(){return"openid"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"profileScope",{get:function(){return"profile"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"oidcScopes",{get:function(){return[this.openidScope,this.profileScope]},enumerable:!1,configurable:!0}),Object.defineProperty(o,"interactionTypeRedirect",{get:function(){return"redirectInteraction"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"interactionTypePopup",{get:function(){return"popupInteraction"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"interactionTypeSilent",{get:function(){return"silentInteraction"},enumerable:!1,configurable:!0}),Object.defineProperty(o,"inProgress",{get:function(){return"inProgress"},enumerable:!1,configurable:!0}),o._popUpWidth=483,o._popUpHeight=600,o})();var Ne="sessionStorage",p;(function(o){o.SCOPE="scope",o.STATE="state",o.ERROR="error",o.ERROR_DESCRIPTION="error_description",o.ACCESS_TOKEN="access_token",o.ID_TOKEN="id_token",o.EXPIRES_IN="expires_in",o.SESSION_STATE="session_state",o.CLIENT_INFO="client_info"})(p||(p={}));var Q={id_token:"id_token",token:"token",id_token_token:"id_token token"},I;(function(o){o.AUTHORITY="authority",o.ACQUIRE_TOKEN_ACCOUNT="acquireTokenAccount",o.SESSION_STATE="session.state",o.STATE_LOGIN="state.login",o.STATE_ACQ_TOKEN="state.acquireToken",o.STATE_RENEW="state.renew",o.NONCE_IDTOKEN="nonce.idtoken",o.LOGIN_REQUEST="login.request",o.RENEW_STATUS="token.renew.status",o.URL_HASH="urlHash",o.INTERACTION_STATUS="interaction.status",o.REDIRECT_REQUEST="redirect_request"})(I||(I={}));var H;(function(o){o.IDTOKEN="idtoken",o.CLIENT_INFO="client.info"})(H||(H={}));var P;(function(o){o.LOGIN_ERROR="login.error",o.ERROR="error",o.ERROR_DESC="error.description"})(P||(P={}));var Ye="https://login.microsoftonline.com/common/",xe=Ye+"/discovery/instance?api-version=1.1&authorization_endpoint=",we=".well-known/openid-configuration",w;(function(o){o.ACCOUNT="account",o.SID="sid",o.LOGIN_HINT="login_hint",o.ORGANIZATIONS="organizations",o.CONSUMERS="consumers",o.ID_TOKEN="id_token",o.ACCOUNT_ID="accountIdentifier",o.HOMEACCOUNT_ID="homeAccountIdentifier"})(w||(w={}));var Ue=[w.SID,w.LOGIN_HINT],se={GET:"GET",POST:"POST"},oe={LOGIN:"login",SELECT_ACCOUNT:"select_account",CONSENT:"consent",NONE:"none"},Ce={ID_TOKEN_FRAME:"msalIdTokenFrame",TOKEN_FRAME:"msalRenewFrame"};var ge={unexpectedError:{code:"unexpected_error",desc:"Unexpected error in authentication."},noWindowObjectError:{code:"no_window_object",desc:"No window object available. Details:"}},D=(function(o){O(e,o);function e(t,r){var n=o.call(this,r)||this;return Object.setPrototypeOf(n,e.prototype),n.errorCode=t,n.errorMessage=r,n.name="AuthError",n}return e.createUnexpectedError=function(t){return new e(ge.unexpectedError.code,ge.unexpectedError.desc+": "+t)},e.createNoWindowObjectError=function(t){return new e(ge.noWindowObjectError.code,ge.noWindowObjectError.desc+" "+t)},e})(Error);var m=(function(){function o(){}return o.isEmpty=function(e){return typeof e>"u"||!e||e.length===0},o.validateAndParseJsonCacheKey=function(e){try{var t=JSON.parse(e);return t&&typeof t=="object"?t:null}catch{return null}},o})();var d={endpointResolutionError:{code:"endpoints_resolution_error",desc:"Error: could not resolve endpoints. Please check network and try again."},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."},tokenRenewalError:{code:"token_renewal_error",desc:"Token renewal operation failed due to timeout."},invalidIdToken:{code:"invalid_id_token",desc:"Invalid ID token format."},invalidStateError:{code:"invalid_state_error",desc:"Invalid state."},nonceMismatchError:{code:"nonce_mismatch_error",desc:"Nonce is not matching, Nonce received: "},loginProgressError:{code:"login_progress_error",desc:"Login_In_Progress: Error during login call - login is already in progress."},acquireTokenProgressError:{code:"acquiretoken_progress_error",desc:"AcquireToken_In_Progress: Error during login call - login is already in progress."},userCancelledError:{code:"user_cancelled",desc:"User cancelled the flow."},callbackError:{code:"callback_error",desc:"Error occurred in token received callback function."},userLoginRequiredError:{code:"user_login_error",desc:"User login is required. For silent calls, request must contain either sid or login_hint"},userDoesNotExistError:{code:"user_non_existent",desc:"User object does not exist. Please call a login API."},clientInfoDecodingError:{code:"client_info_decoding_error",desc:"The client info could not be parsed/decoded correctly. Please review the trace to determine the root cause."},clientInfoNotPopulatedError:{code:"client_info_not_populated_error",desc:"The service did not populate client_info in the response, Please verify with the service team"},nullOrEmptyIdToken:{code:"null_or_empty_id_token",desc:"The idToken is null or empty. Please review the trace to determine the root cause."},idTokenNotParsed:{code:"id_token_parsing_error",desc:"ID token cannot be parsed. Please review stack trace to determine root cause."},tokenEncodingError:{code:"token_encoding_error",desc:"The token to be decoded is not encoded correctly."},invalidInteractionType:{code:"invalid_interaction_type",desc:"The interaction type passed to the handler was incorrect or unknown"},cacheParseError:{code:"cannot_parse_cache",desc:"The cached token key is not a valid JSON and cannot be parsed"},blockTokenRequestsInHiddenIframe:{code:"block_token_requests",desc:"Token calls are blocked in hidden iframes"}},E=(function(o){O(e,o);function e(t,r){var n=o.call(this,t,r)||this;return n.name="ClientAuthError",Object.setPrototypeOf(n,e.prototype),n}return e.createEndpointResolutionError=function(t){var r=d.endpointResolutionError.desc;return t&&!m.isEmpty(t)&&(r+=" Details: "+t),new e(d.endpointResolutionError.code,r)},e.createPopupWindowError=function(t){var r=d.popUpWindowError.desc;return t&&!m.isEmpty(t)&&(r+=" Details: "+t),new e(d.popUpWindowError.code,r)},e.createTokenRenewalTimeoutError=function(){return new e(d.tokenRenewalError.code,d.tokenRenewalError.desc)},e.createInvalidIdTokenError=function(t){return new e(d.invalidIdToken.code,d.invalidIdToken.desc+" Given token: "+t)},e.createInvalidStateError=function(t,r){return new e(d.invalidStateError.code,d.invalidStateError.desc+" "+t+", state expected : "+r+".")},e.createNonceMismatchError=function(t,r){return new e(d.nonceMismatchError.code,d.nonceMismatchError.desc+" "+t+", nonce expected : "+r+".")},e.createLoginInProgressError=function(){return new e(d.loginProgressError.code,d.loginProgressError.desc)},e.createAcquireTokenInProgressError=function(){return new e(d.acquireTokenProgressError.code,d.acquireTokenProgressError.desc)},e.createUserCancelledError=function(){return new e(d.userCancelledError.code,d.userCancelledError.desc)},e.createErrorInCallbackFunction=function(t){return new e(d.callbackError.code,d.callbackError.desc+" "+t+".")},e.createUserLoginRequiredError=function(){return new e(d.userLoginRequiredError.code,d.userLoginRequiredError.desc)},e.createUserDoesNotExistError=function(){return new e(d.userDoesNotExistError.code,d.userDoesNotExistError.desc)},e.createClientInfoDecodingError=function(t){return new e(d.clientInfoDecodingError.code,d.clientInfoDecodingError.desc+" Failed with error: "+t)},e.createClientInfoNotPopulatedError=function(t){return new e(d.clientInfoNotPopulatedError.code,d.clientInfoNotPopulatedError.desc+" Failed with error: "+t)},e.createIdTokenNullOrEmptyError=function(t){return new e(d.nullOrEmptyIdToken.code,d.nullOrEmptyIdToken.desc+" Raw ID Token Value: "+t)},e.createIdTokenParsingError=function(t){return new e(d.idTokenNotParsed.code,d.idTokenNotParsed.desc+" Failed with error: "+t)},e.createTokenEncodingError=function(t){return new e(d.tokenEncodingError.code,d.tokenEncodingError.desc+" Attempted to decode: "+t)},e.createInvalidInteractionTypeError=function(){return new e(d.invalidInteractionType.code,d.invalidInteractionType.desc)},e.createCacheParseError=function(t){var r="invalid key: "+t+", "+d.cacheParseError.desc;return new e(d.cacheParseError.code,r)},e.createBlockTokenRequestsInHiddenIframeError=function(){return new e(d.blockTokenRequestsInHiddenIframe.code,d.blockTokenRequestsInHiddenIframe.desc)},e})(D);var v={configurationNotSet:{code:"no_config_set",desc:"Configuration has not been set. Please call the UserAgentApplication constructor with a valid Configuration object."},storageNotSupported:{code:"storage_not_supported",desc:"The value for the cacheLocation is not supported."},noRedirectCallbacksSet:{code:"no_redirect_callbacks",desc:"No redirect callbacks have been set. Please call handleRedirectCallback() 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."},scopesRequired:{code:"scopes_required",desc:"Scopes are required to obtain an access token."},emptyScopes:{code:"empty_input_scopes_error",desc:"Scopes cannot be passed as empty array."},nonArrayScopes:{code:"nonarray_input_scopes_error",desc:"Scopes cannot be passed as non-array."},invalidPrompt:{code:"invalid_prompt_value",desc:"Supported prompt values are 'login', 'select_account', 'consent' and 'none'"},invalidAuthorityType:{code:"invalid_authority_type",desc:"The given authority is not a valid type of authority supported by MSAL. Please see here for valid authorities: <insert URL here>."},authorityUriInsecure:{code:"authority_uri_insecure",desc:"Authority URIs must use https."},authorityUriInvalidPath:{code:"authority_uri_invalid_path",desc:"Given authority URI is invalid."},unsupportedAuthorityValidation:{code:"unsupported_authority_validation",desc:"The authority validation is not supported for this authority type."},untrustedAuthority:{code:"untrusted_authority",desc:"The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter or set validateAuthority=false."},b2cAuthorityUriInvalidPath:{code:"b2c_authority_uri_invalid_path",desc:"The given URI for the B2C authority is invalid."},b2cKnownAuthoritiesNotSet:{code:"b2c_known_authorities_not_set",desc:"Must set known authorities when validateAuthority is set to True and using B2C"},claimsRequestParsingError:{code:"claims_request_parsing_error",desc:"Could not parse the given claims request object."},emptyRequestError:{code:"empty_request_error",desc:"Request object is required."},invalidCorrelationIdError:{code:"invalid_guid_sent_as_correlationId",desc:"Please set the correlationId as a valid guid"},telemetryConfigError:{code:"telemetry_config_error",desc:"Telemetry config is not configured with required values"},ssoSilentError:{code:"sso_silent_error",desc:"request must contain either sid or login_hint"},invalidAuthorityMetadataError:{code:"authority_metadata_error",desc:"Invalid authorityMetadata. Must be a JSON object containing authorization_endpoint, end_session_endpoint, and issuer fields."}},_=(function(o){O(e,o);function e(t,r){var n=o.call(this,t,r)||this;return n.name="ClientConfigurationError",Object.setPrototypeOf(n,e.prototype),n}return e.createNoSetConfigurationError=function(){return new e(v.configurationNotSet.code,""+v.configurationNotSet.desc)},e.createStorageNotSupportedError=function(t){return new e(v.storageNotSupported.code,v.storageNotSupported.desc+" Given location: "+t)},e.createRedirectCallbacksNotSetError=function(){return new e(v.noRedirectCallbacksSet.code,v.noRedirectCallbacksSet.desc)},e.createInvalidCallbackObjectError=function(t){return new e(v.invalidCallbackObject.code,v.invalidCallbackObject.desc+" Given value for callback function: "+t)},e.createEmptyScopesArrayError=function(t){return new e(v.emptyScopes.code,v.emptyScopes.desc+" Given value: "+t+".")},e.createScopesNonArrayError=function(t){return new e(v.nonArrayScopes.code,v.nonArrayScopes.desc+" Given value: "+t+".")},e.createScopesRequiredError=function(t){return new e(v.scopesRequired.code,v.scopesRequired.desc+" Given value: "+t)},e.createInvalidPromptError=function(t){return new e(v.invalidPrompt.code,v.invalidPrompt.desc+" Given value: "+t)},e.createClaimsRequestParsingError=function(t){return new e(v.claimsRequestParsingError.code,v.claimsRequestParsingError.desc+" Given value: "+t)},e.createEmptyRequestError=function(){var t=v.emptyRequestError,r=t.code,n=t.desc;return new e(r,n)},e.createInvalidCorrelationIdError=function(){return new e(v.invalidCorrelationIdError.code,v.invalidCorrelationIdError.desc)},e.createKnownAuthoritiesNotSetError=function(){return new e(v.b2cKnownAuthoritiesNotSet.code,v.b2cKnownAuthoritiesNotSet.desc)},e.createInvalidAuthorityTypeError=function(){return new e(v.invalidAuthorityType.code,v.invalidAuthorityType.desc)},e.createUntrustedAuthorityError=function(t){return new e(v.untrustedAuthority.code,v.untrustedAuthority.desc+" Provided Authority: "+t)},e.createTelemetryConfigError=function(t){var r=v.telemetryConfigError,n=r.code,i=r.desc,a={applicationName:"string",applicationVersion:"string",telemetryEmitter:"function"},s=Object.keys(a).reduce(function(c,u){return t[u]?c:c.concat([u+" ("+a[u]+")"])},[]);return new e(n,i+" mising values: "+s.join(","))},e.createSsoSilentError=function(){return new e(v.ssoSilentError.code,v.ssoSilentError.desc)},e.createInvalidAuthorityMetadataError=function(){return new e(v.invalidAuthorityMetadataError.code,v.invalidAuthorityMetadataError.desc)},e})(E);var N=(function(){function o(){}return o.isIntersectingScopes=function(e,t){for(var r=this.trimAndConvertArrayToLowerCase(U(e)),n=this.trimAndConvertArrayToLowerCase(U(t)),i=0;i<n.length;i++)if(r.indexOf(n[i].toLowerCase())>-1)return!0;return!1},o.containsScope=function(e,t){var r=this.trimAndConvertArrayToLowerCase(U(e)),n=this.trimAndConvertArrayToLowerCase(U(t));return n.every(function(i){return r.indexOf(i.toString().toLowerCase())>=0})},o.trimAndConvertToLowerCase=function(e){return e.trim().toLowerCase()},o.trimAndConvertArrayToLowerCase=function(e){var t=this;return e.map(function(r){return t.trimAndConvertToLowerCase(r)})},o.trimScopes=function(e){return e.map(function(t){return t.trim()})},o.removeElement=function(e,t){var r=this.trimAndConvertToLowerCase(t);return e.filter(function(n){return n!==r})},o.parseScope=function(e){var t="";if(e)for(var r=0;r<e.length;++r)t+=r!==e.length-1?e[r]+" ":e[r];return t},o.validateInputScope=function(e,t){if(!e){if(t)throw _.createScopesRequiredError(e);return}if(!Array.isArray(e))throw _.createScopesNonArrayError(e);if(e.length<1&&t)throw _.createEmptyScopesArrayError(e.toString())},o.getScopeFromState=function(e){if(e){var t=e.indexOf(l.resourceDelimiter);if(t>-1&&t+1<e.length)return e.substring(t+1)}return""},o.appendScopes=function(e,t){if(e){var r=t?this.trimAndConvertArrayToLowerCase(U(t)):null,n=this.trimAndConvertArrayToLowerCase(U(e));return r?U(n,r):n}return null},o.onlyContainsOidcScopes=function(e){var t=e.length,r=0;return e.indexOf(l.openidScope)>-1&&(r+=1),e.indexOf(l.profileScope)>-1&&(r+=1),t>0&&t===r},o.containsAnyOidcScopes=function(e){var t=e.indexOf(l.openidScope)>-1,r=e.indexOf(l.profileScope)>-1;return t||r},o.onlyContainsClientId=function(e,t){return!!e&&e.indexOf(t)>-1&&e.length===1},o.appendDefaultScopes=function(e){var t=e;return t.indexOf(l.openidScope)===-1&&t.push(l.openidScope),t.indexOf(l.profileScope)===-1&&t.push(l.profileScope),t},o.removeDefaultScopes=function(e){return e.filter(function(t){return t!==l.openidScope&&t!==l.profileScope})},o.translateClientIdIfSingleScope=function(e,t){return this.onlyContainsClientId(e,t)?l.oidcScopes:e},o})();var f=(function(){function o(){}return o.createNavigateUrl=function(e){var t=this.createNavigationUrlString(e),r=e.authorityInstance.AuthorizationEndpoint;r.indexOf("?")<0?r+="?":r+="&";var n=""+r+t.join("&");return n},o.createNavigationUrlString=function(e){var t=N.appendDefaultScopes(e.scopes),r=[];return r.push("response_type="+e.responseType),r.push("scope="+encodeURIComponent(N.parseScope(t))),r.push("client_id="+encodeURIComponent(e.clientId)),r.push("redirect_uri="+encodeURIComponent(e.redirectUri)),r.push("state="+encodeURIComponent(e.state)),r.push("nonce="+encodeURIComponent(e.nonce)),r.push("client_info=1"),r.push("x-client-SKU="+e.xClientSku),r.push("x-client-Ver="+e.xClientVer),e.promptValue&&r.push("prompt="+encodeURIComponent(e.promptValue)),e.claimsValue&&r.push("claims="+encodeURIComponent(e.claimsValue)),e.queryParameters&&r.push(e.queryParameters),e.extraQueryParameters&&r.push(e.extraQueryParameters),r.push("client-request-id="+encodeURIComponent(e.correlationId)),r},o.getCurrentUrl=function(){return window.location.href.split("?")[0].split("#")[0]},o.removeHashFromUrl=function(e){return e.split("#")[0]},o.replaceTenantPath=function(e,t){var r=e.toLowerCase(),n=this.GetUrlComponents(r),i=n.PathSegments;return t&&i.length!==0&&(i[0]===l.common||i[0]===w.ORGANIZATIONS||i[0]===w.CONSUMERS)&&(i[0]=t),this.constructAuthorityUriFromObject(n,i)},o.constructAuthorityUriFromObject=function(e,t){return this.CanonicalizeUri(e.Protocol+"//"+e.HostNameAndPort+"/"+t.join("/"))},o.isCommonAuthority=function(e){var t=this.CanonicalizeUri(e),r=this.GetUrlComponents(t).PathSegments;return r.length!==0&&r[0]===l.common},o.isOrganizationsAuthority=function(e){var t=this.CanonicalizeUri(e),r=this.GetUrlComponents(t).PathSegments;return r.length!==0&&r[0]===w.ORGANIZATIONS},o.isConsumersAuthority=function(e){var t=this.CanonicalizeUri(e),r=this.GetUrlComponents(t).PathSegments;return r.length!==0&&r[0]===w.CONSUMERS},o.GetUrlComponents=function(e){if(!e)throw"Url required";var t=RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?"),r=e.match(t);if(!r||r.length<6)throw"Valid url required";var n={Protocol:r[1],HostNameAndPort:r[4],AbsolutePath:r[5]},i=n.AbsolutePath.split("/");return i=i.filter(function(a){return a&&a.length>0}),n.PathSegments=i,r[6]&&(n.Search=r[6]),r[8]&&(n.Hash=r[8]),n},o.CanonicalizeUri=function(e){if(e){var t=e.toLowerCase();return o.endsWith(t,"/")||(t+="/"),t}return e},o.endsWith=function(e,t){return!e||!t?!1:e.indexOf(t,e.length-t.length)!==-1},o.urlRemoveQueryStringParameter=function(e,t){if(m.isEmpty(e))return e;var r=e,n=new RegExp("(\\&"+t+"=)[^&]+");return r=e.replace(n,""),n=new RegExp("("+t+"=)[^&]+&"),r=e.replace(n,""),n=new RegExp("("+t+"=)[^&]+"),r=e.replace(n,""),r},o.getHashFromUrl=function(e){var t=e.indexOf("#"),r=e.indexOf("#/");return r>-1?e.substring(r+2):t>-1?e.substring(t+1):e},o.urlContainsHash=function(e){var t=o.deserializeHash(e);return t.hasOwnProperty(p.ERROR_DESCRIPTION)||t.hasOwnProperty(p.ERROR)||t.hasOwnProperty(p.ACCESS_TOKEN)||t.hasOwnProperty(p.ID_TOKEN)},o.deserializeHash=function(e){var t=o.getHashFromUrl(e);return b.deserialize(t)},o.getHostFromUri=function(e){var t=String(e).replace(/^(https?:)\/\//,"");return t=t.split("/")[0],t},o})();var Le=(function(){function o(e,t,r,n,i){this.authority=f.CanonicalizeUri(e),this.clientId=t,this.scopes=r,this.homeAccountIdentifier=b.base64Encode(n)+"."+b.base64Encode(i)}return o})();var Me=(function(){function o(e,t,r,n){this.accessToken=e,this.idToken=t,this.expiresIn=r,this.homeAccountIdentifier=n}return o})();var ne="1.4.18";var X=(function(){function o(e,t,r,n,i,a,s){this.authorityInstance=e,this.clientId=t,this.nonce=b.createNewGuid(),this.scopes=i?U(i):l.oidcScopes,this.scopes=N.trimScopes(this.scopes),this.state=a,this.correlationId=s,this.xClientSku="MSAL.JS",this.xClientVer=ne,this.responseType=r,this.redirectUri=n}return Object.defineProperty(o.prototype,"authority",{get:function(){return this.authorityInstance?this.authorityInstance.CanonicalAuthority:null},enumerable:!1,configurable:!0}),o.prototype.populateQueryParams=function(e,t,r,n){var i={};t&&(t.prompt&&(this.promptValue=t.prompt),t.claimsRequest&&(this.claimsValue=t.claimsRequest),o.isSSOParam(t)&&(i=this.constructUnifiedCacheQueryParameter(t,null))),r&&(i=this.constructUnifiedCacheQueryParameter(null,r)),i=this.addHintParameters(e,i);var a=t?t.extraQueryParameters:null;this.queryParameters=o.generateQueryParametersString(i),this.extraQueryParameters=o.generateQueryParametersString(a,n)},o.prototype.constructUnifiedCacheQueryParameter=function(e,t){var r,n,i,a={};if(e)if(e.account){var s=e.account;!((r=s.idTokenClaims)===null||r===void 0)&&r.login_hint?(n=w.LOGIN_HINT,i=s.idTokenClaims.login_hint):s.sid?(n=w.SID,i=s.sid):s.userName&&(n=w.LOGIN_HINT,i=s.userName)}else e.sid?(n=w.SID,i=e.sid):e.loginHint&&(n=w.LOGIN_HINT,i=e.loginHint);else t&&t.hasOwnProperty(l.upn)&&(n=w.ID_TOKEN,i=t.upn);return a=this.addSSOParameter(n,i),a},o.prototype.addHintParameters=function(e,t){var r,n,i=t;return e&&!i[w.SID]&&!i[w.LOGIN_HINT]&&(!((r=e.idTokenClaims)===null||r===void 0)&&r.login_hint?i=this.addSSOParameter(w.LOGIN_HINT,(n=e.idTokenClaims)===null||n===void 0?void 0:n.login_hint,i):e.sid&&this.promptValue===oe.NONE?i=this.addSSOParameter(w.SID,e.sid,i):e.userName&&(i=this.addSSOParameter(w.LOGIN_HINT,e.userName,i))),i},o.prototype.addSSOParameter=function(e,t,r){var n=r||{};if(!t)return n;switch(e){case w.SID:{n[w.SID]=t;break}case w.ID_TOKEN:{n[w.LOGIN_HINT]=t;break}case w.LOGIN_HINT:{n[w.LOGIN_HINT]=t;break}}return n},o.generateQueryParametersString=function(e,t){var r=null;return e&&Object.keys(e).forEach(function(n){n===l.domain_hint&&(t||e[w.SID])||(r?r+="&"+n+"="+encodeURIComponent(e[n]):r=n+"="+encodeURIComponent(e[n]))}),r},o.isSSOParam=function(e){return!!(e&&(e.account||e.sid||e.loginHint))},o.determineResponseType=function(e,t){return N.onlyContainsOidcScopes(t)?Q.id_token:e?this.responseTypeForMatchingAccounts(t):Q.id_token_token},o.responseTypeForMatchingAccounts=function(e){return N.containsAnyOidcScopes(e)?Q.id_token_token:Q.token},o})();var me=(function(){function o(){}return o.prototype.sendRequestAsync=function(e,t,r){var n=this;return new Promise(function(i,a){var s=new XMLHttpRequest;if(s.open(t,e,!0),s.onload=function(){(s.status<200||s.status>=300)&&a(n.handleError(s.responseText));var c;try{c=JSON.parse(s.responseText)}catch{a(n.handleError(s.responseText))}var u={statusCode:s.status,body:c};i(u)},s.onerror=function(){a(s.status)},t===se.GET)s.send();else throw"not implemented"})},o.prototype.handleError=function(e){var t;try{if(t=JSON.parse(e),t.error)return t.error;throw e}catch{return e}},o})();var ce=(function(){function o(){}return o.setTrustedAuthoritiesFromConfig=function(e,t){e&&!this.getTrustedHostList().length&&t.forEach(function(r){o.TrustedHostList.push(r.toLowerCase())})},o.getAliases=function(e,t,r){return G(this,void 0,void 0,function(){var n,i,a,s;return W(this,function(c){return n=new me,i=se.GET,a=""+xe+e+"oauth2/v2.0/authorize",s=t.createAndStartHttpEvent(r,i,a,"getAliases"),[2,n.sendRequestAsync(a,i,!0).then(function(u){return s.httpResponseStatus=u.statusCode,t.stopEvent(s),u.body.metadata}).catch(function(u){throw s.serverErrorCode=u,t.stopEvent(s),u})]})})},o.setTrustedAuthoritiesFromNetwork=function(e,t,r){return G(this,void 0,void 0,function(){var n,i;return W(this,function(a){switch(a.label){case 0:return[4,this.getAliases(e,t,r)];case 1:return n=a.sent(),n.forEach(function(s){var c=s.aliases;c.forEach(function(u){o.TrustedHostList.push(u.toLowerCase())})}),i=f.GetUrlComponents(e).HostNameAndPort,o.getTrustedHostList().length&&!o.IsInTrustedHostList(i)&&o.TrustedHostList.push(i.toLowerCase()),[2]}})})},o.getTrustedHostList=function(){return this.TrustedHostList},o.IsInTrustedHostList=function(e){return this.TrustedHostList.indexOf(e.toLowerCase())>-1},o.TrustedHostList=[],o})();var ee;(function(o){o[o.Default=0]="Default",o[o.Adfs=1]="Adfs"})(ee||(ee={}));var ve=(function(){function o(e,t,r){this.IsValidationEnabled=t,this.CanonicalAuthority=e,this.validateAsUri(),this.tenantDiscoveryResponse=r}return o.isAdfs=function(e){var t=f.GetUrlComponents(e),r=t.PathSegments;return r.length&&r[0].toLowerCase()===l.ADFS},Object.defineProperty(o.prototype,"AuthorityType",{get:function(){return o.isAdfs(this.canonicalAuthority)?ee.Adfs:ee.Default},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"Tenant",{get:function(){return this.CanonicalAuthorityUrlComponents.PathSegments[0]},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"AuthorizationEndpoint",{get:function(){return this.validateResolved(),this.tenantDiscoveryResponse.AuthorizationEndpoint.replace(/{tenant}|{tenantid}/g,this.Tenant)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"EndSessionEndpoint",{get:function(){return this.validateResolved(),this.tenantDiscoveryResponse.EndSessionEndpoint.replace(/{tenant}|{tenantid}/g,this.Tenant)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"SelfSignedJwtAudience",{get:function(){return this.validateResolved(),this.tenantDiscoveryResponse.Issuer.replace(/{tenant}|{tenantid}/g,this.Tenant)},enumerable:!1,configurable:!0}),o.prototype.validateResolved=function(){if(!this.hasCachedMetadata())throw"Please call ResolveEndpointsAsync first"},Object.defineProperty(o.prototype,"CanonicalAuthority",{get:function(){return this.canonicalAuthority},set:function(e){this.canonicalAuthority=f.CanonicalizeUri(e),this.canonicalAuthorityUrlComponents=null},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"CanonicalAuthorityUrlComponents",{get:function(){return this.canonicalAuthorityUrlComponents||(this.canonicalAuthorityUrlComponents=f.GetUrlComponents(this.CanonicalAuthority)),this.canonicalAuthorityUrlComponents},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"DefaultOpenIdConfigurationEndpoint",{get:function(){return this.AuthorityType===ee.Adfs?""+this.CanonicalAuthority+we:this.CanonicalAuthority+"v2.0/"+we},enumerable:!1,configurable:!0}),o.prototype.validateAsUri=function(){var e;try{e=this.CanonicalAuthorityUrlComponents}catch{throw v.invalidAuthorityType}if(!e.Protocol||e.Protocol.toLowerCase()!=="https:")throw v.authorityUriInsecure;if(!e.PathSegments||e.PathSegments.length<1)throw v.authorityUriInvalidPath},o.prototype.DiscoverEndpoints=function(e,t,r){var n=new me,i=se.GET,a=t.createAndStartHttpEvent(r,i,e,"openIdConfigurationEndpoint");return n.sendRequestAsync(e,i,!0).then(function(s){return a.httpResponseStatus=s.statusCode,t.stopEvent(a),{AuthorizationEndpoint:s.body.authorization_endpoint,EndSessionEndpoint:s.body.end_session_endpoint,Issuer:s.body.issuer}}).catch(function(s){throw a.serverErrorCode=s,t.stopEvent(a),s})},o.prototype.resolveEndpointsAsync=function(e,t){return G(this,void 0,void 0,function(){var r,n,i;return W(this,function(a){switch(a.label){case 0:return this.IsValidationEnabled?(r=this.canonicalAuthorityUrlComponents.HostNameAndPort,ce.getTrustedHostList().length!==0?[3,2]:[4,ce.setTrustedAuthoritiesFromNetwork(this.canonicalAuthority,e,t)]):[3,3];case 1:a.sent(),a.label=2;case 2:if(!ce.IsInTrustedHostList(r))throw _.createUntrustedAuthorityError(r);a.label=3;case 3:return n=this.GetOpenIdConfigurationEndpoint(),i=this,[4,this.DiscoverEndpoints(n,e,t)];case 4:return i.tenantDiscoveryResponse=a.sent(),[2,this.tenantDiscoveryResponse]}})})},o.prototype.hasCachedMetadata=function(){return!!(this.tenantDiscoveryResponse&&this.tenantDiscoveryResponse.AuthorizationEndpoint&&this.tenantDiscoveryResponse.EndSessionEndpoint&&this.tenantDiscoveryResponse.Issuer)},o.prototype.GetOpenIdConfigurationEndpoint=function(){return this.DefaultOpenIdConfigurationEndpoint},o})();var ie=(function(){function o(e,t){if(!e||m.isEmpty(e)){this.uid="",this.utid="";return}try{var r=b.base64Decode(e),n=JSON.parse(r);n&&(n.hasOwnProperty("uid")&&(this.uid=t?o.stripPolicyFromUid(n.uid,t):n.uid),n.hasOwnProperty("utid")&&(this.utid=n.utid))}catch(i){throw E.createClientInfoDecodingError(i)}}return Object.defineProperty(o.prototype,"uid",{get:function(){return this._uid?this._uid:""},set:function(e){this._uid=e},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"utid",{get:function(){return this._utid?this._utid:""},set:function(e){this._utid=e},enumerable:!1,configurable:!0}),o.createClientInfoFromIdToken=function(e,t){var r={uid:e.subject,utid:""};return new o(b.base64Encode(JSON.stringify(r)),t)},o.stripPolicyFromUid=function(e,t){var r=e.split("-"),n=t.split("/").reverse(),i="";return m.isEmpty(n[0])?n.length>1&&(i=n[1]):i=n[0],r[r.length-1]===i?r.slice(0,r.length-1).join("-"):e},o.prototype.encodeClientInfo=function(){var e=JSON.stringify({uid:this.uid,utid:this.utid});return b.base64Encode(e)},o})();var Y=(function(){function o(){}return o.parseExpiresIn=function(e){var t=e||"3599";return parseInt(t,10)},o.now=function(){return Math.round(new Date().getTime()/1e3)},o.relativeNowMs=function(){return window.performance.now()},o})();var ue=(function(){function o(){}return o.decodeJwt=function(e){if(m.isEmpty(e))return null;var t=/^([^\.\s]*)\.([^\.\s]+)\.([^\.\s]*)$/,r=t.exec(e);if(!r||r.length<4)return null;var n={header:r[1],JWSPayload:r[2],JWSSig:r[3]};return n},o.validateExpirationIsWithinOffset=function(e,t){var r=t||300;return e&&e>Y.now()+r},o.extractIdToken=function(e){var t=this.decodeJwt(e);if(!t)return null;try{var r=t.JWSPayload,n=b.base64Decode(r);return n?JSON.parse(n):null}catch{}return null},o})();var $=(function(){function o(e){if(m.isEmpty(e))throw E.createIdTokenNullOrEmptyError(e);try{this.rawIdToken=e,this.claims=ue.extractIdToken(e),this.claims&&(this.claims.hasOwnProperty("iss")&&(this.issuer=this.claims.iss),this.claims.hasOwnProperty("oid")&&(this.objectId=this.claims.oid),this.claims.hasOwnProperty("sub")&&(this.subject=this.claims.sub),this.claims.hasOwnProperty("tid")&&(this.tenantId=this.claims.tid),this.claims.hasOwnProperty("ver")&&(this.version=this.claims.ver),this.claims.hasOwnProperty("preferred_username")?this.preferredName=this.claims.preferred_username:this.claims.hasOwnProperty("upn")&&(this.preferredName=this.claims.upn),this.claims.hasOwnProperty("name")&&(this.name=this.claims.name),this.claims.hasOwnProperty("nonce")&&(this.nonce=this.claims.nonce),this.claims.hasOwnProperty("exp")&&(this.expiration=this.claims.exp),this.claims.hasOwnProperty("home_oid")&&(this.homeObjectId=this.claims.home_oid),this.claims.hasOwnProperty("sid")&&(this.sid=this.claims.sid),this.claims.hasOwnProperty("cloud_instance_host_name")&&(this.cloudInstance=this.claims.cloud_instance_host_name))}catch(t){throw E.createIdTokenParsingError(t)}}return o})();var He=(function(){function o(e,t){this.key=e,this.value=t}return o})();var Ae=(function(){function o(e){if(!window)throw D.createNoWindowObjectError("Browser storage class could not find window object");var t=typeof window[e]<"u"&&window[e]!==null;if(!t)throw _.createStorageNotSupportedError(e);this.cacheLocation=e}return o.prototype.setItem=function(e,t,r){window[this.cacheLocation].setItem(e,t),r&&this.setItemCookie(e,t)},o.prototype.getItem=function(e,t){return t&&this.getItemCookie(e)?this.getItemCookie(e):window[this.cacheLocation].getItem(e)},o.prototype.removeItem=function(e){return window[this.cacheLocation].removeItem(e)},o.prototype.clear=function(){return window[this.cacheLocation].clear()},o.prototype.setItemCookie=function(e,t,r){var n=encodeURIComponent(e)+"="+encodeURIComponent(t)+";path=/;";if(r){var i=this.getCookieExpirationTime(r);n+="expires="+i+";"}document.cookie=n},o.prototype.getItemCookie=function(e){for(var t=encodeURIComponent(e)+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var i=r[n];i.charAt(0)===" ";)i=i.substring(1);if(i.indexOf(t)===0)return decodeURIComponent(i.substring(t.length,i.length))}return""},o.prototype.clearItemCookie=function(e){this.setItemCookie(e,"",-1)},o.prototype.getCookieExpirationTime=function(e){var t=new Date,r=new Date(t.getTime()+e*24*60*60*1e3);return r.toUTCString()},o})();var F=(function(){function o(){}return o.validateRequest=function(e,t,r,n){if(!t&&!e)throw _.createEmptyRequestError();var i,a;e&&(i=t?N.appendScopes(e.scopes,e.extraScopesToConsent):e.scopes,N.validateInputScope(i,!t),i=N.translateClientIdIfSingleScope(i,r),this.validatePromptParameter(e.prompt),a=this.validateEQParameters(e.extraQueryParameters,e.claimsRequest),this.validateClaimsRequest(e.claimsRequest));var s=this.validateAndGenerateState(e&&e.state,n),c=this.validateAndGenerateCorrelationId(e&&e.correlationId),u=S(S({},e),{extraQueryParameters:a,scopes:i,state:s,correlationId:c});return u},o.validatePromptParameter=function(e){if(e&&[oe.LOGIN,oe.SELECT_ACCOUNT,oe.CONSENT,oe.NONE].indexOf(e)<0)throw _.createInvalidPromptError(e)},o.validateEQParameters=function(e,t){var r=S({},e);return r?(t&&delete r[l.claims],Ue.forEach(function(n){r[n]&&delete r[n]}),r):null},o.validateClaimsRequest=function(e){if(e)try{JSON.parse(e)}catch(t){throw _.createClaimsRequestParsingError(t)}},o.validateAndGenerateState=function(e,t){return m.isEmpty(e)?o.generateLibraryState(t):""+o.generateLibraryState(t)+l.resourceDelimiter+e},o.generateLibraryState=function(e){var t={id:b.createNewGuid(),ts:Y.now(),method:e},r=JSON.stringify(t);return b.base64Encode(r)},o.parseLibraryState=function(e){var t=decodeURIComponent(e).split(l.resourceDelimiter)[0];if(b.isGuid(t))return{id:t,ts:Y.now(),method:l.interactionTypeRedirect};try{var r=b.base64Decode(t),n=JSON.parse(r);return n}catch{throw E.createInvalidStateError(e,null)}},o.validateAndGenerateCorrelationId=function(e){if(e&&!b.isGuid(e))throw _.createInvalidCorrelationIdError();return b.isGuid(e)?e:b.createNewGuid()},o.createRequestSignature=function(e){return""+e.scopes.join(" ").toLowerCase()+l.resourceDelimiter+e.authority},o})();var A=(function(o){O(e,o);function e(t,r,n){var i=o.call(this,r)||this;return i.temporaryCache=new Ae(Ne),i.clientId=t,i.rollbackEnabled=!0,i.migrateCacheEntries(n),i}return e.prototype.migrateCacheEntries=function(t){var r=this,n=l.cachePrefix+"."+H.IDTOKEN,i=l.cachePrefix+"."+H.CLIENT_INFO,a=l.cachePrefix+"."+P.ERROR,s=l.cachePrefix+"."+P.ERROR_DESC,c=o.prototype.getItem.call(this,n),u;if(c)try{u=new $(c)}catch{return}if(u&&u.claims&&u.claims.aud===this.clientId){var h=o.prototype.getItem.call(this,i),T=o.prototype.getItem.call(this,a),y=o.prototype.getItem.call(this,s),C=[c,h,T,y],k=[H.IDTOKEN,H.CLIENT_INFO,P.ERROR,P.ERROR_DESC];k.forEach(function(x,V){return r.duplicateCacheEntry(x,C[V],t)})}},e.prototype.duplicateCacheEntry=function(t,r,n){r&&this.setItem(t,r,n)},e.prototype.generateCacheKey=function(t,r){try{return JSON.parse(t),t}catch{return t.indexOf(""+l.cachePrefix)===0||t.indexOf(l.adalIdToken)===0?t:r?l.cachePrefix+"."+this.clientId+"."+t:l.cachePrefix+"."+t}},e.prototype.matchKeyForType=function(t,r,n,i){var a=m.validateAndParseJsonCacheKey(t);if(!a)return null;var s=t.match(r)&&t.match(n),c=!1;switch(i){case p.ACCESS_TOKEN:c=!!t.match(l.scopes);break;case p.ID_TOKEN:c=!t.match(l.scopes);break}return s&&c?a:null},e.prototype.setItem=function(t,r,n){o.prototype.setItem.call(this,this.generateCacheKey(t,!0),r,n),this.rollbackEnabled&&!n&&o.prototype.setItem.call(this,this.generateCacheKey(t,!1),r,n)},e.prototype.getItem=function(t,r){return o.prototype.getItem.call(this,this.generateCacheKey(t,!0),r)},e.prototype.removeItem=function(t){this.temporaryCache.removeItem(this.generateCacheKey(t,!0)),o.prototype.removeItem.call(this,this.generateCacheKey(t,!0)),this.rollbackEnabled&&o.prototype.removeItem.call(this,this.generateCacheKey(t,!1))},e.prototype.setTemporaryItem=function(t,r,n){this.temporaryCache.setItem(this.generateCacheKey(t,!0),r,n)},e.prototype.getTemporaryItem=function(t,r){return this.temporaryCache.getItem(this.generateCacheKey(t,!0),r)},e.prototype.resetCacheItems=function(){var t=window[this.cacheLocation],r;for(r in t)t.hasOwnProperty(r)&&r.indexOf(l.cachePrefix)!==-1&&o.prototype.removeItem.call(this,r)},e.prototype.resetTempCacheItems=function(t){var r=this,n=t&&F.parseLibraryState(t).id,i=this.tokenRenewalInProgress(t),a=window[this.cacheLocation];n&&!i&&Object.keys(a).forEach(function(s){s.indexOf(n)!==-1&&(r.removeItem(s),o.prototype.clearItemCookie.call(r,s))}),this.setInteractionInProgress(!1),this.removeItem(I.REDIRECT_REQUEST)},e.prototype.setItemCookie=function(t,r,n){o.prototype.setItemCookie.call(this,this.generateCacheKey(t,!0),r,n),this.rollbackEnabled&&o.prototype.setItemCookie.call(this,this.generateCacheKey(t,!1),r,n)},e.prototype.clearItemCookie=function(t){o.prototype.clearItemCookie.call(this,this.generateCacheKey(t,!0)),this.rollbackEnabled&&o.prototype.clearItemCookie.call(this,this.generateCacheKey(t,!1))},e.prototype.getItemCookie=function(t){return o.prototype.getItemCookie.call(this,this.generateCacheKey(t,!0))},e.prototype.getAllTokensByType=function(t,r,n){var i=this,a=Object.keys(window[this.cacheLocation]).reduce(function(s,c){var u=i.matchKeyForType(c,t,r,n);if(u){var h=i.getItem(c);if(h)try{var T=new He(u,JSON.parse(h));return s.concat([T])}catch{return s}}return s},[]);return a},e.prototype.getAllAccessTokens=function(t,r){return this.getAllTokensByType(t,r,p.ACCESS_TOKEN)},e.prototype.getAllIdTokens=function(t,r){return this.getAllTokensByType(t,r,p.ID_TOKEN)},e.prototype.getAllTokens=function(t,r){var n=this.getAllAccessTokens(t,r),i=this.getAllIdTokens(t,r);return U(n,i)},e.prototype.isInteractionInProgress=function(t){var r=this.getInteractionInProgress();return t?r===this.clientId:!!r},e.prototype.getInteractionInProgress=function(){return this.getTemporaryItem(this.generateCacheKey(I.INTERACTION_STATUS,!1))},e.prototype.setInteractionInProgress=function(t){if(t){if(this.isInteractionInProgress(!1))throw E.createAcquireTokenInProgressError();this.setTemporaryItem(this.generateCacheKey(I.INTERACTION_STATUS,!1),this.clientId)}else!t&&this.isInteractionInProgress(!0)&&this.removeItem(this.generateCacheKey(I.INTERACTION_STATUS,!1))},e.prototype.tokenRenewalInProgress=function(t){var r=this.getItem(e.generateTemporaryCacheKey(I.RENEW_STATUS,t));return!!(r&&r===l.inProgress)},e.prototype.clearMsalCookie=function(t){var r=this;if(t)this.clearItemCookie(e.generateTemporaryCacheKey(I.NONCE_IDTOKEN,t)),this.clearItemCookie(e.generateTemporaryCacheKey(I.STATE_LOGIN,t)),this.clearItemCookie(e.generateTemporaryCacheKey(I.LOGIN_REQUEST,t)),this.clearItemCookie(e.generateTemporaryCacheKey(I.STATE_ACQ_TOKEN,t));else{var n=document.cookie.split(";");n.forEach(function(i){var a=i.trim().split("=")[0];a.indexOf(l.cachePrefix)>-1&&o.prototype.clearItemCookie.call(r,a)})}},e.generateAcquireTokenAccountKey=function(t,r){var n=F.parseLibraryState(r).id;return""+I.ACQUIRE_TOKEN_ACCOUNT+l.resourceDelimiter+t+l.resourceDelimiter+n},e.generateAuthorityKey=function(t){return e.generateTemporaryCacheKey(I.AUTHORITY,t)},e.generateTemporaryCacheKey=function(t,r){var n=F.parseLibraryState(r).id;return""+t+l.resourceDelimiter+n},e})(Ae);var ae=(function(){function o(e,t,r,n,i,a,s){this.accountIdentifier=e,this.homeAccountIdentifier=t,this.userName=r,this.name=n,this.idToken=i,this.idTokenClaims=i,this.sid=a,this.environment=s}return o.createAccount=function(e,t){var r=e.objectId||e.subject,n=t?t.uid:"",i=t?t.utid:"",a;return m.isEmpty(n)||(a=m.isEmpty(i)?b.base64Encode(n):b.base64Encode(n)+"."+b.base64Encode(i)),new o(r,a,e.preferredName,e.name,e.claims,e.sid,e.issuer)},o.compareAccounts=function(e,t){return!e||!t?!1:!!(e.homeAccountIdentifier&&t.homeAccountIdentifier&&e.homeAccountIdentifier===t.homeAccountIdentifier)},o})();var L=(function(){function o(){}return o.isInIframe=function(){return window.parent!==window},o.isInPopup=function(){return!!(window.opener&&window.opener!==window)},o.generateFrameName=function(e,t){return""+e+l.resourceDelimiter+t},o.monitorIframeForHash=function(e,t,r,n){return new Promise(function(i,a){var s=Y.relativeNowMs(),c=s+t;n.verbose("monitorWindowForIframe polling started");var u=setInterval(function(){if(Y.relativeNowMs()>c){n.error("monitorIframeForHash unable to find hash in url, timing out"),n.errorPii("monitorIframeForHash polling timed out for url: "+r),clearInterval(u),a(E.createTokenRenewalTimeoutError());return}var h;try{h=e.location.href}catch{}h&&f.urlContainsHash(h)&&(n.verbose("monitorIframeForHash found url in hash"),clearInterval(u),i(e.location.hash))},o.POLLING_INTERVAL_MS)})},o.monitorPopupForHash=function(e,t,r,n){return new Promise(function(i,a){var s=t/o.POLLING_INTERVAL_MS,c=0;n.verbose("monitorWindowForHash polling started");var u=setInterval(function(){if(e.closed){n.error("monitorWindowForHash window closed"),clearInterval(u),a(E.createUserCancelledError());return}var h;try{h=e.location.href}catch{}if(!(!h||h==="about:blank"))if(c++,h&&f.urlContainsHash(h)){n.verbose("monitorPopupForHash found url in hash"),clearInterval(u);var T=e.location.hash;o.clearUrlFragment(e),i(T)}else c>s&&(n.error("monitorPopupForHash unable to find hash in url, timing out"),n.errorPii("monitorPopupForHash polling timed out for url: "+r),clearInterval(u),a(E.createTokenRenewalTimeoutError()))},o.POLLING_INTERVAL_MS)})},o.loadFrame=function(e,t,r,n){var i=this;return n.infoPii("LoadFrame: "+t),new Promise(function(a,s){setTimeout(function(){var c=i.loadFrameSync(e,t,n);if(!c){s("Unable to load iframe with name: "+t);return}a(c)},r)})},o.loadFrameSync=function(e,t,r){var n=o.addHiddenIFrame(t,r);if(n)(n.src===""||n.src==="about:blank")&&(n.src=e,r.infoPii("Frame Name : "+t+" Navigated to: "+e));else return null;return n},o.addHiddenIFrame=function(e,t){if(typeof e>"u")return null;t.info("Add msal iframe to document"),t.infoPii("Add msal frame to document:"+e);var r=document.getElementById(e);if(r)t.verbose("Add msal iframe already exists");else{t.verbose("Add msal iframe does not exist");var n=document.createElement("iframe");n.setAttribute("id",e),n.setAttribute("aria-hidden","true"),n.style.visibility="hidden",n.style.position="absolute",n.style.width=n.style.height="0",n.style.border="0",n.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms"),r=document.getElementsByTagName("body")[0].appendChild(n)}return r},o.removeHiddenIframe=function(e){document.body===e.parentNode&&document.body.removeChild(e)},o.getIframeWithHash=function(e){var t=document.getElementsByTagName("iframe"),r=Array.apply(null,Array(t.length)).map(function(n,i){return t.item(i)});return r.filter(function(n){try{return n.contentWindow.location.hash===e}catch{return!1}})[0]},o.getPopups=function(){return window.openedWindows||(window.openedWindows=[]),window.openedWindows},o.getPopUpWithHash=function(e){return o.getPopups().filter(function(t){try{return t.location.hash===e}catch{return!1}})[0]},o.trackPopup=function(e){o.getPopups().push(e)},o.closePopups=function(){o.getPopups().forEach(function(e){return e.close()})},o.blockReloadInHiddenIframes=function(){if(f.urlContainsHash(window.location.hash)&&o.isInIframe())throw E.createBlockTokenRequestsInHiddenIframeError()},o.checkIfBackButtonIsPressed=function(e){var t=e.getItem(I.REDIRECT_REQUEST);if(t&&!f.urlContainsHash(window.location.hash)){var r=t.split(l.resourceDelimiter);r.shift();var n=r.length>0?r.join(l.resourceDelimiter):null;e.resetTempCacheItems(n)}},o.clearUrlFragment=function(e){e.location.hash="",typeof e.history.replaceState=="function"&&e.history.replaceState(null,null,""+e.location.pathname+e.location.search)},o.POLLING_INTERVAL_MS=50,o})();var ye=(function(){function o(){}return o.setResponseIdT