@useparagon/connect 2.3.2-experimental.1 → 2.3.2-experimental.20500.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/ConnectSDK.d.ts +1 -1
- package/dist/src/ConnectSDK.js +1 -1
- package/dist/src/bundledMode.d.ts +1 -0
- package/dist/src/file-picker/helpers/microsoftPicker.d.ts +2 -0
- package/dist/src/file-picker/vendor/box/runtime.stub.d.ts +1 -0
- package/dist/src/file-picker/vendor/google/runtime.stub.d.ts +1 -0
- package/dist/src/index.bundled.d.ts +5 -0
- package/dist/src/index.js +1 -1
- package/dist/src/report.bundled.html +39 -0
- package/dist/src/types/action.d.ts +1 -1
- package/dist/src/types/sdk.d.ts +4 -4
- package/dist/src/utils/connect.d.ts +0 -11
- package/dist/src/utils/generic.d.ts +6 -0
- package/dist/src/with-third-party-scripts.js +2 -0
- package/dist/src/with-third-party-scripts.js.LICENSE.txt +63 -0
- package/package.json +6 -10
- package/src/types/assets.d.ts +4 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see with-third-party-scripts.js.LICENSE.txt */
|
|
2
|
+
(()=>{var e={773:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InstallFlow=t.ExternalFilePicker=t.PARAGON_OVERFLOW_EMPTY_VALUE=void 0;const n=r(655),o=n.__importDefault(r(6245)),i=r(3931),a=r(4059),s=r(745),c=r(7343),u=r(7050);Object.defineProperty(t,"ExternalFilePicker",{enumerable:!0,get:function(){return u.ExternalFilePicker}});const l=r(2643),d=r(4429),h=r(9636),p=n.__importDefault(r(9892)),f=r(3821),g=r(2460),y=r(3158),v=r(4846),E=r(5349),m=r(572),C=r(8321),S=r(3035),I="paragon-connect-frame",w=`${I}-container`,T="paragon-connect-user-state";t.PARAGON_OVERFLOW_EMPTY_VALUE="PARAGON_OVERFLOW_EMPTY_VALUE";class A extends p.default{constructor(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(super(),this.sdkVersion="2.3.2-experimental.20500.1",this.rootLoaded=!1,this.isHeadless=!1,this.rootElementCreated=!1,this.modalState={integration:null,onClose:this.onClose.bind(this),overlayStyle:{overflow:"auto"},onOpen:this.onOpen.bind(this),apiInstallationOptions:{isApiInstallation:!1,showPortalAfterInstall:!1}},this.userState={authenticated:!1},this.loadedConfigs={},this.loadedIntegrations={},this.endUserIntegrationConfig={},this.metadata={},this.cachedApiResponse=new S.CacheThrottle({ttl:5e3}),this.keyToRequestPromiseMap={},this.originalBodyOverflow=t.PARAGON_OVERFLOW_EMPTY_VALUE,this.dynamicFieldMappingLoaders={},this.globalDropdownOptions={},this.globalMapObjectFields={},this.integrationSpecificDropdownOptions={},this.integrationSpecificMapObjectFields={},this.customDropdownOptionsLoaders={},"undefined"==typeof window)return void console.warn("connect sdk can only be used on browser");const n=(0,y.getAssetUrl)({CDN_PUBLIC_URL:"https://cdn.useparagon.com",DASHBOARD_PUBLIC_URL:"https://dashboard.useparagon.com",NODE_ENV:"production",PLATFORM_ENV:"production",VERSION:"latest"});if(this.environments={CDN_PUBLIC_URL:n,CONNECT_PUBLIC_URL:"https://connect.useparagon.com",DASHBOARD_PUBLIC_URL:"https://dashboard.useparagon.com",HERMES_PUBLIC_URL:"https://hermes.useparagon.com",NODE_ENV:"production",PASSPORT_PRODUCTION_URL:"https://passport.useparagon.com",PASSPORT_PUBLIC_URL:"https://passport.useparagon.com",PLATFORM_ENV:"production",VERSION:"latest",WORKER_PROXY_PUBLIC_URL:"https://proxy.useparagon.com",ZEUS_PUBLIC_URL:"https://zeus.useparagon.com"},this.userState={authenticated:!1},"string"==typeof e?this.configureGlobal({host:e}):this.environments={...this.environments,...e},!this.environments.CONNECT_PUBLIC_URL)throw new Error("Paragon SDK error! No `CONNECT_PUBLIC_URL` configured.");if(!this.environments.DASHBOARD_PUBLIC_URL)throw new Error("Paragon SDK error! No `DASHBOARD_PUBLIC_URL` configured.");if(!this.environments.PASSPORT_PUBLIC_URL)throw new Error("Paragon SDK error! No `PASSPORT_PUBLIC_URL` configured.");if(!this.environments.WORKER_PROXY_PUBLIC_URL)throw new Error("Paragon SDK error! No `WORKER_PROXY_PUBLIC_URL` configured.");if(!this.environments.ZEUS_PUBLIC_URL)throw new Error("Paragon SDK error! No `ZEUS_PUBLIC_URL` configured.");r.skipBootstrapWithLastKnownState||this.loadState(),window.addEventListener("message",this.eventMessageHandler.bind(this)),window.document.readyState===f.DocumentLoadingState.LOADING?window.document.addEventListener("DOMContentLoaded",(()=>{this.createReactRoot()})):this.createReactRoot(),this.installFlow=new _(this)}setHeadless(e){this.isHeadless=e}getAssetUrl(e){return`${this.environments.DASHBOARD_PUBLIC_URL}/images/${e}.png`}getVersion(){return this.sdkVersion}async eventMessageHandler(e){switch(e.data.type){case"oauth_success_callback":await this._oauthCallback(e.data.credential);break;case"oauth_error_callback":await this._oauthErrorCallback(e.data.error,e);break;default:await this.functionInvocationHandler(e)}}async functionInvocationHandler(e){if("SDK_FUNCTION_INVOCATION"!==e.data.messageType)return;const{type:t,id:r,parameters:n}=e.data;let o;try{o={messageType:"SDK_FUNCTION_RESPONSE",id:r,type:t,result:await this[t](...n)}}catch(e){o={messageType:"SDK_FUNCTION_ERROR",error:!0,message:e.message,id:r}}e.source.postMessage(o,this.environments.CONNECT_PUBLIC_URL)}createReactRoot(){var e;if(this.rootElementCreated)return;this.rootElementCreated=!0,this.root=document.createElement("iframe"),this.root.onload=()=>{this.rootLoaded=!0,this.render()};const t=!!document.querySelector(`#${w}`);this.root.id=I,this.root.src=`${this.environments.CONNECT_PUBLIC_URL}/ui${this.projectId?`?projectId=${this.projectId}`:""}`,this.root.style.position=t?"absolute":"fixed",this.root.style.top="0",this.root.style.left="0",this.root.style.width=t?"100%":"100vw",this.root.style.height=t?"100%":"100vh",this.root.style.zIndex="2147483647",this.root.style.display="none",null===(e=document.querySelector(`#${w}`)||document.body)||void 0===e||e.appendChild(this.root)}validateAction(e){var t;if(!this.loadedIntegrations[e]&&!(0,c.isCustomIntegrationTypeName)(e))throw new Error(`"${e}" is not a valid integration type. The integrations you have configured for this Paragon project are:\n\n${Object.keys(this.loadedConfigs).map((e=>`- "${e}"`)).join("\n")}\n`);if(!this.loadedConfigs[e]||!this.userState.integrations[e])throw new Error(`integration "${e}" has not been set up in your Paragon project yet.\n\n${Object.keys(this.loadedConfigs).map((e=>`- "${e}"`)).join("\n")}`);if(!(null===(t=this.loadedIntegrations[e])||void 0===t?void 0:t.isActive))throw new Error(`integration "${e}" is not active in your Paragon project yet.`)}validateExternalIdOptions(e,t){let{externalId:r,selectedCredentialId:n}=t;var o,i;if(void 0===r)return;const a=(0,y.sanitizeExternalConfigId)(r);if(""===a)throw new Error("`externalId` must not be an empty or whitespace-only string.");if(n)throw new Error("`externalId` cannot be used together with `selectedCredentialId`. `externalId` labels a new credential at install time; `selectedCredentialId` (UUID, externalId, or `ext:<value>`) targets an existing credential for re-authentication.");if(null===(i=null===(o=this.userState.integrations[e])||void 0===o?void 0:o.allCredentials)||void 0===i?void 0:i.find((e=>e.externalId===a)))throw new Error(`A credential with externalId "${a}" already exists for integration "${e}". Use \`selectedCredentialId: "ext:${a}"\` to re-authenticate it.`)}isAlreadyInstalled(e,t,r){var n,o;if(r){const e=this.getCredentialAndConfig({selectedCredentialId:r});return(null===(n=null==e?void 0:e.selectedCredential)||void 0===n?void 0:n.status)===a.CredentialStatus.VALID}return Boolean(null===(o=t.integrations[e])||void 0===o?void 0:o.enabled)}hasCredential(e,t,r){var n,o;if(!r)return Boolean(null===(n=t.integrations[e])||void 0===n?void 0:n.credentialId);try{const e=this.getCredentialAndConfig({selectedCredentialId:r});return Boolean(null===(o=null==e?void 0:e.selectedCredential)||void 0===o?void 0:o.id)}catch(e){return console.error(e),!1}}async bootstrapSDKState(e){this.projectId&&this.userState.authenticated&&await this.updateLocalState(e)}setModalState(e){this.modalState={config:void 0,...this.modalState,...e},this.render()}loadState(){if("undefined"!=typeof window)try{const e=window.localStorage.getItem(T)?JSON.parse(window.localStorage.getItem(T)):{};if(e.projectId&&(this.projectId=e.projectId),e.userState){const{userState:t}=e;if(!("authenticated"in t&&t.authenticated&&"token"in t))throw new Error("Malformatted or unauthenticated user was persisted into localStorage. Refusing to load.");e.environments&&Object.keys(e.environments).length>0&&(this.environments={...this.environments,...e.environments}),this.updateAuthenticatedUser(t),this.bootstrapSDKState().catch((()=>{this.clearState()}))}}catch{this.clearState()}}getIntegrationId(e){const t=this.loadedIntegrations[e];if(!t)throw new Error(`Integration "${e}" not found`);return t.id}saveState(){"undefined"!=typeof window&&this.userState.authenticated&&window.localStorage.setItem(T,JSON.stringify({projectId:this.projectId,userState:this.userState,environments:this.environments}))}clearState(){"undefined"!=typeof window&&window.localStorage.removeItem(T)}render(){if(!this.isHeadless&&this.root&&this.rootLoaded){const{onClose:e,onOpen:t,...r}=this.modalState,n={messageType:"UI_UPDATE",nextContext:{user:this.userState,projectId:this.projectId,environments:this.environments,project:this.project,endUserIntegrationConfig:this.modalState.integration?this.endUserIntegrationConfig[(0,c.getIntegrationTypeName)(this.modalState.integration)||""]:void 0},nextModalState:r};if(!this.root.contentWindow)throw new Error("Browser not supported");this.root.contentWindow.postMessage(n,this.environments.CONNECT_PUBLIC_URL)}}updateContainerStyle(e){let{isModalShown:t}=e;this.root&&(this.root.style.display=t?"block":"none")}async authenticate(e,t,r){var n;if(!e||!t)throw new Error("projectId or token not specified to paragon.authenticate()");let i={};try{i=(0,o.default)(t)}catch(e){throw new Error("A well-formed JWT was not provided to paragon.authenticate()")}this.projectId=e,this.userState={authenticated:!0,token:t,userId:i.sub||i.id,integrations:{},meta:null!==(n=null==r?void 0:r.metadata)&&void 0!==n?n:{},resources:[]};try{if(Date.now()>=1e3*(i.exp||0))throw new Error("JWT token provided has expired.");await this.bootstrapSDKState(null==r?void 0:r.metadata)}catch(e){throw console.warn("paragon.authenticate() could not login user",e),this.logout(),new Error(`Failed to authenticate user with Paragon: ${e.message}`)}this.render()}getUser(){return(0,h.cloneDeep)(Object.fromEntries(Object.entries(this.userState).filter((e=>{let[t]=e;return"token"!==t}))))}updateAuthenticatedUser(e){this.userState.authenticated?this.userState={...this.userState,...e}:e.authenticated&&(this.userState=e),this.render()}logout(){this.userState={authenticated:!1},this.clearState(),this.render()}removeOptionDuplicates(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!e)return;const t=new Set,r=[];for(const n of e)t.has(n.value)?console.warn(`Duplicated key: "${n.value}", Ignored: "${n.label}"`):(r.push(n),t.add(n.value));return r}startOAuthFlow(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var n,o,i;const a=this.getIntegrationByName(e),c=(0,l.findSelectedAccountType)(null===(n=null==a?void 0:a.sdkIntegrationConfig)||void 0===n?void 0:n.accountTypes,this.getAccountName(t.accountType),this.getSelectedMultipleAccountTypes(t.accountType)),u={context:{user:this.userState,projectId:this.projectId,environments:this.environments,endUserIntegrationConfig:null!==(o=t.userProvidedIntegrationConfig)&&void 0!==o?o:this.endUserIntegrationConfig[e]},integration:a,endUserSuppliedValues:t.endUserSuppliedValues},h=Boolean(a.needPreOauthInputs&&c&&!(null===(i=c.endUserSuppliedValues)||void 0===i?void 0:i.length)&&c.scheme===s.AuthenticationScheme.OAUTH);if(this.isHeadless||h||!a.needPreOauthInputs){u.authParams=null==c?void 0:c.oauthParameters,u.installOptions=t;const n=Math.random().toString(36).substring(2,15),o=(0,d.startOAuthFlow)(u,n);if(!o)throw new g.OAuthBlockedError;const i=()=>{clearInterval(y)},a=Date.now(),s=new AbortController,l=500;let h=!1;const p={abortSignal:s.signal,onSuccess:e=>{var t;h||(h=!0,i(),null===(t=r.onSuccess)||void 0===t||t.call(r,e))},onError:e=>{var t;h||(h=!0,i(),s.abort(),null===(t=r.onError)||void 0===t||t.call(r,e))}},f=setInterval((()=>{try{!this.isHeadless&&o.opener||(clearInterval(f),this.pollForCredential(e,n,p))}catch(t){clearInterval(f),this.pollForCredential(e,n,p)}}),l),y=setInterval((()=>{try{if(!h&&r.oauthTimeout&&Date.now()-a>r.oauthTimeout)return o.close(),void p.onError(new g.OAuthTimeoutError)}catch(e){p.onError(e)}}),l)}}getIntegrationByName(e){const t=Object.values(this.loadedIntegrations).find((t=>(0,c.getIntegrationTypeName)(t)===e));if(!t)throw new Error(`Integration "${e}" not found.`);return t}getSelectedMultipleAccountTypes(e){if(Array.isArray(e))return e}getAccountName(e){return"string"==typeof e?e.trim():""}setDynamicFieldMappingLoaders(e,t){var r,n;if(this.dynamicFieldMappingLoaders[e]={},t)for(const[o,i]of Object.entries(t))if("object"==typeof i&&"objectTypes"in i&&"integrationFields"in i&&"applicationFields"in i){const a=i;this.dynamicFieldMappingLoaders[e][o]={objectTypes:null===(r=a.objectTypes)||void 0===r?void 0:r.get,integrationFields:null===(n=a.integrationFields)||void 0===n?void 0:n.get},a.applicationFields&&(t[o]={...a.applicationFields,useBYOFieldMappingOption:!0})}}async connect(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{mapObjectFields:r,overrideRedirectUrl:n,isApiInstallation:o=!1,showPortalAfterInstall:i,bypassPostOAuthPrompt:s,allowMultipleCredentials:c,selectedCredentialId:u,selectedConfigurationId:d,accountType:h,externalId:p,...y}=t;return this.integrationToBeEnabled=e,new Promise(((v,E)=>{var m,S;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;const I=this.getIntegrationByName(e),w=this.getSelectedMultipleAccountTypes(h);this.subscribeToIntegration(e,{...y,onInstall:(t,r)=>{var n;const o=r.integrations[e];t.credentialId=null==o?void 0:o.credentialId,t.credential=null==o?void 0:o.allCredentials.find((e=>e.id===o.credentialId)),v(t),(null==y?void 0:y.onInstall)?y.onInstall(t,r):null===(n=null==y?void 0:y.onSuccess)||void 0===n||n.call(y,t,r)},onError:e=>{var t;E(e),null===(t=null==y?void 0:y.onError)||void 0===t||t.call(y,e)}});try{if(r&&!this.project.accessibleFeatures.includes(f.ConnectAddOn.DynamicFieldMapper))throw new Error("Dynamic Field Mapping is available on our Enterprise plan. Contact sales@useparagon.com to learn more or upgrade.");if(this.validateExternalIdOptions(e,{externalId:p,selectedCredentialId:u}),this.validateAction(e),n&&!(0,C.isValidUrl)(n))throw new Error(`${n} is not valid url.`);this.setDynamicFieldMappingLoaders(e,r),this.endUserIntegrationConfig[e]={mapObjectFields:r,overrideRedirectUrl:n?(0,C.sanitizeUrl)(n):void 0};const g=this.getAccountName(h),y=Array.isArray(h)?h.filter((e=>{var t,r;return!(null===(r=null===(t=null==I?void 0:I.sdkIntegrationConfig)||void 0===t?void 0:t.accountTypes)||void 0===r?void 0:r.some((t=>t.id===e)))})):[],T=(0,l.findSelectedAccountType)(null===(m=null==I?void 0:I.sdkIntegrationConfig)||void 0===m?void 0:m.accountTypes,g,w),A={isApiInstallation:o,showPortalAfterInstall:i,bypassPostOAuthPrompt:s,allowMultipleCredentials:c,selectedCredentialId:u,selectedConfigurationId:d,accountType:h,externalId:p};if(this.setCredentialConfigForUserState(e,u,d),t.isApiInstallation&&(null===(S=this.userState.integrations[e])||void 0===S?void 0:S.credentialStatus)!==a.CredentialStatus.PENDING){const r=this.isHeadless?{onSuccess:e=>{v({integrationId:e.integrationId,integrationType:e.integrationType,credentialId:e.credentialId})},onError:e=>{E(e)},oauthTimeout:t.oauthTimeout}:void 0;this.startOAuthFlow(e,A,r)}(h&&!T&&"string"==typeof h||y.length)&&console.warn(`Account type "${y.length?y:h}" is not valid for integration "${null==I?void 0:I.type}"`);const _=JSON.parse(JSON.stringify(this.loadedConfigs[e]));if(t.dropdowns){const r=t.dropdowns,n=[],o=new Set;for(const e in r){const t=r[e];"loadOptions"in t&&(this.customDropdownOptionsLoaders[e]=t.loadOptions,n.push(e),t.refreshOnOpen&&o.add(e))}if(_.sharedMeta&&Array.isArray(_.sharedMeta.inputs))for(const e of _.sharedMeta.inputs){if(n.includes(e.key)){e.customDropdownOptions=[],e.refreshOnOpen=o.has(e.key);continue}const t=this.removeOptionDuplicates(r[e.key]);t&&e.customDropdownOptions&&(e.customDropdownOptions=t)}if(_.workflowMeta)for(const e in _.workflowMeta){const t=_.workflowMeta[e];for(const e of t.inputs){if(n.includes(e.key)){e.customDropdownOptions=[],e.refreshOnOpen=o.has(e.key);continue}const t=this.removeOptionDuplicates(r[e.key]);t&&e.customDropdownOptions&&(e.customDropdownOptions=t)}}this.loadedConfigs[e]=_}this.setModalState({integration:I,config:this.loadedConfigs[e],apiInstallationOptions:{...A,selectedMultipleAccountTypes:w,selectedAccountConfig:T},selectedCredentialId:u,connectionError:void 0,shouldShowPortalAfterInstall:!1})}catch(t){this.emitError(t,e)}}))}setCredentialConfigForUserState(e,t,r){var n,o,i;if(!this.userState.authenticated||!(null===(n=this.userState.integrations[e])||void 0===n?void 0:n.allCredentials.length))return;const s=this.userState.integrations[e],c=null!==(o=null==s?void 0:s.credentialId)&&void 0!==o?o:null==s?void 0:s.allCredentials[0].id,u=this.getCredentialAndConfig(t||r?{selectedCredentialId:t,selectedConfigurationId:r}:{selectedCredentialId:c},s);if(!(null===(i=null==s?void 0:s.allCredentials)||void 0===i?void 0:i.some((e=>{let{id:t}=e;return t===(null==u?void 0:u.selectedCredential.id)})))||!u)throw new Error(`Credential with ID "${t}" is not a valid ${e} account.`);const{selectedConfig:l,selectedCredential:d}=u,h={...s,allConfigurations:(null==s?void 0:s.allConfigurations)||[],allCredentials:(null==s?void 0:s.allCredentials)||[],enabled:d.status===a.CredentialStatus.VALID,credentialId:d.id,credentialStatus:d.status,providerData:d.providerData,providerId:d.providerId,configMeta:null==l?void 0:l.configMeta,credentialConfigId:null==l?void 0:l.id,externalId:null==l?void 0:l.externalId,sharedSettings:null==l?void 0:l.sharedSettings,workflowSettings:null==l?void 0:l.workflowSettings,configuredWorkflows:null==l?void 0:l.workflowSettings};this.userState.integrations={...this.userState.integrations,[e]:h}}getCredentialAndConfig(e,t,r){var n;const{selectedCredentialId:o,selectedConfigurationId:i}=e;let a=null==o?void 0:o.trim();const s=null==i?void 0:i.trim(),c=!!a&&(a.startsWith("ext:")||!(0,m.isUUID)(a));if(!this.userState.authenticated||!a&&!s)return;let u,l;const d=null!==(n=null==t?void 0:t.allCredentials)&&void 0!==n?n:Object.values(this.userState.integrations).flatMap((e=>(null==e?void 0:e.allCredentials)||[])),h=d.flatMap((e=>{let{configurations:t}=e;return t}));if(c){const e=(0,y.sanitizeExternalConfigId)(a),t=d.find((t=>t.externalId===e));if(!t)throw new Error(`Credential with externalId "${e}" not found.`);a=t.id}if(s){const e=s.startsWith("ext:")||!(0,m.isUUID)(s),t=(0,y.sanitizeExternalConfigId)(s),n=r=>(e?r.externalId===t:r.id===t)&&(!a||r.connectCredentialId===a);if(null==r?void 0:r.throwIfMultipleConfigsFound){const e=h.filter(n);if(e.length>1)throw new Error(`Multiple credential configurations found for provided id: ${s}.`);l=e[0]}else l=h.find(n);if(!l)throw new Error(`Credential configuration not found for provided id: ${s}.`)}if(u=d.find((e=>{let{id:t}=e;return t===((null==l?void 0:l.connectCredentialId)||a)})),l=null!=l?l:null==u?void 0:u.configurations.find((e=>{let{isDefault:t}=e;return t})),!u)throw new Error("Unable to find credential for provided options.");if(!l)throw new Error(`Credential configuration not found for credential: ${u.id}.`);if(l&&l.connectCredentialId!==(null==u?void 0:u.id))throw new Error('Provided "selectedCredentialId" does not belongs to provided "selectedConfigurationId".');return{selectedCredential:u,selectedConfig:l}}_getIntegration(e){return Object.values(this.loadedIntegrations).find((t=>t.id===e))}getIntegrationBySlug(e){const t=this.loadedIntegrations[e];if(!t)throw new g.IntegrationNotFoundError(e);return t}async _oauthCallback(e,t,r){var n,o,i;const{integrationId:s,payload:u}=e,l=this._getIntegration(s);if(!l)return;const d=(0,v.hash)(JSON.stringify({oauthResponse:e,credentialId:t}));if(await this.cachedApiResponse.get(d))return;await this.cachedApiResponse.set(d,!0);const h=(0,c.getIntegrationTypeName)(l),p=null!==(n=null==r?void 0:r.installOptions)&&void 0!==n?n:(null===(o=this.modalState.apiInstallationOptions)||void 0===o?void 0:o.isApiInstallation)?this.modalState.apiInstallationOptions:{};try{const e=t?`/sdk/credentials/${t}/complete-setup`:"/sdk/credentials",r=await this.sendConnectRequest(e,{method:"POST",body:JSON.stringify({integrationId:l.id,config:{},payload:u,installOptions:p})});if(!r)throw new Error("Unable to save oauth credentials");return this.updateCredentialData(r,l),r.status===a.CredentialStatus.VALID&&this.triggerSDKEvent({type:f.SDK_EVENT.ON_INTEGRATION_INSTALL,integrationId:l.id,integrationType:h}),this.setModalState({...this.modalState,...(null===(i=this.modalState.apiInstallationOptions)||void 0===i?void 0:i.showPortalAfterInstall)?{shouldShowPortalAfterInstall:!0}:{},connectionError:void 0}),{integrationId:l.id,integrationType:h,credentialId:r.id,credential:r}}catch(e){if(this.isHeadless)throw e;this.setModalState({...this.modalState,connectionError:e}),this.emitError(e,h),await this._oauthErrorCallback(e.message)}}async _oauthErrorCallback(e,t){var r;const n=e;let o;o=this.integrationToBeEnabled?this.loadedIntegrations[this.integrationToBeEnabled].id:null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.integrationId,t&&(this.emitError(t.data.errorResponse,(0,c.getIntegrationTypeName)(this._getIntegration(o))),this.setModalState({...this.modalState,connectionError:t.data})),console.error("Failed to connect account to Paragon over OAuth",n)}async _loadCustomDropdownOptions(e,t,r){return(0,h.cloneDeep)(this.customDropdownOptionsLoaders[e](t,r))}setDataSources(e){this.globalDropdownOptions={},this.globalMapObjectFields={},this.integrationSpecificDropdownOptions={},this.integrationSpecificMapObjectFields={};const t=Object.keys(this.customDropdownOptionsLoaders);for(const e of t)delete this.customDropdownOptionsLoaders[e];if(this.processDropdownSources(e.dropdowns,this.globalDropdownOptions),this.processMapObjectFieldSources(e.mapObjectFields),e.integrationSpecificSources)for(const[t,r]of Object.entries(e.integrationSpecificSources))r&&"object"==typeof r?(this.integrationSpecificDropdownOptions[t]={},this.processDropdownSources(r.dropdowns,this.integrationSpecificDropdownOptions[t]),this.processMapObjectFieldSources(r.mapObjectFields,t)):console.error(`Could not load data source for integration "${t}" because a valid source object was not provided`)}processDropdownSources(e,t){if(e)for(const[r,n]of Object.entries(e))Array.isArray(n)?t[r]=n:n&&"object"==typeof n&&"loadOptions"in n?this.customDropdownOptionsLoaders[r]=n.loadOptions:console.error(`Could not load data source "${r}" because a valid source object was not provided`)}processMapObjectFieldSources(e,t){var r,n,o,i,a;if(!e)return;const s=t?null!==(r=(a=this.integrationSpecificMapObjectFields)[t])&&void 0!==r?r:a[t]={}:null!==(n=this.globalMapObjectFields)&&void 0!==n?n:this.globalMapObjectFields={};for(const[r,n]of Object.entries(e))if(n&&"object"==typeof n){if(s[r]=n,"objectTypes"in n&&"integrationFields"in n&&"applicationFields"in n){const e=n,a=null!=t?t:"__global__";this.dynamicFieldMappingLoaders[a]||(this.dynamicFieldMappingLoaders[a]={}),this.dynamicFieldMappingLoaders[a][r]={objectTypes:null===(o=e.objectTypes)||void 0===o?void 0:o.get,integrationFields:null===(i=e.integrationFields)||void 0===i?void 0:i.get},e.applicationFields&&(s[r]={...e.applicationFields,useBYOFieldMappingOption:!0})}}else console.error(`Could not load data source "${r}" because a valid source object was not provided`)}resolveCustomDropdownSource(e,t){var r;if(!e)return null;const n=null===(r=this.integrationSpecificDropdownOptions[t])||void 0===r?void 0:r[e];if(n)return n;const o=this.globalDropdownOptions[e];return o||null}resolveMapObjectFieldSource(e,t){var r,n;if(!e)return null;const o=null===(r=this.integrationSpecificMapObjectFields[t])||void 0===r?void 0:r[e];if(o&&!this.isDynamicFieldMappingConfig(o))return o;const i=null===(n=this.globalMapObjectFields)||void 0===n?void 0:n[e];return i&&!this.isDynamicFieldMappingConfig(i)?i:null}isDynamicFieldMappingConfig(e){return"object"==typeof e&&!Array.isArray(e)&&"objectTypes"in e&&"integrationFields"in e}hasCustomDropdownLoader(e){return!!e&&!!this.customDropdownOptionsLoaders[e]}async sendConnectRequest(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];var n;if(!this.userState.authenticated||!this.projectId)throw new Error("Connect SDK attempted to make an API request, but no user was authenticated.\nCall paragon.authenticate(<projectId>, <user token>) before using the SDK.");const o=`${null!==(n=null==t?void 0:t.baseURLOverride)&&void 0!==n?n:this.environments.ZEUS_PUBLIC_URL}${r?`/projects/${this.projectId}`:""}${e}`,i=(0,v.hash)(JSON.stringify({url:o,payload:{...t}})),a=await this.cachedApiResponse.get(i,!0);if((null==t?void 0:t.cacheResult)&&a)return a;const s=Boolean(!t||"GET"===t.method||t.cacheResult);if(s&&"object"==typeof this.keyToRequestPromiseMap[i])return this.keyToRequestPromiseMap[i];const c=this.userState.token,u=this.modalState.integration&&this.integrationToBeEnabled?this.userState.integrations[this.integrationToBeEnabled]:void 0,l=new Promise(((e,r)=>{(async()=>{try{const r=await this.sendRequest(o,{...t,headers:{Accept:"application/json","Content-Type":"application/json",[f.SDK_VERSION_HEADER]:this.sdkVersion,...!(null==t?void 0:t.skipDefaultCredentialIdHeader)&&(null==u?void 0:u.credentialId)?{[f.SELECTED_CREDENTIAL_ID_HEADER]:null==u?void 0:u.credentialId}:{},...null==t?void 0:t.headers,Authorization:`Bearer ${c}`}},s?i:void 0);e(r)}catch(e){r(e)}})()}));return s&&(this.keyToRequestPromiseMap[i]=l),l}async sendRequest(e,t,r){var n;let o,a,s;try{o=await fetch(e,t)}catch(e){s=e}const c=e.includes("proxy");if(o&&!o.ok||s){const e=o?await(0,C.getErrorMessage)(o,!0):null==s?void 0:s.message,t="string"==typeof e?e:null==e?void 0:e.message,a=(0,C.errorMessageParser)(t),u="object"==typeof e&&e.response.code===i.INSUFFICIENT_PERMISSION,l="object"==typeof e&&[i.BYO_CREDENTIAL_VERIFICATION_ERROR,i.BYO_USER_PROFILE_ERROR_CODE].includes(e.response.code),d=401===(null==o?void 0:o.status)||403===(null==o?void 0:o.status),h=!a&&!u&&!l&&d;if(h&&!c)this.logout();else if(h&&c){const e=await this.fetchUserData();this.updateAuthenticatedUser({integrations:e.integrations,meta:e.meta,resources:e.resources})}if(r&&(await this.cachedApiResponse.del(r),delete this.keyToRequestPromiseMap[r]),"string"!=typeof e&&c)throw null===(n=e.response)||void 0===n||delete n.headers,new C.ProxyRequestError(e.message,e.response);throw new Error("string"==typeof e?t:JSON.stringify(e.response))}if(c)return r&&delete this.keyToRequestPromiseMap[r],o;try{a=await(null==o?void 0:o.json())}catch{a=void 0}return r&&(await this.cachedApiResponse.set(r,a),delete this.keyToRequestPromiseMap[r]),a}async request(e,t,r){var n,o;const i=`/sdk/proxy/${e}`,a=t.startsWith("/")?t:`/${t}`,s=r.selectedCredentialId,c=await this.sendConnectRequest(`${i}${a}`,{method:r.method,body:"object"==typeof r.body?JSON.stringify(r.body):r.body,headers:{"Content-Type":f.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS,...s?{[f.SELECTED_CREDENTIAL_ID_HEADER]:s}:{},...r.headers},baseURLOverride:this.environments.WORKER_PROXY_PUBLIC_URL,skipDefaultCredentialIdHeader:!0});let u=c;if(c instanceof Response){const e=await c.text();if(!e)return;if((null!==(o=null===(n=c.headers)||void 0===n?void 0:n.get("content-type"))&&void 0!==o?o:"").includes("application/json"))try{u=JSON.parse(e)}catch{u=e}else u=e}return u&&"object"==typeof u&&"output"in u?u.output:u}async event(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{selectedConfigurationId:n,selectedCredentialId:o}=r;if(n&&!o)throw new Error("Configuration ID cannot be used without a corresponding Credential ID. Please provide both if using Configuration ID.");await this.sendConnectRequest(`/v2/projects/${this.projectId}/sdk/events/trigger`,{method:"POST",headers:{...o?{[f.SELECTED_CREDENTIAL_ID_HEADER]:o}:{},...n?{[f.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:n}:{}},body:JSON.stringify({name:e,payload:t}),skipDefaultCredentialIdHeader:!0,baseURLOverride:this.environments.HERMES_PUBLIC_URL},!1)}onClose(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{integration:r,apiInstallationOptions:n}=this.modalState;r&&(this.triggerSDKEvent({type:f.SDK_EVENT.ON_PORTAL_CLOSE,integrationId:r.id,integrationType:(0,c.getIntegrationTypeName)(r)}),this.originalBodyOverflow!==t.PARAGON_OVERFLOW_EMPTY_VALUE&&(window.document.body.style.overflow=this.originalBodyOverflow,this.originalBodyOverflow=t.PARAGON_OVERFLOW_EMPTY_VALUE),!e&&(null==n?void 0:n.isApiInstallation)||(this.setModalState({integration:null}),this.integrationToBeEnabled=void 0))}onOpen(){const{integration:e}=this.modalState;if(e&&(this.triggerSDKEvent({type:f.SDK_EVENT.ON_PORTAL_OPEN,integrationId:e.id,integrationType:(0,c.getIntegrationTypeName)(e)}),this.root&&this.originalBodyOverflow===t.PARAGON_OVERFLOW_EMPTY_VALUE)){const e=this.root.getBoundingClientRect();window.innerHeight<=e.height&&window.innerWidth<=e.width&&(this.originalBodyOverflow=window.document.body.style.overflow,window.document.body.style.overflow="hidden")}}triggerSDKEvent(e){this.triggerEvent(e,this.userState)}getIntegrationMetadata(e){const t=e=>{return{...e,icon:(t=e.icon,t.includes(".svg")?(null===(r=t.split(".svg"))||void 0===r?void 0:r[0])+".svg":t)};var t,r};if(e){const r=this.metadata[e];if(!r)throw new Error(`${e} is not a valid integration name`);return t(r)}return(0,h.cloneDeep)(Object.values(this.metadata).map(t))}closePortal(){this.onClose(!0)}workflow(e){let{selectedCredentialId:t,selectedConfigurationId:r,body:n={},query:o={},headers:i={}}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var a;if(!e)throw new Error("workflowId is required.");const s=new URLSearchParams(o).toString(),{integrationState:c}=this.getIntegrationForWorkflow(e);let u;if((t||r)&&(u=this.getCredentialAndConfig({selectedCredentialId:t,selectedConfigurationId:r},c,{throwIfMultipleConfigsFound:!0}),!u||!(null===(a=u.selectedConfig.workflowSettings[e])||void 0===a?void 0:a.enabled)))throw new Error(`Workflow ${e} is not enabled for this user.`);return this.sendConnectRequest(`/sdk/triggers/${e}?${s}`,{method:"POST",body:JSON.stringify(n),headers:{...u?{[f.SELECTED_CREDENTIAL_ID_HEADER]:u.selectedCredential.id,[f.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:u.selectedConfig.id}:{},...i},skipDefaultCredentialIdHeader:!0,baseURLOverride:this.environments.HERMES_PUBLIC_URL},!0)}installIntegration(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;this.closePortal();const r={showPortalAfterInstall:!1,bypassPostOAuthPrompt:!1,allowMultipleCredentials:!1,...t,isApiInstallation:!0};if(r.bypassPostOAuthPrompt&&r.showPortalAfterInstall)throw new Error("Could not use both `bypassPostOAuthPrompt` and `showPortalAfterInstall` as true at the same time.");if(this.validateExternalIdOptions(e,{externalId:t.externalId,selectedCredentialId:t.selectedCredentialId}),this.ensureHeadlessIsSupported(),this.validateAction(e),!r.allowMultipleCredentials&&this.isAlreadyInstalled(e,this.userState))throw new Error(`Integration "${e}" is already installed.`);if(t.showPortalAfterInstall){const t=Object.values(this.loadedIntegrations).find((t=>(0,c.getIntegrationTypeName)(t)===e));this.setModalState({integration:t,config:this.loadedConfigs[e],apiInstallationOptions:r,shouldShowPortalAfterInstall:!1})}else this.setModalState({integration:null});return this.connect(e,r)}ensureHeadlessIsSupported(){if(!this.project.accessibleFeatures.includes(f.ConnectAddOn.HeadlessConnectPortal))throw new Error("Headless Connect Portal is available on our Pro plan and above. Contact sales@useparagon.com to learn more or upgrade.")}async uninstallIntegration(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var r;const n=null==t?void 0:t.selectedCredentialId;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;if(this.ensureHeadlessIsSupported(),this.validateAction(e),!this.hasCredential(e,this.userState,t.selectedCredentialId))throw new g.IntegrationNotInstalledError(e);const o=this.loadedIntegrations[e].id,i=this.userState.integrations[e],a=n?null===(r=this.getCredentialAndConfig({selectedCredentialId:n},i))||void 0===r?void 0:r.selectedCredential.id:void 0,s=null!=a?a:null==i?void 0:i.credentialId;if(!s||!i)throw new Error("No credential found for uninstall");await this.sendConnectRequest(`/sdk/integrations/${o}`,{method:"DELETE",headers:{...s?{[f.SELECTED_CREDENTIAL_ID_HEADER]:s}:{}}}),this.updateAuthenticatedUser({integrations:{...this.userState.integrations,[e]:(0,l.getActionStateForCredentialDelete)(s,i)}}),n===this.modalState.selectedCredentialId&&this.setModalState({integration:null,selectedCredentialId:void 0}),this.saveState(),this.triggerSDKEvent({type:f.SDK_EVENT.ON_INTEGRATION_UNINSTALL,integrationId:o,integrationType:e})}async disableWorkflow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var r;const{selectedCredentialId:n,selectedConfigurationId:o}=t,{integration:i,integrationState:a}=this.getIntegrationForWorkflow(e),s=this.getCredentialAndConfig(n||o?{selectedCredentialId:n,selectedConfigurationId:o}:{selectedCredentialId:a.credentialId},a);if(!s||!(null===(r=s.selectedConfig.workflowSettings[e])||void 0===r?void 0:r.enabled))throw new Error(`Workflow ${e} cannot be disabled for this user.`);const{selectedConfig:c,selectedCredential:u}=s;await this.sendConnectRequest(`/sdk/workflows/${e}`,{method:"DELETE",headers:{[f.SELECTED_CREDENTIAL_ID_HEADER]:u.id,[f.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:c.id}});const l={...c,workflowSettings:{...c.workflowSettings,[e]:{settings:{},...c.workflowSettings[e],enabled:!1}}},d={...u,configurations:u.configurations.filter((e=>e.id!==c.id)).concat(l)};this.updateCredentialData(d,i)}async enableWorkflow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var r;const{selectedCredentialId:n,selectedConfigurationId:o}=t,{integration:i,integrationState:s}=this.getIntegrationForWorkflow(e),c=this.getCredentialAndConfig(n||o?{selectedCredentialId:n,selectedConfigurationId:o}:{selectedCredentialId:s.credentialId},s);if(!c||(null==c?void 0:c.selectedCredential.status)!==a.CredentialStatus.VALID)throw new Error("Valid credential not found for provided options.");const{selectedConfig:u,selectedCredential:l}=c;if(null===(r=u.workflowSettings[e])||void 0===r?void 0:r.enabled)throw new Error(`Workflow ${e} is already enabled for this user.`);await this.sendConnectRequest(`/sdk/workflows/${e}`,{method:"POST",headers:{[f.SELECTED_CREDENTIAL_ID_HEADER]:l.id,[f.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:u.id}});const d={...u,workflowSettings:{...u.workflowSettings,[e]:{settings:{},...u.workflowSettings[e],enabled:!0}}},h={...l,configurations:l.configurations.filter((e=>e.id!==u.id)).concat(d)};this.updateCredentialData(h,i)}async getIntegrationAccount(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var r;this.validateAction(e);const n=null===(r=this.userState.integrations[e])||void 0===r?void 0:r.allCredentials;if(!(null==n?void 0:n.length))throw new Error("Connect credential not found");const o=await this.sendConnectRequest(`/sdk/credentials?integration=${e}&includeAccountAuth=${t.includeAccountAuth}`,{method:"GET",headers:t.selectedCredentialId?{[f.SELECTED_CREDENTIAL_ID_HEADER]:t.selectedCredentialId}:{}});if(!o)throw new Error("Integration not connected");return o}getIntegrationForWorkflow(e){if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;const t=Object.values(this.loadedIntegrations).find((t=>{const r=t.configs[0].values;return e in(r.workflowMeta||{})}));if(!t)throw new Error("Workflow not found in the configured integrations in your Paragon project.");const r=(0,c.getIntegrationTypeName)(t)?this.userState.integrations[(0,c.getIntegrationTypeName)(t)]:void 0;if(!r||!r.allCredentials.some((e=>{let{status:t}=e;return t===a.CredentialStatus.VALID})))throw new Error(`Integration "${(0,c.getIntegrationTypeName)(t)}" not enabled for workflow."`);return{integration:t,integrationState:r}}async updateLocalState(e){var t,r;const[n,o]=await Promise.all([this.fetchUserData(),this.fetchIntegrations()]);this.project=n.project;let i={...n.integrations};if(this.modalState.integration&&this.integrationToBeEnabled){const e=this.userState.integrations[this.integrationToBeEnabled],n=null==e?void 0:e.credentialConfigId,o=null==e?void 0:e.credentialId;let a;if(n)a=null===(t=i[this.integrationToBeEnabled])||void 0===t?void 0:t.allConfigurations.find((e=>{let{id:t}=e;return t===n}));else if(o){const e=null===(r=i[this.integrationToBeEnabled])||void 0===r?void 0:r.allCredentials.find((e=>{let{id:t}=e;return t===o}));a=e?e.configurations.find((e=>e.isDefault)):void 0}a&&(i={...i,[this.integrationToBeEnabled]:{enabled:!1,allConfigurations:[],allCredentials:[],...i[this.integrationToBeEnabled],credentialId:a.connectCredentialId,credentialConfigId:a.id,workflowSettings:a.workflowSettings,configuredWorkflows:a.workflowSettings,sharedSettings:a.sharedSettings,configMeta:a.configMeta}})}this.updateAuthenticatedUser({integrations:i,meta:n.meta,resources:n.resources}),this.updateIntegrations(o),this.saveState();const a={...n.meta,...e};null!=e&&Object.keys(e).length>0&&!(0,m.areObjectsEqual)(a,n.meta)&&(await this.patchUserMetadata(e),this.updateAuthenticatedUser({meta:a}))}async patchUserMetadata(e){await this.sendConnectRequest("/sdk/me",{method:"PATCH",body:JSON.stringify({meta:e})})}async fetchUserData(){const e=await this.sendConnectRequest("/sdk/me",{});if(!e)throw new Error("Unable to get user Data");return{...e,integrations:Object.fromEntries(Object.entries(e.integrations).map((e=>{let[t,r]=e;const n=r.allCredentials.flatMap((e=>{let{configurations:t}=e;return t}));return[t,{...r,allConfigurations:n}]})))}}async fetchIntegrations(){const e=await this.sendConnectRequest("/sdk/integrations");if(!e)throw new Error("Unable to fetch integrations");return e}getIntegrationIcon(e){if(!e.customIntegration){const t=f.overrideActionAlias[e.type]||e.type;return`${this.environments.CDN_PUBLIC_URL}/integrations/${t}.svg`}return e.customIntegration.icon?e.customIntegration.icon:`${this.environments.CDN_PUBLIC_URL}/images/icons/byo-placeholder.svg`}updateIntegrations(e){e.forEach((e=>{var t;if(e.configs.length)try{const r=(0,c.getIntegrationTypeName)(e);this.loadedConfigs[r]=e.configs[0].values,this.loadedIntegrations[r]={...e,type:e.type.startsWith("custom.")?i.ACTION_CUSTOM:e.type},Boolean(e.isActive)&&(this.metadata[r]={type:r,name:e.name,brandColor:e.brandColor,icon:this.getIntegrationIcon(e)}),(null===(t=this.modalState.integration)||void 0===t?void 0:t.id)===e.id&&this.setModalState({integration:{...e,type:e.type.startsWith("custom.")?i.ACTION_CUSTOM:e.type}})}catch(e){console.warn(e)}}))}async setUserMetadata(e){return await this.patchUserMetadata(e),await this.updateLocalState(),this.render(),this.userState}configureGlobal(e,t){var r,n,o,i,a,s,c,u;if(!e||!e.host)throw new Error("host not specified");const l=e.host.indexOf("http")>-1?new URL(e.host).hostname:e.host;this.environments.CONNECT_PUBLIC_URL=null!==(r=null==t?void 0:t.CONNECT_PUBLIC_URL)&&void 0!==r?r:(0,C.getServiceUrl)("connect",l),this.environments.DASHBOARD_PUBLIC_URL=null!==(n=null==t?void 0:t.DASHBOARD_PUBLIC_URL)&&void 0!==n?n:(0,C.getServiceUrl)("dashboard",l),this.environments.HERMES_PUBLIC_URL=null!==(o=null==t?void 0:t.HERMES_PUBLIC_URL)&&void 0!==o?o:(0,C.getServiceUrl)("hermes",l),this.environments.PASSPORT_PRODUCTION_URL=null!==(i=null==t?void 0:t.PASSPORT_PRODUCTION_URL)&&void 0!==i?i:(0,C.getServiceUrl)("passport",l),this.environments.PASSPORT_PUBLIC_URL=null!==(a=null==t?void 0:t.PASSPORT_PUBLIC_URL)&&void 0!==a?a:(0,C.getServiceUrl)("passport",l),this.environments.ZEUS_PUBLIC_URL=null!==(s=null==t?void 0:t.ZEUS_PUBLIC_URL)&&void 0!==s?s:(0,C.getServiceUrl)("zeus",l),this.environments.CDN_PUBLIC_URL=null!==(c=null==t?void 0:t.CDN_PUBLIC_URL)&&void 0!==c?c:(0,C.getServiceUrl)("dashboard",l),this.environments.WORKER_PROXY_PUBLIC_URL=null!==(u=null==t?void 0:t.WORKER_PROXY_PUBLIC_URL)&&void 0!==u?u:(0,C.getServiceUrl)("worker-proxy",l),this.userState.authenticated=!1,this.root?this.root.src=`${this.environments.CONNECT_PUBLIC_URL}/ui${this.projectId?`?projectId=${this.projectId}`:""}`:console.error("Root element not defined")}async completeInstall(e,t){var r;if(!this.userState.authenticated)throw new Error("Authentication is required");if(!t||!t.authorizationCode)throw new Error("authorizationCode is required");if(t.redirectUrl&&!(0,C.isValidUrl)(t.redirectUrl))throw new Error(`${t.redirectUrl} is not valid url`);this.validateAction(e);const n=Object.values(this.loadedIntegrations).find((t=>(0,c.getIntegrationTypeName)(t)===e)),o=null===(r=t.showPortalAfterInstall)||void 0===r||r,i=await this.sendConnectRequest("/sdk/credentials",{method:"POST",body:JSON.stringify({code:t.authorizationCode,integrationId:n.id,redirectUrl:t.redirectUrl?(0,C.sanitizeUrl)(t.redirectUrl):void 0,integrationOptions:t.integrationOptions||{}})});if(!i)throw new Error("Unable to create credential");this.updateCredentialData(i,n),o&&this.setModalState({integration:n,config:this.loadedConfigs[e],apiInstallationOptions:{}})}updateCredentialData(e,t){var r;const n=this.userState,o=(0,c.getIntegrationTypeName)(t),i=n.integrations[o],s=i.allCredentials.findIndex((t=>{let{id:r}=t;return r===e.id}));s>-1?i.allCredentials[s]=e:i.allCredentials.push(e);const u=Object.values(null!==(r=i.allConfigurations)&&void 0!==r?r:[]).filter((t=>{let{connectCredentialId:r}=t;return r!==e.id})).concat(e.configurations);if(!(-1===s||e.id===i.credentialId||!(!i.credentialConfigId||!e.configurations.some((e=>e.id===i.credentialConfigId)))))return this.updateAuthenticatedUser({integrations:{...n.integrations,[o]:{...i,allConfigurations:u}}}),void this.saveState();const l=i.credentialConfigId?e.configurations.find((e=>i.credentialConfigId===e.id)):e.configurations[0];this.updateAuthenticatedUser({integrations:{...n.integrations,[o]:{...i,allConfigurations:u,credentialStatus:e.status,enabled:e.status===a.CredentialStatus.VALID,credentialId:e.id,providerId:e.providerId,providerData:e.providerData,configMeta:null==l?void 0:l.configMeta,credentialConfigId:null==l?void 0:l.id,externalId:null==l?void 0:l.externalId,sharedSettings:null==l?void 0:l.sharedSettings,workflowSettings:null==l?void 0:l.workflowSettings,configuredWorkflows:null==l?void 0:l.workflowSettings}}}),this.saveState()}async connectAction(e,t){var r;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;const n=null===(r=this.userState.resources.find((t=>e===t.slug)))||void 0===r?void 0:r.id;if(!n)throw new Error(`No resource found with name "${e}".`);if(!t||"object"!=typeof t)throw new Error("payload must be of type object.");const o=await this.sendConnectRequest(`/sdk/resources/${n}/connect`,{method:"POST",body:JSON.stringify(t)});if(!o)throw new Error(`Unable to connect to "${e}".`);return o}async createConfiguration(e){let{credentialId:t,externalId:r}=e;var n,o;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;if(!t)throw new Error('Required options not provided: "credentialId"');if(void 0!==r&&""===(0,y.sanitizeExternalConfigId)(r))throw new Error("`externalId` must not be an empty or whitespace-only string.");const i=this.getCredentialAndConfig({selectedCredentialId:t});if(!i||(null==i?void 0:i.selectedCredential.status)!==a.CredentialStatus.VALID)throw new Error("Valid credential not found for provided options.");const s=await this.sendConnectRequest(`/sdk/credentials/${t}/configurations`,{method:"POST",body:JSON.stringify(r?{externalId:r}:{})});if(!s)throw new Error("Unable to create a configuration for credential.");const c=Object.keys(this.userState.integrations).find((e=>{var t;return null===(t=this.userState.integrations[e])||void 0===t?void 0:t.allCredentials.find((e=>{let{id:t}=e;return t===s.id}))}));if(c){const e=null===(n=this.userState.integrations[c])||void 0===n?void 0:n.allConfigurations.filter((e=>{let{connectCredentialId:t}=e;return t!==s.id})).concat(s.configurations),t=null===(o=this.userState.integrations[c])||void 0===o?void 0:o.allCredentials.map((e=>e.id===s.id?s:e)),r={...this.userState.integrations,[c]:{enabled:!1,...this.userState.integrations[c],allConfigurations:e||[],allCredentials:t||[]}};this.updateAuthenticatedUser({integrations:r})}return[...s.configurations].sort(((e,t)=>new Date(t.dateCreated).getTime()-new Date(e.dateCreated).getTime()))[0]}async destroyConfiguration(e){let{id:t,credentialId:r}=e;var n,o,i,a;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;if(!(null==t?void 0:t.trim())||!(null==r?void 0:r.trim()))throw new Error("One or more required options not provided.");const s=this.getCredentialAndConfig({selectedConfigurationId:t,selectedCredentialId:r});if(!s)throw new Error(`Unable to find credential for configuration: ${t}.`);if(s.selectedConfig.isDefault)throw new Error("Cannot delete default configuration.");await this.sendConnectRequest(`/sdk/credentials/${s.selectedCredential.id}/configurations`,{method:"DELETE",headers:{[f.SELECTED_CREDENTIAL_ID_HEADER]:null==s?void 0:s.selectedCredential.id,[f.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:null==s?void 0:s.selectedConfig.id}});const c=Object.keys(this.userState.integrations).find((e=>{var t;return null===(t=this.userState.integrations[e])||void 0===t?void 0:t.allCredentials.find((e=>{let{id:t}=e;return t===s.selectedCredential.id}))}));if(c){const{selectedConfig:e,selectedCredential:t}=s,r=null===(n=this.userState.integrations[c])||void 0===n?void 0:n.allConfigurations.filter((t=>{let{id:r}=t;return r!==e.id})),u=null===(o=this.userState.integrations[c])||void 0===o?void 0:o.allCredentials.map((r=>r.id!==t.id?r:{...r,configurations:r.configurations.filter((t=>{let{id:r}=t;return r!==e.id}))})),l={...this.userState.integrations,[c]:{enabled:!1,...this.userState.integrations[c],allConfigurations:r||[],allCredentials:u||[]}};this.updateAuthenticatedUser({integrations:l}),(null===(i=this.userState.integrations[c])||void 0===i?void 0:i.credentialId)===t.id&&(null===(a=this.userState.integrations[c])||void 0===a?void 0:a.credentialConfigId)===e.id&&this.closePortal()}}async updateConfiguration(e){let{id:t,credentialId:r,meta:n={}}=e;var o,i;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;if(!(null==t?void 0:t.trim())||!(null==r?void 0:r.trim()))throw new Error("One or more required options not provided.");const a=this.getCredentialAndConfig({selectedConfigurationId:t,selectedCredentialId:r});if(!(null==a?void 0:a.selectedConfig))throw new Error(`Cannot find credential configuration with given id: "${t}"`);const s=await this.sendConnectRequest(`/sdk/credentials/${a.selectedConfig.connectCredentialId}/configurations`,{method:"PATCH",body:JSON.stringify({meta:n}),headers:{[f.SELECTED_CREDENTIAL_ID_HEADER]:a.selectedCredential.id,[f.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:a.selectedConfig.id}});if(!s)throw new Error("Unable to update configuration.");const c=Object.keys(this.userState.integrations).find((e=>{var t;return null===(t=this.userState.integrations[e])||void 0===t?void 0:t.allCredentials.find((e=>{let{id:t}=e;return t===s.id}))}));if(c){const e=null===(o=this.userState.integrations[c])||void 0===o?void 0:o.allConfigurations.filter((e=>{let{connectCredentialId:t}=e;return t!==s.id})).concat(s.configurations),t=null===(i=this.userState.integrations[c])||void 0===i?void 0:i.allCredentials.map((e=>e.id===s.id?s:e)),r={...this.userState.integrations,[c]:{enabled:!1,...this.userState.integrations[c],allConfigurations:e||[],allCredentials:t||[]}};this.updateAuthenticatedUser({integrations:r})}const u=s.configurations.find((e=>{let{id:t}=e;return t===a.selectedConfig.id}));return u}async pollForCredential(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var n,o,i;const s=Date.now(),c=async()=>{try{return await this.sendConnectRequest(`/sdk/actions/session-id/${t}`,{method:"GET"})}catch(e){return console.error("error",e),null}};try{const t=await(0,m.tryUntil)(c,((e,t)=>{var n;return!(null===(n=r.abortSignal)||void 0===n?void 0:n.aborted)&&!(Date.now()-s>=d.MAX_POLL_DURATION||(null==e?void 0:e.connectCredentialId))}),1e3);if(!t||!t.connectCredentialId)return;const u=null===(n=this.userState.integrations[e])||void 0===n?void 0:n.allCredentials.find((e=>e.id===t.connectCredentialId)),l=this.getIntegrationByName(e);if(u&&u.status===a.CredentialStatus.VALID)return this.triggerSDKEvent({type:f.SDK_EVENT.ON_INTEGRATION_INSTALL,integrationId:l.id,integrationType:e}),void(null===(o=r.onSuccess)||void 0===o||o.call(r,{integrationId:l.id,integrationType:e,credentialId:t.connectCredentialId,credential:u}));const h=await this.sendConnectRequest(`/sdk/credentials/${t.connectCredentialId}`,{method:"GET"});if(!h)return;this.updateCredentialData(h,this.loadedIntegrations[e]),h.status===a.CredentialStatus.VALID&&this.triggerSDKEvent({type:f.SDK_EVENT.ON_INTEGRATION_INSTALL,integrationId:l.id,integrationType:e}),null===(i=r.onSuccess)||void 0===i||i.call(r,{integrationId:l.id,integrationType:e,credentialId:t.connectCredentialId,credential:h})}catch(e){r.onError&&r.onError(e)}finally{await this.sendConnectRequest(`/sdk/actions/session-id/${t}`,{method:"DELETE"})}}async getCustomWebhookUserManualUrl(e,t){var r;const n=this.userState;if(!n.authenticated)throw new g.UserNotAuthenticatedError;const{workflow:o,type:i}=Object.values(this.loadedIntegrations).reduce(((t,r)=>{if(t.workflow)return t;const n=r.workflows.find((t=>t.id===e));return n?{workflow:n,type:r.type}:t}),{workflow:void 0,type:void 0});if(!o)throw new Error(`Unable to get workflow for "${e}".`);if(!i)throw new Error(`Unable to get integration type for "${e}".`);let a=o.integrationId,s=null!=t?t:null===(r=n.integrations[i])||void 0===r?void 0:r.credentialId;if(o.resourceId){const e=n.resources.find((e=>e.id===o.resourceId));a=null==e?void 0:e.integrationId,s=null==e?void 0:e.credentialId}if(!a)throw new Error(`Unable to find integrationId for "${e}".`);if(!s)throw new Error(`Unable to find credentialId for "${e}".`);return`${this.environments.HERMES_PUBLIC_URL}/triggers/connect/${this.projectId}/${a}/custom-triggers/${o.customWebhookTriggerId}?id=${s}`}getIntegrationConfig(e){var t,r;if(!e)throw new Error("Integration is required.");const n=this.loadedIntegrations[e],o=(0,h.cloneDeep)(n.configs[0].values),i=[],a=[],s=new Map(n.workflows.map((e=>[e.id,e]))),c=null!==(t=n.noPermissionWorkflows)&&void 0!==t?t:[];return Object.values(o.workflowMeta||{}).map((e=>{var t;if(!s.has(e.id)&&!c.includes(e.id))return;const r=null===(t=s.get(e.id))||void 0===t?void 0:t.description;e.hidden||e.permissions&&c.includes(e.id)?i.push({...e,description:r}):a.push({...e,description:r})})),{shortDescription:o.description,longDescription:o.overview,availableUserSettings:null===(r=o.sharedMeta)||void 0===r?void 0:r.inputs,availableWorkflows:a,hiddenWorkflows:i}}getCredentialPair(e,t){const r=this.userState;if(!r.authenticated)throw new g.UserNotAuthenticatedError;const n=r.integrations[e];if(!n)throw new g.IntegrationNotFoundError(e);const o=(null==t?void 0:t.selectedCredentialId)||n.credentialId;if(!o)throw new Error("Credential not found");const i=n.allCredentials.find((e=>e.id===o));if(!i)throw new Error("Credential not found");if(i.status!==a.CredentialStatus.VALID)throw new Error("Valid credential not found for provided options.");const s=i.configurations.find((e=>(null==t?void 0:t.selectedConfigurationId)?e.id===t.selectedConfigurationId:e.isDefault));if(!s)throw new Error("Configuration not found");return{selectedCredential:i,selectedConfiguration:s}}async updateConfig(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;this.validateAction(e);const{selectedConfiguration:n,selectedCredential:o}=this.getCredentialPair(e,r),i=this.userState.token,a=await this.sendConnectRequest(`/sdk/credentials/${o.id}`,{method:"PATCH",headers:{Authorization:`Bearer ${i}`,[f.SELECTED_CREDENTIAL_ID_HEADER]:o.id,[f.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:n.id},body:JSON.stringify({config:t})});if(!a)throw new Error(`Failed to update settings for ${e}.`);const s=this.loadedIntegrations[e];return this.updateCredentialData(a,s),a}async updateIntegrationUserSettings(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;const{selectedConfiguration:n}=this.getCredentialPair(e,r),o=n.sharedSettings,i=await this.updateConfig(e,{sharedSettings:{...o,...t}},r);return{userState:this.userState,errors:"errors"in i?i.errors:[]}}async updateWorkflowUserSettings(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;const{selectedConfiguration:o}=this.getCredentialPair(e,n),i=(0,h.cloneDeep)(o.workflowSettings),a=null==i?void 0:i[t];if(!a)throw new Error(`Workflow with ID "${t}" was not found in the current configuration.`);for(const e in r)a.settings[e]=r[e];const s=await this.updateConfig(e,{workflowSettings:i},n);return{userState:this.userState,errors:"errors"in s?s.errors:[]}}async updateWorkflowState(e,t){const r=[];for(const[n,o]of Object.entries(e))try{o?await this.enableWorkflow(n,t):await this.disableWorkflow(n,t)}catch(e){r.push({workflowId:n,message:e.message})}return{user:this.getUser(),errors:r}}async getFieldOptions(e){let{integration:t,action:r,source:n,search:o,cursor:i,parameters:a=[],selectedCredentialId:s}=e;var c;this.validateAction(t);const u=null!=r?r:null==n?void 0:n.cacheKey;if(!u)throw new Error('Either "action" or a "source" with a cacheKey must be provided.');if(this.hasCustomDropdownLoader(u)){const e=await this._loadCustomDropdownOptions(u,"string"==typeof i?i:void 0,o);return{data:e.options,nestedData:[],nextPageCursor:e.nextPageCursor}}if(n&&"dynamicFieldMappingKey"in n){const{dynamicFieldMappingKey:e,dynamicFieldMappingType:r}=n,s=null===(c=a.find((e=>"value"in e.source&&e.source.value)))||void 0===c?void 0:c.source,u=null==s?void 0:s.value,l=await this._fetchBYOFieldMappingOptions(t,r,e,{objectType:u,cursor:"string"==typeof i?i:void 0,search:o});return{data:l.options,nestedData:[],nextPageCursor:l.nextPageCursor}}const l=await this.sendConnectRequest("/sdk/actions",{method:"POST",body:JSON.stringify({action:t,sourceKey:u,parameters:a,paginationParameters:{pageCursor:null!=i?i:0,search:o}}),headers:{...s?{[f.SELECTED_CREDENTIAL_ID_HEADER]:s}:{}}});let d=[],h=[];const p=l.output.records||l.output;return p[0]&&"id"in p[0]?h=p:d=p,{data:d,nestedData:h,nextPageCursor:l.output.nextPageCursor||null}}async getDataSourceOptions(e,t){var r;const n=this.getIntegrationByName(e);return(0,h.cloneDeep)(null===(r=n.sdkIntegrationConfig)||void 0===r?void 0:r.dataSources[t])}getSourcesForInput(e,t){var r,n;if(t.type===f.SidebarInputType.CustomDropdown){const{customDropdownOptions:r,title:n,key:o}=t,i=this.resolveCustomDropdownSource(o,e);return i?{kind:"single",source:{type:f.DataSourceType.STATIC_ENUM,title:null!=n?n:"",id:null!=o?o:"",values:i}}:this.hasCustomDropdownLoader(o)?{kind:"single",source:{type:f.DataSourceType.DYNAMIC,title:null!=n?n:"",cacheKey:null!=o?o:"",refreshDependencies:[],mapRefreshToValues:e=>e,getRefreshActionParameters:()=>({})}}:(null==r?void 0:r.length)?{kind:"single",source:{type:f.DataSourceType.STATIC_ENUM,title:null!=n?n:"",id:null!=o?o:"",values:r}}:(o&&console.error(`No dynamic fields were provided for dropdown key "${o}" for the input "${n}"`),null)}if(!("sourceType"in t)||!t.sourceType)return null;let o;try{o=this.getIntegrationByName(e)}catch{return null}const i=null===(r=o.sdkIntegrationConfig)||void 0===r?void 0:r.dataSources[t.sourceType];if(!i)return null;if(i.type===f.DataSourceType.DYNAMIC)return{kind:"single",source:i};if(i.type===f.DataSourceType.FIELD_MAPPER){const{recordSource:r,fieldSource:o,dependentInputSource:a,dependentFieldInputSource:s}=i,c=t,u=this.resolveMapObjectFieldSource(c.dynamicObjectName,e);c.dynamicObjectName&&!u&&console.error(`No dynamic fields were provided by Object Name key "${c.dynamicObjectName}" for the input "${null!==(n=t.title)&&void 0!==n?n:"Field Mapping"}"`);const l=u&&!Array.isArray(u)&&u.useBYOFieldMappingOption,d=c.dynamicObjectName;return{kind:"fieldMapper",recordSource:l&&d?{...r,dynamicFieldMappingKey:d,dynamicFieldMappingType:f.DynamicFieldMappingLoaderType.OBJECT_TYPES}:r,fieldSource:l&&d?{...o,dynamicFieldMappingKey:d,dynamicFieldMappingType:f.DynamicFieldMappingLoaderType.INTEGRATION_FIELDS}:o,...!l&&a&&{dependentInputSource:a},...!l&&s&&{dependentFieldInputSource:s},...u&&{mapObjectFieldOptions:u}}}if(i.type===f.DataSourceType.COMBO_INPUT){const{mainInputSource:e,dependentInputSource:t}=i;return{kind:"combo",mainInputSource:e,dependentInputSource:t}}if(i.type===f.DataSourceType.DYNAMIC_COMBO_INPUT){const{mainInputSource:e,dependentInputSource:t,variableInputSource:r}=i;return{kind:"defaultFieldValue",mainInputSource:e,dependentInputSource:t,...r&&{variableInputSource:r}}}return null}getAccountTypeOptions(e){var t,r,n;const o=this.getIntegrationBySlug(e);return null!==(n=(0,h.cloneDeep)(null!==(r=null===(t=o.sdkIntegrationConfig)||void 0===t?void 0:t.accountTypes)&&void 0!==r?r:[]))&&void 0!==n?n:[]}getPreOptions(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";var r,n,o,i;const a=(0,h.cloneDeep)(this.getIntegrationBySlug(e));if(a.customIntegration)return a.authenticationType===s.AuthenticationScheme.OAUTH_CLIENT_CREDENTIAL?(0,h.cloneDeep)(b):null!==(r=a.customIntegration.inputFields)&&void 0!==r?r:[];const c=this.getAccountTypeOptions(e);if(null==c?void 0:c.length){const e=null==c?void 0:c.find((e=>e.id===t));if(null===(n=null==e?void 0:e.endUserSuppliedValues)||void 0===n?void 0:n.length)return(0,h.cloneDeep)(e.endUserSuppliedValues)}return(null===(i=null===(o=a.sdkIntegrationConfig)||void 0===o?void 0:o.authConfigInputs)||void 0===i?void 0:i.length)?a.sdkIntegrationConfig.authConfigInputs:[]}getPostOptions(e){var t,r;const n=this.getIntegrationBySlug(e);return null!==(r=(0,h.cloneDeep)(null===(t=n.sdkIntegrationConfig)||void 0===t?void 0:t.postOauthInputs))&&void 0!==r?r:[]}async _fetchBYOFieldMappingOptions(e,t,r,n){var o,i,a;const s=null!==(i=null===(o=this.dynamicFieldMappingLoaders[e])||void 0===o?void 0:o[r])&&void 0!==i?i:null===(a=this.dynamicFieldMappingLoaders.__global__)||void 0===a?void 0:a[r];if(!s)throw new Error(`No dynamic field mapping loader found for key: ${r}`);if(t===f.DynamicFieldMappingLoaderType.OBJECT_TYPES)return await s.objectTypes(null==n?void 0:n.cursor,null==n?void 0:n.search);if(t===f.DynamicFieldMappingLoaderType.INTEGRATION_FIELDS){if(!(null==n?void 0:n.objectType))throw new Error("objectType is required for integrationFields");return await s.integrationFields({objectType:n.objectType},n.cursor,n.search)}throw new Error(`Invalid type: ${t}. Must be 'objectTypes' or 'integrationFields'`)}}t.default=A;class _{constructor(e){this.paragon=e,this.startOptions=null,this.integrationName=null,this.accountTypeValue=null,this.preOptionsValue=null,this.postOptionsValue=null,this.credentialId=null,this.hasFinishedInstruction=!1}start(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.asyncStart(e,t).catch((e=>{this.handleError(e)}))}async cancel(){this.startOptions=null,this.accountTypeValue=null,this.preOptionsValue=null,this.postOptionsValue=null,this.hasFinishedInstruction=!1;try{if(this.credentialId&&this.integrationName&&await this.paragon.uninstallIntegration(this.integrationName,{selectedCredentialId:this.credentialId}),!this.credentialId&&!this.integrationName){const e=new g.NoActiveInstallFlowError;console.warn(e.message)}}catch(e){console.error("Error cancelling the current install flow",{credentialId:this.credentialId,integration:this.integrationName},e)}finally{this.integrationName=null,this.credentialId=null}}getInstallOptions(){var e,t,r,n,o,i,a,s;return{allowMultipleCredentials:null!==(t=null===(e=this.startOptions)||void 0===e?void 0:e.allowMultipleCredentials)&&void 0!==t&&t,overrideRedirectUrl:null!==(n=null===(r=this.startOptions)||void 0===r?void 0:r.overrideRedirectUrl)&&void 0!==n?n:void 0,selectedCredentialId:null!==(i=null===(o=this.startOptions)||void 0===o?void 0:o.selectedCredentialId)&&void 0!==i?i:void 0,externalId:null!==(s=null===(a=this.startOptions)||void 0===a?void 0:a.externalId)&&void 0!==s?s:void 0}}async asyncStart(e,t){if(this.startOptions=t,this.integrationName=e,this.accountTypeValue=null,this.preOptionsValue=null,this.postOptionsValue=null,this.credentialId=null,!this.paragon.isHeadless)throw new g.HeadlessModeNotEnabledError;const r=this.next();if("oauth"===r.stage)return this.handleNext(r),this.handleOAuth();this.handleNext(r)}handleError(e,t){var r,n;const o=(0,g.getConnectSDKError)(e);null===(n=null===(r=this.startOptions)||void 0===r?void 0:r.onError)||void 0===n||n.call(r,o,null!=t?t:null)}handleNext(e){var t,r;null===(r=null===(t=this.startOptions)||void 0===t?void 0:t.onNext)||void 0===r||r.call(t,e)}handleComplete(e){var t,r;null===(r=null===(t=this.startOptions)||void 0===t?void 0:t.onComplete)||void 0===r||r.call(t,e)}getScheme(){var e,t;if(null===this.integrationName)return null;if(!this.accountTypeValue)return null!==(e=this.paragon.getIntegrationBySlug(this.integrationName).authenticationType)&&void 0!==e?e:null;const r=this.getSelectedAccountTypeOption();return null!==(t=null==r?void 0:r.scheme)&&void 0!==t?t:null}getIntegrationName(){if(!this.integrationName)throw new g.NoActiveInstallFlowError;return this.integrationName}getSelectedAccountTypeOption(){var e;return null===(e=this.paragon.getAccountTypeOptions(this.getIntegrationName()))||void 0===e?void 0:e.find((e=>e.id===this.accountTypeValue))}requiresAccountType(){const e=this.paragon.getAccountTypeOptions(this.getIntegrationName());return!(!e||0===e.length)&&!this.accountTypeValue}getIntegrationInstructionMetadata(){var e,t;if(null===this.integrationName)return null;if(!this.accountTypeValue||"user-configured-oauth"===this.accountTypeValue)return null;const r=this.paragon.getIntegrationBySlug(this.integrationName);if("salesforce"!==r.type)return null;let n=null===(t=null===(e=r.sdkIntegrationConfig)||void 0===e?void 0:e.authSchemeOptions)||void 0===t?void 0:t.packageInstallUrl;if(!n)return null;const o="login.salesforce.com/packaging/installPackage.apexp",i="https://"+o,a="appexchange.salesforce.com/appxListingDetail",s="https://"+a,c=n.startsWith(i)||n.startsWith(o),u=n.startsWith(s)||n.startsWith(a);if(!c&&!u)return null;"sandbox"!==this.accountTypeValue||u||(n=n.replace("login.salesforce.com","test.salesforce.com"));const l=this.getSalesforceInstructionMetadata(this.accountTypeValue,u,n);if(!l)return null;return{...l,packageInstallUrl:n}}getSalesforceInstructionMetadata(e,t,r){const n="sandbox"===e,o=t?"Install App":"Install Package",i=t?"You'll need an admin to add this app from AppExchange to your Salesforce org to continue authorizing your account.":"You'll need an admin to install a package to your Salesforce org to continue authorizing your account.",a=t?`From AppExchange, click ${n?"Try It":"Get It Now"} and follow the prompts to add the app to your ${n?"Sandbox":"Production"} environment.`:'In the install prompt, choose "Install for All Users" if Salesforce users in your org other than your admin will also connect their accounts to this integration.',s=t?n?"salesforce-install-app-sandbox":"salesforce-install-app-default":"salesforce-install-package",c=t?"Go to AppExchange":"Install";return{content:(0,E.dedent)(`\n ## ${o}\n\n ${i}\n\n } "Install Image")\n\n ${a}\n `),ctas:[{type:"link",label:c,href:r},{type:"copyButton",label:"Copy link",copyText:r}],finish:{type:"finishButton",label:"I've installed the package",onClick:()=>{this.setHasFinishedInstruction()}}}}requiresInstruction(){if(this.hasFinishedInstruction)return[!1,null];const e=this.getIntegrationInstructionMetadata();return null===e?[!1,null]:[!0,e]}requiresPreOptions(){var e;const t=this.paragon.getPreOptions(this.getIntegrationName(),null!==(e=this.accountTypeValue)&&void 0!==e?e:void 0);return!(!t||0===t.length)&&!this.preOptionsValue}requiresPostOptions(){var e,t;if(null!==(t=null===(e=this.getSelectedAccountTypeOption())||void 0===e?void 0:e.skipPostOAuthInputs)&&void 0!==t&&t)return!1;const r=this.paragon.getPostOptions(this.getIntegrationName());return!(!r||0===r.length)&&!this.postOptionsValue}requiresOAuth(){return this.getScheme()===s.AuthenticationScheme.OAUTH&&!this.credentialId}async handleOAuth(){let{accountType:e,endUserSuppliedValues:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r=null!=e?e:this.accountTypeValue,n=this.getInstallOptions();try{const e=await new Promise(((e,o)=>{var i;this.paragon.startOAuthFlow(this.getIntegrationName(),{accountType:null!=r?r:void 0,endUserSuppliedValues:t,allowMultipleCredentials:n.allowMultipleCredentials,selectedCredentialId:n.selectedCredentialId,externalId:n.externalId,userProvidedIntegrationConfig:{overrideRedirectUrl:n.overrideRedirectUrl?(0,C.sanitizeUrl)(n.overrideRedirectUrl):void 0}},{onSuccess:t=>e(t),onError:e=>o(e),oauthTimeout:null===(i=this.startOptions)||void 0===i?void 0:i.oauthTimeout})}));if(!e||!e.credentialId)throw new Error("Could not find a credential ID");this.credentialId=e.credentialId;const o=this.next();"done"===o.stage?this.handleComplete(e):this.handleNext(o)}catch(e){this.handleError(e,{stage:"oauth"})}}async setAccountType(e){try{this.accountTypeValue=e;const t=this.next();if("oauth"===t.stage)return this.handleNext(t),void await this.handleOAuth();this.handleNext(t)}catch(e){this.handleError(e,{stage:"accountType"})}}async setPreOptions(e){var t,r;try{if(!e)throw new Error("Pre options are not set");this.preOptionsValue=e;const n=this.next();if("oauth"===n.stage)return this.handleNext(n),void await this.handleOAuth({endUserSuppliedValues:{...e}});const o="done"===n.stage,i=null!==(r=null===(t=this.getSelectedAccountTypeOption())||void 0===t?void 0:t.skipPostOAuthInputs)&&void 0!==r&&r,a=await this.paragon._oauthCallback({payload:{...e,skipPostOAuthInputs:i},integrationId:this.paragon.getIntegrationId(this.getIntegrationName())},void 0,{installOptions:this.getInstallOptions()});if(!o)return void this.handleNext(n);if(!a)return void console.warn("Could not find a credential ID");this.handleComplete(a)}catch(e){this.handleError(e,{stage:"preOptions"})}}async setPostOptions(e){var t,r;try{if(!e)throw new Error("Post options are not set");if(!this.credentialId)throw new Error("Credential ID is not set");this.postOptionsValue=e;const n=null!==(r=null===(t=this.getSelectedAccountTypeOption())||void 0===t?void 0:t.skipPostOAuthInputs)&&void 0!==r&&r,o=await this.paragon._oauthCallback({payload:{...e,skipPostOAuthInputs:n},integrationId:this.paragon.getIntegrationId(this.getIntegrationName())},this.credentialId,{installOptions:this.getInstallOptions()}),i=this.next();if(!("done"===i.stage))return void this.handleNext(i);if(!o)return void console.warn("Could not find a credential ID");this.handleComplete(o)}catch(e){this.handleError(e,{stage:"postOptions"})}}async setHasFinishedInstruction(){try{this.hasFinishedInstruction=!0;const e=this.next();if("oauth"===e.stage)return this.handleNext(e),void await this.handleOAuth();this.handleNext(e)}catch(e){this.handleError(e,{stage:"instruction"})}}getAccountTypeValue(){return this.accountTypeValue}getPreOptionsValue(){return this.preOptionsValue}getPostOptionsValue(){return this.postOptionsValue}next(){var e;const t=this.getIntegrationName();if(this.requiresAccountType())return{stage:"accountType",options:this.paragon.getAccountTypeOptions(t),done:!1};const[r,n]=this.requiresInstruction();return r?{stage:"instruction",content:n.content,ctas:n.ctas,finish:n.finish,packageInstallUrl:n.packageInstallUrl,done:!1}:this.requiresPreOptions()?{stage:"preOptions",options:this.paragon.getPreOptions(t,null!==(e=this.accountTypeValue)&&void 0!==e?e:void 0),done:!1}:this.requiresOAuth()?{stage:"oauth",done:!1}:this.requiresPostOptions()?{stage:"postOptions",options:this.paragon.getPostOptions(t),done:!1}:{stage:"done",done:!0}}}t.InstallFlow=_;const b=[{id:"clientId",title:"Client ID",type:f.SidebarInputType.ValueText,required:!0},{id:"clientSecret",title:"Client Secret",type:f.SidebarInputType.Password,required:!0}]},9892:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(3821);t.default=class{constructor(){this.eventListenersMap={},this.integrationStateCallbacks={}}subscribe(e,t){var r;if(this.assertEventType(e),"function"!=typeof t)throw new Error(`no listener is provided for ${e}`);return this.eventListenersMap={...this.eventListenersMap,[e]:[...null!==(r=this.eventListenersMap[e])&&void 0!==r?r:[],t]},()=>this.unsubscribe(e,t)}subscribeToIntegration(e,t){this.integrationStateCallbacks[e]={...t}}unsubscribe(e,t){var r,n;if(this.assertEventType(e),"function"!=typeof t)throw new Error("listener is required for unsubscription");const o=(null!==(r=this.eventListenersMap[e])&&void 0!==r?r:[]).length;return this.eventListenersMap={...this.eventListenersMap,[e]:(null!==(n=this.eventListenersMap[e])&&void 0!==n?n:[]).filter((e=>e!==t))},o>this.eventListenersMap[e].length}assertEventType(e){if(!Object.values(n.SDK_EVENT).includes(e))throw new Error(`${e} is not valid paragon event`)}emitSafe(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var o;(null!==(o=this.eventListenersMap[e])&&void 0!==o?o:[]).forEach((e=>{try{e(...r)}catch(e){console.error(e)}}))}emitError(e,t){this.invokeCallbackSafe(t,"onError",e)}invokeCallbackSafe(e,t){var r,n,o;try{for(var i=arguments.length,a=new Array(i>2?i-2:0),s=2;s<i;s++)a[s-2]=arguments[s];null===(n=null===(r=this.integrationStateCallbacks[e])||void 0===r?void 0:r[t])||void 0===n||n.call(r,...a)}catch(e){console.error(e)}finally{null===(o=this.integrationStateCallbacks[e])||void 0===o||delete o[t]}}triggerEvent(e,t){let{type:r,integrationId:o,integrationType:i,workflowId:a,workflowStateChange:s}=e;if(o&&i)switch(r){case n.SDK_EVENT.ON_INTEGRATION_INSTALL:{const e=[{integrationId:o,integrationType:i},t];this.invokeCallbackSafe(i,"onInstall",...e),this.emitSafe(n.SDK_EVENT.ON_INTEGRATION_INSTALL,...e);break}case n.SDK_EVENT.ON_INTEGRATION_UNINSTALL:{const e=[{integrationId:o,integrationType:i},t];this.invokeCallbackSafe(i,"onUninstall",...e),this.emitSafe(n.SDK_EVENT.ON_INTEGRATION_UNINSTALL,...e);break}case n.SDK_EVENT.ON_PORTAL_OPEN:{const e=[{integrationId:o,integrationType:i},t];this.invokeCallbackSafe(i,"onOpen",...e),this.emitSafe(n.SDK_EVENT.ON_PORTAL_OPEN,...e);break}case n.SDK_EVENT.ON_PORTAL_CLOSE:{const e=[{integrationId:o,integrationType:i},t];this.invokeCallbackSafe(i,"onClose",...e),this.emitSafe(n.SDK_EVENT.ON_PORTAL_CLOSE,...e);break}case n.SDK_EVENT.ON_WORKFLOW_CHANGE:{const e=[{integrationId:o,workflowId:a,workflowStateChange:s||{}},t];this.invokeCallbackSafe(i,"onWorkflowChange",...e),this.emitSafe(n.SDK_EVENT.ON_WORKFLOW_CHANGE,...e);break}default:throw new Error(`${r} is not valid event.`)}}}},5486:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isBundledBuild=void 0;t.isBundledBuild=()=>!0},3931:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PERSONA_META_HEADER=t.BYO_USER_PROFILE_ERROR_CODE=t.BYO_CREDENTIAL_VERIFICATION_ERROR=t.INSUFFICIENT_PERMISSION=t.ACTION_CUSTOM=void 0,t.ACTION_CUSTOM="custom",t.INSUFFICIENT_PERMISSION="7210",t.BYO_CREDENTIAL_VERIFICATION_ERROR="7003",t.BYO_USER_PROFILE_ERROR_CODE="0704",t.PERSONA_META_HEADER="X-Paragon-User-Metadata"},4059:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CredentialStatus=void 0,function(e){e.PENDING="PENDING",e.INVALID="INVALID",e.VALID="VALID"}(t.CredentialStatus||(t.CredentialStatus={}))},745:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AuthenticationScheme=void 0,function(e){e.BASIC="basic",e.OAUTH="oauth",e.OAUTH_CLIENT_CREDENTIAL="oauth_client_credential",e.SERVICE_ACCOUNT="service_account",e.OAUTH_APP="oauth_app",e.IMPERSONATED_APP="impersonated_app"}(t.AuthenticationScheme||(t.AuthenticationScheme={}))},1663:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generateSlugForIntegration=void 0,t.generateSlugForIntegration=function(e){if(!e.name)return;return`custom.${e.name?e.name.replace(/[\W_]+/g,"").trim().toLowerCase():void 0}`}},7343:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isCustomIntegrationTypeName=t.getIntegrationTypeName=void 0;const n=r(3931),o=r(1663);t.getIntegrationTypeName=function(e){var t;if(e.type===n.ACTION_CUSTOM){if(e.customIntegration)return null!==(t=e.customIntegration.slug)&&void 0!==t?t:(0,o.generateSlugForIntegration)(e.customIntegration);throw new Error(`Custom integration details are missing from this integration: ${e.id}`)}return e.type},t.isCustomIntegrationTypeName=function(e){return e.startsWith("custom.")}},9845:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MicrosoftPicker=void 0;const n=r(3821),o=r(5486),i=r(7473);class a extends i.BaseFilePicker{constructor(e,t){super(e,t),this.options=e,this.connectSDKInstance=t,this.accessToken="",this.baseUrl=""}getInstance(){return null}open(){var e,t;return this.dependencyStatus===n.FilePickerStatus.LOADED&&(null===(t=(e=this.options).onOpen)||void 0===t||t.call(e),this.launchPicker(this.getPickerOptions()),!0)}async initPicker(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"https://alcdn.msauth.net/browser/2.19.0/js/msal-browser.min.js";var i;this.dependencyStatus=n.FilePickerStatus.LOADING;const{selectedCredentialId:a,...s}=e||{};this.initOptions=s,this.selectedCredentialId=a;const c=await this.connectSDKInstance.getIntegrationAccount(t,{includeAccountAuth:!0,selectedCredentialId:a});return this.accessToken=c.accountAuth[(null===(i=n.AUTH_TOKEN_ALLOWED_INTEGRATIONS[t])||void 0===i?void 0:i.accessTokenPath)||""],this.baseUrl=this.getUrl(c,t),this.initialiseDependencyPromise(),(0,o.isBundledBuild)()?this.onScriptLoaded():this.injectScript(r),this.dependenciesPromise}onScriptLoaded(){this.dependencyStatus=n.FilePickerStatus.LOADED,this.dependenciesPromise.resolve(!0)}onScriptError(){this.dependencyStatus=n.FilePickerStatus.FAILED,this.dependenciesPromise.reject(new Error("Failed to load dependencies"))}combinePaths(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.map((e=>e.replace(/^[/\\]+|[/\\]+$/g,""))).join("/").replace(/\\/g,"/")}async launchPicker(e){if(!this.accessToken)throw new Error("Access Token is not set! Please re-authenticate your account.");const t={sdk:"8.0",entry:e.entry,search:{enabled:!0},messaging:{origin:window.location.origin,channelId:`X-PARAGON-CHANNEL-${Date.now()}`},selection:{mode:this.options.allowMultiSelect?"multiple":"single"},typesAndSources:{mode:"boolean"==typeof this.options.allowFolderSelect?this.options.allowFolderSelect?"folders":"files":"all",filters:this.options.allowedTypes,pivots:e.pivots}},r=new URLSearchParams({filePicker:JSON.stringify(t)}).toString(),n=`${this.getPickerUrl(this.baseUrl)}?${r}`,o=window.open("","Picker","width=800,height=600,left=100,top=150");if(!o)throw new Error("Failed to open picker window.");const i=o.document.createElement("form");i.setAttribute("action",n),i.setAttribute("method","POST");const a=o.document.createElement("input");a.setAttribute("type","hidden"),a.setAttribute("name","access_token"),a.setAttribute("value",this.accessToken),i.appendChild(a),o.document.body.appendChild(i),i.submit(),this.setupMessageListener(o,t.messaging.channelId)}initializePort(e,t){e.addEventListener("message",(async r=>{const{type:n,data:o,id:i}=r.data;if("command"===n){const{command:r}=o;this.handlePickerCommand({command:r,id:i,items:o.items},t,e)}})),e.start(),e.postMessage({type:"activate"})}setupMessageListener(e,t){window.addEventListener("message",(r=>{var n;if(r.source===e&&(null===(n=r.data)||void 0===n?void 0:n.channelId)===t){const{type:t,data:n}=r.data;switch(t){case"initialize":const o=r.ports[0];this.initializePort(o,e);break;case"command":this.handlePickerCommand(n,e);break;default:console.warn("Unknown message type:",t)}}}))}handlePickerCommand(e,t,r){var n,o,i,a,s,c;const{command:u,id:l,items:d}=e;switch(u){case"authenticate":if(!r)break;r.postMessage({type:"acknowledge",id:l}),this.respondToAuthenticateCommand(l,r);break;case"close":null===(o=(n=this.options).onClose)||void 0===o||o.call(n),t.close();break;case"pick":null==r||r.postMessage({type:"result",id:l,data:{result:"success"}}),null===(a=(i=this.options).onFileSelect)||void 0===a||a.call(i,d),null===(c=(s=this.options).onClose)||void 0===c||c.call(s),t.close();break;default:null==r||r.postMessage({type:"error",id:l,data:{message:"Unsupported command",command:u}})}}async respondToAuthenticateCommand(e,t){var r,o;try{const i=this.getIntegrationName(),a=await this.connectSDKInstance.getIntegrationAccount(i,{includeAccountAuth:!0,selectedCredentialId:this.selectedCredentialId}),s=(null===(r=n.AUTH_TOKEN_ALLOWED_INTEGRATIONS[i])||void 0===r?void 0:r.accessTokenPath)||"",c=null===(o=a.accountAuth)||void 0===o?void 0:o[s];if(!c)throw new Error("Failed to refresh access token");this.accessToken=c,this.baseUrl=this.getUrl(a,i),t.postMessage({type:"result",id:e,data:{result:"token",token:c}})}catch(r){t.postMessage({type:"error",id:e,data:{message:r instanceof Error?r.message:"Failed to refresh access token",command:"authenticate"}})}}}t.MicrosoftPicker=a},9008:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoxFilePicker=void 0;const n=r(3821),o=r(4464),i=r(5486),a=r(7473),s={version:"21.0.0",scriptUrl:"https://cdn01.boxcdn.net/platform/elements/21.0.0/en-US/picker.js",cssUrl:"https://cdn01.boxcdn.net/platform/elements/21.0.0/en-US/picker.css",containerClass:"picker",containerStyles:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"100%",height:"80%",zIndex:"2147483647",display:"flex",alignItems:"center",justifyContent:"center"},pickerOptions:{maxSelectable:1,canUpload:!0,canCreateNewFolder:!0,canSetShareAccess:!0,canDownload:!0,canDelete:!1,canRename:!1,canPreview:!0,canComment:!1,canShare:!0,canMove:!1,canCopy:!0}};class c extends a.BaseFilePicker{constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(e,t),this.accessToken="",this.iframe=null,this.config={...s,...r}}isScopedMode(){var e,t;return Boolean(null===(t=null===(e=this.options.integrationOptions)||void 0===e?void 0:e.box)||void 0===t?void 0:t.scopeCSS)}getInstance(){var e,t,r;if(!this.instance){const n=this.isScopedMode()?null===(e=this.iframe)||void 0===e?void 0:e.contentWindow:window;if(!n)throw new Error("Box script is not loaded yet. Please wait for initialization to complete.");if(!this.options.allowFolderSelect&&!(null===(t=n.Box)||void 0===t?void 0:t.FilePicker)||this.options.allowFolderSelect&&!(null===(r=n.Box)||void 0===r?void 0:r.FolderPicker))throw new Error("Box script is not loaded yet. Please wait for initialization to complete.");const o=new n.Box[this.options.allowFolderSelect?"FolderPicker":"FilePicker"]({container:`.${this.config.containerClass}`});if(!o)throw new Error(`Failed to create Box ${this.options.allowFolderSelect?"Folder":"File"}Picker instance`);this.instance=o,this.setupEventListeners()}return this.instance}setupEventListeners(){var e=this;if(!this.instance)return;const t={choose:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];var r,n;null===(n=(r=e.options).onFileSelect)||void 0===n||n.call(r,t),e.cleanup()},cancel:()=>{var e,t;null===(t=(e=this.options).onCancel)||void 0===t||t.call(e),this.cleanup()},close:()=>{var e,t;null===(t=(e=this.options).onClose)||void 0===t||t.call(e),this.cleanup()}};Object.entries(t).forEach((e=>{let[t,r]=e;var n;null===(n=this.instance)||void 0===n||n.addListener(t,r)}))}cleanup(){var e,t;if(this.instance){if(this.instance.removeAllListeners(),this.isScopedMode()&&this.iframe){const t=null===(e=this.iframe.contentDocument)||void 0===e?void 0:e.querySelector(`.${this.config.containerClass}`);t&&t.remove(),this.iframe.style.display="none"}else null===(t=document.querySelector(`.${this.config.containerClass}`))||void 0===t||t.remove();this.instance=void 0}}createPickerContainer(){if(this.isScopedMode()&&this.iframe){if("none"!==this.iframe.style.display)return;Object.entries(this.config.containerStyles).forEach((e=>{let[t,r]=e;var n;(null===(n=this.iframe)||void 0===n?void 0:n.style)[t]=r})),this.iframe.style.border="0",this.iframe.style.display="block";const e=this.iframe.contentDocument;if(e&&!e.querySelector(`.${this.config.containerClass}`)){const t=e.createElement("div");t.className=this.config.containerClass,e.body.appendChild(t)}return}if(document.querySelector(`.${this.config.containerClass}`))return;const e=document.createElement("div");e.className=this.config.containerClass,Object.entries(this.config.containerStyles).forEach((t=>{let[r,n]=t;e.style[r]=n})),document.body.appendChild(e)}injectCSS(e){const t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}injectGlobalBtnContentCSS(){if(document.getElementById("global-btn-content-style"))return;const e=document.createElement("style");e.id="global-btn-content-style",e.innerHTML="\n .btn-content {\n display: flex !important;\n justify-content: center !important;\n }\n ",document.head.appendChild(e)}open(){var e,t,r;if(this.dependencyStatus===n.FilePickerStatus.LOADED)try{this.instance=void 0;const{scopeCSS:n,...o}=(null===(e=this.options.integrationOptions)||void 0===e?void 0:e.box)||{},i=this.getInstance();if(i){const e={...this.config.pickerOptions,container:`.${this.config.containerClass}`,maxSelectable:this.options.allowMultiSelect?void 0:1,extensions:this.options.allowedTypes,canSelectFolder:this.options.allowFolderSelect,...o};if(this.createPickerContainer(),this.initOptions.folderId)return i.show(this.initOptions.folderId,this.accessToken,e),null===(r=(t=this.options).onOpen)||void 0===r||r.call(t),!0}}catch(e){return!1}return!1}async init(e){this.dependencyStatus=n.FilePickerStatus.LOADING;const{selectedCredentialId:t,...r}=e||{};await this.validateInitOptions(r,[["folderId","Folder ID"]]),this.initOptions={...r};const a=await this.connectSDKInstance.getIntegrationAccount("box",{includeAccountAuth:!0,selectedCredentialId:t}),{accessTokenPath:s=""}=n.AUTH_TOKEN_ALLOWED_INTEGRATIONS.box;if(this.accessToken=a.accountAuth[s],this.initialiseDependencyPromise(),(0,i.isBundledBuild)()){if(this.isScopedMode())throw new Error("Bundled Box picker does not support scopeCSS mode.");return(0,o.ensureBundledBoxStyles)(),this.injectGlobalBtnContentCSS(),this.onScriptLoaded(),this.dependenciesPromise}return this.isScopedMode()?this.createScopedIframe():(this.injectCSS(this.config.cssUrl),this.injectGlobalBtnContentCSS(),this.injectScript(this.config.scriptUrl)),this.dependenciesPromise}createScopedIframe(){if(this.iframe)return void this.onScriptLoaded();const e=this.config.containerClass,t=document.createElement("iframe");t.onload=this.onScriptLoaded.bind(this),t.onerror=this.onScriptError.bind(this),t.style.display="none",t.srcdoc=`<!doctype html>\n <html><head>\n <link rel="stylesheet" href="${this.config.cssUrl}">\n <style>\n html, body, .${e} { height: 100%; margin: 0; padding: 0; }\n .${e} { display: flex; align-items: center; justify-content: center; }\n </style>\n </head><body>\n <div class="${e}"></div>\n <script src="${this.config.scriptUrl}"><\/script>\n </body></html>`,this.iframe=t,document.body.appendChild(t)}async launch(){this.dependencyStatus!==n.FilePickerStatus.LOADED&&await this.init(this.initOptions),this.open()}onScriptLoaded(){this.dependencyStatus=n.FilePickerStatus.LOADED,this.instance=void 0,this.dependenciesPromise.resolve(!0)}onScriptError(){this.dependencyStatus=n.FilePickerStatus.FAILED,this.dependenciesPromise.reject(new Error("Failed to load Box script"))}}t.BoxFilePicker=c},9950:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GoogleDriveFilePicker=void 0;const n=r(3821),o=r(9595),i=r(5486),a=r(7473);class s extends a.BaseFilePicker{constructor(e,t){super(e,t),this.accessToken=""}get google(){return window.google}getInstance(){var e;return null!==(e=this.instance)&&void 0!==e?e:null}open(){var e,t;return!(this.dependencyStatus!==n.FilePickerStatus.LOADED||!this.instance)&&(this.instance.setVisible(!0),null===(t=(e=this.options).onOpen)||void 0===t||t.call(e),!0)}async init(e){this.dependencyStatus=n.FilePickerStatus.LOADING;const{selectedCredentialId:t,...r}=e||{};await this.validateInitOptions(r,[["developerKey","developer key"]]),this.initOptions={...r};const a=await this.connectSDKInstance.getIntegrationAccount("googledrive",{includeAccountAuth:!0,selectedCredentialId:t}),{accessTokenPath:s=""}=n.AUTH_TOKEN_ALLOWED_INTEGRATIONS.googledrive;return this.accessToken=a.accountAuth[s],this.initialiseDependencyPromise(),(0,i.isBundledBuild)()?((0,o.installBundledGoogleScriptInterceptors)(),this.onScriptLoaded(),this.dependenciesPromise):(this.injectScript("https://apis.google.com/js/api.js"),this.dependenciesPromise)}onScriptLoaded(){this.dependencyStatus=n.FilePickerStatus.LOADED,window.gapi.load("picker",this.onPickerLoaded.bind(this))}onScriptError(){this.dependencyStatus=n.FilePickerStatus.FAILED,this.dependenciesPromise.reject(new Error("Not able to load dependencies"))}onPickerLoaded(){var e,t,r;const n=new this.google.picker.PickerBuilder;(null===(e=this.initOptions)||void 0===e?void 0:e.appId)&&n.setAppId(this.initOptions.appId),this.options.allowMultiSelect&&n.enableFeature(this.google.picker.Feature.MULTISELECT_ENABLED),this.options.allowedTypes&&this.options.allowedTypes.length>0&&n.setSelectableMimeTypes(this.options.allowedTypes.join(","));const o=this.createDocsView();if(n.addView(o),null===(r=null===(t=this.options.integrationOptions)||void 0===t?void 0:t.googledrive)||void 0===r?void 0:r.enableSharedDrives){const e=this.createDocsView();e.setEnableDrives(!0),n.addView(e)}if(!this.initOptions.developerKey)throw new Error("Please provide a valid developer key");const i=n.setOAuthToken(this.accessToken).setDeveloperKey(this.initOptions.developerKey).setCallback(this.pickerCallback.bind(this));this.initOptions.appId&&i.setAppId(this.initOptions.appId),this.instance=i.build(),this.dependenciesPromise.resolve(!0)}createDocsView(){var e,t,r,n;const o=new this.google.picker.DocsView;return this.options.allowFolderSelect&&(o.setIncludeFolders(!0),o.setSelectFolderEnabled(!0)),(null===(t=null===(e=this.options.integrationOptions)||void 0===e?void 0:e.googledrive)||void 0===t?void 0:t.viewMode)&&o.setMode(this.options.integrationOptions.googledrive.viewMode),(null===(n=null===(r=this.options.integrationOptions)||void 0===r?void 0:r.googledrive)||void 0===n?void 0:n.includeFolders)&&o.setIncludeFolders(!0),o}pickerCallback(e){var t,r,n,o,i,a;const{action:s,...c}=e;switch(s){case this.google.picker.Action.PICKED:null===(r=(t=this.options).onFileSelect)||void 0===r||r.call(t,c),null===(o=(n=this.options).onClose)||void 0===o||o.call(n);break;case this.google.picker.Action.CANCEL:null===(a=(i=this.options).onCancel)||void 0===a||a.call(i)}}}t.GoogleDriveFilePicker=s},1698:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(9008),o=r(9950),i=r(6128),a=r(8737);t.default={BoxFilePicker:n.BoxFilePicker,GoogleDriveFilePicker:o.GoogleDriveFilePicker,OneDriveFilePicker:i.OneDriveFilePicker,SharepointFilePicker:a.SharepointFilePicker}},6128:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OneDriveFilePicker=void 0;const n=r(3821),o=r(9845);class i extends o.MicrosoftPicker{constructor(){super(...arguments),this.integrationName="onedrive",this.personalAccountUrl="https://onedrive.live.com"}async init(e){return super.initPicker(e,this.integrationName)}getPickerUrl(e){return e?e.includes(this.personalAccountUrl)?`${e}/picker`:this.combinePaths(e,"_layouts/15/FilePicker.aspx"):`${this.personalAccountUrl}/picker`}getIntegrationName(){return this.integrationName}getUrl(e,t){return e.accountAuth[n.AUTH_TOKEN_ALLOWED_INTEGRATIONS[t].domain||""]}getPickerOptions(){return{entry:{oneDrive:{files:{fallbackToRoot:!0}}},pivots:{oneDrive:!0,recent:!0,shared:!0}}}}t.OneDriveFilePicker=i},8737:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharepointFilePicker=void 0;const n=r(8321),o=r(9845);class i extends o.MicrosoftPicker{constructor(){super(...arguments),this.integrationName="sharepoint"}async init(e){return super.initPicker(e,this.integrationName)}getIntegrationName(){return this.integrationName}getPickerUrl(e){return this.combinePaths(e,"_layouts/15/FilePicker.aspx")}getUrl(e){var t;return(0,n.sanitizeUrl)(null===(t=e.providerData)||void 0===t?void 0:t.webUrl)}getPickerOptions(){return{entry:{sharePoint:{byPath:{list:`${this.baseUrl}/Shared Documents`,fallbackToRoot:!0}}},pivots:{shared:!0,oneDrive:!1,sharedLibraries:!0,site:!0}}}}t.SharepointFilePicker=i},7473:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseFilePicker=void 0;const n=r(2643),o=r(572);t.BaseFilePicker=class{constructor(e,t){this.options=e,this.connectSDKInstance=t}initialiseDependencyPromise(){this.dependenciesPromise=new o.DeferredPromise}getInstance(){return this.instance}injectScript(e){if(this.checkIfScriptLoaded(e))this.onScriptLoaded();else{const t=document.createElement("script");t.src=e,t.async=!0,t.id=e,t.onload=this.onScriptLoaded.bind(this),t.onerror=this.onScriptError.bind(this),document.body.appendChild(t)}}checkIfScriptLoaded(e){const t=document.getElementsByTagName("script");for(let r=0;r<t.length;r++)if(t[r].getAttribute("src")==e)return!0;return!1}async validateInitOptions(e,t){for(const[r,o]of t)if(!e||(0,n.isStringEmpty)(e[r]))throw new Error(`Please provide a valid ${o}`);return!0}}},4731:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildExternalFilePickerInstance=void 0;const n=r(655).__importDefault(r(1698));class o{constructor(e,t,r){const n=this.createFilePicker(e,t,r);this.open=this.open.bind(n),this.init=this.init.bind(n),this.getInstance=this.getInstance.bind(n)}createFilePicker(e,t,r){const o={box:n.default.BoxFilePicker,googledrive:n.default.GoogleDriveFilePicker,onedrive:n.default.OneDriveFilePicker,sharepoint:n.default.SharepointFilePicker}[e];if(!o)throw new Error(`${e}'s file picker is not supported`);return new o(t,r)}open(){return this.open()}init(e){return this.init(e)}getInstance(){return this.getInstance()}}t.default=o;t.buildExternalFilePickerInstance=e=>function(t,r){if(!e.getUser().authenticated)throw new Error("Authentication is required");if(!t)throw new Error("Missing argument: Integration type is required");return e.validateAction(t),new o(t,r,e)}},7050:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.buildExternalFilePickerInstance=t.ExternalFilePicker=void 0;var o=r(4731);Object.defineProperty(t,"ExternalFilePicker",{enumerable:!0,get:function(){return n(o).default}}),Object.defineProperty(t,"buildExternalFilePickerInstance",{enumerable:!0,get:function(){return o.buildExternalFilePickerInstance}})},4464:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ensureBundledBoxStyles=void 0;t.ensureBundledBoxStyles=()=>{}},9595:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.installBundledGoogleScriptInterceptors=void 0;t.installBundledGoogleScriptInterceptors=()=>{}},2643:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findSelectedAccountType=t.isStringEmpty=t.getActionStateForCredentialDelete=t.stripUndefinedAndNull=t.parseKeyedSource=void 0;const n=r(4059);t.parseKeyedSource=function(e){return e&&(null==e?void 0:e.length)?Object.fromEntries(e.map((e=>[e.key,"VALUE"===e.source.type?e.source.value:void 0]))):{}},t.stripUndefinedAndNull=function e(t){const r={};return Object.keys(t).forEach((n=>{var o;(o=t[n])&&"object"==typeof o&&!Array.isArray(o)?r[n]=e(t[n]):void 0!==t[n]&&null!==t[n]&&(r[n]=t[n])})),r};t.getActionStateForCredentialDelete=(e,t)=>{var r,o;const i=(null!==(r=null==t?void 0:t.allCredentials)&&void 0!==r?r:[]).filter((t=>t.id!==e)),a=(null!==(o=null==t?void 0:t.allConfigurations)&&void 0!==o?o:[]).filter((t=>t.connectCredentialId!==e));if(0===i.length)return{enabled:!1,workflowSettings:{},allCredentials:[],allConfigurations:[]};{const e=i[0];return{...t,credentialStatus:e.status,enabled:e.status===n.CredentialStatus.VALID,credentialId:e.id,providerId:e.providerId,providerData:e.providerData,allCredentials:i,allConfigurations:a}}};t.isStringEmpty=e=>!e||"string"==typeof e&&!e.trim();t.findSelectedAccountType=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(t)return e.find((e=>{let{id:r}=e;return r===t}));if(1===r.length)return e.find((e=>{let{id:t}=e;return r.includes(t)}));if(!t&&!r.length&&Array.isArray(e)&&2===e.length){const[t,r]=e;return"default"===t.id&&"user-configured-oauth"===r.id?t:void 0}}},4429:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.startOAuthFlow=t.MAX_POLL_DURATION=t.CREDENTIAL_POLL_INTERVAL=void 0;const n=r(3931),o=r(7343),i=r(1935),a=r(2643);t.CREDENTIAL_POLL_INTERVAL=3e3,t.MAX_POLL_DURATION=18e4;t.startOAuthFlow=(e,t)=>{let{context:r,integration:s,endUserSuppliedValues:c={},authParams:u,isPreviewMode:l=!1,installOptions:d={}}=e;var h;const p=(0,o.getIntegrationTypeName)(s);if(!p)return;const f=u?(0,a.parseKeyedSource)(u):{};if(!r.user.authenticated)throw new i.UserNotAuthenticatedError;const g=(0,a.stripUndefinedAndNull)({action:p&&(0,o.isCustomIntegrationTypeName)(p)?n.ACTION_CUSTOM:p,endUserSuppliedValues:JSON.stringify(c),parameters:JSON.stringify(f),userToken:r.user.token,integrationId:s.id,redirectUrl:null===(h=r.endUserIntegrationConfig)||void 0===h?void 0:h.overrideRedirectUrl,originForPostMessage:window.location.origin,isPreviewMode:l,installOptions:JSON.stringify(d),oauthMetaKeyId:t}),y=`${r.environments.ZEUS_PUBLIC_URL}/projects/${r.projectId}/sdk/actions/oauth-nonce?action=${p}&integrationId=${s.id}&originForPostMessage=${window.location.origin}${r.user.token?`&userToken=${r.user.token}`:""}`,v=(async(e,t)=>e.user.authenticated?fetch(`${e.environments.ZEUS_PUBLIC_URL}/v2/projects/${e.projectId}/sdk/actions/build-oauth?${t}`,{method:"GET",headers:{"Content-Type":"application/json",...e.user.token?{Authorization:`Bearer ${e.user.token}`}:{}}}):Promise.reject("User is not authenticated"))(r,new URLSearchParams(g).toString()),E=window.open(y,void 0,"width=500,height=600,left=100,top=150"),m=function(e,t){return function r(n){"oauth-nonce-loaded"===n.data.type&&e.then((async e=>{if(!e.ok){const t=await e.json();return Promise.reject(new Error(t.message))}return e.json()})).then((e=>{if(!t)throw new i.OAuthBlockedError;t.location.href=e.redirectUrl,window.removeEventListener("message",r)})).catch((e=>{console.error("Build Oauth URL fetch failure",e.message)}))}}(v,E);return window.addEventListener("message",m),E}},1838:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;const n=r(655);r(4464),r(9595),r(5431),n.__exportStar(r(3056),t);var o=r(3056);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n.__importDefault(o).default}})},3056:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.paragon=t.connectSingleton=void 0;const n=r(655),o=n.__importDefault(r(773)),i=r(7050);n.__exportStar(r(3821),t),t.connectSingleton=new o.default,t.paragon={_loadCustomDropdownOptions:t.connectSingleton._loadCustomDropdownOptions.bind(t.connectSingleton),_oauthCallback:t.connectSingleton._oauthCallback.bind(t.connectSingleton),_oauthErrorCallback:t.connectSingleton._oauthErrorCallback.bind(t.connectSingleton),authenticate:t.connectSingleton.authenticate.bind(t.connectSingleton),closePortal:t.connectSingleton.closePortal.bind(t.connectSingleton),completeInstall:t.connectSingleton.completeInstall.bind(t.connectSingleton),configureGlobal:t.connectSingleton.configureGlobal.bind(t.connectSingleton),getVersion:t.connectSingleton.getVersion.bind(t.connectSingleton),connect:t.connectSingleton.connect.bind(t.connectSingleton),connectAction:t.connectSingleton.connectAction.bind(t.connectSingleton),getCustomWebhookUserManualUrl:t.connectSingleton.getCustomWebhookUserManualUrl.bind(t.connectSingleton),createConfiguration:t.connectSingleton.createConfiguration.bind(t.connectSingleton),destroyConfiguration:t.connectSingleton.destroyConfiguration.bind(t.connectSingleton),disableWorkflow:t.connectSingleton.disableWorkflow.bind(t.connectSingleton),enableWorkflow:t.connectSingleton.enableWorkflow.bind(t.connectSingleton),event:t.connectSingleton.event.bind(t.connectSingleton),getIntegrationAccount:t.connectSingleton.getIntegrationAccount.bind(t.connectSingleton),getIntegrationMetadata:t.connectSingleton.getIntegrationMetadata.bind(t.connectSingleton),getUser:t.connectSingleton.getUser.bind(t.connectSingleton),installIntegration:t.connectSingleton.installIntegration.bind(t.connectSingleton),request:t.connectSingleton.request.bind(t.connectSingleton),setUserMetadata:t.connectSingleton.setUserMetadata.bind(t.connectSingleton),subscribe:t.connectSingleton.subscribe.bind(t.connectSingleton),uninstallIntegration:t.connectSingleton.uninstallIntegration.bind(t.connectSingleton),unsubscribe:t.connectSingleton.unsubscribe.bind(t.connectSingleton),updateConfiguration:t.connectSingleton.updateConfiguration.bind(t.connectSingleton),workflow:t.connectSingleton.workflow.bind(t.connectSingleton),ExternalFilePicker:(0,i.buildExternalFilePickerInstance)(t.connectSingleton),getIntegrationConfig:t.connectSingleton.getIntegrationConfig.bind(t.connectSingleton),updateIntegrationUserSettings:t.connectSingleton.updateIntegrationUserSettings.bind(t.connectSingleton),updateWorkflowUserSettings:t.connectSingleton.updateWorkflowUserSettings.bind(t.connectSingleton),updateWorkflowState:t.connectSingleton.updateWorkflowState.bind(t.connectSingleton),setHeadless:t.connectSingleton.setHeadless.bind(t.connectSingleton),setDataSources:t.connectSingleton.setDataSources.bind(t.connectSingleton),getIntegrationId:t.connectSingleton.getIntegrationId.bind(t.connectSingleton),getAccountTypeOptions:t.connectSingleton.getAccountTypeOptions.bind(t.connectSingleton),getPreOptions:t.connectSingleton.getPreOptions.bind(t.connectSingleton),getPostOptions:t.connectSingleton.getPostOptions.bind(t.connectSingleton),startOAuthFlow:t.connectSingleton.startOAuthFlow.bind(t.connectSingleton),getAssetUrl:t.connectSingleton.getAssetUrl.bind(t.connectSingleton),installFlow:t.connectSingleton.installFlow,getFieldOptions:t.connectSingleton.getFieldOptions.bind(t.connectSingleton),getDataSourceOptions:t.connectSingleton.getDataSourceOptions.bind(t.connectSingleton),getSourcesForInput:t.connectSingleton.getSourcesForInput.bind(t.connectSingleton)},t.default=o.default},9636:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cloneDeep=void 0;const n=r(655).__importDefault(r(738));t.cloneDeep=function(e){return(0,n.default)(e)}},2992:(e,t)=>{"use strict";var r,n;Object.defineProperty(t,"__esModule",{value:!0}),t.AUTH_TOKEN_ALLOWED_INTEGRATIONS=t.overrideActionAlias=t.DataSourceType=t.TokenType=t.VariableInputType=t.SidebarInputType=void 0,function(e){e.Auth="AUTH",e.Enum="ENUM",e.DynamicEnum="DYNAMIC_ENUM",e.Intent="INTENT",e.Text="TEXT",e.TextArea="TEXTAREA",e.ValueText="TEXT_NO_VARS",e.ValueTextArea="TEXTAREA_NO_VARS",e.Code="CODE",e.ActionButton="ACTION_BUTTON",e.Conditional="CONDITIONAL",e.CustomDropdown="CUSTOM_DROPDOWN",e.DynamicConditional="DYNAMIC_CONDITIONAL",e.NestedList="NESTED_LIST",e.File="FILE",e.EditableDynamicEnum="EDITABLE_DYNAMIC_ENUM",e.EditableEnum="EDITABLE_ENUM",e.BooleanInput="BOOLEAN_INPUT",e.UserSuppliedCredential="USER_SUPPLIED_CREDENTIAL",e.NativeDynamicEnumInput="NATIVE_DYNAMIC_INPUT",e.TimeConstraintInput="TIME_CONSTRAINT_INPUT",e.LinesListInput="LinesListInput",e.LinesListDynamicInput="LinesListDynamicInput",e.Number="NUMBER",e.Email="EMAIL",e.URL="URL",e.EnumTextAreaPairInput="EnumTextAreaPairInput",e.FieldMapper="FIELD_MAPPER",e.ComboInput="COMBO_INPUT",e.Password="PASSWORD",e.Switch="SWITCH",e.DynamicComboInput="DYNAMIC_COMBO_INPUT",e.CopyableButtonInput="COPYABLE_BUTTON_INPUT",e.Permission="PERMISSION"}(t.SidebarInputType||(t.SidebarInputType={})),function(e){e.MultiSelect="multi",e.String="string",e.Dropdown="dropdown",e.MultiSelectCheckbox="multiCheckbox",e.Number="number"}(t.VariableInputType||(t.VariableInputType={})),function(e){e.ACCESS_TOKEN="ACCESS_TOKEN",e.REFRESH_TOKEN="REFRESH_TOKEN",e.BOT_TOKEN="BOT_TOKEN",e.KLAVIYO_API_KEY="KLAVIYO_API_KEY",e.MARKETO_CLIENT_ID="MARKETO_CLIENT_ID",e.MARKETO_CLIENT_SECRET="MARKETO_CLIENT_SECRETI",e.MARKETO_ENDPOINT="MARKETO_ENDPOINT",e.MARKETO_IDENTITY="MARKETO_IDENTITY",e.MONDAY_API_TOKEN="MONDAY_API_TOKEN",e.ORACLE_CLOUD_URL="ORACLE_CLOUD_URL",e.ORACLE_PASSWORD="ORACLE_PASSWORD",e.ORACLE_USERNAME="ORACLE_USERNAME",e.SAGE_INTACCT_COMPANY_ID="SAGE_INTACCT_COMPANY_ID",e.SAGE_INTACCT_USER_ID="SAGE_INTACCT_USER_ID",e.SAGE_INTACCT_USER_PASSWORD="SAGE_INTACCT_USER_PASSWORD",e.SAILTHRU_COMPANY_KEY="SAILTHRU_COMPANY_KEY",e.SAILTHRU_COMPANY_SECRET="SAILTHRU_COMPANY_SECRET",e.SERVICENOW_PASSWORD="SERVICENOW_PASSWORD",e.SERVICENOW_SUBDOMAIN="SERVICENOW_SUBDOMAIN",e.SERVICENOW_USERNAME="SERVICENOW_USERNAME",e.TABLEAU_PERSONAL_ACCESS_TOKEN_NAME="TABLEAU_PERSONAL_ACCESS_TOKEN_NAME",e.TABLEAU_PERSONAL_ACCESS_TOKEN_SECRET="TABLEAU_PERSONAL_ACCESS_TOKEN_SECRET",e.TABLEAU_SERVER_NAME="TABLEAU_SERVER_NAME",e.TABLEAU_SITE_ID="TABLEAU_SITE_ID",e.TRELLO_API_KEY="TRELLO_API_KEY",e.TRELLO_API_TOKEN="TRELLO_API_TOKEN",e.WOOCOMMERCE_CONSUMER_KEY="WOOCOMMERCE_CONSUMER_KEY",e.WOOCOMMERCE_CONSUMER_SECRET="WOOCOMMERCE_CONSUMER_SECRET",e.WOOCOMMERCE_STORE_DOMAIN="WOOCOMMERCE_STORE_DOMAIN",e.WORKABLE_API_ACCESS_TOKEN="WORKABLE_API_ACCESS_TOKEN",e.WORKABLE_ACCOUNT_SUBDOMAIN="WORKABLE_ACCOUNT_SUBDOMAIN",e.ZOHO_CRM_ACCOUNTS_SERVER="ZOHO_CRM_ACCOUNTS_SERVER",e.ZOHO_CRM_API_DOMAIN="ZOHO_CRM_API_DOMAIN"}(t.TokenType||(t.TokenType={})),function(e){e.INFO="INFO",e.ERROR="ERROR",e.SUCCESS="SUCCESS"}(r||(r={})),function(e){e.NONE="NONE",e.RE_AUTHENTICATE="RE_AUTHENTICATE",e.ALERT="ALERT",e.DISPATCH="DISPATCH"}(n||(n={})),function(e){e.DYNAMIC="DYNAMIC_DATA_SOURCE",e.STATIC_ENUM="STATIC_ENUM_DATA_SOURCE",e.FIELD_MAPPER="FIELD_MAPPER_DATA_SOURCE",e.COMBO_INPUT="COMBO_INPUT_DATA_SOURCE",e.DYNAMIC_COMBO_INPUT="DYNAMIC_COMBO_INPUT_DATA_SOURCE"}(t.DataSourceType||(t.DataSourceType={})),t.overrideActionAlias={"monday.com":"monday","wordpress.com":"wordpress"},t.AUTH_TOKEN_ALLOWED_INTEGRATIONS={box:{accessTokenPath:"OAUTH_ACCESS_TOKEN"},googledrive:{accessTokenPath:"OAUTH_ACCESS_TOKEN"},onedrive:{accessTokenPath:"OAUTH_ACCESS_TOKEN",domain:"DOMAIN"},sharepoint:{accessTokenPath:"OAUTH_ACCESS_TOKEN"}}},9034:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CONNECT_PLAN_FEATURE_MAP=void 0;const n=r(471);t.CONNECT_PLAN_FEATURE_MAP={[n.BillingPlan.ConnectBasic]:[],[n.BillingPlan.ConnectPro]:[n.ConnectAddOn.CustomIntegrationBuilder,n.ConnectAddOn.HeadlessConnectPortal,n.ConnectAddOn.Monitoring,n.ConnectAddOn.UserMetadata,n.ConnectAddOn.WhiteLabeling],[n.BillingPlan.ConnectEnterprise]:[n.ConnectAddOn.CustomIntegrationBuilder,n.ConnectAddOn.DynamicFieldMapper,n.ConnectAddOn.HeadlessConnectPortal,n.ConnectAddOn.TaskHistoryAPI,n.ConnectAddOn.Monitoring,n.ConnectAddOn.RoleBasedAccessControl,n.ConnectAddOn.UserMetadata,n.ConnectAddOn.WhiteLabeling,n.ConnectAddOn.WorkflowPermission]}},1935:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SDK_VERSION_HEADER=t.SELECTED_CREDENTIAL_CONFIG_ID_HEADER=t.SELECTED_CREDENTIAL_ID_HEADER=t.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS=t.CredentialStatus=void 0;const n=r(655),o=r(2992);var i=r(4059);Object.defineProperty(t,"CredentialStatus",{enumerable:!0,get:function(){return i.CredentialStatus}}),n.__exportStar(r(2460),t);o.SidebarInputType.ValueText,o.SidebarInputType.DynamicEnum,o.SidebarInputType.Enum,o.SidebarInputType.Number,o.SidebarInputType.Email,o.SidebarInputType.URL,o.SidebarInputType.FieldMapper,o.SidebarInputType.BooleanInput,o.SidebarInputType.ComboInput,o.SidebarInputType.Password,o.SidebarInputType.Switch,o.SidebarInputType.ValueTextArea,o.SidebarInputType.CustomDropdown,o.SidebarInputType.DynamicComboInput,o.SidebarInputType.FieldMapper,o.SidebarInputType.CopyableButtonInput,o.SidebarInputType.Permission,o.SidebarInputType.File;t.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS="auto",t.SELECTED_CREDENTIAL_ID_HEADER="X-Paragon-Credential",t.SELECTED_CREDENTIAL_CONFIG_ID_HEADER="X-Paragon-Configuration-Id",t.SDK_VERSION_HEADER="X-Paragon-SDK-Version"},9977:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},914:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PLATFORM_ENV=t.NODE_ENV=void 0,function(e){e.PRODUCTION="production",e.DEVELOPMENT="development",e.TEST="test"}(t.NODE_ENV||(t.NODE_ENV={})),function(e){e.PRODUCTION="production",e.PRODUCTION_MIRROR_1="p-m1",e.STAGING="staging",e.STAGING_MIRROR_1="s-m1",e.DEVELOPMENT="dev",e.TEST="test",e.SANDBOX="sandbox",e.RELEASE="release",e.ENTERPRISE="enterprise"}(t.PLATFORM_ENV||(t.PLATFORM_ENV={}))},2460:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getConnectSDKError=t.OAuthTimeoutError=t.OAuthBlockedError=t.HeadlessModeNotEnabledError=t.IntegrationNotInstalledError=t.IntegrationNotFoundError=t.NoActiveInstallFlowError=t.UserNotAuthenticatedError=t.BaseSDKError=void 0;class r extends Error{constructor(e){super(e.message),this.name=e.name,this.meta="meta"in e?e.meta:null}}t.BaseSDKError=r;t.UserNotAuthenticatedError=class extends r{constructor(){super({name:"UserNotAuthenticatedError",message:"User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK."})}};t.NoActiveInstallFlowError=class extends r{constructor(){super({name:"NoActiveInstallFlowError",message:"No active install flow, make sure you call installFlow.start(<integrationName>, ...args) before calling any other method"})}};t.IntegrationNotFoundError=class extends r{constructor(e){super({name:"IntegrationNotFoundError",message:`Integration with name ${e} not found`,meta:{integrationName:e}})}};t.IntegrationNotInstalledError=class extends r{constructor(e){super({name:"IntegrationNotInstalledError",message:`Integration "${e}" is not installed.`,meta:{integrationName:e}}),this.integrationName=e}};t.HeadlessModeNotEnabledError=class extends r{constructor(){super({name:"HeadlessModeNotEnabledError",message:"Headless mode is not enabled. Make sure you call `paragon.setHeadless(true)` as early as possible in your code."})}};t.OAuthBlockedError=class extends r{constructor(){super({name:"OAuthBlockedError",message:"Popup was blocked by the browser."})}};t.OAuthTimeoutError=class extends r{constructor(){super({name:"OAuthTimeoutError",message:"OAuth timeout"})}},t.getConnectSDKError=function(e){return e instanceof r?{name:e.name,message:e.message,meta:e.meta}:{name:"UnknownError",message:e instanceof Error?e.message:"An unknown error occurred",originalError:e}}},8065:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3821:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(655);n.__exportStar(r(2992),t),n.__exportStar(r(9034),t),n.__exportStar(r(1935),t),n.__exportStar(r(9977),t),n.__exportStar(r(914),t),n.__exportStar(r(8065),t),n.__exportStar(r(9835),t),n.__exportStar(r(7750),t),n.__exportStar(r(471),t)},9835:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.DataType=void 0,function(e){e.STRING="STRING",e.NUMBER="NUMBER",e.DATE="DATE",e.BOOLEAN="BOOLEAN",e.EMAIL="EMAIL",e.OBJECT="OBJECT",e.ARRAY="ARRAY",e.ANY="ANY",e.FILE="FILE",e.NON_DECIMAL="NON_DECIMAL"}(t.DataType||(t.DataType={})),function(e){e.None="$none",e.StringContains="$stringContains",e.StringDoesNotContain="$stringDoesNotContain",e.StringExactlyMatches="$stringExactlyMatches",e.StringDoesNotExactlyMatch="$stringDoesNotExactlyMatch",e.StringIsIn="$stringIsIn",e.StringIsNotIn="$stringIsNotIn",e.StringStartsWith="$stringStartsWith",e.StringDoesNotStartWith="$stringDoesNotStartWith",e.StringEndsWith="$stringEndsWith",e.StringDoesNotEndWith="$stringDoesNotEndWith",e.NumberGreaterThan="$numberGreaterThan",e.NumberLessThan="$numberLessThan",e.NumberEquals="$numberEquals",e.NumberDoesNotEqual="$numberDoesNotEqual",e.NumberLessThanOrEqualTo="$numberLessThanOrEqualTo",e.NumberGreaterThanOrEqualTo="$numberGreaterThanOrEqualTo",e.DateTimeAfter="$dateTimeAfter",e.DateTimeBefore="$dateTimeBefore",e.DateTimeEquals="$dateTimeEquals",e.BooleanTrue="$booleanTrue",e.BooleanFalse="$booleanFalse",e.IsNotNull="$exists",e.IsNull="$doesNotExist",e.Exists="$isNotUndefinedOrNull",e.DoesNotExist="$isUndefinedOrNull",e.ArrayIsIn="$arrayIsIn",e.ArrayIsNotIn="$arrayIsNotIn",e.ArrayIsEmpty="$arrayIsEmpty",e.ArrayIsNotEmpty="$arrayIsNotEmpty",e.StringGreaterThan="$stringGreaterThan",e.StringLessThan="$stringLessThan"}(r||(r={}))},7750:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FilePickerStatus=t.DocumentLoadingState=t.SDK_EVENT=t.ModalView=t.DynamicFieldMappingLoaderType=void 0,function(e){e.OBJECT_TYPES="objectTypes",e.INTEGRATION_FIELDS="integrationFields"}(t.DynamicFieldMappingLoaderType||(t.DynamicFieldMappingLoaderType={})),function(e){e.OVERVIEW="overview",e.CONFIGURATION="configuration"}(t.ModalView||(t.ModalView={})),function(e){e.ON_INTEGRATION_INSTALL="onIntegrationInstall",e.ON_INTEGRATION_UNINSTALL="onIntegrationUninstall",e.ON_WORKFLOW_CHANGE="onWorkflowChange",e.ON_PORTAL_OPEN="onPortalOpen",e.ON_PORTAL_CLOSE="onPortalClose"}(t.SDK_EVENT||(t.SDK_EVENT={})),function(e){e.LOADING="loading",e.INTERACTIVE="interactive",e.COMPLETE="complete"}(t.DocumentLoadingState||(t.DocumentLoadingState={})),function(e){e.LOADING="loading",e.FAILED="failed",e.LOADED="loaded"}(t.FilePickerStatus||(t.FilePickerStatus={}))},471:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectAddOn=t.BillingPlan=void 0,function(e){e.ClassicFree="free",e.ClassicStarter="starter",e.ClassicBusiness="business",e.ClassicPremium="premium",e.ClassicEnterprise="enterprise",e.ConnectTrial="connect_trial",e.ConnectBasic="basic",e.ConnectPro="pro",e.ConnectEnterprise="connect_enterprise"}(t.BillingPlan||(t.BillingPlan={})),function(e){e.CustomIntegrationBuilder="byo",e.DynamicFieldMapper="dfm",e.HeadlessConnectPortal="headless-cp",e.TaskHistoryAPI="th-api",e.Monitoring="monitoring",e.RoleBasedAccessControl="rbac",e.UserMetadata="user-metadata",e.WhiteLabeling="whitelabel",e.WorkflowPermission="workflow-permissions"}(t.ConnectAddOn||(t.ConnectAddOn={}))},3158:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getHeadersForUserMeta=t.sanitizeExternalConfigId=t.getAssetUrl=void 0;const n=r(3931),o=r(3821);t.getAssetUrl=e=>{let{CDN_PUBLIC_URL:t,DASHBOARD_PUBLIC_URL:r,VERSION:n,PLATFORM_ENV:i,NODE_ENV:a}=e;return t&&a===o.NODE_ENV.PRODUCTION&&i!==o.PLATFORM_ENV.ENTERPRISE?`${t}/${n}/dashboard/public`:r},t.sanitizeExternalConfigId=function(e){if(e.startsWith("ext:")){return(e.split("ext:").pop()||"").trim()}return e.trim()};t.getHeadersForUserMeta=e=>({...e?{[n.PERSONA_META_HEADER]:JSON.stringify(e)}:{}})},4846:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hash=void 0;const n=r(3715);t.hash=function(e){return null==e?e:(0,n.sha256)().update(e).digest("hex").substr(0,10)}},5349:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dedent=void 0,t.dedent=function(e){const t=(e=e.replace(/^\n+|\n+$/g,"")).split("\n"),r=t.filter((e=>e.trim().length>0)).map((e=>e.match(/^(\s*)/)[1].length)),n=r.length>0?Math.min(...r):0;return t.map((e=>e.slice(n))).join("\n")}},572:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tryUntil=t.isUUID=t.uuidPattern=t.areObjectsEqual=t.normalizeForMetaCompare=t.sleep=t.generateMatrix=t.DeferredPromise=void 0;function r(e){return new Promise((t=>setTimeout(t,e)))}function n(e){return Object.keys(e).sort().reduce(((t,r)=>{const o=e[r];return t[r]=null===o||"object"!=typeof o?o:n(o),t}),{})}t.DeferredPromise=class{get state(){return this._state}constructor(){this._state="pending",this._promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}resolve(e){this._resolve(e),this._state="fulfilled"}reject(e){this._reject(e),this._state="rejected"}finally(e){return null==e||e(),this._promise}},Symbol.toStringTag,t.generateMatrix=function(e,t){const r=Object.keys(e);if(r.reduce(((t,r)=>t+e[r].length),0)&&r.length)for(const t of r)e[t].length||e[t].push(void 0);const n=Object.entries(e).reduce(((e,t)=>{let[,r]=t;return e.length?e.reduce(((e,t)=>(r.forEach((r=>{const n=t.slice();n.push(r),e.push(n)}),[]),e)),[]):r.map((e=>[e]))}),[]).reduce(((e,t)=>{const n=t.reduce(((e,t,n)=>({...e,[r[n]]:t})),{});return[...e,n]}),[]);return t?n.slice(-1*t):n},t.sleep=r,t.normalizeForMetaCompare=n,t.areObjectsEqual=function(e,t){return JSON.stringify(n(e))===JSON.stringify(n(t))},t.uuidPattern=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i,t.isUUID=function(e){return"string"==typeof e&&t.uuidPattern.test(e)},t.tryUntil=async function(e,t,n){let o=0,i=!0;for(;i;){o+=1;let a=null,s=null;try{a=await e()}catch(e){s=e}if(i=await t(a,s,o),!i){if(s)throw s;return a}{const e="number"==typeof n?n:n(o);await r(e)}}throw new Error("Method unable to run: invalid retries.")}},8321:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorMessageParser=t.isIntegrationError=t.ProxyRequestError=t.getErrorMessage=t.getServiceUrl=t.sanitizeUrl=t.isValidUrl=void 0;function r(e){return e?e.match(/^[a-zA-Z]+:\/\//)?e:`https://${e}`:e}function n(e){return Array.isArray(e)?e.flatMap((e=>[e,n(e.children||[])].flatMap((e=>"string"==typeof e?e:n(e))))).filter((e=>e)).join(", "):Object.values(e.constraints||{}).join(", ")}t.isValidUrl=e=>{const t=r(e);try{return new globalThis.URL(t),!0}catch(e){return!1}},t.sanitizeUrl=r,t.getServiceUrl=function(e,t){return`https://${e}${`.${t}`}`},t.getErrorMessage=async function(e,r){var o,i;const a=null===(o=e.headers)||void 0===o?void 0:o.get("content-type"),s=a&&a.includes("application/json")?await e.json():null;let c;return c=s&&(0,t.isIntegrationError)(s.meta)?JSON.stringify(s.meta):s&&"string"==typeof s.message?s.message:s&&400===e.status&&Array.isArray(s.message)?n(s.message):s?JSON.stringify(s):await(null===(i=e.text)||void 0===i?void 0:i.call(e)),r?{message:c,response:s||e}:c};class o extends Error{constructor(e,t){super(e),this.name="Error",this.response=t,Object.setPrototypeOf(this,o.prototype)}}t.ProxyRequestError=o;t.isIntegrationError=e=>!("object"!=typeof e||!e)&&e.isIntegrationError,t.errorMessageParser=function(e){e="string"==typeof e?e:e.message;try{const r=JSON.parse(e);return!!(0,t.isIntegrationError)(r)}catch(e){return!1}}},3035:(e,t,r)=>{"use strict";var n,o,i,a,s=r(4155);Object.defineProperty(t,"__esModule",{value:!0}),t.CacheThrottle=t.CacheMode=void 0;const c=r(655),u=r(572);var l,d,h;!function(e){e.Debounce="debounce",e.Throttle="throttle"}(l=t.CacheMode||(t.CacheMode={})),function(e){e.Closed="closed",e.Idle="idle",e.Processing="processing"}(d||(d={})),function(e){e[e.Get=0]="Get",e[e.Set=1]="Set",e[e.GetOrSet=2]="GetOrSet",e[e.Del=3]="Del",e[e.Do=4]="Do"}(h||(h={}));t.CacheThrottle=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n.set(this,d.Idle),o.set(this,{}),i.set(this,void 0),a.set(this,[]),c.__classPrivateFieldSet(this,i,{mode:l.Debounce,ttl:0,...e},"f")}async get(e,t){const r=this.serializeKey(e),n=async()=>{const t=c.__classPrivateFieldGet(this,o,"f")[r],{mode:n,ttl:a,value:s}=null!=t?t:{};return!t||!a||n&&n!==l.Debounce||this.refreshTimeout(e,r,a),c.__classPrivateFieldGet(this,i,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(r,s),s};return t?n():this.enqueue(r,h.Get,n)}async set(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:c.__classPrivateFieldGet(this,i,"f").ttl,n=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;const s=this.serializeKey(e),u=async()=>{const a=c.__classPrivateFieldGet(this,o,"f")[s],u=!!a;return c.__classPrivateFieldGet(this,o,"f")[s]={...a,mode:n,ttl:r,value:t},u&&n===l.Throttle||this.refreshTimeout(e,s,r),c.__classPrivateFieldGet(this,i,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(s,t),t};return a?u():this.enqueue(s,h.Set,u)}async getOrSet(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:c.__classPrivateFieldGet(this,i,"f").ttl,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:c.__classPrivateFieldGet(this,i,"f").mode,a=arguments.length>4?arguments[4]:void 0;const s=this.serializeKey(e),u=async()=>{if(c.__classPrivateFieldGet(this,o,"f")[s])return c.__classPrivateFieldGet(this,o,"f")[s].value;const a=await t();return await this.set(e,a,r,n,!0),c.__classPrivateFieldGet(this,i,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(s,a),a};return a?u():this.enqueue(s,h.GetOrSet,u)}async del(e){let t=arguments.length>2?arguments[2]:void 0;const r=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?e:this.serializeKey(e),n=async()=>{const e=c.__classPrivateFieldGet(this,o,"f")[r];let t;return(null==e?void 0:e.timeout)&&clearTimeout(e.timeout),e&&(t=e.value,delete c.__classPrivateFieldGet(this,o,"f")[r],await(async()=>{var e,r;return null===(r=(e=c.__classPrivateFieldGet(this,i,"f")).onDeregister)||void 0===r?void 0:r.call(e,t)})().catch((e=>{}))),t};return t?n():this.enqueue(r,h.Del,n)}keys(){return Object.keys(c.__classPrivateFieldGet(this,o,"f"))}async do(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:c.__classPrivateFieldGet(this,i,"f").ttl,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:c.__classPrivateFieldGet(this,i,"f").mode;const a=this.serializeKey(e);return this.enqueue(a,h.Do,(async()=>{if(c.__classPrivateFieldGet(this,o,"f")[a])return c.__classPrivateFieldGet(this,o,"f")[a].value;const i=await t();return await this.set(e,i,r,n,!0)}))}async close(){c.__classPrivateFieldSet(this,n,d.Closed,"f"),await Promise.all(Object.keys(c.__classPrivateFieldGet(this,o,"f")).map((e=>this.del(e,!0,!0))))}refreshTimeout(e,t,r){if(c.__classPrivateFieldGet(this,n,"f")===d.Closed)return;const i=c.__classPrivateFieldGet(this,o,"f")[t];return r&&void 0!==(null==i?void 0:i.timeout)&&clearTimeout(i.timeout),r?(i.timeout=setTimeout((()=>this.del(e)),r),i.timeout):void 0}clearPendingDeletesOnKey(e,t){c.__classPrivateFieldSet(this,a,c.__classPrivateFieldGet(this,a,"f").filter((r=>{let[n,o,i,a]=r;return e!==n||o!==h.Del||(a.resolve(t),!1)})),"f")}serializeKey(e){var t,r,n;return null!==(n=null===(r=(t=c.__classPrivateFieldGet(this,i,"f")).serializeKey)||void 0===r?void 0:r.call(t,e))&&void 0!==n?n:e}async enqueue(e,t,r){const o=new u.DeferredPromise;return c.__classPrivateFieldGet(this,a,"f").push([e,t,r,o]),c.__classPrivateFieldGet(this,n,"f")===d.Idle&&this.flush(),o}flush(){c.__classPrivateFieldSet(this,n,d.Processing,"f"),s.nextTick((async()=>{for(;c.__classPrivateFieldGet(this,a,"f").length&&c.__classPrivateFieldGet(this,n,"f")!==d.Closed;){const e=c.__classPrivateFieldGet(this,a,"f").shift();if(e){const[,,t,r]=e;try{const e=await t();r.resolve(e)}catch(e){r.reject(e)}}}c.__classPrivateFieldSet(this,n,d.Idle,"f")}))}},n=new WeakMap,o=new WeakMap,i=new WeakMap,a=new WeakMap},9742:(e,t)=>{"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,i=c(e),a=i[0],s=i[1],u=new o(function(e,t,r){return 3*(t+r)/4-r}(0,a,s)),l=0,d=s>0?a-4:a;for(r=0;r<d;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],u[l++]=t>>16&255,u[l++]=t>>8&255,u[l++]=255&t;2===s&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[l++]=255&t);1===s&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t);return u},t.fromByteArray=function(e){for(var t,n=e.length,o=n%3,i=[],a=16383,s=0,c=n-o;s<c;s+=a)i.push(u(e,s,s+a>c?c:s+a));1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=i.length;a<s;++a)r[a]=i[a],n[i.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,n){for(var o,i,a=[],s=t;s<n;s+=3)o=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),a.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},8764:(e,t,r)=>{"use strict";var n=r(9742),o=r(645),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.lW=c,t.h2=50;var a=2147483647;function s(e){if(e>a)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return d(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|g(e,t),n=s(r),o=n.write(e,t);o!==r&&(n=n.slice(0,o));return n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(B(e,Uint8Array)){var t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return h(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(B(e,ArrayBuffer)||e&&B(e.buffer,ArrayBuffer))return p(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(B(e,SharedArrayBuffer)||e&&B(e.buffer,SharedArrayBuffer)))return p(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return c.from(n,t,r);var o=function(e){if(c.isBuffer(e)){var t=0|f(e.length),r=s(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||K(e.length)?s(0):h(e);if("Buffer"===e.type&&Array.isArray(e.data))return h(e.data)}(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function d(e){return l(e),s(e<0?0:0|f(e))}function h(e){for(var t=e.length<0?0:0|f(e.length),r=s(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}function p(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,c.prototype),n}function f(e){if(e>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|e}function g(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||B(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return H(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return x(e).length;default:if(o)return n?-1:H(e).length;t=(""+t).toLowerCase(),o=!0}}function y(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return N(this,t,r);case"utf8":case"utf-8":return _(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return R(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function v(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function E(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),K(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,o){var i,a=1,s=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,c/=2,r/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(o){var l=-1;for(i=r;i<s;i++)if(u(e,i)===u(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*a}else-1!==l&&(i-=i-l),l=-1}else for(r+c>s&&(r=s-c),i=r;i>=0;i--){for(var d=!0,h=0;h<c;h++)if(u(e,i+h)!==u(t,h)){d=!1;break}if(d)return i}return-1}function C(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=t.length;n>i/2&&(n=i/2);for(var a=0;a<n;++a){var s=parseInt(t.substr(2*a,2),16);if(K(s))return a;e[r+a]=s}return a}function S(e,t,r,n){return q(H(t,e.length-r),e,r,n)}function I(e,t,r,n){return q(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function w(e,t,r,n){return q(x(t),e,r,n)}function T(e,t,r,n){return q(function(e,t){for(var r,n,o,i=[],a=0;a<e.length&&!((t-=2)<0);++a)n=(r=e.charCodeAt(a))>>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function A(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function _(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o<r;){var i,a,s,c,u=e[o],l=null,d=u>239?4:u>223?3:u>191?2:1;if(o+d<=r)switch(d){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[o+1],a=e[o+2],128==(192&i)&&128==(192&a)&&(c=(15&u)<<12|(63&i)<<6|63&a)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[o+1],a=e[o+2],s=e[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(c=(15&u)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&c<1114112&&(l=c)}null===l?(l=65533,d=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),o+=d}return function(e){var t=e.length;if(t<=b)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=b));return r}(n)}c.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),c.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),c.poolSize=8192,c.from=function(e,t,r){return u(e,t,r)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array),c.alloc=function(e,t,r){return function(e,t,r){return l(e),e<=0?s(e):void 0!==t?"string"==typeof r?s(e).fill(t,r):s(e).fill(t):s(e)}(e,t,r)},c.allocUnsafe=function(e){return d(e)},c.allocUnsafeSlow=function(e){return d(e)},c.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==c.prototype},c.compare=function(e,t){if(B(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),B(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=Math.min(r,n);o<i;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=c.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var i=e[r];if(B(i,Uint8Array))o+i.length>n.length?c.from(i).copy(n,o):Uint8Array.prototype.set.call(n,i,o);else{if(!c.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o)}o+=i.length}return n},c.byteLength=g,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)v(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)v(this,t,t+3),v(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)v(this,t,t+7),v(this,t+1,t+6),v(this,t+2,t+5),v(this,t+3,t+4);return this},c.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?_(this,0,e):y.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",r=t.h2;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},i&&(c.prototype[i]=c.prototype.inspect),c.prototype.compare=function(e,t,r,n,o){if(B(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),s=Math.min(i,a),u=this.slice(n,o),l=e.slice(t,r),d=0;d<s;++d)if(u[d]!==l[d]){i=u[d],a=l[d];break}return i<a?-1:a<i?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return E(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return E(this,e,t,r,!1)},c.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return C(this,e,t,r);case"utf8":case"utf-8":return S(this,e,t,r);case"ascii":case"latin1":case"binary":return I(this,e,t,r);case"base64":return w(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var b=4096;function O(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(127&e[o]);return n}function R(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(e[o]);return n}function N(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=t;i<r;++i)o+=j[e[i]];return o}function P(e,t,r){for(var n=e.slice(t,r),o="",i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function k(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function U(e,t,r,n,o,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function D(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(e,t,r,n,i){return t=+t,r>>>=0,i||D(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function M(e,t,r,n,i){return t=+t,r>>>=0,i||D(e,0,r,8),o.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return Object.setPrototypeOf(n,c.prototype),n},c.prototype.readUintLE=c.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||k(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},c.prototype.readUintBE=c.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||k(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||k(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||k(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||k(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||k(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||k(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||k(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||k(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return e>>>=0,t||k(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||k(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){e>>>=0,t||k(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||k(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||k(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return e>>>=0,t||k(e,4,this.length),o.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||k(e,4,this.length),o.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||k(e,8,this.length),o.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||k(e,8,this.length),o.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||U(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=e/o&255;return t+r},c.prototype.writeUintBE=c.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||U(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,e,t,r,o-1,-o)}var i=0,a=1,s=0;for(this[t]=255&e;++i<r&&(a*=256);)e<0&&0===s&&0!==this[t+i-1]&&(s=1),this[t+i]=(e/a>>0)-s&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,e,t,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[t+i]=255&e;--i>=0&&(a*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/a>>0)-s&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return M(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return M(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),o},c.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var o=e.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(e=o)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var a=c.isBuffer(e)?e:c.from(e,n),s=a.length;if(0===s)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=a[i%s]}return this};var F=/[^+/0-9A-Za-z-_]/g;function H(e,t){var r;t=t||1/0;for(var n=e.length,o=null,i=[],a=0;a<n;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function x(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(F,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function q(e,t,r,n){for(var o=0;o<n&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function B(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function K(e){return e!=e}var j=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var n=16*r,o=0;o<16;++o)t[n+o]=e[r]+e[o];return t}()},738:(e,t,r)=>{"use strict";const n=r(3341),o=r(6401),i=r(5299);function a(e,t){switch(o(e)){case"object":return function(e,t){if("function"==typeof t)return t(e);if(t||i(e)){const r=new e.constructor;for(let n in e)r[n]=a(e[n],t);return r}return e}(e,t);case"array":return function(e,t){const r=new e.constructor(e.length);for(let n=0;n<e.length;n++)r[n]=a(e[n],t);return r}(e,t);default:return n(e)}}e.exports=a},3715:(e,t,r)=>{var n=t;n.utils=r(6436),n.common=r(5772),n.sha=r(9041),n.ripemd=r(2949),n.hmac=r(2344),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},5772:(e,t,r)=>{"use strict";var n=r(6436),o=r(9746);function i(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=i,i.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var o=0;o<e.length;o+=this._delta32)this._update(e,o,o+this._delta32)}return this},i.prototype.digest=function(e){return this.update(this._pad()),o(null===this.pending),this._digest(e)},i.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,r=t-(e+this.padLength)%t,n=new Array(r+this.padLength);n[0]=128;for(var o=1;o<r;o++)n[o]=0;if(e<<=3,"big"===this.endian){for(var i=8;i<this.padLength;i++)n[o++]=0;n[o++]=0,n[o++]=0,n[o++]=0,n[o++]=0,n[o++]=e>>>24&255,n[o++]=e>>>16&255,n[o++]=e>>>8&255,n[o++]=255&e}else for(n[o++]=255&e,n[o++]=e>>>8&255,n[o++]=e>>>16&255,n[o++]=e>>>24&255,n[o++]=0,n[o++]=0,n[o++]=0,n[o++]=0,i=8;i<this.padLength;i++)n[o++]=0;return n}},2344:(e,t,r)=>{"use strict";var n=r(6436),o=r(9746);function i(e,t,r){if(!(this instanceof i))return new i(e,t,r);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(n.toArray(t,r))}e.exports=i,i.prototype._init=function(e){e.length>this.blockSize&&(e=(new this.Hash).update(e).digest()),o(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=(new this.Hash).update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=(new this.Hash).update(e)},i.prototype.update=function(e,t){return this.inner.update(e,t),this},i.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}},2949:(e,t,r)=>{"use strict";var n=r(6436),o=r(5772),i=n.rotl32,a=n.sum32,s=n.sum32_3,c=n.sum32_4,u=o.BlockHash;function l(){if(!(this instanceof l))return new l;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function d(e,t,r,n){return e<=15?t^r^n:e<=31?t&r|~t&n:e<=47?(t|~r)^n:e<=63?t&n|r&~n:t^(r|~n)}function h(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function p(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}n.inherits(l,u),t.ripemd160=l,l.blockSize=512,l.outSize=160,l.hmacStrength=192,l.padLength=64,l.prototype._update=function(e,t){for(var r=this.h[0],n=this.h[1],o=this.h[2],u=this.h[3],l=this.h[4],E=r,m=n,C=o,S=u,I=l,w=0;w<80;w++){var T=a(i(c(r,d(w,n,o,u),e[f[w]+t],h(w)),y[w]),l);r=l,l=u,u=i(o,10),o=n,n=T,T=a(i(c(E,d(79-w,m,C,S),e[g[w]+t],p(w)),v[w]),I),E=I,I=S,S=i(C,10),C=m,m=T}T=s(this.h[1],o,S),this.h[1]=s(this.h[2],u,I),this.h[2]=s(this.h[3],l,E),this.h[3]=s(this.h[4],r,m),this.h[4]=s(this.h[0],n,C),this.h[0]=T},l.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"little"):n.split32(this.h,"little")};var f=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],g=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],y=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],v=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},9041:(e,t,r)=>{"use strict";t.sha1=r(4761),t.sha224=r(799),t.sha256=r(9344),t.sha384=r(772),t.sha512=r(5900)},4761:(e,t,r)=>{"use strict";var n=r(6436),o=r(5772),i=r(7038),a=n.rotl32,s=n.sum32,c=n.sum32_5,u=i.ft_1,l=o.BlockHash,d=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;l.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(h,l),e.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n<r.length;n++)r[n]=a(r[n-3]^r[n-8]^r[n-14]^r[n-16],1);var o=this.h[0],i=this.h[1],l=this.h[2],h=this.h[3],p=this.h[4];for(n=0;n<r.length;n++){var f=~~(n/20),g=c(a(o,5),u(f,i,l,h),p,r[n],d[f]);p=h,h=l,l=a(i,30),i=o,o=g}this.h[0]=s(this.h[0],o),this.h[1]=s(this.h[1],i),this.h[2]=s(this.h[2],l),this.h[3]=s(this.h[3],h),this.h[4]=s(this.h[4],p)},h.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},799:(e,t,r)=>{"use strict";var n=r(6436),o=r(9344);function i(){if(!(this instanceof i))return new i;o.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}n.inherits(i,o),e.exports=i,i.blockSize=512,i.outSize=224,i.hmacStrength=192,i.padLength=64,i.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h.slice(0,7),"big"):n.split32(this.h.slice(0,7),"big")}},9344:(e,t,r)=>{"use strict";var n=r(6436),o=r(5772),i=r(7038),a=r(9746),s=n.sum32,c=n.sum32_4,u=n.sum32_5,l=i.ch32,d=i.maj32,h=i.s0_256,p=i.s1_256,f=i.g0_256,g=i.g1_256,y=o.BlockHash,v=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function E(){if(!(this instanceof E))return new E;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=v,this.W=new Array(64)}n.inherits(E,y),e.exports=E,E.blockSize=512,E.outSize=256,E.hmacStrength=192,E.padLength=64,E.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n<r.length;n++)r[n]=c(g(r[n-2]),r[n-7],f(r[n-15]),r[n-16]);var o=this.h[0],i=this.h[1],y=this.h[2],v=this.h[3],E=this.h[4],m=this.h[5],C=this.h[6],S=this.h[7];for(a(this.k.length===r.length),n=0;n<r.length;n++){var I=u(S,p(E),l(E,m,C),this.k[n],r[n]),w=s(h(o),d(o,i,y));S=C,C=m,m=E,E=s(v,I),v=y,y=i,i=o,o=s(I,w)}this.h[0]=s(this.h[0],o),this.h[1]=s(this.h[1],i),this.h[2]=s(this.h[2],y),this.h[3]=s(this.h[3],v),this.h[4]=s(this.h[4],E),this.h[5]=s(this.h[5],m),this.h[6]=s(this.h[6],C),this.h[7]=s(this.h[7],S)},E.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},772:(e,t,r)=>{"use strict";var n=r(6436),o=r(5900);function i(){if(!(this instanceof i))return new i;o.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}n.inherits(i,o),e.exports=i,i.blockSize=1024,i.outSize=384,i.hmacStrength=192,i.padLength=128,i.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h.slice(0,12),"big"):n.split32(this.h.slice(0,12),"big")}},5900:(e,t,r)=>{"use strict";var n=r(6436),o=r(5772),i=r(9746),a=n.rotr64_hi,s=n.rotr64_lo,c=n.shr64_hi,u=n.shr64_lo,l=n.sum64,d=n.sum64_hi,h=n.sum64_lo,p=n.sum64_4_hi,f=n.sum64_4_lo,g=n.sum64_5_hi,y=n.sum64_5_lo,v=o.BlockHash,E=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function m(){if(!(this instanceof m))return new m;v.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=E,this.W=new Array(160)}function C(e,t,r,n,o){var i=e&r^~e&o;return i<0&&(i+=4294967296),i}function S(e,t,r,n,o,i){var a=t&n^~t&i;return a<0&&(a+=4294967296),a}function I(e,t,r,n,o){var i=e&r^e&o^r&o;return i<0&&(i+=4294967296),i}function w(e,t,r,n,o,i){var a=t&n^t&i^n&i;return a<0&&(a+=4294967296),a}function T(e,t){var r=a(e,t,28)^a(t,e,2)^a(t,e,7);return r<0&&(r+=4294967296),r}function A(e,t){var r=s(e,t,28)^s(t,e,2)^s(t,e,7);return r<0&&(r+=4294967296),r}function _(e,t){var r=a(e,t,14)^a(e,t,18)^a(t,e,9);return r<0&&(r+=4294967296),r}function b(e,t){var r=s(e,t,14)^s(e,t,18)^s(t,e,9);return r<0&&(r+=4294967296),r}function O(e,t){var r=a(e,t,1)^a(e,t,8)^c(e,t,7);return r<0&&(r+=4294967296),r}function R(e,t){var r=s(e,t,1)^s(e,t,8)^u(e,t,7);return r<0&&(r+=4294967296),r}function N(e,t){var r=a(e,t,19)^a(t,e,29)^c(e,t,6);return r<0&&(r+=4294967296),r}function P(e,t){var r=s(e,t,19)^s(t,e,29)^u(e,t,6);return r<0&&(r+=4294967296),r}n.inherits(m,v),e.exports=m,m.blockSize=1024,m.outSize=512,m.hmacStrength=192,m.padLength=128,m.prototype._prepareBlock=function(e,t){for(var r=this.W,n=0;n<32;n++)r[n]=e[t+n];for(;n<r.length;n+=2){var o=N(r[n-4],r[n-3]),i=P(r[n-4],r[n-3]),a=r[n-14],s=r[n-13],c=O(r[n-30],r[n-29]),u=R(r[n-30],r[n-29]),l=r[n-32],d=r[n-31];r[n]=p(o,i,a,s,c,u,l,d),r[n+1]=f(o,i,a,s,c,u,l,d)}},m.prototype._update=function(e,t){this._prepareBlock(e,t);var r=this.W,n=this.h[0],o=this.h[1],a=this.h[2],s=this.h[3],c=this.h[4],u=this.h[5],p=this.h[6],f=this.h[7],v=this.h[8],E=this.h[9],m=this.h[10],O=this.h[11],R=this.h[12],N=this.h[13],P=this.h[14],k=this.h[15];i(this.k.length===r.length);for(var U=0;U<r.length;U+=2){var D=P,L=k,M=_(v,E),F=b(v,E),H=C(v,E,m,O,R),x=S(v,E,m,O,R,N),q=this.k[U],B=this.k[U+1],K=r[U],j=r[U+1],G=g(D,L,M,F,H,x,q,B,K,j),W=y(D,L,M,F,H,x,q,B,K,j);D=T(n,o),L=A(n,o),M=I(n,o,a,s,c),F=w(n,o,a,s,c,u);var V=d(D,L,M,F),z=h(D,L,M,F);P=R,k=N,R=m,N=O,m=v,O=E,v=d(p,f,G,W),E=h(f,f,G,W),p=c,f=u,c=a,u=s,a=n,s=o,n=d(G,W,V,z),o=h(G,W,V,z)}l(this.h,0,n,o),l(this.h,2,a,s),l(this.h,4,c,u),l(this.h,6,p,f),l(this.h,8,v,E),l(this.h,10,m,O),l(this.h,12,R,N),l(this.h,14,P,k)},m.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},7038:(e,t,r)=>{"use strict";var n=r(6436).rotr32;function o(e,t,r){return e&t^~e&r}function i(e,t,r){return e&t^e&r^t&r}function a(e,t,r){return e^t^r}t.ft_1=function(e,t,r,n){return 0===e?o(t,r,n):1===e||3===e?a(t,r,n):2===e?i(t,r,n):void 0},t.ch32=o,t.maj32=i,t.p32=a,t.s0_256=function(e){return n(e,2)^n(e,13)^n(e,22)},t.s1_256=function(e){return n(e,6)^n(e,11)^n(e,25)},t.g0_256=function(e){return n(e,7)^n(e,18)^e>>>3},t.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},6436:(e,t,r)=>{"use strict";var n=r(9746),o=r(5717);function i(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function a(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function c(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=o,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),o=0;o<e.length;o+=2)r.push(parseInt(e[o]+e[o+1],16))}else for(var n=0,o=0;o<e.length;o++){var a=e.charCodeAt(o);a<128?r[n++]=a:a<2048?(r[n++]=a>>6|192,r[n++]=63&a|128):i(e,o)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++o)),r[n++]=a>>18|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128,r[n++]=63&a|128):(r[n++]=a>>12|224,r[n++]=a>>6&63|128,r[n++]=63&a|128)}else for(o=0;o<e.length;o++)r[o]=0|e[o];return r},t.toHex=function(e){for(var t="",r=0;r<e.length;r++)t+=s(e[r].toString(16));return t},t.htonl=a,t.toHex32=function(e,t){for(var r="",n=0;n<e.length;n++){var o=e[n];"little"===t&&(o=a(o)),r+=c(o.toString(16))}return r},t.zero2=s,t.zero8=c,t.join32=function(e,t,r,o){var i=r-t;n(i%4==0);for(var a=new Array(i/4),s=0,c=t;s<a.length;s++,c+=4){var u;u="big"===o?e[c]<<24|e[c+1]<<16|e[c+2]<<8|e[c+3]:e[c+3]<<24|e[c+2]<<16|e[c+1]<<8|e[c],a[s]=u>>>0}return a},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,o=0;n<e.length;n++,o+=4){var i=e[n];"big"===t?(r[o]=i>>>24,r[o+1]=i>>>16&255,r[o+2]=i>>>8&255,r[o+3]=255&i):(r[o+3]=i>>>24,r[o+2]=i>>>16&255,r[o+1]=i>>>8&255,r[o]=255&i)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<<t|e>>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,o){return e+t+r+n+o>>>0},t.sum64=function(e,t,r,n){var o=e[t],i=n+e[t+1]>>>0,a=(i<n?1:0)+r+o;e[t]=a>>>0,e[t+1]=i},t.sum64_hi=function(e,t,r,n){return(t+n>>>0<t?1:0)+e+r>>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,o,i,a,s){var c=0,u=t;return c+=(u=u+n>>>0)<t?1:0,c+=(u=u+i>>>0)<i?1:0,e+r+o+a+(c+=(u=u+s>>>0)<s?1:0)>>>0},t.sum64_4_lo=function(e,t,r,n,o,i,a,s){return t+n+i+s>>>0},t.sum64_5_hi=function(e,t,r,n,o,i,a,s,c,u){var l=0,d=t;return l+=(d=d+n>>>0)<t?1:0,l+=(d=d+i>>>0)<i?1:0,l+=(d=d+s>>>0)<s?1:0,e+r+o+a+c+(l+=(d=d+u>>>0)<u?1:0)>>>0},t.sum64_5_lo=function(e,t,r,n,o,i,a,s,c,u){return t+n+i+s+u>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},645:(e,t)=>{t.read=function(e,t,r,n,o){var i,a,s=8*o-n-1,c=(1<<s)-1,u=c>>1,l=-7,d=r?o-1:0,h=r?-1:1,p=e[t+d];for(d+=h,i=p&(1<<-l)-1,p>>=-l,l+=s;l>0;i=256*i+e[t+d],d+=h,l-=8);for(a=i&(1<<-l)-1,i>>=-l,l+=n;l>0;a=256*a+e[t+d],d+=h,l-=8);if(0===i)i=1-u;else{if(i===c)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=u}return(p?-1:1)*a*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var a,s,c,u=8*i-o-1,l=(1<<u)-1,d=l>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,f=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-a))<1&&(a--,c*=2),(t+=a+d>=1?h/c:h*Math.pow(2,1-d))*c>=2&&(a++,c/=2),a+d>=l?(s=0,a=l):a+d>=1?(s=(t*c-1)*Math.pow(2,o),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,o),a=0));o>=8;e[r+p]=255&s,p+=f,s/=256,o-=8);for(a=a<<o|s,u+=o;u>0;e[r+p]=255&a,p+=f,a/=256,u-=8);e[r+p-f]|=128*g}},5717:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},5299:(e,t,r)=>{"use strict";var n=r(7798);function o(e){return!0===n(e)&&"[object Object]"===Object.prototype.toString.call(e)}e.exports=function(e){var t,r;return!1!==o(e)&&("function"==typeof(t=e.constructor)&&(!1!==o(r=t.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}},7798:e=>{"use strict";e.exports=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)}},6245:(e,t,r)=>{"use strict";function n(e){this.message=e}r.r(t),r.d(t,{InvalidTokenError:()=>a,default:()=>s}),n.prototype=new Error,n.prototype.name="InvalidCharacterError";var o="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new n("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,o,i=0,a=0,s="";o=t.charAt(a++);~o&&(r=i%4?64*r+o:o,i++%4)?s+=String.fromCharCode(255&r>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function i(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"Illegal base64url string!"}try{return function(e){return decodeURIComponent(o(e).replace(/(.)/g,(function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(e){return o(t)}}function a(e){this.message=e}a.prototype=new Error,a.prototype.name="InvalidTokenError";const s=function(e,t){if("string"!=typeof e)throw new a("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(i(e.split(".")[r]))}catch(e){throw new a("Invalid token specified: "+e.message)}}},6401:e=>{var t=Object.prototype.toString;function r(e){return"function"==typeof e.constructor?e.constructor.name:null}e.exports=function(e){if(void 0===e)return"undefined";if(null===e)return"null";var n=typeof e;if("boolean"===n)return"boolean";if("string"===n)return"string";if("number"===n)return"number";if("symbol"===n)return"symbol";if("function"===n)return"GeneratorFunction"===r(e)?"generatorfunction":"function";if(function(e){return Array.isArray?Array.isArray(e):e instanceof Array}(e))return"array";if(function(e){if(e.constructor&&"function"==typeof e.constructor.isBuffer)return e.constructor.isBuffer(e);return!1}(e))return"buffer";if(function(e){try{if("number"==typeof e.length&&"function"==typeof e.callee)return!0}catch(e){if(-1!==e.message.indexOf("callee"))return!0}return!1}(e))return"arguments";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";if(function(e){return e instanceof RegExp||"string"==typeof e.flags&&"boolean"==typeof e.ignoreCase&&"boolean"==typeof e.multiline&&"boolean"==typeof e.global}(e))return"regexp";switch(r(e)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(e){return"function"==typeof e.throw&&"function"==typeof e.return&&"function"==typeof e.next}(e))return"generator";switch(n=t.call(e)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return n.slice(8,-1).toLowerCase().replace(/\s/g,"")}},9746:e=>{function t(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=t,t.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},4155:e=>{var t,r,n=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function a(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var s,c=[],u=!1,l=-1;function d(){u&&s&&(u=!1,s.length?c=s.concat(c):l=-1,c.length&&h())}function h(){if(!u){var e=a(d);u=!0;for(var t=c.length;t;){for(s=c,c=[];++l<t;)s&&s[l].run();l=-1,t=c.length}s=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function f(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new p(e,t)),1!==c.length||u||a(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=f,n.addListener=f,n.once=f,n.off=f,n.removeListener=f,n.removeAllListeners=f,n.emit=f,n.prependListener=f,n.prependOnceListener=f,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},3341:(e,t,r)=>{"use strict";var n=r(8764).lW;const o=Symbol.prototype.valueOf,i=r(6401);e.exports=function(e,t){switch(i(e)){case"array":return e.slice();case"object":return Object.assign({},e);case"date":return new e.constructor(Number(e));case"map":return new Map(e);case"set":return new Set(e);case"buffer":return function(e){const t=e.length,r=n.allocUnsafe?n.allocUnsafe(t):n.from(t);return e.copy(r),r}(e);case"symbol":return function(e){return o?Object(o.call(e)):{}}(e);case"arraybuffer":return function(e){const t=new e.constructor(e.byteLength);return new Uint8Array(t).set(new Uint8Array(e)),t}(e);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return function(e,t){return new e.constructor(e.buffer,e.byteOffset,e.length)}(e);case"regexp":return function(e){const t=void 0!==e.flags?e.flags:/\w+$/.exec(e)||void 0,r=new e.constructor(e.source,t);return r.lastIndex=e.lastIndex,r}(e);case"error":return Object.create(e);default:return e}}},655:(e,t,r)=>{"use strict";r.r(t),r.d(t,{__assign:()=>i,__asyncDelegator:()=>S,__asyncGenerator:()=>C,__asyncValues:()=>I,__await:()=>m,__awaiter:()=>l,__classPrivateFieldGet:()=>b,__classPrivateFieldSet:()=>O,__createBinding:()=>h,__decorate:()=>s,__exportStar:()=>p,__extends:()=>o,__generator:()=>d,__importDefault:()=>_,__importStar:()=>A,__makeTemplateObject:()=>w,__metadata:()=>u,__param:()=>c,__read:()=>g,__rest:()=>a,__spread:()=>y,__spreadArray:()=>E,__spreadArrays:()=>v,__values:()=>f});var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)};function a(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function s(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){return function(r,n){t(r,n,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function l(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function d(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}var h=Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function p(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||h(t,e,r)}function f(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}function v(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n}function E(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function m(e){return this instanceof m?(this.v=e,this):new m(e)}function C(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),i=[];return n={},a("next"),a("throw"),a("return"),n[Symbol.asyncIterator]=function(){return this},n;function a(e){o[e]&&(n[e]=function(t){return new Promise((function(r,n){i.push([e,t,r,n])>1||s(e,t)}))})}function s(e,t){try{(r=o[e](t)).value instanceof m?Promise.resolve(r.value.v).then(c,u):l(i[0][2],r)}catch(e){l(i[0][3],e)}var r}function c(e){s("next",e)}function u(e){s("throw",e)}function l(e,t){e(t),i.shift(),i.length&&s(i[0][0],i[0][1])}}function S(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:m(e[n](t)),done:"return"===n}:o?o(t):t}:o}}function I(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=f(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,o,(t=e[r](t)).done,t.value)}))}}}function w(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var T=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function A(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&h(t,e,r);return T(t,e),t}function _(e){return e&&e.__esModule?e:{default:e}}function b(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function O(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r}},5431:function(e,t){"use strict";!function(e){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,r)};function r(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function o(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function i(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function a(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function s(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(a(arguments[t]));return e}var c=function(e,t){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function u(e,t){function r(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var l=function(){return(l=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function d(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function h(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function p(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n}var f,g,y,v,E,m={LIBRARY_NAME:"MSAL.JS",SKU:"msal.js.common",CACHE_PREFIX:"msal",DEFAULT_AUTHORITY:"https://login.microsoftonline.com/common/",DEFAULT_AUTHORITY_HOST:"login.microsoftonline.com",ADFS:"adfs",AAD_INSTANCE_DISCOVERY_ENDPT:"https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=",RESOURCE_DELIM:"|",NO_ACCOUNT:"NO_ACCOUNT",CLAIMS:"claims",CONSUMER_UTID:"9188040d-6c67-4c5b-b112-36a304b66dad",OPENID_SCOPE:"openid",PROFILE_SCOPE:"profile",OFFLINE_ACCESS_SCOPE:"offline_access",EMAIL_SCOPE:"email",CODE_RESPONSE_TYPE:"code",CODE_GRANT_TYPE:"authorization_code",RT_GRANT_TYPE:"refresh_token",FRAGMENT_RESPONSE_MODE:"fragment",S256_CODE_CHALLENGE_METHOD:"S256",URL_FORM_CONTENT_TYPE:"application/x-www-form-urlencoded;charset=utf-8",AUTHORIZATION_PENDING:"authorization_pending",NOT_DEFINED:"not_defined",EMPTY_STRING:"",FORWARD_SLASH:"/",IMDS_ENDPOINT:"http://169.254.169.254/metadata/instance/compute/location",IMDS_VERSION:"2020-06-01",IMDS_TIMEOUT:2e3,AZURE_REGION_AUTO_DISCOVER_FLAG:"TryAutoDetect",REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX:"login.microsoft.com",KNOWN_PUBLIC_CLOUDS:["login.microsoftonline.com","login.windows.net","login.microsoft.com","sts.windows.net"]},C=[m.OPENID_SCOPE,m.PROFILE_SCOPE,m.OFFLINE_ACCESS_SCOPE],S=p(C,[m.EMAIL_SCOPE]);!function(e){e.CONTENT_TYPE="Content-Type",e.RETRY_AFTER="Retry-After",e.CCS_HEADER="X-AnchorMailbox",e.WWWAuthenticate="WWW-Authenticate",e.AuthenticationInfo="Authentication-Info"}(f||(f={})),function(e){e.ID_TOKEN="idtoken",e.CLIENT_INFO="client.info",e.ADAL_ID_TOKEN="adal.idtoken",e.ERROR="error",e.ERROR_DESC="error.description",e.ACTIVE_ACCOUNT="active-account"}(g||(g={})),function(e){e.COMMON="common",e.ORGANIZATIONS="organizations",e.CONSUMERS="consumers"}(y||(y={})),function(e){e.CLIENT_ID="client_id",e.REDIRECT_URI="redirect_uri",e.RESPONSE_TYPE="response_type",e.RESPONSE_MODE="response_mode",e.GRANT_TYPE="grant_type",e.CLAIMS="claims",e.SCOPE="scope",e.ERROR="error",e.ERROR_DESCRIPTION="error_description",e.ACCESS_TOKEN="access_token",e.ID_TOKEN="id_token",e.REFRESH_TOKEN="refresh_token",e.EXPIRES_IN="expires_in",e.STATE="state",e.NONCE="nonce",e.PROMPT="prompt",e.SESSION_STATE="session_state",e.CLIENT_INFO="client_info",e.CODE="code",e.CODE_CHALLENGE="code_challenge",e.CODE_CHALLENGE_METHOD="code_challenge_method",e.CODE_VERIFIER="code_verifier",e.CLIENT_REQUEST_ID="client-request-id",e.X_CLIENT_SKU="x-client-SKU",e.X_CLIENT_VER="x-client-VER",e.X_CLIENT_OS="x-client-OS",e.X_CLIENT_CPU="x-client-CPU",e.X_CLIENT_CURR_TELEM="x-client-current-telemetry",e.X_CLIENT_LAST_TELEM="x-client-last-telemetry",e.X_MS_LIB_CAPABILITY="x-ms-lib-capability",e.POST_LOGOUT_URI="post_logout_redirect_uri",e.ID_TOKEN_HINT="id_token_hint",e.DEVICE_CODE="device_code",e.CLIENT_SECRET="client_secret",e.CLIENT_ASSERTION="client_assertion",e.CLIENT_ASSERTION_TYPE="client_assertion_type",e.TOKEN_TYPE="token_type",e.REQ_CNF="req_cnf",e.OBO_ASSERTION="assertion",e.REQUESTED_TOKEN_USE="requested_token_use",e.ON_BEHALF_OF="on_behalf_of",e.FOCI="foci",e.CCS_HEADER="X-AnchorMailbox"}(v||(v={})),function(e){e.ACCESS_TOKEN="access_token",e.XMS_CC="xms_cc"}(E||(E={}));var I,w={LOGIN:"login",SELECT_ACCOUNT:"select_account",CONSENT:"consent",NONE:"none",CREATE:"create"};!function(e){e.ACCOUNT="account",e.SID="sid",e.LOGIN_HINT="login_hint",e.ID_TOKEN="id_token",e.DOMAIN_HINT="domain_hint",e.ORGANIZATIONS="organizations",e.CONSUMERS="consumers",e.ACCOUNT_ID="accountIdentifier",e.HOMEACCOUNT_ID="homeAccountIdentifier"}(I||(I={}));var T,A,_,b,O,R,N,P={PLAIN:"plain",S256:"S256"};!function(e){e.QUERY="query",e.FRAGMENT="fragment",e.FORM_POST="form_post"}(T||(T={})),function(e){e.IMPLICIT_GRANT="implicit",e.AUTHORIZATION_CODE_GRANT="authorization_code",e.CLIENT_CREDENTIALS_GRANT="client_credentials",e.RESOURCE_OWNER_PASSWORD_GRANT="password",e.REFRESH_TOKEN_GRANT="refresh_token",e.DEVICE_CODE_GRANT="device_code",e.JWT_BEARER="urn:ietf:params:oauth:grant-type:jwt-bearer"}(A||(A={})),function(e){e.MSSTS_ACCOUNT_TYPE="MSSTS",e.ADFS_ACCOUNT_TYPE="ADFS",e.MSAV1_ACCOUNT_TYPE="MSA",e.GENERIC_ACCOUNT_TYPE="Generic"}(_||(_={})),function(e){e.CACHE_KEY_SEPARATOR="-",e.CLIENT_INFO_SEPARATOR="."}(b||(b={})),function(e){e.ID_TOKEN="IdToken",e.ACCESS_TOKEN="AccessToken",e.ACCESS_TOKEN_WITH_AUTH_SCHEME="AccessToken_With_AuthScheme",e.REFRESH_TOKEN="RefreshToken"}(O||(O={})),function(e){e.ACCOUNT="Account",e.CREDENTIAL="Credential",e.ID_TOKEN="IdToken",e.ACCESS_TOKEN="AccessToken",e.REFRESH_TOKEN="RefreshToken",e.APP_METADATA="AppMetadata",e.TEMPORARY="TempCache",e.TELEMETRY="Telemetry",e.UNDEFINED="Undefined",e.THROTTLING="Throttling"}(R||(R={})),function(e){e[e.ADFS=1001]="ADFS",e[e.MSA=1002]="MSA",e[e.MSSTS=1003]="MSSTS",e[e.GENERIC=1004]="GENERIC",e[e.ACCESS_TOKEN=2001]="ACCESS_TOKEN",e[e.REFRESH_TOKEN=2002]="REFRESH_TOKEN",e[e.ID_TOKEN=2003]="ID_TOKEN",e[e.APP_METADATA=3001]="APP_METADATA",e[e.UNDEFINED=9999]="UNDEFINED"}(N||(N={}));var k,U="appmetadata",D="1",L="authority-metadata",M=86400;!function(e){e.CONFIG="config",e.CACHE="cache",e.NETWORK="network"}(k||(k={}));var F,H={SCHEMA_VERSION:5,MAX_CUR_HEADER_BYTES:80,MAX_LAST_HEADER_BYTES:330,MAX_CACHED_ERRORS:50,CACHE_KEY:"server-telemetry",CATEGORY_SEPARATOR:"|",VALUE_SEPARATOR:",",OVERFLOW_TRUE:"1",OVERFLOW_FALSE:"0",UNKNOWN_ERROR:"unknown_error"};e.AuthenticationScheme=void 0,(F=e.AuthenticationScheme||(e.AuthenticationScheme={})).BEARER="Bearer",F.POP="pop",F.SSH="ssh-cert";var x,q,B,K,j,G=60,W=3600,V="throttling",z="retry-after, h429",$="invalid_grant",Y="client_mismatch";!function(e){e.username="username",e.password="password"}(x||(x={})),function(e){e[e.httpSuccess=200]="httpSuccess",e[e.httpBadRequest=400]="httpBadRequest"}(q||(q={})),function(e){e.FAILED_AUTO_DETECTION="1",e.INTERNAL_CACHE="2",e.ENVIRONMENT_VARIABLE="3",e.IMDS="4"}(B||(B={})),function(e){e.CONFIGURED_MATCHES_DETECTED="1",e.CONFIGURED_NO_AUTO_DETECTION="2",e.CONFIGURED_NOT_DETECTED="3",e.AUTO_DETECTION_REQUESTED_SUCCESSFUL="4",e.AUTO_DETECTION_REQUESTED_FAILED="5"}(K||(K={})),function(e){e.NO_CACHE_HIT="0",e.FORCE_REFRESH="1",e.NO_CACHED_ACCESS_TOKEN="2",e.CACHED_ACCESS_TOKEN_EXPIRED="3",e.REFRESH_CACHED_ACCESS_TOKEN="4"}(j||(j={}));var J,Q={unexpectedError:{code:"unexpected_error",desc:"Unexpected error in authentication."}},X=function(e){function t(r,n,o){var i=this,a=n?r+": "+n:r;return i=e.call(this,a)||this,Object.setPrototypeOf(i,t.prototype),i.errorCode=r||m.EMPTY_STRING,i.errorMessage=n||"",i.subError=o||"",i.name="AuthError",i}return u(t,e),t.prototype.setCorrelationId=function(e){this.correlationId=e},t.createUnexpectedError=function(e){return new t(Q.unexpectedError.code,Q.unexpectedError.desc+": "+e)},t}(Error),Z={createNewGuid:function(){throw X.createUnexpectedError("Crypto interface - createNewGuid() has not been implemented")},base64Decode:function(){throw X.createUnexpectedError("Crypto interface - base64Decode() has not been implemented")},base64Encode:function(){throw X.createUnexpectedError("Crypto interface - base64Encode() has not been implemented")},generatePkceCodes:function(){return d(this,void 0,void 0,(function(){return h(this,(function(e){throw X.createUnexpectedError("Crypto interface - generatePkceCodes() has not been implemented")}))}))},getPublicKeyThumbprint:function(){return d(this,void 0,void 0,(function(){return h(this,(function(e){throw X.createUnexpectedError("Crypto interface - getPublicKeyThumbprint() has not been implemented")}))}))},removeTokenBindingKey:function(){return d(this,void 0,void 0,(function(){return h(this,(function(e){throw X.createUnexpectedError("Crypto interface - removeTokenBindingKey() has not been implemented")}))}))},clearKeystore:function(){return d(this,void 0,void 0,(function(){return h(this,(function(e){throw X.createUnexpectedError("Crypto interface - clearKeystore() has not been implemented")}))}))},signJwt:function(){return d(this,void 0,void 0,(function(){return h(this,(function(e){throw X.createUnexpectedError("Crypto interface - signJwt() has not been implemented")}))}))}},ee={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."},clientInfoEmptyError:{code:"client_info_empty_error",desc:"The client info was empty. Please review the trace to determine the root cause."},tokenParsingError:{code:"token_parsing_error",desc:"Token cannot be parsed. Please review stack trace to determine root cause."},nullOrEmptyToken:{code:"null_or_empty_token",desc:"The token is null or empty. Please review the trace to determine the root cause."},endpointResolutionError:{code:"endpoints_resolution_error",desc:"Error: could not resolve endpoints. Please check network and try again."},networkError:{code:"network_error",desc:"Network request failed. Please check network trace to determine root cause."},unableToGetOpenidConfigError:{code:"openid_config_error",desc:"Could not retrieve endpoints. Check your authority and verify the .well-known/openid-configuration endpoint returns the required endpoints."},hashNotDeserialized:{code:"hash_not_deserialized",desc:"The hash parameters could not be deserialized. Please review the trace to determine the root cause."},blankGuidGenerated:{code:"blank_guid_generated",desc:"The guid generated was blank. Please review the trace to determine the root cause."},invalidStateError:{code:"invalid_state",desc:"State was not the expected format. Please check the logs to determine whether the request was sent using ProtocolUtils.setRequestState()."},stateMismatchError:{code:"state_mismatch",desc:"State mismatch error. Please check your network. Continued requests may cause cache overflow."},stateNotFoundError:{code:"state_not_found",desc:"State not found"},nonceMismatchError:{code:"nonce_mismatch",desc:"Nonce mismatch error. This may be caused by a race condition in concurrent requests."},nonceNotFoundError:{code:"nonce_not_found",desc:"nonce not found"},noTokensFoundError:{code:"no_tokens_found",desc:"No tokens were found for the given scopes, and no authorization code was passed to acquireToken. You must retrieve an authorization code before making a call to acquireToken()."},multipleMatchingTokens:{code:"multiple_matching_tokens",desc:"The cache contains multiple tokens satisfying the requirements. Call AcquireToken again providing more requirements such as authority or account."},multipleMatchingAccounts:{code:"multiple_matching_accounts",desc:"The cache contains multiple accounts satisfying the given parameters. Please pass more info to obtain the correct account"},multipleMatchingAppMetadata:{code:"multiple_matching_appMetadata",desc:"The cache contains multiple appMetadata satisfying the given parameters. Please pass more info to obtain the correct appMetadata"},tokenRequestCannotBeMade:{code:"request_cannot_be_made",desc:"Token request cannot be made without authorization code or refresh token."},appendEmptyScopeError:{code:"cannot_append_empty_scope",desc:"Cannot append null or empty scope to ScopeSet. Please check the stack trace for more info."},removeEmptyScopeError:{code:"cannot_remove_empty_scope",desc:"Cannot remove null or empty scope from ScopeSet. Please check the stack trace for more info."},appendScopeSetError:{code:"cannot_append_scopeset",desc:"Cannot append ScopeSet due to error."},emptyInputScopeSetError:{code:"empty_input_scopeset",desc:"Empty input ScopeSet cannot be processed."},DeviceCodePollingCancelled:{code:"device_code_polling_cancelled",desc:"Caller has cancelled token endpoint polling during device code flow by setting DeviceCodeRequest.cancel = true."},DeviceCodeExpired:{code:"device_code_expired",desc:"Device code is expired."},DeviceCodeUnknownError:{code:"device_code_unknown_error",desc:"Device code stopped polling for unknown reasons."},NoAccountInSilentRequest:{code:"no_account_in_silent_request",desc:"Please pass an account object, silent flow is not supported without account information"},invalidCacheRecord:{code:"invalid_cache_record",desc:"Cache record object was null or undefined."},invalidCacheEnvironment:{code:"invalid_cache_environment",desc:"Invalid environment when attempting to create cache entry"},noAccountFound:{code:"no_account_found",desc:"No account found in cache for given key."},CachePluginError:{code:"no cache plugin set on CacheManager",desc:"ICachePlugin needs to be set before using readFromStorage or writeFromStorage"},noCryptoObj:{code:"no_crypto_object",desc:"No crypto object detected. This is required for the following operation: "},invalidCacheType:{code:"invalid_cache_type",desc:"Invalid cache type"},unexpectedAccountType:{code:"unexpected_account_type",desc:"Unexpected account type."},unexpectedCredentialType:{code:"unexpected_credential_type",desc:"Unexpected credential type."},invalidAssertion:{code:"invalid_assertion",desc:"Client assertion must meet requirements described in https://tools.ietf.org/html/rfc7515"},invalidClientCredential:{code:"invalid_client_credential",desc:"Client credential (secret, certificate, or assertion) must not be empty when creating a confidential client. An application should at most have one credential"},tokenRefreshRequired:{code:"token_refresh_required",desc:"Cannot return token from cache because it must be refreshed. This may be due to one of the following reasons: forceRefresh parameter is set to true, claims have been requested, there is no cached access token or it is expired."},userTimeoutReached:{code:"user_timeout_reached",desc:"User defined timeout for device code polling reached"},tokenClaimsRequired:{code:"token_claims_cnf_required_for_signedjwt",desc:"Cannot generate a POP jwt if the token_claims are not populated"},noAuthorizationCodeFromServer:{code:"authorization_code_missing_from_server_response",desc:"Server response does not contain an authorization code to proceed"},noAzureRegionDetected:{code:"no_azure_region_detected",desc:"No azure region was detected and no fallback was made available"},accessTokenEntityNullError:{code:"access_token_entity_null",desc:"Access token entity is null, please check logs and cache to ensure a valid access token is present."},bindingKeyNotRemovedError:{code:"binding_key_not_removed",desc:"Could not remove the credential's binding key from storage."},logoutNotSupported:{code:"end_session_endpoint_not_supported",desc:"Provided authority does not support logout."}},te=function(e){function t(r,n){var o=e.call(this,r,n)||this;return o.name="ClientAuthError",Object.setPrototypeOf(o,t.prototype),o}return u(t,e),t.createClientInfoDecodingError=function(e){return new t(ee.clientInfoDecodingError.code,ee.clientInfoDecodingError.desc+" Failed with error: "+e)},t.createClientInfoEmptyError=function(){return new t(ee.clientInfoEmptyError.code,""+ee.clientInfoEmptyError.desc)},t.createTokenParsingError=function(e){return new t(ee.tokenParsingError.code,ee.tokenParsingError.desc+" Failed with error: "+e)},t.createTokenNullOrEmptyError=function(e){return new t(ee.nullOrEmptyToken.code,ee.nullOrEmptyToken.desc+" Raw Token Value: "+e)},t.createEndpointDiscoveryIncompleteError=function(e){return new t(ee.endpointResolutionError.code,ee.endpointResolutionError.desc+" Detail: "+e)},t.createNetworkError=function(e,r){return new t(ee.networkError.code,ee.networkError.desc+" | Fetch client threw: "+r+" | Attempted to reach: "+e.split("?")[0])},t.createUnableToGetOpenidConfigError=function(e){return new t(ee.unableToGetOpenidConfigError.code,ee.unableToGetOpenidConfigError.desc+" Attempted to retrieve endpoints from: "+e)},t.createHashNotDeserializedError=function(e){return new t(ee.hashNotDeserialized.code,ee.hashNotDeserialized.desc+" Given Object: "+e)},t.createInvalidStateError=function(e,r){return new t(ee.invalidStateError.code,ee.invalidStateError.desc+" Invalid State: "+e+", Root Err: "+r)},t.createStateMismatchError=function(){return new t(ee.stateMismatchError.code,ee.stateMismatchError.desc)},t.createStateNotFoundError=function(e){return new t(ee.stateNotFoundError.code,ee.stateNotFoundError.desc+": "+e)},t.createNonceMismatchError=function(){return new t(ee.nonceMismatchError.code,ee.nonceMismatchError.desc)},t.createNonceNotFoundError=function(e){return new t(ee.nonceNotFoundError.code,ee.nonceNotFoundError.desc+": "+e)},t.createMultipleMatchingTokensInCacheError=function(){return new t(ee.multipleMatchingTokens.code,ee.multipleMatchingTokens.desc+".")},t.createMultipleMatchingAccountsInCacheError=function(){return new t(ee.multipleMatchingAccounts.code,ee.multipleMatchingAccounts.desc)},t.createMultipleMatchingAppMetadataInCacheError=function(){return new t(ee.multipleMatchingAppMetadata.code,ee.multipleMatchingAppMetadata.desc)},t.createTokenRequestCannotBeMadeError=function(){return new t(ee.tokenRequestCannotBeMade.code,ee.tokenRequestCannotBeMade.desc)},t.createAppendEmptyScopeToSetError=function(e){return new t(ee.appendEmptyScopeError.code,ee.appendEmptyScopeError.desc+" Given Scope: "+e)},t.createRemoveEmptyScopeFromSetError=function(e){return new t(ee.removeEmptyScopeError.code,ee.removeEmptyScopeError.desc+" Given Scope: "+e)},t.createAppendScopeSetError=function(e){return new t(ee.appendScopeSetError.code,ee.appendScopeSetError.desc+" Detail Error: "+e)},t.createEmptyInputScopeSetError=function(){return new t(ee.emptyInputScopeSetError.code,""+ee.emptyInputScopeSetError.desc)},t.createDeviceCodeCancelledError=function(){return new t(ee.DeviceCodePollingCancelled.code,""+ee.DeviceCodePollingCancelled.desc)},t.createDeviceCodeExpiredError=function(){return new t(ee.DeviceCodeExpired.code,""+ee.DeviceCodeExpired.desc)},t.createDeviceCodeUnknownError=function(){return new t(ee.DeviceCodeUnknownError.code,""+ee.DeviceCodeUnknownError.desc)},t.createNoAccountInSilentRequestError=function(){return new t(ee.NoAccountInSilentRequest.code,""+ee.NoAccountInSilentRequest.desc)},t.createNullOrUndefinedCacheRecord=function(){return new t(ee.invalidCacheRecord.code,ee.invalidCacheRecord.desc)},t.createInvalidCacheEnvironmentError=function(){return new t(ee.invalidCacheEnvironment.code,ee.invalidCacheEnvironment.desc)},t.createNoAccountFoundError=function(){return new t(ee.noAccountFound.code,ee.noAccountFound.desc)},t.createCachePluginError=function(){return new t(ee.CachePluginError.code,""+ee.CachePluginError.desc)},t.createNoCryptoObjectError=function(e){return new t(ee.noCryptoObj.code,""+ee.noCryptoObj.desc+e)},t.createInvalidCacheTypeError=function(){return new t(ee.invalidCacheType.code,""+ee.invalidCacheType.desc)},t.createUnexpectedAccountTypeError=function(){return new t(ee.unexpectedAccountType.code,""+ee.unexpectedAccountType.desc)},t.createUnexpectedCredentialTypeError=function(){return new t(ee.unexpectedCredentialType.code,""+ee.unexpectedCredentialType.desc)},t.createInvalidAssertionError=function(){return new t(ee.invalidAssertion.code,""+ee.invalidAssertion.desc)},t.createInvalidCredentialError=function(){return new t(ee.invalidClientCredential.code,""+ee.invalidClientCredential.desc)},t.createRefreshRequiredError=function(){return new t(ee.tokenRefreshRequired.code,ee.tokenRefreshRequired.desc)},t.createUserTimeoutReachedError=function(){return new t(ee.userTimeoutReached.code,ee.userTimeoutReached.desc)},t.createTokenClaimsRequiredError=function(){return new t(ee.tokenClaimsRequired.code,ee.tokenClaimsRequired.desc)},t.createNoAuthCodeInServerResponseError=function(){return new t(ee.noAuthorizationCodeFromServer.code,ee.noAuthorizationCodeFromServer.desc)},t.createBindingKeyNotRemovedError=function(){return new t(ee.bindingKeyNotRemovedError.code,ee.bindingKeyNotRemovedError.desc)},t.createLogoutNotSupportedError=function(){return new t(ee.logoutNotSupported.code,ee.logoutNotSupported.desc)},t}(X),re=function(){function e(){}return e.decodeAuthToken=function(t){if(e.isEmpty(t))throw te.createTokenNullOrEmptyError(t);var r=/^([^\.\s]*)\.([^\.\s]+)\.([^\.\s]*)$/.exec(t);if(!r||r.length<4)throw te.createTokenParsingError("Given token is malformed: "+JSON.stringify(t));return{header:r[1],JWSPayload:r[2],JWSSig:r[3]}},e.isEmpty=function(e){return void 0===e||!e||0===e.length},e.isEmptyObj=function(t){if(t&&!e.isEmpty(t))try{var r=JSON.parse(t);return 0===Object.keys(r).length}catch(e){}return!0},e.startsWith=function(e,t){return 0===e.indexOf(t)},e.endsWith=function(e,t){return e.length>=t.length&&e.lastIndexOf(t)===e.length-t.length},e.queryStringToObject=function(e){var t={},r=e.split("&"),n=function(e){return decodeURIComponent(e.replace(/\+/g," "))};return r.forEach((function(e){if(e.trim()){var r=e.split(/=(.+)/g,2),o=r[0],i=r[1];o&&i&&(t[n(o)]=n(i))}})),t},e.trimArrayEntries=function(e){return e.map((function(e){return e.trim()}))},e.removeEmptyStringsFromArray=function(t){return t.filter((function(t){return!e.isEmpty(t)}))},e.jsonParseHelper=function(e){try{return JSON.parse(e)}catch(e){return null}},e.matchPattern=function(e,t){return new RegExp(e.replace(/\\/g,"\\\\").replace(/\*/g,"[^ ]*").replace(/\?/g,"\\?")).test(t)},e}();e.LogLevel=void 0,(J=e.LogLevel||(e.LogLevel={}))[J.Error=0]="Error",J[J.Warning=1]="Warning",J[J.Info=2]="Info",J[J.Verbose=3]="Verbose",J[J.Trace=4]="Trace";var ne,oe=function(){function t(t,r,n){this.level=e.LogLevel.Info,this.localCallback=t.loggerCallback||function(){},this.piiLoggingEnabled=t.piiLoggingEnabled||!1,this.level="number"==typeof t.logLevel?t.logLevel:e.LogLevel.Info,this.correlationId=t.correlationId||"",this.packageName=r||m.EMPTY_STRING,this.packageVersion=n||m.EMPTY_STRING}return t.prototype.clone=function(e,r,n){return new t({loggerCallback:this.localCallback,piiLoggingEnabled:this.piiLoggingEnabled,logLevel:this.level,correlationId:n||this.correlationId},e,r)},t.prototype.logMessage=function(t,r){if(!(r.logLevel>this.level||!this.piiLoggingEnabled&&r.containsPii)){var n=(new Date).toUTCString(),o=(re.isEmpty(r.correlationId)?re.isEmpty(this.correlationId)?"["+n+"]":"["+n+"] : ["+this.correlationId+"]":"["+n+"] : ["+r.correlationId+"]")+" : "+this.packageName+"@"+this.packageVersion+" : "+e.LogLevel[r.logLevel]+" - "+t;this.executeCallback(r.logLevel,o,r.containsPii||!1)}},t.prototype.executeCallback=function(e,t,r){this.localCallback&&this.localCallback(e,t,r)},t.prototype.error=function(t,r){this.logMessage(t,{logLevel:e.LogLevel.Error,containsPii:!1,correlationId:r||""})},t.prototype.errorPii=function(t,r){this.logMessage(t,{logLevel:e.LogLevel.Error,containsPii:!0,correlationId:r||""})},t.prototype.warning=function(t,r){this.logMessage(t,{logLevel:e.LogLevel.Warning,containsPii:!1,correlationId:r||""})},t.prototype.warningPii=function(t,r){this.logMessage(t,{logLevel:e.LogLevel.Warning,containsPii:!0,correlationId:r||""})},t.prototype.info=function(t,r){this.logMessage(t,{logLevel:e.LogLevel.Info,containsPii:!1,correlationId:r||""})},t.prototype.infoPii=function(t,r){this.logMessage(t,{logLevel:e.LogLevel.Info,containsPii:!0,correlationId:r||""})},t.prototype.verbose=function(t,r){this.logMessage(t,{logLevel:e.LogLevel.Verbose,containsPii:!1,correlationId:r||""})},t.prototype.verbosePii=function(t,r){this.logMessage(t,{logLevel:e.LogLevel.Verbose,containsPii:!0,correlationId:r||""})},t.prototype.trace=function(t,r){this.logMessage(t,{logLevel:e.LogLevel.Trace,containsPii:!1,correlationId:r||""})},t.prototype.tracePii=function(t,r){this.logMessage(t,{logLevel:e.LogLevel.Trace,containsPii:!0,correlationId:r||""})},t.prototype.isPiiLoggingEnabled=function(){return this.piiLoggingEnabled||!1},t}(),ie="5.1.0",ae=function(){function t(){}return t.prototype.generateAccountId=function(){return t.generateAccountIdForCacheKey(this.homeAccountId,this.environment)},t.prototype.generateCredentialId=function(){return t.generateCredentialIdForCacheKey(this.credentialType,this.clientId,this.realm,this.familyId)},t.prototype.generateTarget=function(){return t.generateTargetForCacheKey(this.target)},t.prototype.generateCredentialKey=function(){return t.generateCredentialCacheKey(this.homeAccountId,this.environment,this.credentialType,this.clientId,this.realm,this.target,this.familyId,this.tokenType)},t.prototype.generateType=function(){switch(this.credentialType){case O.ID_TOKEN:return N.ID_TOKEN;case O.ACCESS_TOKEN:case O.ACCESS_TOKEN_WITH_AUTH_SCHEME:return N.ACCESS_TOKEN;case O.REFRESH_TOKEN:return N.REFRESH_TOKEN;default:throw te.createUnexpectedCredentialTypeError()}},t.getCredentialType=function(e){return-1!==e.indexOf(O.ACCESS_TOKEN.toLowerCase())?-1!==e.indexOf(O.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())?O.ACCESS_TOKEN_WITH_AUTH_SCHEME:O.ACCESS_TOKEN:-1!==e.indexOf(O.ID_TOKEN.toLowerCase())?O.ID_TOKEN:-1!==e.indexOf(O.REFRESH_TOKEN.toLowerCase())?O.REFRESH_TOKEN:m.NOT_DEFINED},t.generateCredentialCacheKey=function(t,r,n,o,i,a,s,c){var u=[this.generateAccountIdForCacheKey(t,r),this.generateCredentialIdForCacheKey(n,o,i,s),this.generateTargetForCacheKey(a)];return c&&c!==e.AuthenticationScheme.BEARER&&u.push(c.toLowerCase()),u.join(b.CACHE_KEY_SEPARATOR).toLowerCase()},t.generateAccountIdForCacheKey=function(e,t){return[e,t].join(b.CACHE_KEY_SEPARATOR).toLowerCase()},t.generateCredentialIdForCacheKey=function(e,t,r,n){return[e,e===O.REFRESH_TOKEN&&n||t,r||""].join(b.CACHE_KEY_SEPARATOR).toLowerCase()},t.generateTargetForCacheKey=function(e){return(e||"").toLowerCase()},t}(),se={redirectUriNotSet:{code:"redirect_uri_empty",desc:"A redirect URI is required for all calls, and none has been set."},postLogoutUriNotSet:{code:"post_logout_uri_empty",desc:"A post logout redirect has not been set."},claimsRequestParsingError:{code:"claims_request_parsing_error",desc:"Could not parse the given claims request object."},authorityUriInsecure:{code:"authority_uri_insecure",desc:"Authority URIs must use https. Please see here for valid authority configuration options: https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-js-initializing-client-applications#configuration-options"},urlParseError:{code:"url_parse_error",desc:"URL could not be parsed into appropriate segments."},urlEmptyError:{code:"empty_url_error",desc:"URL was empty or null."},emptyScopesError:{code:"empty_input_scopes_error",desc:"Scopes cannot be passed as null, undefined or empty array because they are required to obtain an access token."},nonArrayScopesError:{code:"nonarray_input_scopes_error",desc:"Scopes cannot be passed as non-array."},clientIdSingleScopeError:{code:"clientid_input_scopes_error",desc:"Client ID can only be provided as a single scope."},invalidPrompt:{code:"invalid_prompt_value",desc:"Supported prompt values are 'login', 'select_account', 'consent', 'create' and 'none'. Please see here for valid configuration options: https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_common.html#commonauthorizationurlrequest"},invalidClaimsRequest:{code:"invalid_claims",desc:"Given claims parameter must be a stringified JSON object."},tokenRequestEmptyError:{code:"token_request_empty",desc:"Token request was empty and not found in cache."},logoutRequestEmptyError:{code:"logout_request_empty",desc:"The logout request was null or undefined."},invalidCodeChallengeMethod:{code:"invalid_code_challenge_method",desc:'code_challenge_method passed is invalid. Valid values are "plain" and "S256".'},invalidCodeChallengeParams:{code:"pkce_params_missing",desc:"Both params: code_challenge and code_challenge_method are to be passed if to be sent in the request"},invalidCloudDiscoveryMetadata:{code:"invalid_cloud_discovery_metadata",desc:"Invalid cloudDiscoveryMetadata provided. Must be a stringified JSON object containing tenant_discovery_endpoint and metadata fields"},invalidAuthorityMetadata:{code:"invalid_authority_metadata",desc:"Invalid authorityMetadata provided. Must by a stringified JSON object containing authorization_endpoint, token_endpoint, issuer fields."},untrustedAuthority:{code:"untrusted_authority",desc:"The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter."},missingSshJwk:{code:"missing_ssh_jwk",desc:"Missing sshJwk in SSH certificate request. A stringified JSON Web Key is required when using the SSH authentication scheme."},missingSshKid:{code:"missing_ssh_kid",desc:"Missing sshKid in SSH certificate request. A string that uniquely identifies the public SSH key is required when using the SSH authentication scheme."},missingNonceAuthenticationHeader:{code:"missing_nonce_authentication_header",desc:"Unable to find an authentication header containing server nonce. Either the Authentication-Info or WWW-Authenticate headers must be present in order to obtain a server nonce."},invalidAuthenticationHeader:{code:"invalid_authentication_header",desc:"Invalid authentication header provided"}},ce=function(e){function t(r,n){var o=e.call(this,r,n)||this;return o.name="ClientConfigurationError",Object.setPrototypeOf(o,t.prototype),o}return u(t,e),t.createRedirectUriEmptyError=function(){return new t(se.redirectUriNotSet.code,se.redirectUriNotSet.desc)},t.createPostLogoutRedirectUriEmptyError=function(){return new t(se.postLogoutUriNotSet.code,se.postLogoutUriNotSet.desc)},t.createClaimsRequestParsingError=function(e){return new t(se.claimsRequestParsingError.code,se.claimsRequestParsingError.desc+" Given value: "+e)},t.createInsecureAuthorityUriError=function(e){return new t(se.authorityUriInsecure.code,se.authorityUriInsecure.desc+" Given URI: "+e)},t.createUrlParseError=function(e){return new t(se.urlParseError.code,se.urlParseError.desc+" Given Error: "+e)},t.createUrlEmptyError=function(){return new t(se.urlEmptyError.code,se.urlEmptyError.desc)},t.createEmptyScopesArrayError=function(){return new t(se.emptyScopesError.code,""+se.emptyScopesError.desc)},t.createClientIdSingleScopeError=function(e){return new t(se.clientIdSingleScopeError.code,se.clientIdSingleScopeError.desc+" Given Scopes: "+e)},t.createInvalidPromptError=function(e){return new t(se.invalidPrompt.code,se.invalidPrompt.desc+" Given value: "+e)},t.createInvalidClaimsRequestError=function(){return new t(se.invalidClaimsRequest.code,se.invalidClaimsRequest.desc)},t.createEmptyLogoutRequestError=function(){return new t(se.logoutRequestEmptyError.code,se.logoutRequestEmptyError.desc)},t.createEmptyTokenRequestError=function(){return new t(se.tokenRequestEmptyError.code,se.tokenRequestEmptyError.desc)},t.createInvalidCodeChallengeMethodError=function(){return new t(se.invalidCodeChallengeMethod.code,se.invalidCodeChallengeMethod.desc)},t.createInvalidCodeChallengeParamsError=function(){return new t(se.invalidCodeChallengeParams.code,se.invalidCodeChallengeParams.desc)},t.createInvalidCloudDiscoveryMetadataError=function(){return new t(se.invalidCloudDiscoveryMetadata.code,se.invalidCloudDiscoveryMetadata.desc)},t.createInvalidAuthorityMetadataError=function(){return new t(se.invalidAuthorityMetadata.code,se.invalidAuthorityMetadata.desc)},t.createUntrustedAuthorityError=function(){return new t(se.untrustedAuthority.code,se.untrustedAuthority.desc)},t.createMissingSshJwkError=function(){return new t(se.missingSshJwk.code,se.missingSshJwk.desc)},t.createMissingSshKidError=function(){return new t(se.missingSshKid.code,se.missingSshKid.desc)},t.createMissingNonceAuthenticationHeadersError=function(){return new t(se.missingNonceAuthenticationHeader.code,se.missingNonceAuthenticationHeader.desc)},t.createInvalidAuthenticationHeaderError=function(e,r){return new t(se.invalidAuthenticationHeader.code,se.invalidAuthenticationHeader.desc+". Invalid header: "+e+". Details: "+r)},t}(te),ue=function(){function e(e){var t=this,r=e?re.trimArrayEntries(p(e)):[],n=r?re.removeEmptyStringsFromArray(r):[];this.validateInputScopes(n),this.scopes=new Set,n.forEach((function(e){return t.scopes.add(e)}))}return e.fromString=function(t){return new e((t||"").split(" "))},e.prototype.validateInputScopes=function(e){if(!e||e.length<1)throw ce.createEmptyScopesArrayError()},e.prototype.containsScope=function(t){var r=new e(this.printScopesLowerCase().split(" "));return!re.isEmpty(t)&&r.scopes.has(t.toLowerCase())},e.prototype.containsScopeSet=function(e){var t=this;return!(!e||e.scopes.size<=0)&&this.scopes.size>=e.scopes.size&&e.asArray().every((function(e){return t.containsScope(e)}))},e.prototype.containsOnlyOIDCScopes=function(){var e=this,t=0;return S.forEach((function(r){e.containsScope(r)&&(t+=1)})),this.scopes.size===t},e.prototype.appendScope=function(e){re.isEmpty(e)||this.scopes.add(e.trim())},e.prototype.appendScopes=function(e){var t=this;try{e.forEach((function(e){return t.appendScope(e)}))}catch(e){throw te.createAppendScopeSetError(e)}},e.prototype.removeScope=function(e){if(re.isEmpty(e))throw te.createRemoveEmptyScopeFromSetError(e);this.scopes.delete(e.trim())},e.prototype.removeOIDCScopes=function(){var e=this;S.forEach((function(t){e.scopes.delete(t)}))},e.prototype.unionScopeSets=function(e){if(!e)throw te.createEmptyInputScopeSetError();var t=new Set;return e.scopes.forEach((function(e){return t.add(e.toLowerCase())})),this.scopes.forEach((function(e){return t.add(e.toLowerCase())})),t},e.prototype.intersectingScopeSets=function(e){if(!e)throw te.createEmptyInputScopeSetError();e.containsOnlyOIDCScopes()||e.removeOIDCScopes();var t=this.unionScopeSets(e),r=e.getScopeCount(),n=this.getScopeCount();return t.size<n+r},e.prototype.getScopeCount=function(){return this.scopes.size},e.prototype.asArray=function(){var e=[];return this.scopes.forEach((function(t){return e.push(t)})),e},e.prototype.printScopes=function(){return this.scopes?this.asArray().join(" "):""},e.prototype.printScopesLowerCase=function(){return this.printScopes().toLowerCase()},e}();function le(e,t){if(re.isEmpty(e))throw te.createClientInfoEmptyError();try{var r=t.base64Decode(e);return JSON.parse(r)}catch(e){throw te.createClientInfoDecodingError(e)}}function de(e){if(re.isEmpty(e))throw te.createClientInfoDecodingError("Home account ID was empty.");var t=e.split(b.CLIENT_INFO_SEPARATOR,2);return{uid:t[0],utid:t.length<2?m.EMPTY_STRING:t[1]}}!function(e){e[e.Default=0]="Default",e[e.Adfs=1]="Adfs"}(ne||(ne={}));var he,pe=function(){function e(){}return e.prototype.generateAccountId=function(){return[this.homeAccountId,this.environment].join(b.CACHE_KEY_SEPARATOR).toLowerCase()},e.prototype.generateAccountKey=function(){return e.generateAccountCacheKey({homeAccountId:this.homeAccountId,environment:this.environment,tenantId:this.realm,username:this.username,localAccountId:this.localAccountId})},e.prototype.generateType=function(){switch(this.authorityType){case _.ADFS_ACCOUNT_TYPE:return N.ADFS;case _.MSAV1_ACCOUNT_TYPE:return N.MSA;case _.MSSTS_ACCOUNT_TYPE:return N.MSSTS;case _.GENERIC_ACCOUNT_TYPE:return N.GENERIC;default:throw te.createUnexpectedAccountTypeError()}},e.prototype.getAccountInfo=function(){return{homeAccountId:this.homeAccountId,environment:this.environment,tenantId:this.realm,username:this.username,localAccountId:this.localAccountId,name:this.name,idTokenClaims:this.idTokenClaims}},e.generateAccountCacheKey=function(e){return[e.homeAccountId,e.environment||"",e.tenantId||""].join(b.CACHE_KEY_SEPARATOR).toLowerCase()},e.createAccount=function(t,r,n,o,i,a,s,c){var u,l,d,h,p,f,g=new e;g.authorityType=_.MSSTS_ACCOUNT_TYPE,g.clientInfo=t,g.homeAccountId=r;var y=c||o&&o.getPreferredCache();if(!y)throw te.createInvalidCacheEnvironmentError();return g.environment=y,g.realm=(null===(u=null==n?void 0:n.claims)||void 0===u?void 0:u.tid)||"",g.oboAssertion=i,n&&(g.idTokenClaims=n.claims,g.localAccountId=(null===(l=null==n?void 0:n.claims)||void 0===l?void 0:l.oid)||(null===(d=null==n?void 0:n.claims)||void 0===d?void 0:d.sub)||"",g.username=(null===(h=null==n?void 0:n.claims)||void 0===h?void 0:h.preferred_username)||((null===(p=null==n?void 0:n.claims)||void 0===p?void 0:p.emails)?n.claims.emails[0]:""),g.name=null===(f=null==n?void 0:n.claims)||void 0===f?void 0:f.name),g.cloudGraphHostName=a,g.msGraphHost=s,g},e.createGenericAccount=function(t,r,n,o,i,a,s){var c,u,l,d,h=new e;h.authorityType=n&&n.authorityType===ne.Adfs?_.ADFS_ACCOUNT_TYPE:_.GENERIC_ACCOUNT_TYPE,h.homeAccountId=t,h.realm="",h.oboAssertion=o;var p=s||n&&n.getPreferredCache();if(!p)throw te.createInvalidCacheEnvironmentError();return r&&(h.localAccountId=(null===(c=null==r?void 0:r.claims)||void 0===c?void 0:c.oid)||(null===(u=null==r?void 0:r.claims)||void 0===u?void 0:u.sub)||"",h.username=(null===(l=null==r?void 0:r.claims)||void 0===l?void 0:l.upn)||"",h.name=(null===(d=null==r?void 0:r.claims)||void 0===d?void 0:d.name)||"",h.idTokenClaims=null==r?void 0:r.claims),h.environment=p,h.cloudGraphHostName=i,h.msGraphHost=a,h},e.generateHomeAccountId=function(e,t,r,n,o){var i,a=(null===(i=null==o?void 0:o.claims)||void 0===i?void 0:i.sub)?o.claims.sub:m.EMPTY_STRING;if(t===ne.Adfs)return a;if(e)try{var s=le(e,n);if(!re.isEmpty(s.uid)&&!re.isEmpty(s.utid))return""+s.uid+b.CLIENT_INFO_SEPARATOR+s.utid}catch(e){}return r.verbose("No client info in response"),a},e.isAccountEntity=function(e){return!!e&&e.hasOwnProperty("homeAccountId")&&e.hasOwnProperty("environment")&&e.hasOwnProperty("realm")&&e.hasOwnProperty("localAccountId")&&e.hasOwnProperty("username")&&e.hasOwnProperty("authorityType")},e.accountInfoIsEqual=function(e,t,r){if(!e||!t)return!1;var n=!0;if(r){var o=e.idTokenClaims||{},i=t.idTokenClaims||{};n=o.iat===i.iat&&o.nonce===i.nonce}return e.homeAccountId===t.homeAccountId&&e.localAccountId===t.localAccountId&&e.username===t.username&&e.tenantId===t.tenantId&&e.environment===t.environment&&n},e}(),fe=function(){function e(t,r){if(re.isEmpty(t))throw te.createTokenNullOrEmptyError(t);this.rawToken=t,this.claims=e.extractTokenClaims(t,r)}return e.extractTokenClaims=function(e,t){var r=re.decodeAuthToken(e);try{var n=r.JWSPayload,o=t.base64Decode(n);return JSON.parse(o)}catch(e){throw te.createTokenParsingError(e)}},e}(),ge=function(){function t(e,t){this.clientId=e,this.cryptoImpl=t}return t.prototype.getAllAccounts=function(){var e=this,r=this.getAccountsFilteredBy(),n=Object.keys(r).map((function(e){return r[e]}));return n.length<1?[]:n.map((function(r){var n=t.toObject(new pe,r).getAccountInfo(),o=e.readIdTokenFromCache(e.clientId,n);return o&&!n.idTokenClaims&&(n.idTokenClaims=new fe(o.secret,e.cryptoImpl).claims),n}))},t.prototype.saveCacheRecord=function(e){return d(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:if(!e)throw te.createNullOrUndefinedCacheRecord();return e.account&&this.setAccount(e.account),e.idToken&&this.setIdTokenCredential(e.idToken),e.accessToken?[4,this.saveAccessToken(e.accessToken)]:[3,2];case 1:t.sent(),t.label=2;case 2:return e.refreshToken&&this.setRefreshTokenCredential(e.refreshToken),e.appMetadata&&this.setAppMetadata(e.appMetadata),[2]}}))}))},t.prototype.saveAccessToken=function(e){return d(this,void 0,void 0,(function(){var t,r,n,o,i=this;return h(this,(function(a){switch(a.label){case 0:return t=this.getCredentialsFilteredBy({clientId:e.clientId,credentialType:e.credentialType,environment:e.environment,homeAccountId:e.homeAccountId,realm:e.realm,tokenType:e.tokenType}),r=ue.fromString(e.target),(n=Object.keys(t.accessTokens).map((function(e){return t.accessTokens[e]})))?(o=[],n.forEach((function(e){ue.fromString(e.target).intersectingScopeSets(r)&&o.push(i.removeCredential(e))})),[4,Promise.all(o)]):[3,2];case 1:a.sent(),a.label=2;case 2:return this.setAccessTokenCredential(e),[2]}}))}))},t.prototype.getAccountsFilteredBy=function(e){return this.getAccountsFilteredByInternal(e?e.homeAccountId:"",e?e.environment:"",e?e.realm:"")},t.prototype.getAccountsFilteredByInternal=function(e,t,r){var n=this,o=this.getKeys(),i={};return o.forEach((function(o){var a=n.getAccount(o);a&&(e&&!n.matchHomeAccountId(a,e)||t&&!n.matchEnvironment(a,t)||r&&!n.matchRealm(a,r)||(i[o]=a))})),i},t.prototype.getCredentialsFilteredBy=function(e){return this.getCredentialsFilteredByInternal(e.homeAccountId,e.environment,e.credentialType,e.clientId,e.familyId,e.realm,e.target,e.oboAssertion,e.tokenType,e.keyId)},t.prototype.getCredentialsFilteredByInternal=function(t,r,n,o,i,a,s,c,u,l){var d=this,h=this.getKeys(),p={idTokens:{},accessTokens:{},refreshTokens:{}};return h.forEach((function(h){var f=ae.getCredentialType(h);if(f!==m.NOT_DEFINED){var g=d.getSpecificCredential(h,f);if(g&&(!c||d.matchOboAssertion(g,c))&&(!t||d.matchHomeAccountId(g,t))&&(!r||d.matchEnvironment(g,r))&&(!a||d.matchRealm(g,a))&&(!n||d.matchCredentialType(g,n))&&(!o||d.matchClientId(g,o))&&(!i||d.matchFamilyId(g,i))&&(!s||d.matchTarget(g,s))){if(n===O.ACCESS_TOKEN_WITH_AUTH_SCHEME){if(u&&!d.matchTokenType(g,u))return;switch(u){case e.AuthenticationScheme.POP:if(-1===h.indexOf(e.AuthenticationScheme.POP))return void d.removeItem(h,R.CREDENTIAL);break;case e.AuthenticationScheme.SSH:if(l&&!d.matchKeyId(g,l))return}}switch(f){case O.ID_TOKEN:p.idTokens[h]=g;break;case O.ACCESS_TOKEN:case O.ACCESS_TOKEN_WITH_AUTH_SCHEME:p.accessTokens[h]=g;break;case O.REFRESH_TOKEN:p.refreshTokens[h]=g}}}})),p},t.prototype.getAppMetadataFilteredBy=function(e){return this.getAppMetadataFilteredByInternal(e.environment,e.clientId)},t.prototype.getAppMetadataFilteredByInternal=function(e,t){var r=this,n=this.getKeys(),o={};return n.forEach((function(n){if(r.isAppMetadata(n)){var i=r.getAppMetadata(n);i&&(e&&!r.matchEnvironment(i,e)||t&&!r.matchClientId(i,t)||(o[n]=i))}})),o},t.prototype.getAuthorityMetadataByAlias=function(e){var t=this,r=this.getAuthorityMetadataKeys(),n=null;return r.forEach((function(r){if(t.isAuthorityMetadata(r)&&-1!==r.indexOf(t.clientId)){var o=t.getAuthorityMetadata(r);o&&-1!==o.aliases.indexOf(e)&&(n=o)}})),n},t.prototype.removeAllAccounts=function(){return d(this,void 0,void 0,(function(){var e,t,r=this;return h(this,(function(n){switch(n.label){case 0:return e=this.getKeys(),t=[],e.forEach((function(e){r.getAccount(e)&&t.push(r.removeAccount(e))})),[4,Promise.all(t)];case 1:return n.sent(),[2,!0]}}))}))},t.prototype.removeAccount=function(e){return d(this,void 0,void 0,(function(){var t;return h(this,(function(r){switch(r.label){case 0:if(!(t=this.getAccount(e)))throw te.createNoAccountFoundError();return[4,this.removeAccountContext(t)];case 1:return[2,r.sent()&&this.removeItem(e,R.ACCOUNT)]}}))}))},t.prototype.removeAccountContext=function(e){return d(this,void 0,void 0,(function(){var t,r,n,o=this;return h(this,(function(i){switch(i.label){case 0:return t=this.getKeys(),r=e.generateAccountId(),n=[],t.forEach((function(e){var t=ae.getCredentialType(e);if(t!==m.NOT_DEFINED){var i=o.getSpecificCredential(e,t);i&&r===i.generateAccountId()&&n.push(o.removeCredential(i))}})),[4,Promise.all(n)];case 1:return i.sent(),[2,!0]}}))}))},t.prototype.removeCredential=function(t){return d(this,void 0,void 0,(function(){var r,n;return h(this,(function(o){switch(o.label){case 0:if(r=t.generateCredentialKey(),t.credentialType.toLowerCase()!==O.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())return[3,4];if(t.tokenType!==e.AuthenticationScheme.POP)return[3,4];if(!(n=t.keyId))return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.cryptoImpl.removeTokenBindingKey(n)];case 2:return o.sent(),[3,4];case 3:throw o.sent(),te.createBindingKeyNotRemovedError();case 4:return[2,this.removeItem(r,R.CREDENTIAL)]}}))}))},t.prototype.removeAppMetadata=function(){var e=this;return this.getKeys().forEach((function(t){e.isAppMetadata(t)&&e.removeItem(t,R.APP_METADATA)})),!0},t.prototype.readCacheRecord=function(e,t,r,n,o,i){var a=this.readAccountFromCache(e),s=this.readIdTokenFromCache(t,e),c=this.readAccessTokenFromCache(t,e,r,o,i),u=this.readRefreshTokenFromCache(t,e,!1),l=this.readAppMetadataFromCache(n,t);return a&&s&&(a.idTokenClaims=new fe(s.secret,this.cryptoImpl).claims),{account:a,idToken:s,accessToken:c,refreshToken:u,appMetadata:l}},t.prototype.readAccountFromCache=function(e){var t=pe.generateAccountCacheKey(e);return this.getAccount(t)},t.prototype.readIdTokenFromCache=function(e,t){var r={homeAccountId:t.homeAccountId,environment:t.environment,credentialType:O.ID_TOKEN,clientId:e,realm:t.tenantId},n=this.getCredentialsFilteredBy(r),o=Object.keys(n.idTokens).map((function(e){return n.idTokens[e]})),i=o.length;if(i<1)return null;if(i>1)throw te.createMultipleMatchingTokensInCacheError();return o[0]},t.prototype.readAccessTokenFromCache=function(t,r,n,o,i){var a=o&&o!==e.AuthenticationScheme.BEARER?O.ACCESS_TOKEN_WITH_AUTH_SCHEME:O.ACCESS_TOKEN,s={homeAccountId:r.homeAccountId,environment:r.environment,credentialType:a,clientId:t,realm:r.tenantId,target:n.printScopesLowerCase(),tokenType:o,keyId:i},c=this.getCredentialsFilteredBy(s),u=Object.keys(c.accessTokens).map((function(e){return c.accessTokens[e]})),l=u.length;if(l<1)return null;if(l>1)throw te.createMultipleMatchingTokensInCacheError();return u[0]},t.prototype.readRefreshTokenFromCache=function(e,t,r){var n=r?D:void 0,o={homeAccountId:t.homeAccountId,environment:t.environment,credentialType:O.REFRESH_TOKEN,clientId:e,familyId:n},i=this.getCredentialsFilteredBy(o),a=Object.keys(i.refreshTokens).map((function(e){return i.refreshTokens[e]}));return a.length<1?null:a[0]},t.prototype.readAppMetadataFromCache=function(e,t){var r={environment:e,clientId:t},n=this.getAppMetadataFilteredBy(r),o=Object.keys(n).map((function(e){return n[e]})),i=o.length;if(i<1)return null;if(i>1)throw te.createMultipleMatchingAppMetadataInCacheError();return o[0]},t.prototype.isAppMetadataFOCI=function(e,t){var r=this.readAppMetadataFromCache(e,t);return!(!r||r.familyId!==D)},t.prototype.matchHomeAccountId=function(e,t){return!(!e.homeAccountId||t!==e.homeAccountId)},t.prototype.matchOboAssertion=function(e,t){return!(!e.oboAssertion||t!==e.oboAssertion)},t.prototype.matchEnvironment=function(e,t){var r=this.getAuthorityMetadataByAlias(t);return!!(r&&r.aliases.indexOf(e.environment)>-1)},t.prototype.matchCredentialType=function(e,t){return e.credentialType&&t.toLowerCase()===e.credentialType.toLowerCase()},t.prototype.matchClientId=function(e,t){return!(!e.clientId||t!==e.clientId)},t.prototype.matchFamilyId=function(e,t){return!(!e.familyId||t!==e.familyId)},t.prototype.matchRealm=function(e,t){return!(!e.realm||t!==e.realm)},t.prototype.matchTarget=function(e,t){if(e.credentialType!==O.ACCESS_TOKEN&&e.credentialType!==O.ACCESS_TOKEN_WITH_AUTH_SCHEME||!e.target)return!1;var r=ue.fromString(e.target),n=ue.fromString(t);return n.containsOnlyOIDCScopes()?n.removeScope(m.OFFLINE_ACCESS_SCOPE):n.removeOIDCScopes(),r.containsScopeSet(n)},t.prototype.matchTokenType=function(e,t){return!(!e.tokenType||e.tokenType!==t)},t.prototype.matchKeyId=function(e,t){return!(!e.keyId||e.keyId!==t)},t.prototype.isAppMetadata=function(e){return-1!==e.indexOf(U)},t.prototype.isAuthorityMetadata=function(e){return-1!==e.indexOf(L)},t.prototype.generateAuthorityMetadataCacheKey=function(e){return L+"-"+this.clientId+"-"+e},t.prototype.getSpecificCredential=function(e,t){switch(t){case O.ID_TOKEN:return this.getIdTokenCredential(e);case O.ACCESS_TOKEN:case O.ACCESS_TOKEN_WITH_AUTH_SCHEME:return this.getAccessTokenCredential(e);case O.REFRESH_TOKEN:return this.getRefreshTokenCredential(e);default:return null}},t.toObject=function(e,t){for(var r in t)e[r]=t[r];return e},t}(),ye=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.setAccount=function(){throw X.createUnexpectedError("Storage interface - setAccount() has not been implemented for the cacheStorage interface.")},t.prototype.getAccount=function(){throw X.createUnexpectedError("Storage interface - getAccount() has not been implemented for the cacheStorage interface.")},t.prototype.setIdTokenCredential=function(){throw X.createUnexpectedError("Storage interface - setIdTokenCredential() has not been implemented for the cacheStorage interface.")},t.prototype.getIdTokenCredential=function(){throw X.createUnexpectedError("Storage interface - getIdTokenCredential() has not been implemented for the cacheStorage interface.")},t.prototype.setAccessTokenCredential=function(){throw X.createUnexpectedError("Storage interface - setAccessTokenCredential() has not been implemented for the cacheStorage interface.")},t.prototype.getAccessTokenCredential=function(){throw X.createUnexpectedError("Storage interface - getAccessTokenCredential() has not been implemented for the cacheStorage interface.")},t.prototype.setRefreshTokenCredential=function(){throw X.createUnexpectedError("Storage interface - setRefreshTokenCredential() has not been implemented for the cacheStorage interface.")},t.prototype.getRefreshTokenCredential=function(){throw X.createUnexpectedError("Storage interface - getRefreshTokenCredential() has not been implemented for the cacheStorage interface.")},t.prototype.setAppMetadata=function(){throw X.createUnexpectedError("Storage interface - setAppMetadata() has not been implemented for the cacheStorage interface.")},t.prototype.getAppMetadata=function(){throw X.createUnexpectedError("Storage interface - getAppMetadata() has not been implemented for the cacheStorage interface.")},t.prototype.setServerTelemetry=function(){throw X.createUnexpectedError("Storage interface - setServerTelemetry() has not been implemented for the cacheStorage interface.")},t.prototype.getServerTelemetry=function(){throw X.createUnexpectedError("Storage interface - getServerTelemetry() has not been implemented for the cacheStorage interface.")},t.prototype.setAuthorityMetadata=function(){throw X.createUnexpectedError("Storage interface - setAuthorityMetadata() has not been implemented for the cacheStorage interface.")},t.prototype.getAuthorityMetadata=function(){throw X.createUnexpectedError("Storage interface - getAuthorityMetadata() has not been implemented for the cacheStorage interface.")},t.prototype.getAuthorityMetadataKeys=function(){throw X.createUnexpectedError("Storage interface - getAuthorityMetadataKeys() has not been implemented for the cacheStorage interface.")},t.prototype.setThrottlingCache=function(){throw X.createUnexpectedError("Storage interface - setThrottlingCache() has not been implemented for the cacheStorage interface.")},t.prototype.getThrottlingCache=function(){throw X.createUnexpectedError("Storage interface - getThrottlingCache() has not been implemented for the cacheStorage interface.")},t.prototype.removeItem=function(){throw X.createUnexpectedError("Storage interface - removeItem() has not been implemented for the cacheStorage interface.")},t.prototype.containsKey=function(){throw X.createUnexpectedError("Storage interface - containsKey() has not been implemented for the cacheStorage interface.")},t.prototype.getKeys=function(){throw X.createUnexpectedError("Storage interface - getKeys() has not been implemented for the cacheStorage interface.")},t.prototype.clear=function(){return d(this,void 0,void 0,(function(){return h(this,(function(e){throw X.createUnexpectedError("Storage interface - clear() has not been implemented for the cacheStorage interface.")}))}))},t}(ge),ve={tokenRenewalOffsetSeconds:300,preventCorsPreflight:!1},Ee={loggerCallback:function(){},piiLoggingEnabled:!1,logLevel:e.LogLevel.Info,correlationId:""},me={sendGetRequestAsync:function(){return d(this,void 0,void 0,(function(){return h(this,(function(e){throw X.createUnexpectedError("Network interface - sendGetRequestAsync() has not been implemented")}))}))},sendPostRequestAsync:function(){return d(this,void 0,void 0,(function(){return h(this,(function(e){throw X.createUnexpectedError("Network interface - sendPostRequestAsync() has not been implemented")}))}))}},Ce={sku:m.SKU,version:ie,cpu:"",os:""},Se={clientSecret:"",clientAssertion:void 0},Ie=function(e){function t(r,n,o){var i=e.call(this,r,n,o)||this;return i.name="ServerError",Object.setPrototypeOf(i,t.prototype),i}return u(t,e),t}(X),we=function(){function e(){}return e.generateThrottlingStorageKey=function(e){return V+"."+JSON.stringify(e)},e.preProcess=function(t,r){var n,o=e.generateThrottlingStorageKey(r),i=t.getThrottlingCache(o);if(i){if(i.throttleTime<Date.now())return void t.removeItem(o,R.THROTTLING);throw new Ie((null===(n=i.errorCodes)||void 0===n?void 0:n.join(" "))||m.EMPTY_STRING,i.errorMessage,i.subError)}},e.postProcess=function(t,r,n){if(e.checkResponseStatus(n)||e.checkResponseForRetryAfter(n)){var o={throttleTime:e.calculateThrottleTime(parseInt(n.headers[f.RETRY_AFTER])),error:n.body.error,errorCodes:n.body.error_codes,errorMessage:n.body.error_description,subError:n.body.suberror};t.setThrottlingCache(e.generateThrottlingStorageKey(r),o)}},e.checkResponseStatus=function(e){return 429===e.status||e.status>=500&&e.status<600},e.checkResponseForRetryAfter=function(e){return!!e.headers&&e.headers.hasOwnProperty(f.RETRY_AFTER)&&(e.status<200||e.status>=300)},e.calculateThrottleTime=function(e){var t=e<=0?0:e,r=Date.now()/1e3;return Math.floor(1e3*Math.min(r+(t||G),r+W))},e.removeThrottle=function(e,t,r,n){var o={clientId:t,authority:r.authority,scopes:r.scopes,homeAccountIdentifier:n,authenticationScheme:r.authenticationScheme,resourceRequestMethod:r.resourceRequestMethod,resourceRequestUri:r.resourceRequestUri,shrClaims:r.shrClaims,sshJwk:r.sshJwk,sshKid:r.sshKid},i=this.generateThrottlingStorageKey(o);return e.removeItem(i,R.THROTTLING)},e}(),Te=function(){function e(e,t){this.networkClient=e,this.cacheManager=t}return e.prototype.sendPostRequest=function(e,t,r){return d(this,void 0,void 0,(function(){var n,o;return h(this,(function(i){switch(i.label){case 0:we.preProcess(this.cacheManager,e),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.networkClient.sendPostRequestAsync(t,r)];case 2:return n=i.sent(),[3,4];case 3:throw(o=i.sent())instanceof X?o:te.createNetworkError(t,o);case 4:return we.postProcess(this.cacheManager,e,n),[2,n]}}))}))},e}();!function(e){e.HOME_ACCOUNT_ID="home_account_id",e.UPN="UPN"}(he||(he={}));var Ae,_e=function(){function e(e){var t,r,n,o,i,a,s,c,u,d,h,p,f,g;this.config=(n=(t=e).authOptions,o=t.systemOptions,i=t.loggerOptions,a=t.storageInterface,s=t.networkInterface,c=t.cryptoInterface,u=t.clientCredentials,d=t.libraryInfo,h=t.serverTelemetryManager,p=t.persistencePlugin,f=t.serializableCache,g=l(l({},Ee),i),{authOptions:(r=n,l({clientCapabilities:[]},r)),systemOptions:l(l({},ve),o),loggerOptions:g,storageInterface:a||new ye(n.clientId,Z),networkInterface:s||me,cryptoInterface:c||Z,clientCredentials:u||Se,libraryInfo:l(l({},Ce),d),serverTelemetryManager:h||null,persistencePlugin:p||null,serializableCache:f||null}),this.logger=new oe(this.config.loggerOptions,"@azure/msal-common",ie),this.cryptoUtils=this.config.cryptoInterface,this.cacheManager=this.config.storageInterface,this.networkClient=this.config.networkInterface,this.networkManager=new Te(this.networkClient,this.cacheManager),this.serverTelemetryManager=this.config.serverTelemetryManager,this.authority=this.config.authOptions.authority}return e.prototype.createTokenRequestHeaders=function(e){var t={};if(t[f.CONTENT_TYPE]=m.URL_FORM_CONTENT_TYPE,!this.config.systemOptions.preventCorsPreflight&&e)switch(e.type){case he.HOME_ACCOUNT_ID:try{var r=de(e.credential);t[f.CCS_HEADER]="Oid:"+r.uid+"@"+r.utid}catch(e){this.logger.verbose("Could not parse home account ID for CCS Header: "+e)}break;case he.UPN:t[f.CCS_HEADER]="UPN: "+e.credential}return t},e.prototype.executePostToTokenEndpoint=function(e,t,r,n){return d(this,void 0,void 0,(function(){var o;return h(this,(function(i){switch(i.label){case 0:return[4,this.networkManager.sendPostRequest(n,e,{body:t,headers:r})];case 1:return o=i.sent(),this.config.serverTelemetryManager&&o.status<500&&429!==o.status&&this.config.serverTelemetryManager.clearTelemetryCache(),[2,o]}}))}))},e.prototype.updateAuthority=function(e){if(!e.discoveryComplete())throw te.createEndpointDiscoveryIncompleteError("Updated authority has not completed endpoint discovery.");this.authority=e},e}(),be=function(){function e(){}return e.validateRedirectUri=function(e){if(re.isEmpty(e))throw ce.createRedirectUriEmptyError()},e.validatePrompt=function(e){var t=[];for(var r in w)t.push(w[r]);if(t.indexOf(e)<0)throw ce.createInvalidPromptError(e)},e.validateClaims=function(e){try{JSON.parse(e)}catch(e){throw ce.createInvalidClaimsRequestError()}},e.validateCodeChallengeParams=function(e,t){if(re.isEmpty(e)||re.isEmpty(t))throw ce.createInvalidCodeChallengeParamsError();this.validateCodeChallengeMethod(t)},e.validateCodeChallengeMethod=function(e){if([P.PLAIN,P.S256].indexOf(e)<0)throw ce.createInvalidCodeChallengeMethodError()},e.sanitizeEQParams=function(e,t){return e?(t.forEach((function(t,r){e[r]&&delete e[r]})),e):{}},e}(),Oe=function(){function t(){this.parameters=new Map}return t.prototype.addResponseTypeCode=function(){this.parameters.set(v.RESPONSE_TYPE,encodeURIComponent(m.CODE_RESPONSE_TYPE))},t.prototype.addResponseMode=function(e){this.parameters.set(v.RESPONSE_MODE,encodeURIComponent(e||T.QUERY))},t.prototype.addScopes=function(e,t){void 0===t&&(t=!0);var r=t?p(e||[],C):e||[],n=new ue(r);this.parameters.set(v.SCOPE,encodeURIComponent(n.printScopes()))},t.prototype.addClientId=function(e){this.parameters.set(v.CLIENT_ID,encodeURIComponent(e))},t.prototype.addRedirectUri=function(e){be.validateRedirectUri(e),this.parameters.set(v.REDIRECT_URI,encodeURIComponent(e))},t.prototype.addPostLogoutRedirectUri=function(e){be.validateRedirectUri(e),this.parameters.set(v.POST_LOGOUT_URI,encodeURIComponent(e))},t.prototype.addIdTokenHint=function(e){this.parameters.set(v.ID_TOKEN_HINT,encodeURIComponent(e))},t.prototype.addDomainHint=function(e){this.parameters.set(I.DOMAIN_HINT,encodeURIComponent(e))},t.prototype.addLoginHint=function(e){this.parameters.set(I.LOGIN_HINT,encodeURIComponent(e))},t.prototype.addCcsUpn=function(e){this.parameters.set(f.CCS_HEADER,encodeURIComponent("UPN:"+e))},t.prototype.addCcsOid=function(e){this.parameters.set(f.CCS_HEADER,encodeURIComponent("Oid:"+e.uid+"@"+e.utid))},t.prototype.addSid=function(e){this.parameters.set(I.SID,encodeURIComponent(e))},t.prototype.addClaims=function(e,t){var r=this.addClientCapabilitiesToClaims(e,t);be.validateClaims(r),this.parameters.set(v.CLAIMS,encodeURIComponent(r))},t.prototype.addCorrelationId=function(e){this.parameters.set(v.CLIENT_REQUEST_ID,encodeURIComponent(e))},t.prototype.addLibraryInfo=function(e){this.parameters.set(v.X_CLIENT_SKU,e.sku),this.parameters.set(v.X_CLIENT_VER,e.version),this.parameters.set(v.X_CLIENT_OS,e.os),this.parameters.set(v.X_CLIENT_CPU,e.cpu)},t.prototype.addPrompt=function(e){be.validatePrompt(e),this.parameters.set(""+v.PROMPT,encodeURIComponent(e))},t.prototype.addState=function(e){re.isEmpty(e)||this.parameters.set(v.STATE,encodeURIComponent(e))},t.prototype.addNonce=function(e){this.parameters.set(v.NONCE,encodeURIComponent(e))},t.prototype.addCodeChallengeParams=function(e,t){if(be.validateCodeChallengeParams(e,t),!e||!t)throw ce.createInvalidCodeChallengeParamsError();this.parameters.set(v.CODE_CHALLENGE,encodeURIComponent(e)),this.parameters.set(v.CODE_CHALLENGE_METHOD,encodeURIComponent(t))},t.prototype.addAuthorizationCode=function(e){this.parameters.set(v.CODE,encodeURIComponent(e))},t.prototype.addDeviceCode=function(e){this.parameters.set(v.DEVICE_CODE,encodeURIComponent(e))},t.prototype.addRefreshToken=function(e){this.parameters.set(v.REFRESH_TOKEN,encodeURIComponent(e))},t.prototype.addCodeVerifier=function(e){this.parameters.set(v.CODE_VERIFIER,encodeURIComponent(e))},t.prototype.addClientSecret=function(e){this.parameters.set(v.CLIENT_SECRET,encodeURIComponent(e))},t.prototype.addClientAssertion=function(e){this.parameters.set(v.CLIENT_ASSERTION,encodeURIComponent(e))},t.prototype.addClientAssertionType=function(e){this.parameters.set(v.CLIENT_ASSERTION_TYPE,encodeURIComponent(e))},t.prototype.addOboAssertion=function(e){this.parameters.set(v.OBO_ASSERTION,encodeURIComponent(e))},t.prototype.addRequestTokenUse=function(e){this.parameters.set(v.REQUESTED_TOKEN_USE,encodeURIComponent(e))},t.prototype.addGrantType=function(e){this.parameters.set(v.GRANT_TYPE,encodeURIComponent(e))},t.prototype.addClientInfo=function(){this.parameters.set("client_info","1")},t.prototype.addExtraQueryParameters=function(e){var t=this;be.sanitizeEQParams(e,this.parameters),Object.keys(e).forEach((function(r){t.parameters.set(r,e[r])}))},t.prototype.addClientCapabilitiesToClaims=function(e,t){var r;if(e)try{r=JSON.parse(e)}catch(e){throw ce.createInvalidClaimsRequestError()}else r={};return t&&t.length>0&&(r.hasOwnProperty(E.ACCESS_TOKEN)||(r[E.ACCESS_TOKEN]={}),r[E.ACCESS_TOKEN][E.XMS_CC]={values:t}),JSON.stringify(r)},t.prototype.addUsername=function(e){this.parameters.set(x.username,e)},t.prototype.addPassword=function(e){this.parameters.set(x.password,e)},t.prototype.addPopToken=function(t){re.isEmpty(t)||(this.parameters.set(v.TOKEN_TYPE,e.AuthenticationScheme.POP),this.parameters.set(v.REQ_CNF,encodeURIComponent(t)))},t.prototype.addSshJwk=function(t){re.isEmpty(t)||(this.parameters.set(v.TOKEN_TYPE,e.AuthenticationScheme.SSH),this.parameters.set(v.REQ_CNF,encodeURIComponent(t)))},t.prototype.addServerTelemetry=function(e){this.parameters.set(v.X_CLIENT_CURR_TELEM,e.generateCurrentRequestHeaderValue()),this.parameters.set(v.X_CLIENT_LAST_TELEM,e.generateLastRequestHeaderValue())},t.prototype.addThrottling=function(){this.parameters.set(v.X_MS_LIB_CAPABILITY,z)},t.prototype.createQueryString=function(){var e=new Array;return this.parameters.forEach((function(t,r){e.push(r+"="+t)})),e.join("&")},t}(),Re=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.createIdTokenEntity=function(e,r,n,o,i,a){var s=new t;return s.credentialType=O.ID_TOKEN,s.homeAccountId=e,s.environment=r,s.clientId=o,s.secret=n,s.realm=i,s.oboAssertion=a,s},t.isIdTokenEntity=function(e){return!!e&&e.hasOwnProperty("homeAccountId")&&e.hasOwnProperty("environment")&&e.hasOwnProperty("credentialType")&&e.hasOwnProperty("realm")&&e.hasOwnProperty("clientId")&&e.hasOwnProperty("secret")&&e.credentialType===O.ID_TOKEN},t}(ae),Ne=function(){function e(){}return e.nowSeconds=function(){return Math.round((new Date).getTime()/1e3)},e.isTokenExpired=function(t,r){var n=Number(t)||0;return e.nowSeconds()+r>n},e.wasClockTurnedBack=function(t){return Number(t)>e.nowSeconds()},e.delay=function(e,t){return new Promise((function(r){return setTimeout((function(){return r(t)}),e)}))},e}(),Pe=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return u(r,t),r.createAccessTokenEntity=function(t,n,o,i,a,s,c,u,l,d,h,p,f){var g,y=new r;y.homeAccountId=t,y.credentialType=O.ACCESS_TOKEN,y.secret=o;var v=Ne.nowSeconds();if(y.cachedAt=v.toString(),y.expiresOn=c.toString(),y.extendedExpiresOn=u.toString(),d&&(y.refreshOn=d.toString()),y.environment=n,y.clientId=i,y.realm=a,y.target=s,y.oboAssertion=p,y.tokenType=re.isEmpty(h)?e.AuthenticationScheme.BEARER:h,y.tokenType!==e.AuthenticationScheme.BEARER)switch(y.credentialType=O.ACCESS_TOKEN_WITH_AUTH_SCHEME,y.tokenType){case e.AuthenticationScheme.POP:var E=fe.extractTokenClaims(o,l);if(!(null===(g=null==E?void 0:E.cnf)||void 0===g?void 0:g.kid))throw te.createTokenClaimsRequiredError();y.keyId=E.cnf.kid;break;case e.AuthenticationScheme.SSH:y.keyId=f}return y},r.isAccessTokenEntity=function(e){return!!e&&e.hasOwnProperty("homeAccountId")&&e.hasOwnProperty("environment")&&e.hasOwnProperty("credentialType")&&e.hasOwnProperty("realm")&&e.hasOwnProperty("clientId")&&e.hasOwnProperty("secret")&&e.hasOwnProperty("target")&&(e.credentialType===O.ACCESS_TOKEN||e.credentialType===O.ACCESS_TOKEN_WITH_AUTH_SCHEME)},r}(ae),ke=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.createRefreshTokenEntity=function(e,r,n,o,i,a){var s=new t;return s.clientId=o,s.credentialType=O.REFRESH_TOKEN,s.environment=r,s.homeAccountId=e,s.secret=n,s.oboAssertion=a,i&&(s.familyId=i),s},t.isRefreshTokenEntity=function(e){return!!e&&e.hasOwnProperty("homeAccountId")&&e.hasOwnProperty("environment")&&e.hasOwnProperty("credentialType")&&e.hasOwnProperty("clientId")&&e.hasOwnProperty("secret")&&e.credentialType===O.REFRESH_TOKEN},t}(ae),Ue=["interaction_required","consent_required","login_required"],De=["message_only","additional_action","basic_action","user_password_expired","consent_required"],Le={noTokensFoundError:{code:"no_tokens_found",desc:"No refresh token found in the cache. Please sign-in."}},Me=function(e){function t(r,n,o){var i=e.call(this,r,n,o)||this;return i.name="InteractionRequiredAuthError",Object.setPrototypeOf(i,t.prototype),i}return u(t,e),t.isInteractionRequiredError=function(e,t,r){var n=!!e&&Ue.indexOf(e)>-1,o=!!r&&De.indexOf(r)>-1,i=!!t&&Ue.some((function(e){return t.indexOf(e)>-1}));return n||i||o},t.createNoTokensFoundError=function(){return new t(Le.noTokensFoundError.code,Le.noTokensFoundError.desc)},t}(X),Fe=function(e,t,r,n,o){this.account=e||null,this.idToken=t||null,this.accessToken=r||null,this.refreshToken=n||null,this.appMetadata=o||null},He=function(){function e(){}return e.setRequestState=function(t,r,n){var o=e.generateLibraryState(t,n);return re.isEmpty(r)?o:""+o+m.RESOURCE_DELIM+r},e.generateLibraryState=function(e,t){if(!e)throw te.createNoCryptoObjectError("generateLibraryState");var r={id:e.createNewGuid()};t&&(r.meta=t);var n=JSON.stringify(r);return e.base64Encode(n)},e.parseRequestState=function(e,t){if(!e)throw te.createNoCryptoObjectError("parseRequestState");if(re.isEmpty(t))throw te.createInvalidStateError(t,"Null, undefined or empty state");try{var r=t.split(m.RESOURCE_DELIM),n=r[0],o=r.length>1?r.slice(1).join(m.RESOURCE_DELIM):"",i=e.base64Decode(n),a=JSON.parse(i);return{userRequestState:re.isEmpty(o)?"":o,libraryState:a}}catch(e){throw te.createInvalidStateError(t,e)}},e}(),xe=function(){function e(t){if(this._urlString=t,re.isEmpty(this._urlString))throw ce.createUrlEmptyError();re.isEmpty(this.getHash())&&(this._urlString=e.canonicalizeUri(t))}return Object.defineProperty(e.prototype,"urlString",{get:function(){return this._urlString},enumerable:!1,configurable:!0}),e.canonicalizeUri=function(e){if(e){var t=e.toLowerCase();return re.endsWith(t,"?")?t=t.slice(0,-1):re.endsWith(t,"?/")&&(t=t.slice(0,-2)),re.endsWith(t,"/")||(t+="/"),t}return e},e.prototype.validateAsUri=function(){var e;try{e=this.getUrlComponents()}catch(e){throw ce.createUrlParseError(e)}if(!e.HostNameAndPort||!e.PathSegments)throw ce.createUrlParseError("Given url string: "+this.urlString);if(!e.Protocol||"https:"!==e.Protocol.toLowerCase())throw ce.createInsecureAuthorityUriError(this.urlString)},e.appendQueryString=function(e,t){return re.isEmpty(t)?e:e.indexOf("?")<0?e+"?"+t:e+"&"+t},e.removeHashFromUrl=function(t){return e.canonicalizeUri(t.split("#")[0])},e.prototype.replaceTenantPath=function(t){var r=this.getUrlComponents(),n=r.PathSegments;return!t||0===n.length||n[0]!==y.COMMON&&n[0]!==y.ORGANIZATIONS||(n[0]=t),e.constructAuthorityUriFromObject(r)},e.prototype.getHash=function(){return e.parseHash(this.urlString)},e.prototype.getUrlComponents=function(){var e=RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?"),t=this.urlString.match(e);if(!t)throw ce.createUrlParseError("Given url string: "+this.urlString);var r={Protocol:t[1],HostNameAndPort:t[4],AbsolutePath:t[5],QueryString:t[7]},n=r.AbsolutePath.split("/");return n=n.filter((function(e){return e&&e.length>0})),r.PathSegments=n,!re.isEmpty(r.QueryString)&&r.QueryString.endsWith("/")&&(r.QueryString=r.QueryString.substring(0,r.QueryString.length-1)),r},e.getDomainFromUrl=function(e){var t=RegExp("^([^:/?#]+://)?([^/?#]*)"),r=e.match(t);if(!r)throw ce.createUrlParseError("Given url string: "+e);return r[2]},e.getAbsoluteUrl=function(t,r){if(t[0]===m.FORWARD_SLASH){var n=new e(r).getUrlComponents();return n.Protocol+"//"+n.HostNameAndPort+t}return t},e.parseHash=function(e){var t=e.indexOf("#"),r=e.indexOf("#/");return r>-1?e.substring(r+2):t>-1?e.substring(t+1):""},e.constructAuthorityUriFromObject=function(t){return new e(t.Protocol+"//"+t.HostNameAndPort+"/"+t.PathSegments.join("/"))},e.getDeserializedHash=function(t){if(re.isEmpty(t))return{};var r=e.parseHash(t),n=re.queryStringToObject(re.isEmpty(r)?t:r);if(!n)throw te.createHashNotDeserializedError(JSON.stringify(n));return n},e.hashContainsKnownProperties=function(t){if(re.isEmpty(t)||t.indexOf("=")<0)return!1;var r=e.getDeserializedHash(t);return!!(r.code||r.error_description||r.error||r.state)},e}();!function(e){e.SW="sw",e.UHW="uhw"}(Ae||(Ae={}));var qe,Be=function(){function e(e){this.cryptoUtils=e}return e.prototype.generateCnf=function(e){return d(this,void 0,void 0,(function(){var t;return h(this,(function(r){switch(r.label){case 0:return[4,this.generateKid(e)];case 1:return t=r.sent(),[2,this.cryptoUtils.base64Encode(JSON.stringify(t))]}}))}))},e.prototype.generateKid=function(e){return d(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.cryptoUtils.getPublicKeyThumbprint(e)];case 1:return[2,{kid:t.sent(),xms_ksl:Ae.SW}]}}))}))},e.prototype.signPopToken=function(e,t){var r;return d(this,void 0,void 0,(function(){var n;return h(this,(function(o){if(n=fe.extractTokenClaims(e,this.cryptoUtils),!(null===(r=null==n?void 0:n.cnf)||void 0===r?void 0:r.kid))throw te.createTokenClaimsRequiredError();return[2,this.signPayload(e,n.cnf.kid,t)]}))}))},e.prototype.signPayload=function(e,t,r,n){return d(this,void 0,void 0,(function(){var o,i,a,s,c,u;return h(this,(function(d){switch(d.label){case 0:return o=r.resourceRequestMethod,i=r.resourceRequestUri,a=r.shrClaims,s=r.shrNonce,c=i?new xe(i):void 0,u=null==c?void 0:c.getUrlComponents(),[4,this.cryptoUtils.signJwt(l({at:e,ts:Ne.nowSeconds(),m:null==o?void 0:o.toUpperCase(),u:null==u?void 0:u.HostNameAndPort,nonce:s||this.cryptoUtils.createNewGuid(),p:null==u?void 0:u.AbsolutePath,q:(null==u?void 0:u.QueryString)?[[],u.QueryString]:void 0,client_claims:a||void 0},n),t)];case 1:return[2,d.sent()]}}))}))},e}(),Ke=function(){function e(){}return e.prototype.generateAppMetadataKey=function(){return e.generateAppMetadataCacheKey(this.environment,this.clientId)},e.generateAppMetadataCacheKey=function(e,t){return[U,e,t].join(b.CACHE_KEY_SEPARATOR).toLowerCase()},e.createAppMetadataEntity=function(t,r,n){var o=new e;return o.clientId=t,o.environment=r,n&&(o.familyId=n),o},e.isAppMetadataEntity=function(e,t){return!!t&&0===e.indexOf(U)&&t.hasOwnProperty("clientId")&&t.hasOwnProperty("environment")},e}(),je=function(){function e(e,t){this.cache=e,this.hasChanged=t}return Object.defineProperty(e.prototype,"cacheHasChanged",{get:function(){return this.hasChanged},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tokenCache",{get:function(){return this.cache},enumerable:!1,configurable:!0}),e}(),Ge=function(){function t(e,t,r,n,o,i){this.clientId=e,this.cacheStorage=t,this.cryptoObj=r,this.logger=n,this.serializableCache=o,this.persistencePlugin=i}return t.prototype.validateServerAuthorizationCodeResponse=function(e,t,r){if(!e.state||!t)throw e.state?te.createStateNotFoundError("Cached State"):te.createStateNotFoundError("Server State");if(decodeURIComponent(e.state)!==decodeURIComponent(t))throw te.createStateMismatchError();if(e.error||e.error_description||e.suberror){if(Me.isInteractionRequiredError(e.error,e.error_description,e.suberror))throw new Me(e.error||m.EMPTY_STRING,e.error_description,e.suberror);throw new Ie(e.error||m.EMPTY_STRING,e.error_description,e.suberror)}e.client_info&&le(e.client_info,r)},t.prototype.validateTokenResponse=function(e){if(e.error||e.error_description||e.suberror){if(Me.isInteractionRequiredError(e.error,e.error_description,e.suberror))throw new Me(e.error,e.error_description,e.suberror);var t=e.error_codes+" - ["+e.timestamp+"]: "+e.error_description+" - Correlation ID: "+e.correlation_id+" - Trace ID: "+e.trace_id;throw new Ie(e.error,t,e.suberror)}},t.prototype.handleServerTokenResponse=function(e,r,n,o,i,a,s){return d(this,void 0,void 0,(function(){var c,u,l,d,p;return h(this,(function(h){switch(h.label){case 0:if(e.id_token&&(c=new fe(e.id_token||m.EMPTY_STRING,this.cryptoObj),i&&!re.isEmpty(i.nonce)&&c.claims.nonce!==i.nonce))throw te.createNonceMismatchError();this.homeAccountIdentifier=pe.generateHomeAccountId(e.client_info||m.EMPTY_STRING,r.authorityType,this.logger,this.cryptoObj,c),i&&i.state&&(u=He.parseRequestState(this.cryptoObj,i.state)),e.key_id=e.key_id||o.sshKid||void 0,l=this.generateCacheRecord(e,r,n,c,o.scopes,a,i),h.label=1;case 1:return h.trys.push([1,,5,8]),this.persistencePlugin&&this.serializableCache?(this.logger.verbose("Persistence enabled, calling beforeCacheAccess"),d=new je(this.serializableCache,!0),[4,this.persistencePlugin.beforeCacheAccess(d)]):[3,3];case 2:h.sent(),h.label=3;case 3:return s&&l.account&&(p=l.account.generateAccountKey(),!this.cacheStorage.getAccount(p))?(this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache"),[2,t.generateAuthenticationResult(this.cryptoObj,r,l,!1,o,c,u)]):[4,this.cacheStorage.saveCacheRecord(l)];case 4:return h.sent(),[3,8];case 5:return this.persistencePlugin&&this.serializableCache&&d?(this.logger.verbose("Persistence enabled, calling afterCacheAccess"),[4,this.persistencePlugin.afterCacheAccess(d)]):[3,7];case 6:h.sent(),h.label=7;case 7:return[7];case 8:return[2,t.generateAuthenticationResult(this.cryptoObj,r,l,!1,o,c,u)]}}))}))},t.prototype.generateCacheRecord=function(e,t,r,n,o,i,a){var s,c,u=t.getPreferredCache();if(re.isEmpty(u))throw te.createInvalidCacheEnvironmentError();!re.isEmpty(e.id_token)&&n&&(s=Re.createIdTokenEntity(this.homeAccountIdentifier,u,e.id_token||m.EMPTY_STRING,this.clientId,n.claims.tid||m.EMPTY_STRING,i),c=this.generateAccountEntity(e,n,t,i,a));var l=null;if(!re.isEmpty(e.access_token)){var d=e.scope?ue.fromString(e.scope):new ue(o||[]),h=("string"==typeof e.expires_in?parseInt(e.expires_in,10):e.expires_in)||0,p=("string"==typeof e.ext_expires_in?parseInt(e.ext_expires_in,10):e.ext_expires_in)||0,f=("string"==typeof e.refresh_in?parseInt(e.refresh_in,10):e.refresh_in)||void 0,g=r+h,y=g+p,v=f&&f>0?r+f:void 0;l=Pe.createAccessTokenEntity(this.homeAccountIdentifier,u,e.access_token||m.EMPTY_STRING,this.clientId,n?n.claims.tid||m.EMPTY_STRING:t.tenant,d.printScopes(),g,y,this.cryptoObj,v,e.token_type,i,e.key_id)}var E=null;re.isEmpty(e.refresh_token)||(E=ke.createRefreshTokenEntity(this.homeAccountIdentifier,u,e.refresh_token||m.EMPTY_STRING,this.clientId,e.foci,i));var C=null;return re.isEmpty(e.foci)||(C=Ke.createAppMetadataEntity(this.clientId,u,e.foci)),new Fe(c,s,l,E,C)},t.prototype.generateAccountEntity=function(e,t,r,n,o){var i=r.authorityType,a=o?o.cloud_graph_host_name:"",s=o?o.msgraph_host:"";if(i===ne.Adfs)return this.logger.verbose("Authority type is ADFS, creating ADFS account"),pe.createGenericAccount(this.homeAccountIdentifier,t,r,n,a,s);if(re.isEmpty(e.client_info)&&"AAD"===r.protocolMode)throw te.createClientInfoEmptyError();return e.client_info?pe.createAccount(e.client_info,this.homeAccountIdentifier,t,r,n,a,s):pe.createGenericAccount(this.homeAccountIdentifier,t,r,n,a,s)},t.generateAuthenticationResult=function(t,r,n,o,i,a,s){var c,u,l;return d(this,void 0,void 0,(function(){var d,p,f,g,y,v,E;return h(this,(function(h){switch(h.label){case 0:return d="",p=[],f=null,y=m.EMPTY_STRING,n.accessToken?n.accessToken.tokenType!==e.AuthenticationScheme.POP?[3,2]:[4,new Be(t).signPopToken(n.accessToken.secret,i)]:[3,4];case 1:return d=h.sent(),[3,3];case 2:d=n.accessToken.secret,h.label=3;case 3:p=ue.fromString(n.accessToken.target).asArray(),f=new Date(1e3*Number(n.accessToken.expiresOn)),g=new Date(1e3*Number(n.accessToken.extendedExpiresOn)),h.label=4;case 4:return n.appMetadata&&(y=n.appMetadata.familyId===D?D:m.EMPTY_STRING),v=(null==a?void 0:a.claims.oid)||(null==a?void 0:a.claims.sub)||m.EMPTY_STRING,E=(null==a?void 0:a.claims.tid)||m.EMPTY_STRING,[2,{authority:r.canonicalAuthority,uniqueId:v,tenantId:E,scopes:p,account:n.account?n.account.getAccountInfo():null,idToken:a?a.rawToken:m.EMPTY_STRING,idTokenClaims:a?a.claims:{},accessToken:d,fromCache:o,expiresOn:f,correlationId:i.correlationId,extExpiresOn:g,familyId:y,tokenType:(null===(c=n.accessToken)||void 0===c?void 0:c.tokenType)||m.EMPTY_STRING,state:s?s.userRequestState:m.EMPTY_STRING,cloudGraphHostName:(null===(u=n.account)||void 0===u?void 0:u.cloudGraphHostName)||m.EMPTY_STRING,msGraphHost:(null===(l=n.account)||void 0===l?void 0:l.msGraphHost)||m.EMPTY_STRING}]}}))}))},t}(),We=function(t){function r(e){return t.call(this,e)||this}return u(r,t),r.prototype.getAuthCodeUrl=function(e){return d(this,void 0,void 0,(function(){var t;return h(this,(function(r){return t=this.createAuthCodeUrlQueryString(e),[2,xe.appendQueryString(this.authority.authorizationEndpoint,t)]}))}))},r.prototype.acquireToken=function(e,t){return d(this,void 0,void 0,(function(){var r,n,o;return h(this,(function(i){switch(i.label){case 0:if(this.logger.info("in acquireToken call"),!e||re.isEmpty(e.code))throw te.createTokenRequestCannotBeMadeError();return r=Ne.nowSeconds(),[4,this.executeTokenRequest(this.authority,e)];case 1:return n=i.sent(),(o=new Ge(this.config.authOptions.clientId,this.cacheManager,this.cryptoUtils,this.logger,this.config.serializableCache,this.config.persistencePlugin)).validateTokenResponse(n.body),[4,o.handleServerTokenResponse(n.body,this.authority,r,e,t)];case 2:return[2,i.sent()]}}))}))},r.prototype.handleFragmentResponse=function(e,t){var r=new Ge(this.config.authOptions.clientId,this.cacheManager,this.cryptoUtils,this.logger,null,null),n=new xe(e),o=xe.getDeserializedHash(n.getHash());if(r.validateServerAuthorizationCodeResponse(o,t,this.cryptoUtils),!o.code)throw te.createNoAuthCodeInServerResponseError();return l(l({},o),{code:o.code})},r.prototype.getLogoutUri=function(e){if(!e)throw ce.createEmptyLogoutRequestError();var t=this.createLogoutUrlQueryString(e);return xe.appendQueryString(this.authority.endSessionEndpoint,t)},r.prototype.executeTokenRequest=function(e,t){return d(this,void 0,void 0,(function(){var r,n,o,i,a,s,c;return h(this,(function(u){switch(u.label){case 0:return r={clientId:this.config.authOptions.clientId,authority:e.canonicalAuthority,scopes:t.scopes,authenticationScheme:t.authenticationScheme,resourceRequestMethod:t.resourceRequestMethod,resourceRequestUri:t.resourceRequestUri,shrClaims:t.shrClaims,sshJwk:t.sshJwk,sshKid:t.sshKid},[4,this.createTokenRequestBody(t)];case 1:if(n=u.sent(),o=this.createTokenQueryParameters(t),i=void 0,t.clientInfo)try{a=le(t.clientInfo,this.cryptoUtils),i={credential:""+a.uid+b.CLIENT_INFO_SEPARATOR+a.utid,type:he.HOME_ACCOUNT_ID}}catch(e){this.logger.verbose("Could not parse client info for CCS Header: "+e)}return s=this.createTokenRequestHeaders(i||t.ccsCredential),c=re.isEmpty(o)?e.tokenEndpoint:e.tokenEndpoint+"?"+o,[2,this.executePostToTokenEndpoint(c,n,s,r)]}}))}))},r.prototype.createTokenQueryParameters=function(e){var t=new Oe;return e.tokenQueryParameters&&t.addExtraQueryParameters(e.tokenQueryParameters),t.createQueryString()},r.prototype.createTokenRequestBody=function(t){return d(this,void 0,void 0,(function(){var r,n,o,i,a,s;return h(this,(function(c){switch(c.label){case 0:return(r=new Oe).addClientId(this.config.authOptions.clientId),r.addRedirectUri(t.redirectUri),r.addScopes(t.scopes),r.addAuthorizationCode(t.code),r.addLibraryInfo(this.config.libraryInfo),r.addThrottling(),this.serverTelemetryManager&&r.addServerTelemetry(this.serverTelemetryManager),t.codeVerifier&&r.addCodeVerifier(t.codeVerifier),this.config.clientCredentials.clientSecret&&r.addClientSecret(this.config.clientCredentials.clientSecret),this.config.clientCredentials.clientAssertion&&(n=this.config.clientCredentials.clientAssertion,r.addClientAssertion(n.assertion),r.addClientAssertionType(n.assertionType)),r.addGrantType(A.AUTHORIZATION_CODE_GRANT),r.addClientInfo(),t.authenticationScheme!==e.AuthenticationScheme.POP?[3,2]:[4,new Be(this.cryptoUtils).generateCnf(t)];case 1:return o=c.sent(),r.addPopToken(o),[3,3];case 2:if(t.authenticationScheme===e.AuthenticationScheme.SSH){if(!t.sshJwk)throw ce.createMissingSshJwkError();r.addSshJwk(t.sshJwk)}c.label=3;case 3:if(i=t.correlationId||this.config.cryptoInterface.createNewGuid(),r.addCorrelationId(i),(!re.isEmptyObj(t.claims)||this.config.authOptions.clientCapabilities&&this.config.authOptions.clientCapabilities.length>0)&&r.addClaims(t.claims,this.config.authOptions.clientCapabilities),a=void 0,t.clientInfo)try{s=le(t.clientInfo,this.cryptoUtils),a={credential:""+s.uid+b.CLIENT_INFO_SEPARATOR+s.utid,type:he.HOME_ACCOUNT_ID}}catch(e){this.logger.verbose("Could not parse client info for CCS Header: "+e)}else a=t.ccsCredential;if(this.config.systemOptions.preventCorsPreflight&&a)switch(a.type){case he.HOME_ACCOUNT_ID:try{s=de(a.credential),r.addCcsOid(s)}catch(e){this.logger.verbose("Could not parse home account ID for CCS Header: "+e)}break;case he.UPN:r.addCcsUpn(a.credential)}return[2,r.createQueryString()]}}))}))},r.prototype.createAuthCodeUrlQueryString=function(e){var t=new Oe;t.addClientId(this.config.authOptions.clientId);var r=p(e.scopes||[],e.extraScopesToConsent||[]);t.addScopes(r),t.addRedirectUri(e.redirectUri);var n=e.correlationId||this.config.cryptoInterface.createNewGuid();if(t.addCorrelationId(n),t.addResponseMode(e.responseMode),t.addResponseTypeCode(),t.addLibraryInfo(this.config.libraryInfo),t.addClientInfo(),e.codeChallenge&&e.codeChallengeMethod&&t.addCodeChallengeParams(e.codeChallenge,e.codeChallengeMethod),e.prompt&&t.addPrompt(e.prompt),e.domainHint&&t.addDomainHint(e.domainHint),e.prompt!==w.SELECT_ACCOUNT)if(e.sid&&e.prompt===w.NONE)this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from request"),t.addSid(e.sid);else if(e.account){var o=this.extractAccountSid(e.account);if(o&&e.prompt===w.NONE){this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from account"),t.addSid(o);try{var i=de(e.account.homeAccountId);t.addCcsOid(i)}catch(e){this.logger.verbose("Could not parse home account ID for CCS Header: "+e)}}else if(e.loginHint)this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from request"),t.addLoginHint(e.loginHint),t.addCcsUpn(e.loginHint);else if(e.account.username){this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from account"),t.addLoginHint(e.account.username);try{i=de(e.account.homeAccountId),t.addCcsOid(i)}catch(e){this.logger.verbose("Could not parse home account ID for CCS Header: "+e)}}}else e.loginHint&&(this.logger.verbose("createAuthCodeUrlQueryString: No account, adding login_hint from request"),t.addLoginHint(e.loginHint),t.addCcsUpn(e.loginHint));else this.logger.verbose("createAuthCodeUrlQueryString: Prompt is select_account, ignoring account hints");return e.nonce&&t.addNonce(e.nonce),e.state&&t.addState(e.state),(!re.isEmpty(e.claims)||this.config.authOptions.clientCapabilities&&this.config.authOptions.clientCapabilities.length>0)&&t.addClaims(e.claims,this.config.authOptions.clientCapabilities),e.extraQueryParameters&&t.addExtraQueryParameters(e.extraQueryParameters),t.createQueryString()},r.prototype.createLogoutUrlQueryString=function(e){var t=new Oe;return e.postLogoutRedirectUri&&t.addPostLogoutRedirectUri(e.postLogoutRedirectUri),e.correlationId&&t.addCorrelationId(e.correlationId),e.idTokenHint&&t.addIdTokenHint(e.idTokenHint),e.state&&t.addState(e.state),e.extraQueryParameters&&t.addExtraQueryParameters(e.extraQueryParameters),t.createQueryString()},r.prototype.extractAccountSid=function(e){return e.idTokenClaims&&e.idTokenClaims.sid||null},r}(_e),Ve=function(t){function r(e){return t.call(this,e)||this}return u(r,t),r.prototype.acquireToken=function(e){return d(this,void 0,void 0,(function(){var t,r,n;return h(this,(function(o){switch(o.label){case 0:return t=Ne.nowSeconds(),[4,this.executeTokenRequest(e,this.authority)];case 1:return r=o.sent(),(n=new Ge(this.config.authOptions.clientId,this.cacheManager,this.cryptoUtils,this.logger,this.config.serializableCache,this.config.persistencePlugin)).validateTokenResponse(r.body),[2,n.handleServerTokenResponse(r.body,this.authority,t,e,void 0,void 0,!0)]}}))}))},r.prototype.acquireTokenByRefreshToken=function(e){return d(this,void 0,void 0,(function(){var t,r;return h(this,(function(n){if(!e)throw ce.createEmptyTokenRequestError();if(!e.account)throw te.createNoAccountInSilentRequestError();if(this.cacheManager.isAppMetadataFOCI(e.account.environment,this.config.authOptions.clientId))try{return[2,this.acquireTokenWithCachedRefreshToken(e,!0)]}catch(n){if(t=n instanceof Me&&n.errorCode===Le.noTokensFoundError.code,r=n instanceof Ie&&n.errorCode===$&&n.subError===Y,t||r)return[2,this.acquireTokenWithCachedRefreshToken(e,!1)];throw n}return[2,this.acquireTokenWithCachedRefreshToken(e,!1)]}))}))},r.prototype.acquireTokenWithCachedRefreshToken=function(t,r){return d(this,void 0,void 0,(function(){var n,o;return h(this,(function(i){if(!(n=this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId,t.account,r)))throw Me.createNoTokensFoundError();return o=l(l({},t),{refreshToken:n.secret,authenticationScheme:t.authenticationScheme||e.AuthenticationScheme.BEARER,ccsCredential:{credential:t.account.homeAccountId,type:he.HOME_ACCOUNT_ID}}),[2,this.acquireToken(o)]}))}))},r.prototype.executeTokenRequest=function(e,t){return d(this,void 0,void 0,(function(){var r,n,o,i,a;return h(this,(function(s){switch(s.label){case 0:return[4,this.createTokenRequestBody(e)];case 1:return r=s.sent(),n=this.createTokenQueryParameters(e),o=this.createTokenRequestHeaders(e.ccsCredential),i={clientId:this.config.authOptions.clientId,authority:t.canonicalAuthority,scopes:e.scopes,authenticationScheme:e.authenticationScheme,resourceRequestMethod:e.resourceRequestMethod,resourceRequestUri:e.resourceRequestUri,shrClaims:e.shrClaims,sshJwk:e.sshJwk,sshKid:e.sshKid},a=xe.appendQueryString(t.tokenEndpoint,n),[2,this.executePostToTokenEndpoint(a,r,o,i)]}}))}))},r.prototype.createTokenQueryParameters=function(e){var t=new Oe;return e.tokenQueryParameters&&t.addExtraQueryParameters(e.tokenQueryParameters),t.createQueryString()},r.prototype.createTokenRequestBody=function(t){return d(this,void 0,void 0,(function(){var r,n,o,i,a;return h(this,(function(s){switch(s.label){case 0:return(r=new Oe).addClientId(this.config.authOptions.clientId),r.addScopes(t.scopes),r.addGrantType(A.REFRESH_TOKEN_GRANT),r.addClientInfo(),r.addLibraryInfo(this.config.libraryInfo),r.addThrottling(),this.serverTelemetryManager&&r.addServerTelemetry(this.serverTelemetryManager),n=t.correlationId||this.config.cryptoInterface.createNewGuid(),r.addCorrelationId(n),r.addRefreshToken(t.refreshToken),this.config.clientCredentials.clientSecret&&r.addClientSecret(this.config.clientCredentials.clientSecret),this.config.clientCredentials.clientAssertion&&(o=this.config.clientCredentials.clientAssertion,r.addClientAssertion(o.assertion),r.addClientAssertionType(o.assertionType)),t.authenticationScheme!==e.AuthenticationScheme.POP?[3,2]:[4,new Be(this.cryptoUtils).generateCnf(t)];case 1:return i=s.sent(),r.addPopToken(i),[3,3];case 2:if(t.authenticationScheme===e.AuthenticationScheme.SSH){if(!t.sshJwk)throw ce.createMissingSshJwkError();r.addSshJwk(t.sshJwk)}s.label=3;case 3:if((!re.isEmptyObj(t.claims)||this.config.authOptions.clientCapabilities&&this.config.authOptions.clientCapabilities.length>0)&&r.addClaims(t.claims,this.config.authOptions.clientCapabilities),this.config.systemOptions.preventCorsPreflight&&t.ccsCredential)switch(t.ccsCredential.type){case he.HOME_ACCOUNT_ID:try{a=de(t.ccsCredential.credential),r.addCcsOid(a)}catch(e){this.logger.verbose("Could not parse home account ID for CCS Header: "+e)}break;case he.UPN:r.addCcsUpn(t.ccsCredential.credential)}return[2,r.createQueryString()]}}))}))},r}(_e),ze=function(t){function r(e){return t.call(this,e)||this}return u(r,t),r.prototype.acquireToken=function(e){return d(this,void 0,void 0,(function(){var t;return h(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.acquireCachedToken(e)];case 1:return[2,r.sent()];case 2:if((t=r.sent())instanceof te&&t.errorCode===ee.tokenRefreshRequired.code)return[2,new Ve(this.config).acquireTokenByRefreshToken(e)];throw t;case 3:return[2]}}))}))},r.prototype.acquireCachedToken=function(t){var r,n,o,i;return d(this,void 0,void 0,(function(){var a,s,c,u;return h(this,(function(l){switch(l.label){case 0:if(!t)throw ce.createEmptyTokenRequestError();if(t.forceRefresh)throw null===(r=this.serverTelemetryManager)||void 0===r||r.setCacheOutcome(j.FORCE_REFRESH),this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true."),te.createRefreshRequiredError();if(!re.isEmptyObj(t.claims))throw this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because claims are requested."),te.createRefreshRequiredError();if(!t.account)throw te.createNoAccountInSilentRequestError();if(a=new ue(t.scopes||[]),s=t.authority||this.authority.getPreferredCache(),c=t.authenticationScheme||e.AuthenticationScheme.BEARER,!(u=this.cacheManager.readCacheRecord(t.account,this.config.authOptions.clientId,a,s,c,t.sshKid)).accessToken)throw null===(n=this.serverTelemetryManager)||void 0===n||n.setCacheOutcome(j.NO_CACHED_ACCESS_TOKEN),this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties."),te.createRefreshRequiredError();if(Ne.wasClockTurnedBack(u.accessToken.cachedAt)||Ne.isTokenExpired(u.accessToken.expiresOn,this.config.systemOptions.tokenRenewalOffsetSeconds))throw null===(o=this.serverTelemetryManager)||void 0===o||o.setCacheOutcome(j.CACHED_ACCESS_TOKEN_EXPIRED),this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token is expired or will expire within "+this.config.systemOptions.tokenRenewalOffsetSeconds+" seconds."),te.createRefreshRequiredError();if(u.accessToken.refreshOn&&Ne.isTokenExpired(u.accessToken.refreshOn,0))throw null===(i=this.serverTelemetryManager)||void 0===i||i.setCacheOutcome(j.REFRESH_CACHED_ACCESS_TOKEN),this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'."),te.createRefreshRequiredError();return this.config.serverTelemetryManager&&this.config.serverTelemetryManager.incrementCacheHits(),[4,this.generateResultFromCacheRecord(u,t)];case 1:return[2,l.sent()]}}))}))},r.prototype.generateResultFromCacheRecord=function(e,t){return d(this,void 0,void 0,(function(){var r;return h(this,(function(n){switch(n.label){case 0:return e.idToken&&(r=new fe(e.idToken.secret,this.config.cryptoInterface)),[4,Ge.generateAuthenticationResult(this.cryptoUtils,this.authority,e,!0,t,r)];case 1:return[2,n.sent()]}}))}))},r}(_e);function $e(e){return e.hasOwnProperty("authorization_endpoint")&&e.hasOwnProperty("token_endpoint")&&e.hasOwnProperty("issuer")}e.ProtocolMode=void 0,(qe=e.ProtocolMode||(e.ProtocolMode={})).AAD="AAD",qe.OIDC="OIDC";var Ye,Je,Qe,Xe,Ze,et,tt,rt=function(){function e(){this.expiresAt=Ne.nowSeconds()+M}return e.prototype.updateCloudDiscoveryMetadata=function(e,t){this.aliases=e.aliases,this.preferred_cache=e.preferred_cache,this.preferred_network=e.preferred_network,this.aliasesFromNetwork=t},e.prototype.updateEndpointMetadata=function(e,t){this.authorization_endpoint=e.authorization_endpoint,this.token_endpoint=e.token_endpoint,this.end_session_endpoint=e.end_session_endpoint,this.issuer=e.issuer,this.endpointsFromNetwork=t},e.prototype.updateCanonicalAuthority=function(e){this.canonical_authority=e},e.prototype.resetExpiresAt=function(){this.expiresAt=Ne.nowSeconds()+M},e.prototype.isExpired=function(){return this.expiresAt<=Ne.nowSeconds()},e.isAuthorityMetadataEntity=function(e,t){return!!t&&0===e.indexOf(L)&&t.hasOwnProperty("aliases")&&t.hasOwnProperty("preferred_cache")&&t.hasOwnProperty("preferred_network")&&t.hasOwnProperty("canonical_authority")&&t.hasOwnProperty("authorization_endpoint")&&t.hasOwnProperty("token_endpoint")&&t.hasOwnProperty("issuer")&&t.hasOwnProperty("aliasesFromNetwork")&&t.hasOwnProperty("endpointsFromNetwork")&&t.hasOwnProperty("expiresAt")},e}(),nt=function(){function e(e){this.networkInterface=e}return e.prototype.detectRegion=function(e,t){return d(this,void 0,void 0,(function(){var r,n,o,i;return h(this,(function(a){switch(a.label){case 0:if(r=e)return[3,8];a.label=1;case 1:return a.trys.push([1,6,,7]),[4,this.getRegionFromIMDS(m.IMDS_VERSION)];case 2:return(n=a.sent()).status===q.httpSuccess&&(r=n.body,t.region_source=B.IMDS),n.status!==q.httpBadRequest?[3,5]:[4,this.getCurrentVersion()];case 3:return(o=a.sent())?[4,this.getRegionFromIMDS(o)]:(t.region_source=B.FAILED_AUTO_DETECTION,[2,null]);case 4:(i=a.sent()).status===q.httpSuccess&&(r=i.body,t.region_source=B.IMDS),a.label=5;case 5:return[3,7];case 6:return a.sent(),t.region_source=B.FAILED_AUTO_DETECTION,[2,null];case 7:return[3,9];case 8:t.region_source=B.ENVIRONMENT_VARIABLE,a.label=9;case 9:return r||(t.region_source=B.FAILED_AUTO_DETECTION),[2,r||null]}}))}))},e.prototype.getRegionFromIMDS=function(t){return d(this,void 0,void 0,(function(){return h(this,(function(r){return[2,this.networkInterface.sendGetRequestAsync(m.IMDS_ENDPOINT+"?api-version="+t+"&format=text",e.IMDS_OPTIONS,m.IMDS_TIMEOUT)]}))}))},e.prototype.getCurrentVersion=function(){return d(this,void 0,void 0,(function(){var t;return h(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.networkInterface.sendGetRequestAsync(m.IMDS_ENDPOINT+"?format=json",e.IMDS_OPTIONS)];case 1:return(t=r.sent()).status===q.httpBadRequest&&t.body&&t.body["newest-versions"]&&t.body["newest-versions"].length>0?[2,t.body["newest-versions"][0]]:[2,null];case 2:return r.sent(),[2,null];case 3:return[2]}}))}))},e.IMDS_OPTIONS={headers:{Metadata:"true"}},e}(),ot=function(){function t(e,t,r,n){this.canonicalAuthority=e,this._canonicalAuthority.validateAsUri(),this.networkInterface=t,this.cacheManager=r,this.authorityOptions=n,this.regionDiscovery=new nt(t),this.regionDiscoveryMetadata={region_used:void 0,region_source:void 0,region_outcome:void 0}}return Object.defineProperty(t.prototype,"authorityType",{get:function(){var e=this.canonicalAuthorityUrlComponents.PathSegments;return e.length&&e[0].toLowerCase()===m.ADFS?ne.Adfs:ne.Default},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"protocolMode",{get:function(){return this.authorityOptions.protocolMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this.authorityOptions},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canonicalAuthority",{get:function(){return this._canonicalAuthority.urlString},set:function(e){this._canonicalAuthority=new xe(e),this._canonicalAuthority.validateAsUri(),this._canonicalAuthorityUrlComponents=null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canonicalAuthorityUrlComponents",{get:function(){return this._canonicalAuthorityUrlComponents||(this._canonicalAuthorityUrlComponents=this._canonicalAuthority.getUrlComponents()),this._canonicalAuthorityUrlComponents},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hostnameAndPort",{get:function(){return this.canonicalAuthorityUrlComponents.HostNameAndPort.toLowerCase()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tenant",{get:function(){return this.canonicalAuthorityUrlComponents.PathSegments[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"authorizationEndpoint",{get:function(){if(this.discoveryComplete()){var e=this.replacePath(this.metadata.authorization_endpoint);return this.replaceTenant(e)}throw te.createEndpointDiscoveryIncompleteError("Discovery incomplete.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tokenEndpoint",{get:function(){if(this.discoveryComplete()){var e=this.replacePath(this.metadata.token_endpoint);return this.replaceTenant(e)}throw te.createEndpointDiscoveryIncompleteError("Discovery incomplete.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deviceCodeEndpoint",{get:function(){if(this.discoveryComplete()){var e=this.replacePath(this.metadata.token_endpoint.replace("/token","/devicecode"));return this.replaceTenant(e)}throw te.createEndpointDiscoveryIncompleteError("Discovery incomplete.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endSessionEndpoint",{get:function(){if(this.discoveryComplete()){if(!this.metadata.end_session_endpoint)throw te.createLogoutNotSupportedError();var e=this.replacePath(this.metadata.end_session_endpoint);return this.replaceTenant(e)}throw te.createEndpointDiscoveryIncompleteError("Discovery incomplete.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selfSignedJwtAudience",{get:function(){if(this.discoveryComplete()){var e=this.replacePath(this.metadata.issuer);return this.replaceTenant(e)}throw te.createEndpointDiscoveryIncompleteError("Discovery incomplete.")},enumerable:!1,configurable:!0}),t.prototype.replaceTenant=function(e){return e.replace(/{tenant}|{tenantid}/g,this.tenant)},t.prototype.replacePath=function(e){var t=e,r=new xe(this.metadata.canonical_authority).getUrlComponents().PathSegments;return this.canonicalAuthorityUrlComponents.PathSegments.forEach((function(e,n){var o=r[n];e!==o&&(t=t.replace("/"+o+"/","/"+e+"/"))})),t},Object.defineProperty(t.prototype,"defaultOpenIdConfigurationEndpoint",{get:function(){return this.authorityType===ne.Adfs||this.protocolMode===e.ProtocolMode.OIDC?this.canonicalAuthority+".well-known/openid-configuration":this.canonicalAuthority+"v2.0/.well-known/openid-configuration"},enumerable:!1,configurable:!0}),t.prototype.discoveryComplete=function(){return!!this.metadata},t.prototype.resolveEndpointsAsync=function(){return d(this,void 0,void 0,(function(){var e,t,r,n;return h(this,(function(o){switch(o.label){case 0:return(e=this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort))||(e=new rt).updateCanonicalAuthority(this.canonicalAuthority),[4,this.updateCloudDiscoveryMetadata(e)];case 1:return t=o.sent(),this.canonicalAuthority=this.canonicalAuthority.replace(this.hostnameAndPort,e.preferred_network),[4,this.updateEndpointMetadata(e)];case 2:return r=o.sent(),t!==k.CACHE&&r!==k.CACHE&&(e.resetExpiresAt(),e.updateCanonicalAuthority(this.canonicalAuthority)),n=this.cacheManager.generateAuthorityMetadataCacheKey(e.preferred_cache),this.cacheManager.setAuthorityMetadata(n,e),this.metadata=e,[2]}}))}))},t.prototype.updateEndpointMetadata=function(e){var r;return d(this,void 0,void 0,(function(){var n,o,i;return h(this,(function(a){switch(a.label){case 0:return(n=this.getEndpointMetadataFromConfig())?(e.updateEndpointMetadata(n,!1),[2,k.CONFIG]):this.isAuthoritySameType(e)&&e.endpointsFromNetwork&&!e.isExpired()?[2,k.CACHE]:[4,this.getEndpointMetadataFromNetwork()];case 1:return(n=a.sent())?(null===(r=this.authorityOptions.azureRegionConfiguration)||void 0===r?void 0:r.azureRegion)?[4,this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion,this.regionDiscoveryMetadata)]:[3,3]:[3,4];case 2:o=a.sent(),i=this.authorityOptions.azureRegionConfiguration.azureRegion===m.AZURE_REGION_AUTO_DISCOVER_FLAG?o:this.authorityOptions.azureRegionConfiguration.azureRegion,this.authorityOptions.azureRegionConfiguration.azureRegion===m.AZURE_REGION_AUTO_DISCOVER_FLAG?this.regionDiscoveryMetadata.region_outcome=o?K.AUTO_DETECTION_REQUESTED_SUCCESSFUL:K.AUTO_DETECTION_REQUESTED_FAILED:this.regionDiscoveryMetadata.region_outcome=o?this.authorityOptions.azureRegionConfiguration.azureRegion===o?K.CONFIGURED_MATCHES_DETECTED:K.CONFIGURED_NOT_DETECTED:K.CONFIGURED_NO_AUTO_DETECTION,i&&(this.regionDiscoveryMetadata.region_used=i,n=t.replaceWithRegionalInformation(n,i)),a.label=3;case 3:return e.updateEndpointMetadata(n,!0),[2,k.NETWORK];case 4:throw te.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint)}}))}))},t.prototype.isAuthoritySameType=function(e){return new xe(e.canonical_authority).getUrlComponents().PathSegments.length===this.canonicalAuthorityUrlComponents.PathSegments.length},t.prototype.getEndpointMetadataFromConfig=function(){if(this.authorityOptions.authorityMetadata)try{return JSON.parse(this.authorityOptions.authorityMetadata)}catch(e){throw ce.createInvalidAuthorityMetadataError()}return null},t.prototype.getEndpointMetadataFromNetwork=function(){return d(this,void 0,void 0,(function(){var e;return h(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.networkInterface.sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint)];case 1:return[2,$e((e=t.sent()).body)?e.body:null];case 2:return t.sent(),[2,null];case 3:return[2]}}))}))},t.prototype.updateCloudDiscoveryMetadata=function(e){return d(this,void 0,void 0,(function(){var t;return h(this,(function(r){switch(r.label){case 0:return(t=this.getCloudDiscoveryMetadataFromConfig())?(e.updateCloudDiscoveryMetadata(t,!1),[2,k.CONFIG]):this.isAuthoritySameType(e)&&e.aliasesFromNetwork&&!e.isExpired()?[2,k.CACHE]:[4,this.getCloudDiscoveryMetadataFromNetwork()];case 1:if(t=r.sent())return e.updateCloudDiscoveryMetadata(t,!0),[2,k.NETWORK];throw ce.createUntrustedAuthorityError()}}))}))},t.prototype.getCloudDiscoveryMetadataFromConfig=function(){if(this.authorityOptions.cloudDiscoveryMetadata)try{var e=JSON.parse(this.authorityOptions.cloudDiscoveryMetadata),r=t.getCloudDiscoveryMetadataFromNetworkResponse(e.metadata,this.hostnameAndPort);if(r)return r}catch(e){throw ce.createInvalidCloudDiscoveryMetadataError()}return this.isInKnownAuthorities()?t.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort):null},t.prototype.getCloudDiscoveryMetadataFromNetwork=function(){return d(this,void 0,void 0,(function(){var e,r,n,o;return h(this,(function(i){switch(i.label){case 0:e=""+m.AAD_INSTANCE_DISCOVERY_ENDPT+this.canonicalAuthority+"oauth2/v2.0/authorize",r=null,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.networkInterface.sendGetRequestAsync(e)];case 2:return n=i.sent(),0===(o=function(e){return e.hasOwnProperty("tenant_discovery_endpoint")&&e.hasOwnProperty("metadata")}(n.body)?n.body.metadata:[]).length?[2,null]:(r=t.getCloudDiscoveryMetadataFromNetworkResponse(o,this.hostnameAndPort),[3,4]);case 3:return i.sent(),[2,null];case 4:return r||(r=t.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort)),[2,r]}}))}))},t.prototype.isInKnownAuthorities=function(){var e=this;return this.authorityOptions.knownAuthorities.filter((function(t){return xe.getDomainFromUrl(t).toLowerCase()===e.hostnameAndPort})).length>0},t.createCloudDiscoveryMetadataFromHost=function(e){return{preferred_network:e,preferred_cache:e,aliases:[e]}},t.getCloudDiscoveryMetadataFromNetworkResponse=function(e,t){for(var r=0;r<e.length;r++){var n=e[r];if(n.aliases.indexOf(t)>-1)return n}return null},t.prototype.getPreferredCache=function(){if(this.discoveryComplete())return this.metadata.preferred_cache;throw te.createEndpointDiscoveryIncompleteError("Discovery incomplete.")},t.prototype.isAlias=function(e){return this.metadata.aliases.indexOf(e)>-1},t.isPublicCloudAuthority=function(e){return m.KNOWN_PUBLIC_CLOUDS.indexOf(e)>=0},t.buildRegionalAuthorityString=function(e,t,r){var n=new xe(e);n.validateAsUri();var o=n.getUrlComponents(),i=t+"."+o.HostNameAndPort;this.isPublicCloudAuthority(o.HostNameAndPort)&&(i=t+"."+m.REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX);var a=xe.constructAuthorityUriFromObject(l(l({},n.getUrlComponents()),{HostNameAndPort:i})).urlString;return r?a+"?"+r:a},t.replaceWithRegionalInformation=function(e,r){return e.authorization_endpoint=t.buildRegionalAuthorityString(e.authorization_endpoint,r),e.token_endpoint=t.buildRegionalAuthorityString(e.token_endpoint,r,"allowestsrnonmsi=true"),e.end_session_endpoint&&(e.end_session_endpoint=t.buildRegionalAuthorityString(e.end_session_endpoint,r)),e},t}(),it=function(){function e(){}return e.createDiscoveredInstance=function(t,r,n,o){return d(this,void 0,void 0,(function(){var i,a;return h(this,(function(s){switch(s.label){case 0:i=e.createInstance(t,r,n,o),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,i.resolveEndpointsAsync()];case 2:return s.sent(),[2,i];case 3:throw a=s.sent(),te.createEndpointDiscoveryIncompleteError(a);case 4:return[2]}}))}))},e.createInstance=function(e,t,r,n){if(re.isEmpty(e))throw ce.createUrlEmptyError();return new ot(e,t,r,n)},e}(),at=function(){function e(){this.failedRequests=[],this.errors=[],this.cacheHits=0}return e.isServerTelemetryEntity=function(e,t){var r=0===e.indexOf(H.CACHE_KEY),n=!0;return t&&(n=t.hasOwnProperty("failedRequests")&&t.hasOwnProperty("errors")&&t.hasOwnProperty("cacheHits")),r&&n},e}(),st=function(){function e(){}return e.isThrottlingEntity=function(e,t){var r=!1;e&&(r=0===e.indexOf(V));var n=!0;return t&&(n=t.hasOwnProperty("throttleTime")),r&&n},e}(),ct={sendGetRequestAsync:function(){return Promise.reject(X.createUnexpectedError("Network interface - sendGetRequestAsync() has not been implemented for the Network interface."))},sendPostRequestAsync:function(){return Promise.reject(X.createUnexpectedError("Network interface - sendPostRequestAsync() has not been implemented for the Network interface."))}},ut=function(){function e(e){this.headers=e}return e.prototype.getShrNonce=function(){var e=this.headers[f.AuthenticationInfo];if(e){var t=this.parseChallenges(e);if(t.nextnonce)return t.nextnonce;throw ce.createInvalidAuthenticationHeaderError(f.AuthenticationInfo,"nextnonce challenge is missing.")}var r=this.headers[f.WWWAuthenticate];if(r){var n=this.parseChallenges(r);if(n.nonce)return n.nonce;throw ce.createInvalidAuthenticationHeaderError(f.WWWAuthenticate,"nonce challenge is missing.")}throw ce.createMissingNonceAuthenticationHeadersError()},e.prototype.parseChallenges=function(e){var t=e.indexOf(" "),r=e.substr(t+1).split(","),n={};return r.forEach((function(e){var t=e.split("="),r=t[0],o=t[1];n[r]=unescape(o.replace(/['"]+/g,""))})),n},e}(),lt=function(){function e(e,t){this.cacheOutcome=j.NO_CACHE_HIT,this.cacheManager=t,this.apiId=e.apiId,this.correlationId=e.correlationId,this.wrapperSKU=e.wrapperSKU||m.EMPTY_STRING,this.wrapperVer=e.wrapperVer||m.EMPTY_STRING,this.telemetryCacheKey=H.CACHE_KEY+b.CACHE_KEY_SEPARATOR+e.clientId}return e.prototype.generateCurrentRequestHeaderValue=function(){var e=""+this.apiId+H.VALUE_SEPARATOR+this.cacheOutcome,t=[this.wrapperSKU,this.wrapperVer].join(H.VALUE_SEPARATOR),r=[e,this.getRegionDiscoveryFields()].join(H.VALUE_SEPARATOR);return[H.SCHEMA_VERSION,r,t].join(H.CATEGORY_SEPARATOR)},e.prototype.generateLastRequestHeaderValue=function(){var t=this.getLastRequests(),r=e.maxErrorsToSend(t),n=t.failedRequests.slice(0,2*r).join(H.VALUE_SEPARATOR),o=t.errors.slice(0,r).join(H.VALUE_SEPARATOR),i=t.errors.length,a=[i,r<i?H.OVERFLOW_TRUE:H.OVERFLOW_FALSE].join(H.VALUE_SEPARATOR);return[H.SCHEMA_VERSION,t.cacheHits,n,o,a].join(H.CATEGORY_SEPARATOR)},e.prototype.cacheFailedRequest=function(e){var t=this.getLastRequests();t.errors.length>=H.MAX_CACHED_ERRORS&&(t.failedRequests.shift(),t.failedRequests.shift(),t.errors.shift()),t.failedRequests.push(this.apiId,this.correlationId),re.isEmpty(e.subError)?re.isEmpty(e.errorCode)?e&&e.toString()?t.errors.push(e.toString()):t.errors.push(H.UNKNOWN_ERROR):t.errors.push(e.errorCode):t.errors.push(e.subError),this.cacheManager.setServerTelemetry(this.telemetryCacheKey,t)},e.prototype.incrementCacheHits=function(){var e=this.getLastRequests();return e.cacheHits+=1,this.cacheManager.setServerTelemetry(this.telemetryCacheKey,e),e.cacheHits},e.prototype.getLastRequests=function(){var e=new at;return this.cacheManager.getServerTelemetry(this.telemetryCacheKey)||e},e.prototype.clearTelemetryCache=function(){var t=this.getLastRequests(),r=e.maxErrorsToSend(t);if(r===t.errors.length)this.cacheManager.removeItem(this.telemetryCacheKey);else{var n=new at;n.failedRequests=t.failedRequests.slice(2*r),n.errors=t.errors.slice(r),this.cacheManager.setServerTelemetry(this.telemetryCacheKey,n)}},e.maxErrorsToSend=function(e){var t,r=0,n=0,o=e.errors.length;for(t=0;t<o;t++){var i=e.failedRequests[2*t]||m.EMPTY_STRING,a=e.failedRequests[2*t+1]||m.EMPTY_STRING,s=e.errors[t]||m.EMPTY_STRING;if(!((n+=i.toString().length+a.toString().length+s.length+3)<H.MAX_LAST_HEADER_BYTES))break;r+=1}return r},e.prototype.getRegionDiscoveryFields=function(){var e=[];return e.push(this.regionUsed||""),e.push(this.regionSource||""),e.push(this.regionOutcome||""),e.join(",")},e.prototype.updateRegionDiscoveryMetadata=function(e){this.regionUsed=e.region_used,this.regionSource=e.region_source,this.regionOutcome=e.region_outcome},e.prototype.setCacheOutcome=function(e){this.cacheOutcome=e},e}(),dt="invalid_grant",ht=483,pt=600,ft="msal",gt=50,yt="msal.js.browser";e.BrowserCacheLocation=void 0,(Ye=e.BrowserCacheLocation||(e.BrowserCacheLocation={})).LocalStorage="localStorage",Ye.SessionStorage="sessionStorage",Ye.MemoryStorage="memoryStorage",function(e){e.GET="GET",e.POST="POST"}(Je||(Je={})),function(e){e.AUTHORITY="authority",e.ACQUIRE_TOKEN_ACCOUNT="acquireToken.account",e.SESSION_STATE="session.state",e.REQUEST_STATE="request.state",e.NONCE_IDTOKEN="nonce.id_token",e.ORIGIN_URI="request.origin",e.RENEW_STATUS="token.renew.status",e.URL_HASH="urlHash",e.REQUEST_PARAMS="request.params",e.SCOPES="scopes",e.INTERACTION_STATUS_KEY="interaction.status",e.CCS_CREDENTIAL="ccs.credential",e.CORRELATION_ID="request.correlationId"}(Qe||(Qe={})),function(e){e.WRAPPER_SKU="wrapper.sku",e.WRAPPER_VER="wrapper.version"}(Xe||(Xe={})),e.ApiId=void 0,(Ze=e.ApiId||(e.ApiId={}))[Ze.acquireTokenRedirect=861]="acquireTokenRedirect",Ze[Ze.acquireTokenPopup=862]="acquireTokenPopup",Ze[Ze.ssoSilent=863]="ssoSilent",Ze[Ze.acquireTokenSilent_authCode=864]="acquireTokenSilent_authCode",Ze[Ze.handleRedirectPromise=865]="handleRedirectPromise",Ze[Ze.acquireTokenSilent_silentFlow=61]="acquireTokenSilent_silentFlow",Ze[Ze.logout=961]="logout",Ze[Ze.logoutPopup=962]="logoutPopup",e.InteractionType=void 0,(et=e.InteractionType||(e.InteractionType={})).Redirect="redirect",et.Popup="popup",et.Silent="silent",e.InteractionStatus=void 0,(tt=e.InteractionStatus||(e.InteractionStatus={})).Startup="startup",tt.Login="login",tt.Logout="logout",tt.AcquireToken="acquireToken",tt.SsoSilent="ssoSilent",tt.HandleRedirect="handleRedirect",tt.None="none";var vt,Et={scopes:C},mt="jwk";e.WrapperSKU=void 0,(vt=e.WrapperSKU||(e.WrapperSKU={})).React="@azure/msal-react",vt.Angular="@azure/msal-angular";var Ct,St="msal.db",It=function(){function e(){}return e.decimalToHex=function(e){for(var t=e.toString(16);t.length<2;)t="0"+t;return t},e}(),wt=function(){function e(e){this.cryptoObj=e}return e.prototype.generateGuid=function(){try{var e=new Uint8Array(16);return this.cryptoObj.getRandomValues(e),e[6]|=64,e[6]&=79,e[8]|=128,e[8]&=191,It.decimalToHex(e[0])+It.decimalToHex(e[1])+It.decimalToHex(e[2])+It.decimalToHex(e[3])+"-"+It.decimalToHex(e[4])+It.decimalToHex(e[5])+"-"+It.decimalToHex(e[6])+It.decimalToHex(e[7])+"-"+It.decimalToHex(e[8])+It.decimalToHex(e[9])+"-"+It.decimalToHex(e[10])+It.decimalToHex(e[11])+It.decimalToHex(e[12])+It.decimalToHex(e[13])+It.decimalToHex(e[14])+It.decimalToHex(e[15])}catch(e){for(var t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",r="0123456789abcdef",n=0,o="",i=0;i<36;i++)"-"!==t[i]&&"4"!==t[i]&&(n=16*Math.random()|0),"x"===t[i]?o+=r[n]:"y"===t[i]?(n&=3,o+=r[n|=8]):o+=t[i];return o}},e.isGuid=function(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)},e}(),Tt=function(){function e(){}return e.stringToUtf8Arr=function(e){for(var t,r=0,n=e.length,o=0;o<n;o++)r+=(t=e.charCodeAt(o))<128?1:t<2048?2:t<65536?3:t<2097152?4:t<67108864?5:6;for(var i=new Uint8Array(r),a=0,s=0;a<r;s++)(t=e.charCodeAt(s))<128?i[a++]=t:t<2048?(i[a++]=192+(t>>>6),i[a++]=128+(63&t)):t<65536?(i[a++]=224+(t>>>12),i[a++]=128+(t>>>6&63),i[a++]=128+(63&t)):t<2097152?(i[a++]=240+(t>>>18),i[a++]=128+(t>>>12&63),i[a++]=128+(t>>>6&63),i[a++]=128+(63&t)):t<67108864?(i[a++]=248+(t>>>24),i[a++]=128+(t>>>18&63),i[a++]=128+(t>>>12&63),i[a++]=128+(t>>>6&63),i[a++]=128+(63&t)):(i[a++]=252+(t>>>30),i[a++]=128+(t>>>24&63),i[a++]=128+(t>>>18&63),i[a++]=128+(t>>>12&63),i[a++]=128+(t>>>6&63),i[a++]=128+(63&t));return i},e.stringToArrayBuffer=function(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return t},e.utf8ArrToString=function(e){for(var t="",r=void 0,n=e.length,o=0;o<n;o++)r=e[o],t+=String.fromCharCode(r>251&&r<254&&o+5<n?1073741824*(r-252)+(e[++o]-128<<24)+(e[++o]-128<<18)+(e[++o]-128<<12)+(e[++o]-128<<6)+e[++o]-128:r>247&&r<252&&o+4<n?(r-248<<24)+(e[++o]-128<<18)+(e[++o]-128<<12)+(e[++o]-128<<6)+e[++o]-128:r>239&&r<248&&o+3<n?(r-240<<18)+(e[++o]-128<<12)+(e[++o]-128<<6)+e[++o]-128:r>223&&r<240&&o+2<n?(r-224<<12)+(e[++o]-128<<6)+e[++o]-128:r>191&&r<224&&o+1<n?(r-192<<6)+e[++o]-128:r);return t},e}(),At=function(){function e(){}return e.prototype.urlEncode=function(e){return encodeURIComponent(this.encode(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"))},e.prototype.urlEncodeArr=function(e){return this.base64EncArr(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},e.prototype.encode=function(e){var t=Tt.stringToUtf8Arr(e);return this.base64EncArr(t)},e.prototype.base64EncArr=function(e){for(var t=(3-e.length%3)%3,r="",n=void 0,o=e.length,i=0,a=0;a<o;a++)n=a%3,i|=e[a]<<(16>>>n&24),2!==n&&e.length-a!=1||(r+=String.fromCharCode(this.uint6ToB64(i>>>18&63),this.uint6ToB64(i>>>12&63),this.uint6ToB64(i>>>6&63),this.uint6ToB64(63&i)),i=0);return 0===t?r:r.substring(0,r.length-t)+(1===t?"=":"==")},e.prototype.uint6ToB64=function(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65},e}(),_t=function(){function e(){}return e.prototype.decode=function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("Invalid base64 string")}var r=this.base64DecToArr(t);return Tt.utf8ArrToString(r)},e.prototype.base64DecToArr=function(e,t){for(var r=e.replace(/[^A-Za-z0-9\+\/]/g,""),n=r.length,o=t?Math.ceil((3*n+1>>>2)/t)*t:3*n+1>>>2,i=new Uint8Array(o),a=void 0,s=void 0,c=0,u=0,l=0;l<n;l++)if(s=3&l,c|=this.b64ToUint6(r.charCodeAt(l))<<18-6*s,3===s||n-l==1){for(a=0;a<3&&u<o;a++,u++)i[u]=c>>>(16>>>a&24)&255;c=0}return i},e.prototype.b64ToUint6=function(e){return e>64&&e<91?e-65:e>96&&e<123?e-71:e>47&&e<58?e+4:43===e?62:47===e?63:0},e}(),bt={pkceNotGenerated:{code:"pkce_not_created",desc:"The PKCE code challenge and verifier could not be generated."},cryptoDoesNotExist:{code:"crypto_nonexistent",desc:"The crypto object or function is not available."},httpMethodNotImplementedError:{code:"http_method_not_implemented",desc:"The HTTP method given has not been implemented in this library."},emptyNavigateUriError:{code:"empty_navigate_uri",desc:"Navigation URI is empty. Please check stack trace for more info."},hashEmptyError:{code:"hash_empty_error",desc:"Hash value cannot be processed because it is empty. Please verify that your redirectUri is not clearing the hash."},hashDoesNotContainStateError:{code:"no_state_in_hash",desc:"Hash does not contain state. Please verify that the request originated from msal."},hashDoesNotContainKnownPropertiesError:{code:"hash_does_not_contain_known_properties",desc:"Hash does not contain known properites. Please verify that your redirectUri is not changing the hash."},unableToParseStateError:{code:"unable_to_parse_state",desc:"Unable to parse state. Please verify that the request originated from msal."},stateInteractionTypeMismatchError:{code:"state_interaction_type_mismatch",desc:"Hash contains state but the interaction type does not match the caller."},interactionInProgress:{code:"interaction_in_progress",desc:"Interaction is currently in progress. Please ensure that this interaction has been completed before calling an interactive API. For more visit: aka.ms/msaljs/browser-errors."},popupWindowError:{code:"popup_window_error",desc:"Error opening popup window. This can happen if you are using IE or if popups are blocked in the browser."},emptyWindowError:{code:"empty_window_error",desc:"window.open returned null or undefined window object."},userCancelledError:{code:"user_cancelled",desc:"User cancelled the flow."},monitorPopupTimeoutError:{code:"monitor_window_timeout",desc:"Token acquisition in popup failed due to timeout. For more visit: aka.ms/msaljs/browser-errors."},monitorIframeTimeoutError:{code:"monitor_window_timeout",desc:"Token acquisition in iframe failed due to timeout. For more visit: aka.ms/msaljs/browser-errors."},redirectInIframeError:{code:"redirect_in_iframe",desc:"Code flow is not supported inside an iframe. Please ensure you are using MSAL.js in a top frame of the window if using the redirect APIs, or use the popup APIs."},blockTokenRequestsInHiddenIframeError:{code:"block_iframe_reload",desc:"Request was blocked inside an iframe because MSAL detected an authentication response. For more visit: aka.ms/msaljs/browser-errors"},blockAcquireTokenInPopupsError:{code:"block_nested_popups",desc:"Request was blocked inside a popup because MSAL detected it was running in a popup."},iframeClosedPrematurelyError:{code:"iframe_closed_prematurely",desc:"The iframe being monitored was closed prematurely."},silentLogoutUnsupportedError:{code:"silent_logout_unsupported",desc:"Silent logout not supported. Please call logoutRedirect or logoutPopup instead."},noAccountError:{code:"no_account_error",desc:"No account object provided to acquireTokenSilent and no active account has been set. Please call setActiveAccount or provide an account on the request."},silentPromptValueError:{code:"silent_prompt_value_error",desc:"The value given for the prompt value is not valid for silent requests - must be set to 'none'."},noTokenRequestCacheError:{code:"no_token_request_cache_error",desc:"No token request found in cache."},unableToParseTokenRequestCacheError:{code:"unable_to_parse_token_request_cache_error",desc:"The cached token request could not be parsed."},noCachedAuthorityError:{code:"no_cached_authority_error",desc:"No cached authority found."},authRequestNotSet:{code:"auth_request_not_set_error",desc:"Auth Request not set. Please ensure initiateAuthRequest was called from the InteractionHandler"},invalidCacheType:{code:"invalid_cache_type",desc:"Invalid cache type"},notInBrowserEnvironment:{code:"non_browser_environment",desc:"Login and token requests are not supported in non-browser environments."},databaseNotOpen:{code:"database_not_open",desc:"Database is not open!"},noNetworkConnectivity:{code:"no_network_connectivity",desc:"No network connectivity. Check your internet connection."},postRequestFailed:{code:"post_request_failed",desc:"Network request failed: If the browser threw a CORS error, check that the redirectUri is registered in the Azure App Portal as type 'SPA'"},getRequestFailed:{code:"get_request_failed",desc:"Network request failed. Please check the network trace to determine root cause."},failedToParseNetworkResponse:{code:"failed_to_parse_response",desc:"Failed to parse network response. Check network trace."},unableToLoadTokenError:{code:"unable_to_load_token",desc:"Error loading token to cache."},signingKeyNotFoundInStorage:{code:"crypto_key_not_found",desc:"Cryptographic Key or Keypair not found in browser storage."},databaseUnavailable:{code:"database_unavailable",desc:"IndexedDB, which is required for persistent cryptographic key storage, is unavailable. This may be caused by browser privacy features which block persistent storage in third-party contexts."}},Ot=function(e){function t(r,n){var o=e.call(this,r,n)||this;return Object.setPrototypeOf(o,t.prototype),o.name="BrowserAuthError",o}return r(t,e),t.createPkceNotGeneratedError=function(e){return new t(bt.pkceNotGenerated.code,bt.pkceNotGenerated.desc+" Detail:"+e)},t.createCryptoNotAvailableError=function(e){return new t(bt.cryptoDoesNotExist.code,bt.cryptoDoesNotExist.desc+" Detail:"+e)},t.createHttpMethodNotImplementedError=function(e){return new t(bt.httpMethodNotImplementedError.code,bt.httpMethodNotImplementedError.desc+" Given Method: "+e)},t.createEmptyNavigationUriError=function(){return new t(bt.emptyNavigateUriError.code,bt.emptyNavigateUriError.desc)},t.createEmptyHashError=function(e){return new t(bt.hashEmptyError.code,bt.hashEmptyError.desc+" Given Url: "+e)},t.createHashDoesNotContainStateError=function(){return new t(bt.hashDoesNotContainStateError.code,bt.hashDoesNotContainStateError.desc)},t.createHashDoesNotContainKnownPropertiesError=function(){return new t(bt.hashDoesNotContainKnownPropertiesError.code,bt.hashDoesNotContainKnownPropertiesError.desc)},t.createUnableToParseStateError=function(){return new t(bt.unableToParseStateError.code,bt.unableToParseStateError.desc)},t.createStateInteractionTypeMismatchError=function(){return new t(bt.stateInteractionTypeMismatchError.code,bt.stateInteractionTypeMismatchError.desc)},t.createInteractionInProgressError=function(){return new t(bt.interactionInProgress.code,bt.interactionInProgress.desc)},t.createPopupWindowError=function(e){var r=bt.popupWindowError.desc;return r=re.isEmpty(e)?r:r+" Details: "+e,new t(bt.popupWindowError.code,r)},t.createEmptyWindowCreatedError=function(){return new t(bt.emptyWindowError.code,bt.emptyWindowError.desc)},t.createUserCancelledError=function(){return new t(bt.userCancelledError.code,bt.userCancelledError.desc)},t.createMonitorPopupTimeoutError=function(){return new t(bt.monitorPopupTimeoutError.code,bt.monitorPopupTimeoutError.desc)},t.createMonitorIframeTimeoutError=function(){return new t(bt.monitorIframeTimeoutError.code,bt.monitorIframeTimeoutError.desc)},t.createRedirectInIframeError=function(e){return new t(bt.redirectInIframeError.code,bt.redirectInIframeError.desc+" (window.parent !== window) => "+e)},t.createBlockReloadInHiddenIframeError=function(){return new t(bt.blockTokenRequestsInHiddenIframeError.code,bt.blockTokenRequestsInHiddenIframeError.desc)},t.createBlockAcquireTokenInPopupsError=function(){return new t(bt.blockAcquireTokenInPopupsError.code,bt.blockAcquireTokenInPopupsError.desc)},t.createIframeClosedPrematurelyError=function(){return new t(bt.iframeClosedPrematurelyError.code,bt.iframeClosedPrematurelyError.desc)},t.createSilentLogoutUnsupportedError=function(){return new t(bt.silentLogoutUnsupportedError.code,bt.silentLogoutUnsupportedError.desc)},t.createNoAccountError=function(){return new t(bt.noAccountError.code,bt.noAccountError.desc)},t.createSilentPromptValueError=function(e){return new t(bt.silentPromptValueError.code,bt.silentPromptValueError.desc+" Given value: "+e)},t.createUnableToParseTokenRequestCacheError=function(){return new t(bt.unableToParseTokenRequestCacheError.code,bt.unableToParseTokenRequestCacheError.desc)},t.createNoTokenRequestCacheError=function(){return new t(bt.noTokenRequestCacheError.code,bt.noTokenRequestCacheError.desc)},t.createAuthRequestNotSetError=function(){return new t(bt.authRequestNotSet.code,bt.authRequestNotSet.desc)},t.createNoCachedAuthorityError=function(){return new t(bt.noCachedAuthorityError.code,bt.noCachedAuthorityError.desc)},t.createInvalidCacheTypeError=function(){return new t(bt.invalidCacheType.code,""+bt.invalidCacheType.desc)},t.createNonBrowserEnvironmentError=function(){return new t(bt.notInBrowserEnvironment.code,bt.notInBrowserEnvironment.desc)},t.createDatabaseNotOpenError=function(){return new t(bt.databaseNotOpen.code,bt.databaseNotOpen.desc)},t.createNoNetworkConnectivityError=function(){return new t(bt.noNetworkConnectivity.code,bt.noNetworkConnectivity.desc)},t.createPostRequestFailedError=function(e,r){return new t(bt.postRequestFailed.code,bt.postRequestFailed.desc+" | Network client threw: "+e+" | Attempted to reach: "+r.split("?")[0])},t.createGetRequestFailedError=function(e,r){return new t(bt.getRequestFailed.code,bt.getRequestFailed.desc+" | Network client threw: "+e+" | Attempted to reach: "+r.split("?")[0])},t.createFailedToParseNetworkResponseError=function(e){return new t(bt.failedToParseNetworkResponse.code,bt.failedToParseNetworkResponse.desc+" | Attempted to reach: "+e.split("?")[0])},t.createUnableToLoadTokenError=function(e){return new t(bt.unableToLoadTokenError.code,bt.unableToLoadTokenError.desc+" | "+e)},t.createSigningKeyNotFoundInStorageError=function(e){return new t(bt.signingKeyNotFoundInStorage.code,bt.signingKeyNotFoundInStorage.desc+" | No match found for KeyId: "+e)},t.createDatabaseUnavailableError=function(){return new t(bt.databaseUnavailable.code,bt.databaseUnavailable.desc)},t}(X),Rt=function(){function e(e){this.base64Encode=new At,this.cryptoObj=e}return e.prototype.generateCodes=function(){return o(this,void 0,void 0,(function(){var e,t;return i(this,(function(r){switch(r.label){case 0:return e=this.generateCodeVerifier(),[4,this.generateCodeChallengeFromVerifier(e)];case 1:return t=r.sent(),[2,{verifier:e,challenge:t}]}}))}))},e.prototype.generateCodeVerifier=function(){try{var e=new Uint8Array(32);return this.cryptoObj.getRandomValues(e),this.base64Encode.urlEncodeArr(e)}catch(e){throw Ot.createPkceNotGeneratedError(e)}},e.prototype.generateCodeChallengeFromVerifier=function(e){return o(this,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.cryptoObj.sha256Digest(e)];case 1:return t=n.sent(),[2,this.base64Encode.urlEncodeArr(new Uint8Array(t))];case 2:throw r=n.sent(),Ot.createPkceNotGeneratedError(r);case 3:return[2]}}))}))},e}(),Nt="SHA-256",Pt=new Uint8Array([1,0,1]),kt=function(){function e(e){if(this.logger=e,!this.hasCryptoAPI())throw Ot.createCryptoNotAvailableError("Browser crypto or msCrypto object not available.");this._keygenAlgorithmOptions={name:"RSASSA-PKCS1-v1_5",hash:Nt,modulusLength:2048,publicExponent:Pt}}return e.prototype.sha256Digest=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(r){return t=Tt.stringToUtf8Arr(e),[2,this.hasIECrypto()?this.getMSCryptoDigest(Nt,t):this.getSubtleCryptoDigest(Nt,t)]}))}))},e.prototype.getRandomValues=function(e){var t=window.msCrypto||window.crypto;if(!t.getRandomValues)throw Ot.createCryptoNotAvailableError("getRandomValues does not exist.");t.getRandomValues(e)},e.prototype.generateKeyPair=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.hasIECrypto()?this.msCryptoGenerateKey(e,t):window.crypto.subtle.generateKey(this._keygenAlgorithmOptions,e,t)]}))}))},e.prototype.exportJwk=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.hasIECrypto()?this.msCryptoExportJwk(e):window.crypto.subtle.exportKey(mt,e)]}))}))},e.prototype.importJwk=function(t,r,n){return o(this,void 0,void 0,(function(){var o,a;return i(this,(function(i){return o=e.getJwkString(t),a=Tt.stringToArrayBuffer(o),[2,this.hasIECrypto()?this.msCryptoImportKey(a,r,n):window.crypto.subtle.importKey(mt,t,this._keygenAlgorithmOptions,r,n)]}))}))},e.prototype.sign=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.hasIECrypto()?this.msCryptoSign(e,t):window.crypto.subtle.sign(this._keygenAlgorithmOptions,e,t)]}))}))},e.prototype.hasCryptoAPI=function(){return this.hasIECrypto()||this.hasBrowserCrypto()},e.prototype.hasIECrypto=function(){return"msCrypto"in window},e.prototype.hasBrowserCrypto=function(){return"crypto"in window},e.prototype.getSubtleCryptoDigest=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,window.crypto.subtle.digest(e,t)]}))}))},e.prototype.getMSCryptoDigest=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,new Promise((function(r,n){var o=window.msCrypto.subtle.digest(e,t.buffer);o.addEventListener("complete",(function(e){r(e.target.result)})),o.addEventListener("error",(function(e){n(e)}))}))]}))}))},e.prototype.msCryptoGenerateKey=function(e,t){return o(this,void 0,void 0,(function(){var r=this;return i(this,(function(n){return[2,new Promise((function(n,o){var i=window.msCrypto.subtle.generateKey(r._keygenAlgorithmOptions,e,t);i.addEventListener("complete",(function(e){n(e.target.result)})),i.addEventListener("error",(function(e){o(e)}))}))]}))}))},e.prototype.msCryptoExportJwk=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,new Promise((function(t,r){var n=window.msCrypto.subtle.exportKey(mt,e);n.addEventListener("complete",(function(e){var n=e.target.result,o=Tt.utf8ArrToString(new Uint8Array(n)).replace(/\r/g,"").replace(/\n/g,"").replace(/\t/g,"").split(" ").join("").replace("\0","");try{t(JSON.parse(o))}catch(e){r(e)}})),n.addEventListener("error",(function(e){r(e)}))}))]}))}))},e.prototype.msCryptoImportKey=function(e,t,r){return o(this,void 0,void 0,(function(){var n=this;return i(this,(function(o){return[2,new Promise((function(o,i){var a=window.msCrypto.subtle.importKey(mt,e,n._keygenAlgorithmOptions,t,r);a.addEventListener("complete",(function(e){o(e.target.result)})),a.addEventListener("error",(function(e){i(e)}))}))]}))}))},e.prototype.msCryptoSign=function(e,t){return o(this,void 0,void 0,(function(){var r=this;return i(this,(function(n){return[2,new Promise((function(n,o){var i=window.msCrypto.subtle.sign(r._keygenAlgorithmOptions,e,t);i.addEventListener("complete",(function(e){n(e.target.result)})),i.addEventListener("error",(function(e){o(e)}))}))]}))}))},e.getJwkString=function(e){return JSON.stringify(e,Object.keys(e).sort())},e}(),Ut=function(){function e(){this.dbName=St,this.version=1,this.tableName="msal.db.keys",this.dbOpen=!1}return e.prototype.open=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,r){var n=window.indexedDB.open(e.dbName,e.version);n.addEventListener("upgradeneeded",(function(t){t.target.result.createObjectStore(e.tableName)})),n.addEventListener("success",(function(r){var n=r;e.db=n.target.result,e.dbOpen=!0,t()})),n.addEventListener("error",(function(){return r(Ot.createDatabaseUnavailableError())}))}))]}))}))},e.prototype.validateDbIsOpen=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this.dbOpen?[3,2]:[4,this.open()];case 1:return[2,e.sent()];case 2:return[2]}}))}))},e.prototype.getItem=function(e){return o(this,void 0,void 0,(function(){var t=this;return i(this,(function(r){switch(r.label){case 0:return[4,this.validateDbIsOpen()];case 1:return r.sent(),[2,new Promise((function(r,n){if(!t.db)return n(Ot.createDatabaseNotOpenError());var o=t.db.transaction([t.tableName],"readonly").objectStore(t.tableName).get(e);o.addEventListener("success",(function(e){r(e.target.result)})),o.addEventListener("error",(function(e){return n(e)}))}))]}}))}))},e.prototype.setItem=function(e,t){return o(this,void 0,void 0,(function(){var r=this;return i(this,(function(n){switch(n.label){case 0:return[4,this.validateDbIsOpen()];case 1:return n.sent(),[2,new Promise((function(n,o){if(!r.db)return o(Ot.createDatabaseNotOpenError());var i=r.db.transaction([r.tableName],"readwrite").objectStore(r.tableName).put(t,e);i.addEventListener("success",(function(){return n()})),i.addEventListener("error",(function(e){return o(e)}))}))]}}))}))},e.prototype.removeItem=function(e){return o(this,void 0,void 0,(function(){var t=this;return i(this,(function(r){switch(r.label){case 0:return[4,this.validateDbIsOpen()];case 1:return r.sent(),[2,new Promise((function(r,n){if(!t.db)return n(Ot.createDatabaseNotOpenError());var o=t.db.transaction([t.tableName],"readwrite").objectStore(t.tableName).delete(e);o.addEventListener("success",(function(){return r()})),o.addEventListener("error",(function(e){return n(e)}))}))]}}))}))},e.prototype.getKeys=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){switch(t.label){case 0:return[4,this.validateDbIsOpen()];case 1:return t.sent(),[2,new Promise((function(t,r){if(!e.db)return r(Ot.createDatabaseNotOpenError());var n=e.db.transaction([e.tableName],"readonly").objectStore(e.tableName).getAllKeys();n.addEventListener("success",(function(e){t(e.target.result)})),n.addEventListener("error",(function(e){return r(e)}))}))]}}))}))},e.prototype.containsKey=function(e){return o(this,void 0,void 0,(function(){var t=this;return i(this,(function(r){switch(r.label){case 0:return[4,this.validateDbIsOpen()];case 1:return r.sent(),[2,new Promise((function(r,n){if(!t.db)return n(Ot.createDatabaseNotOpenError());var o=t.db.transaction([t.tableName],"readonly").objectStore(t.tableName).count(e);o.addEventListener("success",(function(e){r(1===e.target.result)})),o.addEventListener("error",(function(e){return n(e)}))}))]}}))}))},e.prototype.deleteDatabase=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new Promise((function(e,t){var r=window.indexedDB.deleteDatabase(St);r.addEventListener("success",(function(){return e(!0)})),r.addEventListener("error",(function(){return t(!1)}))}))]}))}))},e}(),Dt=function(){function e(){this.cache=new Map}return e.prototype.getItem=function(e){return this.cache.get(e)||null},e.prototype.setItem=function(e,t){this.cache.set(e,t)},e.prototype.removeItem=function(e){this.cache.delete(e)},e.prototype.getKeys=function(){var e=[];return this.cache.forEach((function(t,r){e.push(r)})),e},e.prototype.containsKey=function(e){return this.cache.has(e)},e.prototype.clear=function(){this.cache.clear()},e}(),Lt=function(){function e(e){this.inMemoryCache=new Dt,this.indexedDBCache=new Ut,this.logger=e}return e.prototype.handleDatabaseAccessError=function(e){e instanceof Ot&&e.errorCode===bt.databaseUnavailable.code&&this.logger.error("Could not access persistent storage. This may be caused by browser privacy features which block persistent storage in third-party contexts.")},e.prototype.getItem=function(e){return o(this,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:if(t=this.inMemoryCache.getItem(e))return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),this.logger.verbose("Queried item not found in in-memory cache, now querying persistent storage."),[4,this.indexedDBCache.getItem(e)];case 2:return[2,n.sent()];case 3:return r=n.sent(),this.handleDatabaseAccessError(r),[3,4];case 4:return[2,t]}}))}))},e.prototype.setItem=function(e,t){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:this.inMemoryCache.setItem(e,t),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.indexedDBCache.setItem(e,t)];case 2:return n.sent(),[3,4];case 3:return r=n.sent(),this.handleDatabaseAccessError(r),[3,4];case 4:return[2]}}))}))},e.prototype.removeItem=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(r){switch(r.label){case 0:this.inMemoryCache.removeItem(e),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.indexedDBCache.removeItem(e)];case 2:return r.sent(),[3,4];case 3:return t=r.sent(),this.handleDatabaseAccessError(t),[3,4];case 4:return[2]}}))}))},e.prototype.getKeys=function(){return o(this,void 0,void 0,(function(){var e,t;return i(this,(function(r){switch(r.label){case 0:if(0!==(e=this.inMemoryCache.getKeys()).length)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),this.logger.verbose("In-memory cache is empty, now querying persistent storage."),[4,this.indexedDBCache.getKeys()];case 2:return[2,r.sent()];case 3:return t=r.sent(),this.handleDatabaseAccessError(t),[3,4];case 4:return[2,e]}}))}))},e.prototype.containsKey=function(e){return o(this,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:if(t=this.inMemoryCache.containsKey(e))return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),this.logger.verbose("Key not found in in-memory cache, now querying persistent storage."),[4,this.indexedDBCache.containsKey(e)];case 2:return[2,n.sent()];case 3:return r=n.sent(),this.handleDatabaseAccessError(r),[3,4];case 4:return[2,t]}}))}))},e.prototype.clear=function(){return o(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:this.inMemoryCache.clear(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.indexedDBCache.deleteDatabase()];case 2:return t.sent(),[3,4];case 3:return e=t.sent(),this.handleDatabaseAccessError(e),[3,4];case 4:return[2]}}))}))},e}(),Mt=function(){function e(e){this.logger=e,this.browserCrypto=new kt(this.logger),this.b64Encode=new At,this.b64Decode=new _t,this.guidGenerator=new wt(this.browserCrypto),this.pkceGenerator=new Rt(this.browserCrypto),this.cache={asymmetricKeys:new Lt(this.logger),symmetricKeys:new Lt(this.logger)}}return e.prototype.createNewGuid=function(){return this.guidGenerator.generateGuid()},e.prototype.base64Encode=function(e){return this.b64Encode.encode(e)},e.prototype.base64Decode=function(e){return this.b64Decode.decode(e)},e.prototype.generatePkceCodes=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.pkceGenerator.generateCodes()]}))}))},e.prototype.getPublicKeyThumbprint=function(t){return o(this,void 0,void 0,(function(){var r,n,o,a,s,c,u,l;return i(this,(function(i){switch(i.label){case 0:return[4,this.browserCrypto.generateKeyPair(e.EXTRACTABLE,e.POP_KEY_USAGES)];case 1:return r=i.sent(),[4,this.browserCrypto.exportJwk(r.publicKey)];case 2:return n=i.sent(),o={e:n.e,kty:n.kty,n:n.n},a=kt.getJwkString(o),[4,this.browserCrypto.sha256Digest(a)];case 3:return s=i.sent(),c=this.b64Encode.urlEncodeArr(new Uint8Array(s)),[4,this.browserCrypto.exportJwk(r.privateKey)];case 4:return u=i.sent(),[4,this.browserCrypto.importJwk(u,!1,["sign"])];case 5:return l=i.sent(),[4,this.cache.asymmetricKeys.setItem(c,{privateKey:l,publicKey:r.publicKey,requestMethod:t.resourceRequestMethod,requestUri:t.resourceRequestUri})];case 6:return i.sent(),[2,c]}}))}))},e.prototype.removeTokenBindingKey=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.cache.asymmetricKeys.removeItem(e)];case 1:return t.sent(),[4,this.cache.asymmetricKeys.containsKey(e)];case 2:return[2,!t.sent()]}}))}))},e.prototype.clearKeystore=function(){return o(this,void 0,void 0,(function(){var e,t,r;return i(this,(function(n){switch(n.label){case 0:return e=Object.keys(this.cache),(t=this.cache[e[0]])?[4,t.deleteDatabase()]:[3,2];case 1:return r=n.sent(),[3,3];case 2:r=!1,n.label=3;case 3:return[2,r]}}))}))},e.prototype.signJwt=function(e,t){return o(this,void 0,void 0,(function(){var r,n,o,a,s,c,u,l,d,h;return i(this,(function(i){switch(i.label){case 0:return[4,this.cache.asymmetricKeys.getItem(t)];case 1:if(!(r=i.sent()))throw Ot.createSigningKeyNotFoundInStorageError(t);return[4,this.browserCrypto.exportJwk(r.publicKey)];case 2:return n=i.sent(),o=kt.getJwkString(n),a={alg:n.alg,type:mt},s=this.b64Encode.urlEncode(JSON.stringify(a)),e.cnf={jwk:JSON.parse(o)},c=this.b64Encode.urlEncode(JSON.stringify(e)),u=s+"."+c,l=Tt.stringToArrayBuffer(u),[4,this.browserCrypto.sign(r.privateKey,l)];case 3:return d=i.sent(),h=this.b64Encode.urlEncodeArr(new Uint8Array(d)),[2,u+"."+h]}}))}))},e.POP_KEY_USAGES=["sign","verify"],e.EXTRACTABLE=!0,e}(),Ft={redirectUriNotSet:{code:"redirect_uri_empty",desc:"A redirect URI is required for all calls, and none has been set."},postLogoutUriNotSet:{code:"post_logout_uri_empty",desc:"A post logout redirect has not been set."},storageNotSupportedError:{code:"storage_not_supported",desc:"Given storage configuration option was not supported."},noRedirectCallbacksSet:{code:"no_redirect_callbacks",desc:"No redirect callbacks have been set. Please call setRedirectCallbacks() with the appropriate function arguments before continuing. More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics."},invalidCallbackObject:{code:"invalid_callback_object",desc:"The object passed for the callback was invalid. More information is available here: https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics."},stubPcaInstanceCalled:{code:"stubbed_public_client_application_called",desc:"Stub instance of Public Client Application was called. If using msal-react, please ensure context is not used without a provider. For more visit: aka.ms/msaljs/browser-errors"},inMemRedirectUnavailable:{code:"in_mem_redirect_unavailable",desc:"Redirect cannot be supported. In-memory storage was selected and storeAuthStateInCookie=false, which would cause the library to be unable to handle the incoming hash. If you would like to use the redirect API, please use session/localStorage or set storeAuthStateInCookie=true."}},Ht=function(e){function t(r,n){var o=e.call(this,r,n)||this;return o.name="BrowserConfigurationAuthError",Object.setPrototypeOf(o,t.prototype),o}return r(t,e),t.createRedirectUriEmptyError=function(){return new t(Ft.redirectUriNotSet.code,Ft.redirectUriNotSet.desc)},t.createPostLogoutRedirectUriEmptyError=function(){return new t(Ft.postLogoutUriNotSet.code,Ft.postLogoutUriNotSet.desc)},t.createStorageNotSupportedError=function(e){return new t(Ft.storageNotSupportedError.code,Ft.storageNotSupportedError.desc+" Given Location: "+e)},t.createRedirectCallbacksNotSetError=function(){return new t(Ft.noRedirectCallbacksSet.code,Ft.noRedirectCallbacksSet.desc)},t.createStubPcaInstanceCalledError=function(){return new t(Ft.stubPcaInstanceCalled.code,Ft.stubPcaInstanceCalled.desc)},t.createInMemoryRedirectUnavailableError=function(){return new t(Ft.inMemRedirectUnavailable.code,Ft.inMemRedirectUnavailable.desc)},t}(X),xt=function(){function t(e){this.validateWindowStorage(e),this.windowStorage=window[e]}return t.prototype.validateWindowStorage=function(t){if(t!==e.BrowserCacheLocation.LocalStorage&&t!==e.BrowserCacheLocation.SessionStorage)throw Ht.createStorageNotSupportedError(t);if(!window[t])throw Ht.createStorageNotSupportedError(t)},t.prototype.getItem=function(e){return this.windowStorage.getItem(e)},t.prototype.setItem=function(e,t){this.windowStorage.setItem(e,t)},t.prototype.removeItem=function(e){this.windowStorage.removeItem(e)},t.prototype.getKeys=function(){return Object.keys(this.windowStorage)},t.prototype.containsKey=function(e){return this.windowStorage.hasOwnProperty(e)},t}(),qt=function(){function e(){}return e.extractBrowserRequestState=function(e,t){if(re.isEmpty(t))return null;try{return He.parseRequestState(e,t).libraryState.meta}catch(e){throw te.createInvalidStateError(t,e)}},e.parseServerResponseFromHash=function(e){if(!e)return{};var t=new xe(e);return xe.getDeserializedHash(t.getHash())},e}(),Bt=function(t){function n(e,r,n,o){var i=t.call(this,e,n)||this;return i.COOKIE_LIFE_MULTIPLIER=864e5,i.cacheConfig=r,i.logger=o,i.internalStorage=new Dt,i.browserStorage=i.setupBrowserStorage(i.cacheConfig.cacheLocation),i.temporaryCacheStorage=i.setupTemporaryCacheStorage(i.cacheConfig.cacheLocation),i.migrateCacheEntries(),i}return r(n,t),n.prototype.setupBrowserStorage=function(t){switch(t){case e.BrowserCacheLocation.LocalStorage:case e.BrowserCacheLocation.SessionStorage:try{return new xt(t)}catch(e){this.logger.verbose(e);break}case e.BrowserCacheLocation.MemoryStorage:}return this.cacheConfig.cacheLocation=e.BrowserCacheLocation.MemoryStorage,new Dt},n.prototype.setupTemporaryCacheStorage=function(t){switch(t){case e.BrowserCacheLocation.LocalStorage:case e.BrowserCacheLocation.SessionStorage:try{return new xt(e.BrowserCacheLocation.SessionStorage)}catch(e){return this.logger.verbose(e),this.internalStorage}case e.BrowserCacheLocation.MemoryStorage:default:return this.internalStorage}},n.prototype.migrateCacheEntries=function(){var e=this,t=m.CACHE_PREFIX+"."+g.ID_TOKEN,r=m.CACHE_PREFIX+"."+g.CLIENT_INFO,n=m.CACHE_PREFIX+"."+g.ERROR,o=m.CACHE_PREFIX+"."+g.ERROR_DESC,i=[this.browserStorage.getItem(t),this.browserStorage.getItem(r),this.browserStorage.getItem(n),this.browserStorage.getItem(o)];[g.ID_TOKEN,g.CLIENT_INFO,g.ERROR,g.ERROR_DESC].forEach((function(t,r){return e.migrateCacheEntry(t,i[r])}))},n.prototype.migrateCacheEntry=function(e,t){t&&this.setTemporaryCache(e,t,!0)},n.prototype.validateAndParseJson=function(e){try{var t=JSON.parse(e);return t&&"object"==typeof t?t:null}catch(e){return null}},n.prototype.getItem=function(e){return this.browserStorage.getItem(e)},n.prototype.setItem=function(e,t){this.browserStorage.setItem(e,t)},n.prototype.getAccount=function(e){var t=this.getItem(e);if(!t)return null;var r=this.validateAndParseJson(t);return r&&pe.isAccountEntity(r)?ge.toObject(new pe,r):null},n.prototype.setAccount=function(e){this.logger.trace("BrowserCacheManager.setAccount called");var t=e.generateAccountKey();this.setItem(t,JSON.stringify(e))},n.prototype.getIdTokenCredential=function(e){var t=this.getItem(e);if(!t)return this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit"),null;var r=this.validateAndParseJson(t);return r&&Re.isIdTokenEntity(r)?(this.logger.trace("BrowserCacheManager.getIdTokenCredential: cache hit"),ge.toObject(new Re,r)):(this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit"),null)},n.prototype.setIdTokenCredential=function(e){this.logger.trace("BrowserCacheManager.setIdTokenCredential called");var t=e.generateCredentialKey();this.setItem(t,JSON.stringify(e))},n.prototype.getAccessTokenCredential=function(e){var t=this.getItem(e);if(!t)return this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit"),null;var r=this.validateAndParseJson(t);return r&&Pe.isAccessTokenEntity(r)?(this.logger.trace("BrowserCacheManager.getAccessTokenCredential: cache hit"),ge.toObject(new Pe,r)):(this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit"),null)},n.prototype.setAccessTokenCredential=function(e){this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");var t=e.generateCredentialKey();this.setItem(t,JSON.stringify(e))},n.prototype.getRefreshTokenCredential=function(e){var t=this.getItem(e);if(!t)return this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit"),null;var r=this.validateAndParseJson(t);return r&&ke.isRefreshTokenEntity(r)?(this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: cache hit"),ge.toObject(new ke,r)):(this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit"),null)},n.prototype.setRefreshTokenCredential=function(e){this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");var t=e.generateCredentialKey();this.setItem(t,JSON.stringify(e))},n.prototype.getAppMetadata=function(e){var t=this.getItem(e);if(!t)return this.logger.trace("BrowserCacheManager.getAppMetadata: called, no cache hit"),null;var r=this.validateAndParseJson(t);return r&&Ke.isAppMetadataEntity(e,r)?(this.logger.trace("BrowserCacheManager.getAppMetadata: cache hit"),ge.toObject(new Ke,r)):(this.logger.trace("BrowserCacheManager.getAppMetadata: called, no cache hit"),null)},n.prototype.setAppMetadata=function(e){this.logger.trace("BrowserCacheManager.setAppMetadata called");var t=e.generateAppMetadataKey();this.setItem(t,JSON.stringify(e))},n.prototype.getServerTelemetry=function(e){var t=this.getItem(e);if(!t)return this.logger.trace("BrowserCacheManager.getServerTelemetry: called, no cache hit"),null;var r=this.validateAndParseJson(t);return r&&at.isServerTelemetryEntity(e,r)?(this.logger.trace("BrowserCacheManager.getServerTelemetry: cache hit"),ge.toObject(new at,r)):(this.logger.trace("BrowserCacheManager.getServerTelemetry: called, no cache hit"),null)},n.prototype.setServerTelemetry=function(e,t){this.logger.trace("BrowserCacheManager.setServerTelemetry called"),this.setItem(e,JSON.stringify(t))},n.prototype.getAuthorityMetadata=function(e){var t=this.internalStorage.getItem(e);if(!t)return this.logger.trace("BrowserCacheManager.getAuthorityMetadata: called, no cache hit"),null;var r=this.validateAndParseJson(t);return r&&rt.isAuthorityMetadataEntity(e,r)?(this.logger.trace("BrowserCacheManager.getAuthorityMetadata: cache hit"),ge.toObject(new rt,r)):null},n.prototype.getAuthorityMetadataKeys=function(){var e=this;return this.internalStorage.getKeys().filter((function(t){return e.isAuthorityMetadata(t)}))},n.prototype.setWrapperMetadata=function(e,t){this.internalStorage.setItem(Xe.WRAPPER_SKU,e),this.internalStorage.setItem(Xe.WRAPPER_VER,t)},n.prototype.getWrapperMetadata=function(){return[this.internalStorage.getItem(Xe.WRAPPER_SKU)||"",this.internalStorage.getItem(Xe.WRAPPER_VER)||""]},n.prototype.setAuthorityMetadata=function(e,t){this.logger.trace("BrowserCacheManager.setAuthorityMetadata called"),this.internalStorage.setItem(e,JSON.stringify(t))},n.prototype.getActiveAccount=function(){var e=this.generateCacheKey(g.ACTIVE_ACCOUNT),t=this.browserStorage.getItem(e);return t&&this.getAccountInfoByFilter({localAccountId:t})[0]||null},n.prototype.setActiveAccount=function(e){var t=this.generateCacheKey(g.ACTIVE_ACCOUNT);e?(this.logger.verbose("setActiveAccount: Active account set"),this.browserStorage.setItem(t,e.localAccountId)):(this.logger.verbose("setActiveAccount: No account passed, active account not set"),this.browserStorage.removeItem(t))},n.prototype.getAccountInfoByFilter=function(e){return this.getAllAccounts().filter((function(t){return!(e.username&&e.username.toLowerCase()!==t.username.toLowerCase()||e.homeAccountId&&e.homeAccountId!==t.homeAccountId||e.localAccountId&&e.localAccountId!==t.localAccountId||e.tenantId&&e.tenantId!==t.tenantId||e.environment&&e.environment!==t.environment)}))},n.prototype.getThrottlingCache=function(e){var t=this.getItem(e);if(!t)return this.logger.trace("BrowserCacheManager.getThrottlingCache: called, no cache hit"),null;var r=this.validateAndParseJson(t);return r&&st.isThrottlingEntity(e,r)?(this.logger.trace("BrowserCacheManager.getThrottlingCache: cache hit"),ge.toObject(new st,r)):(this.logger.trace("BrowserCacheManager.getThrottlingCache: called, no cache hit"),null)},n.prototype.setThrottlingCache=function(e,t){this.logger.trace("BrowserCacheManager.setThrottlingCache called"),this.setItem(e,JSON.stringify(t))},n.prototype.getTemporaryCache=function(t,r){var n=r?this.generateCacheKey(t):t;if(this.cacheConfig.storeAuthStateInCookie){var o=this.getItemCookie(n);if(o)return this.logger.trace("BrowserCacheManager.getTemporaryCache: storeAuthStateInCookies set to true, retrieving from cookies"),o}var i=this.temporaryCacheStorage.getItem(n);if(!i){if(this.cacheConfig.cacheLocation===e.BrowserCacheLocation.LocalStorage){var a=this.browserStorage.getItem(n);if(a)return this.logger.trace("BrowserCacheManager.getTemporaryCache: Temporary cache item found in local storage"),a}return this.logger.trace("BrowserCacheManager.getTemporaryCache: No cache item found in local storage"),null}return this.logger.trace("BrowserCacheManager.getTemporaryCache: Temporary cache item returned"),i},n.prototype.setTemporaryCache=function(e,t,r){var n=r?this.generateCacheKey(e):e;this.temporaryCacheStorage.setItem(n,t),this.cacheConfig.storeAuthStateInCookie&&(this.logger.trace("BrowserCacheManager.setTemporaryCache: storeAuthStateInCookie set to true, setting item cookie"),this.setItemCookie(n,t))},n.prototype.removeItem=function(e){return this.browserStorage.removeItem(e),this.temporaryCacheStorage.removeItem(e),this.cacheConfig.storeAuthStateInCookie&&(this.logger.trace("BrowserCacheManager.removeItem: storeAuthStateInCookie is true, clearing item cookie"),this.clearItemCookie(e)),!0},n.prototype.containsKey=function(e){return this.browserStorage.containsKey(e)||this.temporaryCacheStorage.containsKey(e)},n.prototype.getKeys=function(){return s(this.browserStorage.getKeys(),this.temporaryCacheStorage.getKeys())},n.prototype.clear=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){switch(t.label){case 0:return[4,this.removeAllAccounts()];case 1:return t.sent(),this.removeAppMetadata(),this.getKeys().forEach((function(t){!e.browserStorage.containsKey(t)&&!e.temporaryCacheStorage.containsKey(t)||-1===t.indexOf(m.CACHE_PREFIX)&&-1===t.indexOf(e.clientId)||e.removeItem(t)})),this.internalStorage.clear(),[2]}}))}))},n.prototype.setItemCookie=function(e,t,r){var n=encodeURIComponent(e)+"="+encodeURIComponent(t)+";path=/;";r&&(n+="expires="+this.getCookieExpirationTime(r)+";"),this.cacheConfig.secureCookies&&(n+="Secure;"),document.cookie=n},n.prototype.getItemCookie=function(e){for(var t=encodeURIComponent(e)+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var o=r[n];" "===o.charAt(0);)o=o.substring(1);if(0===o.indexOf(t))return decodeURIComponent(o.substring(t.length,o.length))}return""},n.prototype.clearMsalCookies=function(){var e=this,t=m.CACHE_PREFIX+"."+this.clientId;document.cookie.split(";").forEach((function(r){for(;" "===r.charAt(0);)r=r.substring(1);if(0===r.indexOf(t)){var n=r.split("=")[0];e.clearItemCookie(n)}}))},n.prototype.clearItemCookie=function(e){this.setItemCookie(e,"",-1)},n.prototype.getCookieExpirationTime=function(e){var t=new Date;return new Date(t.getTime()+e*this.COOKIE_LIFE_MULTIPLIER).toUTCString()},n.prototype.getCache=function(){return this.browserStorage},n.prototype.setCache=function(){},n.prototype.generateCacheKey=function(e){return this.validateAndParseJson(e)?JSON.stringify(e):re.startsWith(e,m.CACHE_PREFIX)||re.startsWith(e,g.ADAL_ID_TOKEN)?e:m.CACHE_PREFIX+"."+this.clientId+"."+e},n.prototype.generateAuthorityKey=function(e){var t=He.parseRequestState(this.cryptoImpl,e).libraryState.id;return this.generateCacheKey(Qe.AUTHORITY+"."+t)},n.prototype.generateNonceKey=function(e){var t=He.parseRequestState(this.cryptoImpl,e).libraryState.id;return this.generateCacheKey(Qe.NONCE_IDTOKEN+"."+t)},n.prototype.generateStateKey=function(e){var t=He.parseRequestState(this.cryptoImpl,e).libraryState.id;return this.generateCacheKey(Qe.REQUEST_STATE+"."+t)},n.prototype.getCachedAuthority=function(e){var t=this.generateStateKey(e),r=this.getTemporaryCache(t);if(!r)return null;var n=this.generateAuthorityKey(r);return this.getTemporaryCache(n)},n.prototype.updateCacheEntries=function(e,t,r,n,o){this.logger.trace("BrowserCacheManager.updateCacheEntries called");var i=this.generateStateKey(e);this.setTemporaryCache(i,e,!1);var a=this.generateNonceKey(e);this.setTemporaryCache(a,t,!1);var s=this.generateAuthorityKey(e);if(this.setTemporaryCache(s,r,!1),o){var c={credential:o.homeAccountId,type:he.HOME_ACCOUNT_ID};this.setTemporaryCache(Qe.CCS_CREDENTIAL,JSON.stringify(c),!0)}else re.isEmpty(n)||(c={credential:n,type:he.UPN},this.setTemporaryCache(Qe.CCS_CREDENTIAL,JSON.stringify(c),!0))},n.prototype.resetRequestCache=function(e){var t=this;this.logger.trace("BrowserCacheManager.resetRequestCache called"),re.isEmpty(e)||this.getKeys().forEach((function(r){-1!==r.indexOf(e)&&t.removeItem(r)})),e&&(this.removeItem(this.generateStateKey(e)),this.removeItem(this.generateNonceKey(e)),this.removeItem(this.generateAuthorityKey(e))),this.removeItem(this.generateCacheKey(Qe.REQUEST_PARAMS)),this.removeItem(this.generateCacheKey(Qe.ORIGIN_URI)),this.removeItem(this.generateCacheKey(Qe.URL_HASH)),this.removeItem(this.generateCacheKey(Qe.CORRELATION_ID)),this.removeItem(this.generateCacheKey(Qe.CCS_CREDENTIAL)),this.setInteractionInProgress(!1)},n.prototype.cleanRequestByState=function(e){if(this.logger.trace("BrowserCacheManager.cleanRequestByState called"),e){var t=this.generateStateKey(e),r=this.temporaryCacheStorage.getItem(t);this.logger.infoPii("BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: "+r),this.resetRequestCache(r||"")}this.clearMsalCookies()},n.prototype.cleanRequestByInteractionType=function(e){var t=this;this.logger.trace("BrowserCacheManager.cleanRequestByInteractionType called"),this.getKeys().forEach((function(r){if(-1!==r.indexOf(Qe.REQUEST_STATE)){var n=t.temporaryCacheStorage.getItem(r);if(n){var o=qt.extractBrowserRequestState(t.cryptoImpl,n);o&&o.interactionType===e&&(t.logger.infoPii("BrowserCacheManager.cleanRequestByInteractionType: Removing temporary cache items for state: "+n),t.resetRequestCache(n))}}})),this.clearMsalCookies()},n.prototype.cacheCodeRequest=function(e,t){this.logger.trace("BrowserCacheManager.cacheCodeRequest called");var r=t.base64Encode(JSON.stringify(e));this.setTemporaryCache(Qe.REQUEST_PARAMS,r,!0)},n.prototype.getCachedRequest=function(e,t){this.logger.trace("BrowserCacheManager.getCachedRequest called");var r=this.getTemporaryCache(Qe.REQUEST_PARAMS,!0);if(!r)throw Ot.createNoTokenRequestCacheError();var n=this.validateAndParseJson(t.base64Decode(r));if(!n)throw Ot.createUnableToParseTokenRequestCacheError();if(this.removeItem(this.generateCacheKey(Qe.REQUEST_PARAMS)),re.isEmpty(n.authority)){var o=this.generateAuthorityKey(e),i=this.getTemporaryCache(o);if(!i)throw Ot.createNoCachedAuthorityError();n.authority=i}return n},n.prototype.isInteractionInProgress=function(e){var t=this.getInteractionInProgress();return e?t===this.clientId:!!t},n.prototype.getInteractionInProgress=function(){var e=m.CACHE_PREFIX+"."+Qe.INTERACTION_STATUS_KEY;return this.getTemporaryCache(e,!1)},n.prototype.setInteractionInProgress=function(e){var t=this.getInteractionInProgress(),r=m.CACHE_PREFIX+"."+Qe.INTERACTION_STATUS_KEY;e&&!t?this.setTemporaryCache(r,this.clientId,!1):e||t!==this.clientId||this.removeItem(r)},n.prototype.getLegacyLoginHint=function(){var e=this.getTemporaryCache(g.ADAL_ID_TOKEN);e&&(this.browserStorage.removeItem(g.ADAL_ID_TOKEN),this.logger.verbose("Cached ADAL id token retrieved."));var t=this.getTemporaryCache(g.ID_TOKEN,!0);t&&(this.removeItem(this.generateCacheKey(g.ID_TOKEN)),this.logger.verbose("Cached MSAL.js v1 id token retrieved"));var r=t||e;if(r){var n=new fe(r,this.cryptoImpl);if(n.claims&&n.claims.preferred_username)return this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 preferred_username as loginHint"),n.claims.preferred_username;if(n.claims&&n.claims.upn)return this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 upn as loginHint"),n.claims.upn;this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, however, no account hint claim found. Enable preferred_username or upn id token claim to get SSO.")}return null},n}(ge),Kt=function(){function e(){}return e.prototype.sendGetRequestAsync=function(e,t){return o(this,void 0,void 0,(function(){var r,n,o;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,fetch(e,{method:Je.GET,headers:this.getFetchHeaders(t)})];case 1:return r=i.sent(),[3,3];case 2:throw n=i.sent(),window.navigator.onLine?Ot.createGetRequestFailedError(n,e):Ot.createNoNetworkConnectivityError();case 3:return i.trys.push([3,5,,6]),o={headers:this.getHeaderDict(r.headers)},[4,r.json()];case 4:return[2,(o.body=i.sent(),o.status=r.status,o)];case 5:throw i.sent(),Ot.createFailedToParseNetworkResponseError(e);case 6:return[2]}}))}))},e.prototype.sendPostRequestAsync=function(e,t){return o(this,void 0,void 0,(function(){var r,n,o,a;return i(this,(function(i){switch(i.label){case 0:r=t&&t.body||"",i.label=1;case 1:return i.trys.push([1,3,,4]),[4,fetch(e,{method:Je.POST,headers:this.getFetchHeaders(t),body:r})];case 2:return n=i.sent(),[3,4];case 3:throw o=i.sent(),window.navigator.onLine?Ot.createPostRequestFailedError(o,e):Ot.createNoNetworkConnectivityError();case 4:return i.trys.push([4,6,,7]),a={headers:this.getHeaderDict(n.headers)},[4,n.json()];case 5:return[2,(a.body=i.sent(),a.status=n.status,a)];case 6:throw i.sent(),Ot.createFailedToParseNetworkResponseError(e);case 7:return[2]}}))}))},e.prototype.getFetchHeaders=function(e){var t=new Headers;if(!e||!e.headers)return t;var r=e.headers;return Object.keys(r).forEach((function(e){t.append(e,r[e])})),t},e.prototype.getHeaderDict=function(e){var t={};return e.forEach((function(e,r){t[r]=e})),t},e}(),jt=function(){function e(){}return e.prototype.sendGetRequestAsync=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.sendRequestAsync(e,Je.GET,t)]}))}))},e.prototype.sendPostRequestAsync=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.sendRequestAsync(e,Je.POST,t)]}))}))},e.prototype.sendRequestAsync=function(e,t,r){var n=this;return new Promise((function(o,i){var a=new XMLHttpRequest;if(a.open(t,e,!0),n.setXhrHeaders(a,r),a.onload=function(){(a.status<200||a.status>=300)&&(t===Je.POST?i(Ot.createPostRequestFailedError("Failed with status "+a.status,e)):i(Ot.createGetRequestFailedError("Failed with status "+a.status,e)));try{var r=JSON.parse(a.responseText),s={headers:n.getHeaderDict(a),body:r,status:a.status};o(s)}catch(t){i(Ot.createFailedToParseNetworkResponseError(e))}},a.onerror=function(){window.navigator.onLine?t===Je.POST?i(Ot.createPostRequestFailedError("Failed with status "+a.status,e)):i(Ot.createGetRequestFailedError("Failed with status "+a.status,e)):i(Ot.createNoNetworkConnectivityError())},t===Je.POST&&r&&r.body)a.send(r.body);else{if(t!==Je.GET)throw Ot.createHttpMethodNotImplementedError(t);a.send()}}))},e.prototype.setXhrHeaders=function(e,t){if(t&&t.headers){var r=t.headers;Object.keys(r).forEach((function(t){e.setRequestHeader(t,r[t])}))}},e.prototype.getHeaderDict=function(e){var t=e.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};return t.forEach((function(e){var t=e.split(": "),n=t.shift(),o=t.join(": ");n&&o&&(r[n]=o)})),r},e}(),Gt=function(){function t(){}return t.clearHash=function(e){e.location.hash=m.EMPTY_STRING,"function"==typeof e.history.replaceState&&e.history.replaceState(null,m.EMPTY_STRING,""+e.location.origin+e.location.pathname+e.location.search)},t.replaceHash=function(e){var t=e.split("#");t.shift(),window.location.hash=t.length>0?t.join("#"):""},t.isInIframe=function(){return window.parent!==window},t.isInPopup=function(){return"undefined"!=typeof window&&!!window.opener&&window.opener!==window&&"string"==typeof window.name&&0===window.name.indexOf(ft+".")},t.getCurrentUri=function(){return window.location.href.split("?")[0].split("#")[0]},t.getHomepage=function(){var e=new xe(window.location.href).getUrlComponents();return e.Protocol+"//"+e.HostNameAndPort+"/"},t.getBrowserNetworkClient=function(){return window.fetch&&window.Headers?new Kt:new jt},t.blockReloadInHiddenIframes=function(){if(xe.hashContainsKnownProperties(window.location.hash)&&t.isInIframe())throw Ot.createBlockReloadInHiddenIframeError()},t.blockRedirectInIframe=function(r,n){var o=t.isInIframe();if(r===e.InteractionType.Redirect&&o&&!n)throw Ot.createRedirectInIframeError(o)},t.blockAcquireTokenInPopups=function(){if(t.isInPopup())throw Ot.createBlockAcquireTokenInPopupsError()},t.blockNonBrowserEnvironment=function(e){if(!e)throw Ot.createNonBrowserEnvironmentError()},t.detectIEOrEdge=function(){var e=window.navigator.userAgent,t=e.indexOf("MSIE "),r=e.indexOf("Trident/"),n=e.indexOf("Edge/");return t>0||r>0||n>0},t}(),Wt=function(){function e(){}return e.prototype.navigateInternal=function(t,r){return e.defaultNavigateWindow(t,r)},e.prototype.navigateExternal=function(t,r){return e.defaultNavigateWindow(t,r)},e.defaultNavigateWindow=function(e,t){return t.noHistory?window.location.replace(e):window.location.assign(e),new Promise((function(e){setTimeout((function(){e(!0)}),t.timeout)}))},e}(),Vt=6e3,zt="@azure/msal-browser",$t="2.19.0";e.EventType=void 0,(Ct=e.EventType||(e.EventType={})).ACCOUNT_ADDED="msal:accountAdded",Ct.ACCOUNT_REMOVED="msal:accountRemoved",Ct.LOGIN_START="msal:loginStart",Ct.LOGIN_SUCCESS="msal:loginSuccess",Ct.LOGIN_FAILURE="msal:loginFailure",Ct.ACQUIRE_TOKEN_START="msal:acquireTokenStart",Ct.ACQUIRE_TOKEN_SUCCESS="msal:acquireTokenSuccess",Ct.ACQUIRE_TOKEN_FAILURE="msal:acquireTokenFailure",Ct.ACQUIRE_TOKEN_NETWORK_START="msal:acquireTokenFromNetworkStart",Ct.SSO_SILENT_START="msal:ssoSilentStart",Ct.SSO_SILENT_SUCCESS="msal:ssoSilentSuccess",Ct.SSO_SILENT_FAILURE="msal:ssoSilentFailure",Ct.HANDLE_REDIRECT_START="msal:handleRedirectStart",Ct.HANDLE_REDIRECT_END="msal:handleRedirectEnd",Ct.POPUP_OPENED="msal:popupOpened",Ct.LOGOUT_START="msal:logoutStart",Ct.LOGOUT_SUCCESS="msal:logoutSuccess",Ct.LOGOUT_FAILURE="msal:logoutFailure",Ct.LOGOUT_END="msal:logoutEnd";var Yt=function(){function t(e,t){this.eventCallbacks=new Map,this.logger=e,this.browserCrypto=t,this.listeningToStorageEvents=!1,this.handleAccountCacheChange=this.handleAccountCacheChange.bind(this)}return t.prototype.addEventCallback=function(e){if("undefined"!=typeof window){var t=this.browserCrypto.createNewGuid();return this.eventCallbacks.set(t,e),this.logger.verbose("Event callback registered with id: "+t),t}return null},t.prototype.removeEventCallback=function(e){this.eventCallbacks.delete(e),this.logger.verbose("Event callback "+e+" removed.")},t.prototype.enableAccountStorageEvents=function(){"undefined"!=typeof window&&(this.listeningToStorageEvents?this.logger.verbose("Account storage listener already registered."):(this.logger.verbose("Adding account storage listener."),this.listeningToStorageEvents=!0,window.addEventListener("storage",this.handleAccountCacheChange)))},t.prototype.disableAccountStorageEvents=function(){"undefined"!=typeof window&&(this.listeningToStorageEvents?(this.logger.verbose("Removing account storage listener."),window.removeEventListener("storage",this.handleAccountCacheChange),this.listeningToStorageEvents=!1):this.logger.verbose("No account storage listener registered."))},t.prototype.emitEvent=function(e,t,r,n){var o=this;if("undefined"!=typeof window){var i={eventType:e,interactionType:t||null,payload:r||null,error:n||null,timestamp:Date.now()};this.logger.info("Emitting event: "+e),this.eventCallbacks.forEach((function(t,r){o.logger.verbose("Emitting event to callback "+r+": "+e),t.apply(null,[i])}))}},t.prototype.handleAccountCacheChange=function(t){try{var r=t.newValue||t.oldValue;if(!r)return;var n=JSON.parse(r);if("object"!=typeof n||!pe.isAccountEntity(n))return;var o=ge.toObject(new pe,n).getAccountInfo();!t.oldValue&&t.newValue?(this.logger.info("Account was added to cache in a different window"),this.emitEvent(e.EventType.ACCOUNT_ADDED,void 0,o)):!t.newValue&&t.oldValue&&(this.logger.info("Account was removed from cache in a different window"),this.emitEvent(e.EventType.ACCOUNT_REMOVED,void 0,o))}catch(t){return}},t}(),Jt=function(e){function t(t,r,n,o,i,a,s){var c=e.call(this,t,r,n,o,i,s)||this;return c.navigationClient=a,c}return r(t,e),t.prototype.initializeAuthorizationCodeRequest=function(e){return o(this,void 0,void 0,(function(){var t,r;return i(this,(function(o){switch(o.label){case 0:return this.logger.verbose("initializeAuthorizationRequest called",e.correlationId),[4,this.browserCrypto.generatePkceCodes()];case 1:return t=o.sent(),r=n(n({},e),{redirectUri:e.redirectUri,code:"",codeVerifier:t.verifier}),e.codeChallenge=t.challenge,e.codeChallengeMethod=m.S256_CODE_CHALLENGE_METHOD,[2,r]}}))}))},t.prototype.initializeLogoutRequest=function(e){if(this.logger.verbose("initializeLogoutRequest called",null==e?void 0:e.correlationId),this.browserStorage.isInteractionInProgress())throw Ot.createInteractionInProgressError();var t=n({correlationId:this.browserCrypto.createNewGuid()},e);return e&&null===e.postLogoutRedirectUri?this.logger.verbose("postLogoutRedirectUri passed as null, not setting post logout redirect uri",t.correlationId):e&&e.postLogoutRedirectUri?(this.logger.verbose("Setting postLogoutRedirectUri to uri set on logout request",t.correlationId),t.postLogoutRedirectUri=xe.getAbsoluteUrl(e.postLogoutRedirectUri,Gt.getCurrentUri())):null===this.config.auth.postLogoutRedirectUri?this.logger.verbose("postLogoutRedirectUri configured as null and no uri set on request, not passing post logout redirect",t.correlationId):this.config.auth.postLogoutRedirectUri?(this.logger.verbose("Setting postLogoutRedirectUri to configured uri",t.correlationId),t.postLogoutRedirectUri=xe.getAbsoluteUrl(this.config.auth.postLogoutRedirectUri,Gt.getCurrentUri())):(this.logger.verbose("Setting postLogoutRedirectUri to current page",t.correlationId),t.postLogoutRedirectUri=xe.getAbsoluteUrl(Gt.getCurrentUri(),Gt.getCurrentUri())),t},t.prototype.createAuthCodeClient=function(e,t){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return[4,this.getClientConfiguration(e,t)];case 1:return r=n.sent(),[2,new We(r)]}}))}))},t.prototype.getClientConfiguration=function(e,t){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return this.logger.verbose("getClientConfiguration called"),[4,this.getDiscoveredAuthority(t)];case 1:return r=n.sent(),[2,{authOptions:{clientId:this.config.auth.clientId,authority:r,clientCapabilities:this.config.auth.clientCapabilities},systemOptions:{tokenRenewalOffsetSeconds:this.config.system.tokenRenewalOffsetSeconds,preventCorsPreflight:!0},loggerOptions:{loggerCallback:this.config.system.loggerOptions.loggerCallback,piiLoggingEnabled:this.config.system.loggerOptions.piiLoggingEnabled,logLevel:this.config.system.loggerOptions.logLevel,correlationId:this.correlationId},cryptoInterface:this.browserCrypto,networkInterface:this.networkClient,storageInterface:this.browserStorage,serverTelemetryManager:e,libraryInfo:{sku:yt,version:$t,cpu:"",os:""}}]}}))}))},t.prototype.validateAndExtractStateFromHash=function(e,t,r){this.logger.verbose("validateAndExtractStateFromHash called",r);var n=xe.getDeserializedHash(e);if(!n.state)throw Ot.createHashDoesNotContainStateError();var o=qt.extractBrowserRequestState(this.browserCrypto,n.state);if(!o)throw Ot.createUnableToParseStateError();if(o.interactionType!==t)throw Ot.createStateInteractionTypeMismatchError();return this.logger.verbose("Returning state from hash",r),n.state},t.prototype.getDiscoveredAuthority=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return this.logger.verbose("getDiscoveredAuthority called"),t={protocolMode:this.config.auth.protocolMode,knownAuthorities:this.config.auth.knownAuthorities,cloudDiscoveryMetadata:this.config.auth.cloudDiscoveryMetadata,authorityMetadata:this.config.auth.authorityMetadata},e?(this.logger.verbose("Creating discovered authority with request authority"),[4,it.createDiscoveredInstance(e,this.config.system.networkClient,this.browserStorage,t)]):[3,2];case 1:case 3:return[2,r.sent()];case 2:return this.logger.verbose("Creating discovered authority with configured authority"),[4,it.createDiscoveredInstance(this.config.auth.authority,this.config.system.networkClient,this.browserStorage,t)]}}))}))},t.prototype.preflightInteractiveRequest=function(e,t){if(this.logger.verbose("preflightInteractiveRequest called, validating app environment",null==e?void 0:e.correlationId),Gt.blockReloadInHiddenIframes(),this.browserStorage.isInteractionInProgress(!1))throw Ot.createInteractionInProgressError();return this.initializeAuthorizationRequest(e,t)},t.prototype.initializeAuthorizationRequest=function(e,t){this.logger.verbose("initializeAuthorizationRequest called");var r=this.getRedirectUri(e.redirectUri),o={interactionType:t},i=He.setRequestState(this.browserCrypto,e&&e.state||"",o),a=n(n({},this.initializeBaseRequest(e)),{redirectUri:r,state:i,nonce:e.nonce||this.browserCrypto.createNewGuid(),responseMode:T.FRAGMENT}),s=e.account||this.browserStorage.getActiveAccount();if(s&&(this.logger.verbose("Setting validated request account"),this.logger.verbosePii("Setting validated request account: "+s),a.account=s),re.isEmpty(a.loginHint)&&!s){var c=this.browserStorage.getLegacyLoginHint();c&&(a.loginHint=c)}return this.browserStorage.updateCacheEntries(a.state,a.nonce,a.authority,a.loginHint||"",a.account||null),a},t}(function(){function t(e,t,r,n,o,i){this.config=e,this.browserStorage=t,this.browserCrypto=r,this.networkClient=this.config.system.networkClient,this.eventHandler=o,this.correlationId=i||this.browserCrypto.createNewGuid(),this.logger=n.clone(yt,$t,this.correlationId)}return t.prototype.clearCacheOnLogout=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(!e)return[3,5];pe.accountInfoIsEqual(e,this.browserStorage.getActiveAccount(),!1)&&(this.logger.verbose("Setting active account to null"),this.browserStorage.setActiveAccount(null)),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.browserStorage.removeAccount(pe.generateAccountCacheKey(e))];case 2:return t.sent(),this.logger.verbose("Cleared cache items belonging to the account provided in the logout request."),[3,4];case 3:return t.sent(),this.logger.error("Account provided in logout request was not found. Local cache unchanged."),[3,4];case 4:return[3,9];case 5:return t.trys.push([5,8,,9]),[4,this.browserStorage.clear()];case 6:return t.sent(),[4,this.browserCrypto.clearKeystore()];case 7:return t.sent(),this.logger.verbose("No account provided in logout request, clearing all cache items."),[3,9];case 8:return t.sent(),this.logger.error("Attempted to clear all MSAL cache items and failed. Local cache unchanged."),[3,9];case 9:return[2]}}))}))},t.prototype.initializeBaseRequest=function(t){this.logger.verbose("Initializing BaseAuthRequest");var r=t.authority||this.config.auth.authority,o=s(t&&t.scopes||[]);if(t.authenticationScheme){if(t.authenticationScheme===e.AuthenticationScheme.SSH){if(!t.sshJwk)throw ce.createMissingSshJwkError();if(!t.sshKid)throw ce.createMissingSshKidError()}this.logger.verbose('Authentication Scheme set to "'+t.authenticationScheme+'" as configured in Auth request')}else t.authenticationScheme=e.AuthenticationScheme.BEARER,this.logger.verbose('Authentication Scheme wasn\'t explicitly set in request, defaulting to "Bearer" request');return n(n({},t),{correlationId:this.correlationId,authority:r,scopes:o})},t.prototype.getRedirectUri=function(e){this.logger.verbose("getRedirectUri called");var t=e||this.config.auth.redirectUri||Gt.getCurrentUri();return xe.getAbsoluteUrl(t,Gt.getCurrentUri())},t.prototype.initializeServerTelemetryManager=function(e,t){this.logger.verbose("initializeServerTelemetryManager called");var r={clientId:this.config.auth.clientId,correlationId:this.correlationId,apiId:e,forceRefresh:t||!1,wrapperSKU:this.browserStorage.getWrapperMetadata()[0],wrapperVer:this.browserStorage.getWrapperMetadata()[1]};return new lt(r,this.browserStorage)},t}()),Qt=function(){function t(e,t){this.browserStorage=e,this.logger=t,this.unloadWindow=this.unloadWindow.bind(this)}return t.prototype.openPopup=function(e,r){try{var n=void 0;if(r.popup?(n=r.popup,this.logger.verbosePii("Navigating popup window to: "+e),n.location.assign(e)):void 0===r.popup&&(this.logger.verbosePii("Opening popup window to: "+e),n=t.openSizedPopup(e,r.popupName,r.popupWindowAttributes,this.logger)),!n)throw Ot.createEmptyWindowCreatedError();return n.focus&&n.focus(),this.currentWindow=n,window.addEventListener("beforeunload",this.unloadWindow),n}catch(e){throw this.logger.error("error opening popup "+e.message),this.browserStorage.setInteractionInProgress(!1),Ot.createPopupWindowError(e.toString())}},t.openSizedPopup=function(e,t,r,n){var o,i,a,s,c=window.screenLeft?window.screenLeft:window.screenX,u=window.screenTop?window.screenTop:window.screenY,l=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,d=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,h=null===(o=r.popupSize)||void 0===o?void 0:o.width,p=null===(i=r.popupSize)||void 0===i?void 0:i.height,f=null===(a=r.popupPosition)||void 0===a?void 0:a.top,g=null===(s=r.popupPosition)||void 0===s?void 0:s.left;return(!h||h<0||h>l)&&(n.verbose("Default popup window width used. Window width not configured or invalid."),h=ht),(!p||p<0||p>d)&&(n.verbose("Default popup window height used. Window height not configured or invalid."),p=pt),(!f||f<0||f>d)&&(n.verbose("Default popup window top position used. Window top not configured or invalid."),f=Math.max(0,d/2-pt/2+u)),(!g||g<0||g>l)&&(n.verbose("Default popup window left position used. Window left not configured or invalid."),g=Math.max(0,l/2-ht/2+c)),window.open(e,t,"width="+h+", height="+p+", top="+f+", left="+g+", scrollbars=yes")},t.prototype.unloadWindow=function(t){this.browserStorage.cleanRequestByInteractionType(e.InteractionType.Popup),this.currentWindow&&this.currentWindow.close(),t.preventDefault()},t.prototype.cleanPopup=function(e){e&&e.close(),window.removeEventListener("beforeunload",this.unloadWindow),this.browserStorage.setInteractionInProgress(!1)},t.prototype.monitorPopupForSameOrigin=function(e){var t=this;return new Promise((function(r,n){var o=setInterval((function(){if(e.closed)return t.cleanPopup(),clearInterval(o),void n(Ot.createUserCancelledError());var i=m.EMPTY_STRING;try{i=e.location.href}catch(e){}re.isEmpty(i)||"about:blank"===i||(clearInterval(o),r())}),gt)}))},t.generatePopupName=function(e,t){return ft+"."+e+"."+t.scopes.join("-")+"."+t.authority+"."+t.correlationId},t.generateLogoutPopupName=function(e,t){var r=t.account&&t.account.homeAccountId;return ft+"."+e+"."+r+"."+t.correlationId},t}(),Xt=function(){function e(e,t,r,n){this.authModule=e,this.browserStorage=t,this.authCodeRequest=r,this.browserRequestLogger=n}return e.prototype.handleCodeResponse=function(e,t,r,n){return o(this,void 0,void 0,(function(){var o,a,s,c,u,l,d;return i(this,(function(i){switch(i.label){case 0:if(this.browserRequestLogger.verbose("InteractionHandler.handleCodeResponse called"),re.isEmpty(e))throw Ot.createEmptyHashError(e);if(o=this.browserStorage.generateStateKey(t),!(a=this.browserStorage.getTemporaryCache(o)))throw te.createStateNotFoundError("Cached State");return s=this.authModule.handleFragmentResponse(e,a),c=this.browserStorage.generateNonceKey(a),u=this.browserStorage.getTemporaryCache(c),this.authCodeRequest.code=s.code,s.cloud_instance_host_name?[4,this.updateTokenEndpointAuthority(s.cloud_instance_host_name,r,n)]:[3,2];case 1:i.sent(),i.label=2;case 2:return s.nonce=u||void 0,s.state=a,s.client_info?this.authCodeRequest.clientInfo=s.client_info:(l=this.checkCcsCredentials())&&(this.authCodeRequest.ccsCredential=l),[4,this.authModule.acquireToken(this.authCodeRequest,s)];case 3:return d=i.sent(),this.browserStorage.cleanRequestByState(t),[2,d]}}))}))},e.prototype.updateTokenEndpointAuthority=function(e,t,r){return o(this,void 0,void 0,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n="https://"+e+"/"+t.tenant+"/",[4,it.createDiscoveredInstance(n,r,this.browserStorage,t.options)];case 1:return o=i.sent(),this.authModule.updateAuthority(o),[2]}}))}))},e.prototype.checkCcsCredentials=function(){var e=this.browserStorage.getTemporaryCache(Qe.CCS_CREDENTIAL,!0);if(e)try{return JSON.parse(e)}catch(t){this.authModule.logger.error("Cache credential could not be parsed"),this.authModule.logger.errorPii("Cache credential could not be parsed: "+e)}return null},e}(),Zt=function(e){function t(t,r,n,o){var i=e.call(this,t,r,n,o)||this;return i.popupUtils=new Qt(r,o),i}return r(t,e),t.prototype.initiateAuthRequest=function(e,t){if(re.isEmpty(e))throw this.browserRequestLogger.error("Navigate url is empty"),Ot.createEmptyNavigationUriError();return this.browserStorage.setInteractionInProgress(!0),this.browserRequestLogger.infoPii("Navigate to: "+e),this.popupUtils.openPopup(e,t)},t.prototype.monitorPopupForHash=function(e){var t=this;return this.popupUtils.monitorPopupForSameOrigin(e).then((function(){var r=e.location.hash;if(Gt.clearHash(e),t.popupUtils.cleanPopup(e),!r)throw Ot.createEmptyHashError(e.location.href);if(xe.hashContainsKnownProperties(r))return r;throw Ot.createHashDoesNotContainKnownPropertiesError()}))},t}(Xt),er=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.prototype.acquireToken=function(t){try{var r=this.preflightInteractiveRequest(t,e.InteractionType.Popup),n=Qt.generatePopupName(this.config.auth.clientId,r),o=t.popupWindowAttributes||{};if(this.config.system.asyncPopups)return this.logger.verbose("asyncPopups set to true, acquiring token"),this.acquireTokenPopupAsync(r,n,o);this.logger.verbose("asyncPopup set to false, opening popup before acquiring token");var i=Qt.openSizedPopup("about:blank",n,o,this.logger);return this.acquireTokenPopupAsync(r,n,o,i)}catch(e){return Promise.reject(e)}},n.prototype.logout=function(e){try{this.logger.verbose("logoutPopup called");var t=this.initializeLogoutRequest(e),r=Qt.generateLogoutPopupName(this.config.auth.clientId,t),n=e&&e.authority,o=e&&e.mainWindowRedirectUri,i=(null==e?void 0:e.popupWindowAttributes)||{};if(this.config.system.asyncPopups)return this.logger.verbose("asyncPopups set to true"),this.logoutPopupAsync(t,r,i,n,void 0,o);this.logger.verbose("asyncPopup set to false, opening popup");var a=Qt.openSizedPopup("about:blank",r,i,this.logger);return this.logoutPopupAsync(t,r,i,n,a,o)}catch(e){return Promise.reject(e)}},n.prototype.acquireTokenPopupAsync=function(t,r,n,a){return o(this,void 0,void 0,(function(){var o,s,c,u,l,d,h,p,f,g;return i(this,(function(i){switch(i.label){case 0:this.logger.verbose("acquireTokenPopupAsync called"),o=this.initializeServerTelemetryManager(e.ApiId.acquireTokenPopup),i.label=1;case 1:return i.trys.push([1,7,,8]),[4,this.initializeAuthorizationCodeRequest(t)];case 2:return s=i.sent(),[4,this.createAuthCodeClient(o,t.authority)];case 3:return c=i.sent(),this.logger.verbose("Auth code client created"),[4,c.getAuthCodeUrl(t)];case 4:return u=i.sent(),l=new Zt(c,this.browserStorage,s,this.logger),d={popup:a,popupName:r,popupWindowAttributes:n},h=l.initiateAuthRequest(u,d),this.eventHandler.emitEvent(e.EventType.POPUP_OPENED,e.InteractionType.Popup,{popupWindow:h},null),[4,l.monitorPopupForHash(h)];case 5:return p=i.sent(),f=this.validateAndExtractStateFromHash(p,e.InteractionType.Popup,t.correlationId),we.removeThrottle(this.browserStorage,this.config.auth.clientId,s),[4,l.handleCodeResponse(p,f,c.authority,this.networkClient)];case 6:return[2,i.sent()];case 7:throw g=i.sent(),a&&a.close(),g instanceof X&&g.setCorrelationId(this.correlationId),o.cacheFailedRequest(g),this.browserStorage.cleanRequestByState(t.state),g;case 8:return[2]}}))}))},n.prototype.logoutPopupAsync=function(t,r,n,a,s,c){return o(this,void 0,void 0,(function(){var o,u,l,d,h,p,f,g,y;return i(this,(function(i){switch(i.label){case 0:this.logger.verbose("logoutPopupAsync called"),this.eventHandler.emitEvent(e.EventType.LOGOUT_START,e.InteractionType.Popup,t),o=this.initializeServerTelemetryManager(e.ApiId.logoutPopup),i.label=1;case 1:return i.trys.push([1,8,,9]),[4,this.clearCacheOnLogout(t.account)];case 2:return i.sent(),this.browserStorage.setInteractionInProgress(!0),[4,this.createAuthCodeClient(o,a)];case 3:u=i.sent(),this.logger.verbose("Auth code client created"),l=u.getLogoutUri(t),this.eventHandler.emitEvent(e.EventType.LOGOUT_SUCCESS,e.InteractionType.Popup,t),d=new Qt(this.browserStorage,this.logger),h=d.openPopup(l,{popupName:r,popupWindowAttributes:n,popup:s}),this.eventHandler.emitEvent(e.EventType.POPUP_OPENED,e.InteractionType.Popup,{popupWindow:h},null),i.label=4;case 4:return i.trys.push([4,6,,7]),[4,d.monitorPopupForSameOrigin(h)];case 5:return i.sent(),this.logger.verbose("Popup successfully redirected to postLogoutRedirectUri"),[3,7];case 6:return p=i.sent(),this.logger.verbose("Error occurred while monitoring popup for same origin. Session on server may remain active. Error: "+p),[3,7];case 7:return d.cleanPopup(h),c?(f={apiId:e.ApiId.logoutPopup,timeout:this.config.system.redirectNavigationTimeout,noHistory:!1},g=xe.getAbsoluteUrl(c,Gt.getCurrentUri()),this.logger.verbose("Redirecting main window to url specified in the request"),this.logger.verbosePii("Redirecing main window to: "+g),this.navigationClient.navigateInternal(g,f)):this.logger.verbose("No main window navigation requested"),[3,9];case 8:throw y=i.sent(),s&&s.close(),y instanceof X&&y.setCorrelationId(this.correlationId),this.browserStorage.setInteractionInProgress(!1),this.eventHandler.emitEvent(e.EventType.LOGOUT_FAILURE,e.InteractionType.Popup,null,y),this.eventHandler.emitEvent(e.EventType.LOGOUT_END,e.InteractionType.Popup),o.cacheFailedRequest(y),y;case 9:return this.eventHandler.emitEvent(e.EventType.LOGOUT_END,e.InteractionType.Popup),[2]}}))}))},n}(Jt),tr=function(t){function n(e,r,n,o,i){var a=t.call(this,e,r,n,o)||this;return a.browserCrypto=i,a}return r(n,t),n.prototype.initiateAuthRequest=function(t,r){return o(this,void 0,void 0,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest called"),re.isEmpty(t)?[3,7]:(r.redirectStartPage&&(this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: redirectStartPage set, caching start page"),this.browserStorage.setTemporaryCache(Qe.ORIGIN_URI,r.redirectStartPage,!0)),this.browserStorage.setInteractionInProgress(!0),this.browserStorage.setTemporaryCache(Qe.CORRELATION_ID,this.authCodeRequest.correlationId,!0),this.browserStorage.cacheCodeRequest(this.authCodeRequest,this.browserCrypto),this.browserRequestLogger.infoPii("RedirectHandler.initiateAuthRequest: Navigate to: "+t),n={apiId:e.ApiId.acquireTokenRedirect,timeout:r.redirectTimeout,noHistory:!1},"function"!=typeof r.onRedirectNavigate?[3,4]:(this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: Invoking onRedirectNavigate callback"),!1===r.onRedirectNavigate(t)?[3,2]:(this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate did not return false, navigating"),[4,r.navigationClient.navigateExternal(t,n)])));case 1:case 5:return o.sent(),[2];case 2:return this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate returned false, stopping navigation"),[2];case 3:return[3,6];case 4:return this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: Navigating window to navigate url"),[4,r.navigationClient.navigateExternal(t,n)];case 6:return[3,8];case 7:throw this.browserRequestLogger.info("RedirectHandler.initiateAuthRequest: Navigate url is empty"),Ot.createEmptyNavigationUriError();case 8:return[2]}}))}))},n.prototype.handleCodeResponse=function(e,t,r,n,a){return o(this,void 0,void 0,(function(){var o,s,c,u,l,d,h;return i(this,(function(i){switch(i.label){case 0:if(this.browserRequestLogger.verbose("RedirectHandler.handleCodeResponse called"),re.isEmpty(e))throw Ot.createEmptyHashError(e);if(this.browserStorage.setInteractionInProgress(!1),o=this.browserStorage.generateStateKey(t),!(s=this.browserStorage.getTemporaryCache(o)))throw te.createStateNotFoundError("Cached State");return c=this.authModule.handleFragmentResponse(e,s),u=this.browserStorage.generateNonceKey(s),l=this.browserStorage.getTemporaryCache(u),this.authCodeRequest.code=c.code,c.cloud_instance_host_name?[4,this.updateTokenEndpointAuthority(c.cloud_instance_host_name,r,n)]:[3,2];case 1:i.sent(),i.label=2;case 2:return c.nonce=l||void 0,c.state=s,c.client_info?this.authCodeRequest.clientInfo=c.client_info:(d=this.checkCcsCredentials())&&(this.authCodeRequest.ccsCredential=d),a&&we.removeThrottle(this.browserStorage,a,this.authCodeRequest),[4,this.authModule.acquireToken(this.authCodeRequest,c)];case 3:return h=i.sent(),this.browserStorage.cleanRequestByState(t),[2,h]}}))}))},n}(Xt),rr=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.prototype.acquireToken=function(t){return o(this,void 0,void 0,(function(){var r,n,o,a,s,c,u,l;return i(this,(function(i){switch(i.label){case 0:r=this.preflightInteractiveRequest(t,e.InteractionType.Redirect),n=this.initializeServerTelemetryManager(e.ApiId.acquireTokenRedirect),i.label=1;case 1:return i.trys.push([1,6,,7]),[4,this.initializeAuthorizationCodeRequest(r)];case 2:return o=i.sent(),[4,this.createAuthCodeClient(n,r.authority)];case 3:return a=i.sent(),this.logger.verbose("Auth code client created"),s=new tr(a,this.browserStorage,o,this.logger,this.browserCrypto),[4,a.getAuthCodeUrl(r)];case 4:return c=i.sent(),u=this.getRedirectStartPage(t.redirectStartPage),this.logger.verbosePii("Redirect start page: "+u),[4,s.initiateAuthRequest(c,{navigationClient:this.navigationClient,redirectTimeout:this.config.system.redirectNavigationTimeout,redirectStartPage:u,onRedirectNavigate:t.onRedirectNavigate})];case 5:return[2,i.sent()];case 6:throw(l=i.sent())instanceof X&&l.setCorrelationId(this.correlationId),n.cacheFailedRequest(l),this.browserStorage.cleanRequestByState(r.state),l;case 7:return[2]}}))}))},n.prototype.handleRedirectPromise=function(t){return o(this,void 0,void 0,(function(){var r,n,o,a,s,c,u,l,d,h,p;return i(this,(function(i){switch(i.label){case 0:r=this.initializeServerTelemetryManager(e.ApiId.handleRedirectPromise),i.label=1;case 1:if(i.trys.push([1,10,,11]),!this.browserStorage.isInteractionInProgress(!0))return this.logger.info("handleRedirectPromise called but there is no interaction in progress, returning null."),[2,null];if(!(n=this.getRedirectResponseHash(t||window.location.hash)))return this.logger.info("handleRedirectPromise did not detect a response hash as a result of a redirect. Cleaning temporary cache."),this.browserStorage.cleanRequestByInteractionType(e.InteractionType.Redirect),[2,null];o=void 0;try{o=this.validateAndExtractStateFromHash(n,e.InteractionType.Redirect),Gt.clearHash(window),this.logger.verbose("State extracted from hash")}catch(t){return this.logger.info("handleRedirectPromise was unable to extract state due to: "+t),this.browserStorage.cleanRequestByInteractionType(e.InteractionType.Redirect),[2,null]}return a=this.browserStorage.getTemporaryCache(Qe.ORIGIN_URI,!0)||"",s=xe.removeHashFromUrl(a),c=xe.removeHashFromUrl(window.location.href),s===c&&this.config.auth.navigateToLoginRequestUrl?(this.logger.verbose("Current page is loginRequestUrl, handling hash"),[4,this.handleHash(n,o,r)]):[3,3];case 2:return u=i.sent(),a.indexOf("#")>-1&&Gt.replaceHash(a),[2,u];case 3:return this.config.auth.navigateToLoginRequestUrl?[3,4]:(this.logger.verbose("NavigateToLoginRequestUrl set to false, handling hash"),[2,this.handleHash(n,o,r)]);case 4:return Gt.isInIframe()&&!this.config.system.allowRedirectInIframe?[3,9]:(this.browserStorage.setTemporaryCache(Qe.URL_HASH,n,!0),l={apiId:e.ApiId.handleRedirectPromise,timeout:this.config.system.redirectNavigationTimeout,noHistory:!0},d=!0,a&&"null"!==a?[3,6]:(h=Gt.getHomepage(),this.browserStorage.setTemporaryCache(Qe.ORIGIN_URI,h,!0),this.logger.warning("Unable to get valid login request url from cache, redirecting to home page"),[4,this.navigationClient.navigateInternal(h,l)]));case 5:return d=i.sent(),[3,8];case 6:return this.logger.verbose("Navigating to loginRequestUrl: "+a),[4,this.navigationClient.navigateInternal(a,l)];case 7:d=i.sent(),i.label=8;case 8:if(!d)return[2,this.handleHash(n,o,r)];i.label=9;case 9:return[2,null];case 10:throw(p=i.sent())instanceof X&&p.setCorrelationId(this.correlationId),r.cacheFailedRequest(p),this.browserStorage.cleanRequestByInteractionType(e.InteractionType.Redirect),p;case 11:return[2]}}))}))},n.prototype.getRedirectResponseHash=function(e){this.logger.verbose("getRedirectResponseHash called");var t=xe.hashContainsKnownProperties(e),r=this.browserStorage.getTemporaryCache(Qe.URL_HASH,!0);return this.browserStorage.removeItem(this.browserStorage.generateCacheKey(Qe.URL_HASH)),t?(this.logger.verbose("Hash contains known properties, returning response hash"),e):(this.logger.verbose("Hash does not contain known properties, returning cached hash"),r)},n.prototype.handleHash=function(e,t,r){return o(this,void 0,void 0,(function(){var n,o,a;return i(this,(function(i){switch(i.label){case 0:if(n=this.browserStorage.getCachedRequest(t,this.browserCrypto),this.logger.verbose("handleHash called, retrieved cached request"),!(o=this.browserStorage.getCachedAuthority(t)))throw Ot.createNoCachedAuthorityError();return[4,this.createAuthCodeClient(r,o)];case 1:return a=i.sent(),this.logger.verbose("Auth code client created"),[4,new tr(a,this.browserStorage,n,this.logger,this.browserCrypto).handleCodeResponse(e,t,a.authority,this.networkClient,this.config.auth.clientId)];case 2:return[2,i.sent()]}}))}))},n.prototype.logout=function(t){return o(this,void 0,void 0,(function(){var r,n,o,a,s,c;return i(this,(function(i){switch(i.label){case 0:this.logger.verbose("logoutRedirect called"),r=this.initializeLogoutRequest(t),n=this.initializeServerTelemetryManager(e.ApiId.logout),i.label=1;case 1:return i.trys.push([1,10,,11]),this.eventHandler.emitEvent(e.EventType.LOGOUT_START,e.InteractionType.Redirect,t),[4,this.clearCacheOnLogout(r.account)];case 2:return i.sent(),o={apiId:e.ApiId.logout,timeout:this.config.system.redirectNavigationTimeout,noHistory:!1},[4,this.createAuthCodeClient(n,t&&t.authority)];case 3:return a=i.sent(),this.logger.verbose("Auth code client created"),s=a.getLogoutUri(r),this.eventHandler.emitEvent(e.EventType.LOGOUT_SUCCESS,e.InteractionType.Redirect,r),t&&"function"==typeof t.onRedirectNavigate?!1===t.onRedirectNavigate(s)?[3,5]:(this.logger.verbose("Logout onRedirectNavigate did not return false, navigating"),[4,this.navigationClient.navigateExternal(s,o)]):[3,7];case 4:return i.sent(),[2];case 5:this.logger.verbose("Logout onRedirectNavigate returned false, stopping navigation"),i.label=6;case 6:return[3,9];case 7:return[4,this.navigationClient.navigateExternal(s,o)];case 8:return i.sent(),[2];case 9:return[3,11];case 10:throw(c=i.sent())instanceof X&&c.setCorrelationId(this.correlationId),n.cacheFailedRequest(c),this.eventHandler.emitEvent(e.EventType.LOGOUT_FAILURE,e.InteractionType.Redirect,null,c),this.eventHandler.emitEvent(e.EventType.LOGOUT_END,e.InteractionType.Redirect),c;case 11:return this.eventHandler.emitEvent(e.EventType.LOGOUT_END,e.InteractionType.Redirect),[2]}}))}))},n.prototype.getRedirectStartPage=function(e){var t=e||window.location.href;return xe.getAbsoluteUrl(t,Gt.getCurrentUri())},n}(Jt),nr=function(e){function t(t,r,n,o,i){var a=e.call(this,t,r,n,o)||this;return a.navigateFrameWait=i,a}return r(t,e),t.prototype.initiateAuthRequest=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(r){switch(r.label){case 0:if(re.isEmpty(e))throw this.browserRequestLogger.info("Navigate url is empty"),Ot.createEmptyNavigationUriError();return this.navigateFrameWait?[4,this.loadFrame(e)]:[3,2];case 1:return t=r.sent(),[3,3];case 2:t=this.loadFrameSync(e),r.label=3;case 3:return[2,t]}}))}))},t.prototype.monitorIframeForHash=function(e,t){var r=this;return new Promise((function(n,o){t<Vt&&r.browserRequestLogger.warning("system.loadFrameTimeout or system.iframeHashTimeout set to lower ("+t+"ms) than the default (6000ms). This may result in timeouts.");var i=window.performance.now()+t,a=setInterval((function(){if(window.performance.now()>i)return r.removeHiddenIframe(e),clearInterval(a),void o(Ot.createMonitorIframeTimeoutError());var t=m.EMPTY_STRING,s=e.contentWindow;try{t=s?s.location.href:m.EMPTY_STRING}catch(e){}if(!re.isEmpty(t)){var c=s?s.location.hash:m.EMPTY_STRING;return xe.hashContainsKnownProperties(c)?(r.removeHiddenIframe(e),clearInterval(a),void n(c)):void 0}}),gt)}))},t.prototype.loadFrame=function(e){var t=this;return new Promise((function(r,n){var o=t.createHiddenIframe();setTimeout((function(){o?(o.src=e,r(o)):n("Unable to load iframe")}),t.navigateFrameWait)}))},t.prototype.loadFrameSync=function(e){var t=this.createHiddenIframe();return t.src=e,t},t.prototype.createHiddenIframe=function(){var e=document.createElement("iframe");return e.style.visibility="hidden",e.style.position="absolute",e.style.width=e.style.height="0",e.style.border="0",e.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms"),document.getElementsByTagName("body")[0].appendChild(e),e},t.prototype.removeHiddenIframe=function(e){document.body===e.parentNode&&document.body.removeChild(e)},t}(Xt),or=function(t){function a(e,r,n,o,i,a,s,c){var u=t.call(this,e,r,n,o,i,a,c)||this;return u.apiId=s,u}return r(a,t),a.prototype.acquireToken=function(t){return o(this,void 0,void 0,(function(){var r,o,a,s,c,u;return i(this,(function(i){switch(i.label){case 0:if(this.logger.verbose("acquireTokenByIframe called"),re.isEmpty(t.loginHint)&&re.isEmpty(t.sid)&&(!t.account||re.isEmpty(t.account.username))&&this.logger.warning("No user hint provided. The authorization server may need more information to complete this request."),t.prompt&&t.prompt!==w.NONE)throw Ot.createSilentPromptValueError(t.prompt);r=this.initializeAuthorizationRequest(n(n({},t),{prompt:w.NONE}),e.InteractionType.Silent),o=this.initializeServerTelemetryManager(this.apiId),i.label=1;case 1:return i.trys.push([1,6,,7]),[4,this.initializeAuthorizationCodeRequest(r)];case 2:return a=i.sent(),[4,this.createAuthCodeClient(o,r.authority)];case 3:return s=i.sent(),this.logger.verbose("Auth code client created"),[4,s.getAuthCodeUrl(r)];case 4:return c=i.sent(),[4,this.silentTokenHelper(c,a,s,this.logger)];case 5:return[2,i.sent()];case 6:throw(u=i.sent())instanceof X&&u.setCorrelationId(this.correlationId),o.cacheFailedRequest(u),this.browserStorage.cleanRequestByState(r.state),u;case 7:return[2]}}))}))},a.prototype.logout=function(){return Promise.reject(Ot.createSilentLogoutUnsupportedError())},a.prototype.silentTokenHelper=function(t,r,n,a){return o(this,void 0,void 0,(function(){var o,s,c,u;return i(this,(function(i){switch(i.label){case 0:return[4,(o=new nr(n,this.browserStorage,r,a,this.config.system.navigateFrameWait)).initiateAuthRequest(t)];case 1:return s=i.sent(),[4,o.monitorIframeForHash(s,this.config.system.iframeHashTimeout)];case 2:return c=i.sent(),u=this.validateAndExtractStateFromHash(c,e.InteractionType.Silent,r.correlationId),[2,o.handleCodeResponse(c,u,n.authority,this.networkClient)]}}))}))},a}(Jt),ir=function(t){function a(){return null!==t&&t.apply(this,arguments)||this}return r(a,t),a.prototype.acquireToken=function(t){return o(this,void 0,void 0,(function(){var r,o,a,s=this;return i(this,(function(i){switch(i.label){case 0:return r=n(n({},t),this.initializeBaseRequest(t)),o=this.initializeServerTelemetryManager(e.ApiId.acquireTokenSilent_silentFlow),[4,this.createRefreshTokenClient(o,r.authority)];case 1:return a=i.sent(),this.logger.verbose("Refresh token client created"),[2,a.acquireTokenByRefreshToken(r).catch((function(e){throw e instanceof X&&e.setCorrelationId(s.correlationId),o.cacheFailedRequest(e),e}))]}}))}))},a.prototype.logout=function(){return Promise.reject(Ot.createSilentLogoutUnsupportedError())},a.prototype.createRefreshTokenClient=function(e,t){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return[4,this.getClientConfiguration(e,t)];case 1:return r=n.sent(),[2,new Ve(r)]}}))}))},a}(Jt),ar=function(){function e(e,t,r,n){this.isBrowserEnvironment="undefined"!=typeof window,this.config=e,this.storage=t,this.logger=r,this.cryptoObj=n}return e.prototype.loadExternalTokens=function(e,t,r){if(this.logger.info("TokenCache - loadExternalTokens called"),!t.id_token)throw Ot.createUnableToLoadTokenError("Please ensure server response includes id token.");if(e.account)this.loadIdToken(t.id_token,e.account.homeAccountId,e.account.environment,e.account.tenantId,r),this.loadAccessToken(e,t,e.account.homeAccountId,e.account.environment,e.account.tenantId,r);else{if(!e.authority)throw Ot.createUnableToLoadTokenError("Please provide a request with an account or a request with authority.");var n={protocolMode:this.config.auth.protocolMode,knownAuthorities:this.config.auth.knownAuthorities,cloudDiscoveryMetadata:this.config.auth.cloudDiscoveryMetadata,authorityMetadata:this.config.auth.authorityMetadata},o=new ot(e.authority,this.config.system.networkClient,this.storage,n);if(r.clientInfo)this.logger.trace("TokenCache - homeAccountId from options"),this.loadIdToken(t.id_token,r.clientInfo,o.hostnameAndPort,o.tenant,r),this.loadAccessToken(e,t,r.clientInfo,o.hostnameAndPort,o.tenant,r);else{if(!t.client_info)throw Ot.createUnableToLoadTokenError("Please provide clientInfo in the response or options.");this.logger.trace("TokenCache - homeAccountId from response"),this.loadIdToken(t.id_token,t.client_info,o.hostnameAndPort,o.tenant,r),this.loadAccessToken(e,t,t.client_info,o.hostnameAndPort,o.tenant,r)}}},e.prototype.loadIdToken=function(e,t,r,n,o){var i=Re.createIdTokenEntity(t,r,e,this.config.auth.clientId,n),a=new fe(e,this.cryptoObj),s=o.clientInfo?pe.createAccount(o.clientInfo,t,a,void 0,void 0,void 0,void 0,r):pe.createGenericAccount(t,a,void 0,void 0,void 0,void 0,r);if(!this.isBrowserEnvironment)throw Ot.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");this.logger.verbose("TokenCache - loading id token"),this.storage.setAccount(s),this.storage.setIdTokenCredential(i)},e.prototype.loadAccessToken=function(e,t,r,n,o,i){if(t.access_token){if(!t.expires_in)throw Ot.createUnableToLoadTokenError("Please ensure server response includes expires_in value.");if(!i.extendedExpiresOn)throw Ot.createUnableToLoadTokenError("Please provide an extendedExpiresOn value in the options.");var a=new ue(e.scopes).printScopes(),s=t.expires_in,c=i.extendedExpiresOn,u=Pe.createAccessTokenEntity(r,n,t.access_token,this.config.auth.clientId,o,a,s,c,this.cryptoObj);if(!this.isBrowserEnvironment)throw Ot.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");this.logger.verbose("TokenCache - loading access token"),this.storage.setAccessTokenCredential(u)}else this.logger.verbose("TokenCache - No access token provided for caching")},e}(),sr=function(){function t(t){var r,o,i,a,s,c,u,l,d,h,p,f;this.isBrowserEnvironment="undefined"!=typeof window,this.config=(r=t,o=this.isBrowserEnvironment,i=r.auth,a=r.cache,s=r.system,c={clientId:"",authority:""+m.DEFAULT_AUTHORITY,knownAuthorities:[],cloudDiscoveryMetadata:"",authorityMetadata:"",redirectUri:"",postLogoutRedirectUri:"",navigateToLoginRequestUrl:!0,clientCapabilities:[],protocolMode:e.ProtocolMode.AAD},u={cacheLocation:e.BrowserCacheLocation.SessionStorage,storeAuthStateInCookie:!1,secureCookies:!1},l={loggerCallback:function(){},logLevel:e.LogLevel.Info,piiLoggingEnabled:!1},d=n(n({},ve),{loggerOptions:l,networkClient:o?Gt.getBrowserNetworkClient():ct,navigationClient:new Wt,loadFrameTimeout:0,windowHashTimeout:s&&s.loadFrameTimeout||6e4,iframeHashTimeout:s&&s.loadFrameTimeout||Vt,navigateFrameWait:o&&Gt.detectIEOrEdge()?500:0,redirectNavigationTimeout:3e4,asyncPopups:!1,allowRedirectInIframe:!1}),{auth:n(n({},c),i),cache:n(n({},u),a),system:n(n({},d),s)}),this.logger=new oe(this.config.system.loggerOptions,zt,$t),this.networkClient=this.config.system.networkClient,this.navigationClient=this.config.system.navigationClient,this.redirectResponse=new Map,this.browserCrypto=this.isBrowserEnvironment?new Mt(this.logger):Z,this.eventHandler=new Yt(this.logger,this.browserCrypto),this.browserStorage=this.isBrowserEnvironment?new Bt(this.config.auth.clientId,this.config.cache,this.browserCrypto,this.logger):(h=this.config.auth.clientId,p=this.logger,f={cacheLocation:e.BrowserCacheLocation.MemoryStorage,storeAuthStateInCookie:!1,secureCookies:!1},new Bt(h,f,Z,p)),this.tokenCache=new ar(this.config,this.browserStorage,this.logger,this.browserCrypto)}return t.prototype.handleRedirectPromise=function(t){return o(this,void 0,void 0,(function(){var r,n,o,a,s,c=this;return i(this,(function(i){return this.logger.verbose("handleRedirectPromise called"),r=this.getAllAccounts(),this.isBrowserEnvironment?(n=t||m.EMPTY_STRING,void 0===(o=this.redirectResponse.get(n))?(this.eventHandler.emitEvent(e.EventType.HANDLE_REDIRECT_START,e.InteractionType.Redirect),this.logger.verbose("handleRedirectPromise has been called for the first time, storing the promise"),a=this.browserStorage.getTemporaryCache(Qe.CORRELATION_ID,!0)||"",s=new rr(this.config,this.browserStorage,this.browserCrypto,this.logger,this.eventHandler,this.navigationClient,a),o=s.handleRedirectPromise(t).then((function(t){return t&&(r.length<c.getAllAccounts().length?(c.eventHandler.emitEvent(e.EventType.LOGIN_SUCCESS,e.InteractionType.Redirect,t),c.logger.verbose("handleRedirectResponse returned result, login success")):(c.eventHandler.emitEvent(e.EventType.ACQUIRE_TOKEN_SUCCESS,e.InteractionType.Redirect,t),c.logger.verbose("handleRedirectResponse returned result, acquire token success"))),c.eventHandler.emitEvent(e.EventType.HANDLE_REDIRECT_END,e.InteractionType.Redirect),t})).catch((function(t){throw r.length>0?c.eventHandler.emitEvent(e.EventType.ACQUIRE_TOKEN_FAILURE,e.InteractionType.Redirect,null,t):c.eventHandler.emitEvent(e.EventType.LOGIN_FAILURE,e.InteractionType.Redirect,null,t),c.eventHandler.emitEvent(e.EventType.HANDLE_REDIRECT_END,e.InteractionType.Redirect),t})),this.redirectResponse.set(n,o)):this.logger.verbose("handleRedirectPromise has been called previously, returning the result from the first call"),[2,o]):(this.logger.verbose("handleRedirectPromise returns null, not browser environment"),[2,null])}))}))},t.prototype.acquireTokenRedirect=function(t){return o(this,void 0,void 0,(function(){var r,n=this;return i(this,(function(o){return this.preflightBrowserEnvironmentCheck(e.InteractionType.Redirect),this.logger.verbose("acquireTokenRedirect called"),(r=this.getAllAccounts().length>0)?this.eventHandler.emitEvent(e.EventType.ACQUIRE_TOKEN_START,e.InteractionType.Redirect,t):this.eventHandler.emitEvent(e.EventType.LOGIN_START,e.InteractionType.Redirect,t),[2,new rr(this.config,this.browserStorage,this.browserCrypto,this.logger,this.eventHandler,this.navigationClient,t.correlationId).acquireToken(t).catch((function(t){throw r?n.eventHandler.emitEvent(e.EventType.ACQUIRE_TOKEN_FAILURE,e.InteractionType.Redirect,null,t):n.eventHandler.emitEvent(e.EventType.LOGIN_FAILURE,e.InteractionType.Redirect,null,t),t}))]}))}))},t.prototype.acquireTokenPopup=function(t){var r=this;try{this.preflightBrowserEnvironmentCheck(e.InteractionType.Popup),this.logger.verbose("acquireTokenPopup called",t.correlationId)}catch(e){return Promise.reject(e)}var n=this.getAllAccounts();return n.length>0?this.eventHandler.emitEvent(e.EventType.ACQUIRE_TOKEN_START,e.InteractionType.Popup,t):this.eventHandler.emitEvent(e.EventType.LOGIN_START,e.InteractionType.Popup,t),new er(this.config,this.browserStorage,this.browserCrypto,this.logger,this.eventHandler,this.navigationClient,t.correlationId).acquireToken(t).then((function(t){return n.length<r.getAllAccounts().length?r.eventHandler.emitEvent(e.EventType.LOGIN_SUCCESS,e.InteractionType.Popup,t):r.eventHandler.emitEvent(e.EventType.ACQUIRE_TOKEN_SUCCESS,e.InteractionType.Popup,t),t})).catch((function(t){return n.length>0?r.eventHandler.emitEvent(e.EventType.ACQUIRE_TOKEN_FAILURE,e.InteractionType.Popup,null,t):r.eventHandler.emitEvent(e.EventType.LOGIN_FAILURE,e.InteractionType.Popup,null,t),Promise.reject(t)}))},t.prototype.ssoSilent=function(t){return o(this,void 0,void 0,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:this.preflightBrowserEnvironmentCheck(e.InteractionType.Silent),this.logger.verbose("ssoSilent called",t.correlationId),this.eventHandler.emitEvent(e.EventType.SSO_SILENT_START,e.InteractionType.Silent,t),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,new or(this.config,this.browserStorage,this.browserCrypto,this.logger,this.eventHandler,this.navigationClient,e.ApiId.ssoSilent,t.correlationId).acquireToken(t)];case 2:return r=o.sent(),this.eventHandler.emitEvent(e.EventType.SSO_SILENT_SUCCESS,e.InteractionType.Silent,r),[2,r];case 3:throw n=o.sent(),this.eventHandler.emitEvent(e.EventType.SSO_SILENT_FAILURE,e.InteractionType.Silent,null,n),n;case 4:return[2]}}))}))},t.prototype.acquireTokenByRefreshToken=function(t){return o(this,void 0,void 0,(function(){var r=this;return i(this,(function(n){return this.eventHandler.emitEvent(e.EventType.ACQUIRE_TOKEN_NETWORK_START,e.InteractionType.Silent,t),Gt.blockReloadInHiddenIframes(),[2,new ir(this.config,this.browserStorage,this.browserCrypto,this.logger,this.eventHandler,this.navigationClient,t.correlationId).acquireToken(t).catch((function(n){var o=n instanceof Ie,i=n instanceof Me,a=n.errorCode===dt;if(o&&a&&!i)return r.logger.verbose("Refresh token expired or invalid, attempting acquire token by iframe",t.correlationId),new or(r.config,r.browserStorage,r.browserCrypto,r.logger,r.eventHandler,r.navigationClient,e.ApiId.acquireTokenSilent_authCode,t.correlationId).acquireToken(t);throw n}))]}))}))},t.prototype.logout=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){return this.logger.warning("logout API is deprecated and will be removed in msal-browser v3.0.0. Use logoutRedirect instead."),[2,this.logoutRedirect(e)]}))}))},t.prototype.logoutRedirect=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(r){return this.preflightBrowserEnvironmentCheck(e.InteractionType.Redirect),[2,new rr(this.config,this.browserStorage,this.browserCrypto,this.logger,this.eventHandler,this.navigationClient,null==t?void 0:t.correlationId).logout(t)]}))}))},t.prototype.logoutPopup=function(t){try{return this.preflightBrowserEnvironmentCheck(e.InteractionType.Popup),new er(this.config,this.browserStorage,this.browserCrypto,this.logger,this.eventHandler,this.navigationClient,null==t?void 0:t.correlationId).logout(t)}catch(e){return Promise.reject(e)}},t.prototype.getAllAccounts=function(){return this.logger.verbose("getAllAccounts called"),this.isBrowserEnvironment?this.browserStorage.getAllAccounts():[]},t.prototype.getAccountByUsername=function(e){var t=this.getAllAccounts();return!re.isEmpty(e)&&t&&t.length?(this.logger.verbose("Account matching username found, returning"),this.logger.verbosePii("Returning signed-in accounts matching username: "+e),t.filter((function(t){return t.username.toLowerCase()===e.toLowerCase()}))[0]||null):(this.logger.verbose("getAccountByUsername: No matching account found, returning null"),null)},t.prototype.getAccountByHomeId=function(e){var t=this.getAllAccounts();return!re.isEmpty(e)&&t&&t.length?(this.logger.verbose("Account matching homeAccountId found, returning"),this.logger.verbosePii("Returning signed-in accounts matching homeAccountId: "+e),t.filter((function(t){return t.homeAccountId===e}))[0]||null):(this.logger.verbose("getAccountByHomeId: No matching account found, returning null"),null)},t.prototype.getAccountByLocalId=function(e){var t=this.getAllAccounts();return!re.isEmpty(e)&&t&&t.length?(this.logger.verbose("Account matching localAccountId found, returning"),this.logger.verbosePii("Returning signed-in accounts matching localAccountId: "+e),t.filter((function(t){return t.localAccountId===e}))[0]||null):(this.logger.verbose("getAccountByLocalId: No matching account found, returning null"),null)},t.prototype.setActiveAccount=function(e){this.browserStorage.setActiveAccount(e)},t.prototype.getActiveAccount=function(){return this.browserStorage.getActiveAccount()},t.prototype.preflightBrowserEnvironmentCheck=function(t){if(this.logger.verbose("preflightBrowserEnvironmentCheck started"),Gt.blockNonBrowserEnvironment(this.isBrowserEnvironment),Gt.blockRedirectInIframe(t,this.config.system.allowRedirectInIframe),Gt.blockReloadInHiddenIframes(),Gt.blockAcquireTokenInPopups(),t===e.InteractionType.Redirect&&this.config.cache.cacheLocation===e.BrowserCacheLocation.MemoryStorage&&!this.config.cache.storeAuthStateInCookie)throw Ht.createInMemoryRedirectUnavailableError()},t.prototype.addEventCallback=function(e){return this.eventHandler.addEventCallback(e)},t.prototype.removeEventCallback=function(e){this.eventHandler.removeEventCallback(e)},t.prototype.enableAccountStorageEvents=function(){this.eventHandler.enableAccountStorageEvents()},t.prototype.disableAccountStorageEvents=function(){this.eventHandler.disableAccountStorageEvents()},t.prototype.getTokenCache=function(){return this.tokenCache},t.prototype.getLogger=function(){return this.logger},t.prototype.setLogger=function(e){this.logger=e},t.prototype.initializeWrapperLibrary=function(e,t){this.browserStorage.setWrapperMetadata(e,t)},t.prototype.setNavigationClient=function(e){this.navigationClient=e},t.prototype.getConfiguration=function(){return this.config},t}(),cr=function(t){function a(){return null!==t&&t.apply(this,arguments)||this}return r(a,t),a.prototype.acquireToken=function(t){return o(this,void 0,void 0,(function(){var r,n,o,a;return i(this,(function(i){switch(i.label){case 0:return r=this.initializeServerTelemetryManager(e.ApiId.acquireTokenSilent_silentFlow),[4,this.createSilentFlowClient(r,t.authority)];case 1:n=i.sent(),this.logger.verbose("Silent auth client created"),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,n.acquireCachedToken(t)];case 3:return o=i.sent(),this.eventHandler.emitEvent(e.EventType.ACQUIRE_TOKEN_SUCCESS,e.InteractionType.Silent,o),[2,o];case 4:throw(a=i.sent())instanceof Ot&&a.errorCode===bt.signingKeyNotFoundInStorage.code&&this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair."),a;case 5:return[2]}}))}))},a.prototype.logout=function(){return Promise.reject(Ot.createSilentLogoutUnsupportedError())},a.prototype.createSilentFlowClient=function(e,t){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return[4,this.getClientConfiguration(e,t)];case 1:return r=n.sent(),[2,new ze(r)]}}))}))},a.prototype.initializeSilentRequest=function(e,t){return n(n(n({},e),this.initializeBaseRequest(e)),{account:t,forceRefresh:e.forceRefresh||!1})},a}(Jt),ur=function(t){function n(e){var r=t.call(this,e)||this;return r.activeSilentTokenRequests=new Map,r}return r(n,t),n.prototype.loginRedirect=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){return this.logger.verbose("loginRedirect called"),[2,this.acquireTokenRedirect(e||Et)]}))}))},n.prototype.loginPopup=function(e){return this.logger.verbose("loginPopup called"),this.acquireTokenPopup(e||Et)},n.prototype.acquireTokenSilent=function(t){return o(this,void 0,void 0,(function(){var r,n,o,a,s,c=this;return i(this,(function(i){if(this.preflightBrowserEnvironmentCheck(e.InteractionType.Silent),this.logger.verbose("acquireTokenSilent called",t.correlationId),!(r=t.account||this.getActiveAccount()))throw Ot.createNoAccountError();return n={clientId:this.config.auth.clientId,authority:t.authority||"",scopes:t.scopes,homeAccountIdentifier:r.homeAccountId,authenticationScheme:t.authenticationScheme,resourceRequestMethod:t.resourceRequestMethod,resourceRequestUri:t.resourceRequestUri,shrClaims:t.shrClaims,sshJwk:t.sshJwk,sshKid:t.sshKid},o=JSON.stringify(n),void 0===(a=this.activeSilentTokenRequests.get(o))?(this.logger.verbose("acquireTokenSilent called for the first time, storing active request",t.correlationId),s=this.acquireTokenSilentAsync(t,r).then((function(e){return c.activeSilentTokenRequests.delete(o),e})).catch((function(e){throw c.activeSilentTokenRequests.delete(o),e})),this.activeSilentTokenRequests.set(o,s),[2,s]):(this.logger.verbose("acquireTokenSilent has been called previously, returning the result from the first call",t.correlationId),[2,a])}))}))},n.prototype.acquireTokenSilentAsync=function(t,r){return o(this,void 0,void 0,(function(){var n,a,s=this;return i(this,(function(c){return n=new cr(this.config,this.browserStorage,this.browserCrypto,this.logger,this.eventHandler,this.navigationClient,t.correlationId),a=n.initializeSilentRequest(t,r),this.eventHandler.emitEvent(e.EventType.ACQUIRE_TOKEN_START,e.InteractionType.Silent,t),[2,n.acquireToken(a).catch((function(){return o(s,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.acquireTokenByRefreshToken(a)];case 1:return t=n.sent(),this.eventHandler.emitEvent(e.EventType.ACQUIRE_TOKEN_SUCCESS,e.InteractionType.Silent,t),[2,t];case 2:throw r=n.sent(),this.eventHandler.emitEvent(e.EventType.ACQUIRE_TOKEN_FAILURE,e.InteractionType.Silent,null,r),r;case 3:return[2]}}))}))}))]}))}))},n}(sr),lr={acquireTokenPopup:function(){return Promise.reject(Ht.createStubPcaInstanceCalledError())},acquireTokenRedirect:function(){return Promise.reject(Ht.createStubPcaInstanceCalledError())},acquireTokenSilent:function(){return Promise.reject(Ht.createStubPcaInstanceCalledError())},getAllAccounts:function(){return[]},getAccountByHomeId:function(){return null},getAccountByUsername:function(){return null},getAccountByLocalId:function(){return null},handleRedirectPromise:function(){return Promise.reject(Ht.createStubPcaInstanceCalledError())},loginPopup:function(){return Promise.reject(Ht.createStubPcaInstanceCalledError())},loginRedirect:function(){return Promise.reject(Ht.createStubPcaInstanceCalledError())},logout:function(){return Promise.reject(Ht.createStubPcaInstanceCalledError())},logoutRedirect:function(){return Promise.reject(Ht.createStubPcaInstanceCalledError())},logoutPopup:function(){return Promise.reject(Ht.createStubPcaInstanceCalledError())},ssoSilent:function(){return Promise.reject(Ht.createStubPcaInstanceCalledError())},addEventCallback:function(){return null},removeEventCallback:function(){},enableAccountStorageEvents:function(){},disableAccountStorageEvents:function(){},getTokenCache:function(){throw Ht.createStubPcaInstanceCalledError()},getLogger:function(){throw Ht.createStubPcaInstanceCalledError()},setLogger:function(){},setActiveAccount:function(){},getActiveAccount:function(){return null},initializeWrapperLibrary:function(){},setNavigationClient:function(){},getConfiguration:function(){throw Ht.createStubPcaInstanceCalledError()}},dr=function(){function t(){}return t.getInteractionStatusFromEvent=function(t,r){switch(t.eventType){case e.EventType.LOGIN_START:return e.InteractionStatus.Login;case e.EventType.SSO_SILENT_START:return e.InteractionStatus.SsoSilent;case e.EventType.ACQUIRE_TOKEN_START:if(t.interactionType===e.InteractionType.Redirect||t.interactionType===e.InteractionType.Popup)return e.InteractionStatus.AcquireToken;break;case e.EventType.HANDLE_REDIRECT_START:return e.InteractionStatus.HandleRedirect;case e.EventType.LOGOUT_START:return e.InteractionStatus.Logout;case e.EventType.SSO_SILENT_SUCCESS:case e.EventType.SSO_SILENT_FAILURE:if(r&&r!==e.InteractionStatus.SsoSilent)break;return e.InteractionStatus.None;case e.EventType.LOGOUT_END:if(r&&r!==e.InteractionStatus.Logout)break;return e.InteractionStatus.None;case e.EventType.HANDLE_REDIRECT_END:if(r&&r!==e.InteractionStatus.HandleRedirect)break;return e.InteractionStatus.None;case e.EventType.LOGIN_SUCCESS:case e.EventType.LOGIN_FAILURE:case e.EventType.ACQUIRE_TOKEN_SUCCESS:case e.EventType.ACQUIRE_TOKEN_FAILURE:if(t.interactionType===e.InteractionType.Redirect||t.interactionType===e.InteractionType.Popup){if(r&&r!==e.InteractionStatus.Login&&r!==e.InteractionStatus.AcquireToken)break;return e.InteractionStatus.None}}return null},t}(),hr=function(){function e(e,t){var r=t&&t.loggerOptions||{};this.logger=new oe(r,zt,$t),this.cryptoOps=new Mt(this.logger),this.popTokenGenerator=new Be(this.cryptoOps),this.shrParameters=e}return e.prototype.generatePublicKeyThumbprint=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.popTokenGenerator.generateKid(this.shrParameters)];case 1:return[2,e.sent().kid]}}))}))},e.prototype.signRequest=function(e,t,r){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.popTokenGenerator.signPayload(e,t,this.shrParameters,r)]}))}))},e.prototype.removeKeys=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.cryptoOps.removeTokenBindingKey(e)];case 1:return[2,t.sent()]}}))}))},e}();e.AccountEntity=pe,e.AuthError=X,e.AuthErrorMessage=Q,e.AuthenticationHeaderParser=ut,e.BrowserAuthError=Ot,e.BrowserAuthErrorMessage=bt,e.BrowserConfigurationAuthError=Ht,e.BrowserConfigurationAuthErrorMessage=Ft,e.BrowserUtils=Gt,e.ClientAuthError=te,e.ClientAuthErrorMessage=ee,e.ClientConfigurationError=ce,e.ClientConfigurationErrorMessage=se,e.EventMessageUtils=dr,e.InteractionRequiredAuthError=Me,e.InteractionRequiredAuthErrorMessage=Le,e.Logger=oe,e.NavigationClient=Wt,e.PublicClientApplication=ur,e.ServerError=Ie,e.SignedHttpRequest=hr,e.StringUtils=re,e.UrlString=xe,e.stubbedPublicClientApplication=lr,e.version=$t,Object.defineProperty(e,"__esModule",{value:!0})}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n=r(1838);module.exports=n})();
|