@descope/web-component 3.34.0 → 3.34.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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("tslib"),e=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins/static-resources-mixin"),s=require("@descope/sdk-mixins/theme-mixin"),r=require("@descope/web-js-sdk"),o=require("../constants/index.js"),n=require("../helpers/helpers.js"),a=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var l,d,u,c,h,g,f,v,p,_,b,m,w,C,F,A,P,x,k,E,I,G=require("../helpers/flowInputs.js"),y=require("../mixins/formMountMixin.js"),j=require("./initTemplate.js"),L=require("../constants/content.js"),U=require("../constants/general.js");function M(t){return Object.freeze({__proto__:null,default:t})}const S=e.compose(s.themeMixin,i.staticResourcesMixin,y.formMountMixin)(HTMLElement);class O extends S{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),l.add(this),u.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,l,"m",E).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},c.set(this,new a),h.set(this,new a),g.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,g,"f"),this.nextRequestStatus=new a({isLoading:!1}),f.set(this,void 0),v.set(this,{popstate:t.__classPrivateFieldGet(this,l,"m",m).bind(this),componentsContext:t.__classPrivateFieldGet(this,l,"m",P).bind(this)}),p.set(this,void 0),this.getConfig=()=>t.__awaiter(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),t.__classPrivateFieldSet(this,p,e,"f"),t.__classPrivateFieldGet(this,l,"m",_).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return G.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return G.extractNestedAttribute(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return t.__awaiter(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),s=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=s.version)&&void 0!==e||(s.version=0),s}))}getTargetLocales(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}getComponentsVersion(){return t.__awaiter(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return t.__awaiter(this,void 0,void 0,(function*(){var i;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(i=e.init)||void 0===i?void 0:i.call(this),t.__classPrivateFieldGet(this,h,"f").subscribe(t.__classPrivateFieldGet(this,l,"m",k).bind(this)),t.__classPrivateFieldGet(this,h,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,l,"m",b).call(this),yield t.__classPrivateFieldGet(this,l,"m",F).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const s=yield this.getConfig();if("isMissingConfig"in s&&s.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t.__classPrivateFieldGet(this,l,"m",I).call(this);const{executionId:r,stepId:o,token:a,code:d,exchangeError:g,redirectAuthCallbackUrl:f,redirectAuthBackupCallbackUri:p,redirectAuthCodeChallenge:_,redirectAuthInitiator:m,ssoQueryParams:w}=n.handleUrlParams(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t.__classPrivateFieldGet(this,v,"f").popstate),window.addEventListener("components-context",t.__classPrivateFieldGet(this,v,"f").componentsContext),t.__classPrivateFieldGet(this,c,"f").subscribe(t.__classPrivateFieldGet(this,l,"m",C).bind(this)),t.__classPrivateFieldGet(this,c,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:r,token:a,code:d,exchangeError:g,redirectAuthCallbackUrl:f,redirectAuthBackupCallbackUri:p,redirectAuthCodeChallenge:_,redirectAuthInitiator:m},w)),t.__classPrivateFieldSet(this,u,!0,"f")}))}disconnectedCallback(){t.__classPrivateFieldGet(this,c,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,h,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,l,"m",x).call(this),window.removeEventListener("popstate",t.__classPrivateFieldGet(this,v,"f").popstate),window.removeEventListener("components-context",t.__classPrivateFieldGet(this,v,"f").componentsContext)}attributeChangedCallback(e,i,s){if(this.shadowRoot.isConnected&&t.__classPrivateFieldGet(this,u,"f")&&i!==s&&d.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,l,"m",b).call(this);const r=null===i;t.__classPrivateFieldGet(this,c,"f").update((({stepId:t,executionId:i})=>{let o=t,a=i;return r||(a=null,o=null,n.clearRunIdsFromUrl()),{[n.camelCase(e)]:s,stepId:o,executionId:a}})),t.__classPrivateFieldGet(this,h,"f").update({isDebug:this.debug})}}}d=O,u=new WeakMap,c=new WeakMap,h=new WeakMap,g=new WeakMap,f=new WeakMap,v=new WeakMap,p=new WeakMap,l=new WeakSet,_=function(){this.shadowRoot.appendChild(j.content.cloneNode(!0)),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},b=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];d.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[n.camelCase(e)])throw Error(`${e} cannot be empty`)}))},m=function(){const{stepId:e,executionId:i}=n.getRunIdsFromUrl(this.flowId);t.__classPrivateFieldGet(this,c,"f").update({stepId:e,executionId:i})},w=function(e,i){this.sdk=r(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},d.sdkConfigOverrides),{projectId:e,baseUrl:i})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...e)}catch(t){return{error:{errorCode:U.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},C=function(e,i,s){return t.__awaiter(this,void 0,void 0,(function*(){const{projectId:i,baseUrl:r}=e;if(s("projectId")||s("baseUrl")){if(!i)return;t.__classPrivateFieldGet(this,l,"m",w).call(this,i,r)}t.__classPrivateFieldGet(this,p,"f").call(this,e)}))},F=function(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t.__classPrivateFieldGet(this,l,"m",A).call(this))}))},A=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=n.getContentUrl({projectId:this.projectId,filename:L.CONFIG_FILENAME,assetsFolder:L.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield n.fetchContent(t,"json"),!0}catch(t){return!1}}))},P=function(e){t.__classPrivateFieldSet(this,g,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,g,"f")),e.detail),"f")},x=function(){var e;null===(e=t.__classPrivateFieldGet(this,f,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,f,null,"f")},k=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,f,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,f,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return M(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,f,"f"))):t.__classPrivateFieldGet(this,l,"m",x).call(this)}))},E=function(e,i){var s;e&&this.debug&&(null===(s=t.__classPrivateFieldGet(this,f,"f"))||void 0===s||s.updateData({title:e,description:i}))},I=function(){this.rootElement.onkeydown=t=>{var e,i,s;const r=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),n=o.ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(null!==(s=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==s?s:"");if("Enter"!==t.key||r||n)return;t.preventDefault();const a=this.rootElement.querySelectorAll("descope-button");if(1===a.length&&"false"!==a[0].getAttribute("auto-submit"))return void a[0].click();const l=Array.from(a).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===l.length)return void l[0].click();const d=Array.from(a).filter((t=>"button"===t.getAttribute("data-type")));if(1===d.length)"false"!==d[0].getAttribute("auto-submit")&&d[0].click();else if(0===d.length){const t=Array.from(a).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},O.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.34.0"}},module.exports=O;
|
|
1
|
+
"use strict";var t=require("tslib"),e=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins/static-resources-mixin"),s=require("@descope/sdk-mixins/theme-mixin"),r=require("@descope/web-js-sdk"),o=require("../constants/index.js"),n=require("../helpers/helpers.js"),a=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var l,d,u,c,h,g,f,v,p,_,b,m,w,C,F,A,P,x,k,E,I,G=require("../helpers/flowInputs.js"),y=require("../mixins/formMountMixin.js"),j=require("./initTemplate.js"),L=require("../constants/content.js"),U=require("../constants/general.js");function M(t){return Object.freeze({__proto__:null,default:t})}const S=e.compose(s.themeMixin,i.staticResourcesMixin,y.formMountMixin)(HTMLElement);class O extends S{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),l.add(this),u.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,l,"m",E).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},c.set(this,new a),h.set(this,new a),g.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,g,"f"),this.nextRequestStatus=new a({isLoading:!1}),f.set(this,void 0),v.set(this,{popstate:t.__classPrivateFieldGet(this,l,"m",m).bind(this),componentsContext:t.__classPrivateFieldGet(this,l,"m",P).bind(this)}),p.set(this,void 0),this.getConfig=()=>t.__awaiter(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),t.__classPrivateFieldSet(this,p,e,"f"),t.__classPrivateFieldGet(this,l,"m",_).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return G.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return G.extractNestedAttribute(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return t.__awaiter(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),s=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=s.version)&&void 0!==e||(s.version=0),s}))}getTargetLocales(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}getComponentsVersion(){return t.__awaiter(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return t.__awaiter(this,void 0,void 0,(function*(){var i;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(i=e.init)||void 0===i?void 0:i.call(this),t.__classPrivateFieldGet(this,h,"f").subscribe(t.__classPrivateFieldGet(this,l,"m",k).bind(this)),t.__classPrivateFieldGet(this,h,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,l,"m",b).call(this),yield t.__classPrivateFieldGet(this,l,"m",F).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const s=yield this.getConfig();if("isMissingConfig"in s&&s.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t.__classPrivateFieldGet(this,l,"m",I).call(this);const{executionId:r,stepId:o,token:a,code:d,exchangeError:g,redirectAuthCallbackUrl:f,redirectAuthBackupCallbackUri:p,redirectAuthCodeChallenge:_,redirectAuthInitiator:m,ssoQueryParams:w}=n.handleUrlParams(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t.__classPrivateFieldGet(this,v,"f").popstate),window.addEventListener("components-context",t.__classPrivateFieldGet(this,v,"f").componentsContext),t.__classPrivateFieldGet(this,c,"f").subscribe(t.__classPrivateFieldGet(this,l,"m",C).bind(this)),t.__classPrivateFieldGet(this,c,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:r,token:a,code:d,exchangeError:g,redirectAuthCallbackUrl:f,redirectAuthBackupCallbackUri:p,redirectAuthCodeChallenge:_,redirectAuthInitiator:m},w)),t.__classPrivateFieldSet(this,u,!0,"f")}))}disconnectedCallback(){t.__classPrivateFieldGet(this,c,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,h,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,l,"m",x).call(this),window.removeEventListener("popstate",t.__classPrivateFieldGet(this,v,"f").popstate),window.removeEventListener("components-context",t.__classPrivateFieldGet(this,v,"f").componentsContext)}attributeChangedCallback(e,i,s){if(this.shadowRoot.isConnected&&t.__classPrivateFieldGet(this,u,"f")&&i!==s&&d.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,l,"m",b).call(this);const r=null===i;t.__classPrivateFieldGet(this,c,"f").update((({stepId:t,executionId:i})=>{let o=t,a=i;return r||(a=null,o=null,n.clearRunIdsFromUrl()),{[n.camelCase(e)]:s,stepId:o,executionId:a}})),t.__classPrivateFieldGet(this,h,"f").update({isDebug:this.debug})}}}d=O,u=new WeakMap,c=new WeakMap,h=new WeakMap,g=new WeakMap,f=new WeakMap,v=new WeakMap,p=new WeakMap,l=new WeakSet,_=function(){this.shadowRoot.appendChild(j.content.cloneNode(!0)),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},b=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];d.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[n.camelCase(e)])throw Error(`${e} cannot be empty`)}))},m=function(){const{stepId:e,executionId:i}=n.getRunIdsFromUrl(this.flowId);t.__classPrivateFieldGet(this,c,"f").update({stepId:e,executionId:i})},w=function(e,i){this.sdk=r(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},d.sdkConfigOverrides),{projectId:e,baseUrl:i})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...e)}catch(t){return{error:{errorCode:U.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},C=function(e,i,s){return t.__awaiter(this,void 0,void 0,(function*(){const{projectId:i,baseUrl:r}=e;if(s("projectId")||s("baseUrl")){if(!i)return;t.__classPrivateFieldGet(this,l,"m",w).call(this,i,r)}t.__classPrivateFieldGet(this,p,"f").call(this,e)}))},F=function(){return t.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t.__classPrivateFieldGet(this,l,"m",A).call(this))}))},A=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=n.getContentUrl({projectId:this.projectId,filename:L.CONFIG_FILENAME,assetsFolder:L.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield n.fetchContent(t,"json"),!0}catch(t){return!1}}))},P=function(e){t.__classPrivateFieldSet(this,g,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,g,"f")),e.detail),"f")},x=function(){var e;null===(e=t.__classPrivateFieldGet(this,f,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,f,null,"f")},k=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,f,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,f,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return M(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,f,"f"))):t.__classPrivateFieldGet(this,l,"m",x).call(this)}))},E=function(e,i){var s;e&&this.debug&&(null===(s=t.__classPrivateFieldGet(this,f,"f"))||void 0===s||s.updateData({title:e,description:i}))},I=function(){this.rootElement.onkeydown=t=>{var e,i,s;const r=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),n=o.ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(null!==(s=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==s?s:"");if("Enter"!==t.key||r||n)return;t.preventDefault();const a=this.rootElement.querySelectorAll("descope-button");if(1===a.length&&"false"!==a[0].getAttribute("auto-submit"))return void a[0].click();const l=Array.from(a).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===l.length)return void l[0].click();const d=Array.from(a).filter((t=>"button"===t.getAttribute("data-type")));if(1===d.length)"false"!==d[0].getAttribute("auto-submit")&&d[0].click();else if(0===d.length){const t=Array.from(a).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},O.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.34.1"}},module.exports=O;
|
|
2
2
|
//# sourceMappingURL=BaseDescopeWc.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import{compose as r}from"@descope/sdk-helpers";import{staticResourcesMixin as s}from"@descope/sdk-mixins/static-resources-mixin";import{themeMixin as o}from"@descope/sdk-mixins/theme-mixin";import n from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as u}from"../constants/index.js";import{handleUrlParams as a,clearRunIdsFromUrl as l,camelCase as d,getRunIdsFromUrl as c,getContentUrl as h,fetchContent as f}from"../helpers/helpers.js";import g from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{transformFlowInputFormData as p,extractNestedAttribute as v}from"../helpers/flowInputs.js";import{formMountMixin as m}from"../mixins/formMountMixin.js";import b from"./initTemplate.js";import{CONFIG_FILENAME as w,PREV_VER_ASSETS_FOLDER as C}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as A}from"../constants/general.js";var k,x,y,j,I,E,L,U,M,S,O,W,D,R,P,F,T,q,B,N,V;const H=r(o,s,m)(HTMLElement);class K extends H{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(r){super(),k.add(this),y.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,k,"m",N).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},j.set(this,new g),I.set(this,new g),E.set(this,{}),this.getComponentsContext=()=>t(this,E,"f"),this.nextRequestStatus=new g({isLoading:!1}),L.set(this,void 0),U.set(this,{popstate:t(this,k,"m",W).bind(this),componentsContext:t(this,k,"m",T).bind(this)}),M.set(this,void 0),this.getConfig=()=>e(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,M,r,"f"),t(this,k,"m",S).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return p(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return v(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return e(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}getComponentsVersion(){return e(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const r=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=r.init)||void 0===e?void 0:e.call(this),t(this,I,"f").subscribe(t(this,k,"m",B).bind(this)),t(this,I,"f").update({isDebug:this.debug}),t(this,k,"m",O).call(this),yield t(this,k,"m",P).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const s=yield this.getConfig();if("isMissingConfig"in s&&s.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t(this,k,"m",V).call(this);const{executionId:o,stepId:n,token:u,code:l,exchangeError:d,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:f,redirectAuthInitiator:g,ssoQueryParams:p}=a(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t(this,U,"f").popstate),window.addEventListener("components-context",t(this,U,"f").componentsContext),t(this,j,"f").subscribe(t(this,k,"m",R).bind(this)),t(this,j,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:o,token:u,code:l,exchangeError:d,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:f,redirectAuthInitiator:g},p)),i(this,y,!0,"f")}))}disconnectedCallback(){t(this,j,"f").unsubscribeAll(),t(this,I,"f").unsubscribeAll(),t(this,k,"m",q).call(this),window.removeEventListener("popstate",t(this,U,"f").popstate),window.removeEventListener("components-context",t(this,U,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t(this,y,"f")&&i!==r&&x.observedAttributes.includes(e)){t(this,k,"m",O).call(this);const s=null===i;t(this,j,"f").update((({stepId:t,executionId:i})=>{let o=t,n=i;return s||(n=null,o=null,l()),{[d(e)]:r,stepId:o,executionId:n}})),t(this,I,"f").update({isDebug:this.debug})}}}x=K,y=new WeakMap,j=new WeakMap,I=new WeakMap,E=new WeakMap,L=new WeakMap,U=new WeakMap,M=new WeakMap,k=new WeakSet,S=function(){this.shadowRoot.appendChild(b.content.cloneNode(!0)),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},O=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];x.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[d(e)])throw Error(`${e} cannot be empty`)}))},W=function(){const{stepId:e,executionId:i}=c(this.flowId);t(this,j,"f").update({stepId:e,executionId:i})},D=function(t,i){this.sdk=n(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},x.sdkConfigOverrides),{projectId:t,baseUrl:i})),["start","next"].forEach((t=>{const i=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>e(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...t)}catch(t){return{error:{errorCode:A,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},R=function(i,r,s){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:r}=i;if(s("projectId")||s("baseUrl")){if(!e)return;t(this,k,"m",D).call(this,e,r)}t(this,M,"f").call(this,i)}))},P=function(){return e(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t(this,k,"m",F).call(this))}))},F=function(){return e(this,void 0,void 0,(function*(){const t=h({projectId:this.projectId,filename:w,assetsFolder:C,baseUrl:this.baseStaticUrl});try{return yield f(t,"json"),!0}catch(t){return!1}}))},T=function(e){i(this,E,Object.assign(Object.assign({},t(this,E,"f")),e.detail),"f")},q=function(){var e;null===(e=t(this,L,"f"))||void 0===e||e.remove(),i(this,L,null,"f")},B=function(r){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,L,document.createElement("descope-debugger"),"f"),Object.assign(t(this,L,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("../debugger-wc.js"),document.body.appendChild(t(this,L,"f"))):t(this,k,"m",q).call(this)}))},N=function(e,i){var r;e&&this.debug&&(null===(r=t(this,L,"f"))||void 0===r||r.updateData({title:e,description:i}))},V=function(){this.rootElement.onkeydown=t=>{var e,i,r;const s=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),o=u.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||s||o)return;t.preventDefault();const n=this.rootElement.querySelectorAll("descope-button");if(1===n.length&&"false"!==n[0].getAttribute("auto-submit"))return void n[0].click();const a=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(n).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(n).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},K.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.34.0"}};export{K as default};
|
|
1
|
+
import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import{compose as r}from"@descope/sdk-helpers";import{staticResourcesMixin as s}from"@descope/sdk-mixins/static-resources-mixin";import{themeMixin as o}from"@descope/sdk-mixins/theme-mixin";import n from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as u}from"../constants/index.js";import{handleUrlParams as a,clearRunIdsFromUrl as l,camelCase as d,getRunIdsFromUrl as c,getContentUrl as h,fetchContent as f}from"../helpers/helpers.js";import g from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{transformFlowInputFormData as p,extractNestedAttribute as v}from"../helpers/flowInputs.js";import{formMountMixin as m}from"../mixins/formMountMixin.js";import b from"./initTemplate.js";import{CONFIG_FILENAME as w,PREV_VER_ASSETS_FOLDER as C}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as A}from"../constants/general.js";var k,x,y,j,I,E,L,U,M,S,O,W,D,R,P,F,T,q,B,N,V;const H=r(o,s,m)(HTMLElement);class K extends H{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(r){super(),k.add(this),y.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,k,"m",N).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},j.set(this,new g),I.set(this,new g),E.set(this,{}),this.getComponentsContext=()=>t(this,E,"f"),this.nextRequestStatus=new g({isLoading:!1}),L.set(this,void 0),U.set(this,{popstate:t(this,k,"m",W).bind(this),componentsContext:t(this,k,"m",T).bind(this)}),M.set(this,void 0),this.getConfig=()=>e(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,M,r,"f"),t(this,k,"m",S).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return p(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return v(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return e(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}getComponentsVersion(){return e(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),i="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const r=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=r.init)||void 0===e?void 0:e.call(this),t(this,I,"f").subscribe(t(this,k,"m",B).bind(this)),t(this,I,"f").update({isDebug:this.debug}),t(this,k,"m",O).call(this),yield t(this,k,"m",P).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const s=yield this.getConfig();if("isMissingConfig"in s&&s.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t(this,k,"m",V).call(this);const{executionId:o,stepId:n,token:u,code:l,exchangeError:d,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:f,redirectAuthInitiator:g,ssoQueryParams:p}=a(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t(this,U,"f").popstate),window.addEventListener("components-context",t(this,U,"f").componentsContext),t(this,j,"f").subscribe(t(this,k,"m",R).bind(this)),t(this,j,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:n,executionId:o,token:u,code:l,exchangeError:d,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:f,redirectAuthInitiator:g},p)),i(this,y,!0,"f")}))}disconnectedCallback(){t(this,j,"f").unsubscribeAll(),t(this,I,"f").unsubscribeAll(),t(this,k,"m",q).call(this),window.removeEventListener("popstate",t(this,U,"f").popstate),window.removeEventListener("components-context",t(this,U,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t(this,y,"f")&&i!==r&&x.observedAttributes.includes(e)){t(this,k,"m",O).call(this);const s=null===i;t(this,j,"f").update((({stepId:t,executionId:i})=>{let o=t,n=i;return s||(n=null,o=null,l()),{[d(e)]:r,stepId:o,executionId:n}})),t(this,I,"f").update({isDebug:this.debug})}}}x=K,y=new WeakMap,j=new WeakMap,I=new WeakMap,E=new WeakMap,L=new WeakMap,U=new WeakMap,M=new WeakMap,k=new WeakSet,S=function(){this.shadowRoot.appendChild(b.content.cloneNode(!0)),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},O=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];x.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[d(e)])throw Error(`${e} cannot be empty`)}))},W=function(){const{stepId:e,executionId:i}=c(this.flowId);t(this,j,"f").update({stepId:e,executionId:i})},D=function(t,i){this.sdk=n(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},x.sdkConfigOverrides),{projectId:t,baseUrl:i})),["start","next"].forEach((t=>{const i=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>e(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...t)}catch(t){return{error:{errorCode:A,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},R=function(i,r,s){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:r}=i;if(s("projectId")||s("baseUrl")){if(!e)return;t(this,k,"m",D).call(this,e,r)}t(this,M,"f").call(this,i)}))},P=function(){return e(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t(this,k,"m",F).call(this))}))},F=function(){return e(this,void 0,void 0,(function*(){const t=h({projectId:this.projectId,filename:w,assetsFolder:C,baseUrl:this.baseStaticUrl});try{return yield f(t,"json"),!0}catch(t){return!1}}))},T=function(e){i(this,E,Object.assign(Object.assign({},t(this,E,"f")),e.detail),"f")},q=function(){var e;null===(e=t(this,L,"f"))||void 0===e||e.remove(),i(this,L,null,"f")},B=function(r){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,L,document.createElement("descope-debugger"),"f"),Object.assign(t(this,L,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("../debugger-wc.js"),document.body.appendChild(t(this,L,"f"))):t(this,k,"m",q).call(this)}))},N=function(e,i){var r;e&&this.debug&&(null===(r=t(this,L,"f"))||void 0===r||r.updateData({title:e,description:i}))},V=function(){this.rootElement.onkeydown=t=>{var e,i,r;const s=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),o=u.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||s||o)return;t.preventDefault();const n=this.rootElement.querySelectorAll("descope-button");if(1===n.length&&"false"!==n[0].getAttribute("auto-submit"))return void n[0].click();const a=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(n).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(n).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},K.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.34.1"}};export{K as default};
|
|
2
2
|
//# sourceMappingURL=BaseDescopeWc.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(){"use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(t);o<i.length;o++)e.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(t,i[o])&&(n[i[o]]=t[i[o]])}return n}function n(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))}function i(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function o(t,e,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(t,n):o?o.value=n:e.set(t,n),n}"function"==typeof SuppressedError&&SuppressedError;class r extends Error{}function s(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(t){return decodeURIComponent(atob(t).replace(/(.)/g,((t,e)=>{let n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return atob(e)}}function a(t,e){if("string"!=typeof t)throw new r("Invalid token specified: must be a string");e||(e={});const n=!0===e.header?0:1,i=t.split(".")[n];if("string"!=typeof i)throw new r(`Invalid token specified: missing part #${n+1}`);let o;try{o=s(i)}catch(t){throw new r(`Invalid token specified: invalid base64 for part #${n+1} (${t.message})`)}try{return JSON.parse(o)}catch(t){throw new r(`Invalid token specified: invalid json for part #${n+1} (${t.message})`)}}r.prototype.name="InvalidTokenError";var l="/v1/auth/accesskey/exchange",c="/v1/auth/otp/verify",d="/v1/auth/otp/signin",u="/v1/auth/otp/signup",h={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},p="/v1/auth/otp/signup-in",f="/v1/auth/magiclink/verify",g="/v1/auth/magiclink/signin",v="/v1/auth/magiclink/signup",m={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},b="/v1/auth/magiclink/signup-in",w="/v1/auth/enchantedlink/verify",y="/v1/auth/enchantedlink/signin",k="/v1/auth/enchantedlink/signup",I="/v1/auth/enchantedlink/pending-session",S={email:"/v1/auth/enchantedlink/update/email"},C="/v1/auth/enchantedlink/signup-in",x="/v1/auth/oauth/authorize",j="/v1/auth/oauth/exchange",O="v1/auth/oauth/native/start",A="v1/auth/oauth/native/finish",U="/v1/auth/saml/authorize",E="/v1/auth/saml/exchange",R="/v1/auth/totp/verify",L="/v1/auth/totp/signup",T="/v1/auth/totp/update",_="/v1/auth/notp/whatsapp/signin",$="/v1/auth/notp/whatsapp/signup",P="/v1/auth/notp/whatsapp/signup-in",M="/v1/auth/notp/pending-session",D={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},N={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},W={start:"/v1/auth/webauthn/signup-in/start"},q={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},F="/v1/auth/password/signup",B="/v1/auth/password/signin",V="/v1/auth/password/reset",K="/v1/auth/password/update",H="/v1/auth/password/replace",G="/v1/auth/password/policy",J="/v1/auth/refresh",z="/v1/auth/tenant/select",X="/v1/auth/logout",Q="/v1/auth/logoutall",Z="/v1/auth/me",Y="/v1/auth/me/tenants",tt="/v1/auth/me/history",et="/v1/flow/start",nt="/v1/flow/next";const it="<region>",ot=`https://api.${it}descope.com`,rt=6e5,st="dct",at=()=>{const t={};return{headers(e){const n="function"==typeof e.entries?Object.fromEntries(e.entries()):e;return t.Headers=JSON.stringify(n),this},body(e){return t.Body=e,this},url(e){return t.Url=e.toString(),this},method(e){return t.Method=e,this},title(e){return t.Title=e,this},status(e){return t.Status=e,this},build:()=>Object.keys(t).flatMap((e=>t[e]?[`${"Title"!==e?`${e}: `:""}${t[e]}`]:[])).join("\n")}};let lt;const ct=()=>{if(lt)return lt;const t=new Date,e=`${t.getUTCFullYear().toString()}-${(t.getUTCMonth()+1).toString().padStart(2,"0")}-${t.getUTCDate().toString().padStart(2,"0")}-${t.getUTCHours().toString().padStart(2,"0")}:${t.getUTCMinutes().toString().padStart(2,"0")}:${t.getUTCSeconds().toString().padStart(2,"0")}:${t.getUTCMilliseconds().toString()}`,n=Math.floor(1e3+9e3*Math.random());return lt=`${e}-${n}`,lt};var dt;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT",t.patch="PATCH"}(dt||(dt={}));const ut=({path:t,baseUrl:e,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);e=e.replace(it,o?o+".":"");let r=t?`${e.replace(/\/$/,"")}/${null==t?void 0:t.replace(/^\//,"")}`:e;if(n){const t=Object.keys(n);t.forEach(((e,i)=>{r=`${r}${0===i?"?":""}${e}=${encodeURIComponent(n[e])}${i===t.length-1?"":"&"}`}))}return r},ht=(...t)=>new Headers(t.reduce(((t,e)=>{const n=(t=>Array.isArray(t)?t:t instanceof Headers?Array.from(t.entries()):t?Object.entries(t):[])(e);return n.reduce(((e,[n,i])=>(t[n]=i,t)),t),t}),{})),pt={"Content-Type":"application/json"},ft=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},gt=t=>{try{t=JSON.parse(t)}catch(t){return!1}return"object"==typeof t&&null!==t},vt=({baseUrl:t,projectId:e,baseConfig:n,logger:i,hooks:o,cookiePolicy:r,fetch:s})=>{const a=((t,e)=>{const n=(t=>async(...e)=>{const n=await t(...e),i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),n.clone=()=>n,n})(e||fetch);return n||null==t||t.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),t?async(...e)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");t.log((t=>at().title("Request").url(t[0]).method(t[1].method).headers(t[1].headers).body(t[1].body).build())(e));const i=await n(...e);return t[i.ok?"log":"error"](await(async t=>{const e=await t.text();return at().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})(i)),i}:n})(i,s),l=async i=>{var s;const l=(null==o?void 0:o.beforeRequest)?o.beforeRequest(i):i,{path:c,body:d,headers:u,queryParams:h,method:p,token:f}=l,g=(t=>void 0===t?void 0:JSON.stringify(t))(d),v={headers:ht(ft(e,f),{"x-descope-sdk-session-id":ct(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.34.0"},(null==n?void 0:n.baseHeaders)||{},gt(g)?pt:{},u),method:p,body:g};null!==r&&(v.credentials=r||"include");const m=await a(ut({path:c,baseUrl:t,queryParams:h,projectId:e}),v);if((null==o?void 0:o.afterRequest)&&await o.afterRequest(i,null==m?void 0:m.clone()),null==o?void 0:o.transformResponse){const t=await m.json(),e=((null===(s=m.headers)||void 0===s?void 0:s.get("set-cookie"))||"").split(";").reduce(((t,e)=>{const[n,i]=e.split("=");return Object.assign(Object.assign({},t),{[n.trim()]:i})}),{}),n=Object.assign(Object.assign({},m),{json:()=>Promise.resolve(t),cookies:e});return n.clone=()=>n,o.transformResponse(n)}return m};return{get:(t,{headers:e,queryParams:n,token:i}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:dt.get,token:i}),post:(t,e,{headers:n,queryParams:i,token:o}={})=>l({path:t,headers:n,queryParams:i,body:e,method:dt.post,token:o}),patch:(t,e,{headers:n,queryParams:i,token:o}={})=>l({path:t,headers:n,queryParams:i,body:e,method:dt.patch,token:o}),put:(t,e,{headers:n,queryParams:i,token:o}={})=>l({path:t,headers:n,queryParams:i,body:e,method:dt.put,token:o}),delete:(t,{headers:e,queryParams:n,token:i}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:dt.delete,token:i}),hooks:o,buildUrl:(n,i)=>ut({projectId:e,baseUrl:t,path:n,queryParams:i})}};var mt=429;function bt(t,e,n){var i;let o=wt(t);if(e){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[st])===e)return(null==o?void 0:o[n])||[];o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[e]}const r=null==o?void 0:o[n];return Array.isArray(r)?r:[]}function wt(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return a(t)}function yt(t){const{exp:e}=wt(t);return(new Date).getTime()/1e3>e}function kt(t){let e=wt(t);const n=Object.keys(null==e?void 0:e.tenants);return Array.isArray(n)?n:[]}function It(t,e){return bt(t,e,"permissions")}function St(t,e){return bt(t,e,"roles")}const Ct=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function xt(t,e){var n;const i=await t,o={code:i.status,ok:i.ok,response:i},r=await i.clone().json();return i.ok?o.data=r:(o.error=r,i.status===mt&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}const jt=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Ot=(t,e)=>(n=e)=>e=>{const i=t.filter((t=>t(e)));return!(i.length<t.length)&&(n?n.replace("{val}",e):i.join(" OR "))},At=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Ut=t=>e=>t.test(e),Et=Ut(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Rt=Ut(/^\+[1-9]{1}[0-9]{3,14}$/),Lt=jt(Et,'"{val}" is not a valid email'),Tt=jt(Rt,'"{val}" is not a valid phone number'),_t=jt((t=>t.length>=1),"Minimum length is 1");const $t=jt((t=>"string"==typeof t),"Input is not a string"),Pt=jt((t=>Array.isArray(t)),"Input is not an array"),Mt=jt((t=>"boolean"==typeof t),"Input is not a boolean"),Dt=jt((t=>void 0===t),"Input is defined"),Nt=Ot([$t(),Dt()],"Input is not a string or undefined"),Wt=Ot([Pt(),Mt()],"Input is not an array or boolean"),qt=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>At(...t).validate(n[e]))),e(...n)),Ft=t=>[$t(`"${t}" must be a string`)],Bt=t=>[$t(`"${t}" must be a string`),_t(`"${t}" must not be empty`)],Vt=t=>[$t(`"${t}" must be a string`),Lt()],Kt=t=>[$t(`"${t}" must be a string`),Tt()],Ht=qt(Bt("accessKey")),Gt=t=>({exchange:Ht(((e,n)=>xt(t.post(l,{loginOptions:n},{token:e}))))}),Jt=(t,e,n)=>(e.forEach((e=>{const i=e.split(".");let o=i.shift(),r=t;for(;i.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${e}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof r[o])throw Error(`"${e}" is not a function`);const s=r[o];r[o]=n(s)})),t),zt=({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||rt,rt)});var Xt,Qt;!function(t){t.sms="sms",t.voice="voice",t.whatsapp="whatsapp"}(Xt||(Xt={})),function(t){t.email="email"}(Qt||(Qt={}));const Zt=Object.assign(Object.assign({},Xt),Qt);var Yt;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(Yt||(Yt={}));const te=Bt("loginId"),ee=qt(Bt("token")),ne=qt(te),ie=qt(Bt("pendingRef")),oe=qt(te,Vt("email")),re=t=>({verify:ee((e=>xt(t.post(w,{token:e})))),signIn:ne(((e,n,i,o)=>xt(t.post(Ct(y,Zt.email),{loginId:e,URI:n,loginOptions:i},{token:o})))),signUpOrIn:ne(((e,n,i)=>xt(t.post(Ct(C,Zt.email),{loginId:e,URI:n,loginOptions:i})))),signUp:ne(((e,n,i,o)=>xt(t.post(Ct(k,Zt.email),{loginId:e,URI:n,user:i,loginOptions:o})))),waitForSession:ie(((e,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=zt(n);let s;const a=setInterval((async()=>{const n=await t.post(I,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(xt(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:oe(((e,n,i,o,r)=>xt(t.post(S.email,Object.assign({loginId:e,email:n,URI:i},r),{token:o}))))}}),se=qt(Bt("flowId")),ae=qt(Bt("executionId"),Bt("stepId"),Bt("interactionId")),le=t=>({start:se(((e,n,i,o,r,s,a)=>xt(t.post(et,{flowId:e,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a})))),next:ae(((e,n,i,o,r,s)=>xt(t.post(nt,{executionId:e,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s}))))}),ce=Bt("loginId"),de=qt(Bt("token")),ue=qt(ce),he=qt(ce,Kt("phone")),pe=qt(ce,Vt("email")),fe=Object.keys(Zt).filter((t=>t!==Xt.voice)),ge=t=>({verify:de((e=>xt(t.post(f,{token:e})))),signIn:fe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,i,o,r)=>xt(t.post(Ct(g,n),{loginId:e,URI:i,loginOptions:o},{token:r}))))})),{}),signUp:fe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,i,o,r)=>xt(t.post(Ct(v,n),{loginId:e,URI:i,user:o,loginOptions:r}))))})),{}),signUpOrIn:fe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,i,o)=>xt(t.post(Ct(b,n),{loginId:e,URI:i,loginOptions:o}))))})),{}),update:{email:pe(((e,n,i,o,r)=>xt(t.post(m.email,Object.assign({loginId:e,email:n,URI:i},r),{token:o})))),phone:Object.keys(Xt).filter((t=>t!==Xt.voice)).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:he(((e,i,o,r,s)=>xt(t.post(Ct(m.phone,n),Object.assign({loginId:e,phone:i,URI:o},s),{token:r}))))})),{})}});var ve;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple",t.discord="discord",t.linkedin="linkedin",t.slack="slack"}(ve||(ve={}));const me=qt(Bt("code")),be=t=>({start:Object.assign(((e,n,i,o)=>xt(t.post(x,i||{},{queryParams:Object.assign({provider:e},n&&{redirectURL:n}),token:o}))),Object.keys(ve).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,i,o)=>xt(t.post(x,i||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:o}))})),{})),exchange:me((e=>xt(t.post(j,{code:e})))),startNative:(e,n,i)=>xt(t.post(O,{provider:e,loginOptions:n,implicit:i})),finishNative:(e,n,i,o,r)=>xt(t.post(A,{provider:e,stateId:n,user:i,code:o,idToken:r}))}),we=Bt("loginId"),ye=qt(we,Bt("code")),ke=qt(we),Ie=qt(we,Kt("phone")),Se=qt(we,Vt("email")),Ce=t=>({verify:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ye(((e,i)=>xt(t.post(Ct(c,n),{code:i,loginId:e}))))})),{}),signIn:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,i,o)=>xt(t.post(Ct(d,n),{loginId:e,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,i,o)=>xt(t.post(Ct(u,n),{loginId:e,user:i,loginOptions:o}))))})),{}),signUpOrIn:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,i)=>xt(t.post(Ct(p,n),{loginId:e,loginOptions:i}))))})),{}),update:{email:Se(((e,n,i,o)=>xt(t.post(h.email,Object.assign({loginId:e,email:n},o),{token:i})))),phone:Object.keys(Xt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Ie(((e,i,o,r)=>xt(t.post(Ct(h.phone,n),Object.assign({loginId:e,phone:i},r),{token:o}))))})),{})}}),xe=qt(Bt("tenant")),je=qt(Bt("code")),Oe=t=>({start:xe(((e,n,i,o)=>xt(t.post(U,i||{},{queryParams:{tenant:e,redirectURL:n},token:o})))),exchange:je((e=>xt(t.post(E,{code:e}))))}),Ae=Bt("loginId"),Ue=qt(Ae,Bt("code")),Ee=qt(Ae),Re=qt(Ae),Le=t=>({signUp:Ee(((e,n)=>xt(t.post(L,{loginId:e,user:n})))),verify:Ue(((e,n,i,o)=>xt(t.post(R,{loginId:e,code:n,loginOptions:i},{token:o})))),update:Re(((e,n)=>xt(t.post(T,{loginId:e},{token:n}))))}),Te=Bt("loginId"),_e=Bt("newPassword"),$e=qt(Te,Bt("password")),Pe=qt(Te),Me=qt(Te,_e),De=qt(Te,Bt("oldPassword"),_e),Ne=t=>({signUp:$e(((e,n,i,o)=>xt(t.post(F,{loginId:e,password:n,user:i,loginOptions:o})))),signIn:$e(((e,n,i)=>xt(t.post(B,{loginId:e,password:n,loginOptions:i})))),sendReset:Pe(((e,n,i)=>xt(t.post(V,{loginId:e,redirectUrl:n,templateOptions:i})))),update:Me(((e,n,i)=>xt(t.post(K,{loginId:e,newPassword:n},{token:i})))),replace:De(((e,n,i)=>xt(t.post(H,{loginId:e,oldPassword:n,newPassword:i})))),policy:()=>xt(t.get(G))}),We=Ft("loginId"),qe=Bt("loginId"),Fe=Bt("origin"),Be=qt(qe,Fe,Bt("name")),Ve=qt(qe,Fe),Ke=qt(We,Fe),He=qt(qe,Fe,Bt("token")),Ge=qt(Bt("transactionId"),Bt("response")),Je=t=>({signUp:{start:Be(((e,n,i,o)=>xt(t.post(D.start,{user:{loginId:e,name:i},origin:n,passkeyOptions:o})))),finish:Ge(((e,n)=>xt(t.post(D.finish,{transactionId:e,response:n}))))},signIn:{start:Ke(((e,n,i,o,r)=>xt(t.post(N.start,{loginId:e,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:Ge(((e,n)=>xt(t.post(N.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Ve(((e,n,i)=>xt(t.post(W.start,{loginId:e,origin:n,passkeyOptions:i}))))},update:{start:He(((e,n,i,o)=>xt(t.post(q.start,{loginId:e,origin:n,passkeyOptions:o},{token:i})))),finish:Ge(((e,n)=>xt(t.post(q.finish,{transactionId:e,response:n}))))}}),ze=Ft("loginId"),Xe=qt(ze),Qe=qt(Bt("pendingRef")),Ze=t=>({signUpOrIn:Xe(((e,n)=>xt(t.post(P,{loginId:e,loginOptions:n})))),signUp:Xe(((e,n,i)=>xt(t.post($,{loginId:e,user:n,loginOptions:i})))),signIn:Xe(((e,n,i)=>xt(t.post(_,{loginId:e,loginOptions:n},{token:i})))),waitForSession:Qe(((e,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=zt(n);let s;const a=setInterval((async()=>{const n=await t.post(M,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(xt(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Ye=qt(Bt("token")),tn=qt([Nt('"token" must be string or undefined')]);var en,nn=qt([(en=Bt("projectId"),jt(((t,e)=>n=>At(...e).validate(((t,e)=>{const n=(Array.isArray(e)?e.join("."):String(e)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((t,e,n)=>"."+n)).split("."),i=n.length;let o=0,r=t===Object(t)?t:void 0;for(;null!=r&&o<i;)r=r[n[o++]];return o&&o===i&&void 0!==r?r:void 0})(n,t)))("projectId",en))())])((t=>{var e;return(({projectId:t,logger:e,baseUrl:n,hooks:i,cookiePolicy:o,baseHeaders:r={},fetch:s})=>{return a=vt({baseUrl:n||ot,projectId:t,logger:e,hooks:i,cookiePolicy:o,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:Gt(a),otp:Ce(a),magicLink:ge(a),enchantedLink:re(a),oauth:be(a),saml:Oe(a),totp:Le(a),notp:Ze(a),webauthn:Je(a),password:Ne(a),flow:le(a),refresh:tn(((t,e)=>xt(a.post(J,{},{token:t,queryParams:e})))),selectTenant:qt([$t("tenantId")],[Nt('"token" must be string or undefined')])(((t,e)=>xt(a.post(z,{tenant:t},{token:e})))),logout:tn((t=>xt(a.post(X,{},{token:t})))),logoutAll:tn((t=>xt(a.post(Q,{},{token:t})))),me:tn((t=>xt(a.get(Z,{token:t})))),myTenants:qt([Wt('"tenants" must a string array or a boolean')],[Nt('"token" must be string or undefined')])(((t,e)=>{const n={};return"boolean"==typeof t?n.dct=t:n.ids=t,xt(a.post(Y,n,{token:e}))})),history:tn((t=>xt(a.get(tt,{token:t})))),isJwtExpired:Ye(yt),getTenants:Ye(kt),getJwtPermissions:Ye(It),getJwtRoles:Ye(St),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>{var n;const i=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((t,e)=>e(t)),e)},afterRequest:async(e,n)=>{var i;const o=[].concat((null===(i=t.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((t=>t(e,null==n?void 0:n.clone()))))).forEach((e=>{var n;return"rejected"===e.status&&(null===(n=t.logger)||void 0===n?void 0:n.error(e.reason))}))},transformResponse:null===(e=t.hooks)||void 0===e?void 0:e.transformResponse}}))})),on=Object.assign(nn,{DeliveryMethods:Zt});
|
|
2
2
|
/*! js-cookie v3.0.5 | MIT */
|
|
3
|
-
function rn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)t[i]=n[i]}return t}var sn=function t(e,n){function i(t,i,o){if("undefined"!=typeof document){"number"==typeof(o=rn({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=t+"="+e.write(i,t)+r}}return Object.create({set:i,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(i[a]=e.read(s,a),t===a)break}catch(t){}}return t?i[t]:i}},remove:function(t,e){i(t,"",rn({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,rn({},this.attributes,e))},withConverter:function(e){return t(rn({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(e)}})}({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var an={default:"endpoint"},ln="Blocked by CSP",cn="The endpoint parameter is not a valid URL",dn="Failed to load the JS script of the agent",un="9319";function hn(t,e){var n,i,o,r,s,a=[],l=(n=function(t){var e=function(t,e,n){if(n||2===arguments.length)for(var i,o=0,r=e.length;o<r;o++)!i&&o in e||(i||(i=Array.prototype.slice.call(e,0,o)),i[o]=e[o]);return t.concat(i||Array.prototype.slice.call(e))}([],t,!0);return{current:function(){return e[0]},postpone:function(){var t=e.shift();void 0!==t&&e.push(t)},exclude:function(){e.shift()}}}(t),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(t,e){var r,s=e instanceof Error?e.message:"";if(s===ln||s===cn)n.exclude(),r=0;else if(s===un)n.exclude();else if(s===dn){var a=Date.now()-t.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:t.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(t){var n=new Date,i=function(e){return a.push({url:t,startedAt:n,finishedAt:new Date,error:e})},o=e(t);return o.then((function(){return i()}),i),o.catch((function(t){if(null!=s||(s=t),a.length>=5)throw s;var e=d(n,t);if(!e)throw s;var i,o=e[0],r=e[1];return(i=r,new Promise((function(t){return setTimeout(t,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(t){return[t,a]}))}var pn="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",fn=pn;function gn(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=e(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:pn,c=function(){var t=[],e=function(){t.push({time:new Date,state:document.visibilityState})},n=function(t,e,n,i){return t.addEventListener(e,n,i),function(){return t.removeEventListener(e,n,i)}}(document,"visibilitychange",e);return e(),[t,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var t=function(t,e){return(Array.isArray(t)?t:[t]).map((function(t){return function(t,e){var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.11.6"):t}))}(String(t),e)}))}(l,s);return hn(t,vn)})).catch((function(t){throw u(),function(t){return t instanceof Error&&t.message===un?new Error(dn):t}(t)})).then((function(e){var n=e[0],i=e[1];return u(),n.load(t(t({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function vn(t){return function(t,e,n){var i,o=document,r="securitypolicyviolation",s=function(e){var n=new URL(t,location.href),o=e.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=e,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(e).then((function(t){return a(),t}),(function(t){return new Promise((function(t){var e=new MessageChannel;e.port1.onmessage=function(){return t()},e.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){if(function(t){if(URL.prototype)try{return new URL(t,location.href),!1}catch(t){if(t instanceof Error&&"TypeError"===t.name)return!0;throw t}}(t))throw new Error(cn);var i=document.createElement("script"),o=function(){var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),e()},i.onerror=function(){o(),n(new Error(dn))},i.async=!0,i.src=t,r.appendChild(i)}))}(t)}),(function(){throw new Error(ln)})).then(mn)}function mn(){var t=window,e="__fpjs_p_l_b",n=t[e];if(function(t,e){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==i?void 0:i.configurable)?delete t[e]:i&&!i.writable||(t[e]=void 0)}(t,e),"function"!=typeof(null==n?void 0:n.load))throw new Error(un);return n}const bn=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=t.hooks)||void 0===o?void 0:o[i])||[]).concat((null==e?void 0:e[i])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},wn=async t=>{if(!(null==t?void 0:t.ok))return{};const e=await(null==t?void 0:t.clone().json());return(null==e?void 0:e.authInfo)||e||{}},yn=async t=>{const e=await wn(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},kn="undefined"!=typeof localStorage,In=(t,e)=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),Sn=t=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Cn=t=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),xn=(...t)=>{console.debug(...t)},jn="undefined"!=typeof window,On=Math.pow(2,31)-1,An="DS",Un="DSR";function En(t=""){return Sn(`${t}${Un}`)||""}function Rn(t=""){return sn.get(An)||Sn(`${t}${An}`)||""}function Ln(t=""){Cn(`${t}${Un}`),Cn(`${t}${An}`),sn.remove(An)}const Tn=jn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",_n="vsid",$n="vrid",Pn="fp",Mn=(t=!1)=>{const e=localStorage.getItem(Pn);if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},Dn=async(t,e=Tn)=>{try{if(Mn())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(e);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(e);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=gn({apiKey:t,endpoint:[i.toString(),an],scriptUrlPattern:[r,fn]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((t,e)=>({[_n]:t,[$n]:e}))(n,l);(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem(Pn,JSON.stringify(e))})(c)}catch(t){console.warn("Could not load fingerprint",t)}},Nn=t=>{const e=Mn(!0);return e&&t.body&&(t.body.fpData=e),t},Wn="dls_last_user_login_id",qn="dls_last_user_display_name",Fn=()=>Sn(Wn),Bn=()=>Sn(qn),Vn=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,i={}]=e,o=Fn(),r=Bn();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await t(...e)};function Kn(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}async function Hn(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Zn(n.publicKey.challenge),n.publicKey.user.id=Zn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Zn(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:Yn(n.rawId),type:n.type,response:{attestationObject:Yn(n.response.attestationObject),clientDataJSON:Yn(n.response.clientDataJSON)}});var n}async function Gn(t){const e=Xn(t);return Qn(await navigator.credentials.get(e))}async function Jn(t,e){const n=Xn(t);return n.signal=e.signal,n.mediation="conditional",Qn(await navigator.credentials.get(n))}async function zn(t=!1){if(!jn)return Promise.resolve(!1);const e=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function Xn(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Zn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Zn(t.id)})),n}function Qn(t){return JSON.stringify({id:t.id,rawId:Yn(t.rawId),type:t.type,response:{authenticatorData:Yn(t.response.authenticatorData),clientDataJSON:Yn(t.response.clientDataJSON),signature:Yn(t.response.signature),userHandle:t.response.userHandle?Yn(t.response.userHandle):void 0}})}function Zn(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Yn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ti,ei=(ti=t=>({async signUp(e,n,i){const o=await t.webauthn.signUp.start(e,window.location.origin,n,i);if(!o.ok)return o;const r=await Hn(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(e,n){const i=await t.webauthn.signIn.start(e,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await Gn(i.data.options);return await t.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(e,n){var i;const o=await t.webauthn.signUpOrIn.start(e,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const e=await Hn(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await Gn(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,e)}},async update(e,n,i){const o=await t.webauthn.update.start(e,window.location.origin,n,i);if(!o.ok)return o;const r=await Hn(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:Hn,get:Gn,isSupported:zn,conditional:Jn}}),(...t)=>{const e=ti(...t);return Object.assign(e.signUp,t[0].webauthn.signUp),Object.assign(e.signIn,t[0].webauthn.signIn),Object.assign(e.signUpOrIn,t[0].webauthn.signUpOrIn),Object.assign(e.update,t[0].webauthn.update),e});const ni="/fedcm/config",ii=(t,e)=>({async oneTap(e,n,i,o,r){const s=null!=e?e:"google",a=await t.oauth.startNative(s,i,!0);if(!a.ok)return a;const{clientId:l,stateId:c,nonce:d}=a.data,u=await async function(){return new Promise(((t,e)=>{if(window.google)return void t(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?t(window.google.accounts.id):e("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){e("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((e=>{var i,a;u.initialize(Object.assign(Object.assign({},n),{itp_support:null===(i=null==n?void 0:n.itp_support)||void 0===i||i,use_fedcm_for_prompt:null===(a=null==n?void 0:n.use_fedcm_for_prompt)||void 0===a||a,client_id:l,callback:n=>{e(t.oauth.finishNative(s,c,"","",n.credential))},nonce:d})),u.prompt((t=>{var e,n;if(r&&(null==t?void 0:t.isDismissedMoment())){const n=null===(e=t.getDismissedReason)||void 0===e?void 0:e.call(t);null==r||r(n)}else if(o&&(null==t?void 0:t.isSkippedMoment())){const e=null===(n=t.getSkippedReason)||void 0===n?void 0:n.call(t);null==o||o(e)}}))}))},async launch(n){var i;const o={identity:{context:n||"signin",providers:[{configURL:t.httpClient.buildUrl(e+ni),clientId:e}]}},r=await(null===(i=navigator.credentials)||void 0===i?void 0:i.get(o));return t.refresh(r.token)},isSupported:()=>jn&&"IdentityCredential"in window,async isLoggedIn(n){var i;const o=t.httpClient.buildUrl(e+ni);try{const t={identity:{context:n||"signin",providers:[{configURL:o,clientId:e}]}},r=await(null===(i=navigator.credentials)||void 0===i?void 0:i.get(t));return!!r&&!!r.token}catch(t){return!1}}});var oi=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await zn(),i=Object.assign(Object.assign({location:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return e[1]=i,t.flow.start(...e)}});const ri=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:i,fpLoad:o}=n,r=e(n,["fpKey","fpLoad"]);return jn?(i&&o&&Dn(i).catch((()=>null)),t(bn(r,{beforeRequest:Nn}))):t(r)}),(t=>n=>{var{autoRefresh:i}=n,o=e(n,["autoRefresh"]);if(!i)return t(o);const{clearAllTimers:r,setTimer:s}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})();let l,c;jn&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>l&&(xn("Expiration time passed, refreshing session"),d.refresh(En()||c))}));const d=t(bn(o,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:i}=await wn(e);if(401===(null==e?void 0:e.status))xn("Received 401, canceling all timers"),r();else if(i){if(l=(t=>{try{const e=a(t);if(e.exp)return new Date(1e3*e.exp)}catch(t){return null}})(i),!l)return void xn("Could not extract expiration time from session token");c=n;let t=((o=l)?o.getTime()-(new Date).getTime():0)-2e4;t>On&&(xn(`Timeout is too large (${t}ms), setting it to ${On}ms`),t=On),r();const e=new Date(Date.now()+t).toLocaleTimeString("en-US",{hour12:!1});xn(`Setting refresh timer for ${e}. (${t}ms)`),s((()=>{xn("Refreshing session due to timer"),d.refresh(En()||n)}),t)}var o}}));return Jt(d,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return xn("Clearing all timers"),r(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.23.10"},e.baseHeaders)}))),(t=>e=>{const n=Kn(),i=Kn(),o=t(bn(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),i.pub(null);else{const t=await yn(e);t&&i.pub(t);const{sessionJwt:o}=await wn(e);o&&n.pub(o)}}})),r=Jt(o,["logout","logoutAll"],(t=>async(...e)=>{const o=await t(...e);return n.pub(null),i.pub(null),o}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:i.sub})}),(t=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=e(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(t(r),{getLastUserLoginId:Fn,getLastUserDisplayName:Bn});const s=t(bn(r,{afterRequest:async(t,e)=>{var n;const i=await yn(e),o=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],r=null==i?void 0:i.name;o&&((t=>{In(Wn,t)})(o),(t=>{In(qn,t)})(r))}}));let a=Jt(s,["flow.start"],Vn);return a=Jt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const i=await e(...n);return t||(Cn(Wn),Cn(qn)),i})(o)),Object.assign(a,{getLastUserLoginId:Fn,getLastUserDisplayName:Bn})}),(t=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,storagePrefix:r}=n,s=e(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!jn)return t(s);const a=t(bn(s,{beforeRequest:(l=r,t=>Object.assign(t,{token:t.token||En(l)})),afterRequest:async(t,n)=>{const i=/^\/v\d+\/mgmt\//.test(t.path);401===(null==n?void 0:n.status)?i||Ln(r):((t={},n,i)=>{var{refreshJwt:o,sessionJwt:r}=t,s=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===i&&(i=""),o&&In(`${i}${Un}`,o),r&&(n?function(t,e,{cookiePath:n,cookieDomain:i,cookieExpiration:o}){if(e){const r=new Date(1e3*o),s=function(t){const e=window.location.hostname.split("."),n=t.split(".");return e.slice(-n.length).join(".")===t}(i);sn.set(t,e,{path:n,domain:s?i:void 0,expires:r,sameSite:"Strict",secure:!0})}}(An,r,s):In(`${i}${An}`,r))})(await wn(n),o,r)}}));var l;const c=Jt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const i=await e(...n);return Ln(t),i})(r));return Object.assign(c,{getRefreshToken:()=>En(r),getSessionToken:()=>Rn(r)})}))(((...t)=>{const e=on(...t);return Object.assign(Object.assign({},e),{refresh:t=>{const n=Rn();return e.refresh(t,{dcs:n?"t":"f"})},flow:oi(e),webauthn:ei(e),fedcm:ii(e,t[0].projectId)})})),si="undefined"!=typeof localStorage,ai="J151000",li=si&&localStorage.getItem("base.content.url")||"",ci="base.ui.components.url";si&&localStorage.getItem(ci),si&&localStorage.getItem(ci);const di="descope-login-flow",ui="code",hi="data-exclude-field",pi="dls_last_auth",fi="state_id",gi="saml_idp_state_id",vi="saml_idp_username",mi="descope_idp_initiated",bi="sso_app_id",wi="third_party_app_id",yi="third_party_app_state_id",ki="oidc_login_hint",Ii="oidc_prompt",Si="oidc_error_redirect_uri",Ci="application_scopes",xi="data-type",ji="redirect",Oi="poll",Ai="webauthnCreate",Ui="webauthnGet",Ei="nativeBridge",Ri="loadForm",Li="submit",Ti="polling",_i=["descope-multi-select-combo-box","descope-text-area"],$i=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Pi;!function(t){t.backward="backward",t.forward="forward"}(Pi||(Pi={}));const Mi=["descope-enriched-text"];function Di(t){return new URLSearchParams(window.location.search).get(t)}function Ni(t){if(window.history.replaceState&&Di(t)){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.delete(t),e.search=n.toString(),window.history.replaceState({},"",e.toString())}}function Wi(t,e){if(!e)return;const n=+t,i=+e;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?Pi.forward:n<i?Pi.backward:void 0}const qi=t=>{let[e="",n=""]=(Di(di)||"").split("_");const i=(t=>{var e;return(null===(e=/(.*)\|#\|.*/.exec(t))||void 0===e?void 0:e[1])||""})(e);return(!t||i&&i!==t)&&(e="",n=""),{executionId:e,stepId:n,executionFlowId:i}};function Fi(){Ni(di)}const Bi=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),Vi=(t,e)=>{const{executionId:n,stepId:i,executionFlowId:o}=qi(t);if(o&&t!==o)return e.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&Fi();const r=Di("t")||void 0;r&&Ni("t");const s=Di(ui)||void 0;s&&Ni(ui);const a=Di("err")||void 0;a&&Ni("err");const{redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u}={redirectAuthCodeChallenge:Di("ra-challenge"),redirectAuthCallbackUrl:Di("ra-callback"),redirectAuthBackupCallbackUri:Di("ra-backup-callback"),redirectAuthInitiator:Di("ra-initiator")},h=Di(fi);h&&Ni(fi);const p=Di(gi);p&&Ni(gi);const f=Di(vi);p&&Ni(vi);const g=Di(mi);g&&Ni(mi);const v=Di(bi);v&&Ni(bi);const m=Di(wi);m&&Ni(wi);const b=Di(yi);b&&Ni(yi);const w=Di(Ci);w&&Ni(Ci);const y=Di(ki);y&&Ni(ki);const k=Di(Ii);k&&Ni(Ii);const I=Di(Si);I&&Ni(Si);return{executionId:n,stepId:i,token:r,code:s,exchangeError:a,redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u,ssoQueryParams:{oidcIdpStateId:h,samlIdpStateId:p,samlIdpUsername:f,descopeIdpInitiated:"true"===g,ssoAppId:v,oidcLoginHint:y,oidcPrompt:k,oidcErrorRedirectUri:I,thirdPartyAppId:m,thirdPartyAppStateId:b,applicationScopes:w}}},Ki=t=>{let e,n;return Object.assign(((...i)=>{return e&&(r=i,(o=e).length===r.length&&o.every(((t,e)=>t===r[e])))||(e=i,n=t(...i)),n;var o,r}),{reset:()=>{e=void 0,n=void 0}})};function Hi(t,e,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${t} ms`))}),t);e.then((t=>{r||(clearTimeout(s),i(t))})).catch((t=>{r||(clearTimeout(s),o(t))}))}))}const Gi=(t,{oidcIdpStateId:e,samlIdpStateId:n,samlIdpUsername:i,ssoAppId:o,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,thirdPartyAppId:l,thirdPartyAppStateId:c,applicationScopes:d})=>!(!t||e||n||i||o||r||s||a||l||c||d),Ji=t=>null==t?void 0:t.submit(),zi=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null},Xi=(t,e=100)=>{let n;return function(...i){n||t.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),e)}};function Qi(t){if(t)return{locale:t.toLowerCase(),fallback:t.toLowerCase()};const e=navigator.language;return e?e.includes("-")?{locale:e.toLowerCase(),fallback:e.split("-")[0].toLowerCase()}:{locale:e.toLowerCase(),fallback:e.toLowerCase()}:{locale:"",fallback:""}}const Zi=t=>{const e=(n=t.screenState,i=(t,e)=>$i.includes(e)||e.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([t,e])=>!i(e,t)))));var n,i;const{screenState:{errorText:o,errorType:r}}=t;return(o||r)&&(e.error={text:o,type:r}),e};var Yi,to,eo,no;function io(t,e){const n=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=t[o],s=e[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!io(r,s))return!1}else if(r!==s)return!1}return!0}class oo{constructor(t={},{forceUpdate:e=!1}={}){Yi.set(this,void 0),to.set(this,{}),eo.set(this,0),no.set(this,!0),this.update=t=>{const e="function"==typeof t?t(i(this,Yi,"f")):t,n=Object.assign(Object.assign({},i(this,Yi,"f")),e);if(i(this,no,"f")||!io(i(this,Yi,"f"),n)){const t=i(this,Yi,"f");o(this,Yi,n,"f"),Object.freeze(i(this,Yi,"f")),setTimeout((()=>{Object.values(i(this,to,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},o(this,Yi,t,"f"),o(this,no,e,"f")}get current(){return Object.assign({},i(this,Yi,"f"))}set forceUpdate(t){o(this,no,t,"f")}subscribe(t){return o(this,eo,i(this,eo,"f")+1,"f"),i(this,to,"f")[i(this,eo,"f")]=t,i(this,eo,"f").toString()}unsubscribe(t){const e=!!i(this,to,"f")[t];return e&&delete i(this,to,"f")[t],e}unsubscribeAll(){return o(this,to,{},"f"),!0}}Yi=new WeakMap,to=new WeakMap,eo=new WeakMap,no=new WeakMap;const ro=["*","#","/","(",")","[","]","_","<",">","`"],so=t=>{const e=ro.map((e=>`${t}${e}`)).join("|");return new RegExp(`(${e})`,"g")},ao=["disabled"],lo=(t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${hi}])`)).forEach((t=>{t.value=n}))}))},co=(t,e)=>e.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),t),uo=(t,e,n)=>t.replace(/{{(.+?)}}/g,((t,i)=>n?(t=>"string"!=typeof t?t:t.replace(so("\\"),"\\$1"))(co(e,i)):co(e,i))),ho=(t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{const n=(i=t.localName,Mi.includes(i));var i;t.textContent=uo(t.textContent,e,n);const o=t.getAttribute("href");o&&t.setAttribute("href",uo(o,e))}))},po=(t,e,n)=>{t.querySelectorAll(`[${xi}="${e}"]`).forEach((t=>{t.setAttribute("href",n)}))},fo=(t,e,n)=>{var i,o;const r=null===(i=customElements.get(e))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==t?void 0:t.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},go=(t,e,n,i,o,r)=>{var s,a;let l=null==e?void 0:e.errorText;try{l=(null==o?void 0:o({text:null==e?void 0:e.errorText,type:null==e?void 0:e.errorType}))||(null==e?void 0:e.errorText)}catch(t){r.error("Error transforming error message",t.message)}((t,e,n="")=>{t.querySelectorAll(`[${xi}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",l),po(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),po(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),ho(t,e),((t,e,n)=>{e&&Object.keys(e).forEach((i=>{t.querySelectorAll(`[name=${i}]`).forEach((t=>{const o=e[i];Object.keys(o).forEach((e=>{let i=o[e];if("string"!=typeof i)try{i=JSON.stringify(i)}catch(t){n.error(`Could not stringify value "${i}" for "${e}"`,t.message),i=""}t.setAttribute(e,i)}))}))}))})(t,n,r),((t,e)=>{t.querySelectorAll("[data-has-dynamic-attr-values]").forEach((t=>{Array.from(t.attributes).forEach((t=>{t.value=uo(t.value,e)}))}))})(t,e),((t,e)=>{Object.entries(e).forEach((([e,n])=>{t.querySelectorAll(`[name="${e}"]`).forEach((t=>{Object.entries(n).forEach((([e,n])=>{ao.includes(e)&&t.setAttribute(e,n)}))}))}))})(t,i)},vo=Ki((()=>n(void 0,void 0,void 0,(function*(){var t,e;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),i=(()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,n=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return n?n.version:0})()>=108;return yield Hi(100,n,i)}catch(t){return console.error("Conditional login check failed",t),!1}})))),mo=(t,e,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(e,("all"===i.left?t.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-t.offsetWidth),window.innerWidth-("all"===i.right?t.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?t.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-t.offsetHeight),window.innerHeight-("all"===i.bottom?t.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]},bo="dls_ab_testing_id",wo={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code},externalToken:{"is-true":t=>!!t.token,"is-false":t=>!t.token},abTestingKey:{"greater-than":(t,e)=>(t.abTestingKey||0)>e,"less-than":(t,e)=>(t.abTestingKey||0)<e}};function yo(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(pi)))}catch(t){}return e}function ko(...t){return e=>t.reduce(((t,e)=>e(t)),e)}const Io=t=>{const e=Symbol((t=>{const e=t.toString();let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n&=n;return n.toString(16)})(t));return n=>{if(n[e])return n;const i=t(n);return i[e]=!0,i}},So=["error","warn","info","debug"],Co=Io((t=>{var e,n,r,s;return s=class extends t{constructor(){super(...arguments),e.add(this),n.set(this,i(this,e,"m",r).call(this,console))}set logger(t){o(this,n,i(this,e,"m",r).call(this,t||console),"f")}get logger(){return i(this,n,"f")}onLogEvent(t,e){}},n=new WeakMap,e=new WeakSet,r=function(t){return So.reduce(((e,n)=>(e[n]=(...e)=>{var i;this.onLogEvent(n,e),null===(i=t[n])||void 0===i||i.call(t,...e)},e)),{})},s})),xo="undefined"!=typeof localStorage,jo=xo&&localStorage.getItem("base.content.url")||"",Oo=(t,e)=>!e&&`${t} cannot be empty, please make sure to set this attribute`,Ao=Io((t=>{var e,n;return n=class extends t{constructor(){super(...arguments),e.set(this,!0)}connectedCallback(){var t,n;null===(t=super.connectedCallback)||void 0===t||t.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&i(this,e,"f")&&(o(this,e,!1,"f"),this.init())}async init(){}},e=new WeakMap,n})),Uo=Io((t=>{var e,n;const o=ko(Co,Ao)(t);return n=class extends o{constructor(){super(...arguments),e.set(this,{})}async init(){var t,n,o;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),n=this,o=t=>{var n;null===(n=i(this,e,"f")[t])||void 0===n||n.forEach((e=>{e(t,this.getAttribute(t))}))},Array.from(n.attributes).forEach((t=>o(t.name))),new MutationObserver((t=>{t.forEach((t=>{"attributes"===t.type&&o(t.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(t,n){i(this,e,"f")[t]||(i(this,e,"f")[t]=[]);const o=i(this,e,"f")[t].push(n);return()=>i(this,e,"f")[t].splice(o,1)}observeAttributes(t,e){const n=t.reduce(((t,n)=>(t.push(this.observeAttribute(n,e)),t)),[]);return()=>n.forEach((t=>t()))}},e=new WeakMap,n})),Eo=t=>e=>{var n,o,r;const s=ko(Co,Ao,Uo)(e),a=Object.keys(t);return r=class extends s{constructor(...t){super(...t),n.add(this),this.observeAttributes(a,i(this,n,"m",o).bind(this))}async init(){var t;a.forEach((t=>i(this,n,"m",o).call(this,t,this.getAttribute(t)))),await(null===(t=super.init)||void 0===t?void 0:t.call(this))}},n=new WeakSet,o=function(e,n){const i=t[e],o="function"==typeof i?i(e,n):i;o&&this.logger.error(o)},r};Eo.missingAttrValidator=Oo;const Ro=Io((t=>{const e=ko(Eo({"project-id":Oo}))(t);return class extends e{get projectId(){return this.getAttribute("project-id")}}})),Lo=Io((t=>class extends t{get baseUrl(){return this.getAttribute("base-url")||""}})),To="Trying the next fallback URL...";function _o({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:i="https://static.descope.com/pages"}){const o=new URL(i);return o.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(o.pathname,t,n,e),o.baseUrl=i,o}const $o=Io((t=>{var e,n,r,s,a;const l=ko(Co,Ro,Lo)(t);return a=class extends l{constructor(){super(...arguments),e.add(this),n.set(this,void 0),r.set(this,void 0)}async fetchStaticResource(t,n){const a=i(this,e,"m",s).call(this,t),l=Array.isArray(a)?t=>{if(t!==a.length-1){const{baseUrl:e}=a[t];o(this,r,e,"f")}}:null;try{const t=await(async(t,e,{logger:n,onSuccess:i})=>{const o=Array.isArray(t)?t:[t];for(let t=0;t<o.length;t++){const r=o[t],s=t===o.length-1;try{const o=await fetch(r.toString(),e);if(o.ok)return null==i||i(t),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${To}`)}catch(t){const e=`Error fetching URL ${r} [${t.message}]`;if(s)throw new Error(e);null==n||n.debug(`${e}. ${To}`)}}})(a,{cache:"default"},{logger:this.logger,onSuccess:l});return{body:await t[n](),headers:Object.fromEntries(t.headers.entries())}}catch(t){this.logger.error(t.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")}},n=new WeakMap,r=new WeakMap,e=new WeakSet,s=function(t){const e=jo||this.baseStaticUrl;if(e)return _o({projectId:this.projectId,filename:t,baseUrl:e});const s=i(this,n,"f")!==this.baseUrl,a=s&&!!this.baseUrl;s&&(o(this,n,this.baseUrl,"f"),o(this,r,void 0,"f"));const l=_o({projectId:this.projectId,filename:t,baseUrl:i(this,r,"f")});if(!a)return l;return[_o({projectId:this.projectId,filename:t,baseUrl:this.baseUrl+"/pages"}),l]},a})),Po=Io((t=>{var e,n;const o=ko(Eo({"project-id":Oo}))(t);return n=class extends o{constructor(){super(...arguments),e.set(this,new Map)}onReset(t,n){if(i(this,e,"f").has(t))throw new Error(`Callback for sectionId ${t} already exists`);return i(this,e,"f").set(t,n),()=>{i(this,e,"f").delete(t)}}async reset(...t){0===t.length?await Promise.all(Array.from(i(this,e,"f").values()).map((t=>t()))):await Promise.all(t.map((t=>{var n;if(!i(this,e,"f").has(t))throw new Error(`Callback for sectionId ${t} does not exist`);return null===(n=i(this,e,"f").get(t))||void 0===n?void 0:n()})))}},e=new WeakMap,n})),Mo=Io((t=>{var e,n,r,s,a;const l=ko($o,Po,Ao)(t);return a=class extends l{constructor(){super(...arguments),e.add(this),r.set(this,void 0),s.set(this,(async()=>{try{const{body:t,headers:e}=await this.fetchStaticResource("config.json","json");return{projectConfig:t,executionContext:{geo:e["x-geo"]}}}catch(t){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,e,"m",n).bind(this))}get config(){return i(this,r,"f")||o(this,r,i(this,s,"f").call(this),"f"),i(this,r,"f")}},r=new WeakMap,s=new WeakMap,e=new WeakSet,n=function(){o(this,r,void 0,"f")},a})),Do="load-descope-ui",No="base.ui.components.url",Wo=xo&&localStorage.getItem(No)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",qo=xo&&localStorage.getItem(No)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Fo=xo&&localStorage.getItem(No)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Bo=t=>{const e=document.createElement("script");return e.id=t,e},Vo=(t,e)=>t.replace("<version>",e),Ko=Io((t=>{var e,n,r,s,a,l,c,d,u,h,p,f;const g=ko(Co,Mo)(t);return f=class extends g{constructor(){super(...arguments),e.add(this),n.set(this,Symbol("errorCbs")),r.set(this,Symbol("loadCbs")),u.set(this,void 0)}get descopeUi(){return i(this,u,"f")||o(this,u,i(this,e,"m",p).call(this),"f"),i(this,u,"f")}async loadDescopeUiComponents(t){const n=Array.isArray(t)?t:(t=>[...Array.from(t.content.querySelectorAll("*")).reduce(((t,e)=>e.localName.startsWith("descope-")?t.add(e.localName):t),new Set)])(t);return Promise.all(n.map((t=>i(this,e,"m",h).call(this,t))))}get baseCdnUrl(){return this.getAttribute("base-cdn-url")}},n=new WeakMap,r=new WeakMap,u=new WeakMap,e=new WeakSet,s=async function(){var t;const e=await this.config,n=null===(t=null==e?void 0:e.projectConfig)||void 0===t?void 0:t.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},a=function(t){const e=i(this,n,"f"),o=i(this,r,"f");t[e]=[],t[o]=[],Object.defineProperty(t,"onerror",{set(n){t[e].push(n)}}),Object.defineProperty(t,"onload",{set(e){t[o].push(e)}})},l=async function(t,n,o,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const a=Bo(o);document.body.append(a),a.addEventListener("error",(()=>{t.forEach((t=>t(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${a.src}"`)))})),a.addEventListener("load",(()=>{n.forEach((t=>t()))})),a.src=Vo(r,await i(this,e,"m",s).call(this))},c=function(t){t.addEventListener("error",(()=>{t[i(this,n,"f")].forEach((e=>e(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${t.src}"`))),i(this,e,"m",l).call(this,[i(this,e,"m",l).bind(this,t[i(this,n,"f")],t[i(this,r,"f")],"load-descope-ui-fallback-script-2",Fo),...t[i(this,n,"f")]],t[i(this,r,"f")],"load-descope-ui-fallback-script",qo)})),t.addEventListener("load",(()=>{t[i(this,r,"f")].forEach((t=>t()))}))},d=async function(){if(document.querySelector(`script#${Do}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const t=Bo(Do);document.body.append(t),i(this,e,"m",a).call(this,t),i(this,e,"m",c).call(this,t),t.src=Vo(this.baseCdnUrl||Wo,await i(this,e,"m",s).call(this))}return document.getElementById(Do)},h=async function(t){if(!!customElements.get(t))return void this.logger.debug(`Loading component "${t}" is skipped as it is already defined`);const e=await this.descopeUi;if(e[t])try{return await e[t]()}catch(e){if("NotSupportedError"!==e.name)throw e;console.debug(`Encountered an error while attempting to define the "${t}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${t}"`,`Descope UI does not have a component named "${t}", available components are: "${Object.keys(e).join(", ")}"`)},p=function(){return new Promise((t=>{globalThis.DescopeUI&&t(globalThis.DescopeUI),i(this,e,"m",d).call(this).then((e=>{e.onerror=this.logger.error,e.onload=()=>{this.logger.debug("DescopeUI was loaded"),t(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&t(globalThis.DescopeUI)}))}))}))},f})),Ho="content-root",Go="root",Jo=Io((t=>class extends t{constructor(...t){var e,n;super(...t),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${Go}, #${Ho} {\n height: 100%;\n }\n #${Go} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${Go}">\n <div id="${Ho}"></div>\n </div>\n `,this.contentRootElement=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById(Ho),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Go)}})),zo=(t,e)=>!!e&&"light"!==e&&"dark"!==e&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Xo=Io((t=>{var e,n,r,s,a,l,c,d,u,h,p,f,g,v;const m=ko(Eo({theme:zo}),$o,Ao,Ko,Mo,Jo,Uo)(t);return v=class extends m{constructor(){super(...arguments),e.add(this),n.set(this,void 0),r.set(this,void 0),p.set(this,(()=>{i(this,e,"m",f).call(this),i(this,g,"f").call(this,"os"===this.getAttribute("theme"))})),g.set(this,(t=>{var n,o,r;const s=t?"addEventListener":"removeEventListener";null===(r=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===r||r.call(o,"change",(()=>i(this,e,"m",f).call(this)))}))}get theme(){var t,e;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(e=null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)"))||void 0===e?void 0:e.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var t;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),i(this,e,"m",l).call(this),i(this,e,"m",c).call(this),i(this,p,"f").call(this),this.observeAttributes(["theme"],i(this,p,"f")),this.observeAttributes(["style-id"],(()=>{o(this,r,null,"f"),i(this,e,"m",u).call(this),i(this,e,"m",l).call(this),i(this,e,"m",c).call(this)}))}},n=new WeakMap,r=new WeakMap,p=new WeakMap,g=new WeakMap,e=new WeakSet,s=async function(){try{const{body:t}=await this.fetchStaticResource(`${this.styleId}.json`,"json");return t}catch(t){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},a=function(){return i(this,r,"f")||(o(this,r,i(this,e,"m",s).call(this),"f"),i(this,r,"f").then((t=>this.logger.debug("Fetched theme",t)))),i(this,r,"f")},l=async function(){var t,r;const s=await i(this,e,"a",a);s&&(i(this,n,"f")||(o(this,n,document.createElement("style"),"f"),i(this,n,"f").id="global-style",this.shadowRoot.appendChild(i(this,n,"f"))),i(this,n,"f").innerText=((null===(t=null==s?void 0:s.light)||void 0===t?void 0:t.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||""))},c=async function(){var t,n;const o=Object.assign({},await i(this,e,"a",a));if(!o)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(t=null==o?void 0:o.light)||void 0===t?void 0:t.components,dark:null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.components})},d=async function(){var t,e;const{projectConfig:n}=await this.config||{},i=null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t[this.styleId],o=null==n?void 0:n.cssTemplate,r=i||o;return null===(e=null==r?void 0:r[this.theme])||void 0===e?void 0:e.fonts},u=async function(){const t=await i(this,e,"m",d).call(this);t?Object.values(t).forEach((t=>{t.url&&(this.logger.debug(`Loading font from URL "${t.url}"`),(t=>{const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url))})):this.logger.debug("No fonts to load")},h=async function(){this.rootElement.setAttribute("data-theme",this.theme);const t=await this.descopeUi;(null==t?void 0:t.componentsThemeManager)&&(t.componentsThemeManager.currentThemeName=this.theme)},f=function(){i(this,e,"m",u).call(this),i(this,e,"m",h).call(this)},v})),Qo=(t,e="")=>Object.keys(t).reduce(((n,i)=>{var o;if("object"==typeof t[i]&&null!==t[i]&&!(null===(o=t[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),Qo(t[i],`${e+i}.`));const r="object"==typeof t[i]?t[i]:{value:t[i]},s=Object.assign(Object.assign({},n),{[e+i]:r,[`form.${e}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${e}fullName`]:r,[`form.${e}fullName`]:r}):s}),[]),Zo=Io((t=>{var e,n,o,r;return r=class extends t{constructor(){super(...arguments),e.add(this)}connectedCallback(){var t;i(this,e,"m",n).call(this)&&i(this,e,"m",o).call(this),null===(t=super.connectedCallback)||void 0===t||t.call(this)}},e=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const t=this.shadowRoot.host,e=document.createElement("form");e.style.width="100%",e.style.height="100%",t.parentElement.appendChild(e),e.appendChild(t)},r})),Yo=document.createElement("template");var tr,er,nr,ir,or,rr,sr,ar,lr,cr,dr,ur,hr,pr,fr,gr,vr,mr,br,wr,yr;Yo.innerHTML="\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n transition: opacity 300ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n .hidden {\n display: none;\n }\n\n\t</style>\n\t";const kr=ko(Xo,$o,Zo)(HTMLElement);class Ir extends kr{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(t){super(),tr.add(this),nr.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(t,e="")=>{this.logger.error(t,e,new Error),i(this,tr,"m",wr).call(this,t,e)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",n={})=>{this.logger.info(t,e,n)},debug:(t,e="")=>{this.logger.debug(t,e)}},ir.set(this,new oo),or.set(this,new oo),rr.set(this,{}),this.getComponentsContext=()=>i(this,rr,"f"),this.nextRequestStatus=new oo({isLoading:!1}),sr.set(this,void 0),ar.set(this,{popstate:i(this,tr,"m",ur).bind(this),componentsContext:i(this,tr,"m",vr).bind(this)}),lr.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,lr,t,"f"),i(this,tr,"m",cr).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(t=>{try{return Qo(JSON.parse(t))}catch(t){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return t=this.formConfig,e="value",Object.fromEntries(Object.entries(t).map((([t,n])=>[t,n[e]])));var t,e}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var t,e;const n=yield this.getProjectConfig(),i=(null===(t=null==n?void 0:n.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=i.version)&&void 0!==e||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),n="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return n||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=t.init)||void 0===e?void 0:e.call(this),i(this,or,"f").subscribe(i(this,tr,"m",br).bind(this)),i(this,or,"f").update({isDebug:this.debug}),i(this,tr,"m",dr).call(this),yield i(this,tr,"m",fr).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");i(this,tr,"m",yr).call(this);const{executionId:r,stepId:s,token:a,code:l,exchangeError:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p,ssoQueryParams:f}=Vi(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,ar,"f").popstate),window.addEventListener("components-context",i(this,ar,"f").componentsContext),i(this,ir,"f").subscribe(i(this,tr,"m",pr).bind(this)),i(this,ir,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:a,code:l,exchangeError:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p},f)),o(this,nr,!0,"f")}))}disconnectedCallback(){i(this,ir,"f").unsubscribeAll(),i(this,or,"f").unsubscribeAll(),i(this,tr,"m",mr).call(this),window.removeEventListener("popstate",i(this,ar,"f").popstate),window.removeEventListener("components-context",i(this,ar,"f").componentsContext)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&i(this,nr,"f")&&e!==n&&er.observedAttributes.includes(t)){i(this,tr,"m",dr).call(this);const o=null===e;i(this,ir,"f").update((({stepId:e,executionId:i})=>{let r=e,s=i;return o||(s=null,r=null,Fi()),{[Bi(t)]:n,stepId:r,executionId:s}})),i(this,or,"f").update({isDebug:this.debug})}}}function Sr(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var Cr,xr,jr,Or,Ar,Ur,Er,Rr,Lr,Tr,_r,$r,Pr,Mr,Dr,Nr,Wr,qr,Fr,Br,Vr,Kr,Hr,Gr,Jr,zr,Xr,Qr,Zr,Yr,ts,es,ns,is,os,rs;er=Ir,nr=new WeakMap,ir=new WeakMap,or=new WeakMap,rr=new WeakMap,sr=new WeakMap,ar=new WeakMap,lr=new WeakMap,tr=new WeakSet,cr=function(){this.shadowRoot.appendChild(Yo.content.cloneNode(!0)),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},dr=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];er.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[Bi(e)])throw Error(`${e} cannot be empty`)}))},ur=function(){const{stepId:t,executionId:e}=qi(this.flowId);i(this,ir,"f").update({stepId:t,executionId:e})},hr=function(t,e){this.sdk=ri(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},er.sdkConfigOverrides),{projectId:t,baseUrl:e})),["start","next"].forEach((t=>{const e=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>n(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield e(...t)}catch(t){return{error:{errorCode:ai,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},pr=function(t,e,o){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n}=t;if(o("projectId")||o("baseUrl")){if(!e)return;i(this,tr,"m",hr).call(this,e,n)}i(this,lr,"f").call(this,t)}))},fr=function(){return n(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"isMissingConfig"in t&&t.isMissingConfig&&(yield i(this,tr,"m",gr).call(this))}))},gr=function(){return n(this,void 0,void 0,(function*(){const t=function({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(li||i||"https://static.descope.com/pages");return o.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(o.pathname,t,n,e),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(t,e){return n(this,void 0,void 0,(function*(){const n=yield fetch(t,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${t} [${n.status}]`);return{body:yield n[e](),headers:Object.fromEntries(n.headers.entries())}}))}(t,"json"),!0}catch(t){return!1}}))},vr=function(t){o(this,rr,Object.assign(Object.assign({},i(this,rr,"f")),t.detail),"f")},mr=function(){var t;null===(t=i(this,sr,"f"))||void 0===t||t.remove(),o(this,sr,null,"f")},br=function(t){return n(this,arguments,void 0,(function*({isDebug:t}){t?(o(this,sr,document.createElement("descope-debugger"),"f"),Object.assign(i(this,sr,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return cs})),document.body.appendChild(i(this,sr,"f"))):i(this,tr,"m",mr).call(this)}))},wr=function(t,e){var n;t&&this.debug&&(null===(n=i(this,sr,"f"))||void 0===n||n.updateData({title:t,description:e}))},yr=function(){this.rootElement.onkeydown=t=>{var e,n,i;const o=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),r=_i.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==t.key||o||r)return;t.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(s).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},Ir.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.34.0"}};class ss extends Ir{static set sdkConfigOverrides(t){Ir.sdkConfigOverrides=t}static get sdkConfigOverrides(){return Ir.sdkConfigOverrides}constructor(){const t=new oo({deferredRedirect:!1});super(t.update.bind(t)),Cr.add(this),this.stepState=new oo({},{forceUpdate:!0}),xr.set(this,void 0),jr.set(this,null),Or.set(this,{visibilitychange:i(this,Cr,"m",Ar).bind(this)}),this.bridgeVersion=1,this.nativeResume=(t,e)=>{var n;const o=JSON.parse(e);if(this.logger.info(`nativeResume received payload of type '${t}'`),"oauthWeb"===t||"sso"===t){let{exchangeCode:t}=o;if(!t){t=null===(n=new URL(o.url).searchParams)||void 0===n?void 0:n.get(ui)}this.nativeComplete({exchangeCode:t,idpInitiated:!0})}else if("magicLink"===t){const t=new URL(o.url),e=t.searchParams.get("t"),n=t.searchParams.get(di).split("_").pop();i(this,Tr,"f").call(this),this.flowState.update({token:e,stepId:n,action:void 0})}else this.nativeComplete(o)},Rr.set(this,(t=>{this.contentRootElement.classList.toggle("hidden",t),this.slotElement.classList.toggle("hidden",!t)})),Lr.set(this,((t,e,r,s,a=!1)=>{if(this.flowState.current.action===Oi){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),c=a?500:2e3;o(this,xr,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const o=this.sdk.flow.next(t,e,Ti,r,s,{}),d=document.hidden&&!a&&Date.now()-l>c+500;let u;d&&this.logger.debug("polling - The polling seems to be throttled");try{const t=d?1e3:6e3;u=yield Hi(t,o)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,Lr,"f").call(this,t,e,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===ai)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,Lr,"f").call(this,t,e,r,s);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),i(this,_r,"f").call(this,u),i(this,Lr,"f").call(this,t,e,r,s)}))),c),"f")}})),Tr.set(this,(()=>{clearTimeout(i(this,xr,"f")),o(this,xr,null,"f")})),_r.set(this,(t=>{var e,n,o,r,s,a,l,c,d,u,h,p;if(!(null==t?void 0:t.ok)){const l=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,c=`${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.status} - ${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.statusText}`;i(this,Cr,"m",zr).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:c,errorMessage:l}),this.loggerWrapper.error((null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorDescription)||l,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||c);const d=null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorCode;return void("E102004"!==d&&"E103205"!==d||!this.isRestartOnError||i(this,Cr,"m",Ur).call(this))}null===(c=null===(l=t.data)||void 0===l?void 0:l.runnerLogs)||void 0===c||c.forEach((t=>{const{level:e,title:n,log:i}=t;e&&this.loggerWrapper[e]?this.loggerWrapper[e](n,i):this.loggerWrapper.info(n,i)}));const f=null===(h=null===(u=null===(d=t.data)||void 0===d?void 0:d.screen)||void 0===u?void 0:u.state)||void 0===h?void 0:h.errorText;(null===(p=t.data)||void 0===p?void 0:p.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${f?`${f} - `:""}${t.data.error.message}`):f&&this.loggerWrapper.error(f);const{status:g,authInfo:v,lastAuth:m}=t.data;if("completed"===g)return this.storeLastAuthenticatedUser&&function(t){(null==t?void 0:t.authMethod)&&si&&localStorage.setItem(pi,JSON.stringify(t))}(m),void i(this,Cr,"m",zr).call(this,"success",v);const{executionId:b,stepId:w,stepName:y,action:k,screen:I,redirect:S,openInNewTabUrl:C,webauthn:x,error:j,samlIdpResponse:O,nativeResponse:A}=t.data;k!==Oi?(this.loggerWrapper.info(`Step "${y||`#${w}`}" is ${g}`,"",{screen:I,status:g,stepId:w,stepName:y,action:k,error:j}),this.flowState.update({stepId:w,stepName:y,executionId:b,action:k,redirectTo:null==S?void 0:S.url,openInNewTabUrl:C,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==x?void 0:x.transactionId,webauthnOptions:null==x?void 0:x.options,samlIdpResponseUrl:null==O?void 0:O.url,samlIdpResponseSamlResponse:null==O?void 0:O.samlResponse,samlIdpResponseRelayState:null==O?void 0:O.relayState,nativeResponseType:null==A?void 0:A.type,nativePayload:null==A?void 0:A.payload})):this.flowState.update({action:k})})),$r.set(this,Ki((()=>n(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.loggerWrapper.warn("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.loggerWrapper.warn("Webauthn start failed",t.message)}}))))),Kr.set(this,Xi(((t,e)=>n(this,void 0,void 0,(function*(){var n,o;if("true"===t.getAttribute("formnovalidate")||i(this,Cr,"m",Nr).call(this)){const r=null==t?void 0:t.getAttribute("id");i(this,Cr,"m",qr).call(this,t);const s=yield i(this,Cr,"m",Wr).call(this),a=(o=t,Array.from((null==o?void 0:o.attributes)||[]).reduce(((t,e)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return i?Object.assign(t,{[i]:e.value}):t}),{})),l=this.getComponentsContext(),c=Object.assign(Object.assign(Object.assign(Object.assign({},l),a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});e(r,c),i(this,Cr,"m",Fr).call(this,s)}}))))),this.flowState=t}loadSdkScripts(){return n(this,void 0,void 0,(function*(){const t=(yield this.getFlowConfig()).sdkScripts;null==t||t.forEach((t=>n(this,void 0,void 0,(function*(){(yield function(t){return n(this,void 0,void 0,(function*(){let e;switch(t){case"forter":return e=yield Promise.resolve().then((function(){return us})),e.default;case"fingerprint":return e=yield Promise.resolve().then((function(){return ps})),e.default;case"fingerprintDescope":return e=yield Promise.resolve().then((function(){return gs})),e.default;default:throw new Error(`Unknown script id: ${t}`)}}))}(t.id))(t.initArgs,{baseUrl:this.baseUrl},(e=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Sr(t.id,t.resultKey)]:e},bubbles:!0,composed:!0}))}))}))))}))}init(){if(!window.isDescopeBridge)return this._init();this.lazyInit=this._init}_init(){const t=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var e,n,o;this.shadowRoot.isConnected&&(null===(e=this.flowState)||void 0===e||e.subscribe(this.onFlowChange.bind(this)),null===(n=this.stepState)||void 0===n||n.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",i(this,Or,"f").visibilitychange)),yield null===(o=t.init)||void 0===o?void 0:o.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=i(this,jr,"f"))||void 0===t||t.abort(),o(this,jr,null,"f"),window.removeEventListener("visibilitychange",i(this,Or,"f").visibilitychange)}getHtmlFilenameWithLocale(t,e){return n(this,void 0,void 0,(function*(){let n;const i=Qi(t),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${e}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${e}-${i.fallback}.html`),n}))}getPageContent(t,e){return n(this,void 0,void 0,(function*(){if(e)try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${e}. Fallback to url ${t}`,n)}try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(t){this.loggerWrapper.error("Failed to fetch flow page",t.message)}return null}))}onFlowChange(t,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:v,redirectTo:m,openInNewTabUrl:b,redirectUrl:w,token:y,code:k,exchangeError:I,webauthnTransactionId:S,webauthnOptions:C,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:O,redirectAuthInitiator:A,locale:U,samlIdpResponseUrl:E,samlIdpResponseSamlResponse:R,samlIdpResponseRelayState:L,nativeResponseType:T,nativePayload:_}=t,$=e(t,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload"]);let P,M,D;const N=(()=>{const t=localStorage.getItem(bo);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(bo,t.toString()),t}return Number(t)})(),W=this.sdk.getLastUserLoginId(),q=yield this.getFlowConfig(),F=yield this.getProjectConfig(),B=Object.entries(F.flows||{}).reduce(((t,[e,n])=>(t[e]=n.version,t)),{}),V=j&&x?{callbackUrl:j,codeChallenge:x,backupCallbackUri:O}:void 0,K=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;if(!p&&(this.loadSdkScripts(),q.fingerprintEnabled&&q.fingerprintKey?yield Dn(q.fingerprintKey,this.baseUrl):localStorage.removeItem(Pn),q.conditions?({startScreenId:P,conditionInteractionId:D,startScreenName:M}=((t,e)=>{const n=null==e?void 0:e.find((({key:e,operator:n,predicate:i})=>{var o;if("ELSE"===e)return!0;const r=null===(o=wo[e])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(t,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId}:{}})({loginId:W,code:k,token:y,abTestingKey:N},q.conditions)):q.condition?({startScreenId:P,conditionInteractionId:D}=((t,e)=>{var n;const i=null===(n=wo[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!i)return{};const o=i(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(q.condition,{loginId:W,code:k,token:y,abTestingKey:N})):(M=q.startScreenName,P=q.startScreenId),!Gi(P,$))){const t=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:V},$),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:yo(W),abTestingKey:N,locale:Qi(U).locale,nativeOptions:K}),D,"",F.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),$.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),$.oidcLoginHint?{externalId:$.oidcLoginHint}:{}));return i(this,_r,"f").call(this,t),void("completed"!==(null===(a=null==t?void 0:t.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&I)){const t=yield this.sdk.flow.next(p,h,Li,q.version,F.componentsVersion,{token:y,exchangeCode:k,exchangeError:I});return i(this,_r,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===Ri&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>s(t)))){if(!E||!R)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=t,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),i(o)})(E,R,L||"",Ji)}if(f===ji&&(s("redirectTo")||s("deferredRedirect")))return m?"android"===A&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(m):void this.loggerWrapper.error("Did not get redirect url");if(f===Ai||f===Ui){if(!S||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,e;null===(l=i(this,jr,"f"))||void 0===l||l.abort(),o(this,jr,null,"f");try{t=f===Ai?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}catch(t){"InvalidStateError"===t.name?this.loggerWrapper.warn("WebAuthn operation failed",t.message):"NotAllowedError"!==t.name&&this.loggerWrapper.error(t.message),e=t.name}const n=yield this.sdk.flow.next(p,h,Li,q.version,F.componentsVersion,{transactionId:S,response:t,failure:e});i(this,_r,"f").call(this,n)}if(f===Ei)return this.nativeComplete=t=>n(this,void 0,void 0,(function*(){const e=yield this.sdk.flow.next(p,h,Li,q.version,F.componentsVersion,t);i(this,_r,"f").call(this,e)})),void i(this,Cr,"m",zr).call(this,"bridge",{type:T,payload:_});if(i(this,Lr,"f").call(this,p,h,q.version,F.componentsVersion),!g&&!P)return void this.loggerWrapper.warn("No screen was found to show");const H=P||g,G=yield this.getHtmlFilenameWithLocale(U,H),{oidcLoginHint:J,oidcPrompt:z,oidcErrorRedirectUri:X,samlIdpUsername:Q}=$,Z={direction:Wi(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:W,name:this.sdk.getLastUserDisplayName()||W}}),htmlFilename:`${H}.html`,htmlLocaleFilename:G,screenId:H,stepName:t.stepName||M,samlIdpUsername:Q,oidcLoginHint:J,oidcPrompt:z,oidcErrorRedirectUri:X,openInNewTabUrl:b},Y=yo(W);Gi(P,$)?Z.next=(t,e)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:V},$),{lastAuth:Y,preview:this.preview,abTestingKey:N,client:this.client}),w&&{redirectUrl:w}),{locale:Qi(U).locale,nativeOptions:K}),D,t,F.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),e),k&&{exchangeCode:k,idpInitiated:!0}),$.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}));return i(this,_r,"f").call(this,n),n})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(Z.next=(t,e)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.next(p,h,t,q.version,F.componentsVersion,e);return i(this,_r,"f").call(this,n),n}))),this.loggerWrapper.debug("Going to render screen with id",Z.screenId),yield i(this,Cr,"m",Er).call(this,Z),this.stepState.update(Z)}))}onStepChange(t,e){return n(this,void 0,void 0,(function*(){var o,r;const{htmlFilename:s,htmlLocaleFilename:a,direction:l,next:c,screenState:d,openInNewTabUrl:u}=t;this.loggerWrapper.debug("Rendering a flow screen");const h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield i(this,Cr,"m",Mr).call(this,p,c):p.querySelectorAll(`descope-button[${xi}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!t.samlIdpUsername||(null===(o=d.form)||void 0===o?void 0:o.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=t.samlIdpUsername,d.form.email=t.samlIdpUsername),go(p,d,d.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((t,e)=>{Array.from(t.querySelectorAll('[default-code="autoDetect"]')).forEach((t=>{t.setAttribute("default-code",e)}))})(p,g);const v=()=>n(this,void 0,void 0,(function*(){var n,o;yield f;const r=this.contentRootElement;var s,a;s=r,a=null===(n=null==d?void 0:d.totp)||void 0===n?void 0:n.image,fo(s,"descope-totp-image",a),((t,e)=>{fo(t,"descope-notp-image",e)})(r,null===(o=null==d?void 0:d.notp)||void 0===o?void 0:o.image),((t,e,n,i)=>{n&&Object.keys(n).forEach((o=>{e.querySelector(o)||i.debug(`Skipping css vars for component "${o}}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((e=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[e];if(!l)return void i.info(`Could not find css variable name for ${e} in ${o}`,"Check if the css variable is defined in the component");const c=a[e];t.style.setProperty(l,c)})):i.info(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,p,d.cssVars,this.loggerWrapper),r.replaceChildren(p);const l=!e.htmlFilename;setTimeout((()=>{i(this,Cr,"m",Br).call(this),this.validateOnBlur&&(t=>{t.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))}))}))})(r),((t,e)=>{lo(t,null==e?void 0:e.inputs),lo(t,null==e?void 0:e.form)})(r,d),i(this,Cr,"m",Dr).call(this,{isFirstScreen:l,stepName:t.stepName}),((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}})(r,this.autoFocus,l)})),i(this,Cr,"m",Gr).call(this,c);r.querySelector(`[${xi}="polling"]`)&&c(Ti,{}),u&&!e.openInNewTabUrl&&window.open(u,"_blank")}));l?i(this,Cr,"m",Jr).call(this,v,l):v()}))}}xr=new WeakMap,jr=new WeakMap,Or=new WeakMap,Rr=new WeakMap,Lr=new WeakMap,Tr=new WeakMap,_r=new WeakMap,$r=new WeakMap,Kr=new WeakMap,Cr=new WeakSet,Ar=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Ur=function(){return n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const t=yield this.getComponentsVersion();this.reset();t===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},Er=function(t){return n(this,void 0,void 0,(function*(){var n;const o=Object.assign(Object.assign({},this.stepState.current),t),{next:r,stepName:s}=o,a=e(o,["next","stepName"]),l=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,s,Zi(a),r,this));if(l){this.loggerWrapper.debug("Rendering a custom screen"),this.contentRootElement.innerHTML="",i(this,Cr,"m",Dr).call(this,{isFirstScreen:!this.stepState.current.htmlFilename,stepName:t.stepName}),this.stepState.unsubscribeAll();const e=this.stepState.subscribe((()=>{var t;this.stepState.unsubscribe(e),null===(t=this.stepState)||void 0===t||t.subscribe(this.onStepChange.bind(this))}))}i(this,Rr,"f").call(this,l),this.flowState.forceUpdate=l}))},Pr=function(t){const e=t.getAttribute("name");if(!["email"].includes(e)){const n=`user-${e}`;t.setAttribute("name",n),t.addEventListener("input",(()=>{t.setAttribute("name",t.value?e:n)}))}},Mr=function(t,e){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,jr,"f"))||void 0===r||r.abort();const s=t.querySelector('*[autocomplete="webauthn"]');if(s&&(yield vo())){const{options:t,transactionId:r}=(yield i(this,$r,"f").call(this))||{};t&&r&&(i(this,Cr,"m",Pr).call(this,s),o(this,jr,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,i(this,jr,"f")).then((t=>n(this,void 0,void 0,(function*(){e(s.id,{transactionId:r,response:t})})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)})))}}))},Dr=function({isFirstScreen:t,stepName:e}){t&&i(this,Cr,"m",zr).call(this,"ready",{}),i(this,Cr,"m",zr).call(this,"page-updated",{screenName:e}),i(this,Cr,"m",zr).call(this,"screen-updated",{screenName:e})},Nr=function(){let t=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e=>{var n,i;"slot"!==e.localName&&(null===(n=e.reportValidity)||void 0===n||n.call(e),t&&(t=null===(i=e.checkValidity)||void 0===i?void 0:i.call(e)))})),t},Wr=function(){return n(this,void 0,void 0,(function*(){const t=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${hi}])`));return(yield Promise.all(t.map((t=>n(this,void 0,void 0,(function*(){return{name:t.getAttribute("name"),value:t.value}})))))).reduce(((t,e)=>Object.assign(Object.assign({},t),{[e.name]:e.value})),{})}))},qr=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},Fr=function(t={}){var e,n;const i=zi(t,["externalId","email","phone"]),o=zi(t,["newPassword","password"]);if(i&&o)try{if(!globalThis.PasswordCredential)return;const t=new globalThis.PasswordCredential({id:i,password:o});null===(n=null===(e=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===e?void 0:e.store)||void 0===n||n.call(e,t)}catch(t){this.loggerWrapper.error("Could not store credentials",t.message)}},Br=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((t=>t.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((t=>i(this,Cr,"m",Vr).call(this,t)))},Vr=function(t){if(!t)return;t.querySelectorAll("input").forEach((e=>{const n=e.getAttribute("slot"),i=`input-${t.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),t.appendChild(o),e.setAttribute("slot",i),this.appendChild(e)}))},Hr=function(t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.addEventListener("input",(()=>{var n;(null===(n=e.checkValidity)||void 0===n?void 0:n.call(e))&&i(this,Kr,"f").call(this,e,t)}))}))},Gr=function(t){this.contentRootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((e=>{e.onclick=()=>{i(this,Kr,"f").call(this,e,t)}})),i(this,Cr,"m",Hr).call(this,t)},Jr=function(t,e){this.contentRootElement.addEventListener("transitionend",(()=>{this.contentRootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===Pi.forward?"slide-forward":"slide-backward";Array.from(this.contentRootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),this.contentRootElement.classList.add("fade-out")},zr=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",ss);const as=document.createElement("template");as.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class ls extends HTMLElement{constructor(){super(),Xr.add(this),Qr.set(this,new oo({messages:[]})),Zr.set(this,void 0),Yr.set(this,void 0),ts.set(this,void 0),es.set(this,{resize:i(this,Xr,"m",rs).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(as.content.cloneNode(!0)),o(this,Zr,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Yr,i(this,Zr,"f").querySelector(".content"),"f"),o(this,ts,i(this,Zr,"f").querySelector(".header"),"f")}updateData(t){i(this,Qr,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((t,e,n)=>{let i=0,o=0,r=0,s=0;function a(e){e.preventDefault(),i=r-e.clientX,o=s-e.clientY,r=e.clientX,s=e.clientY;const[a,l]=mo(t,t.offsetLeft-i,t.offsetTop-o,n);t.style.top=`${l}px`,t.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(t){t.preventDefault(),r=t.clientX,s=t.clientY,document.onmouseup=l,document.onmousemove=a}e?e.onmousedown=c:t.onmousedown=c})(i(this,Zr,"f"),i(this,ts,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,es,"f").resize),(t=i(this,Zr,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&t.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},i(this,Zr,"f").onresize=i(this,Xr,"m",os).bind(this),i(this,Qr,"f").subscribe(i(this,Xr,"m",ns).bind(this))}disconnectedCallback(){i(this,Qr,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,es,"f").resize)}}Qr=new WeakMap,Zr=new WeakMap,Yr=new WeakMap,ts=new WeakMap,es=new WeakMap,Xr=new WeakSet,ns=function(t){i(this,Xr,"m",is).call(this,t),i(this,Xr,"m",os).call(this)},is=function(t){i(this,Yr,"f").innerHTML=t.messages.map((t=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${t.title}\n </div>\n <div class="msg_desc">\n ${t.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},os=function(){i(this,Yr,"f").querySelectorAll(".msg").forEach((t=>{const e=t.querySelector(".msg_desc"),n=e.scrollWidth>e.clientWidth,i=e.clientHeight>20;n||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},rs=function(){const[t,e]=mo(i(this,Zr,"f"),Number.parseInt(i(this,Zr,"f").style.left,10),Number.parseInt(i(this,Zr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Zr,"f").style.top=`${e}px`,i(this,Zr,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",ls);var cs=Object.freeze({__proto__:null,default:ls});const ds='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n';var us=Object.freeze({__proto__:null,default:(t,e,i)=>n(void 0,void 0,void 0,(function*(){const{siteId:e}=t,n=ds.replace(/{{SITE_ID}}/g,e),o=document.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("id",e),o.text=n,document.body.appendChild(o),document.addEventListener("ftr:tokenReady",(t=>{i(t.detail)}))}))});const hs=(t,e,i)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:e,useCloudflareIntegration:n,cloudflareScriptUrl:o,cloudflareEndpointUrl:r}=t;let s=[];s=n&&r?[r,an]:[an];let a=[];if(n&&o){const t=new URL(o);a=[`${t.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,fn]}else a=[fn];const l=gn({apiKey:e,endpoint:s,scriptUrlPattern:a}),c=yield l,{requestId:d}=yield c.get();i(d)}catch(t){console.warn("Could not load fingerprint",t)}}));var ps=Object.freeze({__proto__:null,default:hs,loadFingerprint:hs});const fs=(t,e,i)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:o,cloudflareEndpointPath:r,cloudflareScriptPath:s}=t,{baseUrl:a}=e;let l;l=n?`https://${n}`:a||"https://api.descope.com";const c=new URL(l);c.pathname=r;const d=new URL(l);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=gn({apiKey:o,endpoint:[c.toString(),an],scriptUrlPattern:[u,fn]}),p=yield h,{requestId:f}=yield p.get();i(f)}catch(t){console.warn("Could not load descope fingerprint",t)}}));var gs=Object.freeze({__proto__:null,default:fs,loadFingerprint:fs})}();
|
|
3
|
+
function rn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)t[i]=n[i]}return t}var sn=function t(e,n){function i(t,i,o){if("undefined"!=typeof document){"number"==typeof(o=rn({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=t+"="+e.write(i,t)+r}}return Object.create({set:i,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(i[a]=e.read(s,a),t===a)break}catch(t){}}return t?i[t]:i}},remove:function(t,e){i(t,"",rn({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,rn({},this.attributes,e))},withConverter:function(e){return t(rn({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(e)}})}({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var an={default:"endpoint"},ln="Blocked by CSP",cn="The endpoint parameter is not a valid URL",dn="Failed to load the JS script of the agent",un="9319";function hn(t,e){var n,i,o,r,s,a=[],l=(n=function(t){var e=function(t,e,n){if(n||2===arguments.length)for(var i,o=0,r=e.length;o<r;o++)!i&&o in e||(i||(i=Array.prototype.slice.call(e,0,o)),i[o]=e[o]);return t.concat(i||Array.prototype.slice.call(e))}([],t,!0);return{current:function(){return e[0]},postpone:function(){var t=e.shift();void 0!==t&&e.push(t)},exclude:function(){e.shift()}}}(t),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(t,e){var r,s=e instanceof Error?e.message:"";if(s===ln||s===cn)n.exclude(),r=0;else if(s===un)n.exclude();else if(s===dn){var a=Date.now()-t.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:t.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(t){var n=new Date,i=function(e){return a.push({url:t,startedAt:n,finishedAt:new Date,error:e})},o=e(t);return o.then((function(){return i()}),i),o.catch((function(t){if(null!=s||(s=t),a.length>=5)throw s;var e=d(n,t);if(!e)throw s;var i,o=e[0],r=e[1];return(i=r,new Promise((function(t){return setTimeout(t,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(t){return[t,a]}))}var pn="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",fn=pn;function gn(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=e(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:pn,c=function(){var t=[],e=function(){t.push({time:new Date,state:document.visibilityState})},n=function(t,e,n,i){return t.addEventListener(e,n,i),function(){return t.removeEventListener(e,n,i)}}(document,"visibilitychange",e);return e(),[t,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var t=function(t,e){return(Array.isArray(t)?t:[t]).map((function(t){return function(t,e){var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.11.6"):t}))}(String(t),e)}))}(l,s);return hn(t,vn)})).catch((function(t){throw u(),function(t){return t instanceof Error&&t.message===un?new Error(dn):t}(t)})).then((function(e){var n=e[0],i=e[1];return u(),n.load(t(t({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function vn(t){return function(t,e,n){var i,o=document,r="securitypolicyviolation",s=function(e){var n=new URL(t,location.href),o=e.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=e,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(e).then((function(t){return a(),t}),(function(t){return new Promise((function(t){var e=new MessageChannel;e.port1.onmessage=function(){return t()},e.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){if(function(t){if(URL.prototype)try{return new URL(t,location.href),!1}catch(t){if(t instanceof Error&&"TypeError"===t.name)return!0;throw t}}(t))throw new Error(cn);var i=document.createElement("script"),o=function(){var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),e()},i.onerror=function(){o(),n(new Error(dn))},i.async=!0,i.src=t,r.appendChild(i)}))}(t)}),(function(){throw new Error(ln)})).then(mn)}function mn(){var t=window,e="__fpjs_p_l_b",n=t[e];if(function(t,e){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==i?void 0:i.configurable)?delete t[e]:i&&!i.writable||(t[e]=void 0)}(t,e),"function"!=typeof(null==n?void 0:n.load))throw new Error(un);return n}const bn=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=t.hooks)||void 0===o?void 0:o[i])||[]).concat((null==e?void 0:e[i])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},wn=async t=>{if(!(null==t?void 0:t.ok))return{};const e=await(null==t?void 0:t.clone().json());return(null==e?void 0:e.authInfo)||e||{}},yn=async t=>{const e=await wn(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},kn="undefined"!=typeof localStorage,In=(t,e)=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),Sn=t=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Cn=t=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),xn=(...t)=>{console.debug(...t)},jn="undefined"!=typeof window,On=Math.pow(2,31)-1,An="DS",Un="DSR";function En(t=""){return Sn(`${t}${Un}`)||""}function Rn(t=""){return sn.get(An)||Sn(`${t}${An}`)||""}function Ln(t=""){Cn(`${t}${Un}`),Cn(`${t}${An}`),sn.remove(An)}const Tn=jn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",_n="vsid",$n="vrid",Pn="fp",Mn=(t=!1)=>{const e=localStorage.getItem(Pn);if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},Dn=async(t,e=Tn)=>{try{if(Mn())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(e);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(e);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=gn({apiKey:t,endpoint:[i.toString(),an],scriptUrlPattern:[r,fn]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((t,e)=>({[_n]:t,[$n]:e}))(n,l);(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem(Pn,JSON.stringify(e))})(c)}catch(t){console.warn("Could not load fingerprint",t)}},Nn=t=>{const e=Mn(!0);return e&&t.body&&(t.body.fpData=e),t},Wn="dls_last_user_login_id",qn="dls_last_user_display_name",Fn=()=>Sn(Wn),Bn=()=>Sn(qn),Vn=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,i={}]=e,o=Fn(),r=Bn();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await t(...e)};function Kn(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}async function Hn(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Zn(n.publicKey.challenge),n.publicKey.user.id=Zn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Zn(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:Yn(n.rawId),type:n.type,response:{attestationObject:Yn(n.response.attestationObject),clientDataJSON:Yn(n.response.clientDataJSON)}});var n}async function Gn(t){const e=Xn(t);return Qn(await navigator.credentials.get(e))}async function Jn(t,e){const n=Xn(t);return n.signal=e.signal,n.mediation="conditional",Qn(await navigator.credentials.get(n))}async function zn(t=!1){if(!jn)return Promise.resolve(!1);const e=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function Xn(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Zn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Zn(t.id)})),n}function Qn(t){return JSON.stringify({id:t.id,rawId:Yn(t.rawId),type:t.type,response:{authenticatorData:Yn(t.response.authenticatorData),clientDataJSON:Yn(t.response.clientDataJSON),signature:Yn(t.response.signature),userHandle:t.response.userHandle?Yn(t.response.userHandle):void 0}})}function Zn(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Yn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ti,ei=(ti=t=>({async signUp(e,n,i){const o=await t.webauthn.signUp.start(e,window.location.origin,n,i);if(!o.ok)return o;const r=await Hn(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(e,n){const i=await t.webauthn.signIn.start(e,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await Gn(i.data.options);return await t.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(e,n){var i;const o=await t.webauthn.signUpOrIn.start(e,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const e=await Hn(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await Gn(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,e)}},async update(e,n,i){const o=await t.webauthn.update.start(e,window.location.origin,n,i);if(!o.ok)return o;const r=await Hn(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:Hn,get:Gn,isSupported:zn,conditional:Jn}}),(...t)=>{const e=ti(...t);return Object.assign(e.signUp,t[0].webauthn.signUp),Object.assign(e.signIn,t[0].webauthn.signIn),Object.assign(e.signUpOrIn,t[0].webauthn.signUpOrIn),Object.assign(e.update,t[0].webauthn.update),e});const ni="/fedcm/config",ii=(t,e)=>({async oneTap(e,n,i,o,r){const s=null!=e?e:"google",a=await t.oauth.startNative(s,i,!0);if(!a.ok)return a;const{clientId:l,stateId:c,nonce:d}=a.data,u=await async function(){return new Promise(((t,e)=>{if(window.google)return void t(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?t(window.google.accounts.id):e("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){e("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((e=>{var i,a;u.initialize(Object.assign(Object.assign({},n),{itp_support:null===(i=null==n?void 0:n.itp_support)||void 0===i||i,use_fedcm_for_prompt:null===(a=null==n?void 0:n.use_fedcm_for_prompt)||void 0===a||a,client_id:l,callback:n=>{e(t.oauth.finishNative(s,c,"","",n.credential))},nonce:d})),u.prompt((t=>{var e,n;if(r&&(null==t?void 0:t.isDismissedMoment())){const n=null===(e=t.getDismissedReason)||void 0===e?void 0:e.call(t);null==r||r(n)}else if(o&&(null==t?void 0:t.isSkippedMoment())){const e=null===(n=t.getSkippedReason)||void 0===n?void 0:n.call(t);null==o||o(e)}}))}))},async launch(n){var i;const o={identity:{context:n||"signin",providers:[{configURL:t.httpClient.buildUrl(e+ni),clientId:e}]}},r=await(null===(i=navigator.credentials)||void 0===i?void 0:i.get(o));return t.refresh(r.token)},isSupported:()=>jn&&"IdentityCredential"in window,async isLoggedIn(n){var i;const o=t.httpClient.buildUrl(e+ni);try{const t={identity:{context:n||"signin",providers:[{configURL:o,clientId:e}]}},r=await(null===(i=navigator.credentials)||void 0===i?void 0:i.get(t));return!!r&&!!r.token}catch(t){return!1}}});var oi=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await zn(),i=Object.assign(Object.assign({location:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return e[1]=i,t.flow.start(...e)}});const ri=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:i,fpLoad:o}=n,r=e(n,["fpKey","fpLoad"]);return jn?(i&&o&&Dn(i).catch((()=>null)),t(bn(r,{beforeRequest:Nn}))):t(r)}),(t=>n=>{var{autoRefresh:i}=n,o=e(n,["autoRefresh"]);if(!i)return t(o);const{clearAllTimers:r,setTimer:s}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})();let l,c;jn&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>l&&(xn("Expiration time passed, refreshing session"),d.refresh(En()||c))}));const d=t(bn(o,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:i}=await wn(e);if(401===(null==e?void 0:e.status))xn("Received 401, canceling all timers"),r();else if(i){if(l=(t=>{try{const e=a(t);if(e.exp)return new Date(1e3*e.exp)}catch(t){return null}})(i),!l)return void xn("Could not extract expiration time from session token");c=n;let t=((o=l)?o.getTime()-(new Date).getTime():0)-2e4;t>On&&(xn(`Timeout is too large (${t}ms), setting it to ${On}ms`),t=On),r();const e=new Date(Date.now()+t).toLocaleTimeString("en-US",{hour12:!1});xn(`Setting refresh timer for ${e}. (${t}ms)`),s((()=>{xn("Refreshing session due to timer"),d.refresh(En()||n)}),t)}var o}}));return Jt(d,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return xn("Clearing all timers"),r(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.24.0"},e.baseHeaders)}))),(t=>e=>{const n=Kn(),i=Kn(),o=t(bn(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),i.pub(null);else{const t=await yn(e);t&&i.pub(t);const{sessionJwt:o}=await wn(e);o&&n.pub(o)}}})),r=Jt(o,["logout","logoutAll"],(t=>async(...e)=>{const o=await t(...e);return n.pub(null),i.pub(null),o}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:i.sub})}),(t=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=e(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(t(r),{getLastUserLoginId:Fn,getLastUserDisplayName:Bn});const s=t(bn(r,{afterRequest:async(t,e)=>{var n;const i=await yn(e),o=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],r=null==i?void 0:i.name;o&&((t=>{In(Wn,t)})(o),(t=>{In(qn,t)})(r))}}));let a=Jt(s,["flow.start"],Vn);return a=Jt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const i=await e(...n);return t||(Cn(Wn),Cn(qn)),i})(o)),Object.assign(a,{getLastUserLoginId:Fn,getLastUserDisplayName:Bn})}),(t=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,storagePrefix:r}=n,s=e(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!jn)return t(s);const a=t(bn(s,{beforeRequest:(l=r,t=>Object.assign(t,{token:t.token||En(l)})),afterRequest:async(t,n)=>{const i=/^\/v\d+\/mgmt\//.test(t.path);401===(null==n?void 0:n.status)?i||Ln(r):((t={},n,i)=>{var{refreshJwt:o,sessionJwt:r}=t,s=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===i&&(i=""),o&&In(`${i}${Un}`,o),r&&(n?function(t,e,{cookiePath:n,cookieDomain:i,cookieExpiration:o,cookieSameSite:r="Strict"}){if(e){const s=new Date(1e3*o),a=function(t){const e=window.location.hostname.split("."),n=t.split(".");return e.slice(-n.length).join(".")===t}(i);sn.set(t,e,{path:n,domain:a?i:void 0,expires:s,sameSite:r,secure:!0})}}(An,r,Object.assign(Object.assign({},s),{cookieSameSite:!0===n?"Strict":n.sameSite})):In(`${i}${An}`,r))})(await wn(n),o,r)}}));var l;const c=Jt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const i=await e(...n);return Ln(t),i})(r));return Object.assign(c,{getRefreshToken:()=>En(r),getSessionToken:()=>Rn(r)})}))(((...t)=>{const e=on(...t);return Object.assign(Object.assign({},e),{refresh:t=>{const n=Rn();return e.refresh(t,{dcs:n?"t":"f"})},flow:oi(e),webauthn:ei(e),fedcm:ii(e,t[0].projectId)})})),si="undefined"!=typeof localStorage,ai="J151000",li=si&&localStorage.getItem("base.content.url")||"",ci="base.ui.components.url";si&&localStorage.getItem(ci),si&&localStorage.getItem(ci);const di="descope-login-flow",ui="code",hi="data-exclude-field",pi="dls_last_auth",fi="state_id",gi="saml_idp_state_id",vi="saml_idp_username",mi="descope_idp_initiated",bi="sso_app_id",wi="third_party_app_id",yi="third_party_app_state_id",ki="oidc_login_hint",Ii="oidc_prompt",Si="oidc_error_redirect_uri",Ci="application_scopes",xi="data-type",ji="redirect",Oi="poll",Ai="webauthnCreate",Ui="webauthnGet",Ei="nativeBridge",Ri="loadForm",Li="submit",Ti="polling",_i=["descope-multi-select-combo-box","descope-text-area"],$i=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Pi;!function(t){t.backward="backward",t.forward="forward"}(Pi||(Pi={}));const Mi=["descope-enriched-text"];function Di(t){return new URLSearchParams(window.location.search).get(t)}function Ni(t){if(window.history.replaceState&&Di(t)){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.delete(t),e.search=n.toString(),window.history.replaceState({},"",e.toString())}}function Wi(t,e){if(!e)return;const n=+t,i=+e;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?Pi.forward:n<i?Pi.backward:void 0}const qi=t=>{let[e="",n=""]=(Di(di)||"").split("_");const i=(t=>{var e;return(null===(e=/(.*)\|#\|.*/.exec(t))||void 0===e?void 0:e[1])||""})(e);return(!t||i&&i!==t)&&(e="",n=""),{executionId:e,stepId:n,executionFlowId:i}};function Fi(){Ni(di)}const Bi=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),Vi=(t,e)=>{const{executionId:n,stepId:i,executionFlowId:o}=qi(t);if(o&&t!==o)return e.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&Fi();const r=Di("t")||void 0;r&&Ni("t");const s=Di(ui)||void 0;s&&Ni(ui);const a=Di("err")||void 0;a&&Ni("err");const{redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u}={redirectAuthCodeChallenge:Di("ra-challenge"),redirectAuthCallbackUrl:Di("ra-callback"),redirectAuthBackupCallbackUri:Di("ra-backup-callback"),redirectAuthInitiator:Di("ra-initiator")},h=Di(fi);h&&Ni(fi);const p=Di(gi);p&&Ni(gi);const f=Di(vi);p&&Ni(vi);const g=Di(mi);g&&Ni(mi);const v=Di(bi);v&&Ni(bi);const m=Di(wi);m&&Ni(wi);const b=Di(yi);b&&Ni(yi);const w=Di(Ci);w&&Ni(Ci);const y=Di(ki);y&&Ni(ki);const k=Di(Ii);k&&Ni(Ii);const I=Di(Si);I&&Ni(Si);return{executionId:n,stepId:i,token:r,code:s,exchangeError:a,redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u,ssoQueryParams:{oidcIdpStateId:h,samlIdpStateId:p,samlIdpUsername:f,descopeIdpInitiated:"true"===g,ssoAppId:v,oidcLoginHint:y,oidcPrompt:k,oidcErrorRedirectUri:I,thirdPartyAppId:m,thirdPartyAppStateId:b,applicationScopes:w}}},Ki=t=>{let e,n;return Object.assign(((...i)=>{return e&&(r=i,(o=e).length===r.length&&o.every(((t,e)=>t===r[e])))||(e=i,n=t(...i)),n;var o,r}),{reset:()=>{e=void 0,n=void 0}})};function Hi(t,e,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${t} ms`))}),t);e.then((t=>{r||(clearTimeout(s),i(t))})).catch((t=>{r||(clearTimeout(s),o(t))}))}))}const Gi=(t,{oidcIdpStateId:e,samlIdpStateId:n,samlIdpUsername:i,ssoAppId:o,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,thirdPartyAppId:l,thirdPartyAppStateId:c,applicationScopes:d})=>!(!t||e||n||i||o||r||s||a||l||c||d),Ji=t=>null==t?void 0:t.submit(),zi=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null},Xi=(t,e=100)=>{let n;return function(...i){n||t.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),e)}};function Qi(t){if(t)return{locale:t.toLowerCase(),fallback:t.toLowerCase()};const e=navigator.language;return e?e.includes("-")?{locale:e.toLowerCase(),fallback:e.split("-")[0].toLowerCase()}:{locale:e.toLowerCase(),fallback:e.toLowerCase()}:{locale:"",fallback:""}}const Zi=t=>{const e=(n=t.screenState,i=(t,e)=>$i.includes(e)||e.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([t,e])=>!i(e,t)))));var n,i;const{screenState:{errorText:o,errorType:r}}=t;return(o||r)&&(e.error={text:o,type:r}),e};var Yi,to,eo,no;function io(t,e){const n=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=t[o],s=e[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!io(r,s))return!1}else if(r!==s)return!1}return!0}class oo{constructor(t={},{forceUpdate:e=!1}={}){Yi.set(this,void 0),to.set(this,{}),eo.set(this,0),no.set(this,!0),this.update=t=>{const e="function"==typeof t?t(i(this,Yi,"f")):t,n=Object.assign(Object.assign({},i(this,Yi,"f")),e);if(i(this,no,"f")||!io(i(this,Yi,"f"),n)){const t=i(this,Yi,"f");o(this,Yi,n,"f"),Object.freeze(i(this,Yi,"f")),setTimeout((()=>{Object.values(i(this,to,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},o(this,Yi,t,"f"),o(this,no,e,"f")}get current(){return Object.assign({},i(this,Yi,"f"))}set forceUpdate(t){o(this,no,t,"f")}subscribe(t){return o(this,eo,i(this,eo,"f")+1,"f"),i(this,to,"f")[i(this,eo,"f")]=t,i(this,eo,"f").toString()}unsubscribe(t){const e=!!i(this,to,"f")[t];return e&&delete i(this,to,"f")[t],e}unsubscribeAll(){return o(this,to,{},"f"),!0}}Yi=new WeakMap,to=new WeakMap,eo=new WeakMap,no=new WeakMap;const ro=["*","#","/","(",")","[","]","_","<",">","`"],so=t=>{const e=ro.map((e=>`${t}${e}`)).join("|");return new RegExp(`(${e})`,"g")},ao=["disabled"],lo=(t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${hi}])`)).forEach((t=>{t.value=n}))}))},co=(t,e)=>e.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),t),uo=(t,e,n)=>t.replace(/{{(.+?)}}/g,((t,i)=>n?(t=>"string"!=typeof t?t:t.replace(so("\\"),"\\$1"))(co(e,i)):co(e,i))),ho=(t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{const n=(i=t.localName,Mi.includes(i));var i;t.textContent=uo(t.textContent,e,n);const o=t.getAttribute("href");o&&t.setAttribute("href",uo(o,e))}))},po=(t,e,n)=>{t.querySelectorAll(`[${xi}="${e}"]`).forEach((t=>{t.setAttribute("href",n)}))},fo=(t,e,n)=>{var i,o;const r=null===(i=customElements.get(e))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==t?void 0:t.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},go=(t,e,n,i,o,r)=>{var s,a;let l=null==e?void 0:e.errorText;try{l=(null==o?void 0:o({text:null==e?void 0:e.errorText,type:null==e?void 0:e.errorType}))||(null==e?void 0:e.errorText)}catch(t){r.error("Error transforming error message",t.message)}((t,e,n="")=>{t.querySelectorAll(`[${xi}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",l),po(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),po(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),ho(t,e),((t,e,n)=>{e&&Object.keys(e).forEach((i=>{t.querySelectorAll(`[name=${i}]`).forEach((t=>{const o=e[i];Object.keys(o).forEach((e=>{let i=o[e];if("string"!=typeof i)try{i=JSON.stringify(i)}catch(t){n.error(`Could not stringify value "${i}" for "${e}"`,t.message),i=""}t.setAttribute(e,i)}))}))}))})(t,n,r),((t,e)=>{t.querySelectorAll("[data-has-dynamic-attr-values]").forEach((t=>{Array.from(t.attributes).forEach((t=>{t.value=uo(t.value,e)}))}))})(t,e),((t,e)=>{Object.entries(e).forEach((([e,n])=>{t.querySelectorAll(`[name="${e}"]`).forEach((t=>{Object.entries(n).forEach((([e,n])=>{ao.includes(e)&&t.setAttribute(e,n)}))}))}))})(t,i)},vo=Ki((()=>n(void 0,void 0,void 0,(function*(){var t,e;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),i=(()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,n=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return n?n.version:0})()>=108;return yield Hi(100,n,i)}catch(t){return console.error("Conditional login check failed",t),!1}})))),mo=(t,e,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(e,("all"===i.left?t.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-t.offsetWidth),window.innerWidth-("all"===i.right?t.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?t.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-t.offsetHeight),window.innerHeight-("all"===i.bottom?t.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]},bo="dls_ab_testing_id",wo={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code},externalToken:{"is-true":t=>!!t.token,"is-false":t=>!t.token},abTestingKey:{"greater-than":(t,e)=>(t.abTestingKey||0)>e,"less-than":(t,e)=>(t.abTestingKey||0)<e}};function yo(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(pi)))}catch(t){}return e}function ko(...t){return e=>t.reduce(((t,e)=>e(t)),e)}const Io=t=>{const e=Symbol((t=>{const e=t.toString();let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n&=n;return n.toString(16)})(t));return n=>{if(n[e])return n;const i=t(n);return i[e]=!0,i}},So=["error","warn","info","debug"],Co=Io((t=>{var e,n,r,s;return s=class extends t{constructor(){super(...arguments),e.add(this),n.set(this,i(this,e,"m",r).call(this,console))}set logger(t){o(this,n,i(this,e,"m",r).call(this,t||console),"f")}get logger(){return i(this,n,"f")}onLogEvent(t,e){}},n=new WeakMap,e=new WeakSet,r=function(t){return So.reduce(((e,n)=>(e[n]=(...e)=>{var i;this.onLogEvent(n,e),null===(i=t[n])||void 0===i||i.call(t,...e)},e)),{})},s})),xo="undefined"!=typeof localStorage,jo=xo&&localStorage.getItem("base.content.url")||"",Oo=(t,e)=>!e&&`${t} cannot be empty, please make sure to set this attribute`,Ao=Io((t=>{var e,n;return n=class extends t{constructor(){super(...arguments),e.set(this,!0)}connectedCallback(){var t,n;null===(t=super.connectedCallback)||void 0===t||t.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&i(this,e,"f")&&(o(this,e,!1,"f"),this.init())}async init(){}},e=new WeakMap,n})),Uo=Io((t=>{var e,n;const o=ko(Co,Ao)(t);return n=class extends o{constructor(){super(...arguments),e.set(this,{})}async init(){var t,n,o;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),n=this,o=t=>{var n;null===(n=i(this,e,"f")[t])||void 0===n||n.forEach((e=>{e(t,this.getAttribute(t))}))},Array.from(n.attributes).forEach((t=>o(t.name))),new MutationObserver((t=>{t.forEach((t=>{"attributes"===t.type&&o(t.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(t,n){i(this,e,"f")[t]||(i(this,e,"f")[t]=[]);const o=i(this,e,"f")[t].push(n);return()=>i(this,e,"f")[t].splice(o,1)}observeAttributes(t,e){const n=t.reduce(((t,n)=>(t.push(this.observeAttribute(n,e)),t)),[]);return()=>n.forEach((t=>t()))}},e=new WeakMap,n})),Eo=t=>e=>{var n,o,r;const s=ko(Co,Ao,Uo)(e),a=Object.keys(t);return r=class extends s{constructor(...t){super(...t),n.add(this),this.observeAttributes(a,i(this,n,"m",o).bind(this))}async init(){var t;a.forEach((t=>i(this,n,"m",o).call(this,t,this.getAttribute(t)))),await(null===(t=super.init)||void 0===t?void 0:t.call(this))}},n=new WeakSet,o=function(e,n){const i=t[e],o="function"==typeof i?i(e,n):i;o&&this.logger.error(o)},r};Eo.missingAttrValidator=Oo;const Ro=Io((t=>{const e=ko(Eo({"project-id":Oo}))(t);return class extends e{get projectId(){return this.getAttribute("project-id")}}})),Lo=Io((t=>class extends t{get baseUrl(){return this.getAttribute("base-url")||""}})),To="Trying the next fallback URL...";function _o({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:i="https://static.descope.com/pages"}){const o=new URL(i);return o.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(o.pathname,t,n,e),o.baseUrl=i,o}const $o=Io((t=>{var e,n,r,s,a;const l=ko(Co,Ro,Lo)(t);return a=class extends l{constructor(){super(...arguments),e.add(this),n.set(this,void 0),r.set(this,void 0)}async fetchStaticResource(t,n){const a=i(this,e,"m",s).call(this,t),l=Array.isArray(a)?t=>{if(t!==a.length-1){const{baseUrl:e}=a[t];o(this,r,e,"f")}}:null;try{const t=await(async(t,e,{logger:n,onSuccess:i})=>{const o=Array.isArray(t)?t:[t];for(let t=0;t<o.length;t++){const r=o[t],s=t===o.length-1;try{const o=await fetch(r.toString(),e);if(o.ok)return null==i||i(t),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${To}`)}catch(t){const e=`Error fetching URL ${r} [${t.message}]`;if(s)throw new Error(e);null==n||n.debug(`${e}. ${To}`)}}})(a,{cache:"default"},{logger:this.logger,onSuccess:l});return{body:await t[n](),headers:Object.fromEntries(t.headers.entries())}}catch(t){this.logger.error(t.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")}},n=new WeakMap,r=new WeakMap,e=new WeakSet,s=function(t){const e=jo||this.baseStaticUrl;if(e)return _o({projectId:this.projectId,filename:t,baseUrl:e});const s=i(this,n,"f")!==this.baseUrl,a=s&&!!this.baseUrl;s&&(o(this,n,this.baseUrl,"f"),o(this,r,void 0,"f"));const l=_o({projectId:this.projectId,filename:t,baseUrl:i(this,r,"f")});if(!a)return l;return[_o({projectId:this.projectId,filename:t,baseUrl:this.baseUrl+"/pages"}),l]},a})),Po=Io((t=>{var e,n;const o=ko(Eo({"project-id":Oo}))(t);return n=class extends o{constructor(){super(...arguments),e.set(this,new Map)}onReset(t,n){if(i(this,e,"f").has(t))throw new Error(`Callback for sectionId ${t} already exists`);return i(this,e,"f").set(t,n),()=>{i(this,e,"f").delete(t)}}async reset(...t){0===t.length?await Promise.all(Array.from(i(this,e,"f").values()).map((t=>t()))):await Promise.all(t.map((t=>{var n;if(!i(this,e,"f").has(t))throw new Error(`Callback for sectionId ${t} does not exist`);return null===(n=i(this,e,"f").get(t))||void 0===n?void 0:n()})))}},e=new WeakMap,n})),Mo=Io((t=>{var e,n,r,s,a;const l=ko($o,Po,Ao)(t);return a=class extends l{constructor(){super(...arguments),e.add(this),r.set(this,void 0),s.set(this,(async()=>{try{const{body:t,headers:e}=await this.fetchStaticResource("config.json","json");return{projectConfig:t,executionContext:{geo:e["x-geo"]}}}catch(t){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,e,"m",n).bind(this))}get config(){return i(this,r,"f")||o(this,r,i(this,s,"f").call(this),"f"),i(this,r,"f")}},r=new WeakMap,s=new WeakMap,e=new WeakSet,n=function(){o(this,r,void 0,"f")},a})),Do="load-descope-ui",No="base.ui.components.url",Wo=xo&&localStorage.getItem(No)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",qo=xo&&localStorage.getItem(No)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Fo=xo&&localStorage.getItem(No)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Bo=t=>{const e=document.createElement("script");return e.id=t,e},Vo=(t,e)=>t.replace("<version>",e),Ko=Io((t=>{var e,n,r,s,a,l,c,d,u,h,p,f;const g=ko(Co,Mo)(t);return f=class extends g{constructor(){super(...arguments),e.add(this),n.set(this,Symbol("errorCbs")),r.set(this,Symbol("loadCbs")),u.set(this,void 0)}get descopeUi(){return i(this,u,"f")||o(this,u,i(this,e,"m",p).call(this),"f"),i(this,u,"f")}async loadDescopeUiComponents(t){const n=Array.isArray(t)?t:(t=>[...Array.from(t.content.querySelectorAll("*")).reduce(((t,e)=>e.localName.startsWith("descope-")?t.add(e.localName):t),new Set)])(t);return Promise.all(n.map((t=>i(this,e,"m",h).call(this,t))))}get baseCdnUrl(){return this.getAttribute("base-cdn-url")}},n=new WeakMap,r=new WeakMap,u=new WeakMap,e=new WeakSet,s=async function(){var t;const e=await this.config,n=null===(t=null==e?void 0:e.projectConfig)||void 0===t?void 0:t.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},a=function(t){const e=i(this,n,"f"),o=i(this,r,"f");t[e]=[],t[o]=[],Object.defineProperty(t,"onerror",{set(n){t[e].push(n)}}),Object.defineProperty(t,"onload",{set(e){t[o].push(e)}})},l=async function(t,n,o,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const a=Bo(o);document.body.append(a),a.addEventListener("error",(()=>{t.forEach((t=>t(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${a.src}"`)))})),a.addEventListener("load",(()=>{n.forEach((t=>t()))})),a.src=Vo(r,await i(this,e,"m",s).call(this))},c=function(t){t.addEventListener("error",(()=>{t[i(this,n,"f")].forEach((e=>e(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${t.src}"`))),i(this,e,"m",l).call(this,[i(this,e,"m",l).bind(this,t[i(this,n,"f")],t[i(this,r,"f")],"load-descope-ui-fallback-script-2",Fo),...t[i(this,n,"f")]],t[i(this,r,"f")],"load-descope-ui-fallback-script",qo)})),t.addEventListener("load",(()=>{t[i(this,r,"f")].forEach((t=>t()))}))},d=async function(){if(document.querySelector(`script#${Do}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const t=Bo(Do);document.body.append(t),i(this,e,"m",a).call(this,t),i(this,e,"m",c).call(this,t),t.src=Vo(this.baseCdnUrl||Wo,await i(this,e,"m",s).call(this))}return document.getElementById(Do)},h=async function(t){if(!!customElements.get(t))return void this.logger.debug(`Loading component "${t}" is skipped as it is already defined`);const e=await this.descopeUi;if(e[t])try{return await e[t]()}catch(e){if("NotSupportedError"!==e.name)throw e;console.debug(`Encountered an error while attempting to define the "${t}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${t}"`,`Descope UI does not have a component named "${t}", available components are: "${Object.keys(e).join(", ")}"`)},p=function(){return new Promise((t=>{globalThis.DescopeUI&&t(globalThis.DescopeUI),i(this,e,"m",d).call(this).then((e=>{e.onerror=this.logger.error,e.onload=()=>{this.logger.debug("DescopeUI was loaded"),t(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&t(globalThis.DescopeUI)}))}))}))},f})),Ho="content-root",Go="root",Jo=Io((t=>class extends t{constructor(...t){var e,n;super(...t),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${Go}, #${Ho} {\n height: 100%;\n }\n #${Go} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${Go}">\n <div id="${Ho}"></div>\n </div>\n `,this.contentRootElement=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById(Ho),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Go)}})),zo=(t,e)=>!!e&&"light"!==e&&"dark"!==e&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Xo=Io((t=>{var e,n,r,s,a,l,c,d,u,h,p,f,g,v;const m=ko(Eo({theme:zo}),$o,Ao,Ko,Mo,Jo,Uo)(t);return v=class extends m{constructor(){super(...arguments),e.add(this),n.set(this,void 0),r.set(this,void 0),p.set(this,(()=>{i(this,e,"m",f).call(this),i(this,g,"f").call(this,"os"===this.getAttribute("theme"))})),g.set(this,(t=>{var n,o,r;const s=t?"addEventListener":"removeEventListener";null===(r=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===r||r.call(o,"change",(()=>i(this,e,"m",f).call(this)))}))}get theme(){var t,e;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(e=null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)"))||void 0===e?void 0:e.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var t;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),i(this,e,"m",l).call(this),i(this,e,"m",c).call(this),i(this,p,"f").call(this),this.observeAttributes(["theme"],i(this,p,"f")),this.observeAttributes(["style-id"],(()=>{o(this,r,null,"f"),i(this,e,"m",u).call(this),i(this,e,"m",l).call(this),i(this,e,"m",c).call(this)}))}},n=new WeakMap,r=new WeakMap,p=new WeakMap,g=new WeakMap,e=new WeakSet,s=async function(){try{const{body:t}=await this.fetchStaticResource(`${this.styleId}.json`,"json");return t}catch(t){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},a=function(){return i(this,r,"f")||(o(this,r,i(this,e,"m",s).call(this),"f"),i(this,r,"f").then((t=>this.logger.debug("Fetched theme",t)))),i(this,r,"f")},l=async function(){var t,r;const s=await i(this,e,"a",a);s&&(i(this,n,"f")||(o(this,n,document.createElement("style"),"f"),i(this,n,"f").id="global-style",this.shadowRoot.appendChild(i(this,n,"f"))),i(this,n,"f").innerText=((null===(t=null==s?void 0:s.light)||void 0===t?void 0:t.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||""))},c=async function(){var t,n;const o=Object.assign({},await i(this,e,"a",a));if(!o)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(t=null==o?void 0:o.light)||void 0===t?void 0:t.components,dark:null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.components})},d=async function(){var t,e;const{projectConfig:n}=await this.config||{},i=null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t[this.styleId],o=null==n?void 0:n.cssTemplate,r=i||o;return null===(e=null==r?void 0:r[this.theme])||void 0===e?void 0:e.fonts},u=async function(){const t=await i(this,e,"m",d).call(this);t?Object.values(t).forEach((t=>{t.url&&(this.logger.debug(`Loading font from URL "${t.url}"`),(t=>{const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url))})):this.logger.debug("No fonts to load")},h=async function(){this.rootElement.setAttribute("data-theme",this.theme);const t=await this.descopeUi;(null==t?void 0:t.componentsThemeManager)&&(t.componentsThemeManager.currentThemeName=this.theme)},f=function(){i(this,e,"m",u).call(this),i(this,e,"m",h).call(this)},v})),Qo=(t,e="")=>Object.keys(t).reduce(((n,i)=>{var o;if("object"==typeof t[i]&&null!==t[i]&&!(null===(o=t[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),Qo(t[i],`${e+i}.`));const r="object"==typeof t[i]?t[i]:{value:t[i]},s=Object.assign(Object.assign({},n),{[e+i]:r,[`form.${e}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${e}fullName`]:r,[`form.${e}fullName`]:r}):s}),[]),Zo=Io((t=>{var e,n,o,r;return r=class extends t{constructor(){super(...arguments),e.add(this)}connectedCallback(){var t;i(this,e,"m",n).call(this)&&i(this,e,"m",o).call(this),null===(t=super.connectedCallback)||void 0===t||t.call(this)}},e=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const t=this.shadowRoot.host,e=document.createElement("form");e.style.width="100%",e.style.height="100%",t.parentElement.appendChild(e),e.appendChild(t)},r})),Yo=document.createElement("template");var tr,er,nr,ir,or,rr,sr,ar,lr,cr,dr,ur,hr,pr,fr,gr,vr,mr,br,wr,yr;Yo.innerHTML="\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n transition: opacity 300ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n .hidden {\n display: none;\n }\n\n\t</style>\n\t";const kr=ko(Xo,$o,Zo)(HTMLElement);class Ir extends kr{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(t){super(),tr.add(this),nr.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(t,e="")=>{this.logger.error(t,e,new Error),i(this,tr,"m",wr).call(this,t,e)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",n={})=>{this.logger.info(t,e,n)},debug:(t,e="")=>{this.logger.debug(t,e)}},ir.set(this,new oo),or.set(this,new oo),rr.set(this,{}),this.getComponentsContext=()=>i(this,rr,"f"),this.nextRequestStatus=new oo({isLoading:!1}),sr.set(this,void 0),ar.set(this,{popstate:i(this,tr,"m",ur).bind(this),componentsContext:i(this,tr,"m",vr).bind(this)}),lr.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,lr,t,"f"),i(this,tr,"m",cr).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenantId(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(t=>{try{return Qo(JSON.parse(t))}catch(t){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return t=this.formConfig,e="value",Object.fromEntries(Object.entries(t).map((([t,n])=>[t,n[e]])));var t,e}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"executionContext"in t?t.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"projectConfig"in t?t.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var t,e;const n=yield this.getProjectConfig(),i=(null===(t=null==n?void 0:n.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=i.version)&&void 0!==e||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var t;const e=yield this.getConfig(),n="projectConfig"in e?null===(t=e.projectConfig)||void 0===t?void 0:t.componentsVersion:{};return n||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=t.init)||void 0===e?void 0:e.call(this),i(this,or,"f").subscribe(i(this,tr,"m",br).bind(this)),i(this,or,"f").update({isDebug:this.debug}),i(this,tr,"m",dr).call(this),yield i(this,tr,"m",fr).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");i(this,tr,"m",yr).call(this);const{executionId:r,stepId:s,token:a,code:l,exchangeError:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p,ssoQueryParams:f}=Vi(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,ar,"f").popstate),window.addEventListener("components-context",i(this,ar,"f").componentsContext),i(this,ir,"f").subscribe(i(this,tr,"m",pr).bind(this)),i(this,ir,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:a,code:l,exchangeError:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p},f)),o(this,nr,!0,"f")}))}disconnectedCallback(){i(this,ir,"f").unsubscribeAll(),i(this,or,"f").unsubscribeAll(),i(this,tr,"m",mr).call(this),window.removeEventListener("popstate",i(this,ar,"f").popstate),window.removeEventListener("components-context",i(this,ar,"f").componentsContext)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&i(this,nr,"f")&&e!==n&&er.observedAttributes.includes(t)){i(this,tr,"m",dr).call(this);const o=null===e;i(this,ir,"f").update((({stepId:e,executionId:i})=>{let r=e,s=i;return o||(s=null,r=null,Fi()),{[Bi(t)]:n,stepId:r,executionId:s}})),i(this,or,"f").update({isDebug:this.debug})}}}function Sr(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var Cr,xr,jr,Or,Ar,Ur,Er,Rr,Lr,Tr,_r,$r,Pr,Mr,Dr,Nr,Wr,qr,Fr,Br,Vr,Kr,Hr,Gr,Jr,zr,Xr,Qr,Zr,Yr,ts,es,ns,is,os,rs;er=Ir,nr=new WeakMap,ir=new WeakMap,or=new WeakMap,rr=new WeakMap,sr=new WeakMap,ar=new WeakMap,lr=new WeakMap,tr=new WeakSet,cr=function(){this.shadowRoot.appendChild(Yo.content.cloneNode(!0)),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},dr=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];er.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[Bi(e)])throw Error(`${e} cannot be empty`)}))},ur=function(){const{stepId:t,executionId:e}=qi(this.flowId);i(this,ir,"f").update({stepId:t,executionId:e})},hr=function(t,e){this.sdk=ri(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},er.sdkConfigOverrides),{projectId:t,baseUrl:e})),["start","next"].forEach((t=>{const e=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>n(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield e(...t)}catch(t){return{error:{errorCode:ai,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},pr=function(t,e,o){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n}=t;if(o("projectId")||o("baseUrl")){if(!e)return;i(this,tr,"m",hr).call(this,e,n)}i(this,lr,"f").call(this,t)}))},fr=function(){return n(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"isMissingConfig"in t&&t.isMissingConfig&&(yield i(this,tr,"m",gr).call(this))}))},gr=function(){return n(this,void 0,void 0,(function*(){const t=function({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(li||i||"https://static.descope.com/pages");return o.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(o.pathname,t,n,e),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(t,e){return n(this,void 0,void 0,(function*(){const n=yield fetch(t,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${t} [${n.status}]`);return{body:yield n[e](),headers:Object.fromEntries(n.headers.entries())}}))}(t,"json"),!0}catch(t){return!1}}))},vr=function(t){o(this,rr,Object.assign(Object.assign({},i(this,rr,"f")),t.detail),"f")},mr=function(){var t;null===(t=i(this,sr,"f"))||void 0===t||t.remove(),o(this,sr,null,"f")},br=function(t){return n(this,arguments,void 0,(function*({isDebug:t}){t?(o(this,sr,document.createElement("descope-debugger"),"f"),Object.assign(i(this,sr,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return cs})),document.body.appendChild(i(this,sr,"f"))):i(this,tr,"m",mr).call(this)}))},wr=function(t,e){var n;t&&this.debug&&(null===(n=i(this,sr,"f"))||void 0===n||n.updateData({title:t,description:e}))},yr=function(){this.rootElement.onkeydown=t=>{var e,n,i;const o=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),r=_i.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==t.key||o||r)return;t.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(s).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},Ir.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.34.1"}};class ss extends Ir{static set sdkConfigOverrides(t){Ir.sdkConfigOverrides=t}static get sdkConfigOverrides(){return Ir.sdkConfigOverrides}constructor(){const t=new oo({deferredRedirect:!1});super(t.update.bind(t)),Cr.add(this),this.stepState=new oo({},{forceUpdate:!0}),xr.set(this,void 0),jr.set(this,null),Or.set(this,{visibilitychange:i(this,Cr,"m",Ar).bind(this)}),this.bridgeVersion=1,this.nativeResume=(t,e)=>{var n;const o=JSON.parse(e);if(this.logger.info(`nativeResume received payload of type '${t}'`),"oauthWeb"===t||"sso"===t){let{exchangeCode:t}=o;if(!t){t=null===(n=new URL(o.url).searchParams)||void 0===n?void 0:n.get(ui)}this.nativeComplete({exchangeCode:t,idpInitiated:!0})}else if("magicLink"===t){const t=new URL(o.url),e=t.searchParams.get("t"),n=t.searchParams.get(di).split("_").pop();i(this,Tr,"f").call(this),this.flowState.update({token:e,stepId:n,action:void 0})}else this.nativeComplete(o)},Rr.set(this,(t=>{this.contentRootElement.classList.toggle("hidden",t),this.slotElement.classList.toggle("hidden",!t)})),Lr.set(this,((t,e,r,s,a=!1)=>{if(this.flowState.current.action===Oi){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),c=a?500:2e3;o(this,xr,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const o=this.sdk.flow.next(t,e,Ti,r,s,{}),d=document.hidden&&!a&&Date.now()-l>c+500;let u;d&&this.logger.debug("polling - The polling seems to be throttled");try{const t=d?1e3:6e3;u=yield Hi(t,o)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,Lr,"f").call(this,t,e,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===ai)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,Lr,"f").call(this,t,e,r,s);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),i(this,_r,"f").call(this,u),i(this,Lr,"f").call(this,t,e,r,s)}))),c),"f")}})),Tr.set(this,(()=>{clearTimeout(i(this,xr,"f")),o(this,xr,null,"f")})),_r.set(this,(t=>{var e,n,o,r,s,a,l,c,d,u,h,p;if(!(null==t?void 0:t.ok)){const l=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,c=`${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.status} - ${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.statusText}`;i(this,Cr,"m",zr).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:c,errorMessage:l}),this.loggerWrapper.error((null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorDescription)||l,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||c);const d=null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorCode;return void("E102004"!==d&&"E103205"!==d||!this.isRestartOnError||i(this,Cr,"m",Ur).call(this))}null===(c=null===(l=t.data)||void 0===l?void 0:l.runnerLogs)||void 0===c||c.forEach((t=>{const{level:e,title:n,log:i}=t;e&&this.loggerWrapper[e]?this.loggerWrapper[e](n,i):this.loggerWrapper.info(n,i)}));const f=null===(h=null===(u=null===(d=t.data)||void 0===d?void 0:d.screen)||void 0===u?void 0:u.state)||void 0===h?void 0:h.errorText;(null===(p=t.data)||void 0===p?void 0:p.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${f?`${f} - `:""}${t.data.error.message}`):f&&this.loggerWrapper.error(f);const{status:g,authInfo:v,lastAuth:m}=t.data;if("completed"===g)return this.storeLastAuthenticatedUser&&function(t){(null==t?void 0:t.authMethod)&&si&&localStorage.setItem(pi,JSON.stringify(t))}(m),void i(this,Cr,"m",zr).call(this,"success",v);const{executionId:b,stepId:w,stepName:y,action:k,screen:I,redirect:S,openInNewTabUrl:C,webauthn:x,error:j,samlIdpResponse:O,nativeResponse:A}=t.data;k!==Oi?(this.loggerWrapper.info(`Step "${y||`#${w}`}" is ${g}`,"",{screen:I,status:g,stepId:w,stepName:y,action:k,error:j}),this.flowState.update({stepId:w,stepName:y,executionId:b,action:k,redirectTo:null==S?void 0:S.url,openInNewTabUrl:C,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==x?void 0:x.transactionId,webauthnOptions:null==x?void 0:x.options,samlIdpResponseUrl:null==O?void 0:O.url,samlIdpResponseSamlResponse:null==O?void 0:O.samlResponse,samlIdpResponseRelayState:null==O?void 0:O.relayState,nativeResponseType:null==A?void 0:A.type,nativePayload:null==A?void 0:A.payload})):this.flowState.update({action:k})})),$r.set(this,Ki((()=>n(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.loggerWrapper.warn("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.loggerWrapper.warn("Webauthn start failed",t.message)}}))))),Kr.set(this,Xi(((t,e)=>n(this,void 0,void 0,(function*(){var n,o;if("true"===t.getAttribute("formnovalidate")||i(this,Cr,"m",Nr).call(this)){const r=null==t?void 0:t.getAttribute("id");i(this,Cr,"m",qr).call(this,t);const s=yield i(this,Cr,"m",Wr).call(this),a=(o=t,Array.from((null==o?void 0:o.attributes)||[]).reduce(((t,e)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return i?Object.assign(t,{[i]:e.value}):t}),{})),l=this.getComponentsContext(),c=Object.assign(Object.assign(Object.assign(Object.assign({},l),a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});e(r,c),i(this,Cr,"m",Fr).call(this,s)}}))))),this.flowState=t}loadSdkScripts(){return n(this,void 0,void 0,(function*(){const t=(yield this.getFlowConfig()).sdkScripts;null==t||t.forEach((t=>n(this,void 0,void 0,(function*(){(yield function(t){return n(this,void 0,void 0,(function*(){let e;switch(t){case"forter":return e=yield Promise.resolve().then((function(){return us})),e.default;case"fingerprint":return e=yield Promise.resolve().then((function(){return ps})),e.default;case"fingerprintDescope":return e=yield Promise.resolve().then((function(){return gs})),e.default;default:throw new Error(`Unknown script id: ${t}`)}}))}(t.id))(t.initArgs,{baseUrl:this.baseUrl},(e=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Sr(t.id,t.resultKey)]:e},bubbles:!0,composed:!0}))}))}))))}))}init(){if(!window.isDescopeBridge)return this._init();this.lazyInit=this._init}_init(){const t=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var e,n,o;this.shadowRoot.isConnected&&(null===(e=this.flowState)||void 0===e||e.subscribe(this.onFlowChange.bind(this)),null===(n=this.stepState)||void 0===n||n.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",i(this,Or,"f").visibilitychange)),yield null===(o=t.init)||void 0===o?void 0:o.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=i(this,jr,"f"))||void 0===t||t.abort(),o(this,jr,null,"f"),window.removeEventListener("visibilitychange",i(this,Or,"f").visibilitychange)}getHtmlFilenameWithLocale(t,e){return n(this,void 0,void 0,(function*(){let n;const i=Qi(t),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${e}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${e}-${i.fallback}.html`),n}))}getPageContent(t,e){return n(this,void 0,void 0,(function*(){if(e)try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${e}. Fallback to url ${t}`,n)}try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(t){this.loggerWrapper.error("Failed to fetch flow page",t.message)}return null}))}onFlowChange(t,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:v,redirectTo:m,openInNewTabUrl:b,redirectUrl:w,token:y,code:k,exchangeError:I,webauthnTransactionId:S,webauthnOptions:C,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:O,redirectAuthInitiator:A,locale:U,samlIdpResponseUrl:E,samlIdpResponseSamlResponse:R,samlIdpResponseRelayState:L,nativeResponseType:T,nativePayload:_}=t,$=e(t,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload"]);let P,M,D;const N=(()=>{const t=localStorage.getItem(bo);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(bo,t.toString()),t}return Number(t)})(),W=this.sdk.getLastUserLoginId(),q=yield this.getFlowConfig(),F=yield this.getProjectConfig(),B=Object.entries(F.flows||{}).reduce(((t,[e,n])=>(t[e]=n.version,t)),{}),V=j&&x?{callbackUrl:j,codeChallenge:x,backupCallbackUri:O}:void 0,K=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;if(!p&&(this.loadSdkScripts(),q.fingerprintEnabled&&q.fingerprintKey?yield Dn(q.fingerprintKey,this.baseUrl):localStorage.removeItem(Pn),q.conditions?({startScreenId:P,conditionInteractionId:D,startScreenName:M}=((t,e)=>{const n=null==e?void 0:e.find((({key:e,operator:n,predicate:i})=>{var o;if("ELSE"===e)return!0;const r=null===(o=wo[e])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(t,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId}:{}})({loginId:W,code:k,token:y,abTestingKey:N},q.conditions)):q.condition?({startScreenId:P,conditionInteractionId:D}=((t,e)=>{var n;const i=null===(n=wo[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!i)return{};const o=i(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(q.condition,{loginId:W,code:k,token:y,abTestingKey:N})):(M=q.startScreenName,P=q.startScreenId),!Gi(P,$))){const t=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:V},$),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:yo(W),abTestingKey:N,locale:Qi(U).locale,nativeOptions:K}),D,"",F.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),$.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),$.oidcLoginHint?{externalId:$.oidcLoginHint}:{}));return i(this,_r,"f").call(this,t),void("completed"!==(null===(a=null==t?void 0:t.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&I)){const t=yield this.sdk.flow.next(p,h,Li,q.version,F.componentsVersion,{token:y,exchangeCode:k,exchangeError:I});return i(this,_r,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===Ri&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>s(t)))){if(!E||!R)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=t,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),i(o)})(E,R,L||"",Ji)}if(f===ji&&(s("redirectTo")||s("deferredRedirect")))return m?"android"===A&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(m):void this.loggerWrapper.error("Did not get redirect url");if(f===Ai||f===Ui){if(!S||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,e;null===(l=i(this,jr,"f"))||void 0===l||l.abort(),o(this,jr,null,"f");try{t=f===Ai?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}catch(t){"InvalidStateError"===t.name?this.loggerWrapper.warn("WebAuthn operation failed",t.message):"NotAllowedError"!==t.name&&this.loggerWrapper.error(t.message),e=t.name}const n=yield this.sdk.flow.next(p,h,Li,q.version,F.componentsVersion,{transactionId:S,response:t,failure:e});i(this,_r,"f").call(this,n)}if(f===Ei)return this.nativeComplete=t=>n(this,void 0,void 0,(function*(){const e=yield this.sdk.flow.next(p,h,Li,q.version,F.componentsVersion,t);i(this,_r,"f").call(this,e)})),void i(this,Cr,"m",zr).call(this,"bridge",{type:T,payload:_});if(i(this,Lr,"f").call(this,p,h,q.version,F.componentsVersion),!g&&!P)return void this.loggerWrapper.warn("No screen was found to show");const H=P||g,G=yield this.getHtmlFilenameWithLocale(U,H),{oidcLoginHint:J,oidcPrompt:z,oidcErrorRedirectUri:X,samlIdpUsername:Q}=$,Z={direction:Wi(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:W,name:this.sdk.getLastUserDisplayName()||W}}),htmlFilename:`${H}.html`,htmlLocaleFilename:G,screenId:H,stepName:t.stepName||M,samlIdpUsername:Q,oidcLoginHint:J,oidcPrompt:z,oidcErrorRedirectUri:X,openInNewTabUrl:b},Y=yo(W);Gi(P,$)?Z.next=(t,e)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:V},$),{lastAuth:Y,preview:this.preview,abTestingKey:N,client:this.client}),w&&{redirectUrl:w}),{locale:Qi(U).locale,nativeOptions:K}),D,t,F.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),e),k&&{exchangeCode:k,idpInitiated:!0}),$.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}));return i(this,_r,"f").call(this,n),n})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(Z.next=(t,e)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.next(p,h,t,q.version,F.componentsVersion,e);return i(this,_r,"f").call(this,n),n}))),this.loggerWrapper.debug("Going to render screen with id",Z.screenId),yield i(this,Cr,"m",Er).call(this,Z),this.stepState.update(Z)}))}onStepChange(t,e){return n(this,void 0,void 0,(function*(){var o,r;const{htmlFilename:s,htmlLocaleFilename:a,direction:l,next:c,screenState:d,openInNewTabUrl:u}=t;this.loggerWrapper.debug("Rendering a flow screen");const h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield i(this,Cr,"m",Mr).call(this,p,c):p.querySelectorAll(`descope-button[${xi}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!t.samlIdpUsername||(null===(o=d.form)||void 0===o?void 0:o.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=t.samlIdpUsername,d.form.email=t.samlIdpUsername),go(p,d,d.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((t,e)=>{Array.from(t.querySelectorAll('[default-code="autoDetect"]')).forEach((t=>{t.setAttribute("default-code",e)}))})(p,g);const v=()=>n(this,void 0,void 0,(function*(){var n,o;yield f;const r=this.contentRootElement;var s,a;s=r,a=null===(n=null==d?void 0:d.totp)||void 0===n?void 0:n.image,fo(s,"descope-totp-image",a),((t,e)=>{fo(t,"descope-notp-image",e)})(r,null===(o=null==d?void 0:d.notp)||void 0===o?void 0:o.image),((t,e,n,i)=>{n&&Object.keys(n).forEach((o=>{e.querySelector(o)||i.debug(`Skipping css vars for component "${o}}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((e=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[e];if(!l)return void i.info(`Could not find css variable name for ${e} in ${o}`,"Check if the css variable is defined in the component");const c=a[e];t.style.setProperty(l,c)})):i.info(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,p,d.cssVars,this.loggerWrapper),r.replaceChildren(p);const l=!e.htmlFilename;setTimeout((()=>{i(this,Cr,"m",Br).call(this),this.validateOnBlur&&(t=>{t.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))}))}))})(r),((t,e)=>{lo(t,null==e?void 0:e.inputs),lo(t,null==e?void 0:e.form)})(r,d),i(this,Cr,"m",Dr).call(this,{isFirstScreen:l,stepName:t.stepName}),((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}})(r,this.autoFocus,l)})),i(this,Cr,"m",Gr).call(this,c);r.querySelector(`[${xi}="polling"]`)&&c(Ti,{}),u&&!e.openInNewTabUrl&&window.open(u,"_blank")}));l?i(this,Cr,"m",Jr).call(this,v,l):v()}))}}xr=new WeakMap,jr=new WeakMap,Or=new WeakMap,Rr=new WeakMap,Lr=new WeakMap,Tr=new WeakMap,_r=new WeakMap,$r=new WeakMap,Kr=new WeakMap,Cr=new WeakSet,Ar=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Ur=function(){return n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const t=yield this.getComponentsVersion();this.reset();t===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},Er=function(t){return n(this,void 0,void 0,(function*(){var n;const o=Object.assign(Object.assign({},this.stepState.current),t),{next:r,stepName:s}=o,a=e(o,["next","stepName"]),l=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,s,Zi(a),r,this));if(l){this.loggerWrapper.debug("Rendering a custom screen"),this.contentRootElement.innerHTML="",i(this,Cr,"m",Dr).call(this,{isFirstScreen:!this.stepState.current.htmlFilename,stepName:t.stepName}),this.stepState.unsubscribeAll();const e=this.stepState.subscribe((()=>{var t;this.stepState.unsubscribe(e),null===(t=this.stepState)||void 0===t||t.subscribe(this.onStepChange.bind(this))}))}i(this,Rr,"f").call(this,l),this.flowState.forceUpdate=l}))},Pr=function(t){const e=t.getAttribute("name");if(!["email"].includes(e)){const n=`user-${e}`;t.setAttribute("name",n),t.addEventListener("input",(()=>{t.setAttribute("name",t.value?e:n)}))}},Mr=function(t,e){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,jr,"f"))||void 0===r||r.abort();const s=t.querySelector('*[autocomplete="webauthn"]');if(s&&(yield vo())){const{options:t,transactionId:r}=(yield i(this,$r,"f").call(this))||{};t&&r&&(i(this,Cr,"m",Pr).call(this,s),o(this,jr,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,i(this,jr,"f")).then((t=>n(this,void 0,void 0,(function*(){e(s.id,{transactionId:r,response:t})})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)})))}}))},Dr=function({isFirstScreen:t,stepName:e}){t&&i(this,Cr,"m",zr).call(this,"ready",{}),i(this,Cr,"m",zr).call(this,"page-updated",{screenName:e}),i(this,Cr,"m",zr).call(this,"screen-updated",{screenName:e})},Nr=function(){let t=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e=>{var n,i;"slot"!==e.localName&&(null===(n=e.reportValidity)||void 0===n||n.call(e),t&&(t=null===(i=e.checkValidity)||void 0===i?void 0:i.call(e)))})),t},Wr=function(){return n(this,void 0,void 0,(function*(){const t=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${hi}])`));return(yield Promise.all(t.map((t=>n(this,void 0,void 0,(function*(){return{name:t.getAttribute("name"),value:t.value}})))))).reduce(((t,e)=>Object.assign(Object.assign({},t),{[e.name]:e.value})),{})}))},qr=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},Fr=function(t={}){var e,n;const i=zi(t,["externalId","email","phone"]),o=zi(t,["newPassword","password"]);if(i&&o)try{if(!globalThis.PasswordCredential)return;const t=new globalThis.PasswordCredential({id:i,password:o});null===(n=null===(e=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===e?void 0:e.store)||void 0===n||n.call(e,t)}catch(t){this.loggerWrapper.error("Could not store credentials",t.message)}},Br=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((t=>t.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((t=>i(this,Cr,"m",Vr).call(this,t)))},Vr=function(t){if(!t)return;t.querySelectorAll("input").forEach((e=>{const n=e.getAttribute("slot"),i=`input-${t.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),t.appendChild(o),e.setAttribute("slot",i),this.appendChild(e)}))},Hr=function(t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.addEventListener("input",(()=>{var n;(null===(n=e.checkValidity)||void 0===n?void 0:n.call(e))&&i(this,Kr,"f").call(this,e,t)}))}))},Gr=function(t){this.contentRootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((e=>{e.onclick=()=>{i(this,Kr,"f").call(this,e,t)}})),i(this,Cr,"m",Hr).call(this,t)},Jr=function(t,e){this.contentRootElement.addEventListener("transitionend",(()=>{this.contentRootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===Pi.forward?"slide-forward":"slide-backward";Array.from(this.contentRootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),this.contentRootElement.classList.add("fade-out")},zr=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",ss);const as=document.createElement("template");as.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class ls extends HTMLElement{constructor(){super(),Xr.add(this),Qr.set(this,new oo({messages:[]})),Zr.set(this,void 0),Yr.set(this,void 0),ts.set(this,void 0),es.set(this,{resize:i(this,Xr,"m",rs).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(as.content.cloneNode(!0)),o(this,Zr,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Yr,i(this,Zr,"f").querySelector(".content"),"f"),o(this,ts,i(this,Zr,"f").querySelector(".header"),"f")}updateData(t){i(this,Qr,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((t,e,n)=>{let i=0,o=0,r=0,s=0;function a(e){e.preventDefault(),i=r-e.clientX,o=s-e.clientY,r=e.clientX,s=e.clientY;const[a,l]=mo(t,t.offsetLeft-i,t.offsetTop-o,n);t.style.top=`${l}px`,t.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(t){t.preventDefault(),r=t.clientX,s=t.clientY,document.onmouseup=l,document.onmousemove=a}e?e.onmousedown=c:t.onmousedown=c})(i(this,Zr,"f"),i(this,ts,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,es,"f").resize),(t=i(this,Zr,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&t.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},i(this,Zr,"f").onresize=i(this,Xr,"m",os).bind(this),i(this,Qr,"f").subscribe(i(this,Xr,"m",ns).bind(this))}disconnectedCallback(){i(this,Qr,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,es,"f").resize)}}Qr=new WeakMap,Zr=new WeakMap,Yr=new WeakMap,ts=new WeakMap,es=new WeakMap,Xr=new WeakSet,ns=function(t){i(this,Xr,"m",is).call(this,t),i(this,Xr,"m",os).call(this)},is=function(t){i(this,Yr,"f").innerHTML=t.messages.map((t=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${t.title}\n </div>\n <div class="msg_desc">\n ${t.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},os=function(){i(this,Yr,"f").querySelectorAll(".msg").forEach((t=>{const e=t.querySelector(".msg_desc"),n=e.scrollWidth>e.clientWidth,i=e.clientHeight>20;n||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},rs=function(){const[t,e]=mo(i(this,Zr,"f"),Number.parseInt(i(this,Zr,"f").style.left,10),Number.parseInt(i(this,Zr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Zr,"f").style.top=`${e}px`,i(this,Zr,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",ls);var cs=Object.freeze({__proto__:null,default:ls});const ds='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n';var us=Object.freeze({__proto__:null,default:(t,e,i)=>n(void 0,void 0,void 0,(function*(){const{siteId:e}=t,n=ds.replace(/{{SITE_ID}}/g,e),o=document.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("id",e),o.text=n,document.body.appendChild(o),document.addEventListener("ftr:tokenReady",(t=>{i(t.detail)}))}))});const hs=(t,e,i)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:e,useCloudflareIntegration:n,cloudflareScriptUrl:o,cloudflareEndpointUrl:r}=t;let s=[];s=n&&r?[r,an]:[an];let a=[];if(n&&o){const t=new URL(o);a=[`${t.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,fn]}else a=[fn];const l=gn({apiKey:e,endpoint:s,scriptUrlPattern:a}),c=yield l,{requestId:d}=yield c.get();i(d)}catch(t){console.warn("Could not load fingerprint",t)}}));var ps=Object.freeze({__proto__:null,default:hs,loadFingerprint:hs});const fs=(t,e,i)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:o,cloudflareEndpointPath:r,cloudflareScriptPath:s}=t,{baseUrl:a}=e;let l;l=n?`https://${n}`:a||"https://api.descope.com";const c=new URL(l);c.pathname=r;const d=new URL(l);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=gn({apiKey:o,endpoint:[c.toString(),an],scriptUrlPattern:[u,fn]}),p=yield h,{requestId:f}=yield p.get();i(f)}catch(t){console.warn("Could not load descope fingerprint",t)}}));var gs=Object.freeze({__proto__:null,default:fs,loadFingerprint:fs})}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descope/web-component",
|
|
3
|
-
"version": "3.34.
|
|
3
|
+
"version": "3.34.1",
|
|
4
4
|
"author": "Descope Team <info@descope.com>",
|
|
5
5
|
"homepage": "https://github.com/descope/descope-js",
|
|
6
6
|
"bugs": {
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"tslib": "2.8.1",
|
|
69
69
|
"@fingerprintjs/fingerprintjs-pro": "3.11.6",
|
|
70
70
|
"@descope/sdk-helpers": "0.2.0",
|
|
71
|
-
"@descope/web-js-sdk": "1.23.10",
|
|
72
71
|
"@descope/sdk-mixins": "0.8.0",
|
|
73
|
-
"@descope/escape-markdown": "0.1.5"
|
|
72
|
+
"@descope/escape-markdown": "0.1.5",
|
|
73
|
+
"@descope/web-js-sdk": "1.24.0"
|
|
74
74
|
},
|
|
75
75
|
"overrides": {
|
|
76
76
|
"terser": "5.37.0"
|