@descope/web-component 3.32.10 → 3.33.0

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 +1 @@
1
- "use strict";var t=require("tslib"),e=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins/static-resources-mixin"),r=require("@descope/sdk-mixins/theme-mixin"),s=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,u,d,c,h,g,f,v,p,_,b,m,w,C,F,A,P,x,k,E,I,y=require("../helpers/flowInputs.js"),G=require("../mixins/formMountMixin.js"),j=require("./initTemplate.js"),L=require("../constants/content.js"),S=require("../constants/general.js");function U(t){return Object.freeze({__proto__:null,default:t})}const M=e.compose(r.themeMixin,i.staticResourcesMixin,G.formMountMixin)(HTMLElement);class O extends M{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),d.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=n.withMemCache((()=>t.__awaiter(this,void 0,void 0,(function*(){try{const{body:t,headers:e}=yield this.fetchStaticResource(L.CONFIG_FILENAME,"json");return{projectConfig:t,executionContext:{geo:e["x-geo"]}}}catch(t){return{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 y.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return y.extractNestedAttribute(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t.__awaiter(this,void 0,void 0,(function*(){const{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return t.__awaiter(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();return t}))}getFlowConfig(){return t.__awaiter(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 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,e;const i=null===(e=null===(t=yield this.getConfig())||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.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");if((yield this.getConfig()).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:s,token:o,code:a,exchangeError:u,redirectAuthCallbackUrl:g,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:p,redirectAuthInitiator:_,ssoQueryParams:m}=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:s,executionId:r,token:o,code:a,exchangeError:u,redirectAuthCallbackUrl:g,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:p,redirectAuthInitiator:_},m)),t.__classPrivateFieldSet(this,d,!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,r){if(this.shadowRoot.isConnected&&t.__classPrivateFieldGet(this,d,"f")&&i!==r&&u.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,l,"m",b).call(this);const s=null===i;t.__classPrivateFieldGet(this,c,"f").update((({stepId:t,executionId:i})=>{let o=t,a=i;return s||(a=null,o=null,n.clearRunIdsFromUrl()),{[n.camelCase(e)]:r,stepId:o,executionId:a}})),t.__classPrivateFieldGet(this,h,"f").update({isDebug:this.debug})}}}u=O,d=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.rootElement=this.shadowRoot.querySelector("#root")},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"];u.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=s(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},u.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:S.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},C=function(e,i,r){return t.__awaiter(this,void 0,void 0,(function*(){const{projectId:i,baseUrl:s}=e;if(r("projectId")||r("baseUrl")){if(!i)return;t.__classPrivateFieldGet(this,l,"m",w).call(this,i,s)}t.__classPrivateFieldGet(this,p,"f").call(this,e)}))},F=function(){return t.__awaiter(this,void 0,void 0,(function*(){return(yield this.getConfig()).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 U(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 r;e&&this.debug&&(null===(r=t.__classPrivateFieldGet(this,f,"f"))||void 0===r||r.updateData({title:e,description:i}))},I=function(){this.rootElement.onkeydown=t=>{var e,i,r;const s=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),n=o.ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||s||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 u=Array.from(a).filter((t=>"button"===t.getAttribute("data-type")));if(1===u.length)"false"!==u[0].getAttribute("auto-submit")&&u[0].click();else if(0===u.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.32.10"}},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,u,d,c,h,g,f,v,p,_,b,m,w,C,F,A,P,x,k,E,I,y=require("../helpers/flowInputs.js"),G=require("../mixins/formMountMixin.js"),j=require("./initTemplate.js"),L=require("../constants/content.js"),S=require("../constants/general.js");function U(t){return Object.freeze({__proto__:null,default:t})}const M=e.compose(s.themeMixin,i.staticResourcesMixin,G.formMountMixin)(HTMLElement);class q extends M{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),d.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 y.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return y.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:u,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:u,exchangeError:g,redirectAuthCallbackUrl:f,redirectAuthBackupCallbackUri:p,redirectAuthCodeChallenge:_,redirectAuthInitiator:m},w)),t.__classPrivateFieldSet(this,d,!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,d,"f")&&i!==s&&u.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})}}}u=q,d=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.rootElement=this.shadowRoot.querySelector("#root")},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"];u.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},u.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:S.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 U(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 u=Array.from(a).filter((t=>"button"===t.getAttribute("data-type")));if(1===u.length)"false"!==u[0].getAttribute("auto-submit")&&u[0].click();else if(0===u.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()}}},q.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.33.0"}},module.exports=q;
@@ -1 +1 @@
1
- "use strict";var e,t,i,s,o,r,n,a,l,d,c,h,u,p,g,v,m,f,_,b,w,S,I,E=require("tslib"),C=require("@descope/web-js-sdk"),y=require("../constants/index.js"),O=require("../helpers/helpers.js"),P=require("../helpers/state.js"),R=require("../helpers/templates.js"),T=require("../helpers/webauthn.js"),F=require("../helpers/abTestingKey.js"),A=require("../helpers/conditions.js"),k=require("../helpers/lastAuth.js"),N=require("../types.js"),U=require("./BaseDescopeWc.js"),j=require("./sdkScripts/index.js"),x=require("../constants/general.js");t=new WeakMap,i=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,d=new WeakMap,_=new WeakMap,e=new WeakSet,o=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},r=function(){return E.__awaiter(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.getConfig.reset();e===(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")}))},c=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},h=function(t,s){return E.__awaiter(this,void 0,void 0,(function*(){var o;null===(o=E.__classPrivateFieldGet(this,i,"f"))||void 0===o||o.abort();const r=t.querySelector('*[autocomplete="webauthn"]');if(r&&(yield T.isConditionalLoginSupported())){const{options:t,transactionId:o}=(yield E.__classPrivateFieldGet(this,d,"f").call(this))||{};if(t&&o){E.__classPrivateFieldGet(this,e,"m",c).call(this,r),E.__classPrivateFieldSet(this,i,new AbortController,"f");const n=yield this.getFlowConfig(),a=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,E.__classPrivateFieldGet(this,i,"f")).then((e=>E.__awaiter(this,void 0,void 0,(function*(){const t=yield s(r.id,n.version,a.componentsVersion,{transactionId:o,response:e});E.__classPrivateFieldGet(this,l,"f").call(this,t)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},u=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,s;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(s=t.checkValidity)||void 0===s?void 0:s.call(t)))})),e},p=function(){return E.__awaiter(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${y.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`));return(yield Promise.all(e.map((e=>E.__awaiter(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},g=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},v=function(e={}){var t,i;const s=O.getFirstNonEmptyValue(e,["externalId","email","phone"]),o=O.getFirstNonEmptyValue(e,["newPassword","password"]);if(s&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:s,password:o});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},m=function(){O.clearPreviousExternalInputs();this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>E.__classPrivateFieldGet(this,e,"m",f).call(this,t)))},f=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),s=`input-${e.id}-${i}`,o=document.createElement("slot");o.setAttribute("name",s),o.setAttribute("slot",i),e.appendChild(o),t.setAttribute("slot",s),this.appendChild(t)}))},b=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var i;(null===(i=t.checkValidity)||void 0===i?void 0:i.call(t))&&E.__classPrivateFieldGet(this,_,"f").call(this,t,e)}))}))},w=function(t){this.rootElement.querySelectorAll(`descope-button:not([${y.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}])`).forEach((e=>{e.onclick=()=>{E.__classPrivateFieldGet(this,_,"f").call(this,e,t)}})),E.__classPrivateFieldGet(this,e,"m",b).call(this,t)},S=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===N.Direction.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(i)})),this.rootElement.classList.add("fade-out")},I=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},module.exports=class extends U{static set sdkConfigOverrides(e){U.sdkConfigOverrides=e}static get sdkConfigOverrides(){return U.sdkConfigOverrides}constructor(){const c=new P({deferredRedirect:!1});super(c.update.bind(c)),e.add(this),this.stepState=new P({},{updateOnlyOnChange:!1}),t.set(this,void 0),i.set(this,null),s.set(this,{visibilitychange:E.__classPrivateFieldGet(this,e,"m",o).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var i;const s=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=s;if(!e){e=null===(i=new URL(s.url).searchParams)||void 0===i?void 0:i.get(y.URL_CODE_PARAM_NAME)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(s.url),t=e.searchParams.get(y.URL_TOKEN_PARAM_NAME),i=e.searchParams.get(y.URL_RUN_IDS_PARAM_NAME).split("_").pop();E.__classPrivateFieldGet(this,a,"f").call(this),this.flowState.update({token:t,stepId:i,action:void 0})}else this.nativeComplete(s)},n.set(this,((e,i,s,o,r=!1)=>{if(this.flowState.current.action===y.RESPONSE_ACTIONS.poll){this.logger.debug("polling - Scheduling polling request");const a=Date.now(),d=r?500:2e3;E.__classPrivateFieldSet(this,t,setTimeout((()=>E.__awaiter(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,i,y.CUSTOM_INTERACTIONS.polling,s,o,{}),h=document.hidden&&!r&&Date.now()-a>d+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield O.timeoutPromise(e,c)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void E.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o,h)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===x.FETCH_EXCEPTION_ERROR_CODE)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void E.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o);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)),E.__classPrivateFieldGet(this,l,"f").call(this,u),E.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o)}))),d),"f")}})),a.set(this,(()=>{clearTimeout(E.__classPrivateFieldGet(this,t,"f")),E.__classPrivateFieldSet(this,t,null,"f")})),l.set(this,(t=>{var i,s,o,n,a,l,d,c,h,u,p,g;if(!(null==t?void 0:t.ok)){const d=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,c=`${null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.status} - ${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.statusText}`;E.__classPrivateFieldGet(this,e,"m",I).call(this,"error",(null==t?void 0:t.error)||{errorCode:x.FETCH_ERROR_RESPONSE_ERROR_CODE,errorDescription:c,errorMessage:d}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||d,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||c);const h=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==h&&"E103205"!==h||!this.isRestartOnError||E.__classPrivateFieldGet(this,e,"m",r).call(this))}null===(c=null===(d=t.data)||void 0===d?void 0:d.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:s}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,s):this.loggerWrapper.info(i,s)}));const v=null===(p=null===(u=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===u?void 0:u.state)||void 0===p?void 0:p.errorText;(null===(g=t.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${v?`${v} - `:""}${t.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:f,lastAuth:_}=t.data;if("completed"===m)return this.storeLastAuthenticatedUser&&k.setLastAuth(_),void E.__classPrivateFieldGet(this,e,"m",I).call(this,"success",f);const{executionId:b,stepId:w,stepName:S,action:C,screen:O,redirect:P,openInNewTabUrl:R,webauthn:T,error:F,samlIdpResponse:A,nativeResponse:N}=t.data;C!==y.RESPONSE_ACTIONS.poll?(this.loggerWrapper.info(`Step "${S||`#${w}`}" is ${m}`,"",{screen:O,status:m,stepId:w,stepName:S,action:C,error:F}),this.flowState.update({stepId:w,executionId:b,action:C,redirectTo:null==P?void 0:P.url,openInNewTabUrl:R,screenId:null==O?void 0:O.id,screenState:null==O?void 0:O.state,webauthnTransactionId:null==T?void 0:T.transactionId,webauthnOptions:null==T?void 0:T.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,nativeResponseType:null==N?void 0:N.type,nativePayload:null==N?void 0:N.payload})):this.flowState.update({action:C})})),d.set(this,O.withMemCache((()=>E.__awaiter(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),_.set(this,O.leadingDebounce(((t,i)=>E.__awaiter(this,void 0,void 0,(function*(){var s;if("true"===t.getAttribute("formnovalidate")||E.__classPrivateFieldGet(this,e,"m",u).call(this)){const o=null==t?void 0:t.getAttribute("id");E.__classPrivateFieldGet(this,e,"m",g).call(this,t);const r=yield E.__classPrivateFieldGet(this,e,"m",p).call(this),n=O.getElementDescopeAttributes(t),a=this.getComponentsContext(),d=Object.assign(Object.assign(Object.assign(Object.assign({},a),n),r),{origin:(null===(s=this.nativeOptions)||void 0===s?void 0:s.origin)||window.location.origin}),c=yield this.getFlowConfig(),h=yield this.getProjectConfig(),u=yield i(o,c.version,h.componentsVersion,d);E.__classPrivateFieldGet(this,l,"f").call(this,u),E.__classPrivateFieldGet(this,e,"m",v).call(this,r)}}))))),this.flowState=c}loadSdkScripts(){return E.__awaiter(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>E.__awaiter(this,void 0,void 0,(function*(){(yield j.default(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[j.getScriptResultPath(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return E.__awaiter(this,void 0,void 0,(function*(){var t,i,o;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(i=this.stepState)||void 0===i||i.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",E.__classPrivateFieldGet(this,s,"f").visibilitychange)),yield null===(o=e.init)||void 0===o?void 0:o.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=E.__classPrivateFieldGet(this,i,"f"))||void 0===e||e.abort(),E.__classPrivateFieldSet(this,i,null,"f"),window.removeEventListener("visibilitychange",E.__classPrivateFieldGet(this,s,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return E.__awaiter(this,void 0,void 0,(function*(){let i;const s=O.getUserLocale(e),o=yield this.getTargetLocales();return o.includes(s.locale)?i=`${t}-${s.locale}.html`:o.includes(s.fallback)&&(i=`${t}-${s.fallback}.html`),i}))}getPageContent(e,t){return E.__awaiter(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(t,s,o){return E.__awaiter(this,void 0,void 0,(function*(){var r,a;const{projectId:d,flowId:c,tenant:h,stepId:u,executionId:p,action:g,screenId:v,screenState:m,redirectTo:f,openInNewTabUrl:_,redirectUrl:b,token:w,code:S,exchangeError:P,webauthnTransactionId:R,webauthnOptions:T,redirectAuthCodeChallenge:N,redirectAuthCallbackUrl:U,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:x,locale:G,samlIdpResponseUrl:L,samlIdpResponseSamlResponse:W,samlIdpResponseRelayState:q,nativeResponseType:D,nativePayload:M}=t,$=E.__rest(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 V,B;const K=F.getABTestingKey(),H=this.sdk.getLastUserLoginId(),X=yield this.getFlowConfig(),J=yield this.getProjectConfig(),Y=Object.entries(J.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),z=U&&N?{callbackUrl:U,codeChallenge:N,backupCallbackUri:j}:void 0,Q=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(),X.fingerprintEnabled&&X.fingerprintKey?yield C.ensureFingerprintIds(X.fingerprintKey,this.baseUrl):C.clearFingerprintData(),X.conditions?({startScreenId:V,conditionInteractionId:B}=A.calculateConditions({loginId:H,code:S,token:w,abTestingKey:K},X.conditions)):X.condition?({startScreenId:V,conditionInteractionId:B}=A.calculateCondition(X.condition,{loginId:H,code:S,token:w,abTestingKey:K})):V=X.startScreenId,!O.showFirstScreenOnExecutionInit(V,$))){const e=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},$),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:k.getLastAuth(H),abTestingKey:K,locale:O.getUserLocale(G).locale,nativeOptions:Q}),B,"",J.componentsVersion,Y,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),S?{exchangeCode:S,idpInitiated:!0}:{}),$.descopeIdpInitiated&&{idpInitiated:!0}),w?{token:w}:{}),$.oidcLoginHint?{externalId:$.oidcLoginHint}:{}));return E.__classPrivateFieldGet(this,l,"f").call(this,e),void("completed"!==(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.status)&&this.flowState.update({code:void 0,token:void 0}))}if(p&&(o("token")&&w||o("code")&&S||o("exchangeError")&&P)){const e=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,{token:w,exchangeCode:S,exchangeError:P});return E.__classPrivateFieldGet(this,l,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===y.RESPONSE_ACTIONS.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>o(e)))){if(!L||!W)return void this.loggerWrapper.error("Did not get saml idp params data to load");O.injectSamlIdpForm(L,W,q||"",O.submitForm)}if(g===y.RESPONSE_ACTIONS.redirect&&(o("redirectTo")||o("deferredRedirect")))return f?"android"===x&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(f):void this.loggerWrapper.error("Did not get redirect url");if(g===y.RESPONSE_ACTIONS.webauthnCreate||g===y.RESPONSE_ACTIONS.webauthnGet){if(!R||!T)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(a=E.__classPrivateFieldGet(this,i,"f"))||void 0===a||a.abort(),E.__classPrivateFieldSet(this,i,null,"f");try{e=g===y.RESPONSE_ACTIONS.webauthnCreate?yield this.sdk.webauthn.helpers.create(T):yield this.sdk.webauthn.helpers.get(T)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const s=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,{transactionId:R,response:e,failure:t});E.__classPrivateFieldGet(this,l,"f").call(this,s)}if(g===y.RESPONSE_ACTIONS.nativeBridge)return this.nativeComplete=e=>E.__awaiter(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,e);E.__classPrivateFieldGet(this,l,"f").call(this,t)})),void E.__classPrivateFieldGet(this,e,"m",I).call(this,"bridge",{type:D,payload:M});if(E.__classPrivateFieldGet(this,n,"f").call(this,p,u,X.version,J.componentsVersion),!v&&!V)return void this.loggerWrapper.warn("No screen was found to show");const Z=V||v,ee=yield this.getHtmlFilenameWithLocale(G,Z),{oidcLoginHint:te,oidcPrompt:ie,oidcErrorRedirectUri:se,samlIdpUsername:oe}=$,re={direction:O.getAnimationDirection(u,s.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:H,name:this.sdk.getLastUserDisplayName()||H}}),htmlFilename:`${Z}.html`,htmlLocaleFilename:ee,samlIdpUsername:oe,oidcLoginHint:te,oidcPrompt:ie,oidcErrorRedirectUri:se,openInNewTabUrl:_},ne=k.getLastAuth(H);O.showFirstScreenOnExecutionInit(V,$)?re.next=(e,t,i,s)=>this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},$),{lastAuth:ne,preview:this.preview,abTestingKey:K,client:this.client}),b&&{redirectUrl:b}),{locale:O.getUserLocale(G).locale,nativeOptions:Q}),B,e,i,Y,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),s),S&&{exchangeCode:S,idpInitiated:!0}),$.descopeIdpInitiated&&{idpInitiated:!0}),w&&{token:w})):(o("projectId")||o("baseUrl")||o("executionId")||o("stepId"))&&(re.next=(...e)=>this.sdk.flow.next(p,u,...e)),this.stepState.update(re)}))}onStepChange(t,i){return E.__awaiter(this,void 0,void 0,(function*(){var s,o;const{htmlFilename:r,htmlLocaleFilename:n,direction:a,next:d,screenState:c,openInNewTabUrl:u}=t,p=document.createElement("template");p.innerHTML=yield this.getPageContent(r,n);const g=p.content.cloneNode(!0),v=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield E.__classPrivateFieldGet(this,e,"m",h).call(this,g,d):R.disableWebauthnButtons(g),!t.samlIdpUsername||(null===(s=c.form)||void 0===s?void 0:s.loginId)||(null===(o=c.form)||void 0===o?void 0:o.email)||(c.form||(c.form={}),c.form.loginId=t.samlIdpUsername,c.form.email=t.samlIdpUsername),R.updateTemplateFromScreenState(g,c,c.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();R.setPhoneAutoDetectDefaultCode(g,f);const _=()=>E.__awaiter(this,void 0,void 0,(function*(){var t,s;yield v;const o=this.shadowRoot.querySelector("div");R.setTOTPVariable(o,null===(t=null==c?void 0:c.totp)||void 0===t?void 0:t.image),R.setNOTPVariable(o,null===(s=null==c?void 0:c.notp)||void 0===s?void 0:s.image),R.setCssVars(o,g,c.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(g);const r=!i.htmlFilename;setTimeout((()=>{E.__classPrivateFieldGet(this,e,"m",m).call(this),O.handleAutoFocus(this.rootElement,this.autoFocus,r),this.validateOnBlur&&O.handleReportValidityOnBlur(this.rootElement),R.updateScreenFromScreenState(this.rootElement,c)})),E.__classPrivateFieldGet(this,e,"m",w).call(this,d),r&&E.__classPrivateFieldGet(this,e,"m",I).call(this,"ready",{}),E.__classPrivateFieldGet(this,e,"m",I).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${y.ELEMENT_TYPE_ATTRIBUTE}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),i=yield d(y.CUSTOM_INTERACTIONS.polling,e.version,t.componentsVersion,{});E.__classPrivateFieldGet(this,l,"f").call(this,i)}u&&!i.openInNewTabUrl&&window.open(u,"_blank")}));a?E.__classPrivateFieldGet(this,e,"m",S).call(this,_,a):_()}))}};
1
+ "use strict";var e,t,i,s,o,r,n,a,l,d,c,h,u,p,g,v,m,f,_,b,w,S,I,E=require("tslib"),C=require("@descope/web-js-sdk"),y=require("../constants/index.js"),O=require("../helpers/helpers.js"),P=require("../helpers/state.js"),R=require("../helpers/templates.js"),T=require("../helpers/webauthn.js"),F=require("../helpers/abTestingKey.js"),A=require("../helpers/conditions.js"),k=require("../helpers/lastAuth.js"),N=require("../types.js"),U=require("./BaseDescopeWc.js"),j=require("./sdkScripts/index.js"),x=require("../constants/general.js");t=new WeakMap,i=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,l=new WeakMap,d=new WeakMap,_=new WeakMap,e=new WeakSet,o=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},r=function(){return E.__awaiter(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset();e===(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")}))},c=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},h=function(t,s){return E.__awaiter(this,void 0,void 0,(function*(){var o;null===(o=E.__classPrivateFieldGet(this,i,"f"))||void 0===o||o.abort();const r=t.querySelector('*[autocomplete="webauthn"]');if(r&&(yield T.isConditionalLoginSupported())){const{options:t,transactionId:o}=(yield E.__classPrivateFieldGet(this,d,"f").call(this))||{};if(t&&o){E.__classPrivateFieldGet(this,e,"m",c).call(this,r),E.__classPrivateFieldSet(this,i,new AbortController,"f");const n=yield this.getFlowConfig(),a=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,E.__classPrivateFieldGet(this,i,"f")).then((e=>E.__awaiter(this,void 0,void 0,(function*(){const t=yield s(r.id,n.version,a.componentsVersion,{transactionId:o,response:e});E.__classPrivateFieldGet(this,l,"f").call(this,t)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},u=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,s;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(s=t.checkValidity)||void 0===s?void 0:s.call(t)))})),e},p=function(){return E.__awaiter(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${y.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`));return(yield Promise.all(e.map((e=>E.__awaiter(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},g=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},v=function(e={}){var t,i;const s=O.getFirstNonEmptyValue(e,["externalId","email","phone"]),o=O.getFirstNonEmptyValue(e,["newPassword","password"]);if(s&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:s,password:o});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},m=function(){O.clearPreviousExternalInputs();this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>E.__classPrivateFieldGet(this,e,"m",f).call(this,t)))},f=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),s=`input-${e.id}-${i}`,o=document.createElement("slot");o.setAttribute("name",s),o.setAttribute("slot",i),e.appendChild(o),t.setAttribute("slot",s),this.appendChild(t)}))},b=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var i;(null===(i=t.checkValidity)||void 0===i?void 0:i.call(t))&&E.__classPrivateFieldGet(this,_,"f").call(this,t,e)}))}))},w=function(t){this.rootElement.querySelectorAll(`descope-button:not([${y.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}])`).forEach((e=>{e.onclick=()=>{E.__classPrivateFieldGet(this,_,"f").call(this,e,t)}})),E.__classPrivateFieldGet(this,e,"m",b).call(this,t)},S=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===N.Direction.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(i)})),this.rootElement.classList.add("fade-out")},I=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},module.exports=class extends U{static set sdkConfigOverrides(e){U.sdkConfigOverrides=e}static get sdkConfigOverrides(){return U.sdkConfigOverrides}constructor(){const c=new P({deferredRedirect:!1});super(c.update.bind(c)),e.add(this),this.stepState=new P({},{updateOnlyOnChange:!1}),t.set(this,void 0),i.set(this,null),s.set(this,{visibilitychange:E.__classPrivateFieldGet(this,e,"m",o).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var i;const s=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=s;if(!e){e=null===(i=new URL(s.url).searchParams)||void 0===i?void 0:i.get(y.URL_CODE_PARAM_NAME)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(s.url),t=e.searchParams.get(y.URL_TOKEN_PARAM_NAME),i=e.searchParams.get(y.URL_RUN_IDS_PARAM_NAME).split("_").pop();E.__classPrivateFieldGet(this,a,"f").call(this),this.flowState.update({token:t,stepId:i,action:void 0})}else this.nativeComplete(s)},n.set(this,((e,i,s,o,r=!1)=>{if(this.flowState.current.action===y.RESPONSE_ACTIONS.poll){this.logger.debug("polling - Scheduling polling request");const a=Date.now(),d=r?500:2e3;E.__classPrivateFieldSet(this,t,setTimeout((()=>E.__awaiter(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,i,y.CUSTOM_INTERACTIONS.polling,s,o,{}),h=document.hidden&&!r&&Date.now()-a>d+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield O.timeoutPromise(e,c)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void E.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o,h)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===x.FETCH_EXCEPTION_ERROR_CODE)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void E.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o);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)),E.__classPrivateFieldGet(this,l,"f").call(this,u),E.__classPrivateFieldGet(this,n,"f").call(this,e,i,s,o)}))),d),"f")}})),a.set(this,(()=>{clearTimeout(E.__classPrivateFieldGet(this,t,"f")),E.__classPrivateFieldSet(this,t,null,"f")})),l.set(this,(t=>{var i,s,o,n,a,l,d,c,h,u,p,g;if(!(null==t?void 0:t.ok)){const d=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,c=`${null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.status} - ${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.statusText}`;E.__classPrivateFieldGet(this,e,"m",I).call(this,"error",(null==t?void 0:t.error)||{errorCode:x.FETCH_ERROR_RESPONSE_ERROR_CODE,errorDescription:c,errorMessage:d}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||d,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||c);const h=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==h&&"E103205"!==h||!this.isRestartOnError||E.__classPrivateFieldGet(this,e,"m",r).call(this))}null===(c=null===(d=t.data)||void 0===d?void 0:d.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:s}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,s):this.loggerWrapper.info(i,s)}));const v=null===(p=null===(u=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===u?void 0:u.state)||void 0===p?void 0:p.errorText;(null===(g=t.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${v?`${v} - `:""}${t.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:f,lastAuth:_}=t.data;if("completed"===m)return this.storeLastAuthenticatedUser&&k.setLastAuth(_),void E.__classPrivateFieldGet(this,e,"m",I).call(this,"success",f);const{executionId:b,stepId:w,stepName:S,action:C,screen:O,redirect:P,openInNewTabUrl:R,webauthn:T,error:F,samlIdpResponse:A,nativeResponse:N}=t.data;C!==y.RESPONSE_ACTIONS.poll?(this.loggerWrapper.info(`Step "${S||`#${w}`}" is ${m}`,"",{screen:O,status:m,stepId:w,stepName:S,action:C,error:F}),this.flowState.update({stepId:w,executionId:b,action:C,redirectTo:null==P?void 0:P.url,openInNewTabUrl:R,screenId:null==O?void 0:O.id,screenState:null==O?void 0:O.state,webauthnTransactionId:null==T?void 0:T.transactionId,webauthnOptions:null==T?void 0:T.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,nativeResponseType:null==N?void 0:N.type,nativePayload:null==N?void 0:N.payload})):this.flowState.update({action:C})})),d.set(this,O.withMemCache((()=>E.__awaiter(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),_.set(this,O.leadingDebounce(((t,i)=>E.__awaiter(this,void 0,void 0,(function*(){var s;if("true"===t.getAttribute("formnovalidate")||E.__classPrivateFieldGet(this,e,"m",u).call(this)){const o=null==t?void 0:t.getAttribute("id");E.__classPrivateFieldGet(this,e,"m",g).call(this,t);const r=yield E.__classPrivateFieldGet(this,e,"m",p).call(this),n=O.getElementDescopeAttributes(t),a=this.getComponentsContext(),d=Object.assign(Object.assign(Object.assign(Object.assign({},a),n),r),{origin:(null===(s=this.nativeOptions)||void 0===s?void 0:s.origin)||window.location.origin}),c=yield this.getFlowConfig(),h=yield this.getProjectConfig(),u=yield i(o,c.version,h.componentsVersion,d);E.__classPrivateFieldGet(this,l,"f").call(this,u),E.__classPrivateFieldGet(this,e,"m",v).call(this,r)}}))))),this.flowState=c}loadSdkScripts(){return E.__awaiter(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>E.__awaiter(this,void 0,void 0,(function*(){(yield j.default(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[j.getScriptResultPath(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return E.__awaiter(this,void 0,void 0,(function*(){var t,i,o;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(i=this.stepState)||void 0===i||i.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",E.__classPrivateFieldGet(this,s,"f").visibilitychange)),yield null===(o=e.init)||void 0===o?void 0:o.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=E.__classPrivateFieldGet(this,i,"f"))||void 0===e||e.abort(),E.__classPrivateFieldSet(this,i,null,"f"),window.removeEventListener("visibilitychange",E.__classPrivateFieldGet(this,s,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return E.__awaiter(this,void 0,void 0,(function*(){let i;const s=O.getUserLocale(e),o=yield this.getTargetLocales();return o.includes(s.locale)?i=`${t}-${s.locale}.html`:o.includes(s.fallback)&&(i=`${t}-${s.fallback}.html`),i}))}getPageContent(e,t){return E.__awaiter(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(t,s,o){return E.__awaiter(this,void 0,void 0,(function*(){var r,a;const{projectId:d,flowId:c,tenant:h,stepId:u,executionId:p,action:g,screenId:v,screenState:m,redirectTo:f,openInNewTabUrl:_,redirectUrl:b,token:w,code:S,exchangeError:P,webauthnTransactionId:R,webauthnOptions:T,redirectAuthCodeChallenge:N,redirectAuthCallbackUrl:U,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:x,locale:G,samlIdpResponseUrl:L,samlIdpResponseSamlResponse:W,samlIdpResponseRelayState:q,nativeResponseType:D,nativePayload:M}=t,$=E.__rest(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 V,B;const K=F.getABTestingKey(),H=this.sdk.getLastUserLoginId(),X=yield this.getFlowConfig(),J=yield this.getProjectConfig(),Y=Object.entries(J.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),z=U&&N?{callbackUrl:U,codeChallenge:N,backupCallbackUri:j}:void 0,Q=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(),X.fingerprintEnabled&&X.fingerprintKey?yield C.ensureFingerprintIds(X.fingerprintKey,this.baseUrl):C.clearFingerprintData(),X.conditions?({startScreenId:V,conditionInteractionId:B}=A.calculateConditions({loginId:H,code:S,token:w,abTestingKey:K},X.conditions)):X.condition?({startScreenId:V,conditionInteractionId:B}=A.calculateCondition(X.condition,{loginId:H,code:S,token:w,abTestingKey:K})):V=X.startScreenId,!O.showFirstScreenOnExecutionInit(V,$))){const e=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},$),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:k.getLastAuth(H),abTestingKey:K,locale:O.getUserLocale(G).locale,nativeOptions:Q}),B,"",J.componentsVersion,Y,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),S?{exchangeCode:S,idpInitiated:!0}:{}),$.descopeIdpInitiated&&{idpInitiated:!0}),w?{token:w}:{}),$.oidcLoginHint?{externalId:$.oidcLoginHint}:{}));return E.__classPrivateFieldGet(this,l,"f").call(this,e),void("completed"!==(null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.status)&&this.flowState.update({code:void 0,token:void 0}))}if(p&&(o("token")&&w||o("code")&&S||o("exchangeError")&&P)){const e=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,{token:w,exchangeCode:S,exchangeError:P});return E.__classPrivateFieldGet(this,l,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===y.RESPONSE_ACTIONS.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>o(e)))){if(!L||!W)return void this.loggerWrapper.error("Did not get saml idp params data to load");O.injectSamlIdpForm(L,W,q||"",O.submitForm)}if(g===y.RESPONSE_ACTIONS.redirect&&(o("redirectTo")||o("deferredRedirect")))return f?"android"===x&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(f):void this.loggerWrapper.error("Did not get redirect url");if(g===y.RESPONSE_ACTIONS.webauthnCreate||g===y.RESPONSE_ACTIONS.webauthnGet){if(!R||!T)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(a=E.__classPrivateFieldGet(this,i,"f"))||void 0===a||a.abort(),E.__classPrivateFieldSet(this,i,null,"f");try{e=g===y.RESPONSE_ACTIONS.webauthnCreate?yield this.sdk.webauthn.helpers.create(T):yield this.sdk.webauthn.helpers.get(T)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const s=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,{transactionId:R,response:e,failure:t});E.__classPrivateFieldGet(this,l,"f").call(this,s)}if(g===y.RESPONSE_ACTIONS.nativeBridge)return this.nativeComplete=e=>E.__awaiter(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,u,y.CUSTOM_INTERACTIONS.submit,X.version,J.componentsVersion,e);E.__classPrivateFieldGet(this,l,"f").call(this,t)})),void E.__classPrivateFieldGet(this,e,"m",I).call(this,"bridge",{type:D,payload:M});if(E.__classPrivateFieldGet(this,n,"f").call(this,p,u,X.version,J.componentsVersion),!v&&!V)return void this.loggerWrapper.warn("No screen was found to show");const Z=V||v,ee=yield this.getHtmlFilenameWithLocale(G,Z),{oidcLoginHint:te,oidcPrompt:ie,oidcErrorRedirectUri:se,samlIdpUsername:oe}=$,re={direction:O.getAnimationDirection(u,s.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:H,name:this.sdk.getLastUserDisplayName()||H}}),htmlFilename:`${Z}.html`,htmlLocaleFilename:ee,samlIdpUsername:oe,oidcLoginHint:te,oidcPrompt:ie,oidcErrorRedirectUri:se,openInNewTabUrl:_},ne=k.getLastAuth(H);O.showFirstScreenOnExecutionInit(V,$)?re.next=(e,t,i,s)=>this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},$),{lastAuth:ne,preview:this.preview,abTestingKey:K,client:this.client}),b&&{redirectUrl:b}),{locale:O.getUserLocale(G).locale,nativeOptions:Q}),B,e,i,Y,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),s),S&&{exchangeCode:S,idpInitiated:!0}),$.descopeIdpInitiated&&{idpInitiated:!0}),w&&{token:w})):(o("projectId")||o("baseUrl")||o("executionId")||o("stepId"))&&(re.next=(...e)=>this.sdk.flow.next(p,u,...e)),this.stepState.update(re)}))}onStepChange(t,i){return E.__awaiter(this,void 0,void 0,(function*(){var s,o;const{htmlFilename:r,htmlLocaleFilename:n,direction:a,next:d,screenState:c,openInNewTabUrl:u}=t,p=document.createElement("template");p.innerHTML=yield this.getPageContent(r,n);const g=p.content.cloneNode(!0),v=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield E.__classPrivateFieldGet(this,e,"m",h).call(this,g,d):R.disableWebauthnButtons(g),!t.samlIdpUsername||(null===(s=c.form)||void 0===s?void 0:s.loginId)||(null===(o=c.form)||void 0===o?void 0:o.email)||(c.form||(c.form={}),c.form.loginId=t.samlIdpUsername,c.form.email=t.samlIdpUsername),R.updateTemplateFromScreenState(g,c,c.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();R.setPhoneAutoDetectDefaultCode(g,f);const _=()=>E.__awaiter(this,void 0,void 0,(function*(){var t,s;yield v;const o=this.shadowRoot.querySelector("div");R.setTOTPVariable(o,null===(t=null==c?void 0:c.totp)||void 0===t?void 0:t.image),R.setNOTPVariable(o,null===(s=null==c?void 0:c.notp)||void 0===s?void 0:s.image),R.setCssVars(o,g,c.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(g);const r=!i.htmlFilename;setTimeout((()=>{E.__classPrivateFieldGet(this,e,"m",m).call(this),O.handleAutoFocus(this.rootElement,this.autoFocus,r),this.validateOnBlur&&O.handleReportValidityOnBlur(this.rootElement),R.updateScreenFromScreenState(this.rootElement,c)})),E.__classPrivateFieldGet(this,e,"m",w).call(this,d),r&&E.__classPrivateFieldGet(this,e,"m",I).call(this,"ready",{}),E.__classPrivateFieldGet(this,e,"m",I).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${y.ELEMENT_TYPE_ATTRIBUTE}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),i=yield d(y.CUSTOM_INTERACTIONS.polling,e.version,t.componentsVersion,{});E.__classPrivateFieldGet(this,l,"f").call(this,i)}u&&!i.openInNewTabUrl&&window.open(u,"_blank")}));a?E.__classPrivateFieldGet(this,e,"m",S).call(this,_,a):_()}))}};
@@ -1 +1 @@
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{withMemCache as a,handleUrlParams as l,clearRunIdsFromUrl as d,camelCase as c,getRunIdsFromUrl as h,getContentUrl as f,fetchContent as g}from"../helpers/helpers.js";import p from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{transformFlowInputFormData as v,extractNestedAttribute as m}from"../helpers/flowInputs.js";import{formMountMixin as b}from"../mixins/formMountMixin.js";import w from"./initTemplate.js";import{CONFIG_FILENAME as A,PREV_VER_ASSETS_FOLDER as C}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as k}from"../constants/general.js";var x,y,j,I,E,L,U,S,M,O,W,R,D,P,q,F,T,B,N,V,H;const K=r(o,s,b)(HTMLElement);class z extends K{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(),x.add(this),j.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,x,"m",V).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)}},I.set(this,new p),E.set(this,new p),L.set(this,{}),this.getComponentsContext=()=>t(this,L,"f"),this.nextRequestStatus=new p({isLoading:!1}),U.set(this,void 0),S.set(this,{popstate:t(this,x,"m",R).bind(this),componentsContext:t(this,x,"m",T).bind(this)}),M.set(this,void 0),this.getConfig=a((()=>e(this,void 0,void 0,(function*(){try{const{body:t,headers:e}=yield this.fetchStaticResource(A,"json");return{projectConfig:t,executionContext:{geo:e["x-geo"]}}}catch(t){return{isMissingConfig:!0}}})))),i(this,M,r,"f"),t(this,x,"m",O).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 v(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return m(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return e(this,void 0,void 0,(function*(){const{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();return t}))}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,e;const i=null===(e=null===(t=yield this.getConfig())||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.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,E,"f").subscribe(t(this,x,"m",N).bind(this)),t(this,E,"f").update({isDebug:this.debug}),t(this,x,"m",W).call(this),yield t(this,x,"m",q).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");if((yield this.getConfig()).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t(this,x,"m",H).call(this);const{executionId:s,stepId:o,token:n,code:u,exchangeError:a,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:h,redirectAuthInitiator:f,ssoQueryParams:g}=l(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t(this,S,"f").popstate),window.addEventListener("components-context",t(this,S,"f").componentsContext),t(this,I,"f").subscribe(t(this,x,"m",P).bind(this)),t(this,I,"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:s,token:n,code:u,exchangeError:a,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:h,redirectAuthInitiator:f},g)),i(this,j,!0,"f")}))}disconnectedCallback(){t(this,I,"f").unsubscribeAll(),t(this,E,"f").unsubscribeAll(),t(this,x,"m",B).call(this),window.removeEventListener("popstate",t(this,S,"f").popstate),window.removeEventListener("components-context",t(this,S,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t(this,j,"f")&&i!==r&&y.observedAttributes.includes(e)){t(this,x,"m",W).call(this);const s=null===i;t(this,I,"f").update((({stepId:t,executionId:i})=>{let o=t,n=i;return s||(n=null,o=null,d()),{[c(e)]:r,stepId:o,executionId:n}})),t(this,E,"f").update({isDebug:this.debug})}}}y=z,j=new WeakMap,I=new WeakMap,E=new WeakMap,L=new WeakMap,U=new WeakMap,S=new WeakMap,M=new WeakMap,x=new WeakSet,O=function(){this.shadowRoot.appendChild(w.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},W=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"];y.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[c(e)])throw Error(`${e} cannot be empty`)}))},R=function(){const{stepId:e,executionId:i}=h(this.flowId);t(this,I,"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},y.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:k,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},P=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,x,"m",D).call(this,e,r)}t(this,M,"f").call(this,i)}))},q=function(){return e(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield t(this,x,"m",F).call(this))}))},F=function(){return e(this,void 0,void 0,(function*(){const t=f({projectId:this.projectId,filename:A,assetsFolder:C,baseUrl:this.baseStaticUrl});try{return yield g(t,"json"),!0}catch(t){return!1}}))},T=function(e){i(this,L,Object.assign(Object.assign({},t(this,L,"f")),e.detail),"f")},B=function(){var e;null===(e=t(this,U,"f"))||void 0===e||e.remove(),i(this,U,null,"f")},N=function(r){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,U,document.createElement("descope-debugger"),"f"),Object.assign(t(this,U,"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,U,"f"))):t(this,x,"m",B).call(this)}))},V=function(e,i){var r;e&&this.debug&&(null===(r=t(this,U,"f"))||void 0===r||r.updateData({title:e,description:i}))},H=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()}}},z.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.32.10"}};export{z 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,q,F,T,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",F).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",T).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.rootElement=this.shadowRoot.querySelector("#root")},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",q).call(this))}))},q=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}}))},F=function(e){i(this,E,Object.assign(Object.assign({},t(this,E,"f")),e.detail),"f")},T=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",T).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.33.0"}};export{K as default};
@@ -1 +1 @@
1
- import{__classPrivateFieldGet as e,__classPrivateFieldSet as t,__awaiter as i,__rest as o}from"tslib";import{ensureFingerprintIds as s,clearFingerprintData as n}from"@descope/web-js-sdk";import{URL_CODE_PARAM_NAME as r,URL_TOKEN_PARAM_NAME as l,URL_RUN_IDS_PARAM_NAME as a,RESPONSE_ACTIONS as d,CUSTOM_INTERACTIONS as c,ELEMENT_TYPE_ATTRIBUTE as h,DESCOPE_ATTRIBUTE_EXCLUDE_FIELD as u,DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON as p}from"../constants/index.js";import{timeoutPromise as g,withMemCache as v,leadingDebounce as m,getUserLocale as f,showFirstScreenOnExecutionInit as b,injectSamlIdpForm as w,getAnimationDirection as y,getElementDescopeAttributes as I,submitForm as C,handleAutoFocus as k,handleReportValidityOnBlur as S,getFirstNonEmptyValue as O,clearPreviousExternalInputs as R}from"../helpers/helpers.js";import j from"../helpers/state.js";import{disableWebauthnButtons as E,updateTemplateFromScreenState as A,setPhoneAutoDetectDefaultCode as x,setTOTPVariable as W,setNOTPVariable as U,setCssVars as T,updateScreenFromScreenState as L}from"../helpers/templates.js";import{isConditionalLoginSupported as $}from"../helpers/webauthn.js";import{getABTestingKey as P}from"../helpers/abTestingKey.js";import{calculateConditions as F,calculateCondition as V}from"../helpers/conditions.js";import{setLastAuth as N,getLastAuth as q}from"../helpers/lastAuth.js";import{Direction as M}from"../types.js";import D from"./BaseDescopeWc.js";import K,{getScriptResultPath as H}from"./sdkScripts/index.js";import{FETCH_EXCEPTION_ERROR_CODE as B,FETCH_ERROR_RESPONSE_ERROR_CODE as G}from"../constants/general.js";var J,_,z,Q,X,Y,Z,ee,te,ie,oe,se,ne,re,le,ae,de,ce,he,ue,pe,ge,ve;class me extends D{static set sdkConfigOverrides(e){D.sdkConfigOverrides=e}static get sdkConfigOverrides(){return D.sdkConfigOverrides}constructor(){const o=new j({deferredRedirect:!1});super(o.update.bind(o)),J.add(this),this.stepState=new j({},{updateOnlyOnChange:!1}),_.set(this,void 0),z.set(this,null),Q.set(this,{visibilitychange:e(this,J,"m",X).bind(this)}),this.bridgeVersion=1,this.nativeResume=(t,i)=>{var o;const s=JSON.parse(i);if(this.logger.info(`nativeResume received payload of type '${t}'`),"oauthWeb"===t||"sso"===t){let{exchangeCode:e}=s;if(!e){e=null===(o=new URL(s.url).searchParams)||void 0===o?void 0:o.get(r)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===t){const t=new URL(s.url),i=t.searchParams.get(l),o=t.searchParams.get(a).split("_").pop();e(this,ee,"f").call(this),this.flowState.update({token:i,stepId:o,action:void 0})}else this.nativeComplete(s)},Z.set(this,((o,s,n,r,l=!1)=>{if(this.flowState.current.action===d.poll){this.logger.debug("polling - Scheduling polling request");const a=Date.now(),d=l?500:2e3;t(this,_,setTimeout((()=>i(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const i=this.sdk.flow.next(o,s,c.polling,n,r,{}),h=document.hidden&&!l&&Date.now()-a>d+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield g(e,i)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void e(this,Z,"f").call(this,o,s,n,r,h)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===B)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void e(this,Z,"f").call(this,o,s,n,r);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)),e(this,te,"f").call(this,u),e(this,Z,"f").call(this,o,s,n,r)}))),d),"f")}})),ee.set(this,(()=>{clearTimeout(e(this,_,"f")),t(this,_,null,"f")})),te.set(this,(t=>{var i,o,s,n,r,l,a,c,h,u,p,g;if(!(null==t?void 0:t.ok)){const a=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,d=`${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.status} - ${null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.statusText}`;e(this,J,"m",ve).call(this,"error",(null==t?void 0:t.error)||{errorCode:G,errorDescription:d,errorMessage:a}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||a,(null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorMessage)||d);const c=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==c&&"E103205"!==c||!this.isRestartOnError||e(this,J,"m",Y).call(this))}null===(c=null===(a=t.data)||void 0===a?void 0:a.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,o):this.loggerWrapper.info(i,o)}));const v=null===(p=null===(u=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===u?void 0:u.state)||void 0===p?void 0:p.errorText;(null===(g=t.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${v?`${v} - `:""}${t.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:f,lastAuth:b}=t.data;if("completed"===m)return this.storeLastAuthenticatedUser&&N(b),void e(this,J,"m",ve).call(this,"success",f);const{executionId:w,stepId:y,stepName:I,action:C,screen:k,redirect:S,openInNewTabUrl:O,webauthn:R,error:j,samlIdpResponse:E,nativeResponse:A}=t.data;C!==d.poll?(this.loggerWrapper.info(`Step "${I||`#${y}`}" is ${m}`,"",{screen:k,status:m,stepId:y,stepName:I,action:C,error:j}),this.flowState.update({stepId:y,executionId:w,action:C,redirectTo:null==S?void 0:S.url,openInNewTabUrl:O,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==R?void 0:R.transactionId,webauthnOptions:null==R?void 0:R.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,nativeResponseType:null==A?void 0:A.type,nativePayload:null==A?void 0:A.payload})):this.flowState.update({action:C})})),ie.set(this,v((()=>i(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),he.set(this,m(((t,o)=>i(this,void 0,void 0,(function*(){var i;if("true"===t.getAttribute("formnovalidate")||e(this,J,"m",ne).call(this)){const s=null==t?void 0:t.getAttribute("id");e(this,J,"m",le).call(this,t);const n=yield e(this,J,"m",re).call(this),r=I(t),l=this.getComponentsContext(),a=Object.assign(Object.assign(Object.assign(Object.assign({},l),r),n),{origin:(null===(i=this.nativeOptions)||void 0===i?void 0:i.origin)||window.location.origin}),d=yield this.getFlowConfig(),c=yield this.getProjectConfig(),h=yield o(s,d.version,c.componentsVersion,a);e(this,te,"f").call(this,h),e(this,J,"m",ae).call(this,n)}}))))),this.flowState=o}loadSdkScripts(){return i(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>i(this,void 0,void 0,(function*(){(yield K(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[H(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var i,o,s;this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",e(this,Q,"f").visibilitychange)),yield null===(s=t.init)||void 0===s?void 0:s.call(this)}))}disconnectedCallback(){var i;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(i=e(this,z,"f"))||void 0===i||i.abort(),t(this,z,null,"f"),window.removeEventListener("visibilitychange",e(this,Q,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return i(this,void 0,void 0,(function*(){let i;const o=f(e),s=yield this.getTargetLocales();return s.includes(o.locale)?i=`${t}-${o.locale}.html`:s.includes(o.fallback)&&(i=`${t}-${o.fallback}.html`),i}))}getPageContent(e,t){return i(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(r,l,a){return i(this,void 0,void 0,(function*(){var h,u;const{projectId:p,flowId:g,tenant:v,stepId:m,executionId:I,action:k,screenId:S,screenState:O,redirectTo:R,openInNewTabUrl:j,redirectUrl:E,token:A,code:x,exchangeError:W,webauthnTransactionId:U,webauthnOptions:T,redirectAuthCodeChallenge:L,redirectAuthCallbackUrl:$,redirectAuthBackupCallbackUri:N,redirectAuthInitiator:M,locale:D,samlIdpResponseUrl:K,samlIdpResponseSamlResponse:H,samlIdpResponseRelayState:B,nativeResponseType:G,nativePayload:_}=r,Q=o(r,["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 X,Y;const ee=P(),ie=this.sdk.getLastUserLoginId(),oe=yield this.getFlowConfig(),se=yield this.getProjectConfig(),ne=Object.entries(se.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),re=$&&L?{callbackUrl:$,codeChallenge:L,backupCallbackUri:N}:void 0,le=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(!I&&(this.loadSdkScripts(),oe.fingerprintEnabled&&oe.fingerprintKey?yield s(oe.fingerprintKey,this.baseUrl):n(),oe.conditions?({startScreenId:X,conditionInteractionId:Y}=F({loginId:ie,code:x,token:A,abTestingKey:ee},oe.conditions)):oe.condition?({startScreenId:X,conditionInteractionId:Y}=V(oe.condition,{loginId:ie,code:x,token:A,abTestingKey:ee})):X=oe.startScreenId,!b(X,Q))){const t=yield this.sdk.flow.start(g,Object.assign(Object.assign(Object.assign(Object.assign({tenant:v,redirectAuth:re},Q),{client:this.client}),E&&{redirectUrl:E}),{lastAuth:q(ie),abTestingKey:ee,locale:f(D).locale,nativeOptions:le}),Y,"",se.componentsVersion,ne,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),x?{exchangeCode:x,idpInitiated:!0}:{}),Q.descopeIdpInitiated&&{idpInitiated:!0}),A?{token:A}:{}),Q.oidcLoginHint?{externalId:Q.oidcLoginHint}:{}));return e(this,te,"f").call(this,t),void("completed"!==(null===(h=null==t?void 0:t.data)||void 0===h?void 0:h.status)&&this.flowState.update({code:void 0,token:void 0}))}if(I&&(a("token")&&A||a("code")&&x||a("exchangeError")&&W)){const t=yield this.sdk.flow.next(I,m,c.submit,oe.version,se.componentsVersion,{token:A,exchangeCode:x,exchangeError:W});return e(this,te,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(k===d.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>a(e)))){if(!K||!H)return void this.loggerWrapper.error("Did not get saml idp params data to load");w(K,H,B||"",C)}if(k===d.redirect&&(a("redirectTo")||a("deferredRedirect")))return R?"android"===M&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(R):void this.loggerWrapper.error("Did not get redirect url");if(k===d.webauthnCreate||k===d.webauthnGet){if(!U||!T)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let i,o;null===(u=e(this,z,"f"))||void 0===u||u.abort(),t(this,z,null,"f");try{i=k===d.webauthnCreate?yield this.sdk.webauthn.helpers.create(T):yield this.sdk.webauthn.helpers.get(T)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),o=e.name}const s=yield this.sdk.flow.next(I,m,c.submit,oe.version,se.componentsVersion,{transactionId:U,response:i,failure:o});e(this,te,"f").call(this,s)}if(k===d.nativeBridge)return this.nativeComplete=t=>i(this,void 0,void 0,(function*(){const i=yield this.sdk.flow.next(I,m,c.submit,oe.version,se.componentsVersion,t);e(this,te,"f").call(this,i)})),void e(this,J,"m",ve).call(this,"bridge",{type:G,payload:_});if(e(this,Z,"f").call(this,I,m,oe.version,se.componentsVersion),!S&&!X)return void this.loggerWrapper.warn("No screen was found to show");const ae=X||S,de=yield this.getHtmlFilenameWithLocale(D,ae),{oidcLoginHint:ce,oidcPrompt:he,oidcErrorRedirectUri:ue,samlIdpUsername:pe}=Q,ge={direction:y(m,l.stepId),screenState:Object.assign(Object.assign({},O),{form:Object.assign(Object.assign({},this.formConfigValues),null==O?void 0:O.form),lastAuth:{loginId:ie,name:this.sdk.getLastUserDisplayName()||ie}}),htmlFilename:`${ae}.html`,htmlLocaleFilename:de,samlIdpUsername:pe,oidcLoginHint:ce,oidcPrompt:he,oidcErrorRedirectUri:ue,openInNewTabUrl:j},me=q(ie);b(X,Q)?ge.next=(e,t,i,o)=>this.sdk.flow.start(g,Object.assign(Object.assign(Object.assign(Object.assign({tenant:v,redirectAuth:re},Q),{lastAuth:me,preview:this.preview,abTestingKey:ee,client:this.client}),E&&{redirectUrl:E}),{locale:f(D).locale,nativeOptions:le}),Y,e,i,ne,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),x&&{exchangeCode:x,idpInitiated:!0}),Q.descopeIdpInitiated&&{idpInitiated:!0}),A&&{token:A})):(a("projectId")||a("baseUrl")||a("executionId")||a("stepId"))&&(ge.next=(...e)=>this.sdk.flow.next(I,m,...e)),this.stepState.update(ge)}))}onStepChange(t,o){return i(this,void 0,void 0,(function*(){var s,n;const{htmlFilename:r,htmlLocaleFilename:l,direction:a,next:d,screenState:u,openInNewTabUrl:p}=t,g=document.createElement("template");g.innerHTML=yield this.getPageContent(r,l);const v=g.content.cloneNode(!0),m=this.loadDescopeUiComponents(g);this.sdk.webauthn.helpers.isSupported()?yield e(this,J,"m",se).call(this,v,d):E(v),!t.samlIdpUsername||(null===(s=u.form)||void 0===s?void 0:s.loginId)||(null===(n=u.form)||void 0===n?void 0:n.email)||(u.form||(u.form={}),u.form.loginId=t.samlIdpUsername,u.form.email=t.samlIdpUsername),A(v,u,u.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();x(v,f);const b=()=>i(this,void 0,void 0,(function*(){var t,i;yield m;const s=this.shadowRoot.querySelector("div");W(s,null===(t=null==u?void 0:u.totp)||void 0===t?void 0:t.image),U(s,null===(i=null==u?void 0:u.notp)||void 0===i?void 0:i.image),T(s,v,u.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(v);const n=!o.htmlFilename;setTimeout((()=>{e(this,J,"m",de).call(this),k(this.rootElement,this.autoFocus,n),this.validateOnBlur&&S(this.rootElement),L(this.rootElement,u)})),e(this,J,"m",pe).call(this,d),n&&e(this,J,"m",ve).call(this,"ready",{}),e(this,J,"m",ve).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${h}="polling"]`)){const t=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(c.polling,t.version,i.componentsVersion,{});e(this,te,"f").call(this,o)}p&&!o.openInNewTabUrl&&window.open(p,"_blank")}));a?e(this,J,"m",ge).call(this,b,a):b()}))}}_=new WeakMap,z=new WeakMap,Q=new WeakMap,Z=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,he=new WeakMap,J=new WeakSet,X=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Y=function(){return i(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.getConfig.reset();e===(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")}))},oe=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},se=function(o,s){return i(this,void 0,void 0,(function*(){var n;null===(n=e(this,z,"f"))||void 0===n||n.abort();const r=o.querySelector('*[autocomplete="webauthn"]');if(r&&(yield $())){const{options:o,transactionId:n}=(yield e(this,ie,"f").call(this))||{};if(o&&n){e(this,J,"m",oe).call(this,r),t(this,z,new AbortController,"f");const l=yield this.getFlowConfig(),a=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,e(this,z,"f")).then((t=>i(this,void 0,void 0,(function*(){const i=yield s(r.id,l.version,a.componentsVersion,{transactionId:n,response:t});e(this,te,"f").call(this,i)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},ne=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,o;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},re=function(){return i(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${u}])`));return(yield Promise.all(e.map((e=>i(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},le=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},ae=function(e={}){var t,i;const o=O(e,["externalId","email","phone"]),s=O(e,["newPassword","password"]);if(o&&s)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:s});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},de=function(){R();this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>e(this,J,"m",ce).call(this,t)))},ce=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),o=`input-${e.id}-${i}`,s=document.createElement("slot");s.setAttribute("name",o),s.setAttribute("slot",i),e.appendChild(s),t.setAttribute("slot",o),this.appendChild(t)}))},ue=function(t){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var o;(null===(o=i.checkValidity)||void 0===o?void 0:o.call(i))&&e(this,he,"f").call(this,i,t)}))}))},pe=function(t){this.rootElement.querySelectorAll(`descope-button:not([${p}])`).forEach((i=>{i.onclick=()=>{e(this,he,"f").call(this,i,t)}})),e(this,J,"m",ue).call(this,t)},ge=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===M.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(i)})),this.rootElement.classList.add("fade-out")},ve=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))};export{me as default};
1
+ import{__classPrivateFieldGet as e,__classPrivateFieldSet as t,__awaiter as i,__rest as o}from"tslib";import{ensureFingerprintIds as s,clearFingerprintData as n}from"@descope/web-js-sdk";import{URL_CODE_PARAM_NAME as r,URL_TOKEN_PARAM_NAME as l,URL_RUN_IDS_PARAM_NAME as a,RESPONSE_ACTIONS as d,CUSTOM_INTERACTIONS as c,ELEMENT_TYPE_ATTRIBUTE as h,DESCOPE_ATTRIBUTE_EXCLUDE_FIELD as u,DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON as p}from"../constants/index.js";import{timeoutPromise as g,withMemCache as v,leadingDebounce as m,getUserLocale as f,showFirstScreenOnExecutionInit as b,injectSamlIdpForm as w,getAnimationDirection as y,getElementDescopeAttributes as I,submitForm as C,handleAutoFocus as k,handleReportValidityOnBlur as S,getFirstNonEmptyValue as O,clearPreviousExternalInputs as R}from"../helpers/helpers.js";import j from"../helpers/state.js";import{disableWebauthnButtons as E,updateTemplateFromScreenState as A,setPhoneAutoDetectDefaultCode as x,setTOTPVariable as W,setNOTPVariable as U,setCssVars as T,updateScreenFromScreenState as L}from"../helpers/templates.js";import{isConditionalLoginSupported as $}from"../helpers/webauthn.js";import{getABTestingKey as P}from"../helpers/abTestingKey.js";import{calculateConditions as F,calculateCondition as V}from"../helpers/conditions.js";import{setLastAuth as N,getLastAuth as q}from"../helpers/lastAuth.js";import{Direction as M}from"../types.js";import D from"./BaseDescopeWc.js";import K,{getScriptResultPath as H}from"./sdkScripts/index.js";import{FETCH_EXCEPTION_ERROR_CODE as B,FETCH_ERROR_RESPONSE_ERROR_CODE as G}from"../constants/general.js";var J,_,z,Q,X,Y,Z,ee,te,ie,oe,se,ne,re,le,ae,de,ce,he,ue,pe,ge,ve;class me extends D{static set sdkConfigOverrides(e){D.sdkConfigOverrides=e}static get sdkConfigOverrides(){return D.sdkConfigOverrides}constructor(){const o=new j({deferredRedirect:!1});super(o.update.bind(o)),J.add(this),this.stepState=new j({},{updateOnlyOnChange:!1}),_.set(this,void 0),z.set(this,null),Q.set(this,{visibilitychange:e(this,J,"m",X).bind(this)}),this.bridgeVersion=1,this.nativeResume=(t,i)=>{var o;const s=JSON.parse(i);if(this.logger.info(`nativeResume received payload of type '${t}'`),"oauthWeb"===t||"sso"===t){let{exchangeCode:e}=s;if(!e){e=null===(o=new URL(s.url).searchParams)||void 0===o?void 0:o.get(r)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===t){const t=new URL(s.url),i=t.searchParams.get(l),o=t.searchParams.get(a).split("_").pop();e(this,ee,"f").call(this),this.flowState.update({token:i,stepId:o,action:void 0})}else this.nativeComplete(s)},Z.set(this,((o,s,n,r,l=!1)=>{if(this.flowState.current.action===d.poll){this.logger.debug("polling - Scheduling polling request");const a=Date.now(),d=l?500:2e3;t(this,_,setTimeout((()=>i(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const i=this.sdk.flow.next(o,s,c.polling,n,r,{}),h=document.hidden&&!l&&Date.now()-a>d+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield g(e,i)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void e(this,Z,"f").call(this,o,s,n,r,h)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===B)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void e(this,Z,"f").call(this,o,s,n,r);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)),e(this,te,"f").call(this,u),e(this,Z,"f").call(this,o,s,n,r)}))),d),"f")}})),ee.set(this,(()=>{clearTimeout(e(this,_,"f")),t(this,_,null,"f")})),te.set(this,(t=>{var i,o,s,n,r,l,a,c,h,u,p,g;if(!(null==t?void 0:t.ok)){const a=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,d=`${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.status} - ${null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.statusText}`;e(this,J,"m",ve).call(this,"error",(null==t?void 0:t.error)||{errorCode:G,errorDescription:d,errorMessage:a}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||a,(null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorMessage)||d);const c=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==c&&"E103205"!==c||!this.isRestartOnError||e(this,J,"m",Y).call(this))}null===(c=null===(a=t.data)||void 0===a?void 0:a.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,o):this.loggerWrapper.info(i,o)}));const v=null===(p=null===(u=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===u?void 0:u.state)||void 0===p?void 0:p.errorText;(null===(g=t.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${v?`${v} - `:""}${t.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:f,lastAuth:b}=t.data;if("completed"===m)return this.storeLastAuthenticatedUser&&N(b),void e(this,J,"m",ve).call(this,"success",f);const{executionId:w,stepId:y,stepName:I,action:C,screen:k,redirect:S,openInNewTabUrl:O,webauthn:R,error:j,samlIdpResponse:E,nativeResponse:A}=t.data;C!==d.poll?(this.loggerWrapper.info(`Step "${I||`#${y}`}" is ${m}`,"",{screen:k,status:m,stepId:y,stepName:I,action:C,error:j}),this.flowState.update({stepId:y,executionId:w,action:C,redirectTo:null==S?void 0:S.url,openInNewTabUrl:O,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==R?void 0:R.transactionId,webauthnOptions:null==R?void 0:R.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,nativeResponseType:null==A?void 0:A.type,nativePayload:null==A?void 0:A.payload})):this.flowState.update({action:C})})),ie.set(this,v((()=>i(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),he.set(this,m(((t,o)=>i(this,void 0,void 0,(function*(){var i;if("true"===t.getAttribute("formnovalidate")||e(this,J,"m",ne).call(this)){const s=null==t?void 0:t.getAttribute("id");e(this,J,"m",le).call(this,t);const n=yield e(this,J,"m",re).call(this),r=I(t),l=this.getComponentsContext(),a=Object.assign(Object.assign(Object.assign(Object.assign({},l),r),n),{origin:(null===(i=this.nativeOptions)||void 0===i?void 0:i.origin)||window.location.origin}),d=yield this.getFlowConfig(),c=yield this.getProjectConfig(),h=yield o(s,d.version,c.componentsVersion,a);e(this,te,"f").call(this,h),e(this,J,"m",ae).call(this,n)}}))))),this.flowState=o}loadSdkScripts(){return i(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>i(this,void 0,void 0,(function*(){(yield K(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[H(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var i,o,s;this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",e(this,Q,"f").visibilitychange)),yield null===(s=t.init)||void 0===s?void 0:s.call(this)}))}disconnectedCallback(){var i;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(i=e(this,z,"f"))||void 0===i||i.abort(),t(this,z,null,"f"),window.removeEventListener("visibilitychange",e(this,Q,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return i(this,void 0,void 0,(function*(){let i;const o=f(e),s=yield this.getTargetLocales();return s.includes(o.locale)?i=`${t}-${o.locale}.html`:s.includes(o.fallback)&&(i=`${t}-${o.fallback}.html`),i}))}getPageContent(e,t){return i(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(r,l,a){return i(this,void 0,void 0,(function*(){var h,u;const{projectId:p,flowId:g,tenant:v,stepId:m,executionId:I,action:k,screenId:S,screenState:O,redirectTo:R,openInNewTabUrl:j,redirectUrl:E,token:A,code:x,exchangeError:W,webauthnTransactionId:U,webauthnOptions:T,redirectAuthCodeChallenge:L,redirectAuthCallbackUrl:$,redirectAuthBackupCallbackUri:N,redirectAuthInitiator:M,locale:D,samlIdpResponseUrl:K,samlIdpResponseSamlResponse:H,samlIdpResponseRelayState:B,nativeResponseType:G,nativePayload:_}=r,Q=o(r,["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 X,Y;const ee=P(),ie=this.sdk.getLastUserLoginId(),oe=yield this.getFlowConfig(),se=yield this.getProjectConfig(),ne=Object.entries(se.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),re=$&&L?{callbackUrl:$,codeChallenge:L,backupCallbackUri:N}:void 0,le=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(!I&&(this.loadSdkScripts(),oe.fingerprintEnabled&&oe.fingerprintKey?yield s(oe.fingerprintKey,this.baseUrl):n(),oe.conditions?({startScreenId:X,conditionInteractionId:Y}=F({loginId:ie,code:x,token:A,abTestingKey:ee},oe.conditions)):oe.condition?({startScreenId:X,conditionInteractionId:Y}=V(oe.condition,{loginId:ie,code:x,token:A,abTestingKey:ee})):X=oe.startScreenId,!b(X,Q))){const t=yield this.sdk.flow.start(g,Object.assign(Object.assign(Object.assign(Object.assign({tenant:v,redirectAuth:re},Q),{client:this.client}),E&&{redirectUrl:E}),{lastAuth:q(ie),abTestingKey:ee,locale:f(D).locale,nativeOptions:le}),Y,"",se.componentsVersion,ne,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),x?{exchangeCode:x,idpInitiated:!0}:{}),Q.descopeIdpInitiated&&{idpInitiated:!0}),A?{token:A}:{}),Q.oidcLoginHint?{externalId:Q.oidcLoginHint}:{}));return e(this,te,"f").call(this,t),void("completed"!==(null===(h=null==t?void 0:t.data)||void 0===h?void 0:h.status)&&this.flowState.update({code:void 0,token:void 0}))}if(I&&(a("token")&&A||a("code")&&x||a("exchangeError")&&W)){const t=yield this.sdk.flow.next(I,m,c.submit,oe.version,se.componentsVersion,{token:A,exchangeCode:x,exchangeError:W});return e(this,te,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(k===d.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>a(e)))){if(!K||!H)return void this.loggerWrapper.error("Did not get saml idp params data to load");w(K,H,B||"",C)}if(k===d.redirect&&(a("redirectTo")||a("deferredRedirect")))return R?"android"===M&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(R):void this.loggerWrapper.error("Did not get redirect url");if(k===d.webauthnCreate||k===d.webauthnGet){if(!U||!T)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let i,o;null===(u=e(this,z,"f"))||void 0===u||u.abort(),t(this,z,null,"f");try{i=k===d.webauthnCreate?yield this.sdk.webauthn.helpers.create(T):yield this.sdk.webauthn.helpers.get(T)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),o=e.name}const s=yield this.sdk.flow.next(I,m,c.submit,oe.version,se.componentsVersion,{transactionId:U,response:i,failure:o});e(this,te,"f").call(this,s)}if(k===d.nativeBridge)return this.nativeComplete=t=>i(this,void 0,void 0,(function*(){const i=yield this.sdk.flow.next(I,m,c.submit,oe.version,se.componentsVersion,t);e(this,te,"f").call(this,i)})),void e(this,J,"m",ve).call(this,"bridge",{type:G,payload:_});if(e(this,Z,"f").call(this,I,m,oe.version,se.componentsVersion),!S&&!X)return void this.loggerWrapper.warn("No screen was found to show");const ae=X||S,de=yield this.getHtmlFilenameWithLocale(D,ae),{oidcLoginHint:ce,oidcPrompt:he,oidcErrorRedirectUri:ue,samlIdpUsername:pe}=Q,ge={direction:y(m,l.stepId),screenState:Object.assign(Object.assign({},O),{form:Object.assign(Object.assign({},this.formConfigValues),null==O?void 0:O.form),lastAuth:{loginId:ie,name:this.sdk.getLastUserDisplayName()||ie}}),htmlFilename:`${ae}.html`,htmlLocaleFilename:de,samlIdpUsername:pe,oidcLoginHint:ce,oidcPrompt:he,oidcErrorRedirectUri:ue,openInNewTabUrl:j},me=q(ie);b(X,Q)?ge.next=(e,t,i,o)=>this.sdk.flow.start(g,Object.assign(Object.assign(Object.assign(Object.assign({tenant:v,redirectAuth:re},Q),{lastAuth:me,preview:this.preview,abTestingKey:ee,client:this.client}),E&&{redirectUrl:E}),{locale:f(D).locale,nativeOptions:le}),Y,e,i,ne,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),x&&{exchangeCode:x,idpInitiated:!0}),Q.descopeIdpInitiated&&{idpInitiated:!0}),A&&{token:A})):(a("projectId")||a("baseUrl")||a("executionId")||a("stepId"))&&(ge.next=(...e)=>this.sdk.flow.next(I,m,...e)),this.stepState.update(ge)}))}onStepChange(t,o){return i(this,void 0,void 0,(function*(){var s,n;const{htmlFilename:r,htmlLocaleFilename:l,direction:a,next:d,screenState:u,openInNewTabUrl:p}=t,g=document.createElement("template");g.innerHTML=yield this.getPageContent(r,l);const v=g.content.cloneNode(!0),m=this.loadDescopeUiComponents(g);this.sdk.webauthn.helpers.isSupported()?yield e(this,J,"m",se).call(this,v,d):E(v),!t.samlIdpUsername||(null===(s=u.form)||void 0===s?void 0:s.loginId)||(null===(n=u.form)||void 0===n?void 0:n.email)||(u.form||(u.form={}),u.form.loginId=t.samlIdpUsername,u.form.email=t.samlIdpUsername),A(v,u,u.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();x(v,f);const b=()=>i(this,void 0,void 0,(function*(){var t,i;yield m;const s=this.shadowRoot.querySelector("div");W(s,null===(t=null==u?void 0:u.totp)||void 0===t?void 0:t.image),U(s,null===(i=null==u?void 0:u.notp)||void 0===i?void 0:i.image),T(s,v,u.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(v);const n=!o.htmlFilename;setTimeout((()=>{e(this,J,"m",de).call(this),k(this.rootElement,this.autoFocus,n),this.validateOnBlur&&S(this.rootElement),L(this.rootElement,u)})),e(this,J,"m",pe).call(this,d),n&&e(this,J,"m",ve).call(this,"ready",{}),e(this,J,"m",ve).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${h}="polling"]`)){const t=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(c.polling,t.version,i.componentsVersion,{});e(this,te,"f").call(this,o)}p&&!o.openInNewTabUrl&&window.open(p,"_blank")}));a?e(this,J,"m",ge).call(this,b,a):b()}))}}_=new WeakMap,z=new WeakMap,Q=new WeakMap,Z=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,he=new WeakMap,J=new WeakSet,X=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Y=function(){return i(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset();e===(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")}))},oe=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},se=function(o,s){return i(this,void 0,void 0,(function*(){var n;null===(n=e(this,z,"f"))||void 0===n||n.abort();const r=o.querySelector('*[autocomplete="webauthn"]');if(r&&(yield $())){const{options:o,transactionId:n}=(yield e(this,ie,"f").call(this))||{};if(o&&n){e(this,J,"m",oe).call(this,r),t(this,z,new AbortController,"f");const l=yield this.getFlowConfig(),a=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,e(this,z,"f")).then((t=>i(this,void 0,void 0,(function*(){const i=yield s(r.id,l.version,a.componentsVersion,{transactionId:n,response:t});e(this,te,"f").call(this,i)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},ne=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,o;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},re=function(){return i(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${u}])`));return(yield Promise.all(e.map((e=>i(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},le=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},ae=function(e={}){var t,i;const o=O(e,["externalId","email","phone"]),s=O(e,["newPassword","password"]);if(o&&s)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:s});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},de=function(){R();this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>e(this,J,"m",ce).call(this,t)))},ce=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),o=`input-${e.id}-${i}`,s=document.createElement("slot");s.setAttribute("name",o),s.setAttribute("slot",i),e.appendChild(s),t.setAttribute("slot",o),this.appendChild(t)}))},ue=function(t){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var o;(null===(o=i.checkValidity)||void 0===o?void 0:o.call(i))&&e(this,he,"f").call(this,i,t)}))}))},pe=function(t){this.rootElement.querySelectorAll(`descope-button:not([${p}])`).forEach((i=>{i.onclick=()=>{e(this,he,"f").call(this,i,t)}})),e(this,J,"m",ue).call(this,t)},ge=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===M.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(i)})),this.rootElement.classList.add("fade-out")},ve=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))};export{me as default};
package/dist/index.d.ts CHANGED
@@ -494,9 +494,9 @@ declare const BaseClass: {
494
494
  focus(options?: FocusOptions): void;
495
495
  };
496
496
  } & (new (...params: any[]) => {
497
- "__#24336@#lastBaseUrl"?: string;
498
- "__#24336@#workingBaseUrl"?: string;
499
- "__#24336@#getResourceUrls"(filename: string): (URL & {
497
+ "__#27129@#lastBaseUrl"?: string;
498
+ "__#27129@#workingBaseUrl"?: string;
499
+ "__#27129@#getResourceUrls"(filename: string): (URL & {
500
500
  baseUrl: string;
501
501
  }) | (URL & {
502
502
  baseUrl: string;
@@ -834,40 +834,40 @@ declare const BaseClass: {
834
834
  blur(): void;
835
835
  focus(options?: FocusOptions): void;
836
836
  readonly projectId: string;
837
- "__#24335@#handleError"(attrName: string, newValue: string): void;
837
+ "__#27128@#handleError"(attrName: string, newValue: string): void;
838
838
  init(): Promise<void>;
839
- "__#24334@#observeMappings": {};
839
+ "__#27127@#observeMappings": {};
840
840
  observeAttribute(attrName: string, onAttrChange: (attrName: string, value: string) => void): () => any;
841
841
  observeAttributes(attrs: string[], cb: (attrName: string, value: string) => void): () => void;
842
- "__#24333@#isInit": boolean;
843
- "__#24332@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
844
- "__#24332@#wrapLogger": ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger);
842
+ "__#27126@#isInit": boolean;
843
+ "__#27125@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
844
+ "__#27125@#wrapLogger": ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger);
845
845
  get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
846
846
  set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
847
847
  onLogEvent: ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void);
848
848
  }) & (new (...params: any[]) => {
849
- "__#24346@#globalStyleTag": HTMLStyleElement;
849
+ "__#27140@#globalStyleTag": HTMLStyleElement;
850
850
  readonly theme: _descope_sdk_mixins_static_resources_mixin.ThemeOptions;
851
851
  readonly styleId: string;
852
- "__#24346@#_themeResource": Promise<void | Record<string, any>>;
853
- "__#24346@#fetchTheme"(): Promise<Record<string, any>>;
854
- readonly "__#24346@#themeResource": Promise<void | Record<string, any>>;
855
- "__#24346@#loadGlobalStyle"(): Promise<void>;
856
- "__#24346@#loadComponentsStyle"(): Promise<void>;
857
- "__#24346@#getFontsConfig"(): Promise<Record<string, {
852
+ "__#27140@#_themeResource": Promise<void | Record<string, any>>;
853
+ "__#27140@#fetchTheme"(): Promise<Record<string, any>>;
854
+ readonly "__#27140@#themeResource": Promise<void | Record<string, any>>;
855
+ "__#27140@#loadGlobalStyle"(): Promise<void>;
856
+ "__#27140@#loadComponentsStyle"(): Promise<void>;
857
+ "__#27140@#getFontsConfig"(): Promise<Record<string, {
858
858
  url?: string;
859
859
  }>>;
860
- "__#24346@#loadFonts"(): Promise<void>;
861
- "__#24346@#applyTheme"(): Promise<void>;
862
- "__#24346@#onThemeChange": () => void;
863
- "__#24346@#loadTheme"(): void;
864
- "__#24346@#toggleOsThemeChangeListener": (listen: boolean) => void;
860
+ "__#27140@#loadFonts"(): Promise<void>;
861
+ "__#27140@#applyTheme"(): Promise<void>;
862
+ "__#27140@#onThemeChange": () => void;
863
+ "__#27140@#loadTheme"(): void;
864
+ "__#27140@#toggleOsThemeChangeListener": (listen: boolean) => void;
865
865
  init(): Promise<void>;
866
- "__#24334@#observeMappings": {};
867
- observeAttribute: ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any);
868
- observeAttributes: ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void);
869
- "__#24333@#isInit": boolean;
870
- connectedCallback: (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void);
866
+ "__#27127@#observeMappings": {};
867
+ observeAttribute: ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any);
868
+ observeAttributes: ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void);
869
+ "__#27126@#isInit": boolean;
870
+ connectedCallback: (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void);
871
871
  accessKey: string;
872
872
  readonly accessKeyLabel: string;
873
873
  autocapitalize: string;
@@ -1193,29 +1193,24 @@ declare const BaseClass: {
1193
1193
  tabIndex: number;
1194
1194
  blur(): void;
1195
1195
  focus(options?: FocusOptions): void;
1196
- "__#24332@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
1197
- "__#24332@#wrapLogger": ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger);
1196
+ "__#27125@#logger": _descope_sdk_mixins_static_resources_mixin.Logger;
1197
+ "__#27125@#wrapLogger": ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger) & ((logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>) => _descope_sdk_mixins_static_resources_mixin.Logger);
1198
1198
  get logger(): _descope_sdk_mixins_static_resources_mixin.Logger;
1199
1199
  set logger(logger: Partial<_descope_sdk_mixins_static_resources_mixin.Logger>);
1200
- onLogEvent: ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void);
1200
+ onLogEvent: ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void) & ((logLevel: "error" | "warn" | "info" | "debug", data: any[]) => void);
1201
1201
  contentRootElement: HTMLElement;
1202
1202
  rootElement: HTMLElement;
1203
- readonly config: any;
1204
- "__#24337@#_configResource": any;
1205
- "__#24337@#fetchConfig": (() => Promise<{
1206
- projectConfig: _descope_sdk_mixins_static_resources_mixin.ProjectConfiguration;
1207
- executionContext: {
1208
- geo: any;
1209
- };
1210
- }>) & (() => Promise<{
1211
- projectConfig: _descope_sdk_mixins_static_resources_mixin.ProjectConfiguration;
1212
- executionContext: {
1213
- geo: any;
1214
- };
1215
- }>);
1216
- "__#24336@#lastBaseUrl"?: string;
1217
- "__#24336@#workingBaseUrl"?: string;
1218
- "__#24336@#getResourceUrls": ((filename: string) => (URL & {
1203
+ readonly config: Promise<_descope_sdk_mixins_static_resources_mixin.Config>;
1204
+ "__#27131@#configCacheClear": (() => void) & (() => void);
1205
+ "__#27131@#_configResource": Promise<_descope_sdk_mixins_static_resources_mixin.Config>;
1206
+ "__#27131@#fetchConfig": (() => Promise<_descope_sdk_mixins_static_resources_mixin.Config>) & (() => Promise<_descope_sdk_mixins_static_resources_mixin.Config>);
1207
+ "__#27130@#callbacks": Map<string, () => void> & Map<string, () => void>;
1208
+ onReset: ((sectionId: string, callback: () => void | Promise<void>) => () => void) & ((sectionId: string, callback: () => void | Promise<void>) => () => void);
1209
+ reset: ((...sectionIds: string[]) => Promise<void>) & ((...sectionIds: string[]) => Promise<void>);
1210
+ "__#27128@#handleError": ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void);
1211
+ "__#27129@#lastBaseUrl"?: string;
1212
+ "__#27129@#workingBaseUrl"?: string;
1213
+ "__#27129@#getResourceUrls": ((filename: string) => (URL & {
1219
1214
  baseUrl: string;
1220
1215
  }) | (URL & {
1221
1216
  baseUrl: string;
@@ -1241,19 +1236,19 @@ declare const BaseClass: {
1241
1236
  readonly baseStaticUrl: string;
1242
1237
  readonly baseUrl: string;
1243
1238
  readonly projectId: string;
1244
- "__#24335@#handleError": ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void);
1245
- "__#24340@#errorCbsSym": symbol;
1246
- "__#24340@#loadCbsSym": symbol;
1247
- "__#24340@#getComponentsVersion"(): Promise<any>;
1248
- "__#24340@#exposeAlternateEvents"(scriptEle: HTMLScriptElement): void;
1249
- "__#24340@#handleFallbackScript"(errorCbs: ((error: string) => void)[], loadCbs: (() => void)[], elemId: string, scriptUrl: string): Promise<void>;
1250
- "__#24340@#registerEvents"(scriptEle: HTMLScriptElement): void;
1251
- "__#24340@#getDescopeUiLoadingScript"(): Promise<HTMLElement>;
1252
- "__#24340@#descopeUi": Promise<any>;
1239
+ "__#27134@#errorCbsSym": symbol;
1240
+ "__#27134@#loadCbsSym": symbol;
1241
+ "__#27134@#getComponentsVersion"(): Promise<string>;
1242
+ "__#27134@#exposeAlternateEvents"(scriptEle: HTMLScriptElement): void;
1243
+ "__#27134@#handleFallbackScript"(errorCbs: ((error: string) => void)[], loadCbs: (() => void)[], elemId: string, scriptUrl: string): Promise<void>;
1244
+ "__#27134@#registerEvents"(scriptEle: HTMLScriptElement): void;
1245
+ "__#27134@#getDescopeUiLoadingScript"(): Promise<HTMLElement>;
1246
+ "__#27134@#descopeUi": Promise<any>;
1253
1247
  readonly descopeUi: Promise<any>;
1254
- "__#24340@#loadDescopeUiComponent"(componentName: string): Promise<any>;
1248
+ "__#27134@#loadDescopeUiComponent"(componentName: string): Promise<any>;
1255
1249
  loadDescopeUiComponents(templateOrComponentNames: string[] | HTMLTemplateElement): Promise<any[]>;
1256
- "__#24340@#getDescopeUi"(): Promise<unknown>;
1250
+ "__#27134@#getDescopeUi"(): Promise<unknown>;
1251
+ readonly baseCdnUrl: string;
1257
1252
  }) & {
1258
1253
  new (): HTMLElement;
1259
1254
  prototype: HTMLElement;
@@ -1294,19 +1289,9 @@ declare class BaseDescopeWc extends BaseClass {
1294
1289
  get formConfigValues(): {
1295
1290
  [k: string]: any;
1296
1291
  };
1297
- getConfig: (() => Promise<{
1298
- projectConfig: ProjectConfiguration;
1299
- executionContext: {
1300
- geo: string;
1301
- };
1302
- isMissingConfig?: undefined;
1303
- } | {
1292
+ getConfig: () => Promise<_descope_sdk_mixins_static_resources_mixin.Config | {
1304
1293
  isMissingConfig: boolean;
1305
- projectConfig?: undefined;
1306
- executionContext?: undefined;
1307
- }>) & {
1308
- reset: () => void;
1309
- };
1294
+ }>;
1310
1295
  get isRestartOnError(): boolean;
1311
1296
  getExecutionContext(): Promise<{
1312
1297
  geo: string;
@@ -1314,7 +1299,7 @@ declare class BaseDescopeWc extends BaseClass {
1314
1299
  getProjectConfig(): Promise<ProjectConfiguration>;
1315
1300
  getFlowConfig(): Promise<FlowConfig>;
1316
1301
  getTargetLocales(): Promise<string[]>;
1317
- getComponentsVersion(): Promise<string>;
1302
+ getComponentsVersion(): Promise<{}>;
1318
1303
  static descopeUI: any;
1319
1304
  init(): Promise<void>;
1320
1305
  disconnectedCallback(): void;
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- !function(){"use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}function n(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((o=o.apply(t,e||[])).next())}))}function o(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)}function i(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.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,o=t.split(".")[n];if("string"!=typeof o)throw new r(`Invalid token specified: missing part #${n+1}`);let i;try{i=s(o)}catch(t){throw new r(`Invalid token specified: invalid base64 for part #${n+1} (${t.message})`)}try{return JSON.parse(i)}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",O="/v1/auth/oauth/exchange",j="v1/auth/oauth/native/start",A="v1/auth/oauth/native/finish",U="/v1/auth/saml/authorize",E="/v1/auth/saml/exchange",L="/v1/auth/totp/verify",R="/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"},q={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},W={start:"/v1/auth/webauthn/signup-in/start"},N={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 ot="<region>",it=`https://api.${ot}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:o})=>{const i=o.slice(1,-27);e=e.replace(ot,i?i+".":"");let r=t?`${e.replace(/\/$/,"")}/${null==t?void 0:t.replace(/^\//,"")}`:e;if(n){const t=Object.keys(n);t.forEach(((e,o)=>{r=`${r}${0===o?"?":""}${e}=${encodeURIComponent(n[e])}${o===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,o])=>(t[n]=o,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:o,hooks:i,cookiePolicy:r,fetch:s})=>{const a=((t,e)=>{const n=(t=>async(...e)=>{const n=await t(...e),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),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 o=await n(...e);return t[o.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()})(o)),o}:n})(o,s),l=async o=>{var s;const l=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{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.33.5"},(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==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==m?void 0:m.clone()),null==i?void 0:i.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,o]=e.split("=");return Object.assign(Object.assign({},t),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},m),{json:()=>Promise.resolve(t),cookies:e});return n.clone=()=>n,i.transformResponse(n)}return m};return{get:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:dt.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:dt.post,token:i}),patch:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:dt.patch,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:dt.put,token:i}),delete:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:dt.delete,token:o}),hooks:i,buildUrl:(n,o)=>ut({projectId:e,baseUrl:t,path:n,queryParams:o})}};var mt=429;function bt(t,e,n){var o;let i=wt(t);if(e){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[st])===e)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[e]}const r=null==i?void 0:i[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 o=await t,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=e?e(r):r:(i.error=r,o.status===mt&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Ot=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),jt=(t,e)=>(n=e)=>e=>{const o=t.filter((t=>t(e)));return!(o.length<t.length)&&(n?n.replace("{val}",e):o.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-]+)*$/),Lt=Ut(/^\+[1-9]{1}[0-9]{3,14}$/),Rt=Ot(Et,'"{val}" is not a valid email'),Tt=Ot(Lt,'"{val}" is not a valid phone number'),_t=Ot((t=>t.length>=1),"Minimum length is 1");const $t=Ot((t=>"string"==typeof t),"Input is not a string"),Pt=Ot((t=>Array.isArray(t)),"Input is not an array"),Mt=Ot((t=>"boolean"==typeof t),"Input is not a boolean"),Dt=Ot((t=>void 0===t),"Input is defined"),qt=jt([$t(),Dt()],"Input is not a string or undefined"),Wt=jt([Pt(),Mt()],"Input is not an array or boolean"),Nt=(...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`),Rt()],Kt=t=>[$t(`"${t}" must be a string`),Tt()],Ht=Nt(Bt("accessKey")),Gt=t=>({exchange:Ht(((e,n)=>xt(t.post(l,{loginOptions:n},{token:e}))))}),Jt=(t,e,n)=>(e.forEach((e=>{const o=e.split(".");let i=o.shift(),r=t;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${e}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${e}" is not a function`);const s=r[i];r[i]=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=Nt(Bt("token")),ne=Nt(te),oe=Nt(Bt("pendingRef")),ie=Nt(te,Vt("email")),re=t=>({verify:ee((e=>xt(t.post(w,{token:e})))),signIn:ne(((e,n,o,i)=>xt(t.post(Ct(y,Zt.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:ne(((e,n,o)=>xt(t.post(Ct(C,Zt.email),{loginId:e,URI:n,loginOptions:o})))),signUp:ne(((e,n,o,i)=>xt(t.post(Ct(k,Zt.email),{loginId:e,URI:n,user:o,loginOptions:i})))),waitForSession:oe(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,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),o(xt(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:ie(((e,n,o,i,r)=>xt(t.post(S.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i}))))}}),se=Nt(Bt("flowId")),ae=Nt(Bt("executionId"),Bt("stepId"),Bt("interactionId")),le=t=>({start:se(((e,n,o,i,r,s,a)=>xt(t.post(et,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a})))),next:ae(((e,n,o,i,r,s)=>xt(t.post(nt,{executionId:e,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),ce=Bt("loginId"),de=Nt(Bt("token")),ue=Nt(ce),he=Nt(ce,Kt("phone")),pe=Nt(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,o,i,r)=>xt(t.post(Ct(g,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:fe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,o,i,r)=>xt(t.post(Ct(v,n),{loginId:e,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:fe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,o,i)=>xt(t.post(Ct(b,n),{loginId:e,URI:o,loginOptions:i}))))})),{}),update:{email:pe(((e,n,o,i,r)=>xt(t.post(m.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i})))),phone:Object.keys(Xt).filter((t=>t!==Xt.voice)).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:he(((e,o,i,r,s)=>xt(t.post(Ct(m.phone,n),Object.assign({loginId:e,phone:o,URI:i},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=Nt(Bt("code")),be=t=>({start:Object.assign(((e,n,o,i)=>xt(t.post(x,o||{},{queryParams:Object.assign({provider:e},n&&{redirectURL:n}),token:i}))),Object.keys(ve).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,i)=>xt(t.post(x,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i}))})),{})),exchange:me((e=>xt(t.post(O,{code:e})))),startNative:(e,n,o)=>xt(t.post(j,{provider:e,loginOptions:n,implicit:o})),finishNative:(e,n,o,i,r)=>xt(t.post(A,{provider:e,stateId:n,user:o,code:i,idToken:r}))}),we=Bt("loginId"),ye=Nt(we,Bt("code")),ke=Nt(we),Ie=Nt(we,Kt("phone")),Se=Nt(we,Vt("email")),Ce=t=>({verify:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ye(((e,o)=>xt(t.post(Ct(c,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,o,i)=>xt(t.post(Ct(d,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,o,i)=>xt(t.post(Ct(u,n),{loginId:e,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,o)=>xt(t.post(Ct(p,n),{loginId:e,loginOptions:o}))))})),{}),update:{email:Se(((e,n,o,i)=>xt(t.post(h.email,Object.assign({loginId:e,email:n},i),{token:o})))),phone:Object.keys(Xt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Ie(((e,o,i,r)=>xt(t.post(Ct(h.phone,n),Object.assign({loginId:e,phone:o},r),{token:i}))))})),{})}}),xe=Nt(Bt("tenant")),Oe=Nt(Bt("code")),je=t=>({start:xe(((e,n,o,i)=>xt(t.post(U,o||{},{queryParams:{tenant:e,redirectURL:n},token:i})))),exchange:Oe((e=>xt(t.post(E,{code:e}))))}),Ae=Bt("loginId"),Ue=Nt(Ae,Bt("code")),Ee=Nt(Ae),Le=Nt(Ae),Re=t=>({signUp:Ee(((e,n)=>xt(t.post(R,{loginId:e,user:n})))),verify:Ue(((e,n,o,i)=>xt(t.post(L,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Le(((e,n)=>xt(t.post(T,{loginId:e},{token:n}))))}),Te=Bt("loginId"),_e=Bt("newPassword"),$e=Nt(Te,Bt("password")),Pe=Nt(Te),Me=Nt(Te,_e),De=Nt(Te,Bt("oldPassword"),_e),qe=t=>({signUp:$e(((e,n,o,i)=>xt(t.post(F,{loginId:e,password:n,user:o,loginOptions:i})))),signIn:$e(((e,n,o)=>xt(t.post(B,{loginId:e,password:n,loginOptions:o})))),sendReset:Pe(((e,n,o)=>xt(t.post(V,{loginId:e,redirectUrl:n,templateOptions:o})))),update:Me(((e,n,o)=>xt(t.post(K,{loginId:e,newPassword:n},{token:o})))),replace:De(((e,n,o)=>xt(t.post(H,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>xt(t.get(G))}),We=Ft("loginId"),Ne=Bt("loginId"),Fe=Bt("origin"),Be=Nt(Ne,Fe,Bt("name")),Ve=Nt(Ne,Fe),Ke=Nt(We,Fe),He=Nt(Ne,Fe,Bt("token")),Ge=Nt(Bt("transactionId"),Bt("response")),Je=t=>({signUp:{start:Be(((e,n,o,i)=>xt(t.post(D.start,{user:{loginId:e,name:o},origin:n,passkeyOptions:i})))),finish:Ge(((e,n)=>xt(t.post(D.finish,{transactionId:e,response:n}))))},signIn:{start:Ke(((e,n,o,i,r)=>xt(t.post(q.start,{loginId:e,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:Ge(((e,n)=>xt(t.post(q.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Ve(((e,n,o)=>xt(t.post(W.start,{loginId:e,origin:n,passkeyOptions:o}))))},update:{start:He(((e,n,o,i)=>xt(t.post(N.start,{loginId:e,origin:n,passkeyOptions:i},{token:o})))),finish:Ge(((e,n)=>xt(t.post(N.finish,{transactionId:e,response:n}))))}}),ze=Ft("loginId"),Xe=Nt(ze),Qe=Nt(Bt("pendingRef")),Ze=t=>({signUpOrIn:Xe(((e,n)=>xt(t.post(P,{loginId:e,loginOptions:n})))),signUp:Xe(((e,n,o)=>xt(t.post($,{loginId:e,user:n,loginOptions:o})))),signIn:Xe(((e,n,o)=>xt(t.post(_,{loginId:e,loginOptions:n},{token:o})))),waitForSession:Qe(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,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),o(xt(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Ye=Nt(Bt("token")),tn=Nt([qt('"token" must be string or undefined')]);var en,nn=Nt([(en=Bt("projectId"),Ot(((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("."),o=n.length;let i=0,r=t===Object(t)?t:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,t)))("projectId",en))())])((t=>{var e;return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=vt({baseUrl:n||it,projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:Gt(a),otp:Ce(a),magicLink:ge(a),enchantedLink:re(a),oauth:be(a),saml:je(a),totp:Re(a),notp:Ze(a),webauthn:Je(a),password:qe(a),flow:le(a),refresh:tn(((t,e)=>xt(a.post(J,{},{token:t,queryParams:e})))),selectTenant:Nt([$t("tenantId")],[qt('"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:Nt([Wt('"tenants" must a string array or a boolean')],[qt('"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 o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((t,e)=>e(t)),e)},afterRequest:async(e,n)=>{var o;const i=[].concat((null===(o=t.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.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});
1
+ !function(){"use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}function n(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((o=o.apply(t,e||[])).next())}))}function o(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)}function i(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.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,o=t.split(".")[n];if("string"!=typeof o)throw new r(`Invalid token specified: missing part #${n+1}`);let i;try{i=s(o)}catch(t){throw new r(`Invalid token specified: invalid base64 for part #${n+1} (${t.message})`)}try{return JSON.parse(i)}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",C={email:"/v1/auth/enchantedlink/update/email"},S="/v1/auth/enchantedlink/signup-in",x="/v1/auth/oauth/authorize",O="/v1/auth/oauth/exchange",j="v1/auth/oauth/native/start",A="v1/auth/oauth/native/finish",U="/v1/auth/saml/authorize",E="/v1/auth/saml/exchange",L="/v1/auth/totp/verify",R="/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"},q={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},W={start:"/v1/auth/webauthn/signup-in/start"},N={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 ot="<region>",it=`https://api.${ot}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:o})=>{const i=o.slice(1,-27);e=e.replace(ot,i?i+".":"");let r=t?`${e.replace(/\/$/,"")}/${null==t?void 0:t.replace(/^\//,"")}`:e;if(n){const t=Object.keys(n);t.forEach(((e,o)=>{r=`${r}${0===o?"?":""}${e}=${encodeURIComponent(n[e])}${o===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,o])=>(t[n]=o,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:o,hooks:i,cookiePolicy:r,fetch:s})=>{const a=((t,e)=>{const n=(t=>async(...e)=>{const n=await t(...e),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),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 o=await n(...e);return t[o.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()})(o)),o}:n})(o,s),l=async o=>{var s;const l=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{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.33.6"},(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==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==m?void 0:m.clone()),null==i?void 0:i.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,o]=e.split("=");return Object.assign(Object.assign({},t),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},m),{json:()=>Promise.resolve(t),cookies:e});return n.clone=()=>n,i.transformResponse(n)}return m};return{get:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:dt.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:dt.post,token:i}),patch:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:dt.patch,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:dt.put,token:i}),delete:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:dt.delete,token:o}),hooks:i,buildUrl:(n,o)=>ut({projectId:e,baseUrl:t,path:n,queryParams:o})}};var mt=429;function bt(t,e,n){var o;let i=wt(t);if(e){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[st])===e)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[e]}const r=null==i?void 0:i[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 Ct(t,e){return bt(t,e,"roles")}const St=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function xt(t,e){var n;const o=await t,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=e?e(r):r:(i.error=r,o.status===mt&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Ot=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),jt=(t,e)=>(n=e)=>e=>{const o=t.filter((t=>t(e)));return!(o.length<t.length)&&(n?n.replace("{val}",e):o.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-]+)*$/),Lt=Ut(/^\+[1-9]{1}[0-9]{3,14}$/),Rt=Ot(Et,'"{val}" is not a valid email'),Tt=Ot(Lt,'"{val}" is not a valid phone number'),_t=Ot((t=>t.length>=1),"Minimum length is 1");const $t=Ot((t=>"string"==typeof t),"Input is not a string"),Pt=Ot((t=>Array.isArray(t)),"Input is not an array"),Mt=Ot((t=>"boolean"==typeof t),"Input is not a boolean"),Dt=Ot((t=>void 0===t),"Input is defined"),qt=jt([$t(),Dt()],"Input is not a string or undefined"),Wt=jt([Pt(),Mt()],"Input is not an array or boolean"),Nt=(...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`),Rt()],Kt=t=>[$t(`"${t}" must be a string`),Tt()],Ht=Nt(Bt("accessKey")),Gt=t=>({exchange:Ht(((e,n)=>xt(t.post(l,{loginOptions:n},{token:e}))))}),Jt=(t,e,n)=>(e.forEach((e=>{const o=e.split(".");let i=o.shift(),r=t;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${e}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${e}" is not a function`);const s=r[i];r[i]=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=Nt(Bt("token")),ne=Nt(te),oe=Nt(Bt("pendingRef")),ie=Nt(te,Vt("email")),re=t=>({verify:ee((e=>xt(t.post(w,{token:e})))),signIn:ne(((e,n,o,i)=>xt(t.post(St(y,Zt.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:ne(((e,n,o)=>xt(t.post(St(S,Zt.email),{loginId:e,URI:n,loginOptions:o})))),signUp:ne(((e,n,o,i)=>xt(t.post(St(k,Zt.email),{loginId:e,URI:n,user:o,loginOptions:i})))),waitForSession:oe(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,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),o(xt(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:ie(((e,n,o,i,r)=>xt(t.post(C.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i}))))}}),se=Nt(Bt("flowId")),ae=Nt(Bt("executionId"),Bt("stepId"),Bt("interactionId")),le=t=>({start:se(((e,n,o,i,r,s,a)=>xt(t.post(et,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a})))),next:ae(((e,n,o,i,r,s)=>xt(t.post(nt,{executionId:e,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),ce=Bt("loginId"),de=Nt(Bt("token")),ue=Nt(ce),he=Nt(ce,Kt("phone")),pe=Nt(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,o,i,r)=>xt(t.post(St(g,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:fe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,o,i,r)=>xt(t.post(St(v,n),{loginId:e,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:fe.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ue(((e,o,i)=>xt(t.post(St(b,n),{loginId:e,URI:o,loginOptions:i}))))})),{}),update:{email:pe(((e,n,o,i,r)=>xt(t.post(m.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i})))),phone:Object.keys(Xt).filter((t=>t!==Xt.voice)).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:he(((e,o,i,r,s)=>xt(t.post(St(m.phone,n),Object.assign({loginId:e,phone:o,URI:i},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=Nt(Bt("code")),be=t=>({start:Object.assign(((e,n,o,i)=>xt(t.post(x,o||{},{queryParams:Object.assign({provider:e},n&&{redirectURL:n}),token:i}))),Object.keys(ve).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,i)=>xt(t.post(x,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i}))})),{})),exchange:me((e=>xt(t.post(O,{code:e})))),startNative:(e,n,o)=>xt(t.post(j,{provider:e,loginOptions:n,implicit:o})),finishNative:(e,n,o,i,r)=>xt(t.post(A,{provider:e,stateId:n,user:o,code:i,idToken:r}))}),we=Bt("loginId"),ye=Nt(we,Bt("code")),ke=Nt(we),Ie=Nt(we,Kt("phone")),Ce=Nt(we,Vt("email")),Se=t=>({verify:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ye(((e,o)=>xt(t.post(St(c,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,o,i)=>xt(t.post(St(d,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,o,i)=>xt(t.post(St(u,n),{loginId:e,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(Zt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ke(((e,o)=>xt(t.post(St(p,n),{loginId:e,loginOptions:o}))))})),{}),update:{email:Ce(((e,n,o,i)=>xt(t.post(h.email,Object.assign({loginId:e,email:n},i),{token:o})))),phone:Object.keys(Xt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Ie(((e,o,i,r)=>xt(t.post(St(h.phone,n),Object.assign({loginId:e,phone:o},r),{token:i}))))})),{})}}),xe=Nt(Bt("tenant")),Oe=Nt(Bt("code")),je=t=>({start:xe(((e,n,o,i)=>xt(t.post(U,o||{},{queryParams:{tenant:e,redirectURL:n},token:i})))),exchange:Oe((e=>xt(t.post(E,{code:e}))))}),Ae=Bt("loginId"),Ue=Nt(Ae,Bt("code")),Ee=Nt(Ae),Le=Nt(Ae),Re=t=>({signUp:Ee(((e,n)=>xt(t.post(R,{loginId:e,user:n})))),verify:Ue(((e,n,o,i)=>xt(t.post(L,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Le(((e,n)=>xt(t.post(T,{loginId:e},{token:n}))))}),Te=Bt("loginId"),_e=Bt("newPassword"),$e=Nt(Te,Bt("password")),Pe=Nt(Te),Me=Nt(Te,_e),De=Nt(Te,Bt("oldPassword"),_e),qe=t=>({signUp:$e(((e,n,o,i)=>xt(t.post(F,{loginId:e,password:n,user:o,loginOptions:i})))),signIn:$e(((e,n,o)=>xt(t.post(B,{loginId:e,password:n,loginOptions:o})))),sendReset:Pe(((e,n,o)=>xt(t.post(V,{loginId:e,redirectUrl:n,templateOptions:o})))),update:Me(((e,n,o)=>xt(t.post(K,{loginId:e,newPassword:n},{token:o})))),replace:De(((e,n,o)=>xt(t.post(H,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>xt(t.get(G))}),We=Ft("loginId"),Ne=Bt("loginId"),Fe=Bt("origin"),Be=Nt(Ne,Fe,Bt("name")),Ve=Nt(Ne,Fe),Ke=Nt(We,Fe),He=Nt(Ne,Fe,Bt("token")),Ge=Nt(Bt("transactionId"),Bt("response")),Je=t=>({signUp:{start:Be(((e,n,o,i)=>xt(t.post(D.start,{user:{loginId:e,name:o},origin:n,passkeyOptions:i})))),finish:Ge(((e,n)=>xt(t.post(D.finish,{transactionId:e,response:n}))))},signIn:{start:Ke(((e,n,o,i,r)=>xt(t.post(q.start,{loginId:e,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:Ge(((e,n)=>xt(t.post(q.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Ve(((e,n,o)=>xt(t.post(W.start,{loginId:e,origin:n,passkeyOptions:o}))))},update:{start:He(((e,n,o,i)=>xt(t.post(N.start,{loginId:e,origin:n,passkeyOptions:i},{token:o})))),finish:Ge(((e,n)=>xt(t.post(N.finish,{transactionId:e,response:n}))))}}),ze=Ft("loginId"),Xe=Nt(ze),Qe=Nt(Bt("pendingRef")),Ze=t=>({signUpOrIn:Xe(((e,n)=>xt(t.post(P,{loginId:e,loginOptions:n})))),signUp:Xe(((e,n,o)=>xt(t.post($,{loginId:e,user:n,loginOptions:o})))),signIn:Xe(((e,n,o)=>xt(t.post(_,{loginId:e,loginOptions:n},{token:o})))),waitForSession:Qe(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,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),o(xt(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Ye=Nt(Bt("token")),tn=Nt([qt('"token" must be string or undefined')]);var en,nn=Nt([(en=Bt("projectId"),Ot(((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("."),o=n.length;let i=0,r=t===Object(t)?t:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,t)))("projectId",en))())])((t=>{var e;return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=vt({baseUrl:n||it,projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:Gt(a),otp:Se(a),magicLink:ge(a),enchantedLink:re(a),oauth:be(a),saml:je(a),totp:Re(a),notp:Ze(a),webauthn:Je(a),password:qe(a),flow:le(a),refresh:tn(((t,e)=>xt(a.post(J,{},{token:t,queryParams:e})))),selectTenant:Nt([$t("tenantId")],[qt('"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:Nt([Wt('"tenants" must a string array or a boolean')],[qt('"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(Ct),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>{var n;const o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((t,e)=>e(t)),e)},afterRequest:async(e,n)=>{var o;const i=[].concat((null===(o=t.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.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 o in n)t[o]=n[o]}return t}var sn=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=rn({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=t+"="+e.write(o,t)+r}}return Object.create({set:o,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=e.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}},remove:function(t,e){o(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,o,i,r,s,a=[],l=(n=function(t){var e=function(t,e,n){if(n||2===arguments.length)for(var o,i=0,r=e.length;i<r;i++)!o&&i in e||(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||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,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=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&&!i.has(l)&&(i.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()+o()-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,o=function(e){return a.push({url:t,startedAt:n,finishedAt:new Date,error:e})},i=e(t);return i.then((function(){return o()}),o),i.catch((function(t){if(null!=s||(s=t),a.length>=5)throw s;var e=d(n,t);if(!e)throw s;var o,i=e[0],r=e[1];return(o=r,new Promise((function(t){return setTimeout(t,o)}))).then((function(){return u(i)}))}))};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 o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=e(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:pn,c=function(){var t=[],e=function(){t.push({time:new Date,state:document.visibilityState})},n=function(t,e,n,o){return t.addEventListener(e,n,o),function(){return t.removeEventListener(e,n,o)}}(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],o=e[1];return u(),n.load(t(t({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function vn(t){return function(t,e,n,o){var i,r=document,s="securitypolicyviolation",a=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,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return null==o||o.then(l,l),Promise.resolve().then(e).then((function(t){return l(),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(l(),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 o=document.createElement("script"),i=function(){var t;return null===(t=o.parentNode)||void 0===t?void 0:t.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),e()},o.onerror=function(){i(),n(new Error(dn))},o.async=!0,o.src=t,r.appendChild(o)}))}(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,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==o?void 0:o.configurable)?delete t[e]:o&&!o.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,o)=>{var i;return n[o]=[].concat((null===(i=t.hooks)||void 0===i?void 0:i[o])||[]).concat((null==e?void 0:e[o])||[]),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)},On="undefined"!=typeof window,jn=Math.pow(2,31)-1,An="DS",Un="DSR";function En(t=""){return Sn(`${t}${Un}`)||""}function Ln(t=""){return sn.get(An)||Sn(`${t}${An}`)||""}function Rn(t=""){Cn(`${t}${Un}`),Cn(`${t}${An}`),sn.remove(An)}const Tn=On&&(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),o=new URL(e);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(e);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=gn({apiKey:t,endpoint:[o.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)}},qn=t=>{const e=Mn(!0);return e&&t.body&&(t.body.fpData=e),t},Wn="dls_last_user_login_id",Nn="dls_last_user_display_name",Fn=()=>Sn(Wn),Bn=()=>Sn(Nn),Vn=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=Fn(),r=Bn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.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(!On)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 to,eo=(to=t=>({async signUp(e,n,o){const i=await t.webauthn.signUp.start(e,window.location.origin,n,o);if(!i.ok)return i;const r=await Hn(i.data.options);return await t.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(e,n){const o=await t.webauthn.signIn.start(e,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await Gn(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(e,n){var o;const i=await t.webauthn.signUpOrIn.start(e,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const e=await Hn(i.data.options);return await t.webauthn.signUp.finish(i.data.transactionId,e)}{const e=await Gn(i.data.options);return await t.webauthn.signIn.finish(i.data.transactionId,e)}},async update(e,n,o){const i=await t.webauthn.update.start(e,window.location.origin,n,o);if(!i.ok)return i;const r=await Hn(i.data.options);return await t.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:Hn,get:Gn,isSupported:zn,conditional:Jn}}),(...t)=>{const e=to(...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 no="/fedcm/config",oo=(t,e)=>({async oneTap(e,n,o,i,r){const s=null!=e?e:"google",a=await t.oauth.startNative(s,o,!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 o,a;u.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,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(i&&(null==t?void 0:t.isSkippedMoment())){const e=null===(n=t.getSkippedReason)||void 0===n?void 0:n.call(t);null==i||i(e)}}))}))},async launch(n){var o;const i={identity:{context:n||"signin",providers:[{configURL:t.httpClient.buildUrl(e+no),clientId:e}]}},r=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(i));return t.refresh(r.token)},isSupported:()=>On&&"IdentityCredential"in window,async isLoggedIn(n){var o;const i=t.httpClient.buildUrl(e+no);try{const t={identity:{context:n||"signin",providers:[{configURL:i,clientId:e}]}},r=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(t));return!!r&&!!r.token}catch(t){return!1}}});var io=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await zn(),o=Object.assign(Object.assign({location:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return e[1]=o,t.flow.start(...e)}});const ro=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:o,fpLoad:i}=n,r=e(n,["fpKey","fpLoad"]);return On?(o&&i&&Dn(o).catch((()=>null)),t(bn(r,{beforeRequest:qn}))):t(r)}),(t=>n=>{var{autoRefresh:o}=n,i=e(n,["autoRefresh"]);if(!o)return t(i);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;On&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>l&&(xn("Expiration time passed, refreshing session"),d.refresh(En()||c))}));const d=t(bn(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await wn(e);if(401===(null==e?void 0:e.status))xn("Received 401, canceling all timers"),r();else if(o){if(l=(t=>{try{const e=a(t);if(e.exp)return new Date(1e3*e.exp)}catch(t){return null}})(o),!l)return void xn("Could not extract expiration time from session token");c=n;let t=((i=l)?i.getTime()-(new Date).getTime():0)-2e4;t>jn&&(xn(`Timeout is too large (${t}ms), setting it to ${jn}ms`),t=jn),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 i}}));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.8"},e.baseHeaders)}))),(t=>e=>{const n=Kn(),o=Kn(),i=t(bn(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await yn(e);t&&o.pub(t);const{sessionJwt:i}=await wn(e);i&&n.pub(i)}}})),r=Jt(i,["logout","logoutAll"],(t=>async(...e)=>{const i=await t(...e);return n.pub(null),o.pub(null),i}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(t=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=e(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(t(r),{getLastUserLoginId:Fn,getLastUserDisplayName:Bn});const s=t(bn(r,{afterRequest:async(t,e)=>{var n;const o=await yn(e),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((t=>{In(Wn,t)})(i),(t=>{In(Nn,t)})(r))}}));let a=Jt(s,["flow.start"],Vn);return a=Jt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return t||(Cn(Wn),Cn(Nn)),o})(i)),Object.assign(a,{getLastUserLoginId:Fn,getLastUserDisplayName:Bn})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=e(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!On)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 o=/^\/v\d+\/mgmt\//.test(t.path);401===(null==n?void 0:n.status)?o||Rn(r):((t={},n,o)=>{var{refreshJwt:i,sessionJwt:r}=t,s=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),i&&In(`${o}${Un}`,i),r&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i),s=function(t){const e=window.location.hostname.split("."),n=t.split(".");return e.slice(-n.length).join(".")===t}(o);sn.set(t,e,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(An,r,s):In(`${o}${An}`,r))})(await wn(n),i,r)}}));var l;const c=Jt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return Rn(t),o})(r));return Object.assign(c,{getRefreshToken:()=>En(r),getSessionToken:()=>Ln(r)})}))(((...t)=>{const e=on(...t);return Object.assign(Object.assign({},e),{refresh:t=>{const n=Ln();return e.refresh(t,{dcs:n?"t":"f"})},flow:io(e),webauthn:eo(e),fedcm:oo(e,t[0].projectId)})})),so="undefined"!=typeof localStorage,ao="J151000",lo=so&&localStorage.getItem("base.content.url")||"",co="config.json",uo="base.ui.components.url";so&&localStorage.getItem(uo),so&&localStorage.getItem(uo);const ho="descope-login-flow",po="code",fo="data-exclude-field",go="dls_last_auth",vo="state_id",mo="saml_idp_state_id",bo="saml_idp_username",wo="descope_idp_initiated",yo="sso_app_id",ko="third_party_app_id",Io="third_party_app_state_id",So="oidc_login_hint",Co="oidc_prompt",xo="oidc_error_redirect_uri",Oo="application_scopes",jo="data-type",Ao="redirect",Uo="poll",Eo="webauthnCreate",Lo="webauthnGet",Ro="nativeBridge",To="loadForm",_o="submit",$o="polling",Po=["descope-multi-select-combo-box","descope-text-area"];var Mo;!function(t){t.backward="backward",t.forward="forward"}(Mo||(Mo={}));const Do=["descope-enriched-text"];function qo(t){return new URLSearchParams(window.location.search).get(t)}function Wo(t){if(window.history.replaceState&&qo(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 No(t,e){if(!e)return;const n=+t,o=+e;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?Mo.forward:n<o?Mo.backward:void 0}const Fo=t=>{let[e="",n=""]=(qo(ho)||"").split("_");const o=(t=>{var e;return(null===(e=/(.*)\|#\|.*/.exec(t))||void 0===e?void 0:e[1])||""})(e);return(!t||o&&o!==t)&&(e="",n=""),{executionId:e,stepId:n,executionFlowId:o}};function Bo(){Wo(ho)}const Vo=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),Ko=(t,e)=>{const{executionId:n,stepId:o,executionFlowId:i}=Fo(t);if(i&&t!==i)return e.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&Bo();const r=qo("t")||void 0;r&&Wo("t");const s=qo(po)||void 0;s&&Wo(po);const a=qo("err")||void 0;a&&Wo("err");const{redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u}={redirectAuthCodeChallenge:qo("ra-challenge"),redirectAuthCallbackUrl:qo("ra-callback"),redirectAuthBackupCallbackUri:qo("ra-backup-callback"),redirectAuthInitiator:qo("ra-initiator")},h=qo(vo);h&&Wo(vo);const p=qo(mo);p&&Wo(mo);const f=qo(bo);p&&Wo(bo);const g=qo(wo);g&&Wo(wo);const v=qo(yo);v&&Wo(yo);const m=qo(ko);m&&Wo(ko);const b=qo(Io);b&&Wo(Io);const w=qo(Oo);w&&Wo(Oo);const y=qo(So);y&&Wo(So);const k=qo(Co);k&&Wo(Co);const I=qo(xo);I&&Wo(xo);return{executionId:n,stepId:o,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}}},Ho=t=>{let e,n;return Object.assign(((...o)=>{return e&&(r=o,(i=e).length===r.length&&i.every(((t,e)=>t===r[e])))||(e=o,n=t(...o)),n;var i,r}),{reset:()=>{e=void 0,n=void 0}})};function Go(t,e,n){return new Promise(((o,i)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?o(n):i(new Error(`Promise timed out after ${t} ms`))}),t);e.then((t=>{r||(clearTimeout(s),o(t))})).catch((t=>{r||(clearTimeout(s),i(t))}))}))}const Jo=(t,{oidcIdpStateId:e,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,thirdPartyAppId:l,thirdPartyAppStateId:c,applicationScopes:d})=>!(!t||e||n||o||i||r||s||a||l||c||d),zo=t=>null==t?void 0:t.submit(),Xo=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null},Qo=(t,e=100)=>{let n;return function(...o){n||t.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),e)}};function Zo(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:""}}var Yo,ti,ei,ni;function oi(t,e){const n=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=t[i],s=e[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!oi(r,s))return!1}else if(r!==s)return!1}return!0}class ii{constructor(t={},{updateOnlyOnChange:e=!0}={}){Yo.set(this,void 0),ti.set(this,{}),ei.set(this,0),ni.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,Yo,"f")):t,n=Object.assign(Object.assign({},o(this,Yo,"f")),e);if(!o(this,ni,"f")||!oi(o(this,Yo,"f"),n)){const t=o(this,Yo,"f");i(this,Yo,n,"f"),Object.freeze(o(this,Yo,"f")),setTimeout((()=>{Object.values(o(this,ti,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,Yo,t,"f"),i(this,ni,e,"f")}get current(){return Object.assign({},o(this,Yo,"f"))}subscribe(t){return i(this,ei,o(this,ei,"f")+1,"f"),o(this,ti,"f")[o(this,ei,"f")]=t,o(this,ei,"f").toString()}unsubscribe(t){const e=!!o(this,ti,"f")[t];return e&&delete o(this,ti,"f")[t],e}unsubscribeAll(){return i(this,ti,{},"f"),!0}}Yo=new WeakMap,ti=new WeakMap,ei=new WeakMap,ni=new WeakMap;const ri=["*","#","/","(",")","[","]","_","<",">","`"],si=t=>{const e=ri.map((e=>`${t}${e}`)).join("|");return new RegExp(`(${e})`,"g")},ai=["disabled"],li=(t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${fo}])`)).forEach((t=>{t.value=n}))}))},ci=(t,e)=>e.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),t),di=(t,e,n)=>t.replace(/{{(.+?)}}/g,((t,o)=>n?(t=>"string"!=typeof t?t:t.replace(si("\\"),"\\$1"))(ci(e,o)):ci(e,o))),ui=(t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{const n=(o=t.localName,Do.includes(o));var o;t.textContent=di(t.textContent,e,n);const i=t.getAttribute("href");i&&t.setAttribute("href",di(i,e))}))},hi=(t,e,n)=>{t.querySelectorAll(`[${jo}="${e}"]`).forEach((t=>{t.setAttribute("href",n)}))},pi=(t,e,n)=>{var o,i;const r=null===(o=customElements.get(e))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==t?void 0:t.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},fi=(t,e,n,o,i,r)=>{var s,a;let l=null==e?void 0:e.errorText;try{l=(null==i?void 0:i({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(`[${jo}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",l),hi(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),hi(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),ui(t,e),((t,e,n)=>{e&&Object.keys(e).forEach((o=>{t.querySelectorAll(`[name=${o}]`).forEach((t=>{const i=e[o];Object.keys(i).forEach((e=>{let o=i[e];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(t){n.error(`Could not stringify value "${o}" for "${e}"`,t.message),o=""}t.setAttribute(e,o)}))}))}))})(t,n,r),((t,e)=>{t.querySelectorAll("[data-has-dynamic-attr-values]").forEach((t=>{Array.from(t.attributes).forEach((t=>{t.value=di(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])=>{ai.includes(e)&&t.setAttribute(e,n)}))}))}))})(t,o)},gi=Ho((()=>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)))),o=(()=>{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 Go(100,n,o)}catch(t){return console.error("Conditional login check failed",t),!1}})))),vi=(t,e,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(e,("all"===o.left?t.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-t.offsetWidth),window.innerWidth-("all"===o.right?t.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?t.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-t.offsetHeight),window.innerHeight-("all"===o.bottom?t.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]},mi="dls_ab_testing_id",bi={"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 wi(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(go)))}catch(t){}return e}function yi(...t){return e=>t.reduce(((t,e)=>e(t)),e)}const ki=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 o=t(n);return o[e]=!0,o}},Ii=["error","warn","info","debug"],Si=ki((t=>{var e,n,r,s;return s=class extends t{constructor(){super(...arguments),e.add(this),n.set(this,o(this,e,"m",r).call(this,console))}set logger(t){i(this,n,o(this,e,"m",r).call(this,t||console),"f")}get logger(){return o(this,n,"f")}onLogEvent(t,e){}},n=new WeakMap,e=new WeakSet,r=function(t){return Ii.reduce(((e,n)=>(e[n]=(...e)=>{var o;this.onLogEvent(n,e),null===(o=t[n])||void 0===o||o.call(t,...e)},e)),{})},s})),Ci="undefined"!=typeof localStorage,xi=Ci&&localStorage.getItem("base.content.url")||"",Oi=(t,e)=>!e&&`${t} cannot be empty, please make sure to set this attribute`,ji=ki((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)&&o(this,e,"f")&&(i(this,e,!1,"f"),this.init())}async init(){}},e=new WeakMap,n})),Ai=ki((t=>{var e,n;const i=yi(Si,ji)(t);return n=class extends i{constructor(){super(...arguments),e.set(this,{})}async init(){var t,n,i;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),n=this,i=t=>{var n;null===(n=o(this,e,"f")[t])||void 0===n||n.forEach((e=>{e(t,this.getAttribute(t))}))},Array.from(n.attributes).forEach((t=>i(t.name))),new MutationObserver((t=>{t.forEach((t=>{"attributes"===t.type&&i(t.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(t,n){o(this,e,"f")[t]||(o(this,e,"f")[t]=[]);const i=o(this,e,"f")[t].push(n);return()=>o(this,e,"f")[t].splice(i,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})),Ui=t=>e=>{var n,i,r;const s=yi(Si,ji,Ai)(e),a=Object.keys(t);return r=class extends s{constructor(...t){super(...t),n.add(this),this.observeAttributes(a,o(this,n,"m",i).bind(this))}async init(){var t;a.forEach((t=>o(this,n,"m",i).call(this,t,this.getAttribute(t)))),await(null===(t=super.init)||void 0===t?void 0:t.call(this))}},n=new WeakSet,i=function(e,n){const o=t[e],i="function"==typeof o?o(e,n):o;i&&this.logger.error(i)},r};Ui.missingAttrValidator=Oi;const Ei=ki((t=>{const e=yi(Ui({"project-id":Oi}))(t);return class extends e{get projectId(){return this.getAttribute("project-id")}}})),Li=ki((t=>class extends t{get baseUrl(){return this.getAttribute("base-url")||""}})),Ri="Trying the next fallback URL...";function Ti({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:o="https://static.descope.com/pages"}){const i=new URL(o);return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,n,e),i.baseUrl=o,i}const _i=ki((t=>{var e,n,r,s,a;const l=yi(Si,Ei,Li)(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=o(this,e,"m",s).call(this,t),l=Array.isArray(a)?t=>{if(t!==a.length-1){const{baseUrl:e}=a[t];i(this,r,e,"f")}}:null;try{const t=await(async(t,e,{logger:n,onSuccess:o})=>{const i=Array.isArray(t)?t:[t];for(let t=0;t<i.length;t++){const r=i[t],s=t===i.length-1;try{const i=await fetch(r.toString(),e);if(i.ok)return null==o||o(t),i;const a=`Error fetching URL ${r} [${i.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${Ri}`)}catch(t){const e=`Error fetching URL ${r} [${t.message}]`;if(s)throw new Error(e);null==n||n.debug(`${e}. ${Ri}`)}}})(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=xi||this.baseStaticUrl;if(e)return Ti({projectId:this.projectId,filename:t,baseUrl:e});const s=o(this,n,"f")!==this.baseUrl,a=s&&!!this.baseUrl;s&&(i(this,n,this.baseUrl,"f"),i(this,r,void 0,"f"));const l=Ti({projectId:this.projectId,filename:t,baseUrl:o(this,r,"f")});if(!a)return l;return[Ti({projectId:this.projectId,filename:t,baseUrl:this.baseUrl+"/pages"}),l]},a})),$i=ki((t=>{var e,n,r;const s=yi(_i)(t);return r=class extends s{constructor(){super(...arguments),e.set(this,void 0),n.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")}}))}get config(){return o(this,e,"f")||i(this,e,o(this,n,"f").call(this),"f"),o(this,e,"f")}},e=new WeakMap,n=new WeakMap,r})),Pi="load-descope-ui",Mi="base.ui.components.url",Di=Ci&&localStorage.getItem(Mi)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",qi=Ci&&localStorage.getItem(Mi)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Wi=Ci&&localStorage.getItem(Mi)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Ni=t=>{const e=document.createElement("script");return e.id=t,e},Fi=(t,e)=>t.replace("<version>",e),Bi=ki((t=>{var e,n,r,s,a,l,c,d,u,h,p,f;const g=yi(Si,$i)(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 o(this,u,"f")||i(this,u,o(this,e,"m",p).call(this),"f"),o(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=>o(this,e,"m",h).call(this,t))))}},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=o(this,n,"f"),i=o(this,r,"f");t[e]=[],t[i]=[],Object.defineProperty(t,"onerror",{set(n){t[e].push(n)}}),Object.defineProperty(t,"onload",{set(e){t[i].push(e)}})},l=async function(t,n,i,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const a=Ni(i);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=Fi(r,await o(this,e,"m",s).call(this))},c=function(t){t.addEventListener("error",(()=>{t[o(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}"`))),o(this,e,"m",l).call(this,[o(this,e,"m",l).bind(this,t[o(this,n,"f")],t[o(this,r,"f")],"load-descope-ui-fallback-script-2",Wi),...t[o(this,n,"f")]],t[o(this,r,"f")],"load-descope-ui-fallback-script",qi)})),t.addEventListener("load",(()=>{t[o(this,r,"f")].forEach((t=>t()))}))},d=async function(){if(document.querySelector(`script#${Pi}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const t=Ni(Pi);document.body.append(t),o(this,e,"m",a).call(this,t),o(this,e,"m",c).call(this,t),t.src=Fi(Di,await o(this,e,"m",s).call(this))}return document.getElementById(Pi)},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),o(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})),Vi="content-root",Ki="root",Hi=ki((t=>class extends t{constructor(...t){var e,n;super(...t),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${Ki}, #${Vi} {\n height: 100%;\n }\n #${Ki} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${Ki}">\n <div id="${Vi}"></div>\n </div>\n `,this.contentRootElement=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById(Vi),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Ki)}})),Gi=(t,e)=>!!e&&"light"!==e&&"dark"!==e&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Ji=ki((t=>{var e,n,r,s,a,l,c,d,u,h,p,f,g,v;const m=yi(Ui({theme:Gi}),_i,ji,Bi,$i,Hi,Ai)(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,(()=>{o(this,e,"m",f).call(this),o(this,g,"f").call(this,"os"===this.getAttribute("theme"))})),g.set(this,(t=>{var n,i,r;const s=t?"addEventListener":"removeEventListener";null===(r=null===(i=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===i?void 0:i[s])||void 0===r||r.call(i,"change",(()=>o(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)),o(this,e,"m",l).call(this),o(this,e,"m",c).call(this),o(this,p,"f").call(this),this.observeAttributes(["theme"],o(this,p,"f")),this.observeAttributes(["style-id"],(()=>{i(this,r,null,"f"),o(this,e,"m",u).call(this),o(this,e,"m",l).call(this),o(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 o(this,r,"f")||(i(this,r,o(this,e,"m",s).call(this),"f"),o(this,r,"f").then((t=>this.logger.debug("Fetched theme",t)))),o(this,r,"f")},l=async function(){var t,r;const s=await o(this,e,"a",a);s&&(o(this,n,"f")||(i(this,n,document.createElement("style"),"f"),o(this,n,"f").id="global-style",this.shadowRoot.appendChild(o(this,n,"f"))),o(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 i=Object.assign({},await o(this,e,"a",a));if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(t=null==i?void 0:i.light)||void 0===t?void 0:t.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},d=async function(){var t,e;const{projectConfig:n}=await this.config||{},o=null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t[this.styleId],i=null==n?void 0:n.cssTemplate,r=o||i;return null===(e=null==r?void 0:r[this.theme])||void 0===e?void 0:e.fonts},u=async function(){const t=await o(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(){o(this,e,"m",u).call(this),o(this,e,"m",h).call(this)},v})),zi=(t,e="")=>Object.keys(t).reduce(((n,o)=>{var i;if("object"==typeof t[o]&&null!==t[o]&&!(null===(i=t[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),zi(t[o],`${e+o}.`));const r="object"==typeof t[o]?t[o]:{value:t[o]},s=Object.assign(Object.assign({},n),{[e+o]:r,[`form.${e}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${e}fullName`]:r,[`form.${e}fullName`]:r}):s}),[]),Xi=ki((t=>{var e,n,i,r;return r=class extends t{constructor(){super(...arguments),e.add(this)}connectedCallback(){var t;o(this,e,"m",n).call(this)&&o(this,e,"m",i).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)},i=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})),Qi=document.createElement("template");var Zi,Yi,tr,er,nr,or,ir,rr,sr,ar,lr,cr,dr,ur,hr,pr,fr,gr,vr,mr,br;Qi.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\t\t\ttransition: opacity 300ms ease-in-out;\n display: flex;\n\t\t}\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\t</style>\n\t";const wr=yi(Ji,_i,Xi)(HTMLElement);class yr extends wr{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(),Zi.add(this),tr.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(t,e="")=>{this.logger.error(t,e,new Error),o(this,Zi,"m",mr).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)}},er.set(this,new ii),nr.set(this,new ii),or.set(this,{}),this.getComponentsContext=()=>o(this,or,"f"),this.nextRequestStatus=new ii({isLoading:!1}),ir.set(this,void 0),rr.set(this,{popstate:o(this,Zi,"m",cr).bind(this),componentsContext:o(this,Zi,"m",fr).bind(this)}),sr.set(this,void 0),this.getConfig=Ho((()=>n(this,void 0,void 0,(function*(){try{const{body:t,headers:e}=yield this.fetchStaticResource(co,"json");return{projectConfig:t,executionContext:{geo:e["x-geo"]}}}catch(t){return{isMissingConfig:!0}}})))),i(this,sr,t,"f"),o(this,Zi,"m",ar).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 zi(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{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();return t}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var t,e;const n=yield this.getProjectConfig(),o=(null===(t=null==n?void 0:n.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=o.version)&&void 0!==e||(o.version=0),o}))}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,e;const n=null===(e=null===(t=yield this.getConfig())||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.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),o(this,nr,"f").subscribe(o(this,Zi,"m",vr).bind(this)),o(this,nr,"f").update({isDebug:this.debug}),o(this,Zi,"m",lr).call(this),yield o(this,Zi,"m",hr).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");if((yield this.getConfig()).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");o(this,Zi,"m",br).call(this);const{executionId:n,stepId:r,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,ssoQueryParams:p}=Ko(this.flowId,this.loggerWrapper);window.addEventListener("popstate",o(this,rr,"f").popstate),window.addEventListener("components-context",o(this,rr,"f").componentsContext),o(this,er,"f").subscribe(o(this,Zi,"m",ur).bind(this)),o(this,er,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:r,executionId:n,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h},p)),i(this,tr,!0,"f")}))}disconnectedCallback(){o(this,er,"f").unsubscribeAll(),o(this,nr,"f").unsubscribeAll(),o(this,Zi,"m",gr).call(this),window.removeEventListener("popstate",o(this,rr,"f").popstate),window.removeEventListener("components-context",o(this,rr,"f").componentsContext)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,tr,"f")&&e!==n&&Yi.observedAttributes.includes(t)){o(this,Zi,"m",lr).call(this);const i=null===e;o(this,er,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,Bo()),{[Vo(t)]:n,stepId:r,executionId:s}})),o(this,nr,"f").update({isDebug:this.debug})}}}function kr(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var Ir,Sr,Cr,xr,Or,jr,Ar,Ur,Er,Lr,Rr,Tr,_r,$r,Pr,Mr,Dr,qr,Wr,Nr,Fr,Br,Vr,Kr,Hr,Gr,Jr,zr,Xr,Qr,Zr,Yr,ts;Yi=yr,tr=new WeakMap,er=new WeakMap,nr=new WeakMap,or=new WeakMap,ir=new WeakMap,rr=new WeakMap,sr=new WeakMap,Zi=new WeakSet,ar=function(){this.shadowRoot.appendChild(Qi.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},lr=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"];Yi.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[Vo(e)])throw Error(`${e} cannot be empty`)}))},cr=function(){const{stepId:t,executionId:e}=Fo(this.flowId);o(this,er,"f").update({stepId:t,executionId:e})},dr=function(t,e){this.sdk=ro(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},Yi.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:ao,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},ur=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n}=t;if(i("projectId")||i("baseUrl")){if(!e)return;o(this,Zi,"m",dr).call(this,e,n)}o(this,sr,"f").call(this,t)}))},hr=function(){return n(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield o(this,Zi,"m",pr).call(this))}))},pr=function(){return n(this,void 0,void 0,(function*(){const t=function({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(lo||o||"https://static.descope.com/pages");return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,n,e),i.toString()}({projectId:this.projectId,filename:co,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||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}(t,"json"),!0}catch(t){return!1}}))},fr=function(t){i(this,or,Object.assign(Object.assign({},o(this,or,"f")),t.detail),"f")},gr=function(){var t;null===(t=o(this,ir,"f"))||void 0===t||t.remove(),i(this,ir,null,"f")},vr=function(t){return n(this,arguments,void 0,(function*({isDebug:t}){t?(i(this,ir,document.createElement("descope-debugger"),"f"),Object.assign(o(this,ir,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return is})),document.body.appendChild(o(this,ir,"f"))):o(this,Zi,"m",gr).call(this)}))},mr=function(t,e){var n;t&&this.debug&&(null===(n=o(this,ir,"f"))||void 0===n||n.updateData({title:t,description:e}))},br=function(){this.rootElement.onkeydown=t=>{var e,n,o;const i=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),r=Po.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==t.key||i||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()}}},yr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.32.10"}};class es extends yr{static set sdkConfigOverrides(t){yr.sdkConfigOverrides=t}static get sdkConfigOverrides(){return yr.sdkConfigOverrides}constructor(){const t=new ii({deferredRedirect:!1});super(t.update.bind(t)),Ir.add(this),this.stepState=new ii({},{updateOnlyOnChange:!1}),Sr.set(this,void 0),Cr.set(this,null),xr.set(this,{visibilitychange:o(this,Ir,"m",Or).bind(this)}),this.bridgeVersion=1,this.nativeResume=(t,e)=>{var n;const i=JSON.parse(e);if(this.logger.info(`nativeResume received payload of type '${t}'`),"oauthWeb"===t||"sso"===t){let{exchangeCode:t}=i;if(!t){t=null===(n=new URL(i.url).searchParams)||void 0===n?void 0:n.get(po)}this.nativeComplete({exchangeCode:t,idpInitiated:!0})}else if("magicLink"===t){const t=new URL(i.url),e=t.searchParams.get("t"),n=t.searchParams.get(ho).split("_").pop();o(this,Ur,"f").call(this),this.flowState.update({token:e,stepId:n,action:void 0})}else this.nativeComplete(i)},Ar.set(this,((t,e,r,s,a=!1)=>{if(this.flowState.current.action===Uo){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),c=a?500:2e3;i(this,Sr,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const i=this.sdk.flow.next(t,e,$o,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 Go(t,i)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void o(this,Ar,"f").call(this,t,e,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===ao)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,Ar,"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)),o(this,Er,"f").call(this,u),o(this,Ar,"f").call(this,t,e,r,s)}))),c),"f")}})),Ur.set(this,(()=>{clearTimeout(o(this,Sr,"f")),i(this,Sr,null,"f")})),Er.set(this,(t=>{var e,n,i,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===(i=null==t?void 0:t.response)||void 0===i?void 0:i.statusText}`;o(this,Ir,"m",Vr).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||o(this,Ir,"m",jr).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:o}=t;e&&this.loggerWrapper[e]?this.loggerWrapper[e](n,o):this.loggerWrapper.info(n,o)}));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)&&so&&localStorage.setItem(go,JSON.stringify(t))}(m),void o(this,Ir,"m",Vr).call(this,"success",v);const{executionId:b,stepId:w,stepName:y,action:k,screen:I,redirect:S,openInNewTabUrl:C,webauthn:x,error:O,samlIdpResponse:j,nativeResponse:A}=t.data;k!==Uo?(this.loggerWrapper.info(`Step "${y||`#${w}`}" is ${g}`,"",{screen:I,status:g,stepId:w,stepName:y,action:k,error:O}),this.flowState.update({stepId:w,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==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.relayState,nativeResponseType:null==A?void 0:A.type,nativePayload:null==A?void 0:A.payload})):this.flowState.update({action:k})})),Lr.set(this,Ho((()=>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)}}))))),Wr.set(this,Qo(((t,e)=>n(this,void 0,void 0,(function*(){var n,i;if("true"===t.getAttribute("formnovalidate")||o(this,Ir,"m",_r).call(this)){const r=null==t?void 0:t.getAttribute("id");o(this,Ir,"m",Pr).call(this,t);const s=yield o(this,Ir,"m",$r).call(this),a=(i=t,Array.from((null==i?void 0:i.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]: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}),d=yield this.getFlowConfig(),u=yield this.getProjectConfig(),h=yield e(r,d.version,u.componentsVersion,c);o(this,Er,"f").call(this,h),o(this,Ir,"m",Mr).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 ss})),e.default;case"fingerprint":return e=yield Promise.resolve().then((function(){return ls})),e.default;case"fingerprintDescope":return e=yield Promise.resolve().then((function(){return ds})),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:{[kr(t.id,t.resultKey)]:e},bubbles:!0,composed:!0}))}))}))))}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var e,n,i;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",o(this,xr,"f").visibilitychange)),yield null===(i=t.init)||void 0===i?void 0:i.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=o(this,Cr,"f"))||void 0===t||t.abort(),i(this,Cr,null,"f"),window.removeEventListener("visibilitychange",o(this,xr,"f").visibilitychange)}getHtmlFilenameWithLocale(t,e){return n(this,void 0,void 0,(function*(){let n;const o=Zo(t),i=yield this.getTargetLocales();return i.includes(o.locale)?n=`${e}-${o.locale}.html`:i.includes(o.fallback)&&(n=`${e}-${o.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:O,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:A,locale:U,samlIdpResponseUrl:E,samlIdpResponseSamlResponse:L,samlIdpResponseRelayState:R,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;const D=(()=>{const t=localStorage.getItem(mi);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(mi,t.toString()),t}return Number(t)})(),q=this.sdk.getLastUserLoginId(),W=yield this.getFlowConfig(),N=yield this.getProjectConfig(),F=Object.entries(N.flows||{}).reduce(((t,[e,n])=>(t[e]=n.version,t)),{}),B=O&&x?{callbackUrl:O,codeChallenge:x,backupCallbackUri:j}:void 0,V=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(),W.fingerprintEnabled&&W.fingerprintKey?yield Dn(W.fingerprintKey,this.baseUrl):localStorage.removeItem(Pn),W.conditions?({startScreenId:P,conditionInteractionId:M}=((t,e)=>{const n=null==e?void 0:e.find((({key:e,operator:n,predicate:o})=>{var i;if("ELSE"===e)return!0;const r=null===(i=bi[e])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(t,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:q,code:k,token:y,abTestingKey:D},W.conditions)):W.condition?({startScreenId:P,conditionInteractionId:M}=((t,e)=>{var n;const o=null===(n=bi[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const i=o(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(W.condition,{loginId:q,code:k,token:y,abTestingKey:D})):P=W.startScreenId,!Jo(P,$))){const t=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:B},$),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:wi(q),abTestingKey:D,locale:Zo(U).locale,nativeOptions:V}),M,"",N.componentsVersion,F,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 o(this,Er,"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,_o,W.version,N.componentsVersion,{token:y,exchangeCode:k,exchangeError:I});return o(this,Er,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===To&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>s(t)))){if(!E||!L)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=t,i.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(i),o(i)})(E,L,R||"",zo)}if(f===Ao&&(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===Eo||f===Lo){if(!S||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,e;null===(l=o(this,Cr,"f"))||void 0===l||l.abort(),i(this,Cr,null,"f");try{t=f===Eo?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,_o,W.version,N.componentsVersion,{transactionId:S,response:t,failure:e});o(this,Er,"f").call(this,n)}if(f===Ro)return this.nativeComplete=t=>n(this,void 0,void 0,(function*(){const e=yield this.sdk.flow.next(p,h,_o,W.version,N.componentsVersion,t);o(this,Er,"f").call(this,e)})),void o(this,Ir,"m",Vr).call(this,"bridge",{type:T,payload:_});if(o(this,Ar,"f").call(this,p,h,W.version,N.componentsVersion),!g&&!P)return void this.loggerWrapper.warn("No screen was found to show");const K=P||g,H=yield this.getHtmlFilenameWithLocale(U,K),{oidcLoginHint:G,oidcPrompt:J,oidcErrorRedirectUri:z,samlIdpUsername:X}=$,Q={direction:No(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:q,name:this.sdk.getLastUserDisplayName()||q}}),htmlFilename:`${K}.html`,htmlLocaleFilename:H,samlIdpUsername:X,oidcLoginHint:G,oidcPrompt:J,oidcErrorRedirectUri:z,openInNewTabUrl:b},Z=wi(q);Jo(P,$)?Q.next=(t,e,n,o)=>this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:B},$),{lastAuth:Z,preview:this.preview,abTestingKey:D,client:this.client}),w&&{redirectUrl:w}),{locale:Zo(U).locale,nativeOptions:V}),M,t,n,F,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),k&&{exchangeCode:k,idpInitiated:!0}),$.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(Q.next=(...t)=>this.sdk.flow.next(p,h,...t)),this.stepState.update(Q)}))}onStepChange(t,e){return n(this,void 0,void 0,(function*(){var i,r;const{htmlFilename:s,htmlLocaleFilename:a,direction:l,next:c,screenState:d,openInNewTabUrl:u}=t,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 o(this,Ir,"m",Tr).call(this,p,c):p.querySelectorAll(`descope-button[${jo}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!t.samlIdpUsername||(null===(i=d.form)||void 0===i?void 0:i.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),fi(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 t,n;yield f;const i=this.shadowRoot.querySelector("div");var r,s;r=i,s=null===(t=null==d?void 0:d.totp)||void 0===t?void 0:t.image,pi(r,"descope-totp-image",s),((t,e)=>{pi(t,"descope-notp-image",e)})(i,null===(n=null==d?void 0:d.notp)||void 0===n?void 0:n.image),((t,e,n,o)=>{n&&Object.keys(n).forEach((i=>{e.querySelector(i)||o.debug(`Skipping css vars for component "${i}}"`,`Got css vars for component ${i} but Could not find it on next page`);const r=customElements.get(i);r?Object.keys(n[i]).forEach((e=>{var s;const a=n[i],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[e];if(!l)return void o.info(`Could not find css variable name for ${e} in ${i}`,"Check if the css variable is defined in the component");const c=a[e];t.style.setProperty(l,c)})):o.info(`Could not find component class for ${i}`,"Check if the component is registered")}))})(i,p,d.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(p);const a=!e.htmlFilename;setTimeout((()=>{o(this,Ir,"m",Dr).call(this),((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}})(this.rootElement,this.autoFocus,a),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}))}))}))})(this.rootElement),((t,e)=>{li(t,null==e?void 0:e.inputs),li(t,null==e?void 0:e.form)})(this.rootElement,d)})),o(this,Ir,"m",Fr).call(this,c),a&&o(this,Ir,"m",Vr).call(this,"ready",{}),o(this,Ir,"m",Vr).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${jo}="polling"]`)){const t=yield this.getFlowConfig(),e=yield this.getProjectConfig(),n=yield c($o,t.version,e.componentsVersion,{});o(this,Er,"f").call(this,n)}u&&!e.openInNewTabUrl&&window.open(u,"_blank")}));l?o(this,Ir,"m",Br).call(this,v,l):v()}))}}Sr=new WeakMap,Cr=new WeakMap,xr=new WeakMap,Ar=new WeakMap,Ur=new WeakMap,Er=new WeakMap,Lr=new WeakMap,Wr=new WeakMap,Ir=new WeakSet,Or=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},jr=function(){return n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const t=yield this.getComponentsVersion();this.getConfig.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")}))},Rr=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)}))}},Tr=function(t,e){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,Cr,"f"))||void 0===r||r.abort();const s=t.querySelector('*[autocomplete="webauthn"]');if(s&&(yield gi())){const{options:t,transactionId:r}=(yield o(this,Lr,"f").call(this))||{};if(t&&r){o(this,Ir,"m",Rr).call(this,s),i(this,Cr,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,o(this,Cr,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,a.version,l.componentsVersion,{transactionId:r,response:t});o(this,Er,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},_r=function(){let t=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e=>{var n,o;"slot"!==e.localName&&(null===(n=e.reportValidity)||void 0===n||n.call(e),t&&(t=null===(o=e.checkValidity)||void 0===o?void 0:o.call(e)))})),t},$r=function(){return n(this,void 0,void 0,(function*(){const t=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${fo}])`));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})),{})}))},Pr=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},Mr=function(t={}){var e,n;const o=Xo(t,["externalId","email","phone"]),i=Xo(t,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const t=new globalThis.PasswordCredential({id:o,password:i});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)}},Dr=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((t=>t.remove()));this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>o(this,Ir,"m",qr).call(this,t)))},qr=function(t){if(!t)return;t.querySelectorAll("input").forEach((e=>{const n=e.getAttribute("slot"),o=`input-${t.id}-${n}`,i=document.createElement("slot");i.setAttribute("name",o),i.setAttribute("slot",n),t.appendChild(i),e.setAttribute("slot",o),this.appendChild(e)}))},Nr=function(t){this.rootElement.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))&&o(this,Wr,"f").call(this,e,t)}))}))},Fr=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((e=>{e.onclick=()=>{o(this,Wr,"f").call(this,e,t)}})),o(this,Ir,"m",Nr).call(this,t)},Br=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===Mo.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),this.rootElement.classList.add("fade-out")},Vr=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",es);const ns=document.createElement("template");ns.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 os extends HTMLElement{constructor(){super(),Kr.add(this),Hr.set(this,new ii({messages:[]})),Gr.set(this,void 0),Jr.set(this,void 0),zr.set(this,void 0),Xr.set(this,{resize:o(this,Kr,"m",ts).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ns.content.cloneNode(!0)),i(this,Gr,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Jr,o(this,Gr,"f").querySelector(".content"),"f"),i(this,zr,o(this,Gr,"f").querySelector(".header"),"f")}updateData(t){o(this,Hr,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((t,e,n)=>{let o=0,i=0,r=0,s=0;function a(e){e.preventDefault(),o=r-e.clientX,i=s-e.clientY,r=e.clientX,s=e.clientY;const[a,l]=vi(t,t.offsetLeft-o,t.offsetTop-i,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})(o(this,Gr,"f"),o(this,zr,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Xr,"f").resize),(t=o(this,Gr,"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},o(this,Gr,"f").onresize=o(this,Kr,"m",Yr).bind(this),o(this,Hr,"f").subscribe(o(this,Kr,"m",Qr).bind(this))}disconnectedCallback(){o(this,Hr,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Xr,"f").resize)}}Hr=new WeakMap,Gr=new WeakMap,Jr=new WeakMap,zr=new WeakMap,Xr=new WeakMap,Kr=new WeakSet,Qr=function(t){o(this,Kr,"m",Zr).call(this,t),o(this,Kr,"m",Yr).call(this)},Zr=function(t){o(this,Jr,"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("")},Yr=function(){o(this,Jr,"f").querySelectorAll(".msg").forEach((t=>{const e=t.querySelector(".msg_desc"),n=e.scrollWidth>e.clientWidth,o=e.clientHeight>20;n||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},ts=function(){const[t,e]=vi(o(this,Gr,"f"),Number.parseInt(o(this,Gr,"f").style.left,10),Number.parseInt(o(this,Gr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Gr,"f").style.top=`${e}px`,o(this,Gr,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",os);var is=Object.freeze({__proto__:null,default:os});const rs='\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 ss=Object.freeze({__proto__:null,default:(t,e,o)=>n(void 0,void 0,void 0,(function*(){const{siteId:e}=t,n=rs.replace(/{{SITE_ID}}/g,e),i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("id",e),i.text=n,document.body.appendChild(i),document.addEventListener("ftr:tokenReady",(t=>{o(t.detail)}))}))});const as=(t,e,o)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:e,useCloudflareIntegration:n,cloudflareScriptUrl:i,cloudflareEndpointUrl:r}=t;let s=[];s=n&&r?[r,an]:[an];let a=[];if(n&&i){const t=new URL(i);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();o(d)}catch(t){console.warn("Could not load fingerprint",t)}}));var ls=Object.freeze({__proto__:null,default:as,loadFingerprint:as});const cs=(t,e,o)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:i,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:i,endpoint:[c.toString(),an],scriptUrlPattern:[u,fn]}),p=yield h,{requestId:f}=yield p.get();o(f)}catch(t){console.warn("Could not load descope fingerprint",t)}}));var ds=Object.freeze({__proto__:null,default:cs,loadFingerprint:cs})}();
3
+ function rn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)t[o]=n[o]}return t}var sn=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=rn({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=t+"="+e.write(o,t)+r}}return Object.create({set:o,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=e.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}},remove:function(t,e){o(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,o,i,r,s,a=[],l=(n=function(t){var e=function(t,e,n){if(n||2===arguments.length)for(var o,i=0,r=e.length;i<r;i++)!o&&i in e||(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||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,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=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&&!i.has(l)&&(i.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()+o()-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,o=function(e){return a.push({url:t,startedAt:n,finishedAt:new Date,error:e})},i=e(t);return i.then((function(){return o()}),o),i.catch((function(t){if(null!=s||(s=t),a.length>=5)throw s;var e=d(n,t);if(!e)throw s;var o,i=e[0],r=e[1];return(o=r,new Promise((function(t){return setTimeout(t,o)}))).then((function(){return u(i)}))}))};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 o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=e(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:pn,c=function(){var t=[],e=function(){t.push({time:new Date,state:document.visibilityState})},n=function(t,e,n,o){return t.addEventListener(e,n,o),function(){return t.removeEventListener(e,n,o)}}(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],o=e[1];return u(),n.load(t(t({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function vn(t){return function(t,e,n,o){var i,r=document,s="securitypolicyviolation",a=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,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return null==o||o.then(l,l),Promise.resolve().then(e).then((function(t){return l(),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(l(),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 o=document.createElement("script"),i=function(){var t;return null===(t=o.parentNode)||void 0===t?void 0:t.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),e()},o.onerror=function(){i(),n(new Error(dn))},o.async=!0,o.src=t,r.appendChild(o)}))}(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,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==o?void 0:o.configurable)?delete t[e]:o&&!o.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,o)=>{var i;return n[o]=[].concat((null===(i=t.hooks)||void 0===i?void 0:i[o])||[]).concat((null==e?void 0:e[o])||[]),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)),Cn=t=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Sn=t=>kn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),xn=(...t)=>{console.debug(...t)},On="undefined"!=typeof window,jn=Math.pow(2,31)-1,An="DS",Un="DSR";function En(t=""){return Cn(`${t}${Un}`)||""}function Ln(t=""){return sn.get(An)||Cn(`${t}${An}`)||""}function Rn(t=""){Sn(`${t}${Un}`),Sn(`${t}${An}`),sn.remove(An)}const Tn=On&&(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),o=new URL(e);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(e);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=gn({apiKey:t,endpoint:[o.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)}},qn=t=>{const e=Mn(!0);return e&&t.body&&(t.body.fpData=e),t},Wn="dls_last_user_login_id",Nn="dls_last_user_display_name",Fn=()=>Cn(Wn),Bn=()=>Cn(Nn),Vn=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=Fn(),r=Bn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.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(!On)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 to,eo=(to=t=>({async signUp(e,n,o){const i=await t.webauthn.signUp.start(e,window.location.origin,n,o);if(!i.ok)return i;const r=await Hn(i.data.options);return await t.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(e,n){const o=await t.webauthn.signIn.start(e,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await Gn(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(e,n){var o;const i=await t.webauthn.signUpOrIn.start(e,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const e=await Hn(i.data.options);return await t.webauthn.signUp.finish(i.data.transactionId,e)}{const e=await Gn(i.data.options);return await t.webauthn.signIn.finish(i.data.transactionId,e)}},async update(e,n,o){const i=await t.webauthn.update.start(e,window.location.origin,n,o);if(!i.ok)return i;const r=await Hn(i.data.options);return await t.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:Hn,get:Gn,isSupported:zn,conditional:Jn}}),(...t)=>{const e=to(...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 no="/fedcm/config",oo=(t,e)=>({async oneTap(e,n,o,i,r){const s=null!=e?e:"google",a=await t.oauth.startNative(s,o,!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 o,a;u.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,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(i&&(null==t?void 0:t.isSkippedMoment())){const e=null===(n=t.getSkippedReason)||void 0===n?void 0:n.call(t);null==i||i(e)}}))}))},async launch(n){var o;const i={identity:{context:n||"signin",providers:[{configURL:t.httpClient.buildUrl(e+no),clientId:e}]}},r=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(i));return t.refresh(r.token)},isSupported:()=>On&&"IdentityCredential"in window,async isLoggedIn(n){var o;const i=t.httpClient.buildUrl(e+no);try{const t={identity:{context:n||"signin",providers:[{configURL:i,clientId:e}]}},r=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(t));return!!r&&!!r.token}catch(t){return!1}}});var io=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await zn(),o=Object.assign(Object.assign({location:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return e[1]=o,t.flow.start(...e)}});const ro=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:o,fpLoad:i}=n,r=e(n,["fpKey","fpLoad"]);return On?(o&&i&&Dn(o).catch((()=>null)),t(bn(r,{beforeRequest:qn}))):t(r)}),(t=>n=>{var{autoRefresh:o}=n,i=e(n,["autoRefresh"]);if(!o)return t(i);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;On&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>l&&(xn("Expiration time passed, refreshing session"),d.refresh(En()||c))}));const d=t(bn(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await wn(e);if(401===(null==e?void 0:e.status))xn("Received 401, canceling all timers"),r();else if(o){if(l=(t=>{try{const e=a(t);if(e.exp)return new Date(1e3*e.exp)}catch(t){return null}})(o),!l)return void xn("Could not extract expiration time from session token");c=n;let t=((i=l)?i.getTime()-(new Date).getTime():0)-2e4;t>jn&&(xn(`Timeout is too large (${t}ms), setting it to ${jn}ms`),t=jn),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 i}}));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.9"},e.baseHeaders)}))),(t=>e=>{const n=Kn(),o=Kn(),i=t(bn(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await yn(e);t&&o.pub(t);const{sessionJwt:i}=await wn(e);i&&n.pub(i)}}})),r=Jt(i,["logout","logoutAll"],(t=>async(...e)=>{const i=await t(...e);return n.pub(null),o.pub(null),i}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(t=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=e(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(t(r),{getLastUserLoginId:Fn,getLastUserDisplayName:Bn});const s=t(bn(r,{afterRequest:async(t,e)=>{var n;const o=await yn(e),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((t=>{In(Wn,t)})(i),(t=>{In(Nn,t)})(r))}}));let a=Jt(s,["flow.start"],Vn);return a=Jt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return t||(Sn(Wn),Sn(Nn)),o})(i)),Object.assign(a,{getLastUserLoginId:Fn,getLastUserDisplayName:Bn})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=e(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!On)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 o=/^\/v\d+\/mgmt\//.test(t.path);401===(null==n?void 0:n.status)?o||Rn(r):((t={},n,o)=>{var{refreshJwt:i,sessionJwt:r}=t,s=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),i&&In(`${o}${Un}`,i),r&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i),s=function(t){const e=window.location.hostname.split("."),n=t.split(".");return e.slice(-n.length).join(".")===t}(o);sn.set(t,e,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(An,r,s):In(`${o}${An}`,r))})(await wn(n),i,r)}}));var l;const c=Jt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return Rn(t),o})(r));return Object.assign(c,{getRefreshToken:()=>En(r),getSessionToken:()=>Ln(r)})}))(((...t)=>{const e=on(...t);return Object.assign(Object.assign({},e),{refresh:t=>{const n=Ln();return e.refresh(t,{dcs:n?"t":"f"})},flow:io(e),webauthn:eo(e),fedcm:oo(e,t[0].projectId)})})),so="undefined"!=typeof localStorage,ao="J151000",lo=so&&localStorage.getItem("base.content.url")||"",co="base.ui.components.url";so&&localStorage.getItem(co),so&&localStorage.getItem(co);const uo="descope-login-flow",ho="code",po="data-exclude-field",fo="dls_last_auth",go="state_id",vo="saml_idp_state_id",mo="saml_idp_username",bo="descope_idp_initiated",wo="sso_app_id",yo="third_party_app_id",ko="third_party_app_state_id",Io="oidc_login_hint",Co="oidc_prompt",So="oidc_error_redirect_uri",xo="application_scopes",Oo="data-type",jo="redirect",Ao="poll",Uo="webauthnCreate",Eo="webauthnGet",Lo="nativeBridge",Ro="loadForm",To="submit",_o="polling",$o=["descope-multi-select-combo-box","descope-text-area"];var Po;!function(t){t.backward="backward",t.forward="forward"}(Po||(Po={}));const Mo=["descope-enriched-text"];function Do(t){return new URLSearchParams(window.location.search).get(t)}function qo(t){if(window.history.replaceState&&Do(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 Wo(t,e){if(!e)return;const n=+t,o=+e;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?Po.forward:n<o?Po.backward:void 0}const No=t=>{let[e="",n=""]=(Do(uo)||"").split("_");const o=(t=>{var e;return(null===(e=/(.*)\|#\|.*/.exec(t))||void 0===e?void 0:e[1])||""})(e);return(!t||o&&o!==t)&&(e="",n=""),{executionId:e,stepId:n,executionFlowId:o}};function Fo(){qo(uo)}const Bo=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),Vo=(t,e)=>{const{executionId:n,stepId:o,executionFlowId:i}=No(t);if(i&&t!==i)return e.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&Fo();const r=Do("t")||void 0;r&&qo("t");const s=Do(ho)||void 0;s&&qo(ho);const a=Do("err")||void 0;a&&qo("err");const{redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u}={redirectAuthCodeChallenge:Do("ra-challenge"),redirectAuthCallbackUrl:Do("ra-callback"),redirectAuthBackupCallbackUri:Do("ra-backup-callback"),redirectAuthInitiator:Do("ra-initiator")},h=Do(go);h&&qo(go);const p=Do(vo);p&&qo(vo);const f=Do(mo);p&&qo(mo);const g=Do(bo);g&&qo(bo);const v=Do(wo);v&&qo(wo);const m=Do(yo);m&&qo(yo);const b=Do(ko);b&&qo(ko);const w=Do(xo);w&&qo(xo);const y=Do(Io);y&&qo(Io);const k=Do(Co);k&&qo(Co);const I=Do(So);I&&qo(So);return{executionId:n,stepId:o,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}}},Ko=t=>{let e,n;return Object.assign(((...o)=>{return e&&(r=o,(i=e).length===r.length&&i.every(((t,e)=>t===r[e])))||(e=o,n=t(...o)),n;var i,r}),{reset:()=>{e=void 0,n=void 0}})};function Ho(t,e,n){return new Promise(((o,i)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?o(n):i(new Error(`Promise timed out after ${t} ms`))}),t);e.then((t=>{r||(clearTimeout(s),o(t))})).catch((t=>{r||(clearTimeout(s),i(t))}))}))}const Go=(t,{oidcIdpStateId:e,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,thirdPartyAppId:l,thirdPartyAppStateId:c,applicationScopes:d})=>!(!t||e||n||o||i||r||s||a||l||c||d),Jo=t=>null==t?void 0:t.submit(),zo=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null},Xo=(t,e=100)=>{let n;return function(...o){n||t.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),e)}};function Qo(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:""}}var Zo,Yo,ti,ei;function ni(t,e){const n=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=t[i],s=e[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!ni(r,s))return!1}else if(r!==s)return!1}return!0}class oi{constructor(t={},{updateOnlyOnChange:e=!0}={}){Zo.set(this,void 0),Yo.set(this,{}),ti.set(this,0),ei.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,Zo,"f")):t,n=Object.assign(Object.assign({},o(this,Zo,"f")),e);if(!o(this,ei,"f")||!ni(o(this,Zo,"f"),n)){const t=o(this,Zo,"f");i(this,Zo,n,"f"),Object.freeze(o(this,Zo,"f")),setTimeout((()=>{Object.values(o(this,Yo,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,Zo,t,"f"),i(this,ei,e,"f")}get current(){return Object.assign({},o(this,Zo,"f"))}subscribe(t){return i(this,ti,o(this,ti,"f")+1,"f"),o(this,Yo,"f")[o(this,ti,"f")]=t,o(this,ti,"f").toString()}unsubscribe(t){const e=!!o(this,Yo,"f")[t];return e&&delete o(this,Yo,"f")[t],e}unsubscribeAll(){return i(this,Yo,{},"f"),!0}}Zo=new WeakMap,Yo=new WeakMap,ti=new WeakMap,ei=new WeakMap;const ii=["*","#","/","(",")","[","]","_","<",">","`"],ri=t=>{const e=ii.map((e=>`${t}${e}`)).join("|");return new RegExp(`(${e})`,"g")},si=["disabled"],ai=(t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${po}])`)).forEach((t=>{t.value=n}))}))},li=(t,e)=>e.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),t),ci=(t,e,n)=>t.replace(/{{(.+?)}}/g,((t,o)=>n?(t=>"string"!=typeof t?t:t.replace(ri("\\"),"\\$1"))(li(e,o)):li(e,o))),di=(t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{const n=(o=t.localName,Mo.includes(o));var o;t.textContent=ci(t.textContent,e,n);const i=t.getAttribute("href");i&&t.setAttribute("href",ci(i,e))}))},ui=(t,e,n)=>{t.querySelectorAll(`[${Oo}="${e}"]`).forEach((t=>{t.setAttribute("href",n)}))},hi=(t,e,n)=>{var o,i;const r=null===(o=customElements.get(e))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==t?void 0:t.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},pi=(t,e,n,o,i,r)=>{var s,a;let l=null==e?void 0:e.errorText;try{l=(null==i?void 0:i({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(`[${Oo}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",l),ui(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),ui(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),di(t,e),((t,e,n)=>{e&&Object.keys(e).forEach((o=>{t.querySelectorAll(`[name=${o}]`).forEach((t=>{const i=e[o];Object.keys(i).forEach((e=>{let o=i[e];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(t){n.error(`Could not stringify value "${o}" for "${e}"`,t.message),o=""}t.setAttribute(e,o)}))}))}))})(t,n,r),((t,e)=>{t.querySelectorAll("[data-has-dynamic-attr-values]").forEach((t=>{Array.from(t.attributes).forEach((t=>{t.value=ci(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])=>{si.includes(e)&&t.setAttribute(e,n)}))}))}))})(t,o)},fi=Ko((()=>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)))),o=(()=>{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 Ho(100,n,o)}catch(t){return console.error("Conditional login check failed",t),!1}})))),gi=(t,e,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(e,("all"===o.left?t.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-t.offsetWidth),window.innerWidth-("all"===o.right?t.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?t.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-t.offsetHeight),window.innerHeight-("all"===o.bottom?t.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]},vi="dls_ab_testing_id",mi={"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 bi(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(fo)))}catch(t){}return e}function wi(...t){return e=>t.reduce(((t,e)=>e(t)),e)}const yi=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 o=t(n);return o[e]=!0,o}},ki=["error","warn","info","debug"],Ii=yi((t=>{var e,n,r,s;return s=class extends t{constructor(){super(...arguments),e.add(this),n.set(this,o(this,e,"m",r).call(this,console))}set logger(t){i(this,n,o(this,e,"m",r).call(this,t||console),"f")}get logger(){return o(this,n,"f")}onLogEvent(t,e){}},n=new WeakMap,e=new WeakSet,r=function(t){return ki.reduce(((e,n)=>(e[n]=(...e)=>{var o;this.onLogEvent(n,e),null===(o=t[n])||void 0===o||o.call(t,...e)},e)),{})},s})),Ci="undefined"!=typeof localStorage,Si=Ci&&localStorage.getItem("base.content.url")||"",xi=(t,e)=>!e&&`${t} cannot be empty, please make sure to set this attribute`,Oi=yi((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)&&o(this,e,"f")&&(i(this,e,!1,"f"),this.init())}async init(){}},e=new WeakMap,n})),ji=yi((t=>{var e,n;const i=wi(Ii,Oi)(t);return n=class extends i{constructor(){super(...arguments),e.set(this,{})}async init(){var t,n,i;await(null===(t=super.init)||void 0===t?void 0:t.call(this)),n=this,i=t=>{var n;null===(n=o(this,e,"f")[t])||void 0===n||n.forEach((e=>{e(t,this.getAttribute(t))}))},Array.from(n.attributes).forEach((t=>i(t.name))),new MutationObserver((t=>{t.forEach((t=>{"attributes"===t.type&&i(t.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(t,n){o(this,e,"f")[t]||(o(this,e,"f")[t]=[]);const i=o(this,e,"f")[t].push(n);return()=>o(this,e,"f")[t].splice(i,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})),Ai=t=>e=>{var n,i,r;const s=wi(Ii,Oi,ji)(e),a=Object.keys(t);return r=class extends s{constructor(...t){super(...t),n.add(this),this.observeAttributes(a,o(this,n,"m",i).bind(this))}async init(){var t;a.forEach((t=>o(this,n,"m",i).call(this,t,this.getAttribute(t)))),await(null===(t=super.init)||void 0===t?void 0:t.call(this))}},n=new WeakSet,i=function(e,n){const o=t[e],i="function"==typeof o?o(e,n):o;i&&this.logger.error(i)},r};Ai.missingAttrValidator=xi;const Ui=yi((t=>{const e=wi(Ai({"project-id":xi}))(t);return class extends e{get projectId(){return this.getAttribute("project-id")}}})),Ei=yi((t=>class extends t{get baseUrl(){return this.getAttribute("base-url")||""}})),Li="Trying the next fallback URL...";function Ri({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:o="https://static.descope.com/pages"}){const i=new URL(o);return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,n,e),i.baseUrl=o,i}const Ti=yi((t=>{var e,n,r,s,a;const l=wi(Ii,Ui,Ei)(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=o(this,e,"m",s).call(this,t),l=Array.isArray(a)?t=>{if(t!==a.length-1){const{baseUrl:e}=a[t];i(this,r,e,"f")}}:null;try{const t=await(async(t,e,{logger:n,onSuccess:o})=>{const i=Array.isArray(t)?t:[t];for(let t=0;t<i.length;t++){const r=i[t],s=t===i.length-1;try{const i=await fetch(r.toString(),e);if(i.ok)return null==o||o(t),i;const a=`Error fetching URL ${r} [${i.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${Li}`)}catch(t){const e=`Error fetching URL ${r} [${t.message}]`;if(s)throw new Error(e);null==n||n.debug(`${e}. ${Li}`)}}})(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=Si||this.baseStaticUrl;if(e)return Ri({projectId:this.projectId,filename:t,baseUrl:e});const s=o(this,n,"f")!==this.baseUrl,a=s&&!!this.baseUrl;s&&(i(this,n,this.baseUrl,"f"),i(this,r,void 0,"f"));const l=Ri({projectId:this.projectId,filename:t,baseUrl:o(this,r,"f")});if(!a)return l;return[Ri({projectId:this.projectId,filename:t,baseUrl:this.baseUrl+"/pages"}),l]},a})),_i=yi((t=>{var e,n;const i=wi(Ai({"project-id":xi}))(t);return n=class extends i{constructor(){super(...arguments),e.set(this,new Map)}onReset(t,n){if(o(this,e,"f").has(t))throw new Error(`Callback for sectionId ${t} already exists`);return o(this,e,"f").set(t,n),()=>{o(this,e,"f").delete(t)}}async reset(...t){0===t.length?await Promise.all(Array.from(o(this,e,"f").values()).map((t=>t()))):await Promise.all(t.map((t=>{var n;if(!o(this,e,"f").has(t))throw new Error(`Callback for sectionId ${t} does not exist`);return null===(n=o(this,e,"f").get(t))||void 0===n?void 0:n()})))}},e=new WeakMap,n})),$i=yi((t=>{var e,n,r,s,a;const l=wi(Ti,_i,Oi)(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",o(this,e,"m",n).bind(this))}get config(){return o(this,r,"f")||i(this,r,o(this,s,"f").call(this),"f"),o(this,r,"f")}},r=new WeakMap,s=new WeakMap,e=new WeakSet,n=function(){i(this,r,void 0,"f")},a})),Pi="load-descope-ui",Mi="base.ui.components.url",Di=Ci&&localStorage.getItem(Mi)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",qi=Ci&&localStorage.getItem(Mi)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Wi=Ci&&localStorage.getItem(Mi)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Ni=t=>{const e=document.createElement("script");return e.id=t,e},Fi=(t,e)=>t.replace("<version>",e),Bi=yi((t=>{var e,n,r,s,a,l,c,d,u,h,p,f;const g=wi(Ii,$i)(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 o(this,u,"f")||i(this,u,o(this,e,"m",p).call(this),"f"),o(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=>o(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=o(this,n,"f"),i=o(this,r,"f");t[e]=[],t[i]=[],Object.defineProperty(t,"onerror",{set(n){t[e].push(n)}}),Object.defineProperty(t,"onload",{set(e){t[i].push(e)}})},l=async function(t,n,i,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const a=Ni(i);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=Fi(r,await o(this,e,"m",s).call(this))},c=function(t){t.addEventListener("error",(()=>{t[o(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}"`))),o(this,e,"m",l).call(this,[o(this,e,"m",l).bind(this,t[o(this,n,"f")],t[o(this,r,"f")],"load-descope-ui-fallback-script-2",Wi),...t[o(this,n,"f")]],t[o(this,r,"f")],"load-descope-ui-fallback-script",qi)})),t.addEventListener("load",(()=>{t[o(this,r,"f")].forEach((t=>t()))}))},d=async function(){if(document.querySelector(`script#${Pi}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const t=Ni(Pi);document.body.append(t),o(this,e,"m",a).call(this,t),o(this,e,"m",c).call(this,t),t.src=Fi(this.baseCdnUrl||Di,await o(this,e,"m",s).call(this))}return document.getElementById(Pi)},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),o(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})),Vi="content-root",Ki="root",Hi=yi((t=>class extends t{constructor(...t){var e,n;super(...t),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${Ki}, #${Vi} {\n height: 100%;\n }\n #${Ki} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${Ki}">\n <div id="${Vi}"></div>\n </div>\n `,this.contentRootElement=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById(Vi),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Ki)}})),Gi=(t,e)=>!!e&&"light"!==e&&"dark"!==e&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Ji=yi((t=>{var e,n,r,s,a,l,c,d,u,h,p,f,g,v;const m=wi(Ai({theme:Gi}),Ti,Oi,Bi,$i,Hi,ji)(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,(()=>{o(this,e,"m",f).call(this),o(this,g,"f").call(this,"os"===this.getAttribute("theme"))})),g.set(this,(t=>{var n,i,r;const s=t?"addEventListener":"removeEventListener";null===(r=null===(i=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===i?void 0:i[s])||void 0===r||r.call(i,"change",(()=>o(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)),o(this,e,"m",l).call(this),o(this,e,"m",c).call(this),o(this,p,"f").call(this),this.observeAttributes(["theme"],o(this,p,"f")),this.observeAttributes(["style-id"],(()=>{i(this,r,null,"f"),o(this,e,"m",u).call(this),o(this,e,"m",l).call(this),o(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 o(this,r,"f")||(i(this,r,o(this,e,"m",s).call(this),"f"),o(this,r,"f").then((t=>this.logger.debug("Fetched theme",t)))),o(this,r,"f")},l=async function(){var t,r;const s=await o(this,e,"a",a);s&&(o(this,n,"f")||(i(this,n,document.createElement("style"),"f"),o(this,n,"f").id="global-style",this.shadowRoot.appendChild(o(this,n,"f"))),o(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 i=Object.assign({},await o(this,e,"a",a));if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(t=null==i?void 0:i.light)||void 0===t?void 0:t.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},d=async function(){var t,e;const{projectConfig:n}=await this.config||{},o=null===(t=null==n?void 0:n.styles)||void 0===t?void 0:t[this.styleId],i=null==n?void 0:n.cssTemplate,r=o||i;return null===(e=null==r?void 0:r[this.theme])||void 0===e?void 0:e.fonts},u=async function(){const t=await o(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(){o(this,e,"m",u).call(this),o(this,e,"m",h).call(this)},v})),zi=(t,e="")=>Object.keys(t).reduce(((n,o)=>{var i;if("object"==typeof t[o]&&null!==t[o]&&!(null===(i=t[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),zi(t[o],`${e+o}.`));const r="object"==typeof t[o]?t[o]:{value:t[o]},s=Object.assign(Object.assign({},n),{[e+o]:r,[`form.${e}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${e}fullName`]:r,[`form.${e}fullName`]:r}):s}),[]),Xi=yi((t=>{var e,n,i,r;return r=class extends t{constructor(){super(...arguments),e.add(this)}connectedCallback(){var t;o(this,e,"m",n).call(this)&&o(this,e,"m",i).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)},i=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})),Qi=document.createElement("template");var Zi,Yi,tr,er,nr,or,ir,rr,sr,ar,lr,cr,dr,ur,hr,pr,fr,gr,vr,mr,br;Qi.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\t\t\ttransition: opacity 300ms ease-in-out;\n display: flex;\n\t\t}\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\t</style>\n\t";const wr=wi(Ji,Ti,Xi)(HTMLElement);class yr extends wr{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(),Zi.add(this),tr.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(t,e="")=>{this.logger.error(t,e,new Error),o(this,Zi,"m",mr).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)}},er.set(this,new oi),nr.set(this,new oi),or.set(this,{}),this.getComponentsContext=()=>o(this,or,"f"),this.nextRequestStatus=new oi({isLoading:!1}),ir.set(this,void 0),rr.set(this,{popstate:o(this,Zi,"m",cr).bind(this),componentsContext:o(this,Zi,"m",fr).bind(this)}),sr.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,sr,t,"f"),o(this,Zi,"m",ar).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 zi(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(),o=(null===(t=null==n?void 0:n.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=o.version)&&void 0!==e||(o.version=0),o}))}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),o(this,nr,"f").subscribe(o(this,Zi,"m",vr).bind(this)),o(this,nr,"f").update({isDebug:this.debug}),o(this,Zi,"m",lr).call(this),yield o(this,Zi,"m",hr).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");o(this,Zi,"m",br).call(this);const{executionId:r,stepId:s,token:a,code:l,exchangeError:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p,ssoQueryParams:f}=Vo(this.flowId,this.loggerWrapper);window.addEventListener("popstate",o(this,rr,"f").popstate),window.addEventListener("components-context",o(this,rr,"f").componentsContext),o(this,er,"f").subscribe(o(this,Zi,"m",ur).bind(this)),o(this,er,"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)),i(this,tr,!0,"f")}))}disconnectedCallback(){o(this,er,"f").unsubscribeAll(),o(this,nr,"f").unsubscribeAll(),o(this,Zi,"m",gr).call(this),window.removeEventListener("popstate",o(this,rr,"f").popstate),window.removeEventListener("components-context",o(this,rr,"f").componentsContext)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,tr,"f")&&e!==n&&Yi.observedAttributes.includes(t)){o(this,Zi,"m",lr).call(this);const i=null===e;o(this,er,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,Fo()),{[Bo(t)]:n,stepId:r,executionId:s}})),o(this,nr,"f").update({isDebug:this.debug})}}}function kr(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}var Ir,Cr,Sr,xr,Or,jr,Ar,Ur,Er,Lr,Rr,Tr,_r,$r,Pr,Mr,Dr,qr,Wr,Nr,Fr,Br,Vr,Kr,Hr,Gr,Jr,zr,Xr,Qr,Zr,Yr,ts;Yi=yr,tr=new WeakMap,er=new WeakMap,nr=new WeakMap,or=new WeakMap,ir=new WeakMap,rr=new WeakMap,sr=new WeakMap,Zi=new WeakSet,ar=function(){this.shadowRoot.appendChild(Qi.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},lr=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"];Yi.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[Bo(e)])throw Error(`${e} cannot be empty`)}))},cr=function(){const{stepId:t,executionId:e}=No(this.flowId);o(this,er,"f").update({stepId:t,executionId:e})},dr=function(t,e){this.sdk=ro(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},Yi.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:ao,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},ur=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n}=t;if(i("projectId")||i("baseUrl")){if(!e)return;o(this,Zi,"m",dr).call(this,e,n)}o(this,sr,"f").call(this,t)}))},hr=function(){return n(this,void 0,void 0,(function*(){const t=yield this.getConfig();return"isMissingConfig"in t&&t.isMissingConfig&&(yield o(this,Zi,"m",pr).call(this))}))},pr=function(){return n(this,void 0,void 0,(function*(){const t=function({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(lo||o||"https://static.descope.com/pages");return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,n,e),i.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||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}(t,"json"),!0}catch(t){return!1}}))},fr=function(t){i(this,or,Object.assign(Object.assign({},o(this,or,"f")),t.detail),"f")},gr=function(){var t;null===(t=o(this,ir,"f"))||void 0===t||t.remove(),i(this,ir,null,"f")},vr=function(t){return n(this,arguments,void 0,(function*({isDebug:t}){t?(i(this,ir,document.createElement("descope-debugger"),"f"),Object.assign(o(this,ir,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return is})),document.body.appendChild(o(this,ir,"f"))):o(this,Zi,"m",gr).call(this)}))},mr=function(t,e){var n;t&&this.debug&&(null===(n=o(this,ir,"f"))||void 0===n||n.updateData({title:t,description:e}))},br=function(){this.rootElement.onkeydown=t=>{var e,n,o;const i=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),r=$o.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==t.key||i||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()}}},yr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.33.0"}};class es extends yr{static set sdkConfigOverrides(t){yr.sdkConfigOverrides=t}static get sdkConfigOverrides(){return yr.sdkConfigOverrides}constructor(){const t=new oi({deferredRedirect:!1});super(t.update.bind(t)),Ir.add(this),this.stepState=new oi({},{updateOnlyOnChange:!1}),Cr.set(this,void 0),Sr.set(this,null),xr.set(this,{visibilitychange:o(this,Ir,"m",Or).bind(this)}),this.bridgeVersion=1,this.nativeResume=(t,e)=>{var n;const i=JSON.parse(e);if(this.logger.info(`nativeResume received payload of type '${t}'`),"oauthWeb"===t||"sso"===t){let{exchangeCode:t}=i;if(!t){t=null===(n=new URL(i.url).searchParams)||void 0===n?void 0:n.get(ho)}this.nativeComplete({exchangeCode:t,idpInitiated:!0})}else if("magicLink"===t){const t=new URL(i.url),e=t.searchParams.get("t"),n=t.searchParams.get(uo).split("_").pop();o(this,Ur,"f").call(this),this.flowState.update({token:e,stepId:n,action:void 0})}else this.nativeComplete(i)},Ar.set(this,((t,e,r,s,a=!1)=>{if(this.flowState.current.action===Ao){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),c=a?500:2e3;i(this,Cr,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const i=this.sdk.flow.next(t,e,_o,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 Ho(t,i)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void o(this,Ar,"f").call(this,t,e,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===ao)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,Ar,"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)),o(this,Er,"f").call(this,u),o(this,Ar,"f").call(this,t,e,r,s)}))),c),"f")}})),Ur.set(this,(()=>{clearTimeout(o(this,Cr,"f")),i(this,Cr,null,"f")})),Er.set(this,(t=>{var e,n,i,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===(i=null==t?void 0:t.response)||void 0===i?void 0:i.statusText}`;o(this,Ir,"m",Vr).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||o(this,Ir,"m",jr).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:o}=t;e&&this.loggerWrapper[e]?this.loggerWrapper[e](n,o):this.loggerWrapper.info(n,o)}));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)&&so&&localStorage.setItem(fo,JSON.stringify(t))}(m),void o(this,Ir,"m",Vr).call(this,"success",v);const{executionId:b,stepId:w,stepName:y,action:k,screen:I,redirect:C,openInNewTabUrl:S,webauthn:x,error:O,samlIdpResponse:j,nativeResponse:A}=t.data;k!==Ao?(this.loggerWrapper.info(`Step "${y||`#${w}`}" is ${g}`,"",{screen:I,status:g,stepId:w,stepName:y,action:k,error:O}),this.flowState.update({stepId:w,executionId:b,action:k,redirectTo:null==C?void 0:C.url,openInNewTabUrl:S,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==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.relayState,nativeResponseType:null==A?void 0:A.type,nativePayload:null==A?void 0:A.payload})):this.flowState.update({action:k})})),Lr.set(this,Ko((()=>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)}}))))),Wr.set(this,Xo(((t,e)=>n(this,void 0,void 0,(function*(){var n,i;if("true"===t.getAttribute("formnovalidate")||o(this,Ir,"m",_r).call(this)){const r=null==t?void 0:t.getAttribute("id");o(this,Ir,"m",Pr).call(this,t);const s=yield o(this,Ir,"m",$r).call(this),a=(i=t,Array.from((null==i?void 0:i.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]: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}),d=yield this.getFlowConfig(),u=yield this.getProjectConfig(),h=yield e(r,d.version,u.componentsVersion,c);o(this,Er,"f").call(this,h),o(this,Ir,"m",Mr).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 ss})),e.default;case"fingerprint":return e=yield Promise.resolve().then((function(){return ls})),e.default;case"fingerprintDescope":return e=yield Promise.resolve().then((function(){return ds})),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:{[kr(t.id,t.resultKey)]:e},bubbles:!0,composed:!0}))}))}))))}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var e,n,i;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",o(this,xr,"f").visibilitychange)),yield null===(i=t.init)||void 0===i?void 0:i.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=o(this,Sr,"f"))||void 0===t||t.abort(),i(this,Sr,null,"f"),window.removeEventListener("visibilitychange",o(this,xr,"f").visibilitychange)}getHtmlFilenameWithLocale(t,e){return n(this,void 0,void 0,(function*(){let n;const o=Qo(t),i=yield this.getTargetLocales();return i.includes(o.locale)?n=`${e}-${o.locale}.html`:i.includes(o.fallback)&&(n=`${e}-${o.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:C,webauthnOptions:S,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:O,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:A,locale:U,samlIdpResponseUrl:E,samlIdpResponseSamlResponse:L,samlIdpResponseRelayState:R,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;const D=(()=>{const t=localStorage.getItem(vi);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(vi,t.toString()),t}return Number(t)})(),q=this.sdk.getLastUserLoginId(),W=yield this.getFlowConfig(),N=yield this.getProjectConfig(),F=Object.entries(N.flows||{}).reduce(((t,[e,n])=>(t[e]=n.version,t)),{}),B=O&&x?{callbackUrl:O,codeChallenge:x,backupCallbackUri:j}:void 0,V=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(),W.fingerprintEnabled&&W.fingerprintKey?yield Dn(W.fingerprintKey,this.baseUrl):localStorage.removeItem(Pn),W.conditions?({startScreenId:P,conditionInteractionId:M}=((t,e)=>{const n=null==e?void 0:e.find((({key:e,operator:n,predicate:o})=>{var i;if("ELSE"===e)return!0;const r=null===(i=mi[e])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(t,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:q,code:k,token:y,abTestingKey:D},W.conditions)):W.condition?({startScreenId:P,conditionInteractionId:M}=((t,e)=>{var n;const o=null===(n=mi[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const i=o(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(W.condition,{loginId:q,code:k,token:y,abTestingKey:D})):P=W.startScreenId,!Go(P,$))){const t=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:B},$),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:bi(q),abTestingKey:D,locale:Qo(U).locale,nativeOptions:V}),M,"",N.componentsVersion,F,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 o(this,Er,"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,To,W.version,N.componentsVersion,{token:y,exchangeCode:k,exchangeError:I});return o(this,Er,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===Ro&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>s(t)))){if(!E||!L)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=t,i.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(i),o(i)})(E,L,R||"",Jo)}if(f===jo&&(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===Uo||f===Eo){if(!C||!S)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,e;null===(l=o(this,Sr,"f"))||void 0===l||l.abort(),i(this,Sr,null,"f");try{t=f===Uo?yield this.sdk.webauthn.helpers.create(S):yield this.sdk.webauthn.helpers.get(S)}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,To,W.version,N.componentsVersion,{transactionId:C,response:t,failure:e});o(this,Er,"f").call(this,n)}if(f===Lo)return this.nativeComplete=t=>n(this,void 0,void 0,(function*(){const e=yield this.sdk.flow.next(p,h,To,W.version,N.componentsVersion,t);o(this,Er,"f").call(this,e)})),void o(this,Ir,"m",Vr).call(this,"bridge",{type:T,payload:_});if(o(this,Ar,"f").call(this,p,h,W.version,N.componentsVersion),!g&&!P)return void this.loggerWrapper.warn("No screen was found to show");const K=P||g,H=yield this.getHtmlFilenameWithLocale(U,K),{oidcLoginHint:G,oidcPrompt:J,oidcErrorRedirectUri:z,samlIdpUsername:X}=$,Q={direction:Wo(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:q,name:this.sdk.getLastUserDisplayName()||q}}),htmlFilename:`${K}.html`,htmlLocaleFilename:H,samlIdpUsername:X,oidcLoginHint:G,oidcPrompt:J,oidcErrorRedirectUri:z,openInNewTabUrl:b},Z=bi(q);Go(P,$)?Q.next=(t,e,n,o)=>this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:B},$),{lastAuth:Z,preview:this.preview,abTestingKey:D,client:this.client}),w&&{redirectUrl:w}),{locale:Qo(U).locale,nativeOptions:V}),M,t,n,F,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),k&&{exchangeCode:k,idpInitiated:!0}),$.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(Q.next=(...t)=>this.sdk.flow.next(p,h,...t)),this.stepState.update(Q)}))}onStepChange(t,e){return n(this,void 0,void 0,(function*(){var i,r;const{htmlFilename:s,htmlLocaleFilename:a,direction:l,next:c,screenState:d,openInNewTabUrl:u}=t,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 o(this,Ir,"m",Tr).call(this,p,c):p.querySelectorAll(`descope-button[${Oo}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!t.samlIdpUsername||(null===(i=d.form)||void 0===i?void 0:i.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),pi(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 t,n;yield f;const i=this.shadowRoot.querySelector("div");var r,s;r=i,s=null===(t=null==d?void 0:d.totp)||void 0===t?void 0:t.image,hi(r,"descope-totp-image",s),((t,e)=>{hi(t,"descope-notp-image",e)})(i,null===(n=null==d?void 0:d.notp)||void 0===n?void 0:n.image),((t,e,n,o)=>{n&&Object.keys(n).forEach((i=>{e.querySelector(i)||o.debug(`Skipping css vars for component "${i}}"`,`Got css vars for component ${i} but Could not find it on next page`);const r=customElements.get(i);r?Object.keys(n[i]).forEach((e=>{var s;const a=n[i],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[e];if(!l)return void o.info(`Could not find css variable name for ${e} in ${i}`,"Check if the css variable is defined in the component");const c=a[e];t.style.setProperty(l,c)})):o.info(`Could not find component class for ${i}`,"Check if the component is registered")}))})(i,p,d.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(p);const a=!e.htmlFilename;setTimeout((()=>{o(this,Ir,"m",Dr).call(this),((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}})(this.rootElement,this.autoFocus,a),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}))}))}))})(this.rootElement),((t,e)=>{ai(t,null==e?void 0:e.inputs),ai(t,null==e?void 0:e.form)})(this.rootElement,d)})),o(this,Ir,"m",Fr).call(this,c),a&&o(this,Ir,"m",Vr).call(this,"ready",{}),o(this,Ir,"m",Vr).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${Oo}="polling"]`)){const t=yield this.getFlowConfig(),e=yield this.getProjectConfig(),n=yield c(_o,t.version,e.componentsVersion,{});o(this,Er,"f").call(this,n)}u&&!e.openInNewTabUrl&&window.open(u,"_blank")}));l?o(this,Ir,"m",Br).call(this,v,l):v()}))}}Cr=new WeakMap,Sr=new WeakMap,xr=new WeakMap,Ar=new WeakMap,Ur=new WeakMap,Er=new WeakMap,Lr=new WeakMap,Wr=new WeakMap,Ir=new WeakSet,Or=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},jr=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")}))},Rr=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)}))}},Tr=function(t,e){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,Sr,"f"))||void 0===r||r.abort();const s=t.querySelector('*[autocomplete="webauthn"]');if(s&&(yield fi())){const{options:t,transactionId:r}=(yield o(this,Lr,"f").call(this))||{};if(t&&r){o(this,Ir,"m",Rr).call(this,s),i(this,Sr,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,o(this,Sr,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,a.version,l.componentsVersion,{transactionId:r,response:t});o(this,Er,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},_r=function(){let t=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e=>{var n,o;"slot"!==e.localName&&(null===(n=e.reportValidity)||void 0===n||n.call(e),t&&(t=null===(o=e.checkValidity)||void 0===o?void 0:o.call(e)))})),t},$r=function(){return n(this,void 0,void 0,(function*(){const t=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${po}])`));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})),{})}))},Pr=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},Mr=function(t={}){var e,n;const o=zo(t,["externalId","email","phone"]),i=zo(t,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const t=new globalThis.PasswordCredential({id:o,password:i});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)}},Dr=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((t=>t.remove()));this.rootElement.querySelectorAll('[external-input="true"]').forEach((t=>o(this,Ir,"m",qr).call(this,t)))},qr=function(t){if(!t)return;t.querySelectorAll("input").forEach((e=>{const n=e.getAttribute("slot"),o=`input-${t.id}-${n}`,i=document.createElement("slot");i.setAttribute("name",o),i.setAttribute("slot",n),t.appendChild(i),e.setAttribute("slot",o),this.appendChild(e)}))},Nr=function(t){this.rootElement.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))&&o(this,Wr,"f").call(this,e,t)}))}))},Fr=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((e=>{e.onclick=()=>{o(this,Wr,"f").call(this,e,t)}})),o(this,Ir,"m",Nr).call(this,t)},Br=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===Po.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),this.rootElement.classList.add("fade-out")},Vr=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",es);const ns=document.createElement("template");ns.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 os extends HTMLElement{constructor(){super(),Kr.add(this),Hr.set(this,new oi({messages:[]})),Gr.set(this,void 0),Jr.set(this,void 0),zr.set(this,void 0),Xr.set(this,{resize:o(this,Kr,"m",ts).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ns.content.cloneNode(!0)),i(this,Gr,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Jr,o(this,Gr,"f").querySelector(".content"),"f"),i(this,zr,o(this,Gr,"f").querySelector(".header"),"f")}updateData(t){o(this,Hr,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((t,e,n)=>{let o=0,i=0,r=0,s=0;function a(e){e.preventDefault(),o=r-e.clientX,i=s-e.clientY,r=e.clientX,s=e.clientY;const[a,l]=gi(t,t.offsetLeft-o,t.offsetTop-i,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})(o(this,Gr,"f"),o(this,zr,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Xr,"f").resize),(t=o(this,Gr,"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},o(this,Gr,"f").onresize=o(this,Kr,"m",Yr).bind(this),o(this,Hr,"f").subscribe(o(this,Kr,"m",Qr).bind(this))}disconnectedCallback(){o(this,Hr,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Xr,"f").resize)}}Hr=new WeakMap,Gr=new WeakMap,Jr=new WeakMap,zr=new WeakMap,Xr=new WeakMap,Kr=new WeakSet,Qr=function(t){o(this,Kr,"m",Zr).call(this,t),o(this,Kr,"m",Yr).call(this)},Zr=function(t){o(this,Jr,"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("")},Yr=function(){o(this,Jr,"f").querySelectorAll(".msg").forEach((t=>{const e=t.querySelector(".msg_desc"),n=e.scrollWidth>e.clientWidth,o=e.clientHeight>20;n||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},ts=function(){const[t,e]=gi(o(this,Gr,"f"),Number.parseInt(o(this,Gr,"f").style.left,10),Number.parseInt(o(this,Gr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Gr,"f").style.top=`${e}px`,o(this,Gr,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",os);var is=Object.freeze({__proto__:null,default:os});const rs='\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 ss=Object.freeze({__proto__:null,default:(t,e,o)=>n(void 0,void 0,void 0,(function*(){const{siteId:e}=t,n=rs.replace(/{{SITE_ID}}/g,e),i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("id",e),i.text=n,document.body.appendChild(i),document.addEventListener("ftr:tokenReady",(t=>{o(t.detail)}))}))});const as=(t,e,o)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:e,useCloudflareIntegration:n,cloudflareScriptUrl:i,cloudflareEndpointUrl:r}=t;let s=[];s=n&&r?[r,an]:[an];let a=[];if(n&&i){const t=new URL(i);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();o(d)}catch(t){console.warn("Could not load fingerprint",t)}}));var ls=Object.freeze({__proto__:null,default:as,loadFingerprint:as});const cs=(t,e,o)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:i,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:i,endpoint:[c.toString(),an],scriptUrlPattern:[u,fn]}),p=yield h,{requestId:f}=yield p.get();o(f)}catch(t){console.warn("Could not load descope fingerprint",t)}}));var ds=Object.freeze({__proto__:null,default:cs,loadFingerprint:cs})}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/web-component",
3
- "version": "3.32.10",
3
+ "version": "3.33.0",
4
4
  "author": "Descope Team <info@descope.com>",
5
5
  "homepage": "https://github.com/descope/descope-js",
6
6
  "bugs": {
@@ -21,15 +21,15 @@
21
21
  ],
22
22
  "devDependencies": {
23
23
  "@open-wc/rollup-plugin-html": "1.2.5",
24
- "@rollup/plugin-commonjs": "^27.0.0",
24
+ "@rollup/plugin-commonjs": "^28.0.0",
25
25
  "@rollup/plugin-node-resolve": "^15.0.0",
26
26
  "@rollup/plugin-replace": "^5.0.0",
27
27
  "@rollup/plugin-typescript": "^11.0.0",
28
28
  "@testing-library/dom": "^10.0.0",
29
- "@testing-library/jest-dom": "6.4.6",
29
+ "@testing-library/jest-dom": "6.6.3",
30
30
  "@types/testing-library__jest-dom": "5.14.9",
31
31
  "@types/jest": "^29.0.0",
32
- "@types/node": "20.17.12",
32
+ "@types/node": "20.17.13",
33
33
  "dotenv": "^16.0.3",
34
34
  "eslint": "8.57.1",
35
35
  "eslint-config-airbnb": "19.0.4",
@@ -38,20 +38,20 @@
38
38
  "eslint-config-standard": "17.1.0",
39
39
  "eslint-import-resolver-typescript": "3.6.1",
40
40
  "eslint-plugin-import": "2.31.0",
41
- "eslint-plugin-jest": "28.6.0",
41
+ "eslint-plugin-jest": "28.10.0",
42
42
  "eslint-plugin-jest-dom": "5.4.0",
43
43
  "eslint-plugin-jest-formatting": "3.1.0",
44
44
  "eslint-plugin-n": "17.9.0",
45
45
  "eslint-plugin-no-only-tests": "3.3.0",
46
46
  "eslint-plugin-prefer-arrow": "1.2.3",
47
47
  "eslint-plugin-prettier": "5.1.3",
48
- "eslint-plugin-promise": "6.2.0",
48
+ "eslint-plugin-promise": "6.6.0",
49
49
  "jest": "^29.0.0",
50
50
  "jest-environment-jsdom": "^29.0.0",
51
51
  "lint-staged": "^15.0.0",
52
52
  "prettier": "^3.0.0",
53
53
  "pretty-quick": "^4.0.0",
54
- "rollup": "^3.0.0",
54
+ "rollup": "^4.0.0",
55
55
  "rollup-plugin-browsersync": "^1.3.3",
56
56
  "rollup-plugin-define": "^1.0.1",
57
57
  "rollup-plugin-delete": "^2.0.0",
@@ -67,10 +67,10 @@
67
67
  "dependencies": {
68
68
  "tslib": "2.8.1",
69
69
  "@fingerprintjs/fingerprintjs-pro": "3.11.6",
70
- "@descope/sdk-helpers": "0.1.66",
71
- "@descope/sdk-mixins": "0.6.7",
72
- "@descope/escape-markdown": "0.1.4",
73
- "@descope/web-js-sdk": "1.23.8"
70
+ "@descope/sdk-helpers": "0.1.67",
71
+ "@descope/sdk-mixins": "0.7.0",
72
+ "@descope/web-js-sdk": "1.23.9",
73
+ "@descope/escape-markdown": "0.1.5"
74
74
  },
75
75
  "overrides": {
76
76
  "terser": "5.37.0"