/*! msal v0.2.4 2018-10-15 */

'use strict';
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Msal",[],t):"object"==typeof exports?exports.Msal=t():e.Msal=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=10)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),o=function(){function e(){}return e.compareObjects=function(e,t){return!(!e||!t)&&!(!e.userIdentifier||!t.userIdentifier||e.userIdentifier!==t.userIdentifier)},e.expiresIn=function(e){return e||(e="3599"),this.now()+parseInt(e,10)},e.now=function(){return Math.round((new Date).getTime()/1e3)},e.isEmpty=function(e){return void 0===e||!e||0===e.length},e.extractIdToken=function(e){var t=this.decodeJwt(e);if(!t)return null;try{var n=t.JWSPayload,r=this.base64DecodeStringUrlSafe(n);return r?JSON.parse(r):null}catch(e){}return null},e.base64EncodeStringUrlSafe=function(e){return window.btoa?window.btoa(e):this.encode(e)},e.base64DecodeStringUrlSafe=function(e){return e=e.replace(/-/g,"+").replace(/_/g,"/"),window.atob?decodeURIComponent(encodeURIComponent(window.atob(e))):decodeURIComponent(encodeURIComponent(this.decode(e)))},e.encode=function(e){var t,n,r,o,i,s,a,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u="",l=0;for(e=this.utf8Encode(e);l<e.length;)t=e.charCodeAt(l++),n=e.charCodeAt(l++),r=e.charCodeAt(l++),o=t>>2,i=(3&t)<<4|n>>4,s=(15&n)<<2|r>>6,a=63&r,isNaN(n)?s=a=64:isNaN(r)&&(a=64),u=u+c.charAt(o)+c.charAt(i)+c.charAt(s)+c.charAt(a);return u.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},e.utf8Encode=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t},e.decode=function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e=String(e).replace(/=+$/,"");var n=e.length;if(n%4==1)throw new Error("The token to be decoded is not correctly encoded.");for(var r,o,i,s,a,c,u,l,d="",h=0;h<n;h+=4){if(r=t.indexOf(e.charAt(h)),o=t.indexOf(e.charAt(h+1)),i=t.indexOf(e.charAt(h+2)),s=t.indexOf(e.charAt(h+3)),h+2===n-1){a=r<<18|o<<12|i<<6,c=a>>16&255,u=a>>8&255,d+=String.fromCharCode(c,u);break}if(h+1===n-1){a=r<<18|o<<12,c=a>>16&255,d+=String.fromCharCode(c);break}a=r<<18|o<<12|i<<6|s,c=a>>16&255,u=a>>8&255,l=255&a,d+=String.fromCharCode(c,u,l)}return d},e.decodeJwt=function(e){if(this.isEmpty(e))return null;var t=/^([^\.\s]*)\.([^\.\s]+)\.([^\.\s]*)$/,n=t.exec(e);return!n||n.length<4?null:{header:n[1],JWSPayload:n[2],JWSSig:n[3]}},e.deserialize=function(e){var t,n=/\+/g,r=/([^&=]+)=([^&]*)/g,o=function(e){return decodeURIComponent(e.replace(n," "))},i={};for(t=r.exec(e);t;)i[o(t[1])]=o(t[2]),t=r.exec(e);return i},e.isIntersectingScopes=function(e,t){e=this.convertToLowerCase(e);for(var n=0;n<t.length;n++)if(e.indexOf(t[n].toLowerCase())>-1)return!0;return!1},e.containsScope=function(e,t){return e=this.convertToLowerCase(e),t.every(function(t){return e.indexOf(t.toString().toLowerCase())>=0})},e.convertToLowerCase=function(e){return e.map(function(e){return e.toLowerCase()})},e.removeElement=function(e,t){return e.filter(function(e){return e!==t})},e.decimalToHex=function(e){for(var t=e.toString(16);t.length<2;)t="0"+t;return t},e.getLibraryVersion=function(){return"0.2.4"},e.replaceFirstPath=function(e,t){if(!t)return e;var n=this.GetUrlComponents(e),o=n.PathSegments;return 0===o.length||o[0]!==r.Constants.common&&o[0]!==r.Constants.organizations||(o[0]=t,e=n.Protocol+"//"+n.HostNameAndPort+"/"+o.join("/")),e},e.createNewGuid=function(){var t=window.crypto;if(t&&t.getRandomValues){var n=new Uint8Array(16);return t.getRandomValues(n),n[6]|=64,n[6]&=79,n[8]|=128,n[8]&=191,e.decimalToHex(n[0])+e.decimalToHex(n[1])+e.decimalToHex(n[2])+e.decimalToHex(n[3])+"-"+e.decimalToHex(n[4])+e.decimalToHex(n[5])+"-"+e.decimalToHex(n[6])+e.decimalToHex(n[7])+"-"+e.decimalToHex(n[8])+e.decimalToHex(n[9])+"-"+e.decimalToHex(n[10])+e.decimalToHex(n[11])+e.decimalToHex(n[12])+e.decimalToHex(n[13])+e.decimalToHex(n[14])+e.decimalToHex(n[15])}for(var r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",o="0123456789abcdef",i=0,s="",a=0;a<36;a++)"-"!==r[a]&&"4"!==r[a]&&(i=16*Math.random()|0),"x"===r[a]?s+=o[i]:"y"===r[a]?(i&=3,i|=8,s+=o[i]):s+=r[a];return s},e.GetUrlComponents=function(e){if(!e)throw"Url required";var t=RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?"),n=e.match(t);if(!n||n.length<6)throw"Valid url required";var r={Protocol:n[1],HostNameAndPort:n[4],AbsolutePath:n[5]},o=r.AbsolutePath.split("/");return o=o.filter(function(e){return e&&e.length>0}),r.PathSegments=o,r},e.CanonicalizeUri=function(t){return t&&(t=t.toLowerCase()),t&&!e.endsWith(t,"/")&&(t+="/"),t},e.endsWith=function(e,t){return!(!e||!t)&&-1!==e.indexOf(t,e.length-t.length)},e.checkSSO=function(e){return!(e&&(-1!==e.indexOf(r.Constants.login_hint)||-1!==e.indexOf(r.Constants.sid)))},e.constructUnifiedCacheExtraQueryParameter=function(e,t){return e?e.hasOwnProperty(r.Constants.upn)?(t=this.urlRemoveQueryStringParameter(t,r.Constants.login_hint),t=this.urlRemoveQueryStringParameter(t,r.Constants.domain_hint),t?t+="&"+r.Constants.login_hint+"="+e.upn+"&"+r.Constants.domain_hint+"="+r.Constants.organizations:t="&"+r.Constants.login_hint+"="+e.upn+"&"+r.Constants.domain_hint+"="+r.Constants.organizations):(t=this.urlRemoveQueryStringParameter(t,r.Constants.domain_hint),t?t+="&"+r.Constants.domain_hint+"="+r.Constants.organizations:t="&"+r.Constants.domain_hint+"="+r.Constants.organizations):t},e.urlRemoveQueryStringParameter=function(e,t){if(this.isEmpty(e))return e;var n=new RegExp("(\\&"+t+"=)[^&]+");return e=e.replace(n,""),n=new RegExp("("+t+"=)[^&]+&"),e=e.replace(n,""),n=new RegExp("("+t+"=)[^&]+"),e=e.replace(n,"")},e}();t.Utils=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return Object.defineProperty(e,"errorDescription",{get:function(){return"error_description"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"error",{get:function(){return"error"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"scope",{get:function(){return"scope"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"acquireTokenUser",{get:function(){return"msal.acquireTokenUser"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"clientInfo",{get:function(){return"client_info"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"clientId",{get:function(){return"clientId"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"authority",{get:function(){return"msal.authority"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"idToken",{get:function(){return"id_token"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"accessToken",{get:function(){return"access_token"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"expiresIn",{get:function(){return"expires_in"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"sessionState",{get:function(){return"session_state"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"msalClientInfo",{get:function(){return"msal.client.info"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"msalError",{get:function(){return"msal.error"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"msalErrorDescription",{get:function(){return"msal.error.description"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"msalSessionState",{get:function(){return"msal.session.state"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"tokenKeys",{get:function(){return"msal.token.keys"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"accessTokenKey",{get:function(){return"msal.access.token.key"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"expirationKey",{get:function(){return"msal.expiration.key"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"stateLogin",{get:function(){return"msal.state.login"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"stateAcquireToken",{get:function(){return"msal.state.acquireToken"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"stateRenew",{get:function(){return"msal.state.renew"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"nonceIdToken",{get:function(){return"msal.nonce.idtoken"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"userName",{get:function(){return"msal.username"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"idTokenKey",{get:function(){return"msal.idtoken"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"loginRequest",{get:function(){return"msal.login.request"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"loginError",{get:function(){return"msal.login.error"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"renewStatus",{get:function(){return"msal.token.renew.status"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"msal",{get:function(){return"msal"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"no_user",{get:function(){return"NO_USER"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"login_hint",{get:function(){return"login_hint"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"domain_hint",{get:function(){return"domain_hint"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"organizations",{get:function(){return"organizations"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"consumers",{get:function(){return"consumers"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"consumersUtid",{get:function(){return"9188040d-6c67-4c5b-b112-36a304b66dad"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"sid",{get:function(){return"sid"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"upn",{get:function(){return"upn"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"adalIdToken",{get:function(){return"adal.idtoken"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"prompt_select_account",{get:function(){return"&prompt=select_account"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"prompt_none",{get:function(){return"&prompt=none"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"prompt",{get:function(){return"prompt"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"response_mode_fragment",{get:function(){return"&response_mode=fragment"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"resourceDelimeter",{get:function(){return"|"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"tokenRenewStatusCancelled",{get:function(){return"Canceled"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"tokenRenewStatusCompleted",{get:function(){return"Completed"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"tokenRenewStatusInProgress",{get:function(){return"In Progress"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"popUpWidth",{get:function(){return this._popUpWidth},set:function(e){this._popUpWidth=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"popUpHeight",{get:function(){return this._popUpHeight},set:function(e){this._popUpHeight=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"login",{get:function(){return"LOGIN"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"renewToken",{get:function(){return"RENEW_TOKEN"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unknown",{get:function(){return"UNKNOWN"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"urlHash",{get:function(){return"msal.urlHash"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"angularLoginRequest",{get:function(){return"msal.angular.login.request"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"userIdentifier",{get:function(){return"userIdentifier"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"common",{get:function(){return"common"},enumerable:!0,configurable:!0}),e._popUpWidth=483,e._popUpHeight=600,e}();t.Constants=r;var o=function(){function e(){}return Object.defineProperty(e,"loginProgressError",{get:function(){return"login_progress_error"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"acquireTokenProgressError",{get:function(){return"acquiretoken_progress_error"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"inputScopesError",{get:function(){return"input_scopes_error"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"endpointResolutionError",{get:function(){return"endpoints_resolution_error"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"popUpWindowError",{get:function(){return"popup_window_error"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"userLoginError",{get:function(){return"user_login_error"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"userCancelledError",{get:function(){return"user_cancelled"},enumerable:!0,configurable:!0}),e}();t.ErrorCodes=o;var i=function(){function e(){}return Object.defineProperty(e,"loginProgressError",{get:function(){return"Login is in progress"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"acquireTokenProgressError",{get:function(){return"Acquire token is in progress"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"inputScopesError",{get:function(){return"Invalid value of input scopes provided"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"endpointResolutionError",{get:function(){return"Endpoints cannot be resolved"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"popUpWindowError",{get:function(){return"Error opening popup window. This can happen if you are using IE or if popups are blocked in the browser."},enumerable:!0,configurable:!0}),Object.defineProperty(e,"userLoginError",{get:function(){return"User login is required"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"userCancelledError",{get:function(){return"User closed the popup window and cancelled the flow"},enumerable:!0,configurable:!0}),e}();t.ErrorDescription=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=n(5),i=n(9);!function(e){e[e.Aad=0]="Aad",e[e.Adfs=1]="Adfs",e[e.B2C=2]="B2C"}(t.AuthorityType||(t.AuthorityType={}));var s=function(){function e(e,t){this.IsValidationEnabled=t,this.CanonicalAuthority=e,this.validateAsUri()}return Object.defineProperty(e.prototype,"Tenant",{get:function(){return this.CanonicalAuthorityUrlComponents.PathSegments[0]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"AuthorizationEndpoint",{get:function(){return this.validateResolved(),this.tenantDiscoveryResponse.AuthorizationEndpoint.replace("{tenant}",this.Tenant)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"EndSessionEndpoint",{get:function(){return this.validateResolved(),this.tenantDiscoveryResponse.EndSessionEndpoint.replace("{tenant}",this.Tenant)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"SelfSignedJwtAudience",{get:function(){return this.validateResolved(),this.tenantDiscoveryResponse.Issuer.replace("{tenant}",this.Tenant)},enumerable:!0,configurable:!0}),e.prototype.validateResolved=function(){if(!this.tenantDiscoveryResponse)throw"Please call ResolveEndpointsAsync first"},Object.defineProperty(e.prototype,"CanonicalAuthority",{get:function(){return this.canonicalAuthority},set:function(e){this.canonicalAuthority=r.Utils.CanonicalizeUri(e),this.canonicalAuthorityUrlComponents=null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CanonicalAuthorityUrlComponents",{get:function(){return this.canonicalAuthorityUrlComponents||(this.canonicalAuthorityUrlComponents=r.Utils.GetUrlComponents(this.CanonicalAuthority)),this.canonicalAuthorityUrlComponents},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"DefaultOpenIdConfigurationEndpoint",{get:function(){return this.CanonicalAuthority+"v2.0/.well-known/openid-configuration"},enumerable:!0,configurable:!0}),e.prototype.validateAsUri=function(){var e;try{e=this.CanonicalAuthorityUrlComponents}catch(e){throw o.ErrorMessage.invalidAuthorityType}if(!e.Protocol||"https:"!==e.Protocol.toLowerCase())throw o.ErrorMessage.authorityUriInsecure;if(!e.PathSegments||e.PathSegments.length<1)throw o.ErrorMessage.authorityUriInvalidPath},e.prototype.DiscoverEndpoints=function(e){return(new i.XhrClient).sendRequestAsync(e,"GET",!0).then(function(e){return{AuthorizationEndpoint:e.authorization_endpoint,EndSessionEndpoint:e.end_session_endpoint,Issuer:e.issuer}})},e.prototype.ResolveEndpointsAsync=function(){var e=this,t="";return this.GetOpenIdConfigurationEndpointAsync().then(function(n){return t=n,e.DiscoverEndpoints(t)}).then(function(t){return e.tenantDiscoveryResponse=t,e})},e}();t.Authority=s},function(e,t,n){"use strict";function r(e,t){function n(){this.constructor=e}_(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function o(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&(n[r[o]]=e[r[o]]);return n}function i(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s}function s(e,t){return function(n,r){t(n,r,e)}}function a(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function c(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})}function u(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(o)throw new TypeError("Generator is already executing.");for(;c;)try{if(o=1,i&&(s=i[2&n[0]?"return":n[0]?"throw":"next"])&&!(s=s.call(i,n[1])).done)return s;switch(i=0,s&&(n=[0,s.value]),n[0]){case 0:case 1:s=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,i=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(s=c.trys,!(s=s.length>0&&s[s.length-1])&&(6===n[0]||2===n[0])){c=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]<s[3])){c.label=n[1];break}if(6===n[0]&&c.label<s[1]){c.label=s[1],s=n;break}if(s&&c.label<s[2]){c.label=s[2],c.ops.push(n);break}s[2]&&c.ops.pop(),c.trys.pop();continue}n=t.call(e,c)}catch(e){n=[6,e],i=0}finally{o=s=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var o,i,s,a,c={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return a={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a}function l(e,t){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}function d(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}function h(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function p(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(h(arguments[t]));return e}function f(e){return this instanceof f?(this.v=e,this):new f(e)}function g(e,t,n){function r(e){l[e]&&(u[e]=function(t){return new Promise(function(n,r){d.push([e,t,n,r])>1||o(e,t)})})}function o(e,t){try{i(l[e](t))}catch(e){c(d[0][3],e)}}function i(e){e.value instanceof f?Promise.resolve(e.value.v).then(s,a):c(d[0][2],e)}function s(e){o("next",e)}function a(e){o("throw",e)}function c(e,t){e(t),d.shift(),d.length&&o(d[0][0],d[0][1])}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var u,l=n.apply(e,t||[]),d=[];return u={},r("next"),r("throw"),r("return"),u[Symbol.asyncIterator]=function(){return this},u}function m(e){function t(t,o){e[t]&&(n[t]=function(n){return(r=!r)?{value:f(e[t](n)),done:"return"===t}:o?o(n):n})}var n,r;return n={},t("next"),t("throw",function(e){throw e}),t("return"),n[Symbol.iterator]=function(){return this},n}function y(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator];return t?t.call(e):"function"==typeof d?d(e):e[Symbol.iterator]()}Object.defineProperty(t,"__esModule",{value:!0}),t.__extends=r,n.d(t,"__assign",function(){return C}),t.__rest=o,t.__decorate=i,t.__param=s,t.__metadata=a,t.__awaiter=c,t.__generator=u,t.__exportStar=l,t.__values=d,t.__read=h,t.__spread=p,t.__await=f,t.__asyncGenerator=g,t.__asyncDelegator=m,t.__asyncValues=y;/*! *****************************************************************************
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 _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},C=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=n(0);!function(e){e[e.Error=0]="Error",e[e.Warning=1]="Warning",e[e.Info=2]="Info",e[e.Verbose=3]="Verbose"}(r=t.LogLevel||(t.LogLevel={}));var i=function(){function e(e,t){void 0===t&&(t={}),this._level=r.Info;var n=t.correlationId,o=void 0===n?"":n,i=t.level,s=void 0===i?r.Info:i,a=t.piiLoggingEnabled,c=void 0!==a&&a;this._localCallback=e,this._correlationId=o,this._level=s,this._piiLoggingEnabled=c}return e.prototype.logMessage=function(e,t,n){if(!(e>this._level||!this._piiLoggingEnabled&&n)){var i,s=(new Date).toUTCString();i=o.Utils.isEmpty(this._correlationId)?s+":"+o.Utils.getLibraryVersion()+"-"+r[e]+" "+t:s+":"+this._correlationId+"-"+o.Utils.getLibraryVersion()+"-"+r[e]+" "+t,this.executeCallback(e,i,n)}},e.prototype.executeCallback=function(e,t,n){this._localCallback&&this._localCallback(e,t,n)},e.prototype.error=function(e){this.logMessage(r.Error,e,!1)},e.prototype.errorPii=function(e){this.logMessage(r.Error,e,!0)},e.prototype.warning=function(e){this.logMessage(r.Warning,e,!1)},e.prototype.warningPii=function(e){this.logMessage(r.Warning,e,!0)},e.prototype.info=function(e){this.logMessage(r.Info,e,!1)},e.prototype.infoPii=function(e){this.logMessage(r.Info,e,!0)},e.prototype.verbose=function(e){this.logMessage(r.Verbose,e,!1)},e.prototype.verbosePii=function(e){this.logMessage(r.Verbose,e,!0)},e}();t.Logger=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return Object.defineProperty(e,"authorityUriInvalidPath",{get:function(){return"AuthorityUriInvalidPath"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"authorityUriInsecure",{get:function(){return"AuthorityUriInsecure"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"invalidAuthorityType",{get:function(){return"InvalidAuthorityType"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unsupportedAuthorityValidation",{get:function(){return"UnsupportedAuthorityValidation"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"b2cAuthorityUriInvalidPath",{get:function(){return"B2cAuthorityUriInvalidPath"},enumerable:!0,configurable:!0}),e}();t.ErrorMessage=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this.valid=!1,this.parameters={},this.stateMatch=!1,this.stateResponse="",this.requestType="unknown"}return e}();t.TokenResponse=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=function(){function e(e,t,n,r,o,i){this.displayableId=e,this.name=t,this.identityProvider=n,this.userIdentifier=r,this.idToken=o,this.sid=i}return e.createUser=function(t,n){var o,i;n?(o=n.uid,i=n.utid):(o="",i="");var s=r.Utils.base64EncodeStringUrlSafe(o)+"."+r.Utils.base64EncodeStringUrlSafe(i);return new e(t.preferredName,t.name,t.issuer,s,t.decodedIdToken,t.sid)},e}();t.User=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),o=n(2),i=n(9),s=function(e){function t(t,n){return e.call(this,t,n)||this}return r.__extends(t,e),Object.defineProperty(t.prototype,"AadInstanceDiscoveryEndpointUrl",{get:function(){return t.AadInstanceDiscoveryEndpoint+"?api-version=1.0&authorization_endpoint="+this.CanonicalAuthority+"oauth2/v2.0/authorize"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"AuthorityType",{get:function(){return o.AuthorityType.Aad},enumerable:!0,configurable:!0}),t.prototype.GetOpenIdConfigurationEndpointAsync=function(){var e=this,t=new Promise(function(t,n){return t(e.DefaultOpenIdConfigurationEndpoint)});if(!this.IsValidationEnabled)return t;var n=this.CanonicalAuthorityUrlComponents.HostNameAndPort;return this.IsInTrustedHostList(n)?t:(new i.XhrClient).sendRequestAsync(this.AadInstanceDiscoveryEndpointUrl,"GET",!0).then(function(e){return e.tenant_discovery_endpoint})},t.prototype.IsInTrustedHostList=function(e){return t.TrustedHostList[e.toLowerCase()]},t.AadInstanceDiscoveryEndpoint="https://login.microsoftonline.com/common/discovery/instance",t.TrustedHostList={"login.windows.net":"login.windows.net","login.chinacloudapi.cn":"login.chinacloudapi.cn","login.cloudgovapi.us":"login.cloudgovapi.us","login.microsoftonline.com":"login.microsoftonline.com","login.microsoftonline.de":"login.microsoftonline.de","login.microsoftonline.us":"login.microsoftonline.us"},t}(o.Authority);t.AadAuthority=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return e.prototype.sendRequestAsync=function(e,t,n){var r=this;return new Promise(function(n,o){var i=new XMLHttpRequest;if(i.open(t,e,!0),i.onload=function(e){(i.status<200||i.status>=300)&&o(r.handleError(i.responseText));try{var t=JSON.parse(i.responseText)}catch(e){o(r.handleError(i.responseText))}n(t)},i.onerror=function(e){o(i.status)},"GET"!==t)throw"not implemented";i.send()})},e.prototype.handleError=function(e){var t;try{if(t=JSON.parse(e),t.error)return t.error;throw e}catch(t){return e}},e}();t.XhrClient=r},function(e,t,n){e.exports=n(11)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(12);t.UserAgentApplication=r.UserAgentApplication;var o=n(4);t.Logger=o.Logger;var i=n(4);t.LogLevel=i.LogLevel;var s=n(7);t.User=s.User;var a=n(1);t.Constants=a.Constants;var c=n(6);t.TokenResponse=c.TokenResponse;var u=n(2);t.Authority=u.Authority},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),o=n(13),i=n(14),s=n(15),a=n(16),c=n(1),u=n(17),l=n(4),d=n(18),h=n(6),p=n(7),f=n(0),g=n(20),m={id_token:"id_token",token:"token",id_token_token:"id_token token"},y=function(e,t,n){var r=n.value;return n.value=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.isInIframe()?new Promise(function(){}):r.apply(this,e)},n},_=function(){function e(e,t,n,r){void 0===r&&(r={}),this._cacheLocations={localStorage:"localStorage",sessionStorage:"sessionStorage"},this._clockSkew=300,this._tokenReceivedCallback=null,this._isAngular=!1;var o=r.validateAuthority,i=void 0===o||o,s=r.cacheLocation,a=void 0===s?"sessionStorage":s,u=r.redirectUri,h=void 0===u?window.location.href.split("?")[0].split("#")[0]:u,p=r.postLogoutRedirectUri,f=void 0===p?window.location.href.split("?")[0].split("#")[0]:p,g=r.logger,m=void 0===g?new l.Logger(null):g,y=r.loadFrameTimeout,_=void 0===y?6e3:y,C=r.navigateToLoginRequestUrl,w=void 0===C||C,v=r.state,I=void 0===v?"":v,b=r.isAngular,k=void 0!==b&&b,S=r.unprotectedResources,T=void 0===S?new Array:S,P=r.protectedResourceMap,A=void 0===P?new Map:P,U=r.storeAuthStateInCookie,E=void 0!==U&&U;if(this.loadFrameTimeout=_,this.clientId=e,this.validateAuthority=i,this.authority=t||"https://login.microsoftonline.com/common",this._tokenReceivedCallback=n,this._redirectUri=h,this._postLogoutredirectUri=f,this._loginInProgress=!1,this._acquireTokenInProgress=!1,this._cacheLocation=a,this._navigateToLoginRequestUrl=w,this._state=I,this._isAngular=k,this._unprotectedResources=T,this._protectedResourceMap=A,!this._cacheLocations[a])throw new Error("Cache Location is not valid. Provided value:"+this._cacheLocation+".Possible values are: "+this._cacheLocations.localStorage+", "+this._cacheLocations.sessionStorage);this._cacheStorage=new d.Storage(this._cacheLocation),this._logger=m,this.storeAuthStateInCookie=E,window.openedWindows=[],window.activeRenewals={},window.renewStates=[],window.callBackMappedToRenewStates={},window.callBacksMappedToRenewStates={},window.msal=this;var O=window.location.hash,R=this.isCallback(O);if(!this._isAngular)if(R)this.handleAuthenticationResponse.call(this,O);else{var x=this._cacheStorage.getItem(c.Constants.urlHash);x&&this.processCallBack(x)}}return Object.defineProperty(e.prototype,"cacheLocation",{get:function(){return this._cacheLocation},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"authority",{get:function(){return this.authorityInstance.CanonicalAuthority},set:function(e){this.authorityInstance=g.AuthorityFactory.CreateInstance(e,this.validateAuthority)},enumerable:!0,configurable:!0}),e.prototype.processCallBack=function(e){this._logger.info("Processing the callback from redirect response");var t=this.getRequestInfo(e);this.saveTokenFromHash(t);var n,r=t.parameters[c.Constants.accessToken]||t.parameters[c.Constants.idToken],o=t.parameters[c.Constants.errorDescription],i=t.parameters[c.Constants.error];n=t.parameters[c.Constants.accessToken]?c.Constants.accessToken:c.Constants.idToken,this._cacheStorage.removeItem(c.Constants.urlHash);try{this._tokenReceivedCallback&&(this._cacheStorage.clearCookie(),this._tokenReceivedCallback.call(this,o,r,i,n,this.getUserState(this._cacheStorage.getItem(c.Constants.stateLogin,this.storeAuthStateInCookie))))}catch(e){this._logger.error("Error occurred in token received callback function: "+e)}},e.prototype.loginRedirect=function(e,t){var n=this;if(this._loginInProgress&&this._tokenReceivedCallback)return void this._tokenReceivedCallback(c.ErrorDescription.loginProgressError,null,c.ErrorCodes.loginProgressError,c.Constants.idToken,this.getUserState(this._cacheStorage.getItem(c.Constants.stateLogin,this.storeAuthStateInCookie)));if(e){var r=this.validateInputScope(e);if(r&&!f.Utils.isEmpty(r)&&this._tokenReceivedCallback)return void this._tokenReceivedCallback(c.ErrorDescription.inputScopesError,null,c.ErrorCodes.inputScopesError,c.Constants.idToken,this.getUserState(this._cacheStorage.getItem(c.Constants.stateLogin,this.storeAuthStateInCookie)));e=this.filterScopes(e)}var o;o=this.extractADALIdToken(),o&&!e?(this._logger.info("ADAL's idToken exists. Extracting login information from ADAL's idToken "),t=f.Utils.constructUnifiedCacheExtraQueryParameter(o,t),this._silentLogin=!0,this.acquireTokenSilent([this.clientId],this.authority,this.getUser(),t).then(function(e){n._silentLogin=!1,n._logger.info("Unified cache call is successful"),n._tokenReceivedCallback&&n._tokenReceivedCallback.call(n,null,e,null,c.Constants.idToken,n.getUserState(n._silentAuthenticationState))},function(r){n._silentLogin=!1,n._logger.error("Error occurred during unified cache ATS"),n.loginRedirectHelper(e,t)})):this.loginRedirectHelper(e,t)},e.prototype.loginRedirectHelper=function(e,t){var n=this;this._loginInProgress=!0,this.authorityInstance.ResolveEndpointsAsync().then(function(){var r=new s.AuthenticationRequestParameters(n.authorityInstance,n.clientId,e,m.id_token,n._redirectUri,n._state);t&&(r.extraQueryParameters=t);var o=n._cacheStorage.getItem(c.Constants.angularLoginRequest);o&&""!==o?n._cacheStorage.setItem(c.Constants.angularLoginRequest,""):o=window.location.href,n._cacheStorage.setItem(c.Constants.loginRequest,o,n.storeAuthStateInCookie),n._cacheStorage.setItem(c.Constants.loginError,""),n._cacheStorage.setItem(c.Constants.stateLogin,r.state,n.storeAuthStateInCookie),n._cacheStorage.setItem(c.Constants.nonceIdToken,r.nonce,n.storeAuthStateInCookie),n._cacheStorage.setItem(c.Constants.msalError,""),n._cacheStorage.setItem(c.Constants.msalErrorDescription,"");var i=c.Constants.authority+c.Constants.resourceDelimeter+r.state;n._cacheStorage.setItem(i,n.authority,n.storeAuthStateInCookie);var a=r.createNavigateUrl(e)+c.Constants.prompt_select_account+c.Constants.response_mode_fragment;n.promptUser(a)})},e.prototype.loginPopup=function(e,t){var n=this;return new Promise(function(r,o){if(n._loginInProgress)return void o(c.ErrorCodes.loginProgressError+c.Constants.resourceDelimeter+c.ErrorDescription.loginProgressError);if(e){var i=n.validateInputScope(e);if(i&&!f.Utils.isEmpty(i))return void o(c.ErrorCodes.inputScopesError+c.Constants.resourceDelimeter+c.ErrorDescription.inputScopesError);e=n.filterScopes(e)}var s;s=n.extractADALIdToken(),s&&!e?(n._logger.info("ADAL's idToken exists. Extracting login information from ADAL's idToken "),t=f.Utils.constructUnifiedCacheExtraQueryParameter(s,t),n._silentLogin=!0,n.acquireTokenSilent([n.clientId],n.authority,n.getUser(),t).then(function(e){n._silentLogin=!1,n._logger.info("Unified cache call is successful"),r(e)},function(i){n._silentLogin=!1,n._logger.error("Error occurred during unified cache ATS"),n.loginPopupHelper(r,o,e,t)})):n.loginPopupHelper(r,o,e,t)})},e.prototype.loginPopupHelper=function(e,t,n,r){var o=this;n||(n=[this.clientId]);var i=n.join(" ").toLowerCase(),a=this.openWindow("about:blank","_blank",1,this,e,t);a&&(this._loginInProgress=!0,this.authorityInstance.ResolveEndpointsAsync().then(function(){var u=new s.AuthenticationRequestParameters(o.authorityInstance,o.clientId,n,m.id_token,o._redirectUri,o._state);r&&(u.extraQueryParameters=r),o._cacheStorage.setItem(c.Constants.loginRequest,window.location.href,o.storeAuthStateInCookie),o._cacheStorage.setItem(c.Constants.loginError,""),o._cacheStorage.setItem(c.Constants.nonceIdToken,u.nonce,o.storeAuthStateInCookie),o._cacheStorage.setItem(c.Constants.msalError,""),o._cacheStorage.setItem(c.Constants.msalErrorDescription,"");var l=c.Constants.authority+c.Constants.resourceDelimeter+u.state;o._cacheStorage.setItem(l,o.authority,o.storeAuthStateInCookie);var d=u.createNavigateUrl(n)+c.Constants.prompt_select_account+c.Constants.response_mode_fragment;window.renewStates.push(u.state),window.requestType=c.Constants.login,o.registerCallback(u.state,i,e,t),a&&(o._logger.infoPii("Navigated Popup window to:"+d),a.location.href=d)},function(){o._logger.info(c.ErrorCodes.endpointResolutionError+":"+c.ErrorDescription.endpointResolutionError),o._cacheStorage.setItem(c.Constants.msalError,c.ErrorCodes.endpointResolutionError),o._cacheStorage.setItem(c.Constants.msalErrorDescription,c.ErrorDescription.endpointResolutionError),t&&t(c.ErrorCodes.endpointResolutionError+":"+c.ErrorDescription.endpointResolutionError),a&&a.close()}).catch(function(e){o._logger.warning("could not resolve endpoints"),t(e)}))},e.prototype.promptUser=function(e){e&&!f.Utils.isEmpty(e)?(this._logger.infoPii("Navigate to:"+e),window.location.replace(e)):this._logger.info("Navigate url is empty")},e.prototype.openWindow=function(e,t,n,r,o,i){var s=this,a=this.openPopup(e,t,c.Constants.popUpWidth,c.Constants.popUpHeight);if(null==a)return r._loginInProgress=!1,r._acquireTokenInProgress=!1,this._logger.info(c.ErrorCodes.popUpWindowError+":"+c.ErrorDescription.popUpWindowError),this._cacheStorage.setItem(c.Constants.msalError,c.ErrorCodes.popUpWindowError),this._cacheStorage.setItem(c.Constants.msalErrorDescription,c.ErrorDescription.popUpWindowError),i&&i(c.ErrorCodes.popUpWindowError+c.Constants.resourceDelimeter+c.ErrorDescription.popUpWindowError),null;window.openedWindows.push(a);var u=window.setInterval(function(){if(a&&a.closed&&r._loginInProgress){if(i&&i(c.ErrorCodes.userCancelledError+c.Constants.resourceDelimeter+c.ErrorDescription.userCancelledError),window.clearInterval(u),s._isAngular)return void s.broadcast("msal:popUpClosed",c.ErrorCodes.userCancelledError+c.Constants.resourceDelimeter+c.ErrorDescription.userCancelledError);r._loginInProgress=!1,r._acquireTokenInProgress=!1}try{var e=a.location;if(-1!==e.href.indexOf(s._redirectUri)&&(window.clearInterval(u),r._loginInProgress=!1,r._acquireTokenInProgress=!1,s._logger.info("Closing popup window"),s._isAngular)){s.broadcast("msal:popUpHashChanged",e.hash);for(var t=0;t<window.openedWindows.length;t++)window.openedWindows[t].close()}}catch(e){}},n);return a},e.prototype.broadcast=function(e,t){var n=new CustomEvent(e,{detail:t});window.dispatchEvent(n)},e.prototype.logout=function(){this.clearCache(),this._user=null;var e="";this._postLogoutredirectUri&&(e="post_logout_redirect_uri="+encodeURIComponent(this._postLogoutredirectUri));var t=this.authority+"/oauth2/v2.0/logout?"+e;this.promptUser(t)},e.prototype.clearCache=function(){window.renewStates=[];for(var e=this._cacheStorage.getAllAccessTokens(c.Constants.clientId,c.Constants.userIdentifier),t=0;t<e.length;t++)this._cacheStorage.removeItem(JSON.stringify(e[t].key));this._cacheStorage.resetCacheItems(),this._cacheStorage.clearCookie()},e.prototype.clearCacheForScope=function(e){for(var t=this._cacheStorage.getAllAccessTokens(c.Constants.clientId,c.Constants.userIdentifier),n=0;n<t.length;n++){var r=t[n];r.value.accessToken==e&&this._cacheStorage.removeItem(JSON.stringify(r.key))}},e.prototype.openPopup=function(e,t,n,r){try{var o=window.screenLeft?window.screenLeft:window.screenX,i=window.screenTop?window.screenTop:window.screenY,s=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,a=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,c=s/2-n/2+o,u=a/2-r/2+i,l=window.open(e,t,"width="+n+", height="+r+", top="+u+", left="+c);return l.focus&&l.focus(),l}catch(e){return this._logger.error("error opening popup "+e.message),this._loginInProgress=!1,this._acquireTokenInProgress=!1,null}},e.prototype.validateInputScope=function(e){if(!e||e.length<1)return"Scopes cannot be passed as an empty array";if(!Array.isArray(e))throw new Error("API does not accept non-array scopes");return e.indexOf(this.clientId)>-1&&e.length>1?"ClientId can only be provided as a single scope":""},e.prototype.filterScopes=function(e){return e=e.filter(function(e){return"openid"!==e}),e=e.filter(function(e){return"profile"!==e})},e.prototype.registerCallback=function(e,t,n,r){var o=this;window.activeRenewals[t]=e,window.callBacksMappedToRenewStates[e]||(window.callBacksMappedToRenewStates[e]=[]),window.callBacksMappedToRenewStates[e].push({resolve:n,reject:r}),window.callBackMappedToRenewStates[e]||(window.callBackMappedToRenewStates[e]=function(n,r,i,s){window.activeRenewals[t]=null;for(var a=0;a<window.callBacksMappedToRenewStates[e].length;++a)try{n||i?window.callBacksMappedToRenewStates[e][a].reject(n+c.Constants.resourceDelimeter+i):r&&window.callBacksMappedToRenewStates[e][a].resolve(r)}catch(e){o._logger.warning(e)}window.callBacksMappedToRenewStates[e]=null,window.callBackMappedToRenewStates[e]=null})},e.prototype.getCachedTokenInternal=function(e,t){var n=t||this.getUser();if(n){var r,o=this.authorityInstance?this.authorityInstance:g.AuthorityFactory.CreateInstance(this.authority,this.validateAuthority);return r=f.Utils.compareObjects(n,this.getUser())?e.indexOf(this.clientId)>-1?new s.AuthenticationRequestParameters(o,this.clientId,e,m.id_token,this._redirectUri,this._state):new s.AuthenticationRequestParameters(o,this.clientId,e,m.token,this._redirectUri,this._state):new s.AuthenticationRequestParameters(o,this.clientId,e,m.id_token_token,this._redirectUri,this._state),this.getCachedToken(r,t)}},e.prototype.getCachedToken=function(e,t){var n=null,r=e.scopes,o=this._cacheStorage.getAllAccessTokens(this.clientId,t?t.userIdentifier:null);if(0===o.length)return null;var i=[];if(e.authority){for(var s=0;s<o.length;s++){var a=o[s],c=a.key.scopes.split(" ");f.Utils.containsScope(c,r)&&a.key.authority===e.authority&&i.push(a)}if(0===i.length)return null;if(1!==i.length)return{errorDesc:"The cache contains multiple tokens satisfying the requirements.Call AcquireToken again providing more requirements like authority",token:null,error:"multiple_matching_tokens_detected"};n=i[0]}else{for(var s=0;s<o.length;s++){var a=o[s],c=a.key.scopes.split(" ");f.Utils.containsScope(c,r)&&i.push(a)}if(1===i.length)n=i[0],e.authorityInstance=g.AuthorityFactory.CreateInstance(n.key.authority,this.validateAuthority);else{if(i.length>1)return{errorDesc:"The cache contains multiple tokens satisfying the requirements. Call AcquireToken again providing more requirements like authority",token:null,error:"multiple_matching_tokens_detected"};var u=this.getUniqueAuthority(o,"authority");if(u.length>1)return{errorDesc:"Multiple authorities found in the cache. Pass authority in the API overload.",token:null,error:"multiple_matching_tokens_detected"};e.authorityInstance=g.AuthorityFactory.CreateInstance(u[0],this.validateAuthority)}}if(null!=n){var l=Number(n.value.expiresIn),d=this._clockSkew||300;return l&&l>f.Utils.now()+d?{errorDesc:null,token:n.value.accessToken,error:null}:(this._cacheStorage.removeItem(JSON.stringify(i[0].key)),null)}return null},e.prototype.getAllUsers=function(){for(var e=[],t=this._cacheStorage.getAllAccessTokens(c.Constants.clientId,c.Constants.userIdentifier),n=0;n<t.length;n++){var r=new u.IdToken(t[n].value.idToken),o=new a.ClientInfo(t[n].value.clientInfo),i=p.User.createUser(r,o);e.push(i)}return this.getUniqueUsers(e)},e.prototype.getUniqueUsers=function(e){if(!e||e.length<=1)return e;for(var t=[],n=[],r=0;r<e.length;++r)e[r].userIdentifier&&-1===t.indexOf(e[r].userIdentifier)&&(t.push(e[r].userIdentifier),n.push(e[r]));return n},e.prototype.getUniqueAuthority=function(e,t){var n=[],r=[];return e.forEach(function(e){e.key.hasOwnProperty(t)&&-1===r.indexOf(e.key[t])&&(r.push(e.key[t]),n.push(e.key[t]))}),n},e.prototype.addHintParameters=function(e,t){var n=t||this.getUser();if(n){var r=n.userIdentifier.split("."),o=f.Utils.base64DecodeStringUrlSafe(r[0]),i=f.Utils.base64DecodeStringUrlSafe(r[1]);n.sid&&-1!==e.indexOf(c.Constants.prompt_none)?this.urlContainsQueryStringParameter(c.Constants.sid,e)||this.urlContainsQueryStringParameter(c.Constants.login_hint,e)||(e+="&"+c.Constants.sid+"="+encodeURIComponent(n.sid)):this.urlContainsQueryStringParameter(c.Constants.login_hint,e)||!n.displayableId||f.Utils.isEmpty(n.displayableId)||(e+="&"+c.Constants.login_hint+"="+encodeURIComponent(n.displayableId)),f.Utils.isEmpty(o)||f.Utils.isEmpty(i)||(this.urlContainsQueryStringParameter("domain_req",e)||f.Utils.isEmpty(i)||(e+="&domain_req="+encodeURIComponent(i)),this.urlContainsQueryStringParameter("login_req",e)||f.Utils.isEmpty(o)||(e+="&login_req="+encodeURIComponent(o))),this.urlContainsQueryStringParameter(c.Constants.domain_hint,e)||f.Utils.isEmpty(i)||(i===c.Constants.consumersUtid?e+="&"+c.Constants.domain_hint+"="+encodeURIComponent(c.Constants.consumers):e+="&"+c.Constants.domain_hint+"="+encodeURIComponent(c.Constants.organizations))}return e},e.prototype.urlContainsQueryStringParameter=function(e,t){return new RegExp("[\\?&]"+e+"=").test(t)},e.prototype.acquireTokenRedirect=function(e,t,n,r){var o=this,i=this.validateInputScope(e);if(i&&!f.Utils.isEmpty(i)&&this._tokenReceivedCallback)return void this._tokenReceivedCallback(c.ErrorDescription.inputScopesError,null,c.ErrorCodes.inputScopesError,c.Constants.accessToken,this.getUserState(this._cacheStorage.getItem(c.Constants.stateLogin,this.storeAuthStateInCookie)));e&&(e=this.filterScopes(e));var a=n||this.getUser();if(!this._acquireTokenInProgress){e.join(" ").toLowerCase();if(!(a||r&&-1!==r.indexOf(c.Constants.login_hint))&&this._tokenReceivedCallback)return this._logger.info("User login is required"),void this._tokenReceivedCallback(c.ErrorDescription.userLoginError,null,c.ErrorCodes.userLoginError,c.Constants.accessToken,this.getUserState(this._cacheStorage.getItem(c.Constants.stateLogin,this.storeAuthStateInCookie)));this._acquireTokenInProgress=!0;var u,l=t?g.AuthorityFactory.CreateInstance(t,this.validateAuthority):this.authorityInstance;l.ResolveEndpointsAsync().then(function(){u=f.Utils.compareObjects(a,o.getUser())?e.indexOf(o.clientId)>-1?new s.AuthenticationRequestParameters(l,o.clientId,e,m.id_token,o._redirectUri,o._state):new s.AuthenticationRequestParameters(l,o.clientId,e,m.token,o._redirectUri,o._state):new s.AuthenticationRequestParameters(l,o.clientId,e,m.id_token_token,o._redirectUri,o._state),o._cacheStorage.setItem(c.Constants.nonceIdToken,u.nonce,o.storeAuthStateInCookie);var t;t=a?c.Constants.acquireTokenUser+c.Constants.resourceDelimeter+a.userIdentifier+c.Constants.resourceDelimeter+u.state:c.Constants.acquireTokenUser+c.Constants.resourceDelimeter+c.Constants.no_user+c.Constants.resourceDelimeter+u.state,o._cacheStorage.setItem(t,JSON.stringify(a));var n=c.Constants.authority+c.Constants.resourceDelimeter+u.state;o._cacheStorage.setItem(n,l.CanonicalAuthority,o.storeAuthStateInCookie),r&&(u.extraQueryParameters=r);var i=u.createNavigateUrl(e)+c.Constants.prompt_select_account+c.Constants.response_mode_fragment;(i=o.addHintParameters(i,a))&&(o._cacheStorage.setItem(c.Constants.stateAcquireToken,u.state,o.storeAuthStateInCookie),window.location.replace(i))})}},e.prototype.acquireTokenPopup=function(e,t,n,r){var o=this;return new Promise(function(i,a){var u=o.validateInputScope(e);u&&!f.Utils.isEmpty(u)&&a(c.ErrorCodes.inputScopesError+c.Constants.resourceDelimeter+u),e&&(e=o.filterScopes(e));var l=n||o.getUser();if(o._acquireTokenInProgress)return void a(c.ErrorCodes.acquireTokenProgressError+c.Constants.resourceDelimeter+c.ErrorDescription.acquireTokenProgressError);var d=e.join(" ").toLowerCase();if(!(l||r&&-1!==r.indexOf(c.Constants.login_hint)))return o._logger.info("User login is required"),void a(c.ErrorCodes.userLoginError+c.Constants.resourceDelimeter+c.ErrorDescription.userLoginError);o._acquireTokenInProgress=!0;var h,p=t?g.AuthorityFactory.CreateInstance(t,o.validateAuthority):o.authorityInstance,y=o.openWindow("about:blank","_blank",1,o,i,a);y&&p.ResolveEndpointsAsync().then(function(){h=f.Utils.compareObjects(l,o.getUser())?e.indexOf(o.clientId)>-1?new s.AuthenticationRequestParameters(p,o.clientId,e,m.id_token,o._redirectUri,o._state):new s.AuthenticationRequestParameters(p,o.clientId,e,m.token,o._redirectUri,o._state):new s.AuthenticationRequestParameters(p,o.clientId,e,m.id_token_token,o._redirectUri,o._state),o._cacheStorage.setItem(c.Constants.nonceIdToken,h.nonce),h.state=h.state;var t;t=l?c.Constants.acquireTokenUser+c.Constants.resourceDelimeter+l.userIdentifier+c.Constants.resourceDelimeter+h.state:c.Constants.acquireTokenUser+c.Constants.resourceDelimeter+c.Constants.no_user+c.Constants.resourceDelimeter+h.state,o._cacheStorage.setItem(t,JSON.stringify(l));var n=c.Constants.authority+c.Constants.resourceDelimeter+h.state;o._cacheStorage.setItem(n,p.CanonicalAuthority,o.storeAuthStateInCookie),r&&(h.extraQueryParameters=r);var u=h.createNavigateUrl(e)+c.Constants.prompt_select_account+c.Constants.response_mode_fragment;u=o.addHintParameters(u,l),window.renewStates.push(h.state),window.requestType=c.Constants.renewToken,o.registerCallback(h.state,d,i,a),y&&(y.location.href=u)},function(){o._logger.info(c.ErrorCodes.endpointResolutionError+":"+c.ErrorDescription.endpointResolutionError),o._cacheStorage.setItem(c.Constants.msalError,c.ErrorCodes.endpointResolutionError),o._cacheStorage.setItem(c.Constants.msalErrorDescription,c.ErrorDescription.endpointResolutionError),a&&a(c.ErrorCodes.endpointResolutionError+c.Constants.resourceDelimeter+c.ErrorDescription.endpointResolutionError),y&&y.close()}).catch(function(e){o._logger.warning("could not resolve endpoints"),a(e)})})},e.prototype.acquireTokenSilent=function(e,t,n,r){var o=this;return new Promise(function(i,a){var u=o.validateInputScope(e);if(!u||f.Utils.isEmpty(u)){e&&(e=o.filterScopes(e));var l=e.join(" ").toLowerCase(),d=n||o.getUser(),h=o._cacheStorage.getItem(c.Constants.adalIdToken);if(!d&&f.Utils.checkSSO(r)&&f.Utils.isEmpty(h))return o._logger.info("User login is required"),void a(c.ErrorCodes.userLoginError+c.Constants.resourceDelimeter+c.ErrorDescription.userLoginError);if(!d&&!f.Utils.isEmpty(h)){var p=f.Utils.extractIdToken(h);console.log("ADAL's idToken exists. Extracting login information from ADAL's idToken "),r=f.Utils.constructUnifiedCacheExtraQueryParameter(p,r)}var y;y=f.Utils.compareObjects(d,o.getUser())?e.indexOf(o.clientId)>-1?new s.AuthenticationRequestParameters(g.AuthorityFactory.CreateInstance(t,o.validateAuthority),o.clientId,e,m.id_token,o._redirectUri,o._state):new s.AuthenticationRequestParameters(g.AuthorityFactory.CreateInstance(t,o.validateAuthority),o.clientId,e,m.token,o._redirectUri,o._state):e.indexOf(o.clientId)>-1?new s.AuthenticationRequestParameters(g.AuthorityFactory.CreateInstance(t,o.validateAuthority),o.clientId,e,m.id_token,o._redirectUri,o._state):new s.AuthenticationRequestParameters(g.AuthorityFactory.CreateInstance(t,o.validateAuthority),o.clientId,e,m.id_token_token,o._redirectUri,o._state);var _=o.getCachedToken(y,d);if(_){if(_.token)return o._logger.info("Token is already in cache for scope:"+l),void i(_.token);if(_.errorDesc||_.error)return o._logger.infoPii(_.errorDesc+":"+_.error),void a(_.errorDesc+c.Constants.resourceDelimeter+_.error)}else o._logger.verbose("Token is not in cache for scope:"+l);return y.authorityInstance||(y.authorityInstance=t?g.AuthorityFactory.CreateInstance(t,o.validateAuthority):o.authorityInstance),y.authorityInstance.ResolveEndpointsAsync().then(function(){window.activeRenewals[l]?(o._logger.verbose("Renew token for scope: "+l+" is in progress. Registering callback"),o.registerCallback(window.activeRenewals[l],l,i,a)):e&&e.indexOf(o.clientId)>-1&&1===e.length?(o._logger.verbose("renewing idToken"),o.renewIdToken(e,i,a,d,y,r)):(o._logger.verbose("renewing accesstoken"),o.renewToken(e,i,a,d,y,r))}).catch(function(e){o._logger.warning("could not resolve endpoints"),a(e)})}a(c.ErrorCodes.inputScopesError+"|"+u)})},e.prototype.extractADALIdToken=function(){var e=this._cacheStorage.getItem(c.Constants.adalIdToken);return f.Utils.isEmpty(e)?null:f.Utils.extractIdToken(e)},e.prototype.loadIframeTimeout=function(e,t,n){var r=this,o=window.activeRenewals[n];this._logger.verbose("Set loading state to pending for: "+n+":"+o),this._cacheStorage.setItem(c.Constants.renewStatus+o,c.Constants.tokenRenewStatusInProgress),this.loadFrame(e,t),setTimeout(function(){r._cacheStorage.getItem(c.Constants.renewStatus+o)===c.Constants.tokenRenewStatusInProgress&&(r._logger.verbose("Loading frame has timed out after: "+r.loadFrameTimeout/1e3+" seconds for scope "+n+":"+o),o&&window.callBackMappedToRenewStates[o]&&window.callBackMappedToRenewStates[o]("Token renewal operation failed due to timeout",null,"Token Renewal Failed",c.Constants.accessToken),r._cacheStorage.setItem(c.Constants.renewStatus+o,c.Constants.tokenRenewStatusCancelled))},this.loadFrameTimeout)},e.prototype.loadFrame=function(e,t){var n=this;this._logger.info("LoadFrame: "+t);var r=t;setTimeout(function(){var o=n.addAdalFrame(r);""!==o.src&&"about:blank"!==o.src||(o.src=e,n._logger.infoPii("Frame Name : "+t+" Navigated to: "+e))},500)},e.prototype.addAdalFrame=function(e){if(void 0===e)return null;this._logger.info("Add msal frame to document:"+e);var t=document.getElementById(e);if(!t){if(document.createElement&&document.documentElement&&-1===window.navigator.userAgent.indexOf("MSIE 5.0")){var n=document.createElement("iframe");n.setAttribute("id",e),n.style.visibility="hidden",n.style.position="absolute",n.style.width=n.style.height="0",n.style.border="0",t=document.getElementsByTagName("body")[0].appendChild(n)}else document.body&&document.body.insertAdjacentHTML&&document.body.insertAdjacentHTML("beforeend",'<iframe name="'+e+'" id="'+e+'" style="display:none"></iframe>');window.frames&&window.frames[e]&&(t=window.frames[e])}return t},e.prototype.renewToken=function(e,t,n,r,o,i){var s=e.join(" ").toLowerCase();this._logger.verbose("renewToken is called for scope:"+s);var a=this.addAdalFrame("msalRenewFrame"+s);i&&(o.extraQueryParameters=i);var u;u=r?c.Constants.acquireTokenUser+c.Constants.resourceDelimeter+r.userIdentifier+c.Constants.resourceDelimeter+o.state:c.Constants.acquireTokenUser+c.Constants.resourceDelimeter+c.Constants.no_user+c.Constants.resourceDelimeter+o.state,this._cacheStorage.setItem(u,JSON.stringify(r));var l=c.Constants.authority+c.Constants.resourceDelimeter+o.state;this._cacheStorage.setItem(l,o.authority),this._cacheStorage.setItem(c.Constants.nonceIdToken,o.nonce),this._logger.verbose("Renew token Expected state: "+o.state);var d=f.Utils.urlRemoveQueryStringParameter(o.createNavigateUrl(e),c.Constants.prompt)+c.Constants.prompt_none;d=this.addHintParameters(d,r),window.renewStates.push(o.state),window.requestType=c.Constants.renewToken,this.registerCallback(o.state,s,t,n),this._logger.infoPii("Navigate to:"+d),a.src="about:blank",this.loadIframeTimeout(d,"msalRenewFrame"+s,s)},e.prototype.renewIdToken=function(e,t,n,r,o,i){e.join(" ").toLowerCase();this._logger.info("renewidToken is called");var s=this.addAdalFrame("msalIdTokenFrame");i&&(o.extraQueryParameters=i);var a;a=r?c.Constants.acquireTokenUser+c.Constants.resourceDelimeter+r.userIdentifier+c.Constants.resourceDelimeter+o.state:c.Constants.acquireTokenUser+c.Constants.resourceDelimeter+c.Constants.no_user+c.Constants.resourceDelimeter+o.state,this._cacheStorage.setItem(a,JSON.stringify(r));var u=c.Constants.authority+c.Constants.resourceDelimeter+o.state;this._cacheStorage.setItem(u,o.authority),this._cacheStorage.setItem(c.Constants.nonceIdToken,o.nonce),this._logger.verbose("Renew Idtoken Expected state: "+o.state);var l=f.Utils.urlRemoveQueryStringParameter(o.createNavigateUrl(e),c.Constants.prompt)+c.Constants.prompt_none;l=this.addHintParameters(l,r),this._silentLogin?(window.requestType=c.Constants.login,this._silentAuthenticationState=o.state):(window.requestType=c.Constants.renewToken,window.renewStates.push(o.state)),this.registerCallback(o.state,this.clientId,t,n),this._logger.infoPii("Navigate to:"+l),s.src="about:blank",this.loadIframeTimeout(l,"msalIdTokenFrame",this.clientId)},e.prototype.getUser=function(){if(this._user)return this._user;var e=this._cacheStorage.getItem(c.Constants.idTokenKey),t=this._cacheStorage.getItem(c.Constants.msalClientInfo);if(!f.Utils.isEmpty(e)&&!f.Utils.isEmpty(t)){var n=new u.IdToken(e),r=new a.ClientInfo(t);return this._user=p.User.createUser(n,r),this._user}return null},e.prototype.handleAuthenticationResponse=function(e){null==e&&(e=window.location.hash);var t=null,n=!1,r=!1;try{r=window.opener&&window.opener.msal&&window.opener.msal!==window.msal}catch(e){r=!1}r?(t=window.opener.msal,n=!0):window.parent&&window.parent.msal&&(t=window.parent.msal);var o,i=t.getRequestInfo(e),s=null,a=null;if(t._logger.info("Returned from redirect url"),window.parent!==window&&window.parent.msal)a=window.parent.callBackMappedToRenewStates[i.stateResponse];else if(r)a=window.opener.callBackMappedToRenewStates[i.stateResponse];else{if(t._navigateToLoginRequestUrl)return a=null,t._cacheStorage.setItem(c.Constants.urlHash,e),!1,void(window.parent!==window||n||(window.location.href=t._cacheStorage.getItem(c.Constants.loginRequest,this.storeAuthStateInCookie)));a=t._tokenReceivedCallback,window.location.hash=""}t.saveTokenFromHash(i),i.requestType===c.Constants.renewToken&&window.parent?(window.parent!==window?t._logger.verbose("Window is in iframe, acquiring token silently"):t._logger.verbose("acquiring token interactive in progress"),s=i.parameters[c.Constants.accessToken]||i.parameters[c.Constants.idToken],o=c.Constants.accessToken):i.requestType===c.Constants.login&&(s=i.parameters[c.Constants.idToken],o=c.Constants.idToken);var u=i.parameters[c.Constants.errorDescription],l=i.parameters[c.Constants.error];try{a&&(i.stateMatch?a.call(t,u,s,l,o,this.getUserState(i.stateResponse)):a.call(t,u,s,l,o,null))}catch(e){t._logger.error("Error occurred in token received callback function: "+e)}if(r)for(var d=0;d<window.opener.openedWindows.length;d++)window.opener.openedWindows[d].close()},e.prototype.saveAccessToken=function(e,t,n,r,s){var u,l=new a.ClientInfo(r);if(t.parameters.hasOwnProperty("scope")){u=t.parameters.scope;for(var d=u.split(" "),h=this._cacheStorage.getAllAccessTokens(this.clientId,e),p=0;p<h.length;p++){var g=h[p];if(g.key.userIdentifier===n.userIdentifier){var m=g.key.scopes.split(" ");f.Utils.isIntersectingScopes(m,d)&&this._cacheStorage.removeItem(JSON.stringify(g.key))}}var y=new o.AccessTokenKey(e,this.clientId,u,l.uid,l.utid),_=new i.AccessTokenValue(t.parameters[c.Constants.accessToken],s.rawIdToken,f.Utils.expiresIn(t.parameters[c.Constants.expiresIn]).toString(),r);this._cacheStorage.setItem(JSON.stringify(y),JSON.stringify(_))}else{u=this.clientId;var y=new o.AccessTokenKey(e,this.clientId,u,l.uid,l.utid),_=new i.AccessTokenValue(t.parameters[c.Constants.idToken],t.parameters[c.Constants.idToken],s.expiration,r);this._cacheStorage.setItem(JSON.stringify(y),JSON.stringify(_))}},e.prototype.saveTokenFromHash=function(e){this._logger.info("State status:"+e.stateMatch+"; Request type:"+e.requestType),this._cacheStorage.setItem(c.Constants.msalError,""),this._cacheStorage.setItem(c.Constants.msalErrorDescription,"");var t="",n="";if(e.parameters.hasOwnProperty("scope")?e.parameters.scope.toLowerCase():this.clientId,e.parameters.hasOwnProperty(c.Constants.errorDescription)||e.parameters.hasOwnProperty(c.Constants.error)){if(this._logger.infoPii("Error :"+e.parameters[c.Constants.error]+"; Error description:"+e.parameters[c.Constants.errorDescription]),this._cacheStorage.setItem(c.Constants.msalError,e.parameters.error),this._cacheStorage.setItem(c.Constants.msalErrorDescription,e.parameters[c.Constants.errorDescription]),e.requestType===c.Constants.login&&(this._loginInProgress=!1,this._cacheStorage.setItem(c.Constants.loginError,e.parameters[c.Constants.errorDescription]+":"+e.parameters[c.Constants.error]),t=c.Constants.authority+c.Constants.resourceDelimeter+e.stateResponse),e.requestType===c.Constants.renewToken){this._acquireTokenInProgress=!1,t=c.Constants.authority+c.Constants.resourceDelimeter+e.stateResponse;var r=null!==this.getUser()?this.getUser().userIdentifier:"";n=c.Constants.acquireTokenUser+c.Constants.resourceDelimeter+r+c.Constants.resourceDelimeter+e.stateResponse}}else if(e.stateMatch){this._logger.info("State is right"),e.parameters.hasOwnProperty(c.Constants.sessionState)&&this._cacheStorage.setItem(c.Constants.msalSessionState,e.parameters[c.Constants.sessionState]);var o,i="";if(e.parameters.hasOwnProperty(c.Constants.accessToken)){this._logger.info("Fragment has access token"),this._acquireTokenInProgress=!1;var s=void 0;o=e.parameters.hasOwnProperty(c.Constants.idToken)?new u.IdToken(e.parameters[c.Constants.idToken]):new u.IdToken(this._cacheStorage.getItem(c.Constants.idTokenKey)),t=c.Constants.authority+c.Constants.resourceDelimeter+e.stateResponse;var l=this._cacheStorage.getItem(t,this.storeAuthStateInCookie);f.Utils.isEmpty(l)||(l=f.Utils.replaceFirstPath(l,o.tenantId)),e.parameters.hasOwnProperty(c.Constants.clientInfo)?(i=e.parameters[c.Constants.clientInfo],s=p.User.createUser(o,new a.ClientInfo(i))):(this._logger.warning("ClientInfo not received in the response from AAD"),s=p.User.createUser(o,new a.ClientInfo(i))),n=c.Constants.acquireTokenUser+c.Constants.resourceDelimeter+s.userIdentifier+c.Constants.resourceDelimeter+e.stateResponse;var d=c.Constants.acquireTokenUser+c.Constants.resourceDelimeter+c.Constants.no_user+c.Constants.resourceDelimeter+e.stateResponse,h=this._cacheStorage.getItem(n),g=void 0;f.Utils.isEmpty(h)?f.Utils.isEmpty(this._cacheStorage.getItem(d))||this.saveAccessToken(l,e,s,i,o):(g=JSON.parse(h),s&&g&&f.Utils.compareObjects(s,g)?(this.saveAccessToken(l,e,s,i,o),this._logger.info("The user object received in the response is the same as the one passed in the acquireToken request")):this._logger.warning("The user object created from the response is not the same as the one passed in the acquireToken request"))}if(e.parameters.hasOwnProperty(c.Constants.idToken)){this._logger.info("Fragment has id token"),this._loginInProgress=!1,o=new u.IdToken(e.parameters[c.Constants.idToken]),e.parameters.hasOwnProperty(c.Constants.clientInfo)?i=e.parameters[c.Constants.clientInfo]:this._logger.warning("ClientInfo not received in the response from AAD"),t=c.Constants.authority+c.Constants.resourceDelimeter+e.stateResponse;var l=this._cacheStorage.getItem(t,this.storeAuthStateInCookie);f.Utils.isEmpty(l)||(l=f.Utils.replaceFirstPath(l,o.tenantId)),this._user=p.User.createUser(o,new a.ClientInfo(i)),o&&o.nonce?o.nonce!==this._cacheStorage.getItem(c.Constants.nonceIdToken,this.storeAuthStateInCookie)?(this._user=null,this._cacheStorage.setItem(c.Constants.loginError,"Nonce Mismatch. Expected Nonce: "+this._cacheStorage.getItem(c.Constants.nonceIdToken,this.storeAuthStateInCookie)+",Actual Nonce: "+o.nonce),this._logger.error("Nonce Mismatch.Expected Nonce: "+this._cacheStorage.getItem(c.Constants.nonceIdToken,this.storeAuthStateInCookie)+",Actual Nonce: "+o.nonce)):(this._cacheStorage.setItem(c.Constants.idTokenKey,e.parameters[c.Constants.idToken]),this._cacheStorage.setItem(c.Constants.msalClientInfo,i),this.saveAccessToken(l,e,this._user,i,o)):(t=e.stateResponse,n=e.stateResponse,this._logger.error("Invalid id_token received in the response"),e.parameters.error="invalid idToken",e.parameters.error_description="Invalid idToken. idToken: "+e.parameters[c.Constants.idToken],this._cacheStorage.setItem(c.Constants.msalError,"invalid idToken"),this._cacheStorage.setItem(c.Constants.msalErrorDescription,"Invalid idToken. idToken: "+e.parameters[c.Constants.idToken]))}}else t=e.stateResponse,n=e.stateResponse,this._logger.error("State Mismatch.Expected State: "+this._cacheStorage.getItem(c.Constants.stateLogin,this.storeAuthStateInCookie)+",Actual State: "+e.stateResponse),e.parameters.error="Invalid_state",e.parameters.error_description="Invalid_state. state: "+e.stateResponse,this._cacheStorage.setItem(c.Constants.msalError,"Invalid_state"),this._cacheStorage.setItem(c.Constants.msalErrorDescription,"Invalid_state. state: "+e.stateResponse);this._cacheStorage.setItem(c.Constants.renewStatus+e.stateResponse,c.Constants.tokenRenewStatusCompleted),this._cacheStorage.removeAcquireTokenEntries(t,n),this.storeAuthStateInCookie&&(this._cacheStorage.setItemCookie(t,"",-1),this._cacheStorage.clearCookie())},e.prototype.isCallback=function(e){e=this.getHash(e);var t=f.Utils.deserialize(e);return t.hasOwnProperty(c.Constants.errorDescription)||t.hasOwnProperty(c.Constants.error)||t.hasOwnProperty(c.Constants.accessToken)||t.hasOwnProperty(c.Constants.idToken)},e.prototype.getHash=function(e){return e.indexOf("#/")>-1?e=e.substring(e.indexOf("#/")+2):e.indexOf("#")>-1&&(e=e.substring(1)),e},e.prototype.getRequestInfo=function(e){e=this.getHash(e);var t=f.Utils.deserialize(e),n=new h.TokenResponse;if(t&&(n.parameters=t,t.hasOwnProperty(c.Constants.errorDescription)||t.hasOwnProperty(c.Constants.error)||t.hasOwnProperty(c.Constants.accessToken)||t.hasOwnProperty(c.Constants.idToken))){n.valid=!0;var r=void 0;if(!t.hasOwnProperty("state"))return n;if(r=t.state,n.stateResponse=r,r===this._cacheStorage.getItem(c.Constants.stateLogin,this.storeAuthStateInCookie)||r===this._silentAuthenticationState)return n.requestType=c.Constants.login,n.stateMatch=!0,n;if(r===this._cacheStorage.getItem(c.Constants.stateAcquireToken,this.storeAuthStateInCookie))return n.requestType=c.Constants.renewToken,n.stateMatch=!0,n;if(!n.stateMatch){n.requestType=window.requestType;for(var o=window.renewStates,i=0;i<o.length;i++)if(o[i]===n.stateResponse){n.stateMatch=!0;break}}}return n},e.prototype.getScopeFromState=function(e){if(e){var t=e.indexOf("|");if(t>-1&&t+1<e.length)return e.substring(t+1)}return""},e.prototype.getUserState=function(e){if(e){var t=e.indexOf("|");if(t>-1&&t+1<e.length)return e.substring(t+1)}return""},e.prototype.isInIframe=function(){return window.parent!==window},e.prototype.loginInProgress=function(){return!!this._cacheStorage.getItem(c.Constants.urlHash)||this._loginInProgress},e.prototype.getHostFromUri=function(e){var t=String(e).replace(/^(https?:)\/\//,"");return t=t.split("/")[0]},e.prototype.getScopesForEndpoint=function(e){if(this._unprotectedResources.length>0)for(var t=0;t<this._unprotectedResources.length;t++)if(e.indexOf(this._unprotectedResources[t])>-1)return null;if(this._protectedResourceMap.size>0)for(var n=0,r=Array.from(this._protectedResourceMap.keys());n<r.length;n++){var o=r[n];if(e.indexOf(o)>-1)return this._protectedResourceMap.get(o)}return e.indexOf("http://")>-1||e.indexOf("https://")>-1?this.getHostFromUri(e)===this.getHostFromUri(this._redirectUri)?new Array(this.clientId):null:new Array(this.clientId)},e.prototype.setloginInProgress=function(e){this._loginInProgress=e},e.prototype.getAcquireTokenInProgress=function(){return this._acquireTokenInProgress},e.prototype.setAcquireTokenInProgress=function(e){this._acquireTokenInProgress=e},e.prototype.getLogger=function(){return this._logger},r.__decorate([y],e.prototype,"acquireTokenSilent",null),e}();t.UserAgentApplication=_},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=function(){function e(e,t,n,o,i){this.authority=e,this.clientId=t,this.scopes=n,this.userIdentifier=r.Utils.base64EncodeStringUrlSafe(o)+"."+r.Utils.base64EncodeStringUrlSafe(i)}return e}();t.AccessTokenKey=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t,n,r){this.accessToken=e,this.idToken=t,this.expiresIn=n,this.clientInfo=r}return e}();t.AccessTokenValue=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=function(){function e(e,t,n,o,i,s){this.authorityInstance=e,this.clientId=t,this.scopes=n,this.responseType=o,this.redirectUri=i,this.correlationId=r.Utils.createNewGuid(),this.state=s&&!r.Utils.isEmpty(s)?r.Utils.createNewGuid()+"|"+s:r.Utils.createNewGuid(),this.nonce=r.Utils.createNewGuid(),this.xClientSku="MSAL.JS",this.xClientVer=r.Utils.getLibraryVersion()}return Object.defineProperty(e.prototype,"authority",{get:function(){return this.authorityInstance?this.authorityInstance.CanonicalAuthority:null},enumerable:!0,configurable:!0}),e.prototype.createNavigateUrl=function(e){var t=this.createNavigationUrlString(e),n=this.authorityInstance.AuthorizationEndpoint;return n.indexOf("?")<0?n+="?":n+="&",""+n+t.join("&")},e.prototype.createNavigationUrlString=function(e){e||(e=[this.clientId]),-1===e.indexOf(this.clientId)&&e.push(this.clientId);var t=[];return t.push("response_type="+this.responseType),this.translateclientIdUsedInScope(e),t.push("scope="+encodeURIComponent(this.parseScope(e))),t.push("client_id="+encodeURIComponent(this.clientId)),t.push("redirect_uri="+encodeURIComponent(this.redirectUri)),t.push("state="+encodeURIComponent(this.state)),t.push("nonce="+encodeURIComponent(this.nonce)),t.push("client_info=1"),t.push("x-client-SKU="+this.xClientSku),t.push("x-client-Ver="+this.xClientVer),this.extraQueryParameters&&t.push(this.extraQueryParameters),t.push("client-request-id="+encodeURIComponent(this.correlationId)),t},e.prototype.translateclientIdUsedInScope=function(e){var t=e.indexOf(this.clientId);t>=0&&(e.splice(t,1),-1===e.indexOf("openid")&&e.push("openid"),-1===e.indexOf("profile")&&e.push("profile"))},e.prototype.parseScope=function(e){var t="";if(e)for(var n=0;n<e.length;++n)t+=n!==e.length-1?e[n]+" ":e[n];return t},e}();t.AuthenticationRequestParameters=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=function(){function e(e){if(!e||r.Utils.isEmpty(e))return this.uid="",void(this.utid="");try{var t=r.Utils.base64DecodeStringUrlSafe(e),n=JSON.parse(t);n&&(n.hasOwnProperty("uid")&&(this.uid=n.uid),n.hasOwnProperty("utid")&&(this.utid=n.utid))}catch(e){throw new Error(e)}}return Object.defineProperty(e.prototype,"uid",{get:function(){return this._uid?this._uid:""},set:function(e){this._uid=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"utid",{get:function(){return this._utid?this._utid:""},set:function(e){this._utid=e},enumerable:!0,configurable:!0}),e}();t.ClientInfo=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=function(){function e(e){if(r.Utils.isEmpty(e))throw new Error("null or empty raw idtoken");try{this.rawIdToken=e,this.decodedIdToken=r.Utils.extractIdToken(e),this.decodedIdToken&&(this.decodedIdToken.hasOwnProperty("iss")&&(this.issuer=this.decodedIdToken.iss),this.decodedIdToken.hasOwnProperty("oid")&&(this.objectId=this.decodedIdToken.oid),this.decodedIdToken.hasOwnProperty("sub")&&(this.subject=this.decodedIdToken.sub),this.decodedIdToken.hasOwnProperty("tid")&&(this.tenantId=this.decodedIdToken.tid),this.decodedIdToken.hasOwnProperty("ver")&&(this.version=this.decodedIdToken.ver),this.decodedIdToken.hasOwnProperty("preferred_username")&&(this.preferredName=this.decodedIdToken.preferred_username),this.decodedIdToken.hasOwnProperty("name")&&(this.name=this.decodedIdToken.name),this.decodedIdToken.hasOwnProperty("nonce")&&(this.nonce=this.decodedIdToken.nonce),this.decodedIdToken.hasOwnProperty("exp")&&(this.expiration=this.decodedIdToken.exp),this.decodedIdToken.hasOwnProperty("home_oid")&&(this.homeObjectId=this.decodedIdToken.home_oid),this.decodedIdToken.hasOwnProperty("sid")&&(this.sid=this.decodedIdToken.sid))}catch(e){throw new Error("Failed to parse the returned id token")}}return e}();t.IdToken=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),o=n(19),i=function(){function e(t){if(e._instance)return e._instance;if(this._cacheLocation=t,this._localStorageSupported=void 0!==window[this._cacheLocation]&&null!=window[this._cacheLocation],this._sessionStorageSupported=void 0!==window[t]&&null!=window[t],e._instance=this,!this._localStorageSupported&&!this._sessionStorageSupported)throw new Error("localStorage and sessionStorage not supported");return e._instance}return e.prototype.setItem=function(e,t,n){window[this._cacheLocation]&&window[this._cacheLocation].setItem(e,t),n&&this.setItemCookie(e,t)},e.prototype.getItem=function(e,t){return t&&this.getItemCookie(e)?this.getItemCookie(e):window[this._cacheLocation]?window[this._cacheLocation].getItem(e):void 0},e.prototype.removeItem=function(e){if(window[this._cacheLocation])return window[this._cacheLocation].removeItem(e)},e.prototype.clear=function(){if(window[this._cacheLocation])return window[this._cacheLocation].clear()},e.prototype.getAllAccessTokens=function(e,t){var n,r=[],i=window[this._cacheLocation];if(i){var s=void 0;for(s in i)if(i.hasOwnProperty(s)&&s.match(e)&&s.match(t)){var a=this.getItem(s);a&&(n=new o.AccessTokenCacheItem(JSON.parse(s),JSON.parse(a)),r.push(n))}}return r},e.prototype.removeAcquireTokenEntries=function(e,t){var n=window[this._cacheLocation];if(n){var r=void 0;for(r in n)n.hasOwnProperty(r)&&(""!=e&&r.indexOf(e)>-1||""!=t&&r.indexOf(t)>-1)&&this.removeItem(r)}},e.prototype.resetCacheItems=function(){var e=window[this._cacheLocation];if(e){var t=void 0;for(t in e)e.hasOwnProperty(t)&&-1!==t.indexOf(r.Constants.msal)&&this.setItem(t,""),e.hasOwnProperty(t)&&-1!==t.indexOf(r.Constants.renewStatus)&&this.removeItem(t)}},e.prototype.setItemCookie=function(e,t,n){var r=e+"="+t+";";if(n){r+="expires="+this.setExpirationCookie(n)+";"}document.cookie=r},e.prototype.getItemCookie=function(e){for(var t=e+"=",n=document.cookie.split(";"),r=0;r<n.length;r++){for(var o=n[r];" "==o.charAt(0);)o=o.substring(1);if(0==o.indexOf(t))return o.substring(t.length,o.length)}return""},e.prototype.setExpirationCookie=function(e){var t=new Date;return new Date(t.getTime()+24*e*60*60*1e3).toUTCString()},e.prototype.clearCookie=function(){this.setItemCookie(r.Constants.nonceIdToken,"",-1),this.setItemCookie(r.Constants.stateLogin,"",-1),this.setItemCookie(r.Constants.loginRequest,"",-1),this.setItemCookie(r.Constants.stateAcquireToken,"",-1)},e}();t.Storage=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){this.key=e,this.value=t}return e}();t.AccessTokenCacheItem=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=n(8),i=n(21),s=n(2),a=n(5),c=function(){function e(){}return e.DetectAuthorityFromUrl=function(e){switch(e=r.Utils.CanonicalizeUri(e),r.Utils.GetUrlComponents(e).PathSegments[0]){case"tfp":return s.AuthorityType.B2C;case"adfs":return s.AuthorityType.Adfs;default:return s.AuthorityType.Aad}},e.CreateInstance=function(t,n){if(r.Utils.isEmpty(t))return null;switch(e.DetectAuthorityFromUrl(t)){case s.AuthorityType.B2C:return new i.B2cAuthority(t,n);case s.AuthorityType.Aad:return new o.AadAuthority(t,n);default:throw a.ErrorMessage.invalidAuthorityType}},e}();t.AuthorityFactory=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),o=n(8),i=n(2),s=n(5),a=n(0),c=function(e){function t(t,n){var r=e.call(this,t,n)||this,o=a.Utils.GetUrlComponents(t),i=o.PathSegments;if(i.length<3)throw s.ErrorMessage.b2cAuthorityUriInvalidPath;return r.CanonicalAuthority="https://"+o.HostNameAndPort+"/"+i[0]+"/"+i[1]+"/"+i[2]+"/",r}return r.__extends(t,e),Object.defineProperty(t.prototype,"AuthorityType",{get:function(){return i.AuthorityType.B2C},enumerable:!0,configurable:!0}),t.prototype.GetOpenIdConfigurationEndpointAsync=function(){var e=this,t=new Promise(function(t,n){return t(e.DefaultOpenIdConfigurationEndpoint)});return this.IsValidationEnabled?this.IsInTrustedHostList(this.CanonicalAuthorityUrlComponents.HostNameAndPort)?t:new Promise(function(e,t){return t(s.ErrorMessage.unsupportedAuthorityValidation)}):t},t}(o.AadAuthority);t.B2cAuthority=c}])});
//# sourceMappingURL=msal.min.js.map