@useparagon/connect 2.2.3-experimental.2 → 2.2.4-experimental-15311.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/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- (()=>{var t={773:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InstallFlow=e.ExternalFilePicker=e.PARAGON_OVERFLOW_EMPTY_VALUE=void 0;const r=n(655),i=r.__importDefault(n(6245)),o=n(3931),s=n(4059),a=n(745),l=n(7343),c=n(7050);Object.defineProperty(e,"ExternalFilePicker",{enumerable:!0,get:function(){return c.ExternalFilePicker}});const u=n(2643),d=n(4429),h=n(9636),f=r.__importDefault(n(9892)),p=n(3821),g=n(2460),v=n(3158),y=n(4846),E=n(572),I=n(8321),S=n(3035),w="paragon-connect-frame",_=`${w}-container`,m="paragon-connect-user-state";e.PARAGON_OVERFLOW_EMPTY_VALUE="PARAGON_OVERFLOW_EMPTY_VALUE";class C extends f.default{constructor(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(super(),this.sdkVersion="2.2.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=e.PARAGON_OVERFLOW_EMPTY_VALUE,this.dynamicFieldMappingLoaders={},this.customDropdownOptionsLoaders={},"undefined"==typeof window)return void console.warn("connect sdk can only be used on browser");const r=(0,v.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:r,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 t?this.configureGlobal({host:t}):this.environments={...this.environments,...t},!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.");n.skipBootstrapWithLastKnownState||this.loadState(),window.addEventListener("message",this.eventMessageHandler.bind(this)),window.document.readyState===p.DocumentLoadingState.LOADING?window.document.addEventListener("DOMContentLoaded",(()=>{this.createReactRoot()})):this.createReactRoot(),this.installFlow=new O(this)}setHeadless(t){this.isHeadless=t}async eventMessageHandler(t){switch(t.data.type){case"oauth_success_callback":await this._oauthCallback(t.data.credential);break;case"oauth_error_callback":await this._oauthErrorCallback(t.data.error,t);break;default:await this.functionInvocationHandler(t)}}async functionInvocationHandler(t){if("SDK_FUNCTION_INVOCATION"!==t.data.messageType)return;const{type:e,id:n,parameters:r}=t.data;let i;try{i={messageType:"SDK_FUNCTION_RESPONSE",id:n,type:e,result:await this[e](...r)}}catch(t){i={messageType:"SDK_FUNCTION_ERROR",error:!0,message:t.message,id:n}}t.source.postMessage(i,this.environments.CONNECT_PUBLIC_URL)}createReactRoot(){var t;if(this.rootElementCreated)return;this.rootElementCreated=!0,this.root=document.createElement("iframe"),this.root.onload=()=>{this.rootLoaded=!0,this.render()};const e=!!document.querySelector(`#${_}`);this.root.id=w,this.root.src=`${this.environments.CONNECT_PUBLIC_URL}/ui${this.projectId?`?projectId=${this.projectId}`:""}`,this.root.style.position=e?"absolute":"fixed",this.root.style.top="0",this.root.style.left="0",this.root.style.width=e?"100%":"100vw",this.root.style.height=e?"100%":"100vh",this.root.style.zIndex="2147483647",this.root.style.display="none",null===(t=document.querySelector(`#${_}`)||document.body)||void 0===t||t.appendChild(this.root)}validateAction(t){var e;if(!this.loadedIntegrations[t]&&!(0,l.isCustomIntegrationTypeName)(t))throw new Error(`"${t}" is not a valid integration type. The integrations you have configured for this Paragon project are:\n\n${Object.keys(this.loadedConfigs).map((t=>`- "${t}"`)).join("\n")}\n`);if(!this.loadedConfigs[t]||!this.userState.integrations[t])throw new Error(`integration "${t}" has not been set up in your Paragon project yet.\n\n${Object.keys(this.loadedConfigs).map((t=>`- "${t}"`)).join("\n")}`);if(!(null===(e=this.loadedIntegrations[t])||void 0===e?void 0:e.isActive))throw new Error(`integration "${t}" is not active in your Paragon project yet.`)}isAlreadyInstalled(t,e,n){var r,i;if(n){const t=this.getCredentialAndConfig({selectedCredentialId:n});return(null===(r=null==t?void 0:t.selectedCredential)||void 0===r?void 0:r.status)===s.CredentialStatus.VALID}return Boolean(null===(i=e.integrations[t])||void 0===i?void 0:i.enabled)}hasCredential(t,e,n){var r,i;if(!n)return Boolean(null===(r=e.integrations[t])||void 0===r?void 0:r.credentialId);try{const t=this.getCredentialAndConfig({selectedCredentialId:n});return Boolean(null===(i=null==t?void 0:t.selectedCredential)||void 0===i?void 0:i.id)}catch(t){return console.error(t),!1}}async bootstrapSDKState(t){this.projectId&&this.userState.authenticated&&await this.updateLocalState(t)}setModalState(t){this.modalState={config:void 0,...this.modalState,...t},this.render()}loadState(){if("undefined"!=typeof window)try{const t=window.localStorage.getItem(m)?JSON.parse(window.localStorage.getItem(m)):{};if(t.projectId&&(this.projectId=t.projectId),t.userState){const{userState:e}=t;if(!("authenticated"in e&&e.authenticated&&"token"in e))throw new Error("Malformatted or unauthenticated user was persisted into localStorage. Refusing to load.");this.updateAuthenticatedUser(e),this.bootstrapSDKState().catch((()=>{this.clearState()}))}}catch{this.clearState()}}getIntegrationId(t){const e=this.loadedIntegrations[t];if(!e)throw new Error(`Integration "${t}" not found`);return e.id}saveState(){"undefined"!=typeof window&&this.userState.authenticated&&window.localStorage.setItem(m,JSON.stringify({projectId:this.projectId,userState:this.userState}))}clearState(){"undefined"!=typeof window&&window.localStorage.removeItem(m)}render(){if(!this.isHeadless&&this.root&&this.rootLoaded){const{onClose:t,onOpen:e,...n}=this.modalState,r={messageType:"UI_UPDATE",nextContext:{user:this.userState,projectId:this.projectId,environments:this.environments,project:this.project,endUserIntegrationConfig:this.modalState.integration?this.endUserIntegrationConfig[(0,l.getIntegrationTypeName)(this.modalState.integration)||""]:void 0},nextModalState:n};if(!this.root.contentWindow)throw new Error("Browser not supported");this.root.contentWindow.postMessage(r,this.environments.CONNECT_PUBLIC_URL)}}updateContainerStyle(t){let{isModalShown:e}=t;this.root&&(this.root.style.display=e?"block":"none")}async authenticate(t,e,n){var r;if(!t||!e)throw new Error("projectId or token not specified to paragon.authenticate()");let o={};try{o=(0,i.default)(e)}catch(t){throw new Error("A well-formed JWT was not provided to paragon.authenticate()")}this.projectId=t,this.userState={authenticated:!0,token:e,userId:o.sub||o.id,integrations:{},meta:null!==(r=null==n?void 0:n.metadata)&&void 0!==r?r:{},resources:[]};try{if(Date.now()>=1e3*(o.exp||0))throw new Error("JWT token provided has expired.");await this.bootstrapSDKState(null==n?void 0:n.metadata)}catch(t){throw console.warn("paragon.authenticate() could not login user",t),this.logout(),new Error(`Failed to authenticate user with Paragon: ${t.message}`)}this.render()}getUser(){return(0,h.cloneDeep)(Object.fromEntries(Object.entries(this.userState).filter((t=>{let[e]=t;return"token"!==e}))))}updateAuthenticatedUser(t){this.userState.authenticated?this.userState={...this.userState,...t}:t.authenticated&&(this.userState=t),this.render()}logout(){this.userState={authenticated:!1},this.clearState(),this.render()}removeOptionDuplicates(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!t)return;const e=new Set,n=[];for(const r of t)e.has(r.value)?console.warn(`Duplicated key: "${r.value}", Ignored: "${r.label}"`):(n.push(r),e.add(r.value));return n}startOAuthFlow(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var r,i;const o=this.getIntegrationByName(t),s=(0,u.findSelectedAccountType)(null===(r=null==o?void 0:o.sdkIntegrationConfig)||void 0===r?void 0:r.accountTypes,this.getAccountName(e.accountType),this.getSelectedMultipleAccountTypes(e.accountType)),l={context:{user:this.userState,projectId:this.projectId,environments:this.environments,endUserIntegrationConfig:this.endUserIntegrationConfig[t]},integration:o,endUserSuppliedValues:e.endUserSuppliedValues},c=Boolean(o.needPreOauthInputs&&s&&!(null===(i=s.endUserSuppliedValues)||void 0===i?void 0:i.length)&&s.scheme===a.AuthenticationScheme.OAUTH);if(this.isHeadless||c||!o.needPreOauthInputs){l.authParams=null==s?void 0:s.oauthParameters,l.installOptions=e;const r=Math.random().toString(36).substring(2,15),i=(0,d.startOAuthFlow)(l,r);if(!i)throw new g.OAuthBlockedError;const o=()=>{clearInterval(v)},a=Date.now(),c=new AbortController,u=500;let h=!1;const f={abortSignal:c.signal,onSuccess:t=>{var e;h||(h=!0,o(),null===(e=n.onSuccess)||void 0===e||e.call(n,t))},onError:t=>{var e;h||(h=!0,o(),c.abort(),null===(e=n.onError)||void 0===e||e.call(n,t))}};new Promise(((t,e)=>{const n=r=>{"oauth_success_callback"===r.data.type&&(window.removeEventListener("message",n),t(r.data.credential.payload.credentialId)),"oauth_error_callback"===r.data.type&&(window.removeEventListener("message",n),e(new Error(r.data.error)))};window.addEventListener("message",n)})).then((t=>{f.onSuccess(t)})).catch((t=>{f.onError(t)}));const p=setInterval((()=>{try{i.opener||(clearInterval(p),this.pollForCredential(t,r,f))}catch(e){clearInterval(p),this.pollForCredential(t,r,f)}}),u),v=setInterval((()=>{try{if(!h&&n.oauthTimeout&&Date.now()-a>n.oauthTimeout)return i.close(),void f.onError(new g.OAuthTimeoutError)}catch(t){f.onError(t)}}),u)}}getIntegrationByName(t){const e=Object.values(this.loadedIntegrations).find((e=>(0,l.getIntegrationTypeName)(e)===t));if(!e)throw new Error(`Integration "${t}" not found.`);return e}getSelectedMultipleAccountTypes(t){if(Array.isArray(t))return t}getAccountName(t){return"string"==typeof t?t.trim():""}setDynamicFieldMappingLoaders(t,e){var n,r;if(this.dynamicFieldMappingLoaders[t]={},e)for(const[i,o]of Object.entries(e))if("object"==typeof o&&"objectTypes"in o&&"integrationFields"in o&&"applicationFields"in o){const s=o;this.dynamicFieldMappingLoaders[t][i]={objectTypes:null===(n=s.objectTypes)||void 0===n?void 0:n.get,integrationFields:null===(r=s.integrationFields)||void 0===r?void 0:r.get},s.applicationFields&&(e[i]={...s.applicationFields,useBYOFieldMappingOption:!0})}}async connect(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{mapObjectFields:n,overrideRedirectUrl:r,isApiInstallation:i=!1,showPortalAfterInstall:o,bypassPostOAuthPrompt:a,allowMultipleCredentials:l,selectedCredentialId:c,selectedConfigurationId:d,accountType:h,...f}=e;return this.integrationToBeEnabled=t,new Promise(((v,y)=>{var E,S;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;const w=this.getIntegrationByName(t),_=this.getSelectedMultipleAccountTypes(h);this.subscribeToIntegration(t,{...f,onInstall:(e,n)=>{var r;const i=n.integrations[t];e.credentialId=null==i?void 0:i.credentialId,e.credential=null==i?void 0:i.allCredentials.find((t=>t.id===i.credentialId)),v(e),(null==f?void 0:f.onInstall)?f.onInstall(e,n):null===(r=null==f?void 0:f.onSuccess)||void 0===r||r.call(f,e,n)},onError:t=>{var e;y(t),null===(e=null==f?void 0:f.onError)||void 0===e||e.call(f,t)}});try{if(n&&!this.project.accessibleFeatures.includes(p.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.validateAction(t),r&&!(0,I.isValidUrl)(r))throw new Error(`${r} is not valid url.`);this.setDynamicFieldMappingLoaders(t,n),this.endUserIntegrationConfig[t]={mapObjectFields:n,overrideRedirectUrl:r?(0,I.sanitizeUrl)(r):void 0};const f=this.getAccountName(h),g=Array.isArray(h)?h.filter((t=>{var e,n;return!(null===(n=null===(e=null==w?void 0:w.sdkIntegrationConfig)||void 0===e?void 0:e.accountTypes)||void 0===n?void 0:n.some((e=>e.id===t)))})):[],m=(0,u.findSelectedAccountType)(null===(E=null==w?void 0:w.sdkIntegrationConfig)||void 0===E?void 0:E.accountTypes,f,_),C={isApiInstallation:i,showPortalAfterInstall:o,bypassPostOAuthPrompt:a,allowMultipleCredentials:l,selectedCredentialId:c,selectedConfigurationId:d,accountType:h};if(this.setCredentialConfigForUserState(t,c,d),e.isApiInstallation&&(null===(S=this.userState.integrations[t])||void 0===S?void 0:S.credentialStatus)!==s.CredentialStatus.PENDING){const n=this.isHeadless?{onSuccess:t=>{v({integrationId:w.id,integrationType:w.type,credentialId:t})},onError:t=>{y(t)},oauthTimeout:e.oauthTimeout}:void 0;this.startOAuthFlow(t,C,n)}(h&&!m&&"string"==typeof h||g.length)&&console.warn(`Account type "${g.length?g:h}" is not valid for integration "${null==w?void 0:w.type}"`);const O=JSON.parse(JSON.stringify(this.loadedConfigs[t]));if(e.dropdowns){const n=e.dropdowns,r=[];for(const t in n){const e=n[t];if("loadOptions"in e){const n=e.loadOptions;this.customDropdownOptionsLoaders[t]=n,r.push(t)}}if(O.sharedMeta&&Array.isArray(O.sharedMeta.inputs))for(const t of O.sharedMeta.inputs){if(r.includes(t.key)){t.customDropdownOptions=[];continue}const e=this.removeOptionDuplicates(n[t.key]);e&&t.customDropdownOptions&&(t.customDropdownOptions=e)}if(O.workflowMeta)for(const t in O.workflowMeta){const e=O.workflowMeta[t];for(const t of e.inputs){if(r.includes(t.key)){t.customDropdownOptions=[];continue}const e=this.removeOptionDuplicates(n[t.key]);e&&t.customDropdownOptions&&(t.customDropdownOptions=e)}}this.loadedConfigs[t]=O}this.setModalState({integration:w,config:this.loadedConfigs[t],apiInstallationOptions:{...C,selectedMultipleAccountTypes:_,selectedAccountConfig:m},selectedCredentialId:c,connectionError:void 0,shouldShowPortalAfterInstall:!1})}catch(e){this.emitError(e,t)}}))}setCredentialConfigForUserState(t,e,n){var r,i,o;if(!this.userState.authenticated||!(null===(r=this.userState.integrations[t])||void 0===r?void 0:r.allCredentials.length))return;const a=this.userState.integrations[t],l=null!==(i=null==a?void 0:a.credentialId)&&void 0!==i?i:null==a?void 0:a.allCredentials[0].id,c=this.getCredentialAndConfig(e||n?{selectedCredentialId:e,selectedConfigurationId:n}:{selectedCredentialId:l},a);if(!(null===(o=null==a?void 0:a.allCredentials)||void 0===o?void 0:o.some((t=>{let{id:e}=t;return e===(null==c?void 0:c.selectedCredential.id)})))||!c)throw new Error(`Credential with ID "${e}" is not a valid ${t} account.`);const{selectedConfig:u,selectedCredential:d}=c,h={...a,allConfigurations:(null==a?void 0:a.allConfigurations)||[],allCredentials:(null==a?void 0:a.allCredentials)||[],enabled:d.status===s.CredentialStatus.VALID,credentialId:d.id,credentialStatus:d.status,providerData:d.providerData,providerId:d.providerId,configMeta:null==u?void 0:u.configMeta,credentialConfigId:null==u?void 0:u.id,externalId:null==u?void 0:u.externalId,sharedSettings:null==u?void 0:u.sharedSettings,workflowSettings:null==u?void 0:u.workflowSettings,configuredWorkflows:null==u?void 0:u.workflowSettings};this.userState.integrations={...this.userState.integrations,[t]:h}}getCredentialAndConfig(t,e,n){var r;const{selectedCredentialId:i,selectedConfigurationId:o}=t,s=null==i?void 0:i.trim(),a=null==o?void 0:o.trim();if(s&&!(0,E.isUUID)(s))throw new Error(`Selected credential id: ${s} is not a valid UUID.`);if(!this.userState.authenticated||!s&&!a)return;let l,c;const u=null!==(r=null==e?void 0:e.allCredentials)&&void 0!==r?r:Object.values(this.userState.integrations).flatMap((t=>(null==t?void 0:t.allCredentials)||[])),d=u.flatMap((t=>{let{configurations:e}=t;return e}));if(a){const t=a.startsWith("ext:")||!(0,E.isUUID)(a),e=(0,v.sanitizeExternalConfigId)(a),r=n=>(t?n.externalId===e:n.id===e)&&(!s||n.connectCredentialId===s);if(null==n?void 0:n.throwIfMultipleConfigsFound){const t=d.filter(r);if(t.length>1)throw new Error(`Multiple credential configurations found for provided id: ${a}.`);c=t[0]}else c=d.find(r);if(!c)throw new Error(`Credential configuration not found for provided id: ${a}.`)}if(l=u.find((t=>{let{id:e}=t;return e===((null==c?void 0:c.connectCredentialId)||s)})),c=null!=c?c:null==l?void 0:l.configurations.find((t=>{let{isDefault:e}=t;return e})),!l)throw new Error("Unable to find credential for provided options.");if(!c)throw new Error(`Credential configuration not found for credential: ${l.id}.`);if(c&&c.connectCredentialId!==(null==l?void 0:l.id))throw new Error('Provided "selectedCredentialId" does not belongs to provided "selectedConfigurationId".');return{selectedCredential:l,selectedConfig:c}}_getIntegration(t){return Object.values(this.loadedIntegrations).find((e=>e.id===t))}getIntegrationBySlug(t){const e=this.loadedIntegrations[t];if(!e)throw new g.IntegrationNotFoundError(t);return e}async _oauthCallback(t,e){var n,r;const{integrationId:i,payload:o}=t,a=this._getIntegration(i);if(!a)return;const c=(0,y.hash)(JSON.stringify({oauthResponse:t,credentialId:e}));if(await this.cachedApiResponse.get(c))return;await this.cachedApiResponse.set(c,!0);const u=(0,l.getIntegrationTypeName)(a),d=(null===(n=this.modalState.apiInstallationOptions)||void 0===n?void 0:n.isApiInstallation)?this.modalState.apiInstallationOptions:{};try{const t=e?`/sdk/credentials/${e}/complete-setup`:"/sdk/credentials",n=await this.sendConnectRequest(t,{method:"POST",body:JSON.stringify({integrationId:a.id,config:{},payload:o,installOptions:d})});if(!n)throw new Error("Unable to save oauth credentials");this.updateCredentialData(n,a),n.status===s.CredentialStatus.VALID&&this.triggerSDKEvent({type:p.SDK_EVENT.ON_INTEGRATION_INSTALL,integrationId:a.id,integrationType:u}),this.setModalState({...this.modalState,...(null===(r=this.modalState.apiInstallationOptions)||void 0===r?void 0:r.showPortalAfterInstall)?{shouldShowPortalAfterInstall:!0}:{},connectionError:void 0})}catch(t){if(this.isHeadless)throw t;this.setModalState({...this.modalState,connectionError:t}),this.emitError(t,u),await this._oauthErrorCallback(t.message)}}async _oauthErrorCallback(t,e){var n;const r=t;let i;i=this.integrationToBeEnabled?this.loadedIntegrations[this.integrationToBeEnabled].id:null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.integrationId,e&&(this.emitError(e.data.errorResponse,(0,l.getIntegrationTypeName)(this._getIntegration(i))),this.setModalState({...this.modalState,connectionError:e.data})),console.error("Failed to connect account to Paragon over OAuth",r)}async _loadCustomDropdownOptions(t,e,n){return(0,h.cloneDeep)(this.customDropdownOptionsLoaders[t](e,n))}async sendConnectRequest(t,e){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];var r;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 i=`${null!==(r=null==e?void 0:e.baseURLOverride)&&void 0!==r?r:this.environments.ZEUS_PUBLIC_URL}${n?`/projects/${this.projectId}`:""}${t}`,o=(0,y.hash)(JSON.stringify({url:i,payload:{...e}})),s=await this.cachedApiResponse.get(o,!0);if((null==e?void 0:e.cacheResult)&&s)return s;const a=Boolean(!e||"GET"===e.method||e.cacheResult);if(a&&"object"==typeof this.keyToRequestPromiseMap[o])return this.keyToRequestPromiseMap[o];const l=this.userState.token,c=this.modalState.integration&&this.integrationToBeEnabled?this.userState.integrations[this.integrationToBeEnabled]:void 0,u=new Promise(((t,n)=>{(async()=>{try{const n=await this.sendRequest(i,{...e,headers:{Accept:"application/json","Content-Type":"application/json",[p.SDK_VERSION_HEADER]:this.sdkVersion,...!(null==e?void 0:e.skipDefaultCredentialIdHeader)&&(null==c?void 0:c.credentialId)?{[p.SELECTED_CREDENTIAL_ID_HEADER]:null==c?void 0:c.credentialId}:{},...null==e?void 0:e.headers,Authorization:`Bearer ${l}`}},a?o:void 0);t(n)}catch(t){n(t)}})()}));return a&&(this.keyToRequestPromiseMap[o]=u),u}async sendRequest(t,e,n){var r;let i,s,a;try{i=await fetch(t,e)}catch(t){a=t}if(i&&!i.ok||a){const e=i?await(0,I.getErrorMessage)(i,!0):null==a?void 0:a.message,s="string"==typeof e?e:null==e?void 0:e.message,l=(0,I.errorMessageParser)(s),c="object"==typeof e&&e.response.code===o.INSUFFICIENT_PERMISSION,u="object"==typeof e&&[o.BYO_CREDENTIAL_VERIFICATION_ERROR,o.BYO_USER_PROFILE_ERROR_CODE].includes(e.response.code),d=401===(null==i?void 0:i.status)||403===(null==i?void 0:i.status),h=!l&&!c&&!u&&d;if(h&&!t.includes("proxy"))this.logout();else if(h&&t.includes("proxy")){const t=await this.fetchUserData();this.updateAuthenticatedUser({integrations:t.integrations,meta:t.meta,resources:t.resources})}if(n&&(await this.cachedApiResponse.del(n),delete this.keyToRequestPromiseMap[n]),"string"!=typeof e&&t.includes("proxy"))throw null===(r=e.response)||void 0===r||delete r.headers,new I.ProxyRequestError(e.message,e.response);throw new Error("string"==typeof e?s:JSON.stringify(e.response))}try{s=await(null==i?void 0:i.json())}catch{s=void 0}return n&&(await this.cachedApiResponse.set(n,s),delete this.keyToRequestPromiseMap[n]),s}async request(t,e,n){const r=`/sdk/proxy/${t}`,i=e.startsWith("/")?e:`/${e}`,o=n.selectedCredentialId,s=await this.sendConnectRequest(`${r}${i}`,{method:n.method,body:"object"==typeof n.body?JSON.stringify(n.body):n.body,headers:{"Content-Type":p.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS,...o?{[p.SELECTED_CREDENTIAL_ID_HEADER]:o}:{},...n.headers},baseURLOverride:this.environments.WORKER_PROXY_PUBLIC_URL,skipDefaultCredentialIdHeader:!0});return null==s?void 0:s.output}async event(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{selectedConfigurationId:r,selectedCredentialId:i}=n;if(r&&!i)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:{...i?{[p.SELECTED_CREDENTIAL_ID_HEADER]:i}:{},...r?{[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:r}:{}},body:JSON.stringify({name:t,payload:e}),skipDefaultCredentialIdHeader:!0,baseURLOverride:this.environments.HERMES_PUBLIC_URL},!1)}onClose(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{integration:n,apiInstallationOptions:r}=this.modalState;n&&(this.triggerSDKEvent({type:p.SDK_EVENT.ON_PORTAL_CLOSE,integrationId:n.id,integrationType:(0,l.getIntegrationTypeName)(n)}),this.originalBodyOverflow!==e.PARAGON_OVERFLOW_EMPTY_VALUE&&(window.document.body.style.overflow=this.originalBodyOverflow,this.originalBodyOverflow=e.PARAGON_OVERFLOW_EMPTY_VALUE),!t&&(null==r?void 0:r.isApiInstallation)||(this.setModalState({integration:null}),this.integrationToBeEnabled=void 0))}onOpen(){const{integration:t}=this.modalState;if(t&&(this.triggerSDKEvent({type:p.SDK_EVENT.ON_PORTAL_OPEN,integrationId:t.id,integrationType:(0,l.getIntegrationTypeName)(t)}),this.root&&this.originalBodyOverflow===e.PARAGON_OVERFLOW_EMPTY_VALUE)){const t=this.root.getBoundingClientRect();window.innerHeight<=t.height&&window.innerWidth<=t.width&&(this.originalBodyOverflow=window.document.body.style.overflow,window.document.body.style.overflow="hidden")}}triggerSDKEvent(t){this.triggerEvent(t,this.userState)}getIntegrationMetadata(t){const e=t=>{return{...t,icon:(e=t.icon,e.includes(".svg")?(null===(n=e.split(".svg"))||void 0===n?void 0:n[0])+".svg":e)};var e,n};if(t){const n=this.metadata[t];if(!n)throw new Error(`${t} is not a valid integration name`);return e(n)}return(0,h.cloneDeep)(Object.values(this.metadata).map(e))}closePortal(){this.onClose(!0)}workflow(t){let{selectedCredentialId:e,selectedConfigurationId:n,body:r={},query:i={},headers:o={}}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var s;if(!t)throw new Error("workflowId is required.");const a=new URLSearchParams(i).toString(),{integrationState:l}=this.getIntegrationForWorkflow(t);let c;if((e||n)&&(c=this.getCredentialAndConfig({selectedCredentialId:e,selectedConfigurationId:n},l,{throwIfMultipleConfigsFound:!0}),!c||!(null===(s=c.selectedConfig.workflowSettings[t])||void 0===s?void 0:s.enabled)))throw new Error(`Workflow ${t} is not enabled for this user.`);return this.sendConnectRequest(`/sdk/triggers/${t}?${a}`,{method:"POST",body:JSON.stringify(r),headers:{...c?{[p.SELECTED_CREDENTIAL_ID_HEADER]:c.selectedCredential.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:c.selectedConfig.id}:{},...o},skipDefaultCredentialIdHeader:!0,baseURLOverride:this.environments.HERMES_PUBLIC_URL},!0)}installIntegration(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;this.closePortal();const n={showPortalAfterInstall:!1,bypassPostOAuthPrompt:!1,allowMultipleCredentials:!1,...e,isApiInstallation:!0};if(n.bypassPostOAuthPrompt&&n.showPortalAfterInstall)throw new Error("Could not use both `bypassPostOAuthPrompt` and `showPortalAfterInstall` as true at the same time.");if(this.ensureHeadlessIsSupported(),this.validateAction(t),!n.allowMultipleCredentials&&this.isAlreadyInstalled(t,this.userState))throw new Error(`Integration "${t}" is already installed.`);if(e.showPortalAfterInstall){const e=Object.values(this.loadedIntegrations).find((e=>(0,l.getIntegrationTypeName)(e)===t));this.setModalState({integration:e,config:this.loadedConfigs[t],apiInstallationOptions:n,shouldShowPortalAfterInstall:!1})}else this.setModalState({integration:null});return this.connect(t,n)}ensureHeadlessIsSupported(){if(!this.project.accessibleFeatures.includes(p.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(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=null==e?void 0:e.selectedCredentialId;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;if(this.ensureHeadlessIsSupported(),this.validateAction(t),!this.hasCredential(t,this.userState,e.selectedCredentialId))throw new g.IntegrationNotInstalledError(t);const r=this.loadedIntegrations[t].id,i=this.userState.integrations[t],o=n||(null==i?void 0:i.credentialId);if(!o||!i)throw new Error("No credential found for uninstall");await this.sendConnectRequest(`/sdk/integrations/${r}`,{method:"DELETE",headers:{...o?{[p.SELECTED_CREDENTIAL_ID_HEADER]:o}:{}}}),this.updateAuthenticatedUser({integrations:{...this.userState.integrations,[t]:(0,u.getActionStateForCredentialDelete)(o,i)}}),n===this.modalState.selectedCredentialId&&this.setModalState({integration:null,selectedCredentialId:void 0}),this.saveState(),this.triggerSDKEvent({type:p.SDK_EVENT.ON_INTEGRATION_UNINSTALL,integrationId:r,integrationType:t})}async disableWorkflow(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;const{selectedCredentialId:r,selectedConfigurationId:i}=e,{integration:o,integrationState:s}=this.getIntegrationForWorkflow(t),a=this.getCredentialAndConfig(r||i?{selectedCredentialId:r,selectedConfigurationId:i}:{selectedCredentialId:s.credentialId},s);if(!a||!(null===(n=a.selectedConfig.workflowSettings[t])||void 0===n?void 0:n.enabled))throw new Error(`Workflow ${t} cannot be disabled for this user.`);const{selectedConfig:l,selectedCredential:c}=a;await this.sendConnectRequest(`/sdk/workflows/${t}`,{method:"DELETE",headers:{[p.SELECTED_CREDENTIAL_ID_HEADER]:c.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:l.id}});const u={...l,workflowSettings:{...l.workflowSettings,[t]:{settings:{},...l.workflowSettings[t],enabled:!1}}},d={...c,configurations:c.configurations.filter((t=>t.id!==l.id)).concat(u)};this.updateCredentialData(d,o)}async enableWorkflow(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;const{selectedCredentialId:r,selectedConfigurationId:i}=e,{integration:o,integrationState:a}=this.getIntegrationForWorkflow(t),l=this.getCredentialAndConfig(r||i?{selectedCredentialId:r,selectedConfigurationId:i}:{selectedCredentialId:a.credentialId},a);if(!l||(null==l?void 0:l.selectedCredential.status)!==s.CredentialStatus.VALID)throw new Error("Valid credential not found for provided options.");const{selectedConfig:c,selectedCredential:u}=l;if(null===(n=c.workflowSettings[t])||void 0===n?void 0:n.enabled)throw new Error(`Workflow ${t} is already enabled for this user.`);await this.sendConnectRequest(`/sdk/workflows/${t}`,{method:"POST",headers:{[p.SELECTED_CREDENTIAL_ID_HEADER]:u.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:c.id}});const d={...c,workflowSettings:{...c.workflowSettings,[t]:{settings:{},...c.workflowSettings[t],enabled:!0}}},h={...u,configurations:u.configurations.filter((t=>t.id!==c.id)).concat(d)};this.updateCredentialData(h,o)}async getIntegrationAccount(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;this.validateAction(t);const r=null===(n=this.userState.integrations[t])||void 0===n?void 0:n.allCredentials;if(!(null==r?void 0:r.length))throw new Error("Connect credential not found");const i=await this.sendConnectRequest(`/sdk/credentials?integration=${t}&includeAccountAuth=${e.includeAccountAuth}`,{method:"GET",headers:e.selectedCredentialId?{[p.SELECTED_CREDENTIAL_ID_HEADER]:e.selectedCredentialId}:{}});if(!i)throw new Error("Integration not connected");return i}getIntegrationForWorkflow(t){if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;const e=Object.values(this.loadedIntegrations).find((e=>{const n=e.configs[0].values;return t in(n.workflowMeta||{})}));if(!e)throw new Error("Workflow not found in the configured integrations in your Paragon project.");const n=(0,l.getIntegrationTypeName)(e)?this.userState.integrations[(0,l.getIntegrationTypeName)(e)]:void 0;if(!n||!n.allCredentials.some((t=>{let{status:e}=t;return e===s.CredentialStatus.VALID})))throw new Error(`Integration "${(0,l.getIntegrationTypeName)(e)}" not enabled for workflow."`);return{integration:e,integrationState:n}}async updateLocalState(t){var e,n;const[r,i]=await Promise.all([this.fetchUserData(t),this.fetchIntegrations()]);this.project=r.project;let o={...r.integrations};if(this.modalState.integration&&this.integrationToBeEnabled){const t=this.userState.integrations[this.integrationToBeEnabled],r=null==t?void 0:t.credentialConfigId,i=null==t?void 0:t.credentialId;let s;if(r)s=null===(e=o[this.integrationToBeEnabled])||void 0===e?void 0:e.allConfigurations.find((t=>{let{id:e}=t;return e===r}));else if(i){const t=null===(n=o[this.integrationToBeEnabled])||void 0===n?void 0:n.allCredentials.find((t=>{let{id:e}=t;return e===i}));s=t?t.configurations.find((t=>t.isDefault)):void 0}s&&(o={...o,[this.integrationToBeEnabled]:{enabled:!1,allConfigurations:[],allCredentials:[],...o[this.integrationToBeEnabled],credentialId:s.connectCredentialId,credentialConfigId:s.id,workflowSettings:s.workflowSettings,configuredWorkflows:s.workflowSettings,sharedSettings:s.sharedSettings,configMeta:s.configMeta}})}this.updateAuthenticatedUser({integrations:o,meta:r.meta,resources:r.resources}),this.updateIntegrations(i),this.saveState()}async fetchUserData(t){const e=await this.sendConnectRequest("/sdk/me",{headers:(0,v.getHeadersForUserMeta)(t)});if(!e)throw new Error("Unable to get user Data");return{...e,integrations:Object.fromEntries(Object.entries(e.integrations).map((t=>{let[e,n]=t;const r=n.allCredentials.flatMap((t=>{let{configurations:e}=t;return e}));return[e,{...n,allConfigurations:r}]})))}}async fetchIntegrations(){const t=await this.sendConnectRequest("/sdk/integrations");if(!t)throw new Error("Unable to fetch integrations");return t}getIntegrationIcon(t){if(!t.customIntegration){const e=p.overrideActionAlias[t.type]||t.type;return`${this.environments.CDN_PUBLIC_URL}/integrations/${e}.svg`}return t.customIntegration.icon?t.customIntegration.icon:`${this.environments.CDN_PUBLIC_URL}/images/icons/byo-placeholder.svg`}updateIntegrations(t){t.forEach((t=>{var e;if(t.configs.length)try{const n=(0,l.getIntegrationTypeName)(t);this.loadedConfigs[n]=t.configs[0].values,this.loadedIntegrations[n]={...t,type:t.type.startsWith("custom.")?o.ACTION_CUSTOM:t.type},Boolean(t.isActive)&&(this.metadata[n]={type:n,name:t.name,brandColor:t.brandColor,icon:this.getIntegrationIcon(t)}),(null===(e=this.modalState.integration)||void 0===e?void 0:e.id)===t.id&&this.setModalState({integration:{...t,type:t.type.startsWith("custom.")?o.ACTION_CUSTOM:t.type}})}catch(t){console.warn(t)}}))}async setUserMetadata(t){return await this.sendConnectRequest("/sdk/me",{method:"PATCH",body:JSON.stringify({meta:t})}),await this.updateLocalState(),this.render(),this.userState}configureGlobal(t,e){var n,r,i,o,s,a,l,c;if(!t||!t.host)throw new Error("host not specified");const u=t.host.indexOf("http")>-1?new URL(t.host).hostname:t.host;this.environments.CONNECT_PUBLIC_URL=null!==(n=null==e?void 0:e.CONNECT_PUBLIC_URL)&&void 0!==n?n:(0,I.getServiceUrl)("connect",u),this.environments.DASHBOARD_PUBLIC_URL=null!==(r=null==e?void 0:e.DASHBOARD_PUBLIC_URL)&&void 0!==r?r:(0,I.getServiceUrl)("dashboard",u),this.environments.HERMES_PUBLIC_URL=null!==(i=null==e?void 0:e.HERMES_PUBLIC_URL)&&void 0!==i?i:(0,I.getServiceUrl)("hermes",u),this.environments.PASSPORT_PRODUCTION_URL=null!==(o=null==e?void 0:e.PASSPORT_PRODUCTION_URL)&&void 0!==o?o:(0,I.getServiceUrl)("passport",u),this.environments.PASSPORT_PUBLIC_URL=null!==(s=null==e?void 0:e.PASSPORT_PUBLIC_URL)&&void 0!==s?s:(0,I.getServiceUrl)("passport",u),this.environments.ZEUS_PUBLIC_URL=null!==(a=null==e?void 0:e.ZEUS_PUBLIC_URL)&&void 0!==a?a:(0,I.getServiceUrl)("zeus",u),this.environments.CDN_PUBLIC_URL=null!==(l=null==e?void 0:e.CDN_PUBLIC_URL)&&void 0!==l?l:(0,I.getServiceUrl)("dashboard",u),this.environments.WORKER_PROXY_PUBLIC_URL=null!==(c=null==e?void 0:e.WORKER_PROXY_PUBLIC_URL)&&void 0!==c?c:(0,I.getServiceUrl)("worker-proxy",u),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(t,e){var n;if(!this.userState.authenticated)throw new Error("Authentication is required");if(!e||!e.authorizationCode)throw new Error("authorizationCode is required");if(e.redirectUrl&&!(0,I.isValidUrl)(e.redirectUrl))throw new Error(`${e.redirectUrl} is not valid url`);this.validateAction(t);const r=Object.values(this.loadedIntegrations).find((e=>(0,l.getIntegrationTypeName)(e)===t)),i=null===(n=e.showPortalAfterInstall)||void 0===n||n,o=await this.sendConnectRequest("/sdk/credentials",{method:"POST",body:JSON.stringify({code:e.authorizationCode,integrationId:r.id,redirectUrl:e.redirectUrl?(0,I.sanitizeUrl)(e.redirectUrl):void 0,integrationOptions:e.integrationOptions||{}})});if(!o)throw new Error("Unable to create credential");this.updateCredentialData(o,r),i&&this.setModalState({integration:r,config:this.loadedConfigs[t],apiInstallationOptions:{}})}updateCredentialData(t,e){var n;const r=this.userState,i=(0,l.getIntegrationTypeName)(e),o=r.integrations[i],a=o.allCredentials.findIndex((e=>{let{id:n}=e;return n===t.id}));a>-1?o.allCredentials[a]=t:o.allCredentials.push(t);const c=Object.values(null!==(n=o.allConfigurations)&&void 0!==n?n:[]).filter((e=>{let{connectCredentialId:n}=e;return n!==t.id})).concat(t.configurations);if(!(-1===a||t.id===o.credentialId||!(!o.credentialConfigId||!t.configurations.some((t=>t.id===o.credentialConfigId)))))return this.updateAuthenticatedUser({integrations:{...r.integrations,[i]:{...o,allConfigurations:c}}}),void this.saveState();const u=o.credentialConfigId?t.configurations.find((t=>o.credentialConfigId===t.id)):t.configurations[0];this.updateAuthenticatedUser({integrations:{...r.integrations,[i]:{...o,allConfigurations:c,credentialStatus:t.status,enabled:t.status===s.CredentialStatus.VALID,credentialId:t.id,providerId:t.providerId,providerData:t.providerData,configMeta:null==u?void 0:u.configMeta,credentialConfigId:null==u?void 0:u.id,externalId:null==u?void 0:u.externalId,sharedSettings:null==u?void 0:u.sharedSettings,workflowSettings:null==u?void 0:u.workflowSettings,configuredWorkflows:null==u?void 0:u.workflowSettings}}}),this.saveState()}async connectAction(t,e){var n;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;const r=null===(n=this.userState.resources.find((e=>t===e.slug)))||void 0===n?void 0:n.id;if(!r)throw new Error(`No resource found with name "${t}".`);if(!e||"object"!=typeof e)throw new Error("payload must be of type object.");const i=await this.sendConnectRequest(`/sdk/resources/${r}/connect`,{method:"POST",body:JSON.stringify(e)});if(!i)throw new Error(`Unable to connect to "${t}".`);return i}async createConfiguration(t){let{credentialId:e,externalId:n}=t;var r,i;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;if(!e)throw new Error('Required options not provided: "credentialId"');const o=this.getCredentialAndConfig({selectedCredentialId:e});if(!o||(null==o?void 0:o.selectedCredential.status)!==s.CredentialStatus.VALID)throw new Error("Valid credential not found for provided options.");const a=await this.sendConnectRequest(`/sdk/credentials/${e}/configurations`,{method:"POST",body:JSON.stringify(n?{externalId:n}:{})});if(!a)throw new Error("Unable to create a configuration for credential.");const l=Object.keys(this.userState.integrations).find((t=>{var e;return null===(e=this.userState.integrations[t])||void 0===e?void 0:e.allCredentials.find((t=>{let{id:e}=t;return e===a.id}))}));if(l){const t=null===(r=this.userState.integrations[l])||void 0===r?void 0:r.allConfigurations.filter((t=>{let{connectCredentialId:e}=t;return e!==a.id})).concat(a.configurations),e=null===(i=this.userState.integrations[l])||void 0===i?void 0:i.allCredentials.map((t=>t.id===a.id?a:t)),n={...this.userState.integrations,[l]:{enabled:!1,...this.userState.integrations[l],allConfigurations:t||[],allCredentials:e||[]}};this.updateAuthenticatedUser({integrations:n})}return[...a.configurations].sort(((t,e)=>new Date(e.dateCreated).getTime()-new Date(t.dateCreated).getTime()))[0]}async destroyConfiguration(t){let{id:e,credentialId:n}=t;var r,i,o,s;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;if(!(null==e?void 0:e.trim())||!(null==n?void 0:n.trim()))throw new Error("One or more required options not provided.");const a=this.getCredentialAndConfig({selectedConfigurationId:e,selectedCredentialId:n});if(!a)throw new Error(`Unable to find credential for configuration: ${e}.`);if(a.selectedConfig.isDefault)throw new Error("Cannot delete default configuration.");await this.sendConnectRequest(`/sdk/credentials/${a.selectedCredential.id}/configurations`,{method:"DELETE",headers:{[p.SELECTED_CREDENTIAL_ID_HEADER]:null==a?void 0:a.selectedCredential.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:null==a?void 0:a.selectedConfig.id}});const l=Object.keys(this.userState.integrations).find((t=>{var e;return null===(e=this.userState.integrations[t])||void 0===e?void 0:e.allCredentials.find((t=>{let{id:e}=t;return e===a.selectedCredential.id}))}));if(l){const{selectedConfig:t,selectedCredential:e}=a,n=null===(r=this.userState.integrations[l])||void 0===r?void 0:r.allConfigurations.filter((e=>{let{id:n}=e;return n!==t.id})),c=null===(i=this.userState.integrations[l])||void 0===i?void 0:i.allCredentials.map((n=>n.id!==e.id?n:{...n,configurations:n.configurations.filter((e=>{let{id:n}=e;return n!==t.id}))})),u={...this.userState.integrations,[l]:{enabled:!1,...this.userState.integrations[l],allConfigurations:n||[],allCredentials:c||[]}};this.updateAuthenticatedUser({integrations:u}),(null===(o=this.userState.integrations[l])||void 0===o?void 0:o.credentialId)===e.id&&(null===(s=this.userState.integrations[l])||void 0===s?void 0:s.credentialConfigId)===t.id&&this.closePortal()}}async updateConfiguration(t){let{id:e,credentialId:n,meta:r={}}=t;var i,o;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;if(!(null==e?void 0:e.trim())||!(null==n?void 0:n.trim()))throw new Error("One or more required options not provided.");const s=this.getCredentialAndConfig({selectedConfigurationId:e,selectedCredentialId:n});if(!(null==s?void 0:s.selectedConfig))throw new Error(`Cannot find credential configuration with given id: "${e}"`);const a=await this.sendConnectRequest(`/sdk/credentials/${s.selectedConfig.connectCredentialId}/configurations`,{method:"PATCH",body:JSON.stringify({meta:r}),headers:{[p.SELECTED_CREDENTIAL_ID_HEADER]:s.selectedCredential.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:s.selectedConfig.id}});if(!a)throw new Error("Unable to update configuration.");const l=Object.keys(this.userState.integrations).find((t=>{var e;return null===(e=this.userState.integrations[t])||void 0===e?void 0:e.allCredentials.find((t=>{let{id:e}=t;return e===a.id}))}));if(l){const t=null===(i=this.userState.integrations[l])||void 0===i?void 0:i.allConfigurations.filter((t=>{let{connectCredentialId:e}=t;return e!==a.id})).concat(a.configurations),e=null===(o=this.userState.integrations[l])||void 0===o?void 0:o.allCredentials.map((t=>t.id===a.id?a:t)),n={...this.userState.integrations,[l]:{enabled:!1,...this.userState.integrations[l],allConfigurations:t||[],allCredentials:e||[]}};this.updateAuthenticatedUser({integrations:n})}const c=a.configurations.find((t=>{let{id:e}=t;return e===s.selectedConfig.id}));return c}async pollForCredential(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var r;const i=Date.now(),o=async()=>{try{return await this.sendConnectRequest(`/sdk/actions/session-id/${e}`,{method:"GET"})}catch(t){return console.error("error",t),null}};try{const e=await(0,E.tryUntil)(o,((t,e)=>{var r;return!(null===(r=n.abortSignal)||void 0===r?void 0:r.aborted)&&!(Date.now()-i>=d.MAX_POLL_DURATION||(null==t?void 0:t.connectCredentialId))}),1e3);if(!e||!e.connectCredentialId)return;n.onSuccess&&n.onSuccess(e.connectCredentialId);const a=null===(r=this.userState.integrations[t])||void 0===r?void 0:r.allCredentials.find((t=>t.id===e.connectCredentialId)),l=this.getIntegrationByName(t);if(a&&a.status===s.CredentialStatus.VALID)return void this.triggerSDKEvent({type:p.SDK_EVENT.ON_INTEGRATION_INSTALL,integrationId:l.id,integrationType:t});const c=await this.sendConnectRequest(`/sdk/credentials/${e.connectCredentialId}`,{method:"GET"});if(!c)return;this.updateCredentialData(c,this.loadedIntegrations[t]),c.status===s.CredentialStatus.VALID&&this.triggerSDKEvent({type:p.SDK_EVENT.ON_INTEGRATION_INSTALL,integrationId:l.id,integrationType:t})}catch(t){n.onError&&n.onError(t)}finally{await this.sendConnectRequest(`/sdk/actions/session-id/${e}`,{method:"DELETE"})}}async getCustomWebhookUserManualUrl(t,e){var n;const r=this.userState;if(!r.authenticated)throw new g.UserNotAuthenticatedError;const{workflow:i,type:o}=Object.values(this.loadedIntegrations).reduce(((e,n)=>{if(e.workflow)return e;const r=n.workflows.find((e=>e.id===t));return r?{workflow:r,type:n.type}:e}),{workflow:void 0,type:void 0});if(!i)throw new Error(`Unable to get workflow for "${t}".`);if(!o)throw new Error(`Unable to get integration type for "${t}".`);let s=i.integrationId,a=null!=e?e:null===(n=r.integrations[o])||void 0===n?void 0:n.credentialId;if(i.resourceId){const t=r.resources.find((t=>t.id===i.resourceId));s=null==t?void 0:t.integrationId,a=null==t?void 0:t.credentialId}if(!s)throw new Error(`Unable to find integrationId for "${t}".`);if(!a)throw new Error(`Unable to find credentialId for "${t}".`);return`${this.environments.HERMES_PUBLIC_URL}/triggers/connect/${this.projectId}/${s}/custom-triggers/${i.customWebhookTriggerId}?id=${a}`}getIntegrationConfig(t){var e,n;if(!t)throw new Error("Integration is required.");const r=this.loadedIntegrations[t],i=(0,h.cloneDeep)(r.configs[0].values),o=[],s=[],a=new Map(r.workflows.map((t=>[t.id,t]))),l=null!==(e=r.noPermissionWorkflows)&&void 0!==e?e:[];return Object.values(i.workflowMeta||{}).map((t=>{var e;if(!a.has(t.id)&&!l.includes(t.id))return;const n=null===(e=a.get(t.id))||void 0===e?void 0:e.description;t.hidden||t.permissions&&l.includes(t.id)?o.push({...t,description:n}):s.push({...t,description:n})})),{shortDescription:i.description,longDescription:i.overview,availableUserSettings:null===(n=i.sharedMeta)||void 0===n?void 0:n.inputs,availableWorkflows:s,hiddenWorkflows:o}}getIntegrationCredential(t){let{integration:e,settings:n}=t;const{selectedCredentialId:r,selectedConfigurationId:i}=n,o=this.userState.integrations[e];if(!o)throw new Error(`Integration "${e}" state not found.`);const a=this.getCredentialAndConfig(r||i?{selectedCredentialId:r,selectedConfigurationId:i}:{selectedCredentialId:o.credentialId},o);if(!a||(null==a?void 0:a.selectedCredential.status)!==s.CredentialStatus.VALID)throw new Error("Valid credential not found for provided options.");return a}async updateIntegrationUserSettings(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var r;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;this.validateAction(t);const{selectedConfig:i,selectedCredential:o}=this.getIntegrationCredential({integration:t,settings:n}),s=this.userState.token,a=null===(r=this.userState.integrations[t])||void 0===r?void 0:r.sharedSettings,l=await this.sendConnectRequest(`/sdk/credentials/${o.id}`,{method:"PATCH",headers:{Authorization:`Bearer ${s}`,[p.SELECTED_CREDENTIAL_ID_HEADER]:o.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:i.id},body:JSON.stringify({config:{sharedSettings:{...a,...e}}})});if(!l)throw new Error(`Failed to update settings for ${t}.`);if(l.credential){const e=this.loadedIntegrations[t];this.updateCredentialData(l.credential,e)}return{userState:this.userState,errors:l.errors||[]}}async updateWorkflowUserSettings(t,e,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};var i;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;this.validateAction(t);const{selectedConfig:o,selectedCredential:s}=this.getIntegrationCredential({integration:t,settings:r}),a=this.userState.token,l=structuredClone(null===(i=this.userState.integrations[t])||void 0===i?void 0:i.workflowSettings),c=null==l?void 0:l[e];if(!c)throw new Error("The workflow needs to be enabled in order to add workflow level user settings.");for(const t in n)c.settings[t]=n[t];const u=await this.sendConnectRequest(`/sdk/credentials/${s.id}`,{method:"PATCH",headers:{Authorization:`Bearer ${a}`,[p.SELECTED_CREDENTIAL_ID_HEADER]:s.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:o.id},body:JSON.stringify({config:{workflowSettings:l}})});if(!u)throw new Error(`Failed to update settings for ${t}.`);if(u.credential){const e=this.loadedIntegrations[t];this.updateCredentialData(u.credential,e)}return{userState:this.userState,errors:u.errors||[]}}async updateWorkflowState(t,e){const n=[];for(const[r,i]of Object.entries(t))try{i?await this.enableWorkflow(r,e):await this.disableWorkflow(r,e)}catch(t){n.push({workflowId:r,message:t.message})}return{user:this.getUser(),errors:n}}async getFieldOptions(t){let{integration:e,action:n,search:r,cursor:i,parameters:o=[]}=t;this.validateAction(e);const s=await this.sendConnectRequest("/sdk/actions",{method:"POST",body:JSON.stringify({action:e,sourceKey:n,parameters:o,paginationParameters:{pageCursor:null!=i?i:0,search:r}})});let a=[],l=[];const c=s.output.records||s.output;return c[0]&&"id"in c[0]?l=c:a=c,{data:a,nestedData:l,nextPageCursor:s.output.nextPageCursor||null}}async getDataSourceOptions(t,e){var n;const r=this.getIntegrationByName(t);return(0,h.cloneDeep)(null===(n=r.sdkIntegrationConfig)||void 0===n?void 0:n.dataSources[e])}getAccountTypeOptions(t){var e,n,r;const i=this.getIntegrationBySlug(t);return null!==(r=(0,h.cloneDeep)(null!==(n=null===(e=i.sdkIntegrationConfig)||void 0===e?void 0:e.accountTypes)&&void 0!==n?n:[]))&&void 0!==r?r:[]}getPreOptions(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";var n,r,i,o;const s=(0,h.cloneDeep)(this.getIntegrationBySlug(t));if(s.customIntegration)return s.authenticationType===a.AuthenticationScheme.OAUTH_CLIENT_CREDENTIAL?(0,h.cloneDeep)(A):null!==(n=s.customIntegration.inputFields)&&void 0!==n?n:[];const l=this.getAccountTypeOptions(t);if(null==l?void 0:l.length){const t=null==l?void 0:l.find((t=>t.id===e));if(null===(r=null==t?void 0:t.endUserSuppliedValues)||void 0===r?void 0:r.length)return(0,h.cloneDeep)(t.endUserSuppliedValues)}return(null===(o=null===(i=s.sdkIntegrationConfig)||void 0===i?void 0:i.authConfigInputs)||void 0===o?void 0:o.length)?s.sdkIntegrationConfig.authConfigInputs:[]}getPostOptions(t){var e,n;const r=this.getIntegrationBySlug(t);return null!==(n=(0,h.cloneDeep)(null===(e=r.sdkIntegrationConfig)||void 0===e?void 0:e.postOauthInputs))&&void 0!==n?n:[]}async _fetchBYOFieldMappingOptions(t,e,n,r){var i;const o=null===(i=this.dynamicFieldMappingLoaders[t])||void 0===i?void 0:i[n];if(!o)throw new Error(`No dynamic field mapping loader found for key: ${n}`);if(e===p.DynamicFieldMappingLoaderType.OBJECT_TYPES)return await o.objectTypes(null==r?void 0:r.cursor,null==r?void 0:r.search);if(e===p.DynamicFieldMappingLoaderType.INTEGRATION_FIELDS){if(!(null==r?void 0:r.objectType))throw new Error("objectType is required for integrationFields");return await o.integrationFields({objectType:r.objectType},r.cursor,r.search)}throw new Error(`Invalid type: ${e}. Must be 'objectTypes' or 'integrationFields'`)}}e.default=C;class O{constructor(t){this.paragon=t,this.startOptions=null,this.integrationName=null,this.accountTypeValue=null,this.preOptionsValue=null,this.postOptionsValue=null,this.credentialId=null}start(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.asyncStart(t,e).catch((t=>{this.handleError(t)}))}async cancel(){this.startOptions=null,this.accountTypeValue=null,this.preOptionsValue=null,this.postOptionsValue=null;try{if(this.credentialId&&this.integrationName&&await this.paragon.uninstallIntegration(this.integrationName,{selectedCredentialId:this.credentialId}),!this.credentialId&&!this.integrationName){const t=new g.NoActiveInstallFlowError;console.warn(t.message)}}catch(t){console.error("Error cancelling the current install flow",{credentialId:this.credentialId,integration:this.integrationName},t)}finally{this.integrationName=null,this.credentialId=null}}async asyncStart(t,e){if(this.startOptions=e,this.integrationName=t,this.accountTypeValue=null,this.preOptionsValue=null,this.postOptionsValue=null,this.credentialId=null,!this.paragon.isHeadless)throw new g.HeadlessModeNotEnabledError;const n=this.next();if("done"===n.stage||"postOptions"===n.stage){const r=await this.paragon.installIntegration(t,{oauthTimeout:null==e?void 0:e.oauthTimeout,allowMultipleCredentials:!0});if("done"===n.stage)return void this.handleComplete();(null==r?void 0:r.credentialId)&&(this.credentialId=r.credentialId)}this.handleNext(n)}handleError(t,e){var n,r;const i=(0,g.getConnectSDKError)(t);null===(r=null===(n=this.startOptions)||void 0===n?void 0:n.onError)||void 0===r||r.call(n,i,null!=e?e:null)}handleNext(t){var e,n;null===(n=null===(e=this.startOptions)||void 0===e?void 0:e.onNext)||void 0===n||n.call(e,t)}handleComplete(){var t,e;null===(e=null===(t=this.startOptions)||void 0===t?void 0:t.onComplete)||void 0===e||e.call(t)}getScheme(){var t,e;if(null===this.integrationName)return null;if(!this.accountTypeValue)return null!==(t=this.paragon.getIntegrationBySlug(this.integrationName).authenticationType)&&void 0!==t?t:null;const n=this.getSelectedAccountTypeOption();return null!==(e=null==n?void 0:n.scheme)&&void 0!==e?e:null}getIntegrationName(){if(!this.integrationName)throw new g.NoActiveInstallFlowError;return this.integrationName}getSelectedAccountTypeOption(){var t;return null===(t=this.paragon.getAccountTypeOptions(this.getIntegrationName()))||void 0===t?void 0:t.find((t=>t.id===this.accountTypeValue))}requiresAccountType(){const t=this.paragon.getAccountTypeOptions(this.getIntegrationName());return!(!t||0===t.length)&&!this.accountTypeValue}requiresPreOptions(){var t;const e=this.paragon.getPreOptions(this.getIntegrationName(),null!==(t=this.accountTypeValue)&&void 0!==t?t:void 0);return!(!e||0===e.length)&&!this.preOptionsValue}requiresPostOptions(){var t,e;if(null!==(e=null===(t=this.getSelectedAccountTypeOption())||void 0===t?void 0:t.skipPostOAuthInputs)&&void 0!==e&&e)return!1;const n=this.paragon.getPostOptions(this.getIntegrationName());return!(!n||0===n.length)&&!this.postOptionsValue}async handleOAuth(){let{accountType:t,endUserSuppliedValues:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=await new Promise(((n,r)=>{var i;this.paragon.startOAuthFlow(this.getIntegrationName(),{accountType:t,endUserSuppliedValues:e},{onSuccess:t=>n(t),onError:t=>r(t),oauthTimeout:null===(i=this.startOptions)||void 0===i?void 0:i.oauthTimeout})}));this.credentialId=n}async setAccountType(t){try{this.accountTypeValue=t;const e=this.next();if("preOptions"===e.stage)return void this.handleNext(e);if(this.getScheme()!==a.AuthenticationScheme.OAUTH)return void this.handleNext(e);await this.handleOAuth({accountType:t}),"done"===e.stage?this.handleComplete():this.handleNext(e)}catch(t){this.handleError(t,{stage:"accountType"})}}async setPreOptions(t){var e,n,r;try{if(!t)throw new Error("Pre options are not set");this.preOptionsValue=t;const i=this.next(),o="done"===i.stage;if(this.getScheme()===a.AuthenticationScheme.OAUTH)return await this.handleOAuth({accountType:null!==(e=this.accountTypeValue)&&void 0!==e?e:void 0,endUserSuppliedValues:{...this.preOptionsValue}}),void(o?this.handleComplete():this.handleNext(i));const s=null!==(r=null===(n=this.getSelectedAccountTypeOption())||void 0===n?void 0:n.skipPostOAuthInputs)&&void 0!==r&&r;await this.paragon._oauthCallback({payload:{...t,skipPostOAuthInputs:s},integrationId:this.paragon.getIntegrationId(this.getIntegrationName())}),o?this.handleComplete():this.handleNext(i)}catch(t){this.handleError(t,{stage:"preOptions"})}}async setPostOptions(t){var e,n;try{if(!t)throw new Error("Post options are not set");if(!this.credentialId)throw new Error("Credential ID is not set");this.postOptionsValue=t;const r=null!==(n=null===(e=this.getSelectedAccountTypeOption())||void 0===e?void 0:e.skipPostOAuthInputs)&&void 0!==n&&n;await this.paragon._oauthCallback({payload:{...t,skipPostOAuthInputs:r},integrationId:this.paragon.getIntegrationId(this.getIntegrationName())},this.credentialId);const i=this.next();"done"===i.stage?this.handleComplete():this.handleNext(i)}catch(t){this.handleError(t,{stage:"postOptions"})}}getAccountTypeValue(){return this.accountTypeValue}getPreOptionsValue(){return this.preOptionsValue}getPostOptionsValue(){return this.postOptionsValue}next(){var t;const e=this.getIntegrationName();return this.requiresAccountType()?{stage:"accountType",options:this.paragon.getAccountTypeOptions(e),done:!1}:this.requiresPreOptions()?{stage:"preOptions",options:this.paragon.getPreOptions(e,null!==(t=this.accountTypeValue)&&void 0!==t?t:void 0),done:!1}:this.requiresPostOptions()?{stage:"postOptions",options:this.paragon.getPostOptions(e),done:!1}:{stage:"done",done:!0}}}e.InstallFlow=O;const A=[{id:"clientId",title:"Client ID",type:p.SidebarInputType.ValueText,required:!0},{id:"clientSecret",title:"Client Secret",type:p.SidebarInputType.Password,required:!0}]},9892:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(3821);e.default=class{constructor(){this.eventListenersMap={},this.integrationStateCallbacks={}}subscribe(t,e){var n;if(this.assertEventType(t),"function"!=typeof e)throw new Error(`no listener is provided for ${t}`);return this.eventListenersMap={...this.eventListenersMap,[t]:[...null!==(n=this.eventListenersMap[t])&&void 0!==n?n:[],e]},()=>this.unsubscribe(t,e)}subscribeToIntegration(t,e){this.integrationStateCallbacks[t]={...e}}unsubscribe(t,e){var n,r;if(this.assertEventType(t),"function"!=typeof e)throw new Error("listener is required for unsubscription");const i=(null!==(n=this.eventListenersMap[t])&&void 0!==n?n:[]).length;return this.eventListenersMap={...this.eventListenersMap,[t]:(null!==(r=this.eventListenersMap[t])&&void 0!==r?r:[]).filter((t=>t!==e))},i>this.eventListenersMap[t].length}assertEventType(t){if(!Object.values(r.SDK_EVENT).includes(t))throw new Error(`${t} is not valid paragon event`)}emitSafe(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var i;(null!==(i=this.eventListenersMap[t])&&void 0!==i?i:[]).forEach((t=>{try{t(...n)}catch(t){console.error(t)}}))}emitError(t,e){this.invokeCallbackSafe(e,"onError",t)}invokeCallbackSafe(t,e){var n,r,i;try{for(var o=arguments.length,s=new Array(o>2?o-2:0),a=2;a<o;a++)s[a-2]=arguments[a];null===(r=null===(n=this.integrationStateCallbacks[t])||void 0===n?void 0:n[e])||void 0===r||r.call(n,...s)}catch(t){console.error(t)}finally{null===(i=this.integrationStateCallbacks[t])||void 0===i||delete i[e]}}triggerEvent(t,e){let{type:n,integrationId:i,integrationType:o,workflowId:s,workflowStateChange:a}=t;if(i&&o)switch(n){case r.SDK_EVENT.ON_INTEGRATION_INSTALL:{const t=[{integrationId:i,integrationType:o},e];this.invokeCallbackSafe(o,"onInstall",...t),this.emitSafe(r.SDK_EVENT.ON_INTEGRATION_INSTALL,...t);break}case r.SDK_EVENT.ON_INTEGRATION_UNINSTALL:{const t=[{integrationId:i,integrationType:o},e];this.invokeCallbackSafe(o,"onUninstall",...t),this.emitSafe(r.SDK_EVENT.ON_INTEGRATION_UNINSTALL,...t);break}case r.SDK_EVENT.ON_PORTAL_OPEN:{const t=[{integrationId:i,integrationType:o},e];this.invokeCallbackSafe(o,"onOpen",...t),this.emitSafe(r.SDK_EVENT.ON_PORTAL_OPEN,...t);break}case r.SDK_EVENT.ON_PORTAL_CLOSE:{const t=[{integrationId:i,integrationType:o},e];this.invokeCallbackSafe(o,"onClose",...t),this.emitSafe(r.SDK_EVENT.ON_PORTAL_CLOSE,...t);break}case r.SDK_EVENT.ON_WORKFLOW_CHANGE:{const t=[{integrationId:i,workflowId:s,workflowStateChange:a||{}},e];this.invokeCallbackSafe(o,"onWorkflowChange",...t),this.emitSafe(r.SDK_EVENT.ON_WORKFLOW_CHANGE,...t);break}default:throw new Error(`${n} is not valid event.`)}}}},3931:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PERSONA_META_HEADER=e.BYO_USER_PROFILE_ERROR_CODE=e.BYO_CREDENTIAL_VERIFICATION_ERROR=e.INSUFFICIENT_PERMISSION=e.ACTION_CUSTOM=void 0,e.ACTION_CUSTOM="custom",e.INSUFFICIENT_PERMISSION="7210",e.BYO_CREDENTIAL_VERIFICATION_ERROR="7003",e.BYO_USER_PROFILE_ERROR_CODE="0704",e.PERSONA_META_HEADER="X-Paragon-User-Metadata"},4059:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CredentialStatus=void 0,function(t){t.PENDING="PENDING",t.INVALID="INVALID",t.VALID="VALID"}(e.CredentialStatus||(e.CredentialStatus={}))},745:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AuthenticationScheme=void 0,function(t){t.BASIC="basic",t.OAUTH="oauth",t.OAUTH_CLIENT_CREDENTIAL="oauth_client_credential",t.SERVICE_ACCOUNT="service_account",t.OAUTH_APP="oauth_app",t.IMPERSONATED_APP="impersonated_app"}(e.AuthenticationScheme||(e.AuthenticationScheme={}))},1663:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generateSlugForIntegration=void 0,e.generateSlugForIntegration=function(t){if(!t.name)return;return`custom.${t.name?t.name.replace(/[\W_]+/g,"").trim().toLowerCase():void 0}`}},7343:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isCustomIntegrationTypeName=e.getIntegrationTypeName=void 0;const r=n(3931),i=n(1663);e.getIntegrationTypeName=function(t){if(t.type===r.ACTION_CUSTOM){if(t.customIntegration)return(0,i.generateSlugForIntegration)(t.customIntegration);throw new Error(`Custom integration details are missing from this integration: ${t.id}`)}return t.type},e.isCustomIntegrationTypeName=function(t){return t.startsWith("custom.")}},9845:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MicrosoftPicker=void 0;const r=n(3821),i=n(7473);class o extends i.BaseFilePicker{constructor(t,e){super(t,e),this.options=t,this.connectSDKInstance=e,this.accessToken="",this.baseUrl=""}getInstance(){return null}open(){var t,e;return this.dependencyStatus===r.FilePickerStatus.LOADED&&(null===(e=(t=this.options).onOpen)||void 0===e||e.call(t),this.launchPicker(this.getPickerOptions()),!0)}async initPicker(t,e){let n=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=r.FilePickerStatus.LOADING;const{selectedCredentialId:o,...s}=t||{};this.initOptions=s;const a=await this.connectSDKInstance.getIntegrationAccount(e,{includeAccountAuth:!0,selectedCredentialId:o});return this.accessToken=a.accountAuth[(null===(i=r.AUTH_TOKEN_ALLOWED_INTEGRATIONS[e])||void 0===i?void 0:i.accessTokenPath)||""],this.baseUrl=this.getUrl(a,e),this.initialiseDependencyPromise(),this.injectScript(n),this.dependenciesPromise}onScriptLoaded(){this.dependencyStatus=r.FilePickerStatus.LOADED,this.dependenciesPromise.resolve(!0)}onScriptError(){this.dependencyStatus=r.FilePickerStatus.FAILED,this.dependenciesPromise.reject(new Error("Failed to load dependencies"))}combinePaths(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.map((t=>t.replace(/^[/\\]+|[/\\]+$/g,""))).join("/").replace(/\\/g,"/")}async launchPicker(t){if(!this.accessToken)throw new Error("Access Token is not set! Please re-authenticate your account.");const e={sdk:"8.0",entry:t.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:t.pivots}},n=new URLSearchParams({filePicker:JSON.stringify(e)}).toString(),r=`${this.getPickerUrl(this.baseUrl)}?${n}`,i=window.open("","Picker","width=800,height=600,left=100,top=150");if(!i)throw new Error("Failed to open picker window.");const o=i.document.createElement("form");o.setAttribute("action",r),o.setAttribute("method","POST");const s=i.document.createElement("input");s.setAttribute("type","hidden"),s.setAttribute("name","access_token"),s.setAttribute("value",this.accessToken),o.appendChild(s),i.document.body.appendChild(o),o.submit(),this.setupMessageListener(i,e.messaging.channelId)}initializePort(t,e){t.addEventListener("message",(async n=>{const{type:r,data:i,id:o}=n.data;if("command"===r){const{command:n}=i;this.handlePickerCommand({command:n,id:o,items:i.items},e,t)}})),t.start(),t.postMessage({type:"activate"})}setupMessageListener(t,e){window.addEventListener("message",(n=>{var r;if(n.source===t&&(null===(r=n.data)||void 0===r?void 0:r.channelId)===e){const{type:e,data:r}=n.data;switch(e){case"initialize":const i=n.ports[0];this.initializePort(i,t);break;case"command":this.handlePickerCommand(r,t);break;default:console.warn("Unknown message type:",e)}}}))}handlePickerCommand(t,e,n){var r,i,o,s,a,l;const{command:c,id:u,items:d}=t;switch(c){case"close":null===(i=(r=this.options).onClose)||void 0===i||i.call(r),e.close();break;case"pick":null==n||n.postMessage({type:"result",id:u,data:{result:"success"}}),null===(s=(o=this.options).onFileSelect)||void 0===s||s.call(o,d),null===(l=(a=this.options).onClose)||void 0===l||l.call(a),e.close();break;default:null==n||n.postMessage({type:"error",id:u,data:{message:"Unsupported command",command:c}})}}}e.MicrosoftPicker=o},9008:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BoxFilePicker=void 0;const r=n(3821),i=n(7473),o={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 s extends i.BaseFilePicker{constructor(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(t,e),this.accessToken="",this.config={...o,...n}}getInstance(){var t,e;if(!this.instance){const n=window;if(!this.options.allowFolderSelect&&!(null===(t=n.Box)||void 0===t?void 0:t.FilePicker)||this.options.allowFolderSelect&&!(null===(e=n.Box)||void 0===e?void 0:e.FolderPicker))throw new Error("Box script is not loaded yet. Please wait for initialization to complete.");const r=new n.Box[this.options.allowFolderSelect?"FolderPicker":"FilePicker"]({container:`.${this.config.containerClass}`});if(!r)throw new Error(`Failed to create Box ${this.options.allowFolderSelect?"Folder":"File"}Picker instance`);this.instance=r,this.setupEventListeners()}return this.instance}setupEventListeners(){var t=this;if(!this.instance)return;const e={choose:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];var n,r;null===(r=(n=t.options).onFileSelect)||void 0===r||r.call(n,e),t.cleanup()},cancel:()=>{var t,e;null===(e=(t=this.options).onCancel)||void 0===e||e.call(t),this.cleanup()},close:()=>{var t,e;null===(e=(t=this.options).onClose)||void 0===e||e.call(t),this.cleanup()}};Object.entries(e).forEach((t=>{let[e,n]=t;var r;null===(r=this.instance)||void 0===r||r.addListener(e,n)}))}cleanup(){var t;this.instance&&(this.instance.removeAllListeners(),null===(t=document.querySelector(`.${this.config.containerClass}`))||void 0===t||t.remove())}createPickerContainer(){if(document.querySelector(`.${this.config.containerClass}`))return;const t=document.createElement("div");t.className=this.config.containerClass,Object.entries(this.config.containerStyles).forEach((e=>{let[n,r]=e;t.style[n]=r})),document.body.appendChild(t)}injectCSS(t){const e=document.createElement("link");e.rel="stylesheet",e.href=t,document.head.appendChild(e)}injectGlobalBtnContentCSS(){if(document.getElementById("global-btn-content-style"))return;const t=document.createElement("style");t.id="global-btn-content-style",t.innerHTML="\n .btn-content {\n display: flex !important;\n justify-content: center !important;\n }\n ",document.head.appendChild(t)}open(){var t,e,n;if(this.dependencyStatus===r.FilePickerStatus.LOADED)try{this.instance=void 0;const r=this.getInstance();if(r){const i={...this.config.pickerOptions,container:`.${this.config.containerClass}`,maxSelectable:this.options.allowMultiSelect?void 0:1,extensions:this.options.allowedTypes,canSelectFolder:this.options.allowFolderSelect,...(null===(t=this.options.integrationOptions)||void 0===t?void 0:t.box)||{}};if(this.createPickerContainer(),this.initOptions.folderId)return r.show(this.initOptions.folderId,this.accessToken,i),null===(n=(e=this.options).onOpen)||void 0===n||n.call(e),!0}}catch(t){return!1}return!1}async init(t){this.dependencyStatus=r.FilePickerStatus.LOADING;const{selectedCredentialId:e,...n}=t||{};await this.validateInitOptions(n,[["folderId","Folder ID"]]),this.initOptions={...n};const i=await this.connectSDKInstance.getIntegrationAccount("box",{includeAccountAuth:!0,selectedCredentialId:e}),{accessTokenPath:o=""}=r.AUTH_TOKEN_ALLOWED_INTEGRATIONS.box;return this.accessToken=i.accountAuth[o],this.initialiseDependencyPromise(),this.injectCSS(this.config.cssUrl),this.injectGlobalBtnContentCSS(),this.injectScript(this.config.scriptUrl),this.dependenciesPromise}async launch(){this.dependencyStatus!==r.FilePickerStatus.LOADED&&await this.init(this.initOptions),this.open()}onScriptLoaded(){this.dependencyStatus=r.FilePickerStatus.LOADED,this.instance=void 0,this.dependenciesPromise.resolve(!0)}onScriptError(){this.dependencyStatus=r.FilePickerStatus.FAILED,this.dependenciesPromise.reject(new Error("Failed to load Box script"))}}e.BoxFilePicker=s},9950:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GoogleDriveFilePicker=void 0;const r=n(3821),i=n(7473);class o extends i.BaseFilePicker{constructor(t,e){super(t,e),this.accessToken=""}get google(){return window.google}getInstance(){var t;return null!==(t=this.instance)&&void 0!==t?t:null}open(){var t,e;return!(this.dependencyStatus!==r.FilePickerStatus.LOADED||!this.instance)&&(this.instance.setVisible(!0),null===(e=(t=this.options).onOpen)||void 0===e||e.call(t),!0)}async init(t){this.dependencyStatus=r.FilePickerStatus.LOADING;const{selectedCredentialId:e,...n}=t||{};await this.validateInitOptions(n,[["developerKey","developer key"]]),this.initOptions={...n};const i=await this.connectSDKInstance.getIntegrationAccount("googledrive",{includeAccountAuth:!0,selectedCredentialId:e}),{accessTokenPath:o=""}=r.AUTH_TOKEN_ALLOWED_INTEGRATIONS.googledrive;return this.accessToken=i.accountAuth[o],this.initialiseDependencyPromise(),this.injectScript("https://apis.google.com/js/api.js"),this.dependenciesPromise}onScriptLoaded(){this.dependencyStatus=r.FilePickerStatus.LOADED,window.gapi.load("picker",this.onPickerLoaded.bind(this))}onScriptError(){this.dependencyStatus=r.FilePickerStatus.FAILED,this.dependenciesPromise.reject(new Error("Not able to load dependencies"))}onPickerLoaded(){var t,e,n,r,i;const o=new this.google.picker.PickerBuilder,s=new this.google.picker.DocsView;if((null===(t=this.initOptions)||void 0===t?void 0:t.appId)&&o.setAppId(this.initOptions.appId),this.options.allowMultiSelect&&o.enableFeature(this.google.picker.Feature.MULTISELECT_ENABLED),this.options.allowFolderSelect&&(s.setIncludeFolders(!0),s.setSelectFolderEnabled(!0)),this.options.allowedTypes&&this.options.allowedTypes.length>0&&o.setSelectableMimeTypes(this.options.allowedTypes.join(",")),(null===(n=null===(e=this.options.integrationOptions)||void 0===e?void 0:e.googledrive)||void 0===n?void 0:n.viewMode)&&s.setMode(this.options.integrationOptions.googledrive.viewMode),(null===(i=null===(r=this.options.integrationOptions)||void 0===r?void 0:r.googledrive)||void 0===i?void 0:i.includeFolders)&&s.setIncludeFolders(!0),!this.initOptions.developerKey)throw new Error("Please provide a valid developer key");const a=o.addView(s).setOAuthToken(this.accessToken).setDeveloperKey(this.initOptions.developerKey).setCallback(this.pickerCallback.bind(this));this.initOptions.appId&&a.setAppId(this.initOptions.appId),this.instance=a.build(),this.dependenciesPromise.resolve(!0)}pickerCallback(t){var e,n,r,i,o,s;const{action:a,...l}=t;switch(a){case this.google.picker.Action.PICKED:null===(n=(e=this.options).onFileSelect)||void 0===n||n.call(e,l),null===(i=(r=this.options).onClose)||void 0===i||i.call(r);break;case this.google.picker.Action.CANCEL:null===(s=(o=this.options).onCancel)||void 0===s||s.call(o)}}}e.GoogleDriveFilePicker=o},1698:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(9008),i=n(9950),o=n(6128),s=n(8737);e.default={BoxFilePicker:r.BoxFilePicker,GoogleDriveFilePicker:i.GoogleDriveFilePicker,OneDriveFilePicker:o.OneDriveFilePicker,SharepointFilePicker:s.SharepointFilePicker}},6128:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OneDriveFilePicker=void 0;const r=n(3821),i=n(9845);class o extends i.MicrosoftPicker{constructor(){super(...arguments),this.integrationName="onedrive",this.personalAccountUrl="https://onedrive.live.com"}async init(t){return super.initPicker(t,this.integrationName)}getPickerUrl(t){return t?t.includes(this.personalAccountUrl)?`${t}/picker`:this.combinePaths(t,"_layouts/15/FilePicker.aspx"):`${this.personalAccountUrl}/picker`}getIntegrationName(){return this.integrationName}getUrl(t,e){return t.accountAuth[r.AUTH_TOKEN_ALLOWED_INTEGRATIONS[e].domain||""]}getPickerOptions(){return{entry:{oneDrive:{files:{fallbackToRoot:!0}}},pivots:{oneDrive:!0,recent:!0,shared:!0}}}}e.OneDriveFilePicker=o},8737:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SharepointFilePicker=void 0;const r=n(8321),i=n(9845);class o extends i.MicrosoftPicker{constructor(){super(...arguments),this.integrationName="sharepoint"}async init(t){return super.initPicker(t,this.integrationName)}getIntegrationName(){return this.integrationName}getPickerUrl(t){return this.combinePaths(t,"_layouts/15/FilePicker.aspx")}getUrl(t){var e;return(0,r.sanitizeUrl)(null===(e=t.providerData)||void 0===e?void 0:e.webUrl)}getPickerOptions(){return{entry:{sharePoint:{byPath:{list:`${this.baseUrl}/Shared Documents`,fallbackToRoot:!0}}},pivots:{shared:!0,oneDrive:!1,sharedLibraries:!0,site:!0}}}}e.SharepointFilePicker=o},7473:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BaseFilePicker=void 0;const r=n(2643),i=n(572);e.BaseFilePicker=class{constructor(t,e){this.options=t,this.connectSDKInstance=e}initialiseDependencyPromise(){this.dependenciesPromise=new i.DeferredPromise}getInstance(){return this.instance}injectScript(t){if(this.checkIfScriptLoaded(t))this.onScriptLoaded();else{const e=document.createElement("script");e.src=t,e.async=!0,e.id=t,e.onload=this.onScriptLoaded.bind(this),e.onerror=this.onScriptError.bind(this),document.body.appendChild(e)}}checkIfScriptLoaded(t){const e=document.getElementsByTagName("script");for(let n=0;n<e.length;n++)if(e[n].getAttribute("src")==t)return!0;return!1}async validateInitOptions(t,e){for(const[n,i]of e)if(!t||(0,r.isStringEmpty)(t[n]))throw new Error(`Please provide a valid ${i}`);return!0}}},4731:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.buildExternalFilePickerInstance=void 0;const r=n(655).__importDefault(n(1698));class i{constructor(t,e,n){const r=this.createFilePicker(t,e,n);this.open=this.open.bind(r),this.init=this.init.bind(r),this.getInstance=this.getInstance.bind(r)}createFilePicker(t,e,n){const i={box:r.default.BoxFilePicker,googledrive:r.default.GoogleDriveFilePicker,onedrive:r.default.OneDriveFilePicker,sharepoint:r.default.SharepointFilePicker}[t];if(!i)throw new Error(`${t}'s file picker is not supported`);return new i(e,n)}open(){return this.open()}init(t){return this.init(t)}getInstance(){return this.getInstance()}}e.default=i;e.buildExternalFilePickerInstance=t=>function(e,n){if(!t.getUser().authenticated)throw new Error("Authentication is required");if(!e)throw new Error("Missing argument: Integration type is required");return t.validateAction(e),new i(e,n,t)}},7050:function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.buildExternalFilePickerInstance=e.ExternalFilePicker=void 0;var i=n(4731);Object.defineProperty(e,"ExternalFilePicker",{enumerable:!0,get:function(){return r(i).default}}),Object.defineProperty(e,"buildExternalFilePickerInstance",{enumerable:!0,get:function(){return i.buildExternalFilePickerInstance}})},2643:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.findSelectedAccountType=e.isStringEmpty=e.getActionStateForCredentialDelete=e.stripUndefinedAndNull=e.parseKeyedSource=void 0;const r=n(4059);e.parseKeyedSource=function(t){return t&&(null==t?void 0:t.length)?Object.fromEntries(t.map((t=>[t.key,"VALUE"===t.source.type?t.source.value:void 0]))):{}},e.stripUndefinedAndNull=function t(e){const n={};return Object.keys(e).forEach((r=>{var i;(i=e[r])&&"object"==typeof i&&!Array.isArray(i)?n[r]=t(e[r]):void 0!==e[r]&&null!==e[r]&&(n[r]=e[r])})),n};e.getActionStateForCredentialDelete=(t,e)=>{var n,i;const o=(null!==(n=null==e?void 0:e.allCredentials)&&void 0!==n?n:[]).filter((e=>e.id!==t)),s=(null!==(i=null==e?void 0:e.allConfigurations)&&void 0!==i?i:[]).filter((e=>e.connectCredentialId!==t));if(0===o.length)return{enabled:!1,workflowSettings:{},allCredentials:[],allConfigurations:[]};{const t=o[0];return{...e,credentialStatus:t.status,enabled:t.status===r.CredentialStatus.VALID,credentialId:t.id,providerId:t.providerId,providerData:t.providerData,allCredentials:o,allConfigurations:s}}};e.isStringEmpty=t=>!t||"string"==typeof t&&!t.trim();e.findSelectedAccountType=function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(e)return t.find((t=>{let{id:n}=t;return n===e}));if(1===n.length)return t.find((t=>{let{id:e}=t;return n.includes(e)}));if(!e&&!n.length&&Array.isArray(t)&&2===t.length){const[e,n]=t;return"default"===e.id&&"user-configured-oauth"===n.id?e:void 0}}},4429:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.startOAuthFlow=e.MAX_POLL_DURATION=e.CREDENTIAL_POLL_INTERVAL=void 0;const r=n(3931),i=n(7343),o=n(1935),s=n(2643);e.CREDENTIAL_POLL_INTERVAL=3e3,e.MAX_POLL_DURATION=6e4;e.startOAuthFlow=(t,e)=>{let{context:n,integration:a,endUserSuppliedValues:l={},authParams:c,isPreviewMode:u=!1,installOptions:d={}}=t;var h;const f=(0,i.getIntegrationTypeName)(a);if(!f)return;const p=c?(0,s.parseKeyedSource)(c):{};if(!n.user.authenticated)throw new o.UserNotAuthenticatedError;const g=(0,s.stripUndefinedAndNull)({action:f&&(0,i.isCustomIntegrationTypeName)(f)?r.ACTION_CUSTOM:f,endUserSuppliedValues:JSON.stringify(l),parameters:JSON.stringify(p),userToken:n.user.token,integrationId:a.id,redirectUrl:null===(h=n.endUserIntegrationConfig)||void 0===h?void 0:h.overrideRedirectUrl,originForPostMessage:window.location.origin,isPreviewMode:u,installOptions:JSON.stringify(d),oauthMetaKeyId:e}),v=`${n.environments.ZEUS_PUBLIC_URL}/projects/${n.projectId}/sdk/actions/oauth-nonce?action=${f}&integrationId=${a.id}&originForPostMessage=${window.location.origin}${n.user.token?`&userToken=${n.user.token}`:""}`,y=(async(t,e)=>t.user.authenticated?fetch(`${t.environments.ZEUS_PUBLIC_URL}/v2/projects/${t.projectId}/sdk/actions/build-oauth?${e}`,{method:"GET",headers:{"Content-Type":"application/json",...t.user.token?{Authorization:`Bearer ${t.user.token}`}:{}}}):Promise.reject("User is not authenticated"))(n,new URLSearchParams(g).toString()),E=window.open(v,void 0,"width=500,height=600,left=100,top=150"),I=function(t,e){return function n(r){"oauth-nonce-loaded"===r.data.type&&t.then((async t=>{if(!t.ok){const e=await t.json();return Promise.reject(new Error(e.message))}return t.json()})).then((t=>{if(!e)throw new o.OAuthBlockedError;e.location.href=t.redirectUrl,window.removeEventListener("message",n)})).catch((t=>{console.error("Build Oauth URL fetch failure",t.message)}))}}(y,E);return window.addEventListener("message",I),E}},3056:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.paragon=e.connectSingleton=void 0;const r=n(655),i=r.__importDefault(n(773)),o=n(7050);r.__exportStar(n(3821),e),e.connectSingleton=new i.default,e.paragon={_loadCustomDropdownOptions:e.connectSingleton._loadCustomDropdownOptions.bind(e.connectSingleton),_oauthCallback:e.connectSingleton._oauthCallback.bind(e.connectSingleton),_oauthErrorCallback:e.connectSingleton._oauthErrorCallback.bind(e.connectSingleton),authenticate:e.connectSingleton.authenticate.bind(e.connectSingleton),closePortal:e.connectSingleton.closePortal.bind(e.connectSingleton),completeInstall:e.connectSingleton.completeInstall.bind(e.connectSingleton),configureGlobal:e.connectSingleton.configureGlobal.bind(e.connectSingleton),connect:e.connectSingleton.connect.bind(e.connectSingleton),connectAction:e.connectSingleton.connectAction.bind(e.connectSingleton),getCustomWebhookUserManualUrl:e.connectSingleton.getCustomWebhookUserManualUrl.bind(e.connectSingleton),createConfiguration:e.connectSingleton.createConfiguration.bind(e.connectSingleton),destroyConfiguration:e.connectSingleton.destroyConfiguration.bind(e.connectSingleton),disableWorkflow:e.connectSingleton.disableWorkflow.bind(e.connectSingleton),enableWorkflow:e.connectSingleton.enableWorkflow.bind(e.connectSingleton),event:e.connectSingleton.event.bind(e.connectSingleton),getIntegrationAccount:e.connectSingleton.getIntegrationAccount.bind(e.connectSingleton),getIntegrationMetadata:e.connectSingleton.getIntegrationMetadata.bind(e.connectSingleton),getUser:e.connectSingleton.getUser.bind(e.connectSingleton),installIntegration:e.connectSingleton.installIntegration.bind(e.connectSingleton),request:e.connectSingleton.request.bind(e.connectSingleton),setUserMetadata:e.connectSingleton.setUserMetadata.bind(e.connectSingleton),subscribe:e.connectSingleton.subscribe.bind(e.connectSingleton),uninstallIntegration:e.connectSingleton.uninstallIntegration.bind(e.connectSingleton),unsubscribe:e.connectSingleton.unsubscribe.bind(e.connectSingleton),updateConfiguration:e.connectSingleton.updateConfiguration.bind(e.connectSingleton),workflow:e.connectSingleton.workflow.bind(e.connectSingleton),ExternalFilePicker:(0,o.buildExternalFilePickerInstance)(e.connectSingleton),getIntegrationConfig:e.connectSingleton.getIntegrationConfig.bind(e.connectSingleton),updateIntegrationUserSettings:e.connectSingleton.updateIntegrationUserSettings.bind(e.connectSingleton),updateWorkflowUserSettings:e.connectSingleton.updateWorkflowUserSettings.bind(e.connectSingleton),updateWorkflowState:e.connectSingleton.updateWorkflowState.bind(e.connectSingleton),setHeadless:e.connectSingleton.setHeadless.bind(e.connectSingleton),getIntegrationId:e.connectSingleton.getIntegrationId.bind(e.connectSingleton),getAccountTypeOptions:e.connectSingleton.getAccountTypeOptions.bind(e.connectSingleton),getPreOptions:e.connectSingleton.getPreOptions.bind(e.connectSingleton),getPostOptions:e.connectSingleton.getPostOptions.bind(e.connectSingleton),startOAuthFlow:e.connectSingleton.startOAuthFlow.bind(e.connectSingleton),installFlow:e.connectSingleton.installFlow,getFieldOptions:e.connectSingleton.getFieldOptions.bind(e.connectSingleton),getDataSourceOptions:e.connectSingleton.getDataSourceOptions.bind(e.connectSingleton)},e.default=i.default},9636:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.cloneDeep=void 0;const r=n(655).__importDefault(n(738));e.cloneDeep=function(t){return(0,r.default)(t)}},2992:(t,e)=>{"use strict";var n,r,i;Object.defineProperty(e,"__esModule",{value:!0}),e.AUTH_TOKEN_ALLOWED_INTEGRATIONS=e.overrideActionAlias=e.TokenType=e.VariableInputType=e.SidebarInputType=void 0,function(t){t.Auth="AUTH",t.Enum="ENUM",t.DynamicEnum="DYNAMIC_ENUM",t.Intent="INTENT",t.Text="TEXT",t.TextArea="TEXTAREA",t.ValueText="TEXT_NO_VARS",t.ValueTextArea="TEXTAREA_NO_VARS",t.Code="CODE",t.ActionButton="ACTION_BUTTON",t.Conditional="CONDITIONAL",t.CustomDropdown="CUSTOM_DROPDOWN",t.DynamicConditional="DYNAMIC_CONDITIONAL",t.NestedList="NESTED_LIST",t.File="FILE",t.EditableDynamicEnum="EDITABLE_DYNAMIC_ENUM",t.EditableEnum="EDITABLE_ENUM",t.BooleanInput="BOOLEAN_INPUT",t.UserSuppliedCredential="USER_SUPPLIED_CREDENTIAL",t.NativeDynamicEnumInput="NATIVE_DYNAMIC_INPUT",t.TimeConstraintInput="TIME_CONSTRAINT_INPUT",t.LinesListInput="LinesListInput",t.LinesListDynamicInput="LinesListDynamicInput",t.Number="NUMBER",t.Email="EMAIL",t.URL="URL",t.EnumTextAreaPairInput="EnumTextAreaPairInput",t.FieldMapper="FIELD_MAPPER",t.ComboInput="COMBO_INPUT",t.Password="PASSWORD",t.Switch="SWITCH",t.DynamicComboInput="DYNAMIC_COMBO_INPUT",t.CopyableButtonInput="COPYABLE_BUTTON_INPUT",t.Permission="PERMISSION"}(e.SidebarInputType||(e.SidebarInputType={})),function(t){t.MultiSelect="multi",t.String="string",t.Dropdown="dropdown",t.MultiSelectCheckbox="multiCheckbox",t.Number="number"}(e.VariableInputType||(e.VariableInputType={})),function(t){t.ACCESS_TOKEN="ACCESS_TOKEN",t.REFRESH_TOKEN="REFRESH_TOKEN",t.BOT_TOKEN="BOT_TOKEN",t.KLAVIYO_API_KEY="KLAVIYO_API_KEY",t.MARKETO_CLIENT_ID="MARKETO_CLIENT_ID",t.MARKETO_CLIENT_SECRET="MARKETO_CLIENT_SECRETI",t.MARKETO_ENDPOINT="MARKETO_ENDPOINT",t.MARKETO_IDENTITY="MARKETO_IDENTITY",t.MONDAY_API_TOKEN="MONDAY_API_TOKEN",t.ORACLE_CLOUD_URL="ORACLE_CLOUD_URL",t.ORACLE_PASSWORD="ORACLE_PASSWORD",t.ORACLE_USERNAME="ORACLE_USERNAME",t.SAGE_INTACCT_COMPANY_ID="SAGE_INTACCT_COMPANY_ID",t.SAGE_INTACCT_USER_ID="SAGE_INTACCT_USER_ID",t.SAGE_INTACCT_USER_PASSWORD="SAGE_INTACCT_USER_PASSWORD",t.SAILTHRU_COMPANY_KEY="SAILTHRU_COMPANY_KEY",t.SAILTHRU_COMPANY_SECRET="SAILTHRU_COMPANY_SECRET",t.SERVICENOW_PASSWORD="SERVICENOW_PASSWORD",t.SERVICENOW_SUBDOMAIN="SERVICENOW_SUBDOMAIN",t.SERVICENOW_USERNAME="SERVICENOW_USERNAME",t.TABLEAU_PERSONAL_ACCESS_TOKEN_NAME="TABLEAU_PERSONAL_ACCESS_TOKEN_NAME",t.TABLEAU_PERSONAL_ACCESS_TOKEN_SECRET="TABLEAU_PERSONAL_ACCESS_TOKEN_SECRET",t.TABLEAU_SERVER_NAME="TABLEAU_SERVER_NAME",t.TABLEAU_SITE_ID="TABLEAU_SITE_ID",t.TRELLO_API_KEY="TRELLO_API_KEY",t.TRELLO_API_TOKEN="TRELLO_API_TOKEN",t.WOOCOMMERCE_CONSUMER_KEY="WOOCOMMERCE_CONSUMER_KEY",t.WOOCOMMERCE_CONSUMER_SECRET="WOOCOMMERCE_CONSUMER_SECRET",t.WOOCOMMERCE_STORE_DOMAIN="WOOCOMMERCE_STORE_DOMAIN",t.WORKABLE_API_ACCESS_TOKEN="WORKABLE_API_ACCESS_TOKEN",t.WORKABLE_ACCOUNT_SUBDOMAIN="WORKABLE_ACCOUNT_SUBDOMAIN",t.ZOHO_CRM_ACCOUNTS_SERVER="ZOHO_CRM_ACCOUNTS_SERVER",t.ZOHO_CRM_API_DOMAIN="ZOHO_CRM_API_DOMAIN"}(e.TokenType||(e.TokenType={})),function(t){t.INFO="INFO",t.ERROR="ERROR",t.SUCCESS="SUCCESS"}(n||(n={})),function(t){t.NONE="NONE",t.RE_AUTHENTICATE="RE_AUTHENTICATE",t.ALERT="ALERT",t.DISPATCH="DISPATCH"}(r||(r={})),function(t){t.DYNAMIC="DYNAMIC_DATA_SOURCE",t.STATIC_ENUM="STATIC_ENUM_DATA_SOURCE",t.FIELD_MAPPER="FIELD_MAPPER_DATA_SOURCE",t.COMBO_INPUT="COMBO_INPUT_DATA_SOURCE",t.DYNAMIC_COMBO_INPUT="DYNAMIC_COMBO_INPUT_DATA_SOURCE"}(i||(i={})),e.overrideActionAlias={"monday.com":"monday","wordpress.com":"wordpress"},e.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:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONNECT_PLAN_FEATURE_MAP=void 0;const r=n(471);e.CONNECT_PLAN_FEATURE_MAP={[r.BillingPlan.ConnectBasic]:[],[r.BillingPlan.ConnectPro]:[r.ConnectAddOn.CustomIntegrationBuilder,r.ConnectAddOn.HeadlessConnectPortal,r.ConnectAddOn.Monitoring,r.ConnectAddOn.UserMetadata,r.ConnectAddOn.WhiteLabeling],[r.BillingPlan.ConnectEnterprise]:[r.ConnectAddOn.CustomIntegrationBuilder,r.ConnectAddOn.DynamicFieldMapper,r.ConnectAddOn.HeadlessConnectPortal,r.ConnectAddOn.TaskHistoryAPI,r.ConnectAddOn.Monitoring,r.ConnectAddOn.RoleBasedAccessControl,r.ConnectAddOn.UserMetadata,r.ConnectAddOn.WhiteLabeling,r.ConnectAddOn.WorkflowPermission]}},1935:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SDK_VERSION_HEADER=e.SELECTED_CREDENTIAL_CONFIG_ID_HEADER=e.SELECTED_CREDENTIAL_ID_HEADER=e.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS=e.CredentialStatus=void 0;const r=n(655),i=n(2992);var o=n(4059);Object.defineProperty(e,"CredentialStatus",{enumerable:!0,get:function(){return o.CredentialStatus}}),r.__exportStar(n(2460),e);i.SidebarInputType.ValueText,i.SidebarInputType.DynamicEnum,i.SidebarInputType.Enum,i.SidebarInputType.Number,i.SidebarInputType.Email,i.SidebarInputType.URL,i.SidebarInputType.FieldMapper,i.SidebarInputType.BooleanInput,i.SidebarInputType.ComboInput,i.SidebarInputType.Password,i.SidebarInputType.Switch,i.SidebarInputType.ValueTextArea,i.SidebarInputType.CustomDropdown,i.SidebarInputType.DynamicComboInput,i.SidebarInputType.FieldMapper,i.SidebarInputType.CopyableButtonInput,i.SidebarInputType.Permission,i.SidebarInputType.File;e.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS="auto",e.SELECTED_CREDENTIAL_ID_HEADER="X-Paragon-Credential",e.SELECTED_CREDENTIAL_CONFIG_ID_HEADER="X-Paragon-Configuration-Id",e.SDK_VERSION_HEADER="X-Paragon-SDK-Version"},9977:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},914:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PLATFORM_ENV=e.NODE_ENV=void 0,function(t){t.PRODUCTION="production",t.DEVELOPMENT="development",t.TEST="test"}(e.NODE_ENV||(e.NODE_ENV={})),function(t){t.PRODUCTION="production",t.PRODUCTION_MIRROR_1="p-m1",t.STAGING="staging",t.STAGING_MIRROR_1="s-m1",t.DEVELOPMENT="dev",t.TEST="test",t.SANDBOX="sandbox",t.RELEASE="release",t.ENTERPRISE="enterprise"}(e.PLATFORM_ENV||(e.PLATFORM_ENV={}))},2460:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getConnectSDKError=e.OAuthTimeoutError=e.OAuthBlockedError=e.HeadlessModeNotEnabledError=e.IntegrationNotInstalledError=e.IntegrationNotFoundError=e.NoActiveInstallFlowError=e.UserNotAuthenticatedError=e.BaseSDKError=void 0;class n extends Error{constructor(t){super(t.message),this.name=t.name,this.meta="meta"in t?t.meta:null}}e.BaseSDKError=n;e.UserNotAuthenticatedError=class extends n{constructor(){super({name:"UserNotAuthenticatedError",message:"User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK."})}};e.NoActiveInstallFlowError=class extends n{constructor(){super({name:"NoActiveInstallFlowError",message:"No active install flow, make sure you call installFlow.start(<integrationName>, ...args) before calling any other method"})}};e.IntegrationNotFoundError=class extends n{constructor(t){super({name:"IntegrationNotFoundError",message:`Integration with name ${t} not found`,meta:{integrationName:t}})}};e.IntegrationNotInstalledError=class extends n{constructor(t){super({name:"IntegrationNotInstalledError",message:`Integration "${t}" is not installed.`,meta:{integrationName:t}}),this.integrationName=t}};e.HeadlessModeNotEnabledError=class extends n{constructor(){super({name:"HeadlessModeNotEnabledError",message:"Headless mode is not enabled. Make sure you call `paragon.setHeadless(true)` as early as possible in your code."})}};e.OAuthBlockedError=class extends n{constructor(){super({name:"OAuthBlockedError",message:"Popup was blocked by the browser."})}};e.OAuthTimeoutError=class extends n{constructor(){super({name:"OAuthTimeoutError",message:"OAuth timeout"})}},e.getConnectSDKError=function(t){return t instanceof n?{name:t.name,message:t.message,meta:t.meta}:{name:"UnknownError",message:t instanceof Error?t.message:"An unknown error occurred",originalError:t}}},8065:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},3821:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(655);r.__exportStar(n(2992),e),r.__exportStar(n(9034),e),r.__exportStar(n(1935),e),r.__exportStar(n(9977),e),r.__exportStar(n(914),e),r.__exportStar(n(8065),e),r.__exportStar(n(9835),e),r.__exportStar(n(7750),e),r.__exportStar(n(471),e)},9835:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.DataType=void 0,function(t){t.STRING="STRING",t.NUMBER="NUMBER",t.DATE="DATE",t.BOOLEAN="BOOLEAN",t.EMAIL="EMAIL",t.OBJECT="OBJECT",t.ARRAY="ARRAY",t.ANY="ANY",t.FILE="FILE",t.NON_DECIMAL="NON_DECIMAL"}(e.DataType||(e.DataType={})),function(t){t.None="$none",t.StringContains="$stringContains",t.StringDoesNotContain="$stringDoesNotContain",t.StringExactlyMatches="$stringExactlyMatches",t.StringDoesNotExactlyMatch="$stringDoesNotExactlyMatch",t.StringIsIn="$stringIsIn",t.StringIsNotIn="$stringIsNotIn",t.StringStartsWith="$stringStartsWith",t.StringDoesNotStartWith="$stringDoesNotStartWith",t.StringEndsWith="$stringEndsWith",t.StringDoesNotEndWith="$stringDoesNotEndWith",t.NumberGreaterThan="$numberGreaterThan",t.NumberLessThan="$numberLessThan",t.NumberEquals="$numberEquals",t.NumberDoesNotEqual="$numberDoesNotEqual",t.NumberLessThanOrEqualTo="$numberLessThanOrEqualTo",t.NumberGreaterThanOrEqualTo="$numberGreaterThanOrEqualTo",t.DateTimeAfter="$dateTimeAfter",t.DateTimeBefore="$dateTimeBefore",t.DateTimeEquals="$dateTimeEquals",t.BooleanTrue="$booleanTrue",t.BooleanFalse="$booleanFalse",t.IsNotNull="$exists",t.IsNull="$doesNotExist",t.Exists="$isNotUndefinedOrNull",t.DoesNotExist="$isUndefinedOrNull",t.ArrayIsIn="$arrayIsIn",t.ArrayIsNotIn="$arrayIsNotIn",t.ArrayIsEmpty="$arrayIsEmpty",t.ArrayIsNotEmpty="$arrayIsNotEmpty",t.StringGreaterThan="$stringGreaterThan",t.StringLessThan="$stringLessThan"}(n||(n={}))},7750:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.FilePickerStatus=e.DocumentLoadingState=e.SDK_EVENT=e.ModalView=e.DynamicFieldMappingLoaderType=void 0,function(t){t.OBJECT_TYPES="objectTypes",t.INTEGRATION_FIELDS="integrationFields"}(e.DynamicFieldMappingLoaderType||(e.DynamicFieldMappingLoaderType={})),function(t){t.OVERVIEW="overview",t.CONFIGURATION="configuration"}(e.ModalView||(e.ModalView={})),function(t){t.ON_INTEGRATION_INSTALL="onIntegrationInstall",t.ON_INTEGRATION_UNINSTALL="onIntegrationUninstall",t.ON_WORKFLOW_CHANGE="onWorkflowChange",t.ON_PORTAL_OPEN="onPortalOpen",t.ON_PORTAL_CLOSE="onPortalClose"}(e.SDK_EVENT||(e.SDK_EVENT={})),function(t){t.LOADING="loading",t.INTERACTIVE="interactive",t.COMPLETE="complete"}(e.DocumentLoadingState||(e.DocumentLoadingState={})),function(t){t.LOADING="loading",t.FAILED="failed",t.LOADED="loaded"}(e.FilePickerStatus||(e.FilePickerStatus={}))},471:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ConnectAddOn=e.BillingPlan=void 0,function(t){t.ClassicFree="free",t.ClassicStarter="starter",t.ClassicBusiness="business",t.ClassicPremium="premium",t.ClassicEnterprise="enterprise",t.ConnectTrial="connect_trial",t.ConnectBasic="basic",t.ConnectPro="pro",t.ConnectEnterprise="connect_enterprise"}(e.BillingPlan||(e.BillingPlan={})),function(t){t.CustomIntegrationBuilder="byo",t.DynamicFieldMapper="dfm",t.HeadlessConnectPortal="headless-cp",t.TaskHistoryAPI="th-api",t.Monitoring="monitoring",t.RoleBasedAccessControl="rbac",t.UserMetadata="user-metadata",t.WhiteLabeling="whitelabel",t.WorkflowPermission="workflow-permissions"}(e.ConnectAddOn||(e.ConnectAddOn={}))},3158:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getHeadersForUserMeta=e.sanitizeExternalConfigId=e.getAssetUrl=void 0;const r=n(3931),i=n(3821);e.getAssetUrl=t=>{let{CDN_PUBLIC_URL:e,DASHBOARD_PUBLIC_URL:n,VERSION:r,PLATFORM_ENV:o,NODE_ENV:s}=t;return e&&s===i.NODE_ENV.PRODUCTION&&o!==i.PLATFORM_ENV.ENTERPRISE?`${e}/${r}/dashboard/public`:n},e.sanitizeExternalConfigId=function(t){if(t.startsWith("ext:")){return(t.split("ext:").pop()||"").trim()}return t.trim()};e.getHeadersForUserMeta=t=>({...t?{[r.PERSONA_META_HEADER]:JSON.stringify(t)}:{}})},4846:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hash=void 0;const r=n(3715);e.hash=function(t){return null==t?t:(0,r.sha256)().update(t).digest("hex").substr(0,10)}},572:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.tryUntil=e.isUUID=e.uuidPattern=e.sleep=e.generateMatrix=e.DeferredPromise=void 0;function n(t){return new Promise((e=>setTimeout(e,t)))}e.DeferredPromise=class{get state(){return this._state}constructor(){this._state="pending",this._promise=new Promise(((t,e)=>{this._resolve=t,this._reject=e}))}then(t,e){return this._promise.then(t,e)}catch(t){return this._promise.catch(t)}resolve(t){this._resolve(t),this._state="fulfilled"}reject(t){this._reject(t),this._state="rejected"}finally(t){return null==t||t(),this._promise}},Symbol.toStringTag,e.generateMatrix=function(t,e){const n=Object.keys(t);if(n.reduce(((e,n)=>e+t[n].length),0)&&n.length)for(const e of n)t[e].length||t[e].push(void 0);const r=Object.entries(t).reduce(((t,e)=>{let[,n]=e;return t.length?t.reduce(((t,e)=>(n.forEach((n=>{const r=e.slice();r.push(n),t.push(r)}),[]),t)),[]):n.map((t=>[t]))}),[]).reduce(((t,e)=>{const r=e.reduce(((t,e,r)=>({...t,[n[r]]:e})),{});return[...t,r]}),[]);return e?r.slice(-1*e):r},e.sleep=n,e.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,e.isUUID=function(t){return"string"==typeof t&&e.uuidPattern.test(t)},e.tryUntil=async function(t,e,r){let i=0,o=!0;for(;o;){i+=1;let s=null,a=null;try{s=await t()}catch(t){a=t}if(o=await e(s,a,i),!o){if(a)throw a;return s}{const t="number"==typeof r?r:r(i);await n(t)}}throw new Error("Method unable to run: invalid retries.")}},8321:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.errorMessageParser=e.isIntegrationError=e.ProxyRequestError=e.getErrorMessage=e.getServiceUrl=e.sanitizeUrl=e.isValidUrl=void 0;function n(t){return t?t.match(/^[a-zA-Z]+:\/\//)?t:`https://${t}`:t}function r(t){return Array.isArray(t)?t.flatMap((t=>[t,r(t.children||[])].flatMap((t=>"string"==typeof t?t:r(t))))).filter((t=>t)).join(", "):Object.values(t.constraints||{}).join(", ")}e.isValidUrl=t=>{const e=n(t);try{return new globalThis.URL(e),!0}catch(t){return!1}},e.sanitizeUrl=n,e.getServiceUrl=function(t,e){return`https://${t}${`.${e}`}`},e.getErrorMessage=async function(t,n){var i,o;const s=null===(i=t.headers)||void 0===i?void 0:i.get("content-type"),a=s&&s.includes("application/json")?await t.json():null;let l;return l=a&&(0,e.isIntegrationError)(a.meta)?JSON.stringify(a.meta):a&&"string"==typeof a.message?a.message:a&&400===t.status&&Array.isArray(a.message)?r(a.message):a?JSON.stringify(a):await(null===(o=t.text)||void 0===o?void 0:o.call(t)),n?{message:l,response:a||t}:l};class i extends Error{constructor(t,e){super(t),this.name="Error",this.response=e,Object.setPrototypeOf(this,i.prototype)}}e.ProxyRequestError=i;e.isIntegrationError=t=>!("object"!=typeof t||!t)&&t.isIntegrationError,e.errorMessageParser=function(t){t="string"==typeof t?t:t.message;try{const n=JSON.parse(t);return!!(0,e.isIntegrationError)(n)}catch(t){return!1}}},3035:(t,e,n)=>{"use strict";var r,i,o,s,a=n(4155);Object.defineProperty(e,"__esModule",{value:!0}),e.CacheThrottle=e.CacheMode=void 0;const l=n(655),c=n(572);var u,d,h;!function(t){t.Debounce="debounce",t.Throttle="throttle"}(u=e.CacheMode||(e.CacheMode={})),function(t){t.Closed="closed",t.Idle="idle",t.Processing="processing"}(d||(d={})),function(t){t[t.Get=0]="Get",t[t.Set=1]="Set",t[t.GetOrSet=2]="GetOrSet",t[t.Del=3]="Del",t[t.Do=4]="Do"}(h||(h={}));e.CacheThrottle=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r.set(this,d.Idle),i.set(this,{}),o.set(this,void 0),s.set(this,[]),l.__classPrivateFieldSet(this,o,{mode:u.Debounce,ttl:0,...t},"f")}async get(t,e){const n=this.serializeKey(t),r=async()=>{const e=l.__classPrivateFieldGet(this,i,"f")[n],{mode:r,ttl:s,value:a}=null!=e?e:{};return!e||!s||r&&r!==u.Debounce||this.refreshTimeout(t,n,s),l.__classPrivateFieldGet(this,o,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(n,a),a};return e?r():this.enqueue(n,h.Get,r)}async set(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.__classPrivateFieldGet(this,o,"f").ttl,r=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;const a=this.serializeKey(t),c=async()=>{const s=l.__classPrivateFieldGet(this,i,"f")[a],c=!!s;return l.__classPrivateFieldGet(this,i,"f")[a]={...s,mode:r,ttl:n,value:e},c&&r===u.Throttle||this.refreshTimeout(t,a,n),l.__classPrivateFieldGet(this,o,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(a,e),e};return s?c():this.enqueue(a,h.Set,c)}async getOrSet(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.__classPrivateFieldGet(this,o,"f").ttl,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l.__classPrivateFieldGet(this,o,"f").mode,s=arguments.length>4?arguments[4]:void 0;const a=this.serializeKey(t),c=async()=>{if(l.__classPrivateFieldGet(this,i,"f")[a])return l.__classPrivateFieldGet(this,i,"f")[a].value;const s=await e();return await this.set(t,s,n,r,!0),l.__classPrivateFieldGet(this,o,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(a,s),s};return s?c():this.enqueue(a,h.GetOrSet,c)}async del(t){let e=arguments.length>2?arguments[2]:void 0;const n=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?t:this.serializeKey(t),r=async()=>{const t=l.__classPrivateFieldGet(this,i,"f")[n];let e;return(null==t?void 0:t.timeout)&&clearTimeout(t.timeout),t&&(e=t.value,delete l.__classPrivateFieldGet(this,i,"f")[n],await(async()=>{var t,n;return null===(n=(t=l.__classPrivateFieldGet(this,o,"f")).onDeregister)||void 0===n?void 0:n.call(t,e)})().catch((t=>{}))),e};return e?r():this.enqueue(n,h.Del,r)}keys(){return Object.keys(l.__classPrivateFieldGet(this,i,"f"))}async do(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.__classPrivateFieldGet(this,o,"f").ttl,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l.__classPrivateFieldGet(this,o,"f").mode;const s=this.serializeKey(t);return this.enqueue(s,h.Do,(async()=>{if(l.__classPrivateFieldGet(this,i,"f")[s])return l.__classPrivateFieldGet(this,i,"f")[s].value;const o=await e();return await this.set(t,o,n,r,!0)}))}async close(){l.__classPrivateFieldSet(this,r,d.Closed,"f"),await Promise.all(Object.keys(l.__classPrivateFieldGet(this,i,"f")).map((t=>this.del(t,!0,!0))))}refreshTimeout(t,e,n){if(l.__classPrivateFieldGet(this,r,"f")===d.Closed)return;const o=l.__classPrivateFieldGet(this,i,"f")[e];return n&&void 0!==(null==o?void 0:o.timeout)&&clearTimeout(o.timeout),n?(o.timeout=setTimeout((()=>this.del(t)),n),o.timeout):void 0}clearPendingDeletesOnKey(t,e){l.__classPrivateFieldSet(this,s,l.__classPrivateFieldGet(this,s,"f").filter((n=>{let[r,i,o,s]=n;return t!==r||i!==h.Del||(s.resolve(e),!1)})),"f")}serializeKey(t){var e,n,r;return null!==(r=null===(n=(e=l.__classPrivateFieldGet(this,o,"f")).serializeKey)||void 0===n?void 0:n.call(e,t))&&void 0!==r?r:t}async enqueue(t,e,n){const i=new c.DeferredPromise;return l.__classPrivateFieldGet(this,s,"f").push([t,e,n,i]),l.__classPrivateFieldGet(this,r,"f")===d.Idle&&this.flush(),i}flush(){l.__classPrivateFieldSet(this,r,d.Processing,"f"),a.nextTick((async()=>{for(;l.__classPrivateFieldGet(this,s,"f").length&&l.__classPrivateFieldGet(this,r,"f")!==d.Closed;){const t=l.__classPrivateFieldGet(this,s,"f").shift();if(t){const[,,e,n]=t;try{const t=await e();n.resolve(t)}catch(t){n.reject(t)}}}l.__classPrivateFieldSet(this,r,d.Idle,"f")}))}},r=new WeakMap,i=new WeakMap,o=new WeakMap,s=new WeakMap},9742:(t,e)=>{"use strict";e.byteLength=function(t){var e=l(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,o=l(t),s=o[0],a=o[1],c=new i(function(t,e,n){return 3*(e+n)/4-n}(0,s,a)),u=0,d=a>0?s-4:s;for(n=0;n<d;n+=4)e=r[t.charCodeAt(n)]<<18|r[t.charCodeAt(n+1)]<<12|r[t.charCodeAt(n+2)]<<6|r[t.charCodeAt(n+3)],c[u++]=e>>16&255,c[u++]=e>>8&255,c[u++]=255&e;2===a&&(e=r[t.charCodeAt(n)]<<2|r[t.charCodeAt(n+1)]>>4,c[u++]=255&e);1===a&&(e=r[t.charCodeAt(n)]<<10|r[t.charCodeAt(n+1)]<<4|r[t.charCodeAt(n+2)]>>2,c[u++]=e>>8&255,c[u++]=255&e);return c},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=16383,a=0,l=r-i;a<l;a+=s)o.push(c(t,a,a+s>l?l:a+s));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=o.length;s<a;++s)n[s]=o[s],r[o.charCodeAt(s)]=s;function l(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function c(t,e,r){for(var i,o,s=[],a=e;a<r;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},8764:(t,e,n)=>{"use strict";var r=n(9742),i=n(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=l,e.h2=50;var s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,l.prototype),e}function l(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return d(t)}return c(t,e,n)}function c(t,e,n){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!l.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var n=0|g(t,e),r=a(n),i=r.write(t,e);i!==n&&(r=r.slice(0,i));return r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(V(t,Uint8Array)){var e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(V(t,ArrayBuffer)||t&&V(t.buffer,ArrayBuffer))return f(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(V(t,SharedArrayBuffer)||t&&V(t.buffer,SharedArrayBuffer)))return f(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return l.from(r,e,n);var i=function(t){if(l.isBuffer(t)){var e=0|p(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}if(void 0!==t.length)return"number"!=typeof t.length||$(t.length)?a(0):h(t);if("Buffer"===t.type&&Array.isArray(t.data))return h(t.data)}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return l.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function d(t){return u(t),a(t<0?0:0|p(t))}function h(t){for(var e=t.length<0?0:0|p(t.length),n=a(e),r=0;r<e;r+=1)n[r]=255&t[r];return n}function f(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,l.prototype),r}function p(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function g(t,e){if(l.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||V(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return B(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return j(t).length;default:if(i)return r?-1:B(t).length;e=(""+e).toLowerCase(),i=!0}}function v(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return b(this,e,n);case"latin1":case"binary":return N(this,e,n);case"base64":return O(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function E(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),$(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=l.from(e,r)),l.isBuffer(e))return 0===e.length?-1:I(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):I(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function I(t,e,n,r,i){var o,s=1,a=t.length,l=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,l/=2,n/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var u=-1;for(o=n;o<a;o++)if(c(t,o)===c(e,-1===u?0:o-u)){if(-1===u&&(u=o),o-u+1===l)return u*s}else-1!==u&&(o-=o-u),u=-1}else for(n+l>a&&(n=a-l),o=n;o>=0;o--){for(var d=!0,h=0;h<l;h++)if(c(t,o+h)!==c(e,h)){d=!1;break}if(d)return o}return-1}function S(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=e.length;r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(e.substr(2*s,2),16);if($(a))return s;t[n+s]=a}return s}function w(t,e,n,r){return x(B(e,t.length-n),t,n,r)}function _(t,e,n,r){return x(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function m(t,e,n,r){return x(j(e),t,n,r)}function C(t,e,n,r){return x(function(t,e){for(var n,r,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)r=(n=t.charCodeAt(s))>>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function O(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i<n;){var o,s,a,l,c=t[i],u=null,d=c>239?4:c>223?3:c>191?2:1;if(i+d<=n)switch(d){case 1:c<128&&(u=c);break;case 2:128==(192&(o=t[i+1]))&&(l=(31&c)<<6|63&o)>127&&(u=l);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(l=(15&c)<<12|(63&o)<<6|63&s)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&l<1114112&&(u=l)}null===u?(u=65533,d=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),i+=d}return function(t){var e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=T));return n}(r)}l.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),l.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(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}}),l.poolSize=8192,l.from=function(t,e,n){return c(t,e,n)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array),l.alloc=function(t,e,n){return function(t,e,n){return u(t),t<=0?a(t):void 0!==e?"string"==typeof n?a(t).fill(e,n):a(t).fill(e):a(t)}(t,e,n)},l.allocUnsafe=function(t){return d(t)},l.allocUnsafeSlow=function(t){return d(t)},l.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==l.prototype},l.compare=function(t,e){if(V(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),V(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(t)||!l.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,r=e.length,i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},l.isEncoding=function(t){switch(String(t).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}},l.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return l.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=l.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var o=t[n];if(V(o,Uint8Array))i+o.length>r.length?l.from(o).copy(r,i):Uint8Array.prototype.set.call(r,o,i);else{if(!l.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i)}i+=o.length}return r},l.byteLength=g,l.prototype._isBuffer=!0,l.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)y(this,e,e+1);return this},l.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},l.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},l.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):v.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(t){if(!l.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===l.compare(this,t)},l.prototype.inspect=function(){var t="",n=e.h2;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},o&&(l.prototype[o]=l.prototype.inspect),l.prototype.compare=function(t,e,n,r,i){if(V(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(e>>>=0),a=Math.min(o,s),c=this.slice(r,i),u=t.slice(e,n),d=0;d<a;++d)if(c[d]!==u[d]){o=c[d],s=u[d];break}return o<s?-1:s<o?1:0},l.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},l.prototype.indexOf=function(t,e,n){return E(this,t,e,n,!0)},l.prototype.lastIndexOf=function(t,e,n){return E(this,t,e,n,!1)},l.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return S(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return _(this,t,e,n);case"base64":return m(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function b(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function N(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function P(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=e;o<n;++o)i+=H[t[o]];return i}function D(t,e,n){for(var r=t.slice(e,n),i="",o=0;o<r.length-1;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function R(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function L(t,e,n,r,i,o){if(!l.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function U(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function k(t,e,n,r,o){return e=+e,n>>>=0,o||U(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function M(t,e,n,r,o){return e=+e,n>>>=0,o||U(t,0,n,8),i.write(t,e,n,r,52,8),n+8}l.prototype.slice=function(t,e){var n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);var r=this.subarray(t,e);return Object.setPrototypeOf(r,l.prototype),r},l.prototype.readUintLE=l.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r},l.prototype.readUintBE=l.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);)r+=this[t+--e]*i;return r},l.prototype.readUint8=l.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},l.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*e)),r},l.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},l.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},l.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},l.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},l.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!0,23,4)},l.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!1,23,4)},l.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!0,52,8)},l.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e>>>=0,n>>>=0,r)||L(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e>>>=0,n>>>=0,r)||L(this,t,e,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},l.prototype.writeUint8=l.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,1,255,0),this[e]=255&t,e+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var i=Math.pow(2,8*n-1);L(this,t,e,n,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o<n&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+n},l.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var i=Math.pow(2,8*n-1);L(this,t,e,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+n},l.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},l.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},l.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeFloatLE=function(t,e,n){return k(this,t,e,!0,n)},l.prototype.writeFloatBE=function(t,e,n){return k(this,t,e,!1,n)},l.prototype.writeDoubleLE=function(t,e,n){return M(this,t,e,!0,n)},l.prototype.writeDoubleBE=function(t,e,n){return M(this,t,e,!1,n)},l.prototype.copy=function(t,e,n,r){if(!l.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var i=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),i},l.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!l.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){var i=t.charCodeAt(0);("utf8"===r&&i<128||"latin1"===r)&&(t=i)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var o;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o<n;++o)this[o]=t;else{var s=l.isBuffer(t)?t:l.from(t,r),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=s[o%a]}return this};var F=/[^+/0-9A-Za-z-_]/g;function B(t,e){var n;e=e||1/0;for(var r=t.length,i=null,o=[],s=0;s<r;++s){if((n=t.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function j(t){return r.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(F,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function x(t,e,n,r){for(var i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function V(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function $(t){return t!=t}var H=function(){for(var t="0123456789abcdef",e=new Array(256),n=0;n<16;++n)for(var r=16*n,i=0;i<16;++i)e[r+i]=t[n]+t[i];return e}()},738:(t,e,n)=>{"use strict";const r=n(3341),i=n(6401),o=n(5299);function s(t,e){switch(i(t)){case"object":return function(t,e){if("function"==typeof e)return e(t);if(e||o(t)){const n=new t.constructor;for(let r in t)n[r]=s(t[r],e);return n}return t}(t,e);case"array":return function(t,e){const n=new t.constructor(t.length);for(let r=0;r<t.length;r++)n[r]=s(t[r],e);return n}(t,e);default:return r(t)}}t.exports=s},3715:(t,e,n)=>{var r=e;r.utils=n(6436),r.common=n(5772),r.sha=n(9041),r.ripemd=n(2949),r.hmac=n(2344),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},5772:(t,e,n)=>{"use strict";var r=n(6436),i=n(9746);function o(){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}e.BlockHash=o,o.prototype.update=function(t,e){if(t=r.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var n=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-n,t.length),0===this.pending.length&&(this.pending=null),t=r.join32(t,0,t.length-n,this.endian);for(var i=0;i<t.length;i+=this._delta32)this._update(t,i,i+this._delta32)}return this},o.prototype.digest=function(t){return this.update(this._pad()),i(null===this.pending),this._digest(t)},o.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,n=e-(t+this.padLength)%e,r=new Array(n+this.padLength);r[0]=128;for(var i=1;i<n;i++)r[i]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)r[i++]=0;r[i++]=0,r[i++]=0,r[i++]=0,r[i++]=0,r[i++]=t>>>24&255,r[i++]=t>>>16&255,r[i++]=t>>>8&255,r[i++]=255&t}else for(r[i++]=255&t,r[i++]=t>>>8&255,r[i++]=t>>>16&255,r[i++]=t>>>24&255,r[i++]=0,r[i++]=0,r[i++]=0,r[i++]=0,o=8;o<this.padLength;o++)r[i++]=0;return r}},2344:(t,e,n)=>{"use strict";var r=n(6436),i=n(9746);function o(t,e,n){if(!(this instanceof o))return new o(t,e,n);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(r.toArray(e,n))}t.exports=o,o.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},o.prototype.update=function(t,e){return this.inner.update(t,e),this},o.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)}},2949:(t,e,n)=>{"use strict";var r=n(6436),i=n(5772),o=r.rotl32,s=r.sum32,a=r.sum32_3,l=r.sum32_4,c=i.BlockHash;function u(){if(!(this instanceof u))return new u;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function d(t,e,n,r){return t<=15?e^n^r:t<=31?e&n|~e&r:t<=47?(e|~n)^r:t<=63?e&r|n&~r:e^(n|~r)}function h(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function f(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}r.inherits(u,c),e.ripemd160=u,u.blockSize=512,u.outSize=160,u.hmacStrength=192,u.padLength=64,u.prototype._update=function(t,e){for(var n=this.h[0],r=this.h[1],i=this.h[2],c=this.h[3],u=this.h[4],E=n,I=r,S=i,w=c,_=u,m=0;m<80;m++){var C=s(o(l(n,d(m,r,i,c),t[p[m]+e],h(m)),v[m]),u);n=u,u=c,c=o(i,10),i=r,r=C,C=s(o(l(E,d(79-m,I,S,w),t[g[m]+e],f(m)),y[m]),_),E=_,_=w,w=o(S,10),S=I,I=C}C=a(this.h[1],i,w),this.h[1]=a(this.h[2],c,_),this.h[2]=a(this.h[3],u,E),this.h[3]=a(this.h[4],n,I),this.h[4]=a(this.h[0],r,S),this.h[0]=C},u.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"little"):r.split32(this.h,"little")};var p=[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],v=[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],y=[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:(t,e,n)=>{"use strict";e.sha1=n(4761),e.sha224=n(799),e.sha256=n(9344),e.sha384=n(772),e.sha512=n(5900)},4761:(t,e,n)=>{"use strict";var r=n(6436),i=n(5772),o=n(7038),s=r.rotl32,a=r.sum32,l=r.sum32_5,c=o.ft_1,u=i.BlockHash,d=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}r.inherits(h,u),t.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.prototype._update=function(t,e){for(var n=this.W,r=0;r<16;r++)n[r]=t[e+r];for(;r<n.length;r++)n[r]=s(n[r-3]^n[r-8]^n[r-14]^n[r-16],1);var i=this.h[0],o=this.h[1],u=this.h[2],h=this.h[3],f=this.h[4];for(r=0;r<n.length;r++){var p=~~(r/20),g=l(s(i,5),c(p,o,u,h),f,n[r],d[p]);f=h,h=u,u=s(o,30),o=i,i=g}this.h[0]=a(this.h[0],i),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],u),this.h[3]=a(this.h[3],h),this.h[4]=a(this.h[4],f)},h.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},799:(t,e,n)=>{"use strict";var r=n(6436),i=n(9344);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}r.inherits(o,i),t.exports=o,o.blockSize=512,o.outSize=224,o.hmacStrength=192,o.padLength=64,o.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h.slice(0,7),"big"):r.split32(this.h.slice(0,7),"big")}},9344:(t,e,n)=>{"use strict";var r=n(6436),i=n(5772),o=n(7038),s=n(9746),a=r.sum32,l=r.sum32_4,c=r.sum32_5,u=o.ch32,d=o.maj32,h=o.s0_256,f=o.s1_256,p=o.g0_256,g=o.g1_256,v=i.BlockHash,y=[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;v.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=y,this.W=new Array(64)}r.inherits(E,v),t.exports=E,E.blockSize=512,E.outSize=256,E.hmacStrength=192,E.padLength=64,E.prototype._update=function(t,e){for(var n=this.W,r=0;r<16;r++)n[r]=t[e+r];for(;r<n.length;r++)n[r]=l(g(n[r-2]),n[r-7],p(n[r-15]),n[r-16]);var i=this.h[0],o=this.h[1],v=this.h[2],y=this.h[3],E=this.h[4],I=this.h[5],S=this.h[6],w=this.h[7];for(s(this.k.length===n.length),r=0;r<n.length;r++){var _=c(w,f(E),u(E,I,S),this.k[r],n[r]),m=a(h(i),d(i,o,v));w=S,S=I,I=E,E=a(y,_),y=v,v=o,o=i,i=a(_,m)}this.h[0]=a(this.h[0],i),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],v),this.h[3]=a(this.h[3],y),this.h[4]=a(this.h[4],E),this.h[5]=a(this.h[5],I),this.h[6]=a(this.h[6],S),this.h[7]=a(this.h[7],w)},E.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},772:(t,e,n)=>{"use strict";var r=n(6436),i=n(5900);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}r.inherits(o,i),t.exports=o,o.blockSize=1024,o.outSize=384,o.hmacStrength=192,o.padLength=128,o.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h.slice(0,12),"big"):r.split32(this.h.slice(0,12),"big")}},5900:(t,e,n)=>{"use strict";var r=n(6436),i=n(5772),o=n(9746),s=r.rotr64_hi,a=r.rotr64_lo,l=r.shr64_hi,c=r.shr64_lo,u=r.sum64,d=r.sum64_hi,h=r.sum64_lo,f=r.sum64_4_hi,p=r.sum64_4_lo,g=r.sum64_5_hi,v=r.sum64_5_lo,y=i.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 I(){if(!(this instanceof I))return new I;y.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 S(t,e,n,r,i){var o=t&n^~t&i;return o<0&&(o+=4294967296),o}function w(t,e,n,r,i,o){var s=e&r^~e&o;return s<0&&(s+=4294967296),s}function _(t,e,n,r,i){var o=t&n^t&i^n&i;return o<0&&(o+=4294967296),o}function m(t,e,n,r,i,o){var s=e&r^e&o^r&o;return s<0&&(s+=4294967296),s}function C(t,e){var n=s(t,e,28)^s(e,t,2)^s(e,t,7);return n<0&&(n+=4294967296),n}function O(t,e){var n=a(t,e,28)^a(e,t,2)^a(e,t,7);return n<0&&(n+=4294967296),n}function A(t,e){var n=s(t,e,14)^s(t,e,18)^s(e,t,9);return n<0&&(n+=4294967296),n}function T(t,e){var n=a(t,e,14)^a(t,e,18)^a(e,t,9);return n<0&&(n+=4294967296),n}function b(t,e){var n=s(t,e,1)^s(t,e,8)^l(t,e,7);return n<0&&(n+=4294967296),n}function N(t,e){var n=a(t,e,1)^a(t,e,8)^c(t,e,7);return n<0&&(n+=4294967296),n}function P(t,e){var n=s(t,e,19)^s(e,t,29)^l(t,e,6);return n<0&&(n+=4294967296),n}function D(t,e){var n=a(t,e,19)^a(e,t,29)^c(t,e,6);return n<0&&(n+=4294967296),n}r.inherits(I,y),t.exports=I,I.blockSize=1024,I.outSize=512,I.hmacStrength=192,I.padLength=128,I.prototype._prepareBlock=function(t,e){for(var n=this.W,r=0;r<32;r++)n[r]=t[e+r];for(;r<n.length;r+=2){var i=P(n[r-4],n[r-3]),o=D(n[r-4],n[r-3]),s=n[r-14],a=n[r-13],l=b(n[r-30],n[r-29]),c=N(n[r-30],n[r-29]),u=n[r-32],d=n[r-31];n[r]=f(i,o,s,a,l,c,u,d),n[r+1]=p(i,o,s,a,l,c,u,d)}},I.prototype._update=function(t,e){this._prepareBlock(t,e);var n=this.W,r=this.h[0],i=this.h[1],s=this.h[2],a=this.h[3],l=this.h[4],c=this.h[5],f=this.h[6],p=this.h[7],y=this.h[8],E=this.h[9],I=this.h[10],b=this.h[11],N=this.h[12],P=this.h[13],D=this.h[14],R=this.h[15];o(this.k.length===n.length);for(var L=0;L<n.length;L+=2){var U=D,k=R,M=A(y,E),F=T(y,E),B=S(y,E,I,b,N),j=w(y,E,I,b,N,P),x=this.k[L],V=this.k[L+1],$=n[L],H=n[L+1],K=g(U,k,M,F,B,j,x,V,$,H),W=v(U,k,M,F,B,j,x,V,$,H);U=C(r,i),k=O(r,i),M=_(r,i,s,a,l),F=m(r,i,s,a,l,c);var G=d(U,k,M,F),q=h(U,k,M,F);D=N,R=P,N=I,P=b,I=y,b=E,y=d(f,p,K,W),E=h(p,p,K,W),f=l,p=c,l=s,c=a,s=r,a=i,r=d(K,W,G,q),i=h(K,W,G,q)}u(this.h,0,r,i),u(this.h,2,s,a),u(this.h,4,l,c),u(this.h,6,f,p),u(this.h,8,y,E),u(this.h,10,I,b),u(this.h,12,N,P),u(this.h,14,D,R)},I.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},7038:(t,e,n)=>{"use strict";var r=n(6436).rotr32;function i(t,e,n){return t&e^~t&n}function o(t,e,n){return t&e^t&n^e&n}function s(t,e,n){return t^e^n}e.ft_1=function(t,e,n,r){return 0===t?i(e,n,r):1===t||3===t?s(e,n,r):2===t?o(e,n,r):void 0},e.ch32=i,e.maj32=o,e.p32=s,e.s0_256=function(t){return r(t,2)^r(t,13)^r(t,22)},e.s1_256=function(t){return r(t,6)^r(t,11)^r(t,25)},e.g0_256=function(t){return r(t,7)^r(t,18)^t>>>3},e.g1_256=function(t){return r(t,17)^r(t,19)^t>>>10}},6436:(t,e,n)=>{"use strict";var r=n(9746),i=n(5717);function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function l(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}e.inherits=i,e.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var n=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i<t.length;i+=2)n.push(parseInt(t[i]+t[i+1],16))}else for(var r=0,i=0;i<t.length;i++){var s=t.charCodeAt(i);s<128?n[r++]=s:s<2048?(n[r++]=s>>6|192,n[r++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),n[r++]=s>>18|240,n[r++]=s>>12&63|128,n[r++]=s>>6&63|128,n[r++]=63&s|128):(n[r++]=s>>12|224,n[r++]=s>>6&63|128,n[r++]=63&s|128)}else for(i=0;i<t.length;i++)n[i]=0|t[i];return n},e.toHex=function(t){for(var e="",n=0;n<t.length;n++)e+=a(t[n].toString(16));return e},e.htonl=s,e.toHex32=function(t,e){for(var n="",r=0;r<t.length;r++){var i=t[r];"little"===e&&(i=s(i)),n+=l(i.toString(16))}return n},e.zero2=a,e.zero8=l,e.join32=function(t,e,n,i){var o=n-e;r(o%4==0);for(var s=new Array(o/4),a=0,l=e;a<s.length;a++,l+=4){var c;c="big"===i?t[l]<<24|t[l+1]<<16|t[l+2]<<8|t[l+3]:t[l+3]<<24|t[l+2]<<16|t[l+1]<<8|t[l],s[a]=c>>>0}return s},e.split32=function(t,e){for(var n=new Array(4*t.length),r=0,i=0;r<t.length;r++,i+=4){var o=t[r];"big"===e?(n[i]=o>>>24,n[i+1]=o>>>16&255,n[i+2]=o>>>8&255,n[i+3]=255&o):(n[i+3]=o>>>24,n[i+2]=o>>>16&255,n[i+1]=o>>>8&255,n[i]=255&o)}return n},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return t<<e|t>>>32-e},e.sum32=function(t,e){return t+e>>>0},e.sum32_3=function(t,e,n){return t+e+n>>>0},e.sum32_4=function(t,e,n,r){return t+e+n+r>>>0},e.sum32_5=function(t,e,n,r,i){return t+e+n+r+i>>>0},e.sum64=function(t,e,n,r){var i=t[e],o=r+t[e+1]>>>0,s=(o<r?1:0)+n+i;t[e]=s>>>0,t[e+1]=o},e.sum64_hi=function(t,e,n,r){return(e+r>>>0<e?1:0)+t+n>>>0},e.sum64_lo=function(t,e,n,r){return e+r>>>0},e.sum64_4_hi=function(t,e,n,r,i,o,s,a){var l=0,c=e;return l+=(c=c+r>>>0)<e?1:0,l+=(c=c+o>>>0)<o?1:0,t+n+i+s+(l+=(c=c+a>>>0)<a?1:0)>>>0},e.sum64_4_lo=function(t,e,n,r,i,o,s,a){return e+r+o+a>>>0},e.sum64_5_hi=function(t,e,n,r,i,o,s,a,l,c){var u=0,d=e;return u+=(d=d+r>>>0)<e?1:0,u+=(d=d+o>>>0)<o?1:0,u+=(d=d+a>>>0)<a?1:0,t+n+i+s+l+(u+=(d=d+c>>>0)<c?1:0)>>>0},e.sum64_5_lo=function(t,e,n,r,i,o,s,a,l,c){return e+r+o+a+c>>>0},e.rotr64_hi=function(t,e,n){return(e<<32-n|t>>>n)>>>0},e.rotr64_lo=function(t,e,n){return(t<<32-n|e>>>n)>>>0},e.shr64_hi=function(t,e,n){return t>>>n},e.shr64_lo=function(t,e,n){return(t<<32-n|e>>>n)>>>0}},645:(t,e)=>{e.read=function(t,e,n,r,i){var o,s,a=8*i-r-1,l=(1<<a)-1,c=l>>1,u=-7,d=n?i-1:0,h=n?-1:1,f=t[e+d];for(d+=h,o=f&(1<<-u)-1,f>>=-u,u+=a;u>0;o=256*o+t[e+d],d+=h,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=r;u>0;s=256*s+t[e+d],d+=h,u-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),o-=c}return(f?-1:1)*s*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var s,a,l,c=8*o-i-1,u=(1<<c)-1,d=u>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+d>=1?h/l:h*Math.pow(2,1-d))*l>=2&&(s++,l/=2),s+d>=u?(a=0,s=u):s+d>=1?(a=(e*l-1)*Math.pow(2,i),s+=d):(a=e*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;t[n+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;t[n+f]=255&s,f+=p,s/=256,c-=8);t[n+f-p]|=128*g}},5717:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}},5299:(t,e,n)=>{"use strict";var r=n(7798);function i(t){return!0===r(t)&&"[object Object]"===Object.prototype.toString.call(t)}t.exports=function(t){var e,n;return!1!==i(t)&&("function"==typeof(e=t.constructor)&&(!1!==i(n=e.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")))}},7798:t=>{"use strict";t.exports=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)}},6245:(t,e,n)=>{"use strict";function r(t){this.message=t}n.r(e),n.d(e,{InvalidTokenError:()=>s,default:()=>a}),r.prototype=new Error,r.prototype.name="InvalidCharacterError";var i="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,o=0,s=0,a="";i=e.charAt(s++);~i&&(n=o%4?64*n+i:i,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return a};function o(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(i(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return i(e)}}function s(t){this.message=t}s.prototype=new Error,s.prototype.name="InvalidTokenError";const a=function(t,e){if("string"!=typeof t)throw new s("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(o(t.split(".")[n]))}catch(t){throw new s("Invalid token specified: "+t.message)}}},6401:t=>{var e=Object.prototype.toString;function n(t){return"function"==typeof t.constructor?t.constructor.name:null}t.exports=function(t){if(void 0===t)return"undefined";if(null===t)return"null";var r=typeof t;if("boolean"===r)return"boolean";if("string"===r)return"string";if("number"===r)return"number";if("symbol"===r)return"symbol";if("function"===r)return"GeneratorFunction"===n(t)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(t))return"array";if(function(t){if(t.constructor&&"function"==typeof t.constructor.isBuffer)return t.constructor.isBuffer(t);return!1}(t))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}(t))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(t))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(t))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(t))return"regexp";switch(n(t)){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(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(t))return"generator";switch(r=e.call(t)){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 r.slice(8,-1).toLowerCase().replace(/\s/g,"")}},9746:t=>{function e(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=e,e.equal=function(t,e,n){if(t!=e)throw new Error(n||"Assertion failed: "+t+" != "+e)}},4155:t=>{var e,n,r=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(t){if(e===setTimeout)return setTimeout(t,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:i}catch(t){e=i}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var a,l=[],c=!1,u=-1;function d(){c&&a&&(c=!1,a.length?l=a.concat(l):u=-1,l.length&&h())}function h(){if(!c){var t=s(d);c=!0;for(var e=l.length;e;){for(a=l,l=[];++u<e;)a&&a[u].run();u=-1,e=l.length}a=null,c=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{return n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function f(t,e){this.fun=t,this.array=e}function p(){}r.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];l.push(new f(t,e)),1!==l.length||c||s(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=p,r.addListener=p,r.once=p,r.off=p,r.removeListener=p,r.removeAllListeners=p,r.emit=p,r.prependListener=p,r.prependOnceListener=p,r.listeners=function(t){return[]},r.binding=function(t){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(t){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},3341:(t,e,n)=>{"use strict";var r=n(8764).lW;const i=Symbol.prototype.valueOf,o=n(6401);t.exports=function(t,e){switch(o(t)){case"array":return t.slice();case"object":return Object.assign({},t);case"date":return new t.constructor(Number(t));case"map":return new Map(t);case"set":return new Set(t);case"buffer":return function(t){const e=t.length,n=r.allocUnsafe?r.allocUnsafe(e):r.from(e);return t.copy(n),n}(t);case"symbol":return function(t){return i?Object(i.call(t)):{}}(t);case"arraybuffer":return function(t){const e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e}(t);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return function(t,e){return new t.constructor(t.buffer,t.byteOffset,t.length)}(t);case"regexp":return function(t){const e=void 0!==t.flags?t.flags:/\w+$/.exec(t)||void 0,n=new t.constructor(t.source,e);return n.lastIndex=t.lastIndex,n}(t);case"error":return Object.create(t);default:return t}}},655:(t,e,n)=>{"use strict";n.r(e),n.d(e,{__assign:()=>o,__asyncDelegator:()=>w,__asyncGenerator:()=>S,__asyncValues:()=>_,__await:()=>I,__awaiter:()=>u,__classPrivateFieldGet:()=>T,__classPrivateFieldSet:()=>b,__createBinding:()=>h,__decorate:()=>a,__exportStar:()=>f,__extends:()=>i,__generator:()=>d,__importDefault:()=>A,__importStar:()=>O,__makeTemplateObject:()=>m,__metadata:()=>c,__param:()=>l,__read:()=>g,__rest:()=>s,__spread:()=>v,__spreadArray:()=>E,__spreadArrays:()=>y,__values:()=>p});var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},o.apply(this,arguments)};function s(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function a(t,e,n,r){var i,o=arguments.length,s=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s}function l(t,e){return function(n,r){e(n,r,t)}}function c(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function u(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{l(r.next(t))}catch(t){o(t)}}function a(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((r=r.apply(t,e||[])).next())}))}function d(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}var h=Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]};function f(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||h(e,t,n)}function p(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function v(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(g(arguments[e]));return t}function y(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}function E(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function I(t){return this instanceof I?(this.v=t,this):new I(t)}function S(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(t,e||[]),o=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(t){i[t]&&(r[t]=function(e){return new Promise((function(n,r){o.push([t,e,n,r])>1||a(t,e)}))})}function a(t,e){try{(n=i[t](e)).value instanceof I?Promise.resolve(n.value.v).then(l,c):u(o[0][2],n)}catch(t){u(o[0][3],t)}var n}function l(t){a("next",t)}function c(t){a("throw",t)}function u(t,e){t(e),o.shift(),o.length&&a(o[0][0],o[0][1])}}function w(t){var e,n;return e={},r("next"),r("throw",(function(t){throw t})),r("return"),e[Symbol.iterator]=function(){return this},e;function r(r,i){e[r]=t[r]?function(e){return(n=!n)?{value:I(t[r](e)),done:"return"===r}:i?i(e):e}:i}}function _(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=p(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,i){(function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)})(r,i,(e=t[n](e)).done,e.value)}))}}}function m(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var C=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};function O(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&h(e,t,n);return C(e,t),e}function A(t){return t&&t.__esModule?t:{default:t}}function T(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}function b(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n}}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={exports:{}};return t[r].call(o.exports,o,o.exports,n),o.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r=n(3056);module.exports=r})();
2
+ (()=>{var t={773:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InstallFlow=e.ExternalFilePicker=e.PARAGON_OVERFLOW_EMPTY_VALUE=void 0;const r=n(655),i=r.__importDefault(n(6245)),o=n(3931),s=n(4059),a=n(745),l=n(7343),c=n(7050);Object.defineProperty(e,"ExternalFilePicker",{enumerable:!0,get:function(){return c.ExternalFilePicker}});const d=n(2643),u=n(4429),h=n(9636),f=r.__importDefault(n(9892)),p=n(3821),g=n(2460),v=n(3158),y=n(4846),E=n(572),I=n(8321),w=n(3035),S="paragon-connect-frame",_=`${S}-container`,m="paragon-connect-user-state";e.PARAGON_OVERFLOW_EMPTY_VALUE="PARAGON_OVERFLOW_EMPTY_VALUE";class C extends f.default{constructor(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(super(),this.sdkVersion="2.2.2",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 w.CacheThrottle({ttl:5e3}),this.keyToRequestPromiseMap={},this.originalBodyOverflow=e.PARAGON_OVERFLOW_EMPTY_VALUE,this.dynamicFieldMappingLoaders={},this.customDropdownOptionsLoaders={},this.customDropdownOptionsStatic={},"undefined"==typeof window)return void console.warn("connect sdk can only be used on browser");const r=(0,v.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:r,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 t?this.configureGlobal({host:t}):this.environments={...this.environments,...t},!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.");n.skipBootstrapWithLastKnownState||this.loadState(),window.addEventListener("message",this.eventMessageHandler.bind(this)),window.document.readyState===p.DocumentLoadingState.LOADING?window.document.addEventListener("DOMContentLoaded",(()=>{this.createReactRoot()})):this.createReactRoot(),this.installFlow=new O(this)}setHeadless(t){this.isHeadless=t}async eventMessageHandler(t){switch(t.data.type){case"oauth_success_callback":await this._oauthCallback(t.data.credential);break;case"oauth_error_callback":await this._oauthErrorCallback(t.data.error,t);break;default:await this.functionInvocationHandler(t)}}async functionInvocationHandler(t){if("SDK_FUNCTION_INVOCATION"!==t.data.messageType)return;const{type:e,id:n,parameters:r}=t.data;let i;try{i={messageType:"SDK_FUNCTION_RESPONSE",id:n,type:e,result:await this[e](...r)}}catch(t){i={messageType:"SDK_FUNCTION_ERROR",error:!0,message:t.message,id:n}}t.source.postMessage(i,this.environments.CONNECT_PUBLIC_URL)}createReactRoot(){var t;if(this.rootElementCreated)return;this.rootElementCreated=!0,this.root=document.createElement("iframe"),this.root.onload=()=>{this.rootLoaded=!0,this.render()};const e=!!document.querySelector(`#${_}`);this.root.id=S,this.root.src=`${this.environments.CONNECT_PUBLIC_URL}/ui${this.projectId?`?projectId=${this.projectId}`:""}`,this.root.style.position=e?"absolute":"fixed",this.root.style.top="0",this.root.style.left="0",this.root.style.width=e?"100%":"100vw",this.root.style.height=e?"100%":"100vh",this.root.style.zIndex="2147483647",this.root.style.display="none",null===(t=document.querySelector(`#${_}`)||document.body)||void 0===t||t.appendChild(this.root)}validateAction(t){var e;if(!this.loadedIntegrations[t]&&!(0,l.isCustomIntegrationTypeName)(t))throw new Error(`"${t}" is not a valid integration type. The integrations you have configured for this Paragon project are:\n\n ${Object.keys(this.loadedConfigs).map((t=>`- "${t}"`)).join("\n")}\n `);if(!this.loadedConfigs[t]||!this.userState.integrations[t])throw new Error(`integration "${t}" has not been set up in your Paragon project yet.\n\n ${Object.keys(this.loadedConfigs).map((t=>`- "${t}"`)).join("\n")}`);if(!(null===(e=this.loadedIntegrations[t])||void 0===e?void 0:e.isActive))throw new Error(`integration "${t}" is not active in your Paragon project yet.`)}isAlreadyInstalled(t,e,n){var r,i;if(n){const t=this.getCredentialAndConfig({selectedCredentialId:n});return(null===(r=null==t?void 0:t.selectedCredential)||void 0===r?void 0:r.status)===s.CredentialStatus.VALID}return Boolean(null===(i=e.integrations[t])||void 0===i?void 0:i.enabled)}hasCredential(t,e,n){var r,i;if(!n)return Boolean(null===(r=e.integrations[t])||void 0===r?void 0:r.credentialId);try{const t=this.getCredentialAndConfig({selectedCredentialId:n});return Boolean(null===(i=null==t?void 0:t.selectedCredential)||void 0===i?void 0:i.id)}catch(t){return console.error(t),!1}}async bootstrapSDKState(t){this.projectId&&this.userState.authenticated&&await this.updateLocalState(t)}setModalState(t){this.modalState={config:void 0,...this.modalState,...t},this.render()}loadState(){if("undefined"!=typeof window)try{const t=window.localStorage.getItem(m)?JSON.parse(window.localStorage.getItem(m)):{};if(t.projectId&&(this.projectId=t.projectId),t.userState){const{userState:e}=t;if(!("authenticated"in e&&e.authenticated&&"token"in e))throw new Error("Malformatted or unauthenticated user was persisted into localStorage. Refusing to load.");this.updateAuthenticatedUser(e),this.bootstrapSDKState().catch((()=>{this.clearState()}))}}catch{this.clearState()}}getIntegrationId(t){const e=this.loadedIntegrations[t];if(!e)throw new Error(`Integration "${t}" not found`);return e.id}saveState(){"undefined"!=typeof window&&this.userState.authenticated&&window.localStorage.setItem(m,JSON.stringify({projectId:this.projectId,userState:this.userState}))}clearState(){"undefined"!=typeof window&&window.localStorage.removeItem(m)}render(){if(!this.isHeadless&&this.root&&this.rootLoaded){const{onClose:t,onOpen:e,...n}=this.modalState,r={messageType:"UI_UPDATE",nextContext:{user:this.userState,projectId:this.projectId,environments:this.environments,project:this.project,endUserIntegrationConfig:this.modalState.integration?this.endUserIntegrationConfig[(0,l.getIntegrationTypeName)(this.modalState.integration)||""]:void 0},nextModalState:n};if(!this.root.contentWindow)throw new Error("Browser not supported");this.root.contentWindow.postMessage(r,this.environments.CONNECT_PUBLIC_URL)}}updateContainerStyle(t){let{isModalShown:e}=t;this.root&&(this.root.style.display=e?"block":"none")}async authenticate(t,e,n){var r;if(!t||!e)throw new Error("projectId or token not specified to paragon.authenticate()");let o={};try{o=(0,i.default)(e)}catch(t){throw new Error("A well-formed JWT was not provided to paragon.authenticate()")}this.projectId=t,this.userState={authenticated:!0,token:e,userId:o.sub||o.id,integrations:{},meta:null!==(r=null==n?void 0:n.metadata)&&void 0!==r?r:{},resources:[]};try{if(Date.now()>=1e3*(o.exp||0))throw new Error("JWT token provided has expired.");await this.bootstrapSDKState(null==n?void 0:n.metadata)}catch(t){throw console.warn("paragon.authenticate() could not login user",t),this.logout(),new Error(`Failed to authenticate user with Paragon: ${t.message}`)}this.render()}getUser(){return(0,h.cloneDeep)(Object.fromEntries(Object.entries(this.userState).filter((t=>{let[e]=t;return"token"!==e}))))}updateAuthenticatedUser(t){this.userState.authenticated?this.userState={...this.userState,...t}:t.authenticated&&(this.userState=t),this.render()}logout(){this.userState={authenticated:!1},this.clearState(),this.render()}removeOptionDuplicates(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!t)return;const e=new Set,n=[];for(const r of t)e.has(r.value)?console.warn(`Duplicated key: "${r.value}", Ignored: "${r.label}"`):(n.push(r),e.add(r.value));return n}applyCustomDropdownOptions(t,e){const n=[];for(const t in e){const r=e[t];if("loadOptions"in r){const e=r.loadOptions;this.customDropdownOptionsLoaders[t]=e,n.push(t)}else Array.isArray(r)&&(this.customDropdownOptionsStatic[t]=r)}if(t.sharedMeta&&Array.isArray(t.sharedMeta.inputs))for(const r of t.sharedMeta.inputs){if(n.includes(r.key)){r.customDropdownOptions=[];continue}const t=e[r.key];if(Array.isArray(t)){const e=this.removeOptionDuplicates(t);e&&(r.customDropdownOptions=e)}}if(t.workflowMeta)for(const r in t.workflowMeta){const i=t.workflowMeta[r];for(const t of i.inputs){if(n.includes(t.key)){t.customDropdownOptions=[];continue}const r=e[t.key];if(Array.isArray(r)){const e=this.removeOptionDuplicates(r);e&&(t.customDropdownOptions=e)}}}return t}startOAuthFlow(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var r,i;const o=this.getIntegrationByName(t),s=(0,d.findSelectedAccountType)(null===(r=null==o?void 0:o.sdkIntegrationConfig)||void 0===r?void 0:r.accountTypes,this.getAccountName(e.accountType),this.getSelectedMultipleAccountTypes(e.accountType)),l={context:{user:this.userState,projectId:this.projectId,environments:this.environments,endUserIntegrationConfig:e.userProvidedIntegrationConfig},integration:o,endUserSuppliedValues:e.endUserSuppliedValues},c=Boolean(o.needPreOauthInputs&&s&&!(null===(i=s.endUserSuppliedValues)||void 0===i?void 0:i.length)&&s.scheme===a.AuthenticationScheme.OAUTH);if(this.isHeadless||c||!o.needPreOauthInputs){l.authParams=null==s?void 0:s.oauthParameters,l.installOptions=e;const r=Math.random().toString(36).substring(2,15),i=(0,u.startOAuthFlow)(l,r);if(!i)throw new g.OAuthBlockedError;const o=()=>{clearInterval(v)},a=Date.now(),c=new AbortController,d=500;let h=!1;const f={abortSignal:c.signal,onSuccess:t=>{var e;h||(h=!0,o(),null===(e=n.onSuccess)||void 0===e||e.call(n,t))},onError:t=>{var e;h||(h=!0,o(),c.abort(),null===(e=n.onError)||void 0===e||e.call(n,t))}};new Promise(((e,n)=>{const r=i=>{"oauth_success_callback"===i.data.type&&(window.removeEventListener("message",r),e({integrationId:i.data.credential.integrationId,integrationType:t,credentialId:i.data.credential.payload.credentialId})),"oauth_error_callback"===i.data.type&&(window.removeEventListener("message",r),n(new Error(i.data.error)))};window.addEventListener("message",r)})).then((t=>{f.onSuccess(t)})).catch((t=>{f.onError(t)}));const p=setInterval((()=>{try{i.opener||(clearInterval(p),this.pollForCredential(t,r,f))}catch(e){clearInterval(p),this.pollForCredential(t,r,f)}}),d),v=setInterval((()=>{try{if(!h&&n.oauthTimeout&&Date.now()-a>n.oauthTimeout)return i.close(),void f.onError(new g.OAuthTimeoutError)}catch(t){f.onError(t)}}),d)}}getIntegrationByName(t){const e=Object.values(this.loadedIntegrations).find((e=>(0,l.getIntegrationTypeName)(e)===t));if(!e)throw new Error(`Integration "${t}" not found.`);return e}getSelectedMultipleAccountTypes(t){if(Array.isArray(t))return t}getAccountName(t){return"string"==typeof t?t.trim():""}setDynamicFieldMappingLoaders(t,e){var n,r;if(this.dynamicFieldMappingLoaders[t]={},e)for(const[i,o]of Object.entries(e))if("object"==typeof o&&"objectTypes"in o&&"integrationFields"in o&&"applicationFields"in o){const s=o;this.dynamicFieldMappingLoaders[t][i]={objectTypes:null===(n=s.objectTypes)||void 0===n?void 0:n.get,integrationFields:null===(r=s.integrationFields)||void 0===r?void 0:r.get},s.applicationFields&&(e[i]={...s.applicationFields,useBYOFieldMappingOption:!0})}}async connect(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{mapObjectFields:n,overrideRedirectUrl:r,isApiInstallation:i=!1,showPortalAfterInstall:o,bypassPostOAuthPrompt:a,allowMultipleCredentials:l,selectedCredentialId:c,selectedConfigurationId:u,accountType:h,...f}=e;return this.integrationToBeEnabled=t,new Promise(((v,y)=>{var E,w;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;const S=this.getIntegrationByName(t),_=this.getSelectedMultipleAccountTypes(h);this.subscribeToIntegration(t,{...f,onInstall:(e,n)=>{var r;const i=n.integrations[t];e.credentialId=null==i?void 0:i.credentialId,e.credential=null==i?void 0:i.allCredentials.find((t=>t.id===i.credentialId)),v(e),(null==f?void 0:f.onInstall)?f.onInstall(e,n):null===(r=null==f?void 0:f.onSuccess)||void 0===r||r.call(f,e,n)},onError:t=>{var e;y(t),null===(e=null==f?void 0:f.onError)||void 0===e||e.call(f,t)}});try{if(n&&!this.project.accessibleFeatures.includes(p.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.validateAction(t),r&&!(0,I.isValidUrl)(r))throw new Error(`${r} is not valid url.`);this.setDynamicFieldMappingLoaders(t,n);const f=this.getAccountName(h),g=Array.isArray(h)?h.filter((t=>{var e,n;return!(null===(n=null===(e=null==S?void 0:S.sdkIntegrationConfig)||void 0===e?void 0:e.accountTypes)||void 0===n?void 0:n.some((e=>e.id===t)))})):[],m=(0,d.findSelectedAccountType)(null===(E=null==S?void 0:S.sdkIntegrationConfig)||void 0===E?void 0:E.accountTypes,f,_),C={isApiInstallation:i,showPortalAfterInstall:o,bypassPostOAuthPrompt:a,allowMultipleCredentials:l,selectedCredentialId:c,selectedConfigurationId:u,accountType:h};if(this.setCredentialConfigForUserState(t,c,u),e.isApiInstallation&&(null===(w=this.userState.integrations[t])||void 0===w?void 0:w.credentialStatus)!==s.CredentialStatus.PENDING){const i=this.isHeadless?{onSuccess:t=>{v({integrationId:t.integrationId,integrationType:t.integrationType,credentialId:t.credentialId})},onError:t=>{y(t)},oauthTimeout:e.oauthTimeout}:void 0;this.startOAuthFlow(t,{...C,userProvidedIntegrationConfig:{mapObjectFields:n,overrideRedirectUrl:r?(0,I.sanitizeUrl)(r):void 0}},i)}(h&&!m&&"string"==typeof h||g.length)&&console.warn(`Account type "${g.length?g:h}" is not valid for integration "${null==S?void 0:S.type}"`);const O=JSON.parse(JSON.stringify(this.loadedConfigs[t]));e.dropdowns&&(this.loadedConfigs[t]=this.applyCustomDropdownOptions(O,e.dropdowns)),this.setModalState({integration:S,config:this.loadedConfigs[t],apiInstallationOptions:{...C,selectedMultipleAccountTypes:_,selectedAccountConfig:m},selectedCredentialId:c,connectionError:void 0,shouldShowPortalAfterInstall:!1})}catch(e){this.emitError(e,t)}}))}setCredentialConfigForUserState(t,e,n){var r,i,o;if(!this.userState.authenticated||!(null===(r=this.userState.integrations[t])||void 0===r?void 0:r.allCredentials.length))return;const a=this.userState.integrations[t],l=null!==(i=null==a?void 0:a.credentialId)&&void 0!==i?i:null==a?void 0:a.allCredentials[0].id,c=this.getCredentialAndConfig(e||n?{selectedCredentialId:e,selectedConfigurationId:n}:{selectedCredentialId:l},a);if(!(null===(o=null==a?void 0:a.allCredentials)||void 0===o?void 0:o.some((t=>{let{id:e}=t;return e===(null==c?void 0:c.selectedCredential.id)})))||!c)throw new Error(`Credential with ID "${e}" is not a valid ${t} account.`);const{selectedConfig:d,selectedCredential:u}=c,h={...a,allConfigurations:(null==a?void 0:a.allConfigurations)||[],allCredentials:(null==a?void 0:a.allCredentials)||[],enabled:u.status===s.CredentialStatus.VALID,credentialId:u.id,credentialStatus:u.status,providerData:u.providerData,providerId:u.providerId,configMeta:null==d?void 0:d.configMeta,credentialConfigId:null==d?void 0:d.id,externalId:null==d?void 0:d.externalId,sharedSettings:null==d?void 0:d.sharedSettings,workflowSettings:null==d?void 0:d.workflowSettings,configuredWorkflows:null==d?void 0:d.workflowSettings};this.userState.integrations={...this.userState.integrations,[t]:h}}getCredentialAndConfig(t,e,n){var r;const{selectedCredentialId:i,selectedConfigurationId:o}=t,s=null==i?void 0:i.trim(),a=null==o?void 0:o.trim();if(s&&!(0,E.isUUID)(s))throw new Error(`Selected credential id: ${s} is not a valid UUID.`);if(!this.userState.authenticated||!s&&!a)return;let l,c;const d=null!==(r=null==e?void 0:e.allCredentials)&&void 0!==r?r:Object.values(this.userState.integrations).flatMap((t=>(null==t?void 0:t.allCredentials)||[])),u=d.flatMap((t=>{let{configurations:e}=t;return e}));if(a){const t=a.startsWith("ext:")||!(0,E.isUUID)(a),e=(0,v.sanitizeExternalConfigId)(a),r=n=>(t?n.externalId===e:n.id===e)&&(!s||n.connectCredentialId===s);if(null==n?void 0:n.throwIfMultipleConfigsFound){const t=u.filter(r);if(t.length>1)throw new Error(`Multiple credential configurations found for provided id: ${a}.`);c=t[0]}else c=u.find(r);if(!c)throw new Error(`Credential configuration not found for provided id: ${a}.`)}if(l=d.find((t=>{let{id:e}=t;return e===((null==c?void 0:c.connectCredentialId)||s)})),c=null!=c?c:null==l?void 0:l.configurations.find((t=>{let{isDefault:e}=t;return e})),!l)throw new Error("Unable to find credential for provided options.");if(!c)throw new Error(`Credential configuration not found for credential: ${l.id}.`);if(c&&c.connectCredentialId!==(null==l?void 0:l.id))throw new Error('Provided "selectedCredentialId" does not belongs to provided "selectedConfigurationId".');return{selectedCredential:l,selectedConfig:c}}_getIntegration(t){return Object.values(this.loadedIntegrations).find((e=>e.id===t))}getIntegrationBySlug(t){const e=this.loadedIntegrations[t];if(!e)throw new g.IntegrationNotFoundError(t);return e}async _oauthCallback(t,e,n){var r,i,o;const{integrationId:a,payload:c}=t,d=this._getIntegration(a);if(!d)return;const u=(0,y.hash)(JSON.stringify({oauthResponse:t,credentialId:e}));if(await this.cachedApiResponse.get(u))return;await this.cachedApiResponse.set(u,!0);const h=(0,l.getIntegrationTypeName)(d),f=null!==(r=null==n?void 0:n.installOptions)&&void 0!==r?r:(null===(i=this.modalState.apiInstallationOptions)||void 0===i?void 0:i.isApiInstallation)?this.modalState.apiInstallationOptions:{};try{const t=e?`/sdk/credentials/${e}/complete-setup`:"/sdk/credentials",n=await this.sendConnectRequest(t,{method:"POST",body:JSON.stringify({integrationId:d.id,config:{},payload:c,installOptions:f})});if(!n)throw new Error("Unable to save oauth credentials");return this.updateCredentialData(n,d),n.status===s.CredentialStatus.VALID&&this.triggerSDKEvent({type:p.SDK_EVENT.ON_INTEGRATION_INSTALL,integrationId:d.id,integrationType:h}),this.setModalState({...this.modalState,...(null===(o=this.modalState.apiInstallationOptions)||void 0===o?void 0:o.showPortalAfterInstall)?{shouldShowPortalAfterInstall:!0}:{},connectionError:void 0}),{integrationId:d.id,integrationType:h,credentialId:n.id,credential:n}}catch(t){if(this.isHeadless)throw t;this.setModalState({...this.modalState,connectionError:t}),this.emitError(t,h),await this._oauthErrorCallback(t.message)}}async _oauthErrorCallback(t,e){var n;const r=t;let i;i=this.integrationToBeEnabled?this.loadedIntegrations[this.integrationToBeEnabled].id:null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.integrationId,e&&(this.emitError(e.data.errorResponse,(0,l.getIntegrationTypeName)(this._getIntegration(i))),this.setModalState({...this.modalState,connectionError:e.data})),console.error("Failed to connect account to Paragon over OAuth",r)}async _loadCustomDropdownOptions(t,e,n){return(0,h.cloneDeep)(this.customDropdownOptionsLoaders[t](e,n))}async sendConnectRequest(t,e){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];var r;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 i=`${null!==(r=null==e?void 0:e.baseURLOverride)&&void 0!==r?r:this.environments.ZEUS_PUBLIC_URL}${n?`/projects/${this.projectId}`:""}${t}`,o=(0,y.hash)(JSON.stringify({url:i,payload:{...e}})),s=await this.cachedApiResponse.get(o,!0);if((null==e?void 0:e.cacheResult)&&s)return s;const a=Boolean(!e||"GET"===e.method||e.cacheResult);if(a&&"object"==typeof this.keyToRequestPromiseMap[o])return this.keyToRequestPromiseMap[o];const l=this.userState.token,c=this.modalState.integration&&this.integrationToBeEnabled?this.userState.integrations[this.integrationToBeEnabled]:void 0,d=new Promise(((t,n)=>{(async()=>{try{const n=await this.sendRequest(i,{...e,headers:{Accept:"application/json","Content-Type":"application/json",[p.SDK_VERSION_HEADER]:this.sdkVersion,...!(null==e?void 0:e.skipDefaultCredentialIdHeader)&&(null==c?void 0:c.credentialId)?{[p.SELECTED_CREDENTIAL_ID_HEADER]:null==c?void 0:c.credentialId}:{},...null==e?void 0:e.headers,Authorization:`Bearer ${l}`}},a?o:void 0);t(n)}catch(t){n(t)}})()}));return a&&(this.keyToRequestPromiseMap[o]=d),d}async sendRequest(t,e,n){var r;let i,s,a;try{i=await fetch(t,e)}catch(t){a=t}if(i&&!i.ok||a){const e=i?await(0,I.getErrorMessage)(i,!0):null==a?void 0:a.message,s="string"==typeof e?e:null==e?void 0:e.message,l=(0,I.errorMessageParser)(s),c="object"==typeof e&&e.response.code===o.INSUFFICIENT_PERMISSION,d="object"==typeof e&&[o.BYO_CREDENTIAL_VERIFICATION_ERROR,o.BYO_USER_PROFILE_ERROR_CODE].includes(e.response.code),u=401===(null==i?void 0:i.status)||403===(null==i?void 0:i.status),h=!l&&!c&&!d&&u;if(h&&!t.includes("proxy"))this.logout();else if(h&&t.includes("proxy")){const t=await this.fetchUserData();this.updateAuthenticatedUser({integrations:t.integrations,meta:t.meta,resources:t.resources})}if(n&&(await this.cachedApiResponse.del(n),delete this.keyToRequestPromiseMap[n]),"string"!=typeof e&&t.includes("proxy"))throw null===(r=e.response)||void 0===r||delete r.headers,new I.ProxyRequestError(e.message,e.response);throw new Error("string"==typeof e?s:JSON.stringify(e.response))}try{s=await(null==i?void 0:i.json())}catch{s=void 0}return n&&(await this.cachedApiResponse.set(n,s),delete this.keyToRequestPromiseMap[n]),s}async request(t,e,n){const r=`/sdk/proxy/${t}`,i=e.startsWith("/")?e:`/${e}`,o=n.selectedCredentialId,s=await this.sendConnectRequest(`${r}${i}`,{method:n.method,body:"object"==typeof n.body?JSON.stringify(n.body):n.body,headers:{"Content-Type":p.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS,...o?{[p.SELECTED_CREDENTIAL_ID_HEADER]:o}:{},...n.headers},baseURLOverride:this.environments.WORKER_PROXY_PUBLIC_URL,skipDefaultCredentialIdHeader:!0});return null==s?void 0:s.output}async event(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{selectedConfigurationId:r,selectedCredentialId:i}=n;if(r&&!i)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:{...i?{[p.SELECTED_CREDENTIAL_ID_HEADER]:i}:{},...r?{[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:r}:{}},body:JSON.stringify({name:t,payload:e}),skipDefaultCredentialIdHeader:!0,baseURLOverride:this.environments.HERMES_PUBLIC_URL},!1)}onClose(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{integration:n,apiInstallationOptions:r}=this.modalState;n&&(this.triggerSDKEvent({type:p.SDK_EVENT.ON_PORTAL_CLOSE,integrationId:n.id,integrationType:(0,l.getIntegrationTypeName)(n)}),this.originalBodyOverflow!==e.PARAGON_OVERFLOW_EMPTY_VALUE&&(window.document.body.style.overflow=this.originalBodyOverflow,this.originalBodyOverflow=e.PARAGON_OVERFLOW_EMPTY_VALUE),!t&&(null==r?void 0:r.isApiInstallation)||(this.setModalState({integration:null}),this.integrationToBeEnabled=void 0))}onOpen(){const{integration:t}=this.modalState;if(t&&(this.triggerSDKEvent({type:p.SDK_EVENT.ON_PORTAL_OPEN,integrationId:t.id,integrationType:(0,l.getIntegrationTypeName)(t)}),this.root&&this.originalBodyOverflow===e.PARAGON_OVERFLOW_EMPTY_VALUE)){const t=this.root.getBoundingClientRect();window.innerHeight<=t.height&&window.innerWidth<=t.width&&(this.originalBodyOverflow=window.document.body.style.overflow,window.document.body.style.overflow="hidden")}}triggerSDKEvent(t){this.triggerEvent(t,this.userState)}getIntegrationMetadata(t){const e=t=>{return{...t,icon:(e=t.icon,e.includes(".svg")?(null===(n=e.split(".svg"))||void 0===n?void 0:n[0])+".svg":e)};var e,n};if(t){const n=this.metadata[t];if(!n)throw new Error(`${t} is not a valid integration name`);return e(n)}return(0,h.cloneDeep)(Object.values(this.metadata).map(e))}closePortal(){this.onClose(!0)}workflow(t){let{selectedCredentialId:e,selectedConfigurationId:n,body:r={},query:i={},headers:o={}}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var s;if(!t)throw new Error("workflowId is required.");const a=new URLSearchParams(i).toString(),{integrationState:l}=this.getIntegrationForWorkflow(t);let c;if((e||n)&&(c=this.getCredentialAndConfig({selectedCredentialId:e,selectedConfigurationId:n},l,{throwIfMultipleConfigsFound:!0}),!c||!(null===(s=c.selectedConfig.workflowSettings[t])||void 0===s?void 0:s.enabled)))throw new Error(`Workflow ${t} is not enabled for this user.`);return this.sendConnectRequest(`/sdk/triggers/${t}?${a}`,{method:"POST",body:JSON.stringify(r),headers:{...c?{[p.SELECTED_CREDENTIAL_ID_HEADER]:c.selectedCredential.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:c.selectedConfig.id}:{},...o},skipDefaultCredentialIdHeader:!0,baseURLOverride:this.environments.HERMES_PUBLIC_URL},!0)}installIntegration(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;this.closePortal();const n={showPortalAfterInstall:!1,bypassPostOAuthPrompt:!1,allowMultipleCredentials:!1,...e,isApiInstallation:!0};if(n.bypassPostOAuthPrompt&&n.showPortalAfterInstall)throw new Error("Could not use both `bypassPostOAuthPrompt` and `showPortalAfterInstall` as true at the same time.");if(this.ensureHeadlessIsSupported(),this.validateAction(t),!n.allowMultipleCredentials&&this.isAlreadyInstalled(t,this.userState))throw new Error(`Integration "${t}" is already installed.`);if(e.showPortalAfterInstall){const e=Object.values(this.loadedIntegrations).find((e=>(0,l.getIntegrationTypeName)(e)===t));this.setModalState({integration:e,config:this.loadedConfigs[t],apiInstallationOptions:n,shouldShowPortalAfterInstall:!1})}else this.setModalState({integration:null});return this.connect(t,n)}ensureHeadlessIsSupported(){if(!this.project.accessibleFeatures.includes(p.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(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=null==e?void 0:e.selectedCredentialId;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;if(this.ensureHeadlessIsSupported(),this.validateAction(t),!this.hasCredential(t,this.userState,e.selectedCredentialId))throw new g.IntegrationNotInstalledError(t);const r=this.loadedIntegrations[t].id,i=this.userState.integrations[t],o=n||(null==i?void 0:i.credentialId);if(!o||!i)throw new Error("No credential found for uninstall");await this.sendConnectRequest(`/sdk/integrations/${r}`,{method:"DELETE",headers:{...o?{[p.SELECTED_CREDENTIAL_ID_HEADER]:o}:{}}}),this.updateAuthenticatedUser({integrations:{...this.userState.integrations,[t]:(0,d.getActionStateForCredentialDelete)(o,i)}}),n===this.modalState.selectedCredentialId&&this.setModalState({integration:null,selectedCredentialId:void 0}),this.saveState(),this.triggerSDKEvent({type:p.SDK_EVENT.ON_INTEGRATION_UNINSTALL,integrationId:r,integrationType:t})}async disableWorkflow(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;const{selectedCredentialId:r,selectedConfigurationId:i}=e,{integration:o,integrationState:s}=this.getIntegrationForWorkflow(t),a=this.getCredentialAndConfig(r||i?{selectedCredentialId:r,selectedConfigurationId:i}:{selectedCredentialId:s.credentialId},s);if(!a||!(null===(n=a.selectedConfig.workflowSettings[t])||void 0===n?void 0:n.enabled))throw new Error(`Workflow ${t} cannot be disabled for this user.`);const{selectedConfig:l,selectedCredential:c}=a;await this.sendConnectRequest(`/sdk/workflows/${t}`,{method:"DELETE",headers:{[p.SELECTED_CREDENTIAL_ID_HEADER]:c.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:l.id}});const d={...l,workflowSettings:{...l.workflowSettings,[t]:{settings:{},...l.workflowSettings[t],enabled:!1}}},u={...c,configurations:c.configurations.filter((t=>t.id!==l.id)).concat(d)};this.updateCredentialData(u,o)}async enableWorkflow(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;const{selectedCredentialId:r,selectedConfigurationId:i}=e,{integration:o,integrationState:a}=this.getIntegrationForWorkflow(t),l=this.getCredentialAndConfig(r||i?{selectedCredentialId:r,selectedConfigurationId:i}:{selectedCredentialId:a.credentialId},a);if(!l||(null==l?void 0:l.selectedCredential.status)!==s.CredentialStatus.VALID)throw new Error("Valid credential not found for provided options.");const{selectedConfig:c,selectedCredential:d}=l;if(null===(n=c.workflowSettings[t])||void 0===n?void 0:n.enabled)throw new Error(`Workflow ${t} is already enabled for this user.`);await this.sendConnectRequest(`/sdk/workflows/${t}`,{method:"POST",headers:{[p.SELECTED_CREDENTIAL_ID_HEADER]:d.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:c.id}});const u={...c,workflowSettings:{...c.workflowSettings,[t]:{settings:{},...c.workflowSettings[t],enabled:!0}}},h={...d,configurations:d.configurations.filter((t=>t.id!==c.id)).concat(u)};this.updateCredentialData(h,o)}async getIntegrationAccount(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;this.validateAction(t);const r=null===(n=this.userState.integrations[t])||void 0===n?void 0:n.allCredentials;if(!(null==r?void 0:r.length))throw new Error("Connect credential not found");const i=await this.sendConnectRequest(`/sdk/credentials?integration=${t}&includeAccountAuth=${e.includeAccountAuth}`,{method:"GET",headers:e.selectedCredentialId?{[p.SELECTED_CREDENTIAL_ID_HEADER]:e.selectedCredentialId}:{}});if(!i)throw new Error("Integration not connected");return i}getIntegrationForWorkflow(t){if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;const e=Object.values(this.loadedIntegrations).find((e=>{const n=e.configs[0].values;return t in(n.workflowMeta||{})}));if(!e)throw new Error("Workflow not found in the configured integrations in your Paragon project.");const n=(0,l.getIntegrationTypeName)(e)?this.userState.integrations[(0,l.getIntegrationTypeName)(e)]:void 0;if(!n||!n.allCredentials.some((t=>{let{status:e}=t;return e===s.CredentialStatus.VALID})))throw new Error(`Integration "${(0,l.getIntegrationTypeName)(e)}" not enabled for workflow."`);return{integration:e,integrationState:n}}async updateLocalState(t){var e,n;const[r,i]=await Promise.all([this.fetchUserData(t),this.fetchIntegrations()]);this.project=r.project;let o={...r.integrations};if(this.modalState.integration&&this.integrationToBeEnabled){const t=this.userState.integrations[this.integrationToBeEnabled],r=null==t?void 0:t.credentialConfigId,i=null==t?void 0:t.credentialId;let s;if(r)s=null===(e=o[this.integrationToBeEnabled])||void 0===e?void 0:e.allConfigurations.find((t=>{let{id:e}=t;return e===r}));else if(i){const t=null===(n=o[this.integrationToBeEnabled])||void 0===n?void 0:n.allCredentials.find((t=>{let{id:e}=t;return e===i}));s=t?t.configurations.find((t=>t.isDefault)):void 0}s&&(o={...o,[this.integrationToBeEnabled]:{enabled:!1,allConfigurations:[],allCredentials:[],...o[this.integrationToBeEnabled],credentialId:s.connectCredentialId,credentialConfigId:s.id,workflowSettings:s.workflowSettings,configuredWorkflows:s.workflowSettings,sharedSettings:s.sharedSettings,configMeta:s.configMeta}})}this.updateAuthenticatedUser({integrations:o,meta:r.meta,resources:r.resources}),this.updateIntegrations(i),this.saveState()}async fetchUserData(t){const e=await this.sendConnectRequest("/sdk/me",{headers:(0,v.getHeadersForUserMeta)(t)});if(!e)throw new Error("Unable to get user Data");return{...e,integrations:Object.fromEntries(Object.entries(e.integrations).map((t=>{let[e,n]=t;const r=n.allCredentials.flatMap((t=>{let{configurations:e}=t;return e}));return[e,{...n,allConfigurations:r}]})))}}async fetchIntegrations(){const t=await this.sendConnectRequest("/sdk/integrations");if(!t)throw new Error("Unable to fetch integrations");return t}getIntegrationIcon(t){if(!t.customIntegration){const e=p.overrideActionAlias[t.type]||t.type;return`${this.environments.CDN_PUBLIC_URL}/integrations/${e}.svg`}return t.customIntegration.icon?t.customIntegration.icon:`${this.environments.CDN_PUBLIC_URL}/images/icons/byo-placeholder.svg`}updateIntegrations(t){t.forEach((t=>{var e;if(t.configs.length)try{const n=(0,l.getIntegrationTypeName)(t);this.loadedConfigs[n]=t.configs[0].values,this.loadedIntegrations[n]={...t,type:t.type.startsWith("custom.")?o.ACTION_CUSTOM:t.type},Boolean(t.isActive)&&(this.metadata[n]={type:n,name:t.name,brandColor:t.brandColor,icon:this.getIntegrationIcon(t)}),(null===(e=this.modalState.integration)||void 0===e?void 0:e.id)===t.id&&this.setModalState({integration:{...t,type:t.type.startsWith("custom.")?o.ACTION_CUSTOM:t.type}})}catch(t){console.warn(t)}}))}async setUserMetadata(t){return await this.sendConnectRequest("/sdk/me",{method:"PATCH",body:JSON.stringify({meta:t})}),await this.updateLocalState(),this.render(),this.userState}configureGlobal(t,e){var n,r,i,o,s,a,l,c;if(!t||!t.host)throw new Error("host not specified");const d=t.host.indexOf("http")>-1?new URL(t.host).hostname:t.host;this.environments.CONNECT_PUBLIC_URL=null!==(n=null==e?void 0:e.CONNECT_PUBLIC_URL)&&void 0!==n?n:(0,I.getServiceUrl)("connect",d),this.environments.DASHBOARD_PUBLIC_URL=null!==(r=null==e?void 0:e.DASHBOARD_PUBLIC_URL)&&void 0!==r?r:(0,I.getServiceUrl)("dashboard",d),this.environments.HERMES_PUBLIC_URL=null!==(i=null==e?void 0:e.HERMES_PUBLIC_URL)&&void 0!==i?i:(0,I.getServiceUrl)("hermes",d),this.environments.PASSPORT_PRODUCTION_URL=null!==(o=null==e?void 0:e.PASSPORT_PRODUCTION_URL)&&void 0!==o?o:(0,I.getServiceUrl)("passport",d),this.environments.PASSPORT_PUBLIC_URL=null!==(s=null==e?void 0:e.PASSPORT_PUBLIC_URL)&&void 0!==s?s:(0,I.getServiceUrl)("passport",d),this.environments.ZEUS_PUBLIC_URL=null!==(a=null==e?void 0:e.ZEUS_PUBLIC_URL)&&void 0!==a?a:(0,I.getServiceUrl)("zeus",d),this.environments.CDN_PUBLIC_URL=null!==(l=null==e?void 0:e.CDN_PUBLIC_URL)&&void 0!==l?l:(0,I.getServiceUrl)("dashboard",d),this.environments.WORKER_PROXY_PUBLIC_URL=null!==(c=null==e?void 0:e.WORKER_PROXY_PUBLIC_URL)&&void 0!==c?c:(0,I.getServiceUrl)("worker-proxy",d),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(t,e){var n;if(!this.userState.authenticated)throw new Error("Authentication is required");if(!e||!e.authorizationCode)throw new Error("authorizationCode is required");if(e.redirectUrl&&!(0,I.isValidUrl)(e.redirectUrl))throw new Error(`${e.redirectUrl} is not valid url`);this.validateAction(t);const r=Object.values(this.loadedIntegrations).find((e=>(0,l.getIntegrationTypeName)(e)===t)),i=null===(n=e.showPortalAfterInstall)||void 0===n||n,o=await this.sendConnectRequest("/sdk/credentials",{method:"POST",body:JSON.stringify({code:e.authorizationCode,integrationId:r.id,redirectUrl:e.redirectUrl?(0,I.sanitizeUrl)(e.redirectUrl):void 0,integrationOptions:e.integrationOptions||{}})});if(!o)throw new Error("Unable to create credential");this.updateCredentialData(o,r),i&&this.setModalState({integration:r,config:this.loadedConfigs[t],apiInstallationOptions:{}})}updateCredentialData(t,e){var n;const r=this.userState,i=(0,l.getIntegrationTypeName)(e),o=r.integrations[i],a=o.allCredentials.findIndex((e=>{let{id:n}=e;return n===t.id}));a>-1?o.allCredentials[a]=t:o.allCredentials.push(t);const c=Object.values(null!==(n=o.allConfigurations)&&void 0!==n?n:[]).filter((e=>{let{connectCredentialId:n}=e;return n!==t.id})).concat(t.configurations);if(!(-1===a||t.id===o.credentialId||!(!o.credentialConfigId||!t.configurations.some((t=>t.id===o.credentialConfigId)))))return this.updateAuthenticatedUser({integrations:{...r.integrations,[i]:{...o,allConfigurations:c}}}),void this.saveState();const d=o.credentialConfigId?t.configurations.find((t=>o.credentialConfigId===t.id)):t.configurations[0];this.updateAuthenticatedUser({integrations:{...r.integrations,[i]:{...o,allConfigurations:c,credentialStatus:t.status,enabled:t.status===s.CredentialStatus.VALID,credentialId:t.id,providerId:t.providerId,providerData:t.providerData,configMeta:null==d?void 0:d.configMeta,credentialConfigId:null==d?void 0:d.id,externalId:null==d?void 0:d.externalId,sharedSettings:null==d?void 0:d.sharedSettings,workflowSettings:null==d?void 0:d.workflowSettings,configuredWorkflows:null==d?void 0:d.workflowSettings}}}),this.saveState()}async connectAction(t,e){var n;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;const r=null===(n=this.userState.resources.find((e=>t===e.slug)))||void 0===n?void 0:n.id;if(!r)throw new Error(`No resource found with name "${t}".`);if(!e||"object"!=typeof e)throw new Error("payload must be of type object.");const i=await this.sendConnectRequest(`/sdk/resources/${r}/connect`,{method:"POST",body:JSON.stringify(e)});if(!i)throw new Error(`Unable to connect to "${t}".`);return i}async createConfiguration(t){let{credentialId:e,externalId:n}=t;var r,i;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;if(!e)throw new Error('Required options not provided: "credentialId"');const o=this.getCredentialAndConfig({selectedCredentialId:e});if(!o||(null==o?void 0:o.selectedCredential.status)!==s.CredentialStatus.VALID)throw new Error("Valid credential not found for provided options.");const a=await this.sendConnectRequest(`/sdk/credentials/${e}/configurations`,{method:"POST",body:JSON.stringify(n?{externalId:n}:{})});if(!a)throw new Error("Unable to create a configuration for credential.");const l=Object.keys(this.userState.integrations).find((t=>{var e;return null===(e=this.userState.integrations[t])||void 0===e?void 0:e.allCredentials.find((t=>{let{id:e}=t;return e===a.id}))}));if(l){const t=null===(r=this.userState.integrations[l])||void 0===r?void 0:r.allConfigurations.filter((t=>{let{connectCredentialId:e}=t;return e!==a.id})).concat(a.configurations),e=null===(i=this.userState.integrations[l])||void 0===i?void 0:i.allCredentials.map((t=>t.id===a.id?a:t)),n={...this.userState.integrations,[l]:{enabled:!1,...this.userState.integrations[l],allConfigurations:t||[],allCredentials:e||[]}};this.updateAuthenticatedUser({integrations:n})}return[...a.configurations].sort(((t,e)=>new Date(e.dateCreated).getTime()-new Date(t.dateCreated).getTime()))[0]}async destroyConfiguration(t){let{id:e,credentialId:n}=t;var r,i,o,s;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;if(!(null==e?void 0:e.trim())||!(null==n?void 0:n.trim()))throw new Error("One or more required options not provided.");const a=this.getCredentialAndConfig({selectedConfigurationId:e,selectedCredentialId:n});if(!a)throw new Error(`Unable to find credential for configuration: ${e}.`);if(a.selectedConfig.isDefault)throw new Error("Cannot delete default configuration.");await this.sendConnectRequest(`/sdk/credentials/${a.selectedCredential.id}/configurations`,{method:"DELETE",headers:{[p.SELECTED_CREDENTIAL_ID_HEADER]:null==a?void 0:a.selectedCredential.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:null==a?void 0:a.selectedConfig.id}});const l=Object.keys(this.userState.integrations).find((t=>{var e;return null===(e=this.userState.integrations[t])||void 0===e?void 0:e.allCredentials.find((t=>{let{id:e}=t;return e===a.selectedCredential.id}))}));if(l){const{selectedConfig:t,selectedCredential:e}=a,n=null===(r=this.userState.integrations[l])||void 0===r?void 0:r.allConfigurations.filter((e=>{let{id:n}=e;return n!==t.id})),c=null===(i=this.userState.integrations[l])||void 0===i?void 0:i.allCredentials.map((n=>n.id!==e.id?n:{...n,configurations:n.configurations.filter((e=>{let{id:n}=e;return n!==t.id}))})),d={...this.userState.integrations,[l]:{enabled:!1,...this.userState.integrations[l],allConfigurations:n||[],allCredentials:c||[]}};this.updateAuthenticatedUser({integrations:d}),(null===(o=this.userState.integrations[l])||void 0===o?void 0:o.credentialId)===e.id&&(null===(s=this.userState.integrations[l])||void 0===s?void 0:s.credentialConfigId)===t.id&&this.closePortal()}}async updateConfiguration(t){let{id:e,credentialId:n,meta:r={}}=t;var i,o;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;if(!(null==e?void 0:e.trim())||!(null==n?void 0:n.trim()))throw new Error("One or more required options not provided.");const s=this.getCredentialAndConfig({selectedConfigurationId:e,selectedCredentialId:n});if(!(null==s?void 0:s.selectedConfig))throw new Error(`Cannot find credential configuration with given id: "${e}"`);const a=await this.sendConnectRequest(`/sdk/credentials/${s.selectedConfig.connectCredentialId}/configurations`,{method:"PATCH",body:JSON.stringify({meta:r}),headers:{[p.SELECTED_CREDENTIAL_ID_HEADER]:s.selectedCredential.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:s.selectedConfig.id}});if(!a)throw new Error("Unable to update configuration.");const l=Object.keys(this.userState.integrations).find((t=>{var e;return null===(e=this.userState.integrations[t])||void 0===e?void 0:e.allCredentials.find((t=>{let{id:e}=t;return e===a.id}))}));if(l){const t=null===(i=this.userState.integrations[l])||void 0===i?void 0:i.allConfigurations.filter((t=>{let{connectCredentialId:e}=t;return e!==a.id})).concat(a.configurations),e=null===(o=this.userState.integrations[l])||void 0===o?void 0:o.allCredentials.map((t=>t.id===a.id?a:t)),n={...this.userState.integrations,[l]:{enabled:!1,...this.userState.integrations[l],allConfigurations:t||[],allCredentials:e||[]}};this.updateAuthenticatedUser({integrations:n})}const c=a.configurations.find((t=>{let{id:e}=t;return e===s.selectedConfig.id}));return c}async pollForCredential(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var r;const i=Date.now(),o=async()=>{try{return await this.sendConnectRequest(`/sdk/actions/session-id/${e}`,{method:"GET"})}catch(t){return console.error("error",t),null}};try{const e=await(0,E.tryUntil)(o,((t,e)=>{var r;return!(null===(r=n.abortSignal)||void 0===r?void 0:r.aborted)&&!(Date.now()-i>=u.MAX_POLL_DURATION||(null==t?void 0:t.connectCredentialId))}),1e3);if(!e||!e.connectCredentialId)return;const a=null===(r=this.userState.integrations[t])||void 0===r?void 0:r.allCredentials.find((t=>t.id===e.connectCredentialId)),l=this.getIntegrationByName(t);if(n.onSuccess&&n.onSuccess({integrationId:l.id,integrationType:t,credentialId:e.connectCredentialId,credential:a}),a&&a.status===s.CredentialStatus.VALID)return void this.triggerSDKEvent({type:p.SDK_EVENT.ON_INTEGRATION_INSTALL,integrationId:l.id,integrationType:t});const c=await this.sendConnectRequest(`/sdk/credentials/${e.connectCredentialId}`,{method:"GET"});if(!c)return;this.updateCredentialData(c,this.loadedIntegrations[t]),c.status===s.CredentialStatus.VALID&&this.triggerSDKEvent({type:p.SDK_EVENT.ON_INTEGRATION_INSTALL,integrationId:l.id,integrationType:t})}catch(t){n.onError&&n.onError(t)}finally{await this.sendConnectRequest(`/sdk/actions/session-id/${e}`,{method:"DELETE"})}}async getCustomWebhookUserManualUrl(t,e){var n;const r=this.userState;if(!r.authenticated)throw new g.UserNotAuthenticatedError;const{workflow:i,type:o}=Object.values(this.loadedIntegrations).reduce(((e,n)=>{if(e.workflow)return e;const r=n.workflows.find((e=>e.id===t));return r?{workflow:r,type:n.type}:e}),{workflow:void 0,type:void 0});if(!i)throw new Error(`Unable to get workflow for "${t}".`);if(!o)throw new Error(`Unable to get integration type for "${t}".`);let s=i.integrationId,a=null!=e?e:null===(n=r.integrations[o])||void 0===n?void 0:n.credentialId;if(i.resourceId){const t=r.resources.find((t=>t.id===i.resourceId));s=null==t?void 0:t.integrationId,a=null==t?void 0:t.credentialId}if(!s)throw new Error(`Unable to find integrationId for "${t}".`);if(!a)throw new Error(`Unable to find credentialId for "${t}".`);return`${this.environments.HERMES_PUBLIC_URL}/triggers/connect/${this.projectId}/${s}/custom-triggers/${i.customWebhookTriggerId}?id=${a}`}getIntegrationConfig(t){var e,n;if(!t)throw new Error("Integration is required.");const r=this.loadedIntegrations[t],i=(0,h.cloneDeep)(r.configs[0].values),o=[],s=[],a=new Map(r.workflows.map((t=>[t.id,t]))),l=null!==(e=r.noPermissionWorkflows)&&void 0!==e?e:[];return Object.values(i.workflowMeta||{}).map((t=>{var e;if(!a.has(t.id)&&!l.includes(t.id))return;const n=null===(e=a.get(t.id))||void 0===e?void 0:e.description;t.hidden||t.permissions&&l.includes(t.id)?o.push({...t,description:n}):s.push({...t,description:n})})),{shortDescription:i.description,longDescription:i.overview,availableUserSettings:null===(n=i.sharedMeta)||void 0===n?void 0:n.inputs,availableWorkflows:s,hiddenWorkflows:o}}getIntegrationCredential(t){let{integration:e,settings:n}=t;const{selectedCredentialId:r,selectedConfigurationId:i}=n,o=this.userState.integrations[e];if(!o)throw new Error(`Integration "${e}" state not found.`);const a=this.getCredentialAndConfig(r||i?{selectedCredentialId:r,selectedConfigurationId:i}:{selectedCredentialId:o.credentialId},o);if(!a||(null==a?void 0:a.selectedCredential.status)!==s.CredentialStatus.VALID)throw new Error("Valid credential not found for provided options.");return a}async updateIntegrationUserSettings(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var r;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;this.validateAction(t);const{selectedConfig:i,selectedCredential:o}=this.getIntegrationCredential({integration:t,settings:n}),s=this.userState.token,a=null===(r=this.userState.integrations[t])||void 0===r?void 0:r.sharedSettings,l=await this.sendConnectRequest(`/sdk/credentials/${o.id}`,{method:"PATCH",headers:{Authorization:`Bearer ${s}`,[p.SELECTED_CREDENTIAL_ID_HEADER]:o.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:i.id},body:JSON.stringify({config:{sharedSettings:{...a,...e}}})});if(!l)throw new Error(`Failed to update settings for ${t}.`);if(l.credential){const e=this.loadedIntegrations[t];this.updateCredentialData(l.credential,e)}return{userState:this.userState,errors:l.errors||[]}}async updateWorkflowUserSettings(t,e,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};var i;if(!this.userState.authenticated)throw new g.UserNotAuthenticatedError;this.validateAction(t);const{selectedConfig:o,selectedCredential:s}=this.getIntegrationCredential({integration:t,settings:r}),a=this.userState.token,l=structuredClone(null===(i=this.userState.integrations[t])||void 0===i?void 0:i.workflowSettings),c=null==l?void 0:l[e];if(!c)throw new Error("The workflow needs to be enabled in order to add workflow level user settings.");for(const t in n)c.settings[t]=n[t];const d=await this.sendConnectRequest(`/sdk/credentials/${s.id}`,{method:"PATCH",headers:{Authorization:`Bearer ${a}`,[p.SELECTED_CREDENTIAL_ID_HEADER]:s.id,[p.SELECTED_CREDENTIAL_CONFIG_ID_HEADER]:o.id},body:JSON.stringify({config:{workflowSettings:l}})});if(!d)throw new Error(`Failed to update settings for ${t}.`);if(d.credential){const e=this.loadedIntegrations[t];this.updateCredentialData(d.credential,e)}return{userState:this.userState,errors:d.errors||[]}}async updateWorkflowState(t,e){const n=[];for(const[r,i]of Object.entries(t))try{i?await this.enableWorkflow(r,e):await this.disableWorkflow(r,e)}catch(t){n.push({workflowId:r,message:t.message})}return{user:this.getUser(),errors:n}}async getFieldOptions(t){let{integration:e,action:n,search:r,cursor:i,parameters:o=[]}=t;this.validateAction(e);const s=await this.sendConnectRequest("/sdk/actions",{method:"POST",body:JSON.stringify({action:e,sourceKey:n,parameters:o,paginationParameters:{pageCursor:null!=i?i:0,search:r}})});let a=[],l=[];const c=s.output.records||s.output;return c[0]&&"id"in c[0]?l=c:a=c,{data:a,nestedData:l,nextPageCursor:s.output.nextPageCursor||null}}async getDataSourceOptions(t,e){var n;const r=this.getIntegrationByName(t);return(0,h.cloneDeep)(null===(n=r.sdkIntegrationConfig)||void 0===n?void 0:n.dataSources[e])}setCustomDropdownOptions(t,e){if(!this.loadedConfigs[t])return void console.warn(`Integration config for "${t}" is not loaded. Data sources will be applied when the integration is loaded.`);const n=JSON.parse(JSON.stringify(this.loadedConfigs[t]));return this.loadedConfigs[t]=this.applyCustomDropdownOptions(n,e),this.loadedConfigs[t]}getCustomDropdownOptions(t,e){var n;if(!this.loadedConfigs[t])throw new Error(`Integration config for "${t}" is not loaded. Please load the integration first.`);const r=[],i=this.loadedConfigs[t],o=new Set;if(null===(n=i.sharedMeta)||void 0===n?void 0:n.inputs)for(const t of i.sharedMeta.inputs)e&&t.key!==e||void 0!==t.customDropdownOptions&&(o.add(t.key),this.customDropdownOptionsLoaders[t.key]?r.push({fieldKey:t.key,source:"shared",type:"dynamic",loadOptions:this.customDropdownOptionsLoaders[t.key]}):Array.isArray(t.customDropdownOptions)&&r.push({fieldKey:t.key,source:"shared",type:"static",options:(0,h.cloneDeep)(t.customDropdownOptions)}));if(i.workflowMeta)for(const t in i.workflowMeta){const n=i.workflowMeta[t];if(n.inputs)for(const i of n.inputs)e&&i.key!==e||void 0!==i.customDropdownOptions&&(o.add(i.key),this.customDropdownOptionsLoaders[i.key]?r.push({fieldKey:i.key,source:"workflow",workflowId:t,type:"dynamic",loadOptions:this.customDropdownOptionsLoaders[i.key]}):Array.isArray(i.customDropdownOptions)&&r.push({fieldKey:i.key,source:"workflow",workflowId:t,type:"static",options:(0,h.cloneDeep)(i.customDropdownOptions)}))}for(const t in this.customDropdownOptionsLoaders)e&&t!==e||o.has(t)||r.push({fieldKey:t,source:"shared",type:"dynamic",loadOptions:this.customDropdownOptionsLoaders[t]});for(const t in this.customDropdownOptionsStatic)e&&t!==e||o.has(t)||r.push({fieldKey:t,source:"shared",type:"static",options:(0,h.cloneDeep)(this.customDropdownOptionsStatic[t])});return r}getAccountTypeOptions(t){var e,n,r;const i=this.getIntegrationBySlug(t);return null!==(r=(0,h.cloneDeep)(null!==(n=null===(e=i.sdkIntegrationConfig)||void 0===e?void 0:e.accountTypes)&&void 0!==n?n:[]))&&void 0!==r?r:[]}getPreOptions(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";var n,r,i,o;const s=(0,h.cloneDeep)(this.getIntegrationBySlug(t));if(s.customIntegration)return s.authenticationType===a.AuthenticationScheme.OAUTH_CLIENT_CREDENTIAL?(0,h.cloneDeep)(A):null!==(n=s.customIntegration.inputFields)&&void 0!==n?n:[];const l=this.getAccountTypeOptions(t);if(null==l?void 0:l.length){const t=null==l?void 0:l.find((t=>t.id===e));if(null===(r=null==t?void 0:t.endUserSuppliedValues)||void 0===r?void 0:r.length)return(0,h.cloneDeep)(t.endUserSuppliedValues)}return(null===(o=null===(i=s.sdkIntegrationConfig)||void 0===i?void 0:i.authConfigInputs)||void 0===o?void 0:o.length)?s.sdkIntegrationConfig.authConfigInputs:[]}getPostOptions(t){var e,n;const r=this.getIntegrationBySlug(t);return null!==(n=(0,h.cloneDeep)(null===(e=r.sdkIntegrationConfig)||void 0===e?void 0:e.postOauthInputs))&&void 0!==n?n:[]}async _fetchBYOFieldMappingOptions(t,e,n,r){var i;const o=null===(i=this.dynamicFieldMappingLoaders[t])||void 0===i?void 0:i[n];if(!o)throw new Error(`No dynamic field mapping loader found for key: ${n}`);if(e===p.DynamicFieldMappingLoaderType.OBJECT_TYPES)return await o.objectTypes(null==r?void 0:r.cursor,null==r?void 0:r.search);if(e===p.DynamicFieldMappingLoaderType.INTEGRATION_FIELDS){if(!(null==r?void 0:r.objectType))throw new Error("objectType is required for integrationFields");return await o.integrationFields({objectType:r.objectType},r.cursor,r.search)}throw new Error(`Invalid type: ${e}. Must be 'objectTypes' or 'integrationFields'`)}}e.default=C;class O{constructor(t){this.paragon=t,this.startOptions=null,this.integrationName=null,this.accountTypeValue=null,this.preOptionsValue=null,this.postOptionsValue=null,this.credentialId=null}start(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.asyncStart(t,e).catch((t=>{this.handleError(t)}))}async cancel(){this.startOptions=null,this.accountTypeValue=null,this.preOptionsValue=null,this.postOptionsValue=null;try{if(this.credentialId&&this.integrationName&&await this.paragon.uninstallIntegration(this.integrationName,{selectedCredentialId:this.credentialId}),!this.credentialId&&!this.integrationName){const t=new g.NoActiveInstallFlowError;console.warn(t.message)}}catch(t){console.error("Error cancelling the current install flow",{credentialId:this.credentialId,integration:this.integrationName},t)}finally{this.integrationName=null,this.credentialId=null}}getInstallOptions(){var t,e,n,r,i,o;return{allowMultipleCredentials:null!==(e=null===(t=this.startOptions)||void 0===t?void 0:t.allowMultipleCredentials)&&void 0!==e&&e,overrideRedirectUrl:null!==(r=null===(n=this.startOptions)||void 0===n?void 0:n.overrideRedirectUrl)&&void 0!==r?r:void 0,selectedCredentialId:null!==(o=null===(i=this.startOptions)||void 0===i?void 0:i.selectedCredentialId)&&void 0!==o?o:void 0}}async asyncStart(t,e){if(this.startOptions=e,this.integrationName=t,this.accountTypeValue=null,this.preOptionsValue=null,this.postOptionsValue=null,this.credentialId=null,!this.paragon.isHeadless)throw new g.HeadlessModeNotEnabledError;const n=this.next();if("done"===n.stage||"postOptions"===n.stage){const r=await this.paragon.installIntegration(t,{oauthTimeout:null==e?void 0:e.oauthTimeout,...this.getInstallOptions()});if("done"===n.stage&&r)return void this.handleComplete(r);(null==r?void 0:r.credentialId)&&(this.credentialId=r.credentialId)}this.handleNext(n)}handleError(t,e){var n,r;const i=(0,g.getConnectSDKError)(t);null===(r=null===(n=this.startOptions)||void 0===n?void 0:n.onError)||void 0===r||r.call(n,i,null!=e?e:null)}handleNext(t){var e,n;null===(n=null===(e=this.startOptions)||void 0===e?void 0:e.onNext)||void 0===n||n.call(e,t)}handleComplete(t){var e,n;null===(n=null===(e=this.startOptions)||void 0===e?void 0:e.onComplete)||void 0===n||n.call(e,t)}getScheme(){var t,e;if(null===this.integrationName)return null;if(!this.accountTypeValue)return null!==(t=this.paragon.getIntegrationBySlug(this.integrationName).authenticationType)&&void 0!==t?t:null;const n=this.getSelectedAccountTypeOption();return null!==(e=null==n?void 0:n.scheme)&&void 0!==e?e:null}getIntegrationName(){if(!this.integrationName)throw new g.NoActiveInstallFlowError;return this.integrationName}getSelectedAccountTypeOption(){var t;return null===(t=this.paragon.getAccountTypeOptions(this.getIntegrationName()))||void 0===t?void 0:t.find((t=>t.id===this.accountTypeValue))}requiresAccountType(){const t=this.paragon.getAccountTypeOptions(this.getIntegrationName());return!(!t||0===t.length)&&!this.accountTypeValue}requiresPreOptions(){var t;const e=this.paragon.getPreOptions(this.getIntegrationName(),null!==(t=this.accountTypeValue)&&void 0!==t?t:void 0);return!(!e||0===e.length)&&!this.preOptionsValue}requiresPostOptions(){var t,e;if(null!==(e=null===(t=this.getSelectedAccountTypeOption())||void 0===t?void 0:t.skipPostOAuthInputs)&&void 0!==e&&e)return!1;const n=this.paragon.getPostOptions(this.getIntegrationName());return!(!n||0===n.length)&&!this.postOptionsValue}async handleOAuth(){let{accountType:t,endUserSuppliedValues:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=await new Promise(((n,r)=>{var i;const o=this.getInstallOptions();this.paragon.startOAuthFlow(this.getIntegrationName(),{accountType:t,endUserSuppliedValues:e,allowMultipleCredentials:o.allowMultipleCredentials,selectedCredentialId:o.selectedCredentialId,userProvidedIntegrationConfig:{overrideRedirectUrl:o.overrideRedirectUrl?(0,I.sanitizeUrl)(o.overrideRedirectUrl):void 0}},{onSuccess:t=>n(t),onError:t=>r(t),oauthTimeout:null===(i=this.startOptions)||void 0===i?void 0:i.oauthTimeout})}));if(!n||!n.credentialId)throw new Error("Could not find a credential ID");return this.credentialId=n.credentialId,n}async setAccountType(t){try{this.accountTypeValue=t;const e=this.next();if("preOptions"===e.stage)return void this.handleNext(e);if(this.getScheme()!==a.AuthenticationScheme.OAUTH)return void this.handleNext(e);const n=await this.handleOAuth({accountType:t});"done"===e.stage?this.handleComplete(n):this.handleNext(e)}catch(t){this.handleError(t,{stage:"accountType"})}}async setPreOptions(t){var e,n,r;try{if(!t)throw new Error("Pre options are not set");this.preOptionsValue=t;const i=this.next(),o="done"===i.stage;if(this.getScheme()===a.AuthenticationScheme.OAUTH){const t=await this.handleOAuth({accountType:null!==(e=this.accountTypeValue)&&void 0!==e?e:void 0,endUserSuppliedValues:{...this.preOptionsValue}});return void(o?this.handleComplete(t):this.handleNext(i))}const s=null!==(r=null===(n=this.getSelectedAccountTypeOption())||void 0===n?void 0:n.skipPostOAuthInputs)&&void 0!==r&&r,l=await this.paragon._oauthCallback({payload:{...t,skipPostOAuthInputs:s},integrationId:this.paragon.getIntegrationId(this.getIntegrationName())},void 0,{installOptions:this.getInstallOptions()});if(!o)return void this.handleNext(i);if(!l)return void console.warn("Could not find a credential ID");this.handleComplete(l)}catch(t){this.handleError(t,{stage:"preOptions"})}}async setPostOptions(t){var e,n;try{if(!t)throw new Error("Post options are not set");if(!this.credentialId)throw new Error("Credential ID is not set");this.postOptionsValue=t;const r=null!==(n=null===(e=this.getSelectedAccountTypeOption())||void 0===e?void 0:e.skipPostOAuthInputs)&&void 0!==n&&n,i=await this.paragon._oauthCallback({payload:{...t,skipPostOAuthInputs:r},integrationId:this.paragon.getIntegrationId(this.getIntegrationName())},this.credentialId,{installOptions:this.getInstallOptions()}),o=this.next();if(!("done"===o.stage))return void this.handleNext(o);if(!i)return void console.warn("Could not find a credential ID");this.handleComplete(i)}catch(t){this.handleError(t,{stage:"postOptions"})}}getAccountTypeValue(){return this.accountTypeValue}getPreOptionsValue(){return this.preOptionsValue}getPostOptionsValue(){return this.postOptionsValue}next(){var t;const e=this.getIntegrationName();return this.requiresAccountType()?{stage:"accountType",options:this.paragon.getAccountTypeOptions(e),done:!1}:this.requiresPreOptions()?{stage:"preOptions",options:this.paragon.getPreOptions(e,null!==(t=this.accountTypeValue)&&void 0!==t?t:void 0),done:!1}:this.requiresPostOptions()?{stage:"postOptions",options:this.paragon.getPostOptions(e),done:!1}:{stage:"done",done:!0}}}e.InstallFlow=O;const A=[{id:"clientId",title:"Client ID",type:p.SidebarInputType.ValueText,required:!0},{id:"clientSecret",title:"Client Secret",type:p.SidebarInputType.Password,required:!0}]},9892:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(3821);e.default=class{constructor(){this.eventListenersMap={},this.integrationStateCallbacks={}}subscribe(t,e){var n;if(this.assertEventType(t),"function"!=typeof e)throw new Error(`no listener is provided for ${t}`);return this.eventListenersMap={...this.eventListenersMap,[t]:[...null!==(n=this.eventListenersMap[t])&&void 0!==n?n:[],e]},()=>this.unsubscribe(t,e)}subscribeToIntegration(t,e){this.integrationStateCallbacks[t]={...e}}unsubscribe(t,e){var n,r;if(this.assertEventType(t),"function"!=typeof e)throw new Error("listener is required for unsubscription");const i=(null!==(n=this.eventListenersMap[t])&&void 0!==n?n:[]).length;return this.eventListenersMap={...this.eventListenersMap,[t]:(null!==(r=this.eventListenersMap[t])&&void 0!==r?r:[]).filter((t=>t!==e))},i>this.eventListenersMap[t].length}assertEventType(t){if(!Object.values(r.SDK_EVENT).includes(t))throw new Error(`${t} is not valid paragon event`)}emitSafe(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var i;(null!==(i=this.eventListenersMap[t])&&void 0!==i?i:[]).forEach((t=>{try{t(...n)}catch(t){console.error(t)}}))}emitError(t,e){this.invokeCallbackSafe(e,"onError",t)}invokeCallbackSafe(t,e){var n,r,i;try{for(var o=arguments.length,s=new Array(o>2?o-2:0),a=2;a<o;a++)s[a-2]=arguments[a];null===(r=null===(n=this.integrationStateCallbacks[t])||void 0===n?void 0:n[e])||void 0===r||r.call(n,...s)}catch(t){console.error(t)}finally{null===(i=this.integrationStateCallbacks[t])||void 0===i||delete i[e]}}triggerEvent(t,e){let{type:n,integrationId:i,integrationType:o,workflowId:s,workflowStateChange:a}=t;if(i&&o)switch(n){case r.SDK_EVENT.ON_INTEGRATION_INSTALL:{const t=[{integrationId:i,integrationType:o},e];this.invokeCallbackSafe(o,"onInstall",...t),this.emitSafe(r.SDK_EVENT.ON_INTEGRATION_INSTALL,...t);break}case r.SDK_EVENT.ON_INTEGRATION_UNINSTALL:{const t=[{integrationId:i,integrationType:o},e];this.invokeCallbackSafe(o,"onUninstall",...t),this.emitSafe(r.SDK_EVENT.ON_INTEGRATION_UNINSTALL,...t);break}case r.SDK_EVENT.ON_PORTAL_OPEN:{const t=[{integrationId:i,integrationType:o},e];this.invokeCallbackSafe(o,"onOpen",...t),this.emitSafe(r.SDK_EVENT.ON_PORTAL_OPEN,...t);break}case r.SDK_EVENT.ON_PORTAL_CLOSE:{const t=[{integrationId:i,integrationType:o},e];this.invokeCallbackSafe(o,"onClose",...t),this.emitSafe(r.SDK_EVENT.ON_PORTAL_CLOSE,...t);break}case r.SDK_EVENT.ON_WORKFLOW_CHANGE:{const t=[{integrationId:i,workflowId:s,workflowStateChange:a||{}},e];this.invokeCallbackSafe(o,"onWorkflowChange",...t),this.emitSafe(r.SDK_EVENT.ON_WORKFLOW_CHANGE,...t);break}default:throw new Error(`${n} is not valid event.`)}}}},3931:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PERSONA_META_HEADER=e.BYO_USER_PROFILE_ERROR_CODE=e.BYO_CREDENTIAL_VERIFICATION_ERROR=e.INSUFFICIENT_PERMISSION=e.ACTION_CUSTOM=void 0,e.ACTION_CUSTOM="custom",e.INSUFFICIENT_PERMISSION="7210",e.BYO_CREDENTIAL_VERIFICATION_ERROR="7003",e.BYO_USER_PROFILE_ERROR_CODE="0704",e.PERSONA_META_HEADER="X-Paragon-User-Metadata"},4059:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CredentialStatus=void 0,function(t){t.PENDING="PENDING",t.INVALID="INVALID",t.VALID="VALID"}(e.CredentialStatus||(e.CredentialStatus={}))},745:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AuthenticationScheme=void 0,function(t){t.BASIC="basic",t.OAUTH="oauth",t.OAUTH_CLIENT_CREDENTIAL="oauth_client_credential",t.SERVICE_ACCOUNT="service_account",t.OAUTH_APP="oauth_app",t.IMPERSONATED_APP="impersonated_app"}(e.AuthenticationScheme||(e.AuthenticationScheme={}))},1663:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generateSlugForIntegration=void 0,e.generateSlugForIntegration=function(t){if(!t.name)return;return`custom.${t.name?t.name.replace(/[\W_]+/g,"").trim().toLowerCase():void 0}`}},7343:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isCustomIntegrationTypeName=e.getIntegrationTypeName=void 0;const r=n(3931),i=n(1663);e.getIntegrationTypeName=function(t){if(t.type===r.ACTION_CUSTOM){if(t.customIntegration)return(0,i.generateSlugForIntegration)(t.customIntegration);throw new Error(`Custom integration details are missing from this integration: ${t.id}`)}return t.type},e.isCustomIntegrationTypeName=function(t){return t.startsWith("custom.")}},9845:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MicrosoftPicker=void 0;const r=n(3821),i=n(7473);class o extends i.BaseFilePicker{constructor(t,e){super(t,e),this.options=t,this.connectSDKInstance=e,this.accessToken="",this.baseUrl=""}getInstance(){return null}open(){var t,e;return this.dependencyStatus===r.FilePickerStatus.LOADED&&(null===(e=(t=this.options).onOpen)||void 0===e||e.call(t),this.launchPicker(this.getPickerOptions()),!0)}async initPicker(t,e){let n=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=r.FilePickerStatus.LOADING;const{selectedCredentialId:o,...s}=t||{};this.initOptions=s;const a=await this.connectSDKInstance.getIntegrationAccount(e,{includeAccountAuth:!0,selectedCredentialId:o});return this.accessToken=a.accountAuth[(null===(i=r.AUTH_TOKEN_ALLOWED_INTEGRATIONS[e])||void 0===i?void 0:i.accessTokenPath)||""],this.baseUrl=this.getUrl(a,e),this.initialiseDependencyPromise(),this.injectScript(n),this.dependenciesPromise}onScriptLoaded(){this.dependencyStatus=r.FilePickerStatus.LOADED,this.dependenciesPromise.resolve(!0)}onScriptError(){this.dependencyStatus=r.FilePickerStatus.FAILED,this.dependenciesPromise.reject(new Error("Failed to load dependencies"))}combinePaths(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.map((t=>t.replace(/^[/\\]+|[/\\]+$/g,""))).join("/").replace(/\\/g,"/")}async launchPicker(t){if(!this.accessToken)throw new Error("Access Token is not set! Please re-authenticate your account.");const e={sdk:"8.0",entry:t.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:t.pivots}},n=new URLSearchParams({filePicker:JSON.stringify(e)}).toString(),r=`${this.getPickerUrl(this.baseUrl)}?${n}`,i=window.open("","Picker","width=800,height=600,left=100,top=150");if(!i)throw new Error("Failed to open picker window.");const o=i.document.createElement("form");o.setAttribute("action",r),o.setAttribute("method","POST");const s=i.document.createElement("input");s.setAttribute("type","hidden"),s.setAttribute("name","access_token"),s.setAttribute("value",this.accessToken),o.appendChild(s),i.document.body.appendChild(o),o.submit(),this.setupMessageListener(i,e.messaging.channelId)}initializePort(t,e){t.addEventListener("message",(async n=>{const{type:r,data:i,id:o}=n.data;if("command"===r){const{command:n}=i;this.handlePickerCommand({command:n,id:o,items:i.items},e,t)}})),t.start(),t.postMessage({type:"activate"})}setupMessageListener(t,e){window.addEventListener("message",(n=>{var r;if(n.source===t&&(null===(r=n.data)||void 0===r?void 0:r.channelId)===e){const{type:e,data:r}=n.data;switch(e){case"initialize":const i=n.ports[0];this.initializePort(i,t);break;case"command":this.handlePickerCommand(r,t);break;default:console.warn("Unknown message type:",e)}}}))}handlePickerCommand(t,e,n){var r,i,o,s,a,l;const{command:c,id:d,items:u}=t;switch(c){case"close":null===(i=(r=this.options).onClose)||void 0===i||i.call(r),e.close();break;case"pick":null==n||n.postMessage({type:"result",id:d,data:{result:"success"}}),null===(s=(o=this.options).onFileSelect)||void 0===s||s.call(o,u),null===(l=(a=this.options).onClose)||void 0===l||l.call(a),e.close();break;default:null==n||n.postMessage({type:"error",id:d,data:{message:"Unsupported command",command:c}})}}}e.MicrosoftPicker=o},9008:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BoxFilePicker=void 0;const r=n(3821),i=n(7473),o={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 s extends i.BaseFilePicker{constructor(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(t,e),this.accessToken="",this.config={...o,...n}}getInstance(){var t,e;if(!this.instance){const n=window;if(!this.options.allowFolderSelect&&!(null===(t=n.Box)||void 0===t?void 0:t.FilePicker)||this.options.allowFolderSelect&&!(null===(e=n.Box)||void 0===e?void 0:e.FolderPicker))throw new Error("Box script is not loaded yet. Please wait for initialization to complete.");const r=new n.Box[this.options.allowFolderSelect?"FolderPicker":"FilePicker"]({container:`.${this.config.containerClass}`});if(!r)throw new Error(`Failed to create Box ${this.options.allowFolderSelect?"Folder":"File"}Picker instance`);this.instance=r,this.setupEventListeners()}return this.instance}setupEventListeners(){var t=this;if(!this.instance)return;const e={choose:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];var n,r;null===(r=(n=t.options).onFileSelect)||void 0===r||r.call(n,e),t.cleanup()},cancel:()=>{var t,e;null===(e=(t=this.options).onCancel)||void 0===e||e.call(t),this.cleanup()},close:()=>{var t,e;null===(e=(t=this.options).onClose)||void 0===e||e.call(t),this.cleanup()}};Object.entries(e).forEach((t=>{let[e,n]=t;var r;null===(r=this.instance)||void 0===r||r.addListener(e,n)}))}cleanup(){var t;this.instance&&(this.instance.removeAllListeners(),null===(t=document.querySelector(`.${this.config.containerClass}`))||void 0===t||t.remove())}createPickerContainer(){if(document.querySelector(`.${this.config.containerClass}`))return;const t=document.createElement("div");t.className=this.config.containerClass,Object.entries(this.config.containerStyles).forEach((e=>{let[n,r]=e;t.style[n]=r})),document.body.appendChild(t)}injectCSS(t){const e=document.createElement("link");e.rel="stylesheet",e.href=t,document.head.appendChild(e)}injectGlobalBtnContentCSS(){if(document.getElementById("global-btn-content-style"))return;const t=document.createElement("style");t.id="global-btn-content-style",t.innerHTML="\n .btn-content {\n display: flex !important;\n justify-content: center !important;\n }\n ",document.head.appendChild(t)}open(){var t,e,n;if(this.dependencyStatus===r.FilePickerStatus.LOADED)try{this.instance=void 0;const r=this.getInstance();if(r){const i={...this.config.pickerOptions,container:`.${this.config.containerClass}`,maxSelectable:this.options.allowMultiSelect?void 0:1,extensions:this.options.allowedTypes,canSelectFolder:this.options.allowFolderSelect,...(null===(t=this.options.integrationOptions)||void 0===t?void 0:t.box)||{}};if(this.createPickerContainer(),this.initOptions.folderId)return r.show(this.initOptions.folderId,this.accessToken,i),null===(n=(e=this.options).onOpen)||void 0===n||n.call(e),!0}}catch(t){return!1}return!1}async init(t){this.dependencyStatus=r.FilePickerStatus.LOADING;const{selectedCredentialId:e,...n}=t||{};await this.validateInitOptions(n,[["folderId","Folder ID"]]),this.initOptions={...n};const i=await this.connectSDKInstance.getIntegrationAccount("box",{includeAccountAuth:!0,selectedCredentialId:e}),{accessTokenPath:o=""}=r.AUTH_TOKEN_ALLOWED_INTEGRATIONS.box;return this.accessToken=i.accountAuth[o],this.initialiseDependencyPromise(),this.injectCSS(this.config.cssUrl),this.injectGlobalBtnContentCSS(),this.injectScript(this.config.scriptUrl),this.dependenciesPromise}async launch(){this.dependencyStatus!==r.FilePickerStatus.LOADED&&await this.init(this.initOptions),this.open()}onScriptLoaded(){this.dependencyStatus=r.FilePickerStatus.LOADED,this.instance=void 0,this.dependenciesPromise.resolve(!0)}onScriptError(){this.dependencyStatus=r.FilePickerStatus.FAILED,this.dependenciesPromise.reject(new Error("Failed to load Box script"))}}e.BoxFilePicker=s},9950:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GoogleDriveFilePicker=void 0;const r=n(3821),i=n(7473);class o extends i.BaseFilePicker{constructor(t,e){super(t,e),this.accessToken=""}get google(){return window.google}getInstance(){var t;return null!==(t=this.instance)&&void 0!==t?t:null}open(){var t,e;return!(this.dependencyStatus!==r.FilePickerStatus.LOADED||!this.instance)&&(this.instance.setVisible(!0),null===(e=(t=this.options).onOpen)||void 0===e||e.call(t),!0)}async init(t){this.dependencyStatus=r.FilePickerStatus.LOADING;const{selectedCredentialId:e,...n}=t||{};await this.validateInitOptions(n,[["developerKey","developer key"]]),this.initOptions={...n};const i=await this.connectSDKInstance.getIntegrationAccount("googledrive",{includeAccountAuth:!0,selectedCredentialId:e}),{accessTokenPath:o=""}=r.AUTH_TOKEN_ALLOWED_INTEGRATIONS.googledrive;return this.accessToken=i.accountAuth[o],this.initialiseDependencyPromise(),this.injectScript("https://apis.google.com/js/api.js"),this.dependenciesPromise}onScriptLoaded(){this.dependencyStatus=r.FilePickerStatus.LOADED,window.gapi.load("picker",this.onPickerLoaded.bind(this))}onScriptError(){this.dependencyStatus=r.FilePickerStatus.FAILED,this.dependenciesPromise.reject(new Error("Not able to load dependencies"))}onPickerLoaded(){var t,e,n;const r=new this.google.picker.PickerBuilder;(null===(t=this.initOptions)||void 0===t?void 0:t.appId)&&r.setAppId(this.initOptions.appId),this.options.allowMultiSelect&&r.enableFeature(this.google.picker.Feature.MULTISELECT_ENABLED),this.options.allowedTypes&&this.options.allowedTypes.length>0&&r.setSelectableMimeTypes(this.options.allowedTypes.join(","));const i=this.createDocsView();if(r.addView(i),null===(n=null===(e=this.options.integrationOptions)||void 0===e?void 0:e.googledrive)||void 0===n?void 0:n.enableSharedDrives){const t=this.createDocsView();t.setEnableDrives(!0),r.addView(t)}if(!this.initOptions.developerKey)throw new Error("Please provide a valid developer key");const o=r.setOAuthToken(this.accessToken).setDeveloperKey(this.initOptions.developerKey).setCallback(this.pickerCallback.bind(this));this.initOptions.appId&&o.setAppId(this.initOptions.appId),this.instance=o.build(),this.dependenciesPromise.resolve(!0)}createDocsView(){var t,e,n,r;const i=new this.google.picker.DocsView;return this.options.allowFolderSelect&&(i.setIncludeFolders(!0),i.setSelectFolderEnabled(!0)),(null===(e=null===(t=this.options.integrationOptions)||void 0===t?void 0:t.googledrive)||void 0===e?void 0:e.viewMode)&&i.setMode(this.options.integrationOptions.googledrive.viewMode),(null===(r=null===(n=this.options.integrationOptions)||void 0===n?void 0:n.googledrive)||void 0===r?void 0:r.includeFolders)&&i.setIncludeFolders(!0),i}pickerCallback(t){var e,n,r,i,o,s;const{action:a,...l}=t;switch(a){case this.google.picker.Action.PICKED:null===(n=(e=this.options).onFileSelect)||void 0===n||n.call(e,l),null===(i=(r=this.options).onClose)||void 0===i||i.call(r);break;case this.google.picker.Action.CANCEL:null===(s=(o=this.options).onCancel)||void 0===s||s.call(o)}}}e.GoogleDriveFilePicker=o},1698:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(9008),i=n(9950),o=n(6128),s=n(8737);e.default={BoxFilePicker:r.BoxFilePicker,GoogleDriveFilePicker:i.GoogleDriveFilePicker,OneDriveFilePicker:o.OneDriveFilePicker,SharepointFilePicker:s.SharepointFilePicker}},6128:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OneDriveFilePicker=void 0;const r=n(3821),i=n(9845);class o extends i.MicrosoftPicker{constructor(){super(...arguments),this.integrationName="onedrive",this.personalAccountUrl="https://onedrive.live.com"}async init(t){return super.initPicker(t,this.integrationName)}getPickerUrl(t){return t?t.includes(this.personalAccountUrl)?`${t}/picker`:this.combinePaths(t,"_layouts/15/FilePicker.aspx"):`${this.personalAccountUrl}/picker`}getIntegrationName(){return this.integrationName}getUrl(t,e){return t.accountAuth[r.AUTH_TOKEN_ALLOWED_INTEGRATIONS[e].domain||""]}getPickerOptions(){return{entry:{oneDrive:{files:{fallbackToRoot:!0}}},pivots:{oneDrive:!0,recent:!0,shared:!0}}}}e.OneDriveFilePicker=o},8737:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SharepointFilePicker=void 0;const r=n(8321),i=n(9845);class o extends i.MicrosoftPicker{constructor(){super(...arguments),this.integrationName="sharepoint"}async init(t){return super.initPicker(t,this.integrationName)}getIntegrationName(){return this.integrationName}getPickerUrl(t){return this.combinePaths(t,"_layouts/15/FilePicker.aspx")}getUrl(t){var e;return(0,r.sanitizeUrl)(null===(e=t.providerData)||void 0===e?void 0:e.webUrl)}getPickerOptions(){return{entry:{sharePoint:{byPath:{list:`${this.baseUrl}/Shared Documents`,fallbackToRoot:!0}}},pivots:{shared:!0,oneDrive:!1,sharedLibraries:!0,site:!0}}}}e.SharepointFilePicker=o},7473:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BaseFilePicker=void 0;const r=n(2643),i=n(572);e.BaseFilePicker=class{constructor(t,e){this.options=t,this.connectSDKInstance=e}initialiseDependencyPromise(){this.dependenciesPromise=new i.DeferredPromise}getInstance(){return this.instance}injectScript(t){if(this.checkIfScriptLoaded(t))this.onScriptLoaded();else{const e=document.createElement("script");e.src=t,e.async=!0,e.id=t,e.onload=this.onScriptLoaded.bind(this),e.onerror=this.onScriptError.bind(this),document.body.appendChild(e)}}checkIfScriptLoaded(t){const e=document.getElementsByTagName("script");for(let n=0;n<e.length;n++)if(e[n].getAttribute("src")==t)return!0;return!1}async validateInitOptions(t,e){for(const[n,i]of e)if(!t||(0,r.isStringEmpty)(t[n]))throw new Error(`Please provide a valid ${i}`);return!0}}},4731:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.buildExternalFilePickerInstance=void 0;const r=n(655).__importDefault(n(1698));class i{constructor(t,e,n){const r=this.createFilePicker(t,e,n);this.open=this.open.bind(r),this.init=this.init.bind(r),this.getInstance=this.getInstance.bind(r)}createFilePicker(t,e,n){const i={box:r.default.BoxFilePicker,googledrive:r.default.GoogleDriveFilePicker,onedrive:r.default.OneDriveFilePicker,sharepoint:r.default.SharepointFilePicker}[t];if(!i)throw new Error(`${t}'s file picker is not supported`);return new i(e,n)}open(){return this.open()}init(t){return this.init(t)}getInstance(){return this.getInstance()}}e.default=i;e.buildExternalFilePickerInstance=t=>function(e,n){if(!t.getUser().authenticated)throw new Error("Authentication is required");if(!e)throw new Error("Missing argument: Integration type is required");return t.validateAction(e),new i(e,n,t)}},7050:function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.buildExternalFilePickerInstance=e.ExternalFilePicker=void 0;var i=n(4731);Object.defineProperty(e,"ExternalFilePicker",{enumerable:!0,get:function(){return r(i).default}}),Object.defineProperty(e,"buildExternalFilePickerInstance",{enumerable:!0,get:function(){return i.buildExternalFilePickerInstance}})},2643:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.findSelectedAccountType=e.isStringEmpty=e.getActionStateForCredentialDelete=e.stripUndefinedAndNull=e.parseKeyedSource=void 0;const r=n(4059);e.parseKeyedSource=function(t){return t&&(null==t?void 0:t.length)?Object.fromEntries(t.map((t=>[t.key,"VALUE"===t.source.type?t.source.value:void 0]))):{}},e.stripUndefinedAndNull=function t(e){const n={};return Object.keys(e).forEach((r=>{var i;(i=e[r])&&"object"==typeof i&&!Array.isArray(i)?n[r]=t(e[r]):void 0!==e[r]&&null!==e[r]&&(n[r]=e[r])})),n};e.getActionStateForCredentialDelete=(t,e)=>{var n,i;const o=(null!==(n=null==e?void 0:e.allCredentials)&&void 0!==n?n:[]).filter((e=>e.id!==t)),s=(null!==(i=null==e?void 0:e.allConfigurations)&&void 0!==i?i:[]).filter((e=>e.connectCredentialId!==t));if(0===o.length)return{enabled:!1,workflowSettings:{},allCredentials:[],allConfigurations:[]};{const t=o[0];return{...e,credentialStatus:t.status,enabled:t.status===r.CredentialStatus.VALID,credentialId:t.id,providerId:t.providerId,providerData:t.providerData,allCredentials:o,allConfigurations:s}}};e.isStringEmpty=t=>!t||"string"==typeof t&&!t.trim();e.findSelectedAccountType=function(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(e)return t.find((t=>{let{id:n}=t;return n===e}));if(1===n.length)return t.find((t=>{let{id:e}=t;return n.includes(e)}));if(!e&&!n.length&&Array.isArray(t)&&2===t.length){const[e,n]=t;return"default"===e.id&&"user-configured-oauth"===n.id?e:void 0}}},4429:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.startOAuthFlow=e.MAX_POLL_DURATION=e.CREDENTIAL_POLL_INTERVAL=void 0;const r=n(3931),i=n(7343),o=n(1935),s=n(2643);e.CREDENTIAL_POLL_INTERVAL=3e3,e.MAX_POLL_DURATION=6e4;e.startOAuthFlow=(t,e)=>{let{context:n,integration:a,endUserSuppliedValues:l={},authParams:c,isPreviewMode:d=!1,installOptions:u={}}=t;var h;const f=(0,i.getIntegrationTypeName)(a);if(!f)return;const p=c?(0,s.parseKeyedSource)(c):{};if(!n.user.authenticated)throw new o.UserNotAuthenticatedError;const g=(0,s.stripUndefinedAndNull)({action:f&&(0,i.isCustomIntegrationTypeName)(f)?r.ACTION_CUSTOM:f,endUserSuppliedValues:JSON.stringify(l),parameters:JSON.stringify(p),userToken:n.user.token,integrationId:a.id,redirectUrl:null===(h=n.endUserIntegrationConfig)||void 0===h?void 0:h.overrideRedirectUrl,originForPostMessage:window.location.origin,isPreviewMode:d,installOptions:JSON.stringify(u),oauthMetaKeyId:e}),v=`${n.environments.ZEUS_PUBLIC_URL}/projects/${n.projectId}/sdk/actions/oauth-nonce?action=${f}&integrationId=${a.id}&originForPostMessage=${window.location.origin}${n.user.token?`&userToken=${n.user.token}`:""}`,y=(async(t,e)=>t.user.authenticated?fetch(`${t.environments.ZEUS_PUBLIC_URL}/v2/projects/${t.projectId}/sdk/actions/build-oauth?${e}`,{method:"GET",headers:{"Content-Type":"application/json",...t.user.token?{Authorization:`Bearer ${t.user.token}`}:{}}}):Promise.reject("User is not authenticated"))(n,new URLSearchParams(g).toString()),E=window.open(v,void 0,"width=500,height=600,left=100,top=150"),I=function(t,e){return function n(r){"oauth-nonce-loaded"===r.data.type&&t.then((async t=>{if(!t.ok){const e=await t.json();return Promise.reject(new Error(e.message))}return t.json()})).then((t=>{if(!e)throw new o.OAuthBlockedError;e.location.href=t.redirectUrl,window.removeEventListener("message",n)})).catch((t=>{console.error("Build Oauth URL fetch failure",t.message)}))}}(y,E);return window.addEventListener("message",I),E}},3056:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.paragon=e.connectSingleton=void 0;const r=n(655),i=r.__importDefault(n(773)),o=n(7050);r.__exportStar(n(3821),e),e.connectSingleton=new i.default,e.paragon={_loadCustomDropdownOptions:e.connectSingleton._loadCustomDropdownOptions.bind(e.connectSingleton),_oauthCallback:e.connectSingleton._oauthCallback.bind(e.connectSingleton),_oauthErrorCallback:e.connectSingleton._oauthErrorCallback.bind(e.connectSingleton),authenticate:e.connectSingleton.authenticate.bind(e.connectSingleton),closePortal:e.connectSingleton.closePortal.bind(e.connectSingleton),completeInstall:e.connectSingleton.completeInstall.bind(e.connectSingleton),configureGlobal:e.connectSingleton.configureGlobal.bind(e.connectSingleton),connect:e.connectSingleton.connect.bind(e.connectSingleton),connectAction:e.connectSingleton.connectAction.bind(e.connectSingleton),getCustomWebhookUserManualUrl:e.connectSingleton.getCustomWebhookUserManualUrl.bind(e.connectSingleton),createConfiguration:e.connectSingleton.createConfiguration.bind(e.connectSingleton),destroyConfiguration:e.connectSingleton.destroyConfiguration.bind(e.connectSingleton),disableWorkflow:e.connectSingleton.disableWorkflow.bind(e.connectSingleton),enableWorkflow:e.connectSingleton.enableWorkflow.bind(e.connectSingleton),event:e.connectSingleton.event.bind(e.connectSingleton),getIntegrationAccount:e.connectSingleton.getIntegrationAccount.bind(e.connectSingleton),getIntegrationMetadata:e.connectSingleton.getIntegrationMetadata.bind(e.connectSingleton),getUser:e.connectSingleton.getUser.bind(e.connectSingleton),installIntegration:e.connectSingleton.installIntegration.bind(e.connectSingleton),request:e.connectSingleton.request.bind(e.connectSingleton),setUserMetadata:e.connectSingleton.setUserMetadata.bind(e.connectSingleton),subscribe:e.connectSingleton.subscribe.bind(e.connectSingleton),uninstallIntegration:e.connectSingleton.uninstallIntegration.bind(e.connectSingleton),unsubscribe:e.connectSingleton.unsubscribe.bind(e.connectSingleton),updateConfiguration:e.connectSingleton.updateConfiguration.bind(e.connectSingleton),workflow:e.connectSingleton.workflow.bind(e.connectSingleton),ExternalFilePicker:(0,o.buildExternalFilePickerInstance)(e.connectSingleton),getIntegrationConfig:e.connectSingleton.getIntegrationConfig.bind(e.connectSingleton),updateIntegrationUserSettings:e.connectSingleton.updateIntegrationUserSettings.bind(e.connectSingleton),updateWorkflowUserSettings:e.connectSingleton.updateWorkflowUserSettings.bind(e.connectSingleton),updateWorkflowState:e.connectSingleton.updateWorkflowState.bind(e.connectSingleton),setHeadless:e.connectSingleton.setHeadless.bind(e.connectSingleton),getIntegrationId:e.connectSingleton.getIntegrationId.bind(e.connectSingleton),getAccountTypeOptions:e.connectSingleton.getAccountTypeOptions.bind(e.connectSingleton),getPreOptions:e.connectSingleton.getPreOptions.bind(e.connectSingleton),getPostOptions:e.connectSingleton.getPostOptions.bind(e.connectSingleton),startOAuthFlow:e.connectSingleton.startOAuthFlow.bind(e.connectSingleton),installFlow:e.connectSingleton.installFlow,getFieldOptions:e.connectSingleton.getFieldOptions.bind(e.connectSingleton),getDataSourceOptions:e.connectSingleton.getDataSourceOptions.bind(e.connectSingleton),setCustomDropdownOptions:e.connectSingleton.setCustomDropdownOptions.bind(e.connectSingleton),getCustomDropdownOptions:e.connectSingleton.getCustomDropdownOptions.bind(e.connectSingleton)},e.default=i.default},9636:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.cloneDeep=void 0;const r=n(655).__importDefault(n(738));e.cloneDeep=function(t){return(0,r.default)(t)}},2992:(t,e)=>{"use strict";var n,r,i;Object.defineProperty(e,"__esModule",{value:!0}),e.AUTH_TOKEN_ALLOWED_INTEGRATIONS=e.overrideActionAlias=e.TokenType=e.VariableInputType=e.SidebarInputType=void 0,function(t){t.Auth="AUTH",t.Enum="ENUM",t.DynamicEnum="DYNAMIC_ENUM",t.Intent="INTENT",t.Text="TEXT",t.TextArea="TEXTAREA",t.ValueText="TEXT_NO_VARS",t.ValueTextArea="TEXTAREA_NO_VARS",t.Code="CODE",t.ActionButton="ACTION_BUTTON",t.Conditional="CONDITIONAL",t.CustomDropdown="CUSTOM_DROPDOWN",t.DynamicConditional="DYNAMIC_CONDITIONAL",t.NestedList="NESTED_LIST",t.File="FILE",t.EditableDynamicEnum="EDITABLE_DYNAMIC_ENUM",t.EditableEnum="EDITABLE_ENUM",t.BooleanInput="BOOLEAN_INPUT",t.UserSuppliedCredential="USER_SUPPLIED_CREDENTIAL",t.NativeDynamicEnumInput="NATIVE_DYNAMIC_INPUT",t.TimeConstraintInput="TIME_CONSTRAINT_INPUT",t.LinesListInput="LinesListInput",t.LinesListDynamicInput="LinesListDynamicInput",t.Number="NUMBER",t.Email="EMAIL",t.URL="URL",t.EnumTextAreaPairInput="EnumTextAreaPairInput",t.FieldMapper="FIELD_MAPPER",t.ComboInput="COMBO_INPUT",t.Password="PASSWORD",t.Switch="SWITCH",t.DynamicComboInput="DYNAMIC_COMBO_INPUT",t.CopyableButtonInput="COPYABLE_BUTTON_INPUT",t.Permission="PERMISSION"}(e.SidebarInputType||(e.SidebarInputType={})),function(t){t.MultiSelect="multi",t.String="string",t.Dropdown="dropdown",t.MultiSelectCheckbox="multiCheckbox",t.Number="number"}(e.VariableInputType||(e.VariableInputType={})),function(t){t.ACCESS_TOKEN="ACCESS_TOKEN",t.REFRESH_TOKEN="REFRESH_TOKEN",t.BOT_TOKEN="BOT_TOKEN",t.KLAVIYO_API_KEY="KLAVIYO_API_KEY",t.MARKETO_CLIENT_ID="MARKETO_CLIENT_ID",t.MARKETO_CLIENT_SECRET="MARKETO_CLIENT_SECRETI",t.MARKETO_ENDPOINT="MARKETO_ENDPOINT",t.MARKETO_IDENTITY="MARKETO_IDENTITY",t.MONDAY_API_TOKEN="MONDAY_API_TOKEN",t.ORACLE_CLOUD_URL="ORACLE_CLOUD_URL",t.ORACLE_PASSWORD="ORACLE_PASSWORD",t.ORACLE_USERNAME="ORACLE_USERNAME",t.SAGE_INTACCT_COMPANY_ID="SAGE_INTACCT_COMPANY_ID",t.SAGE_INTACCT_USER_ID="SAGE_INTACCT_USER_ID",t.SAGE_INTACCT_USER_PASSWORD="SAGE_INTACCT_USER_PASSWORD",t.SAILTHRU_COMPANY_KEY="SAILTHRU_COMPANY_KEY",t.SAILTHRU_COMPANY_SECRET="SAILTHRU_COMPANY_SECRET",t.SERVICENOW_PASSWORD="SERVICENOW_PASSWORD",t.SERVICENOW_SUBDOMAIN="SERVICENOW_SUBDOMAIN",t.SERVICENOW_USERNAME="SERVICENOW_USERNAME",t.TABLEAU_PERSONAL_ACCESS_TOKEN_NAME="TABLEAU_PERSONAL_ACCESS_TOKEN_NAME",t.TABLEAU_PERSONAL_ACCESS_TOKEN_SECRET="TABLEAU_PERSONAL_ACCESS_TOKEN_SECRET",t.TABLEAU_SERVER_NAME="TABLEAU_SERVER_NAME",t.TABLEAU_SITE_ID="TABLEAU_SITE_ID",t.TRELLO_API_KEY="TRELLO_API_KEY",t.TRELLO_API_TOKEN="TRELLO_API_TOKEN",t.WOOCOMMERCE_CONSUMER_KEY="WOOCOMMERCE_CONSUMER_KEY",t.WOOCOMMERCE_CONSUMER_SECRET="WOOCOMMERCE_CONSUMER_SECRET",t.WOOCOMMERCE_STORE_DOMAIN="WOOCOMMERCE_STORE_DOMAIN",t.WORKABLE_API_ACCESS_TOKEN="WORKABLE_API_ACCESS_TOKEN",t.WORKABLE_ACCOUNT_SUBDOMAIN="WORKABLE_ACCOUNT_SUBDOMAIN",t.ZOHO_CRM_ACCOUNTS_SERVER="ZOHO_CRM_ACCOUNTS_SERVER",t.ZOHO_CRM_API_DOMAIN="ZOHO_CRM_API_DOMAIN"}(e.TokenType||(e.TokenType={})),function(t){t.INFO="INFO",t.ERROR="ERROR",t.SUCCESS="SUCCESS"}(n||(n={})),function(t){t.NONE="NONE",t.RE_AUTHENTICATE="RE_AUTHENTICATE",t.ALERT="ALERT",t.DISPATCH="DISPATCH"}(r||(r={})),function(t){t.DYNAMIC="DYNAMIC_DATA_SOURCE",t.STATIC_ENUM="STATIC_ENUM_DATA_SOURCE",t.FIELD_MAPPER="FIELD_MAPPER_DATA_SOURCE",t.COMBO_INPUT="COMBO_INPUT_DATA_SOURCE",t.DYNAMIC_COMBO_INPUT="DYNAMIC_COMBO_INPUT_DATA_SOURCE"}(i||(i={})),e.overrideActionAlias={"monday.com":"monday","wordpress.com":"wordpress"},e.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:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONNECT_PLAN_FEATURE_MAP=void 0;const r=n(471);e.CONNECT_PLAN_FEATURE_MAP={[r.BillingPlan.ConnectBasic]:[],[r.BillingPlan.ConnectPro]:[r.ConnectAddOn.CustomIntegrationBuilder,r.ConnectAddOn.HeadlessConnectPortal,r.ConnectAddOn.Monitoring,r.ConnectAddOn.UserMetadata,r.ConnectAddOn.WhiteLabeling],[r.BillingPlan.ConnectEnterprise]:[r.ConnectAddOn.CustomIntegrationBuilder,r.ConnectAddOn.DynamicFieldMapper,r.ConnectAddOn.HeadlessConnectPortal,r.ConnectAddOn.TaskHistoryAPI,r.ConnectAddOn.Monitoring,r.ConnectAddOn.RoleBasedAccessControl,r.ConnectAddOn.UserMetadata,r.ConnectAddOn.WhiteLabeling,r.ConnectAddOn.WorkflowPermission]}},1935:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SDK_VERSION_HEADER=e.SELECTED_CREDENTIAL_CONFIG_ID_HEADER=e.SELECTED_CREDENTIAL_ID_HEADER=e.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS=e.CredentialStatus=void 0;const r=n(655),i=n(2992);var o=n(4059);Object.defineProperty(e,"CredentialStatus",{enumerable:!0,get:function(){return o.CredentialStatus}}),r.__exportStar(n(2460),e);i.SidebarInputType.ValueText,i.SidebarInputType.DynamicEnum,i.SidebarInputType.Enum,i.SidebarInputType.Number,i.SidebarInputType.Email,i.SidebarInputType.URL,i.SidebarInputType.FieldMapper,i.SidebarInputType.BooleanInput,i.SidebarInputType.ComboInput,i.SidebarInputType.Password,i.SidebarInputType.Switch,i.SidebarInputType.ValueTextArea,i.SidebarInputType.CustomDropdown,i.SidebarInputType.DynamicComboInput,i.SidebarInputType.FieldMapper,i.SidebarInputType.CopyableButtonInput,i.SidebarInputType.Permission,i.SidebarInputType.File;e.INFER_CONTENT_TYPE_FROM_CONNECT_OPTIONS="auto",e.SELECTED_CREDENTIAL_ID_HEADER="X-Paragon-Credential",e.SELECTED_CREDENTIAL_CONFIG_ID_HEADER="X-Paragon-Configuration-Id",e.SDK_VERSION_HEADER="X-Paragon-SDK-Version"},9977:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},914:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PLATFORM_ENV=e.NODE_ENV=void 0,function(t){t.PRODUCTION="production",t.DEVELOPMENT="development",t.TEST="test"}(e.NODE_ENV||(e.NODE_ENV={})),function(t){t.PRODUCTION="production",t.PRODUCTION_MIRROR_1="p-m1",t.STAGING="staging",t.STAGING_MIRROR_1="s-m1",t.DEVELOPMENT="dev",t.TEST="test",t.SANDBOX="sandbox",t.RELEASE="release",t.ENTERPRISE="enterprise"}(e.PLATFORM_ENV||(e.PLATFORM_ENV={}))},2460:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getConnectSDKError=e.OAuthTimeoutError=e.OAuthBlockedError=e.HeadlessModeNotEnabledError=e.IntegrationNotInstalledError=e.IntegrationNotFoundError=e.NoActiveInstallFlowError=e.UserNotAuthenticatedError=e.BaseSDKError=void 0;class n extends Error{constructor(t){super(t.message),this.name=t.name,this.meta="meta"in t?t.meta:null}}e.BaseSDKError=n;e.UserNotAuthenticatedError=class extends n{constructor(){super({name:"UserNotAuthenticatedError",message:"User not authenticated, Call paragon.authenticate(<projectId>, <user token>) before using the SDK."})}};e.NoActiveInstallFlowError=class extends n{constructor(){super({name:"NoActiveInstallFlowError",message:"No active install flow, make sure you call installFlow.start(<integrationName>, ...args) before calling any other method"})}};e.IntegrationNotFoundError=class extends n{constructor(t){super({name:"IntegrationNotFoundError",message:`Integration with name ${t} not found`,meta:{integrationName:t}})}};e.IntegrationNotInstalledError=class extends n{constructor(t){super({name:"IntegrationNotInstalledError",message:`Integration "${t}" is not installed.`,meta:{integrationName:t}}),this.integrationName=t}};e.HeadlessModeNotEnabledError=class extends n{constructor(){super({name:"HeadlessModeNotEnabledError",message:"Headless mode is not enabled. Make sure you call `paragon.setHeadless(true)` as early as possible in your code."})}};e.OAuthBlockedError=class extends n{constructor(){super({name:"OAuthBlockedError",message:"Popup was blocked by the browser."})}};e.OAuthTimeoutError=class extends n{constructor(){super({name:"OAuthTimeoutError",message:"OAuth timeout"})}},e.getConnectSDKError=function(t){return t instanceof n?{name:t.name,message:t.message,meta:t.meta}:{name:"UnknownError",message:t instanceof Error?t.message:"An unknown error occurred",originalError:t}}},8065:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},3821:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(655);r.__exportStar(n(2992),e),r.__exportStar(n(9034),e),r.__exportStar(n(1935),e),r.__exportStar(n(9977),e),r.__exportStar(n(914),e),r.__exportStar(n(8065),e),r.__exportStar(n(9835),e),r.__exportStar(n(7750),e),r.__exportStar(n(471),e)},9835:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.DataType=void 0,function(t){t.STRING="STRING",t.NUMBER="NUMBER",t.DATE="DATE",t.BOOLEAN="BOOLEAN",t.EMAIL="EMAIL",t.OBJECT="OBJECT",t.ARRAY="ARRAY",t.ANY="ANY",t.FILE="FILE",t.NON_DECIMAL="NON_DECIMAL"}(e.DataType||(e.DataType={})),function(t){t.None="$none",t.StringContains="$stringContains",t.StringDoesNotContain="$stringDoesNotContain",t.StringExactlyMatches="$stringExactlyMatches",t.StringDoesNotExactlyMatch="$stringDoesNotExactlyMatch",t.StringIsIn="$stringIsIn",t.StringIsNotIn="$stringIsNotIn",t.StringStartsWith="$stringStartsWith",t.StringDoesNotStartWith="$stringDoesNotStartWith",t.StringEndsWith="$stringEndsWith",t.StringDoesNotEndWith="$stringDoesNotEndWith",t.NumberGreaterThan="$numberGreaterThan",t.NumberLessThan="$numberLessThan",t.NumberEquals="$numberEquals",t.NumberDoesNotEqual="$numberDoesNotEqual",t.NumberLessThanOrEqualTo="$numberLessThanOrEqualTo",t.NumberGreaterThanOrEqualTo="$numberGreaterThanOrEqualTo",t.DateTimeAfter="$dateTimeAfter",t.DateTimeBefore="$dateTimeBefore",t.DateTimeEquals="$dateTimeEquals",t.BooleanTrue="$booleanTrue",t.BooleanFalse="$booleanFalse",t.IsNotNull="$exists",t.IsNull="$doesNotExist",t.Exists="$isNotUndefinedOrNull",t.DoesNotExist="$isUndefinedOrNull",t.ArrayIsIn="$arrayIsIn",t.ArrayIsNotIn="$arrayIsNotIn",t.ArrayIsEmpty="$arrayIsEmpty",t.ArrayIsNotEmpty="$arrayIsNotEmpty",t.StringGreaterThan="$stringGreaterThan",t.StringLessThan="$stringLessThan"}(n||(n={}))},7750:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.FilePickerStatus=e.DocumentLoadingState=e.SDK_EVENT=e.ModalView=e.DynamicFieldMappingLoaderType=void 0,function(t){t.OBJECT_TYPES="objectTypes",t.INTEGRATION_FIELDS="integrationFields"}(e.DynamicFieldMappingLoaderType||(e.DynamicFieldMappingLoaderType={})),function(t){t.OVERVIEW="overview",t.CONFIGURATION="configuration"}(e.ModalView||(e.ModalView={})),function(t){t.ON_INTEGRATION_INSTALL="onIntegrationInstall",t.ON_INTEGRATION_UNINSTALL="onIntegrationUninstall",t.ON_WORKFLOW_CHANGE="onWorkflowChange",t.ON_PORTAL_OPEN="onPortalOpen",t.ON_PORTAL_CLOSE="onPortalClose"}(e.SDK_EVENT||(e.SDK_EVENT={})),function(t){t.LOADING="loading",t.INTERACTIVE="interactive",t.COMPLETE="complete"}(e.DocumentLoadingState||(e.DocumentLoadingState={})),function(t){t.LOADING="loading",t.FAILED="failed",t.LOADED="loaded"}(e.FilePickerStatus||(e.FilePickerStatus={}))},471:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ConnectAddOn=e.BillingPlan=void 0,function(t){t.ClassicFree="free",t.ClassicStarter="starter",t.ClassicBusiness="business",t.ClassicPremium="premium",t.ClassicEnterprise="enterprise",t.ConnectTrial="connect_trial",t.ConnectBasic="basic",t.ConnectPro="pro",t.ConnectEnterprise="connect_enterprise"}(e.BillingPlan||(e.BillingPlan={})),function(t){t.CustomIntegrationBuilder="byo",t.DynamicFieldMapper="dfm",t.HeadlessConnectPortal="headless-cp",t.TaskHistoryAPI="th-api",t.Monitoring="monitoring",t.RoleBasedAccessControl="rbac",t.UserMetadata="user-metadata",t.WhiteLabeling="whitelabel",t.WorkflowPermission="workflow-permissions"}(e.ConnectAddOn||(e.ConnectAddOn={}))},3158:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getHeadersForUserMeta=e.sanitizeExternalConfigId=e.getAssetUrl=void 0;const r=n(3931),i=n(3821);e.getAssetUrl=t=>{let{CDN_PUBLIC_URL:e,DASHBOARD_PUBLIC_URL:n,VERSION:r,PLATFORM_ENV:o,NODE_ENV:s}=t;return e&&s===i.NODE_ENV.PRODUCTION&&o!==i.PLATFORM_ENV.ENTERPRISE?`${e}/${r}/dashboard/public`:n},e.sanitizeExternalConfigId=function(t){if(t.startsWith("ext:")){return(t.split("ext:").pop()||"").trim()}return t.trim()};e.getHeadersForUserMeta=t=>({...t?{[r.PERSONA_META_HEADER]:JSON.stringify(t)}:{}})},4846:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hash=void 0;const r=n(3715);e.hash=function(t){return null==t?t:(0,r.sha256)().update(t).digest("hex").substr(0,10)}},572:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.tryUntil=e.isUUID=e.uuidPattern=e.sleep=e.generateMatrix=e.DeferredPromise=void 0;function n(t){return new Promise((e=>setTimeout(e,t)))}e.DeferredPromise=class{get state(){return this._state}constructor(){this._state="pending",this._promise=new Promise(((t,e)=>{this._resolve=t,this._reject=e}))}then(t,e){return this._promise.then(t,e)}catch(t){return this._promise.catch(t)}resolve(t){this._resolve(t),this._state="fulfilled"}reject(t){this._reject(t),this._state="rejected"}finally(t){return null==t||t(),this._promise}},Symbol.toStringTag,e.generateMatrix=function(t,e){const n=Object.keys(t);if(n.reduce(((e,n)=>e+t[n].length),0)&&n.length)for(const e of n)t[e].length||t[e].push(void 0);const r=Object.entries(t).reduce(((t,e)=>{let[,n]=e;return t.length?t.reduce(((t,e)=>(n.forEach((n=>{const r=e.slice();r.push(n),t.push(r)}),[]),t)),[]):n.map((t=>[t]))}),[]).reduce(((t,e)=>{const r=e.reduce(((t,e,r)=>({...t,[n[r]]:e})),{});return[...t,r]}),[]);return e?r.slice(-1*e):r},e.sleep=n,e.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,e.isUUID=function(t){return"string"==typeof t&&e.uuidPattern.test(t)},e.tryUntil=async function(t,e,r){let i=0,o=!0;for(;o;){i+=1;let s=null,a=null;try{s=await t()}catch(t){a=t}if(o=await e(s,a,i),!o){if(a)throw a;return s}{const t="number"==typeof r?r:r(i);await n(t)}}throw new Error("Method unable to run: invalid retries.")}},8321:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.errorMessageParser=e.isIntegrationError=e.ProxyRequestError=e.getErrorMessage=e.getServiceUrl=e.sanitizeUrl=e.isValidUrl=void 0;function n(t){return t?t.match(/^[a-zA-Z]+:\/\//)?t:`https://${t}`:t}function r(t){return Array.isArray(t)?t.flatMap((t=>[t,r(t.children||[])].flatMap((t=>"string"==typeof t?t:r(t))))).filter((t=>t)).join(", "):Object.values(t.constraints||{}).join(", ")}e.isValidUrl=t=>{const e=n(t);try{return new globalThis.URL(e),!0}catch(t){return!1}},e.sanitizeUrl=n,e.getServiceUrl=function(t,e){return`https://${t}${`.${e}`}`},e.getErrorMessage=async function(t,n){var i,o;const s=null===(i=t.headers)||void 0===i?void 0:i.get("content-type"),a=s&&s.includes("application/json")?await t.json():null;let l;return l=a&&(0,e.isIntegrationError)(a.meta)?JSON.stringify(a.meta):a&&"string"==typeof a.message?a.message:a&&400===t.status&&Array.isArray(a.message)?r(a.message):a?JSON.stringify(a):await(null===(o=t.text)||void 0===o?void 0:o.call(t)),n?{message:l,response:a||t}:l};class i extends Error{constructor(t,e){super(t),this.name="Error",this.response=e,Object.setPrototypeOf(this,i.prototype)}}e.ProxyRequestError=i;e.isIntegrationError=t=>!("object"!=typeof t||!t)&&t.isIntegrationError,e.errorMessageParser=function(t){t="string"==typeof t?t:t.message;try{const n=JSON.parse(t);return!!(0,e.isIntegrationError)(n)}catch(t){return!1}}},3035:(t,e,n)=>{"use strict";var r,i,o,s,a=n(4155);Object.defineProperty(e,"__esModule",{value:!0}),e.CacheThrottle=e.CacheMode=void 0;const l=n(655),c=n(572);var d,u,h;!function(t){t.Debounce="debounce",t.Throttle="throttle"}(d=e.CacheMode||(e.CacheMode={})),function(t){t.Closed="closed",t.Idle="idle",t.Processing="processing"}(u||(u={})),function(t){t[t.Get=0]="Get",t[t.Set=1]="Set",t[t.GetOrSet=2]="GetOrSet",t[t.Del=3]="Del",t[t.Do=4]="Do"}(h||(h={}));e.CacheThrottle=class{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r.set(this,u.Idle),i.set(this,{}),o.set(this,void 0),s.set(this,[]),l.__classPrivateFieldSet(this,o,{mode:d.Debounce,ttl:0,...t},"f")}async get(t,e){const n=this.serializeKey(t),r=async()=>{const e=l.__classPrivateFieldGet(this,i,"f")[n],{mode:r,ttl:s,value:a}=null!=e?e:{};return!e||!s||r&&r!==d.Debounce||this.refreshTimeout(t,n,s),l.__classPrivateFieldGet(this,o,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(n,a),a};return e?r():this.enqueue(n,h.Get,r)}async set(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.__classPrivateFieldGet(this,o,"f").ttl,r=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;const a=this.serializeKey(t),c=async()=>{const s=l.__classPrivateFieldGet(this,i,"f")[a],c=!!s;return l.__classPrivateFieldGet(this,i,"f")[a]={...s,mode:r,ttl:n,value:e},c&&r===d.Throttle||this.refreshTimeout(t,a,n),l.__classPrivateFieldGet(this,o,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(a,e),e};return s?c():this.enqueue(a,h.Set,c)}async getOrSet(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.__classPrivateFieldGet(this,o,"f").ttl,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l.__classPrivateFieldGet(this,o,"f").mode,s=arguments.length>4?arguments[4]:void 0;const a=this.serializeKey(t),c=async()=>{if(l.__classPrivateFieldGet(this,i,"f")[a])return l.__classPrivateFieldGet(this,i,"f")[a].value;const s=await e();return await this.set(t,s,n,r,!0),l.__classPrivateFieldGet(this,o,"f").clearPendingDeletes&&this.clearPendingDeletesOnKey(a,s),s};return s?c():this.enqueue(a,h.GetOrSet,c)}async del(t){let e=arguments.length>2?arguments[2]:void 0;const n=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?t:this.serializeKey(t),r=async()=>{const t=l.__classPrivateFieldGet(this,i,"f")[n];let e;return(null==t?void 0:t.timeout)&&clearTimeout(t.timeout),t&&(e=t.value,delete l.__classPrivateFieldGet(this,i,"f")[n],await(async()=>{var t,n;return null===(n=(t=l.__classPrivateFieldGet(this,o,"f")).onDeregister)||void 0===n?void 0:n.call(t,e)})().catch((t=>{}))),e};return e?r():this.enqueue(n,h.Del,r)}keys(){return Object.keys(l.__classPrivateFieldGet(this,i,"f"))}async do(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.__classPrivateFieldGet(this,o,"f").ttl,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l.__classPrivateFieldGet(this,o,"f").mode;const s=this.serializeKey(t);return this.enqueue(s,h.Do,(async()=>{if(l.__classPrivateFieldGet(this,i,"f")[s])return l.__classPrivateFieldGet(this,i,"f")[s].value;const o=await e();return await this.set(t,o,n,r,!0)}))}async close(){l.__classPrivateFieldSet(this,r,u.Closed,"f"),await Promise.all(Object.keys(l.__classPrivateFieldGet(this,i,"f")).map((t=>this.del(t,!0,!0))))}refreshTimeout(t,e,n){if(l.__classPrivateFieldGet(this,r,"f")===u.Closed)return;const o=l.__classPrivateFieldGet(this,i,"f")[e];return n&&void 0!==(null==o?void 0:o.timeout)&&clearTimeout(o.timeout),n?(o.timeout=setTimeout((()=>this.del(t)),n),o.timeout):void 0}clearPendingDeletesOnKey(t,e){l.__classPrivateFieldSet(this,s,l.__classPrivateFieldGet(this,s,"f").filter((n=>{let[r,i,o,s]=n;return t!==r||i!==h.Del||(s.resolve(e),!1)})),"f")}serializeKey(t){var e,n,r;return null!==(r=null===(n=(e=l.__classPrivateFieldGet(this,o,"f")).serializeKey)||void 0===n?void 0:n.call(e,t))&&void 0!==r?r:t}async enqueue(t,e,n){const i=new c.DeferredPromise;return l.__classPrivateFieldGet(this,s,"f").push([t,e,n,i]),l.__classPrivateFieldGet(this,r,"f")===u.Idle&&this.flush(),i}flush(){l.__classPrivateFieldSet(this,r,u.Processing,"f"),a.nextTick((async()=>{for(;l.__classPrivateFieldGet(this,s,"f").length&&l.__classPrivateFieldGet(this,r,"f")!==u.Closed;){const t=l.__classPrivateFieldGet(this,s,"f").shift();if(t){const[,,e,n]=t;try{const t=await e();n.resolve(t)}catch(t){n.reject(t)}}}l.__classPrivateFieldSet(this,r,u.Idle,"f")}))}},r=new WeakMap,i=new WeakMap,o=new WeakMap,s=new WeakMap},9742:(t,e)=>{"use strict";e.byteLength=function(t){var e=l(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,o=l(t),s=o[0],a=o[1],c=new i(function(t,e,n){return 3*(e+n)/4-n}(0,s,a)),d=0,u=a>0?s-4:s;for(n=0;n<u;n+=4)e=r[t.charCodeAt(n)]<<18|r[t.charCodeAt(n+1)]<<12|r[t.charCodeAt(n+2)]<<6|r[t.charCodeAt(n+3)],c[d++]=e>>16&255,c[d++]=e>>8&255,c[d++]=255&e;2===a&&(e=r[t.charCodeAt(n)]<<2|r[t.charCodeAt(n+1)]>>4,c[d++]=255&e);1===a&&(e=r[t.charCodeAt(n)]<<10|r[t.charCodeAt(n+1)]<<4|r[t.charCodeAt(n+2)]>>2,c[d++]=e>>8&255,c[d++]=255&e);return c},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=16383,a=0,l=r-i;a<l;a+=s)o.push(c(t,a,a+s>l?l:a+s));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=o.length;s<a;++s)n[s]=o[s],r[o.charCodeAt(s)]=s;function l(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function c(t,e,r){for(var i,o,s=[],a=e;a<r;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},8764:(t,e,n)=>{"use strict";var r=n(9742),i=n(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=l,e.h2=50;var s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,l.prototype),e}function l(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return c(t,e,n)}function c(t,e,n){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!l.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var n=0|g(t,e),r=a(n),i=r.write(t,e);i!==n&&(r=r.slice(0,i));return r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(V(t,Uint8Array)){var e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(V(t,ArrayBuffer)||t&&V(t.buffer,ArrayBuffer))return f(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(V(t,SharedArrayBuffer)||t&&V(t.buffer,SharedArrayBuffer)))return f(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return l.from(r,e,n);var i=function(t){if(l.isBuffer(t)){var e=0|p(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}if(void 0!==t.length)return"number"!=typeof t.length||$(t.length)?a(0):h(t);if("Buffer"===t.type&&Array.isArray(t.data))return h(t.data)}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return l.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function d(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(t){return d(t),a(t<0?0:0|p(t))}function h(t){for(var e=t.length<0?0:0|p(t.length),n=a(e),r=0;r<e;r+=1)n[r]=255&t[r];return n}function f(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,l.prototype),r}function p(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function g(t,e){if(l.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||V(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return B(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return j(t).length;default:if(i)return r?-1:B(t).length;e=(""+e).toLowerCase(),i=!0}}function v(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return b(this,e,n);case"latin1":case"binary":return N(this,e,n);case"base64":return O(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function E(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),$(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=l.from(e,r)),l.isBuffer(e))return 0===e.length?-1:I(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):I(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function I(t,e,n,r,i){var o,s=1,a=t.length,l=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,l/=2,n/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var d=-1;for(o=n;o<a;o++)if(c(t,o)===c(e,-1===d?0:o-d)){if(-1===d&&(d=o),o-d+1===l)return d*s}else-1!==d&&(o-=o-d),d=-1}else for(n+l>a&&(n=a-l),o=n;o>=0;o--){for(var u=!0,h=0;h<l;h++)if(c(t,o+h)!==c(e,h)){u=!1;break}if(u)return o}return-1}function w(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=e.length;r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(e.substr(2*s,2),16);if($(a))return s;t[n+s]=a}return s}function S(t,e,n,r){return x(B(e,t.length-n),t,n,r)}function _(t,e,n,r){return x(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function m(t,e,n,r){return x(j(e),t,n,r)}function C(t,e,n,r){return x(function(t,e){for(var n,r,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)r=(n=t.charCodeAt(s))>>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function O(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function A(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i<n;){var o,s,a,l,c=t[i],d=null,u=c>239?4:c>223?3:c>191?2:1;if(i+u<=n)switch(u){case 1:c<128&&(d=c);break;case 2:128==(192&(o=t[i+1]))&&(l=(31&c)<<6|63&o)>127&&(d=l);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(l=(15&c)<<12|(63&o)<<6|63&s)>2047&&(l<55296||l>57343)&&(d=l);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&l<1114112&&(d=l)}null===d?(d=65533,u=1):d>65535&&(d-=65536,r.push(d>>>10&1023|55296),d=56320|1023&d),r.push(d),i+=u}return function(t){var e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=T));return n}(r)}l.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),l.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(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}}),l.poolSize=8192,l.from=function(t,e,n){return c(t,e,n)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array),l.alloc=function(t,e,n){return function(t,e,n){return d(t),t<=0?a(t):void 0!==e?"string"==typeof n?a(t).fill(e,n):a(t).fill(e):a(t)}(t,e,n)},l.allocUnsafe=function(t){return u(t)},l.allocUnsafeSlow=function(t){return u(t)},l.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==l.prototype},l.compare=function(t,e){if(V(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),V(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(t)||!l.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,r=e.length,i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},l.isEncoding=function(t){switch(String(t).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}},l.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return l.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=l.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var o=t[n];if(V(o,Uint8Array))i+o.length>r.length?l.from(o).copy(r,i):Uint8Array.prototype.set.call(r,o,i);else{if(!l.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i)}i+=o.length}return r},l.byteLength=g,l.prototype._isBuffer=!0,l.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)y(this,e,e+1);return this},l.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},l.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},l.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):v.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(t){if(!l.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===l.compare(this,t)},l.prototype.inspect=function(){var t="",n=e.h2;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},o&&(l.prototype[o]=l.prototype.inspect),l.prototype.compare=function(t,e,n,r,i){if(V(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(e>>>=0),a=Math.min(o,s),c=this.slice(r,i),d=t.slice(e,n),u=0;u<a;++u)if(c[u]!==d[u]){o=c[u],s=d[u];break}return o<s?-1:s<o?1:0},l.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},l.prototype.indexOf=function(t,e,n){return E(this,t,e,n,!0)},l.prototype.lastIndexOf=function(t,e,n){return E(this,t,e,n,!1)},l.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return w(this,t,e,n);case"utf8":case"utf-8":return S(this,t,e,n);case"ascii":case"latin1":case"binary":return _(this,t,e,n);case"base64":return m(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function b(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function N(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function P(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=e;o<n;++o)i+=H[t[o]];return i}function D(t,e,n){for(var r=t.slice(e,n),i="",o=0;o<r.length-1;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function R(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function L(t,e,n,r,i,o){if(!l.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function U(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function k(t,e,n,r,o){return e=+e,n>>>=0,o||U(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function M(t,e,n,r,o){return e=+e,n>>>=0,o||U(t,0,n,8),i.write(t,e,n,r,52,8),n+8}l.prototype.slice=function(t,e){var n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);var r=this.subarray(t,e);return Object.setPrototypeOf(r,l.prototype),r},l.prototype.readUintLE=l.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r},l.prototype.readUintBE=l.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);)r+=this[t+--e]*i;return r},l.prototype.readUint8=l.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},l.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*e)),r},l.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},l.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},l.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},l.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},l.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!0,23,4)},l.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!1,23,4)},l.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!0,52,8)},l.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e>>>=0,n>>>=0,r)||L(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e>>>=0,n>>>=0,r)||L(this,t,e,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},l.prototype.writeUint8=l.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,1,255,0),this[e]=255&t,e+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var i=Math.pow(2,8*n-1);L(this,t,e,n,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o<n&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+n},l.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var i=Math.pow(2,8*n-1);L(this,t,e,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+n},l.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},l.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},l.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeFloatLE=function(t,e,n){return k(this,t,e,!0,n)},l.prototype.writeFloatBE=function(t,e,n){return k(this,t,e,!1,n)},l.prototype.writeDoubleLE=function(t,e,n){return M(this,t,e,!0,n)},l.prototype.writeDoubleBE=function(t,e,n){return M(this,t,e,!1,n)},l.prototype.copy=function(t,e,n,r){if(!l.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var i=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),i},l.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!l.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){var i=t.charCodeAt(0);("utf8"===r&&i<128||"latin1"===r)&&(t=i)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var o;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o<n;++o)this[o]=t;else{var s=l.isBuffer(t)?t:l.from(t,r),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=s[o%a]}return this};var F=/[^+/0-9A-Za-z-_]/g;function B(t,e){var n;e=e||1/0;for(var r=t.length,i=null,o=[],s=0;s<r;++s){if((n=t.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function j(t){return r.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(F,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function x(t,e,n,r){for(var i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function V(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function $(t){return t!=t}var H=function(){for(var t="0123456789abcdef",e=new Array(256),n=0;n<16;++n)for(var r=16*n,i=0;i<16;++i)e[r+i]=t[n]+t[i];return e}()},738:(t,e,n)=>{"use strict";const r=n(3341),i=n(6401),o=n(5299);function s(t,e){switch(i(t)){case"object":return function(t,e){if("function"==typeof e)return e(t);if(e||o(t)){const n=new t.constructor;for(let r in t)n[r]=s(t[r],e);return n}return t}(t,e);case"array":return function(t,e){const n=new t.constructor(t.length);for(let r=0;r<t.length;r++)n[r]=s(t[r],e);return n}(t,e);default:return r(t)}}t.exports=s},3715:(t,e,n)=>{var r=e;r.utils=n(6436),r.common=n(5772),r.sha=n(9041),r.ripemd=n(2949),r.hmac=n(2344),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},5772:(t,e,n)=>{"use strict";var r=n(6436),i=n(9746);function o(){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}e.BlockHash=o,o.prototype.update=function(t,e){if(t=r.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var n=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-n,t.length),0===this.pending.length&&(this.pending=null),t=r.join32(t,0,t.length-n,this.endian);for(var i=0;i<t.length;i+=this._delta32)this._update(t,i,i+this._delta32)}return this},o.prototype.digest=function(t){return this.update(this._pad()),i(null===this.pending),this._digest(t)},o.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,n=e-(t+this.padLength)%e,r=new Array(n+this.padLength);r[0]=128;for(var i=1;i<n;i++)r[i]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)r[i++]=0;r[i++]=0,r[i++]=0,r[i++]=0,r[i++]=0,r[i++]=t>>>24&255,r[i++]=t>>>16&255,r[i++]=t>>>8&255,r[i++]=255&t}else for(r[i++]=255&t,r[i++]=t>>>8&255,r[i++]=t>>>16&255,r[i++]=t>>>24&255,r[i++]=0,r[i++]=0,r[i++]=0,r[i++]=0,o=8;o<this.padLength;o++)r[i++]=0;return r}},2344:(t,e,n)=>{"use strict";var r=n(6436),i=n(9746);function o(t,e,n){if(!(this instanceof o))return new o(t,e,n);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(r.toArray(e,n))}t.exports=o,o.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},o.prototype.update=function(t,e){return this.inner.update(t,e),this},o.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)}},2949:(t,e,n)=>{"use strict";var r=n(6436),i=n(5772),o=r.rotl32,s=r.sum32,a=r.sum32_3,l=r.sum32_4,c=i.BlockHash;function d(){if(!(this instanceof d))return new d;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function u(t,e,n,r){return t<=15?e^n^r:t<=31?e&n|~e&r:t<=47?(e|~n)^r:t<=63?e&r|n&~r:e^(n|~r)}function h(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function f(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}r.inherits(d,c),e.ripemd160=d,d.blockSize=512,d.outSize=160,d.hmacStrength=192,d.padLength=64,d.prototype._update=function(t,e){for(var n=this.h[0],r=this.h[1],i=this.h[2],c=this.h[3],d=this.h[4],E=n,I=r,w=i,S=c,_=d,m=0;m<80;m++){var C=s(o(l(n,u(m,r,i,c),t[p[m]+e],h(m)),v[m]),d);n=d,d=c,c=o(i,10),i=r,r=C,C=s(o(l(E,u(79-m,I,w,S),t[g[m]+e],f(m)),y[m]),_),E=_,_=S,S=o(w,10),w=I,I=C}C=a(this.h[1],i,S),this.h[1]=a(this.h[2],c,_),this.h[2]=a(this.h[3],d,E),this.h[3]=a(this.h[4],n,I),this.h[4]=a(this.h[0],r,w),this.h[0]=C},d.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"little"):r.split32(this.h,"little")};var p=[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],v=[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],y=[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:(t,e,n)=>{"use strict";e.sha1=n(4761),e.sha224=n(799),e.sha256=n(9344),e.sha384=n(772),e.sha512=n(5900)},4761:(t,e,n)=>{"use strict";var r=n(6436),i=n(5772),o=n(7038),s=r.rotl32,a=r.sum32,l=r.sum32_5,c=o.ft_1,d=i.BlockHash,u=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;d.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}r.inherits(h,d),t.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.prototype._update=function(t,e){for(var n=this.W,r=0;r<16;r++)n[r]=t[e+r];for(;r<n.length;r++)n[r]=s(n[r-3]^n[r-8]^n[r-14]^n[r-16],1);var i=this.h[0],o=this.h[1],d=this.h[2],h=this.h[3],f=this.h[4];for(r=0;r<n.length;r++){var p=~~(r/20),g=l(s(i,5),c(p,o,d,h),f,n[r],u[p]);f=h,h=d,d=s(o,30),o=i,i=g}this.h[0]=a(this.h[0],i),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],d),this.h[3]=a(this.h[3],h),this.h[4]=a(this.h[4],f)},h.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},799:(t,e,n)=>{"use strict";var r=n(6436),i=n(9344);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}r.inherits(o,i),t.exports=o,o.blockSize=512,o.outSize=224,o.hmacStrength=192,o.padLength=64,o.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h.slice(0,7),"big"):r.split32(this.h.slice(0,7),"big")}},9344:(t,e,n)=>{"use strict";var r=n(6436),i=n(5772),o=n(7038),s=n(9746),a=r.sum32,l=r.sum32_4,c=r.sum32_5,d=o.ch32,u=o.maj32,h=o.s0_256,f=o.s1_256,p=o.g0_256,g=o.g1_256,v=i.BlockHash,y=[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;v.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=y,this.W=new Array(64)}r.inherits(E,v),t.exports=E,E.blockSize=512,E.outSize=256,E.hmacStrength=192,E.padLength=64,E.prototype._update=function(t,e){for(var n=this.W,r=0;r<16;r++)n[r]=t[e+r];for(;r<n.length;r++)n[r]=l(g(n[r-2]),n[r-7],p(n[r-15]),n[r-16]);var i=this.h[0],o=this.h[1],v=this.h[2],y=this.h[3],E=this.h[4],I=this.h[5],w=this.h[6],S=this.h[7];for(s(this.k.length===n.length),r=0;r<n.length;r++){var _=c(S,f(E),d(E,I,w),this.k[r],n[r]),m=a(h(i),u(i,o,v));S=w,w=I,I=E,E=a(y,_),y=v,v=o,o=i,i=a(_,m)}this.h[0]=a(this.h[0],i),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],v),this.h[3]=a(this.h[3],y),this.h[4]=a(this.h[4],E),this.h[5]=a(this.h[5],I),this.h[6]=a(this.h[6],w),this.h[7]=a(this.h[7],S)},E.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},772:(t,e,n)=>{"use strict";var r=n(6436),i=n(5900);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}r.inherits(o,i),t.exports=o,o.blockSize=1024,o.outSize=384,o.hmacStrength=192,o.padLength=128,o.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h.slice(0,12),"big"):r.split32(this.h.slice(0,12),"big")}},5900:(t,e,n)=>{"use strict";var r=n(6436),i=n(5772),o=n(9746),s=r.rotr64_hi,a=r.rotr64_lo,l=r.shr64_hi,c=r.shr64_lo,d=r.sum64,u=r.sum64_hi,h=r.sum64_lo,f=r.sum64_4_hi,p=r.sum64_4_lo,g=r.sum64_5_hi,v=r.sum64_5_lo,y=i.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 I(){if(!(this instanceof I))return new I;y.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 w(t,e,n,r,i){var o=t&n^~t&i;return o<0&&(o+=4294967296),o}function S(t,e,n,r,i,o){var s=e&r^~e&o;return s<0&&(s+=4294967296),s}function _(t,e,n,r,i){var o=t&n^t&i^n&i;return o<0&&(o+=4294967296),o}function m(t,e,n,r,i,o){var s=e&r^e&o^r&o;return s<0&&(s+=4294967296),s}function C(t,e){var n=s(t,e,28)^s(e,t,2)^s(e,t,7);return n<0&&(n+=4294967296),n}function O(t,e){var n=a(t,e,28)^a(e,t,2)^a(e,t,7);return n<0&&(n+=4294967296),n}function A(t,e){var n=s(t,e,14)^s(t,e,18)^s(e,t,9);return n<0&&(n+=4294967296),n}function T(t,e){var n=a(t,e,14)^a(t,e,18)^a(e,t,9);return n<0&&(n+=4294967296),n}function b(t,e){var n=s(t,e,1)^s(t,e,8)^l(t,e,7);return n<0&&(n+=4294967296),n}function N(t,e){var n=a(t,e,1)^a(t,e,8)^c(t,e,7);return n<0&&(n+=4294967296),n}function P(t,e){var n=s(t,e,19)^s(e,t,29)^l(t,e,6);return n<0&&(n+=4294967296),n}function D(t,e){var n=a(t,e,19)^a(e,t,29)^c(t,e,6);return n<0&&(n+=4294967296),n}r.inherits(I,y),t.exports=I,I.blockSize=1024,I.outSize=512,I.hmacStrength=192,I.padLength=128,I.prototype._prepareBlock=function(t,e){for(var n=this.W,r=0;r<32;r++)n[r]=t[e+r];for(;r<n.length;r+=2){var i=P(n[r-4],n[r-3]),o=D(n[r-4],n[r-3]),s=n[r-14],a=n[r-13],l=b(n[r-30],n[r-29]),c=N(n[r-30],n[r-29]),d=n[r-32],u=n[r-31];n[r]=f(i,o,s,a,l,c,d,u),n[r+1]=p(i,o,s,a,l,c,d,u)}},I.prototype._update=function(t,e){this._prepareBlock(t,e);var n=this.W,r=this.h[0],i=this.h[1],s=this.h[2],a=this.h[3],l=this.h[4],c=this.h[5],f=this.h[6],p=this.h[7],y=this.h[8],E=this.h[9],I=this.h[10],b=this.h[11],N=this.h[12],P=this.h[13],D=this.h[14],R=this.h[15];o(this.k.length===n.length);for(var L=0;L<n.length;L+=2){var U=D,k=R,M=A(y,E),F=T(y,E),B=w(y,E,I,b,N),j=S(y,E,I,b,N,P),x=this.k[L],V=this.k[L+1],$=n[L],H=n[L+1],K=g(U,k,M,F,B,j,x,V,$,H),W=v(U,k,M,F,B,j,x,V,$,H);U=C(r,i),k=O(r,i),M=_(r,i,s,a,l),F=m(r,i,s,a,l,c);var G=u(U,k,M,F),q=h(U,k,M,F);D=N,R=P,N=I,P=b,I=y,b=E,y=u(f,p,K,W),E=h(p,p,K,W),f=l,p=c,l=s,c=a,s=r,a=i,r=u(K,W,G,q),i=h(K,W,G,q)}d(this.h,0,r,i),d(this.h,2,s,a),d(this.h,4,l,c),d(this.h,6,f,p),d(this.h,8,y,E),d(this.h,10,I,b),d(this.h,12,N,P),d(this.h,14,D,R)},I.prototype._digest=function(t){return"hex"===t?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},7038:(t,e,n)=>{"use strict";var r=n(6436).rotr32;function i(t,e,n){return t&e^~t&n}function o(t,e,n){return t&e^t&n^e&n}function s(t,e,n){return t^e^n}e.ft_1=function(t,e,n,r){return 0===t?i(e,n,r):1===t||3===t?s(e,n,r):2===t?o(e,n,r):void 0},e.ch32=i,e.maj32=o,e.p32=s,e.s0_256=function(t){return r(t,2)^r(t,13)^r(t,22)},e.s1_256=function(t){return r(t,6)^r(t,11)^r(t,25)},e.g0_256=function(t){return r(t,7)^r(t,18)^t>>>3},e.g1_256=function(t){return r(t,17)^r(t,19)^t>>>10}},6436:(t,e,n)=>{"use strict";var r=n(9746),i=n(5717);function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function l(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}e.inherits=i,e.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var n=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i<t.length;i+=2)n.push(parseInt(t[i]+t[i+1],16))}else for(var r=0,i=0;i<t.length;i++){var s=t.charCodeAt(i);s<128?n[r++]=s:s<2048?(n[r++]=s>>6|192,n[r++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),n[r++]=s>>18|240,n[r++]=s>>12&63|128,n[r++]=s>>6&63|128,n[r++]=63&s|128):(n[r++]=s>>12|224,n[r++]=s>>6&63|128,n[r++]=63&s|128)}else for(i=0;i<t.length;i++)n[i]=0|t[i];return n},e.toHex=function(t){for(var e="",n=0;n<t.length;n++)e+=a(t[n].toString(16));return e},e.htonl=s,e.toHex32=function(t,e){for(var n="",r=0;r<t.length;r++){var i=t[r];"little"===e&&(i=s(i)),n+=l(i.toString(16))}return n},e.zero2=a,e.zero8=l,e.join32=function(t,e,n,i){var o=n-e;r(o%4==0);for(var s=new Array(o/4),a=0,l=e;a<s.length;a++,l+=4){var c;c="big"===i?t[l]<<24|t[l+1]<<16|t[l+2]<<8|t[l+3]:t[l+3]<<24|t[l+2]<<16|t[l+1]<<8|t[l],s[a]=c>>>0}return s},e.split32=function(t,e){for(var n=new Array(4*t.length),r=0,i=0;r<t.length;r++,i+=4){var o=t[r];"big"===e?(n[i]=o>>>24,n[i+1]=o>>>16&255,n[i+2]=o>>>8&255,n[i+3]=255&o):(n[i+3]=o>>>24,n[i+2]=o>>>16&255,n[i+1]=o>>>8&255,n[i]=255&o)}return n},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return t<<e|t>>>32-e},e.sum32=function(t,e){return t+e>>>0},e.sum32_3=function(t,e,n){return t+e+n>>>0},e.sum32_4=function(t,e,n,r){return t+e+n+r>>>0},e.sum32_5=function(t,e,n,r,i){return t+e+n+r+i>>>0},e.sum64=function(t,e,n,r){var i=t[e],o=r+t[e+1]>>>0,s=(o<r?1:0)+n+i;t[e]=s>>>0,t[e+1]=o},e.sum64_hi=function(t,e,n,r){return(e+r>>>0<e?1:0)+t+n>>>0},e.sum64_lo=function(t,e,n,r){return e+r>>>0},e.sum64_4_hi=function(t,e,n,r,i,o,s,a){var l=0,c=e;return l+=(c=c+r>>>0)<e?1:0,l+=(c=c+o>>>0)<o?1:0,t+n+i+s+(l+=(c=c+a>>>0)<a?1:0)>>>0},e.sum64_4_lo=function(t,e,n,r,i,o,s,a){return e+r+o+a>>>0},e.sum64_5_hi=function(t,e,n,r,i,o,s,a,l,c){var d=0,u=e;return d+=(u=u+r>>>0)<e?1:0,d+=(u=u+o>>>0)<o?1:0,d+=(u=u+a>>>0)<a?1:0,t+n+i+s+l+(d+=(u=u+c>>>0)<c?1:0)>>>0},e.sum64_5_lo=function(t,e,n,r,i,o,s,a,l,c){return e+r+o+a+c>>>0},e.rotr64_hi=function(t,e,n){return(e<<32-n|t>>>n)>>>0},e.rotr64_lo=function(t,e,n){return(t<<32-n|e>>>n)>>>0},e.shr64_hi=function(t,e,n){return t>>>n},e.shr64_lo=function(t,e,n){return(t<<32-n|e>>>n)>>>0}},645:(t,e)=>{e.read=function(t,e,n,r,i){var o,s,a=8*i-r-1,l=(1<<a)-1,c=l>>1,d=-7,u=n?i-1:0,h=n?-1:1,f=t[e+u];for(u+=h,o=f&(1<<-d)-1,f>>=-d,d+=a;d>0;o=256*o+t[e+u],u+=h,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=r;d>0;s=256*s+t[e+u],u+=h,d-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),o-=c}return(f?-1:1)*s*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var s,a,l,c=8*o-i-1,d=(1<<c)-1,u=d>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=d):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+u>=1?h/l:h*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(e*l-1)*Math.pow(2,i),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,i),s=0));i>=8;t[n+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;t[n+f]=255&s,f+=p,s/=256,c-=8);t[n+f-p]|=128*g}},5717:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}},5299:(t,e,n)=>{"use strict";var r=n(7798);function i(t){return!0===r(t)&&"[object Object]"===Object.prototype.toString.call(t)}t.exports=function(t){var e,n;return!1!==i(t)&&("function"==typeof(e=t.constructor)&&(!1!==i(n=e.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")))}},7798:t=>{"use strict";t.exports=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)}},6245:(t,e,n)=>{"use strict";function r(t){this.message=t}n.r(e),n.d(e,{InvalidTokenError:()=>s,default:()=>a}),r.prototype=new Error,r.prototype.name="InvalidCharacterError";var i="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,o=0,s=0,a="";i=e.charAt(s++);~i&&(n=o%4?64*n+i:i,o++%4)?a+=String.fromCharCode(255&n>>(-2*o&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return a};function o(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(i(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return i(e)}}function s(t){this.message=t}s.prototype=new Error,s.prototype.name="InvalidTokenError";const a=function(t,e){if("string"!=typeof t)throw new s("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(o(t.split(".")[n]))}catch(t){throw new s("Invalid token specified: "+t.message)}}},6401:t=>{var e=Object.prototype.toString;function n(t){return"function"==typeof t.constructor?t.constructor.name:null}t.exports=function(t){if(void 0===t)return"undefined";if(null===t)return"null";var r=typeof t;if("boolean"===r)return"boolean";if("string"===r)return"string";if("number"===r)return"number";if("symbol"===r)return"symbol";if("function"===r)return"GeneratorFunction"===n(t)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(t))return"array";if(function(t){if(t.constructor&&"function"==typeof t.constructor.isBuffer)return t.constructor.isBuffer(t);return!1}(t))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}(t))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(t))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(t))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(t))return"regexp";switch(n(t)){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(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(t))return"generator";switch(r=e.call(t)){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 r.slice(8,-1).toLowerCase().replace(/\s/g,"")}},9746:t=>{function e(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=e,e.equal=function(t,e,n){if(t!=e)throw new Error(n||"Assertion failed: "+t+" != "+e)}},4155:t=>{var e,n,r=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(t){if(e===setTimeout)return setTimeout(t,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:i}catch(t){e=i}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var a,l=[],c=!1,d=-1;function u(){c&&a&&(c=!1,a.length?l=a.concat(l):d=-1,l.length&&h())}function h(){if(!c){var t=s(u);c=!0;for(var e=l.length;e;){for(a=l,l=[];++d<e;)a&&a[d].run();d=-1,e=l.length}a=null,c=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{return n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function f(t,e){this.fun=t,this.array=e}function p(){}r.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];l.push(new f(t,e)),1!==l.length||c||s(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=p,r.addListener=p,r.once=p,r.off=p,r.removeListener=p,r.removeAllListeners=p,r.emit=p,r.prependListener=p,r.prependOnceListener=p,r.listeners=function(t){return[]},r.binding=function(t){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(t){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},3341:(t,e,n)=>{"use strict";var r=n(8764).lW;const i=Symbol.prototype.valueOf,o=n(6401);t.exports=function(t,e){switch(o(t)){case"array":return t.slice();case"object":return Object.assign({},t);case"date":return new t.constructor(Number(t));case"map":return new Map(t);case"set":return new Set(t);case"buffer":return function(t){const e=t.length,n=r.allocUnsafe?r.allocUnsafe(e):r.from(e);return t.copy(n),n}(t);case"symbol":return function(t){return i?Object(i.call(t)):{}}(t);case"arraybuffer":return function(t){const e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e}(t);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return function(t,e){return new t.constructor(t.buffer,t.byteOffset,t.length)}(t);case"regexp":return function(t){const e=void 0!==t.flags?t.flags:/\w+$/.exec(t)||void 0,n=new t.constructor(t.source,e);return n.lastIndex=t.lastIndex,n}(t);case"error":return Object.create(t);default:return t}}},655:(t,e,n)=>{"use strict";n.r(e),n.d(e,{__assign:()=>o,__asyncDelegator:()=>S,__asyncGenerator:()=>w,__asyncValues:()=>_,__await:()=>I,__awaiter:()=>d,__classPrivateFieldGet:()=>T,__classPrivateFieldSet:()=>b,__createBinding:()=>h,__decorate:()=>a,__exportStar:()=>f,__extends:()=>i,__generator:()=>u,__importDefault:()=>A,__importStar:()=>O,__makeTemplateObject:()=>m,__metadata:()=>c,__param:()=>l,__read:()=>g,__rest:()=>s,__spread:()=>v,__spreadArray:()=>E,__spreadArrays:()=>y,__values:()=>p});var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},o.apply(this,arguments)};function s(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function a(t,e,n,r){var i,o=arguments.length,s=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s}function l(t,e){return function(n,r){e(n,r,t)}}function c(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function d(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{l(r.next(t))}catch(t){o(t)}}function a(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((r=r.apply(t,e||[])).next())}))}function u(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}var h=Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]};function f(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||h(e,t,n)}function p(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function v(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(g(arguments[e]));return t}function y(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r}function E(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function I(t){return this instanceof I?(this.v=t,this):new I(t)}function w(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(t,e||[]),o=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(t){i[t]&&(r[t]=function(e){return new Promise((function(n,r){o.push([t,e,n,r])>1||a(t,e)}))})}function a(t,e){try{(n=i[t](e)).value instanceof I?Promise.resolve(n.value.v).then(l,c):d(o[0][2],n)}catch(t){d(o[0][3],t)}var n}function l(t){a("next",t)}function c(t){a("throw",t)}function d(t,e){t(e),o.shift(),o.length&&a(o[0][0],o[0][1])}}function S(t){var e,n;return e={},r("next"),r("throw",(function(t){throw t})),r("return"),e[Symbol.iterator]=function(){return this},e;function r(r,i){e[r]=t[r]?function(e){return(n=!n)?{value:I(t[r](e)),done:"return"===r}:i?i(e):e}:i}}function _(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=p(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,i){(function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)})(r,i,(e=t[n](e)).done,e.value)}))}}}function m(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var C=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};function O(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&h(e,t,n);return C(e,t),e}function A(t){return t&&t.__esModule?t:{default:t}}function T(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}function b(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n}}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={exports:{}};return t[r].call(o.exports,o,o.exports,n),o.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r=n(3056);module.exports=r})();