@descope/web-component 3.43.15 → 3.43.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("tslib"),e=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins/static-resources-mixin"),s=require("@descope/sdk-mixins/theme-mixin"),r=require("@descope/sdk-mixins/inject-style-mixin"),n=require("@descope/web-js-sdk"),o=require("../constants/index.js"),a=require("../helpers/helpers.js"),l=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var u,d,c,h,g,f,p,v,_,b,m,w,C,k,A,F,P,x,E,y,I,G,j=require("../helpers/flowInputs.js"),S=require("../mixins/formMountMixin.js"),M=require("../constants/content.js"),U=require("../constants/general.js");function L(t){return Object.freeze({__proto__:null,default:t})}const O=e.compose(s.themeMixin,i.staticResourcesMixin,S.formMountMixin,r.injectStyleMixin)(HTMLElement);class q extends O{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),u.add(this),c.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,u,"m",I).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)}},h.set(this,new l),g.set(this,new l),f.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,f,"f"),this.nextRequestStatus=new l({isLoading:!1}),p.set(this,void 0),v.set(this,{popstate:t.__classPrivateFieldGet(this,u,"m",C).bind(this),componentsContext:t.__classPrivateFieldGet(this,u,"m",x).bind(this)}),_.set(this,void 0),this.getConfig=()=>t.__awaiter(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),t.__classPrivateFieldSet(this,_,e,"f"),t.__classPrivateFieldGet(this,u,"m",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 refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}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 j.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return j.extractNestedAttribute(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}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,g,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",y).bind(this)),t.__classPrivateFieldGet(this,g,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,u,"m",w).call(this),yield t.__classPrivateFieldGet(this,u,"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,u,"m",G).call(this);const{executionId:r,stepId:n,token:o,code:l,isPopup:d,exchangeError:f,redirectAuthCallbackUrl:p,redirectAuthBackupCallbackUri:_,redirectAuthCodeChallenge:b,redirectAuthInitiator:m,ssoQueryParams:C}=a.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,h,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",A).bind(this)),t.__classPrivateFieldGet(this,h,"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:r,token:o,code:l,isPopup:d,exchangeError:f,redirectAuthCallbackUrl:p,redirectAuthBackupCallbackUri:_,redirectAuthCodeChallenge:b,redirectAuthInitiator:m},C)),t.__classPrivateFieldSet(this,c,!0,"f")}))}disconnectedCallback(){t.__classPrivateFieldGet(this,h,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,g,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,u,"m",E).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,c,"f")&&i!==s&&d.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,u,"m",w).call(this);const r=null===i;t.__classPrivateFieldGet(this,h,"f").update((({stepId:t,executionId:i})=>{let n=t,o=i;return r||(o=null,n=null,a.clearRunIdsFromUrl()),{[a.camelCase(e)]:s,stepId:n,executionId:o}})),t.__classPrivateFieldGet(this,g,"f").update({isDebug:this.debug})}}}d=q,c=new WeakMap,h=new WeakMap,g=new WeakMap,f=new WeakMap,p=new WeakMap,v=new WeakMap,_=new WeakMap,u=new WeakSet,b=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},m=function(){t.__classPrivateFieldGet(this,u,"m",b).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},w=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes"];d.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[a.camelCase(e)])throw Error(`${e} cannot be empty`)}))},C=function(){const{stepId:e,executionId:i}=a.getRunIdsFromUrl(this.flowId);t.__classPrivateFieldGet(this,h,"f").update({stepId:e,executionId:i})},k=function(e,i){this.sdk=n(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},d.sdkConfigOverrides),{projectId:e,baseUrl:i})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){try{return yield i(...e)}catch(t){return{error:{errorCode:U.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}}))}))},A=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,u,"m",k).call(this,i,r)}t.__classPrivateFieldGet(this,_,"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,u,"m",P).call(this))}))},P=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=a.getContentUrl({projectId:this.projectId,filename:M.CONFIG_FILENAME,assetsFolder:M.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield a.fetchContent(t,"json"),!0}catch(t){return!1}}))},x=function(e){t.__classPrivateFieldSet(this,f,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,f,"f")),e.detail),"f")},E=function(){var e;null===(e=t.__classPrivateFieldGet(this,p,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,p,null,"f")},y=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,p,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,p,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return L(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,p,"f"))):t.__classPrivateFieldGet(this,u,"m",E).call(this)}))},I=function(e,i){var s;e&&this.debug&&(null===(s=t.__classPrivateFieldGet(this,p,"f"))||void 0===s||s.updateData({title:e,description:i}))},G=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.43.15"}},module.exports=q;
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/sdk-mixins/inject-style-mixin"),n=require("@descope/web-js-sdk"),o=require("../constants/index.js"),a=require("../helpers/helpers.js"),l=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var u,d,c,h,g,f,p,v,_,b,m,w,C,k,A,F,P,x,E,y,I,G,j=require("../helpers/flowInputs.js"),S=require("../mixins/formMountMixin.js"),M=require("../constants/content.js"),U=require("../constants/general.js");function L(t){return Object.freeze({__proto__:null,default:t})}const O=e.compose(s.themeMixin,i.staticResourcesMixin,S.formMountMixin,r.injectStyleMixin)(HTMLElement);class q extends O{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),u.add(this),c.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,u,"m",I).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)}},h.set(this,new l),g.set(this,new l),f.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,f,"f"),this.nextRequestStatus=new l({isLoading:!1}),p.set(this,void 0),v.set(this,{popstate:t.__classPrivateFieldGet(this,u,"m",C).bind(this),componentsContext:t.__classPrivateFieldGet(this,u,"m",x).bind(this)}),_.set(this,void 0),this.getConfig=()=>t.__awaiter(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),t.__classPrivateFieldSet(this,_,e,"f"),t.__classPrivateFieldGet(this,u,"m",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 refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}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 j.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return j.extractNestedAttribute(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}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,g,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",y).bind(this)),t.__classPrivateFieldGet(this,g,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,u,"m",w).call(this),yield t.__classPrivateFieldGet(this,u,"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,u,"m",G).call(this);const{executionId:r,stepId:n,token:o,code:l,isPopup:d,exchangeError:f,redirectAuthCallbackUrl:p,redirectAuthBackupCallbackUri:_,redirectAuthCodeChallenge:b,redirectAuthInitiator:m,ssoQueryParams:C}=a.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,h,"f").subscribe(t.__classPrivateFieldGet(this,u,"m",A).bind(this)),t.__classPrivateFieldGet(this,h,"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:r,token:o,code:l,isPopup:d,exchangeError:f,redirectAuthCallbackUrl:p,redirectAuthBackupCallbackUri:_,redirectAuthCodeChallenge:b,redirectAuthInitiator:m},C)),t.__classPrivateFieldSet(this,c,!0,"f")}))}disconnectedCallback(){t.__classPrivateFieldGet(this,h,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,g,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,u,"m",E).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,c,"f")&&i!==s&&d.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,u,"m",w).call(this);const r=null===i;t.__classPrivateFieldGet(this,h,"f").update((({stepId:t,executionId:i})=>{let n=t,o=i;return r||(o=null,n=null,a.clearRunIdsFromUrl()),{[a.camelCase(e)]:s,stepId:n,executionId:o}})),t.__classPrivateFieldGet(this,g,"f").update({isDebug:this.debug})}}}d=q,c=new WeakMap,h=new WeakMap,g=new WeakMap,f=new WeakMap,p=new WeakMap,v=new WeakMap,_=new WeakMap,u=new WeakSet,b=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},m=function(){t.__classPrivateFieldGet(this,u,"m",b).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},w=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes"];d.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[a.camelCase(e)])throw Error(`${e} cannot be empty`)}))},C=function(){const{stepId:e,executionId:i}=a.getRunIdsFromUrl(this.flowId);t.__classPrivateFieldGet(this,h,"f").update({stepId:e,executionId:i})},k=function(e,i){this.sdk=n(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},d.sdkConfigOverrides),{projectId:e,baseUrl:i})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){try{return yield i(...e)}catch(t){return{error:{errorCode:U.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}}))}))},A=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,u,"m",k).call(this,i,r)}t.__classPrivateFieldGet(this,_,"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,u,"m",P).call(this))}))},P=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=a.getContentUrl({projectId:this.projectId,filename:M.CONFIG_FILENAME,assetsFolder:M.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield a.fetchContent(t,"json"),!0}catch(t){return!1}}))},x=function(e){t.__classPrivateFieldSet(this,f,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,f,"f")),e.detail),"f")},E=function(){var e;null===(e=t.__classPrivateFieldGet(this,p,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,p,null,"f")},y=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,p,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,p,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return L(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,p,"f"))):t.__classPrivateFieldGet(this,u,"m",E).call(this)}))},I=function(e,i){var s;e&&this.debug&&(null===(s=t.__classPrivateFieldGet(this,p,"f"))||void 0===s||s.updateData({title:e,description:i}))},G=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.43.16"}},module.exports=q;
2
2
  //# sourceMappingURL=BaseDescopeWc.js.map
@@ -1,2 +1,2 @@
1
- import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import{compose as r}from"@descope/sdk-helpers";import{staticResourcesMixin as o}from"@descope/sdk-mixins/static-resources-mixin";import{themeMixin as s}from"@descope/sdk-mixins/theme-mixin";import{injectStyleMixin as n}from"@descope/sdk-mixins/inject-style-mixin";import u from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as a}from"../constants/index.js";import{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 m,extractNestedAttribute as b}from"../helpers/flowInputs.js";import{formMountMixin as v}from"../mixins/formMountMixin.js";import{CONFIG_FILENAME as w,PREV_VER_ASSETS_FOLDER as k}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as C}from"../constants/general.js";var A,x,y,j,I,E,L,U,M,S,O,W,D,P,N,F,R,T,B,V,q,H;const J=r(s,o,v,n)(HTMLElement);class K extends J{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(r){super(),A.add(this),y.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,A,"m",q).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 p),I.set(this,new p),E.set(this,{}),this.getComponentsContext=()=>t(this,E,"f"),this.nextRequestStatus=new p({isLoading:!1}),L.set(this,void 0),U.set(this,{popstate:t(this,A,"m",D).bind(this),componentsContext:t(this,A,"m",T).bind(this)}),M.set(this,void 0),this.getConfig=()=>e(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,M,r,"f"),t(this,A,"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 refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}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 m(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return b(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}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,A,"m",V).bind(this)),t(this,I,"f").update({isDebug:this.debug}),t(this,A,"m",W).call(this),yield t(this,A,"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 o=yield this.getConfig();if("isMissingConfig"in o&&o.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t(this,A,"m",H).call(this);const{executionId:s,stepId:n,token:u,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:g,redirectAuthInitiator:p,ssoQueryParams:m}=l(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,A,"m",N).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:s,token:u,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:g,redirectAuthInitiator:p},m)),i(this,y,!0,"f")}))}disconnectedCallback(){t(this,j,"f").unsubscribeAll(),t(this,I,"f").unsubscribeAll(),t(this,A,"m",B).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,A,"m",W).call(this);const o=null===i;t(this,j,"f").update((({stepId:t,executionId:i})=>{let s=t,n=i;return o||(n=null,s=null,d()),{[c(e)]:r,stepId:s,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,A=new WeakSet,S=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},O=function(){t(this,A,"m",S).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},W=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes"];x.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[c(e)])throw Error(`${e} cannot be empty`)}))},D=function(){const{stepId:e,executionId:i}=h(this.flowId);t(this,j,"f").update({stepId:e,executionId:i})},P=function(t,i){this.sdk=u(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},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*(){try{return yield i(...t)}catch(t){return{error:{errorCode:C,errorDescription:t.toString()}}}}))}))},N=function(i,r,o){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:r}=i;if(o("projectId")||o("baseUrl")){if(!e)return;t(this,A,"m",P).call(this,e,r)}t(this,M,"f").call(this,i)}))},F=function(){return e(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t(this,A,"m",R).call(this))}))},R=function(){return e(this,void 0,void 0,(function*(){const t=f({projectId:this.projectId,filename:w,assetsFolder:k,baseUrl:this.baseStaticUrl});try{return yield g(t,"json"),!0}catch(t){return!1}}))},T=function(e){i(this,E,Object.assign(Object.assign({},t(this,E,"f")),e.detail),"f")},B=function(){var e;null===(e=t(this,L,"f"))||void 0===e||e.remove(),i(this,L,null,"f")},V=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,A,"m",B).call(this)}))},q=function(e,i){var r;e&&this.debug&&(null===(r=t(this,L,"f"))||void 0===r||r.updateData({title:e,description:i}))},H=function(){this.rootElement.onkeydown=t=>{var e,i,r;const o=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),s=a.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||o||s)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 u=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===u.length)return void u[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.43.15"}};export{K as default};
1
+ import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import{compose as r}from"@descope/sdk-helpers";import{staticResourcesMixin as o}from"@descope/sdk-mixins/static-resources-mixin";import{themeMixin as s}from"@descope/sdk-mixins/theme-mixin";import{injectStyleMixin as n}from"@descope/sdk-mixins/inject-style-mixin";import u from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as a}from"../constants/index.js";import{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 m,extractNestedAttribute as b}from"../helpers/flowInputs.js";import{formMountMixin as v}from"../mixins/formMountMixin.js";import{CONFIG_FILENAME as w,PREV_VER_ASSETS_FOLDER as k}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as C}from"../constants/general.js";var A,x,y,j,I,E,L,U,M,S,O,W,D,P,N,F,R,T,B,V,q,H;const J=r(s,o,v,n)(HTMLElement);class K extends J{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(r){super(),A.add(this),y.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,A,"m",q).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 p),I.set(this,new p),E.set(this,{}),this.getComponentsContext=()=>t(this,E,"f"),this.nextRequestStatus=new p({isLoading:!1}),L.set(this,void 0),U.set(this,{popstate:t(this,A,"m",D).bind(this),componentsContext:t(this,A,"m",T).bind(this)}),M.set(this,void 0),this.getConfig=()=>e(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,M,r,"f"),t(this,A,"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 refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}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 m(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return b(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const t=JSON.parse(this.getAttribute("outbound-app-scopes"));return t||null}catch(t){return null}}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,A,"m",V).bind(this)),t(this,I,"f").update({isDebug:this.debug}),t(this,A,"m",W).call(this),yield t(this,A,"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 o=yield this.getConfig();if("isMissingConfig"in o&&o.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t(this,A,"m",H).call(this);const{executionId:s,stepId:n,token:u,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:g,redirectAuthInitiator:p,ssoQueryParams:m}=l(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,A,"m",N).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:s,token:u,code:a,isPopup:d,exchangeError:c,redirectAuthCallbackUrl:h,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:g,redirectAuthInitiator:p},m)),i(this,y,!0,"f")}))}disconnectedCallback(){t(this,j,"f").unsubscribeAll(),t(this,I,"f").unsubscribeAll(),t(this,A,"m",B).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,A,"m",W).call(this);const o=null===i;t(this,j,"f").update((({stepId:t,executionId:i})=>{let s=t,n=i;return o||(n=null,s=null,d()),{[c(e)]:r,stepId:s,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,A=new WeakSet,S=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},O=function(){t(this,A,"m",S).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},W=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes"];x.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[c(e)])throw Error(`${e} cannot be empty`)}))},D=function(){const{stepId:e,executionId:i}=h(this.flowId);t(this,j,"f").update({stepId:e,executionId:i})},P=function(t,i){this.sdk=u(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},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*(){try{return yield i(...t)}catch(t){return{error:{errorCode:C,errorDescription:t.toString()}}}}))}))},N=function(i,r,o){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:r}=i;if(o("projectId")||o("baseUrl")){if(!e)return;t(this,A,"m",P).call(this,e,r)}t(this,M,"f").call(this,i)}))},F=function(){return e(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield t(this,A,"m",R).call(this))}))},R=function(){return e(this,void 0,void 0,(function*(){const t=f({projectId:this.projectId,filename:w,assetsFolder:k,baseUrl:this.baseStaticUrl});try{return yield g(t,"json"),!0}catch(t){return!1}}))},T=function(e){i(this,E,Object.assign(Object.assign({},t(this,E,"f")),e.detail),"f")},B=function(){var e;null===(e=t(this,L,"f"))||void 0===e||e.remove(),i(this,L,null,"f")},V=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,A,"m",B).call(this)}))},q=function(e,i){var r;e&&this.debug&&(null===(r=t(this,L,"f"))||void 0===r||r.updateData({title:e,description:i}))},H=function(){this.rootElement.onkeydown=t=>{var e,i,r;const o=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),s=a.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||o||s)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 u=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===u.length)return void u[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.43.16"}};export{K as default};
2
2
  //# sourceMappingURL=BaseDescopeWc.js.map
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- !function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function n(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((i=i.apply(e,t||[])).next())}))}function i(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function o(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;class r extends Error{}function s(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}function a(e,t){if("string"!=typeof e)throw new r("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,i=e.split(".")[n];if("string"!=typeof i)throw new r(`Invalid token specified: missing part #${n+1}`);let o;try{o=s(i)}catch(e){throw new r(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new r(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}r.prototype.name="InvalidTokenError";var l={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const c="<region>",d=`https://api.${c}descope.com`,u=6e5,h="dct",p=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};let g;const f=()=>{if(g)return g;const e=new Date,t=`${e.getUTCFullYear().toString()}-${(e.getUTCMonth()+1).toString().padStart(2,"0")}-${e.getUTCDate().toString().padStart(2,"0")}-${e.getUTCHours().toString().padStart(2,"0")}:${e.getUTCMinutes().toString().padStart(2,"0")}:${e.getUTCSeconds().toString().padStart(2,"0")}:${e.getUTCMilliseconds().toString()}`,n=Math.floor(1e3+9e3*Math.random());return g=`${t}-${n}`,g};var v;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(v||(v={}));const m=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(c,o?o+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,i)=>{r=`${r}${0===i?"?":""}${t}=${encodeURIComponent(n[t])}${i===e.length-1?"":"&"}`}))}return r},b=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,i])=>(e[n]=i,e)),e),e}),{})),w={"Content-Type":"application/json"},y=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},k=(e,t)=>{const n={"x-descope-sdk-session-id":f(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.44.2","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},I=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e},S=({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const l=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.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"),e?async(...t)=>{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");e.log((e=>p().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await n(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return p().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(i)),i}:n})(o,a),c=async o=>{var a;const c=(null==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:d,body:u,headers:h,queryParams:p,method:g,token:f}=c,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),S={headers:b(y(t,f),k(t,i),(null==n?void 0:n.baseHeaders)||{},I(v)?w:{},h),method:g,body:v};null!==s&&(S.credentials=s||"include");const O=await l(m({path:d,baseUrl:e,queryParams:p,projectId:t}),S);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(o,null==O?void 0:O.clone()),null==r?void 0:r.transformResponse){const e=await O.json(),t=((null===(a=O.headers)||void 0===a?void 0:a.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,i]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:i})}),{}),n=Object.assign(Object.assign({},O),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}return O};return{get:(e,{headers:t,queryParams:n,token:i}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:v.get,token:i}),post:(e,t,{headers:n,queryParams:i,token:o}={})=>c({path:e,headers:n,queryParams:i,body:t,method:v.post,token:o}),patch:(e,t,{headers:n,queryParams:i,token:o}={})=>c({path:e,headers:n,queryParams:i,body:t,method:v.patch,token:o}),put:(e,t,{headers:n,queryParams:i,token:o}={})=>c({path:e,headers:n,queryParams:i,body:t,method:v.put,token:o}),delete:(e,{headers:t,queryParams:n,token:i}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:v.delete,token:i}),hooks:r,buildUrl:(n,i)=>m({projectId:t,baseUrl:e,path:n,queryParams:i})}};var O=429;function C(e,t,n){var i;let o=x(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[h])===t)return(null==o?void 0:o[n])||[];o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[t]}const r=null==o?void 0:o[n];return Array.isArray(r)?r:[]}function x(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return a(e)}function j(e){const{exp:t}=x(e);return(new Date).getTime()/1e3>t}function A(e){let t=x(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function E(e,t){return C(e,t,"permissions")}function U(e,t){return C(e,t,"roles")}const R=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function T(e,t){var n;const i=await e,o={code:i.status,ok:i.ok,response:i},r=await i.clone().json();return i.ok?o.data=r:(o.error=r,i.status===O&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function $(e){var t;return(null===(t=x(e))||void 0===t?void 0:t[h])||""}const L=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),P=(e,t)=>(n=t)=>t=>{const i=e.filter((e=>e(t)));return!(i.length<e.length)&&(n?n.replace("{val}",t):i.join(" OR "))},N=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),_=e=>t=>e.test(t),M=_(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),W=_(/^\+[1-9]{1}[0-9]{3,14}$/),D=L(M,'"{val}" is not a valid email'),q=L(W,'"{val}" is not a valid phone number'),F=L((e=>e.length>=1),"Minimum length is 1");const K=L((e=>"string"==typeof e),"Input is not a string"),J=L((e=>Array.isArray(e)),"Input is not an array"),V=L((e=>"boolean"==typeof e),"Input is not a boolean"),H=L((e=>void 0===e),"Input is defined"),B=P([K(),H()],"Input is not a string or undefined"),z=P([J(),V()],"Input is not an array or boolean"),G=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>N(...e).validate(n[t]))),t(...n)),Z=e=>[K(`"${e}" must be a string`)],X=e=>[B(`"${e}" must be string or undefined`)],Y=e=>[K(`"${e}" must be a string`),F(`"${e}" must not be empty`)],Q=e=>[K(`"${e}" must be a string`),D()],ee=e=>[K(`"${e}" must be a string`),q()],te=G(Y("accessKey")),ne=e=>({exchange:te(((t,n)=>T(e.post(l.accessKey.exchange,{loginOptions:n},{token:t}))))}),ie=(e,t,n)=>(t.forEach((t=>{const i=t.split(".");let o=i.shift(),r=e;for(;i.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof r[o])throw Error(`"${t}" is not a function`);const s=r[o];r[o]=n(s)})),e),oe=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||u,u)});var re,se;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(re||(re={})),function(e){e.email="email"}(se||(se={}));const ae=Object.assign(Object.assign({},re),se);var le;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(le||(le={}));const ce=Y("loginId"),de=G(Y("token")),ue=G(ce),he=G(Y("pendingRef")),pe=G(ce,Q("email")),ge=e=>({verify:de((t=>T(e.post(l.enchantedLink.verify,{token:t})))),signIn:ue(((t,n,i,o)=>T(e.post(R(l.enchantedLink.signIn,ae.email),{loginId:t,URI:n,loginOptions:i},{token:o})))),signUpOrIn:ue(((t,n,i)=>T(e.post(R(l.enchantedLink.signUpOrIn,ae.email),{loginId:t,URI:n,loginOptions:i})))),signUp:ue(((t,n,i,o)=>T(e.post(R(l.enchantedLink.signUp,ae.email),{loginId:t,URI:n,user:i,loginOptions:o})))),waitForSession:he(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=oe(n);let s;const a=setInterval((async()=>{const n=await e.post(l.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(T(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:pe(((t,n,i,o,r)=>T(e.post(l.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o}))))}}),fe=G(Y("flowId")),ve=G(Y("executionId"),Y("stepId"),Y("interactionId")),me=e=>({start:fe(((t,n,i,o,r,s,a)=>T(e.post(l.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a})))),next:ve(((t,n,i,o,r,s)=>T(e.post(l.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s}))))}),be=Y("loginId"),we=G(Y("token")),ye=G(be),ke=G(be,ee("phone")),Ie=G(be,Q("email")),Se=Object.keys(ae).filter((e=>e!==re.voice)),Oe=e=>({verify:we((t=>T(e.post(l.magicLink.verify,{token:t})))),signIn:Se.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,i,o,r)=>T(e.post(R(l.magicLink.signIn,n),{loginId:t,URI:i,loginOptions:o},{token:r}))))})),{}),signUp:Se.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,i,o,r)=>T(e.post(R(l.magicLink.signUp,n),{loginId:t,URI:i,user:o,loginOptions:r}))))})),{}),signUpOrIn:Se.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,i,o)=>T(e.post(R(l.magicLink.signUpOrIn,n),{loginId:t,URI:i,loginOptions:o}))))})),{}),update:{email:Ie(((t,n,i,o,r)=>T(e.post(l.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(re).filter((e=>e!==re.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ke(((t,i,o,r,s)=>T(e.post(R(l.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var Ce;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(Ce||(Ce={}));const xe=G(Y("code")),je=e=>({start:Object.assign(((t,n,i,o,r)=>T(e.post(l.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(Ce).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>T(e.post(l.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:xe((t=>T(e.post(l.oauth.exchange,{code:t})))),startNative:(t,n,i)=>T(e.post(l.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>T(e.post(l.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>T(e.get(l.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>T(e.post(l.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>T(e.post(l.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),Ae=Y("appId"),Ee=G(Ae),Ue=e=>({connect:Ee(((t,n,i)=>T(e.post(l.outbound.connect,{appId:t,options:n},{token:i}))))}),Re=Y("loginId"),Te=G(Re,Y("code")),$e=G(Re),Le=G(Re,ee("phone")),Pe=G(Re,Q("email")),Ne=e=>({verify:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Te(((t,i)=>T(e.post(R(l.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:$e(((t,i,o)=>T(e.post(R(l.otp.signIn,n),{loginId:t,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:$e(((t,i,o)=>T(e.post(R(l.otp.signUp,n),{loginId:t,user:i,loginOptions:o}))))})),{}),signUpOrIn:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:$e(((t,i)=>T(e.post(R(l.otp.signUpOrIn,n),{loginId:t,loginOptions:i}))))})),{}),update:{email:Pe(((t,n,i,o)=>T(e.post(l.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(re).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Le(((t,i,o,r)=>T(e.post(R(l.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),_e=G(Y("tenant")),Me=G(Y("code")),We=e=>({start:_e(((t,n,i,o,r)=>T(e.post(l.saml.start,i||{},Object.assign({queryParams:Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r})},o&&{token:o}))))),exchange:Me((t=>T(e.post(l.saml.exchange,{code:t}))))}),De=Y("loginId"),qe=G(De,Y("code")),Fe=G(De),Ke=G(De),Je=e=>({signUp:Fe(((t,n)=>T(e.post(l.totp.signUp,{loginId:t,user:n})))),verify:qe(((t,n,i,o)=>T(e.post(l.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:Ke(((t,n)=>T(e.post(l.totp.update,{loginId:t},{token:n}))))}),Ve=Y("loginId"),He=Y("newPassword"),Be=G(Ve,Y("password")),ze=G(Ve),Ge=G(Ve,He),Ze=G(Ve,Y("oldPassword"),He),Xe=e=>({signUp:Be(((t,n,i,o)=>T(e.post(l.password.signUp,{loginId:t,password:n,user:i,loginOptions:o})))),signIn:Be(((t,n,i)=>T(e.post(l.password.signIn,{loginId:t,password:n,loginOptions:i})))),sendReset:ze(((t,n,i)=>T(e.post(l.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:Ge(((t,n,i)=>T(e.post(l.password.update,{loginId:t,newPassword:n},{token:i})))),replace:Ze(((t,n,i)=>T(e.post(l.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>T(e.get(l.password.policy))}),Ye=Z("loginId"),Qe=Y("loginId"),et=Y("origin"),tt=G(Qe,et,Y("name")),nt=G(Qe,et),it=G(Ye,et),ot=G(Qe,et,X("token")),rt=G(Y("transactionId"),Y("response")),st=e=>({signUp:{start:tt(((t,n,i,o)=>T(e.post(l.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,passkeyOptions:o})))),finish:rt(((t,n)=>T(e.post(l.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:it(((t,n,i,o,r)=>T(e.post(l.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:rt(((t,n)=>T(e.post(l.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:nt(((t,n,i)=>T(e.post(l.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:i}))))},update:{start:ot(((t,n,i,o)=>T(e.post(l.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o},{token:i})))),finish:rt(((t,n)=>T(e.post(l.webauthn.update.finish,{transactionId:t,response:n}))))}}),at=Z("loginId"),lt=G(at),ct=G(Y("pendingRef")),dt=e=>({signUpOrIn:lt(((t,n)=>T(e.post(l.notp.signUpOrIn,{loginId:t,loginOptions:n})))),signUp:lt(((t,n,i)=>T(e.post(l.notp.signUp,{loginId:t,user:n,loginOptions:i})))),signIn:lt(((t,n,i)=>T(e.post(l.notp.signIn,{loginId:t,loginOptions:n},{token:i})))),waitForSession:ct(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=oe(n);let s;const a=setInterval((async()=>{const n=await e.post(l.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(T(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),ut=G(Y("token")),ht=G(X("token"));var pt,gt=G([(pt=Y("projectId"),L(((e,t)=>n=>N(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=n.length;let o=0,r=e===Object(e)?e:void 0;for(;null!=r&&o<i;)r=r[n[o++]];return o&&o===i&&void 0!==r?r:void 0})(n,e)))("projectId",pt))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a})=>{return c=S({baseUrl:n||d,projectId:e,logger:t,hooks:i,cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:ne(c),otp:Ne(c),magicLink:Oe(c),enchantedLink:ge(c),oauth:je(c),outbound:Ue(c),saml:We(c),totp:Je(c),notp:dt(c),webauthn:st(c),password:Xe(c),flow:me(c),refresh:ht(((e,t,n)=>{const i={};return n&&(i.externalToken=n),T(c.post(l.refresh,i,{token:e,queryParams:t}))})),selectTenant:G([K("tenantId")],[B('"token" must be string or undefined')])(((e,t)=>T(c.post(l.selectTenant,{tenant:e},{token:t})))),logout:ht((e=>T(c.post(l.logout,{},{token:e})))),logoutAll:ht((e=>T(c.post(l.logoutAll,{},{token:e})))),me:ht((e=>T(c.get(l.me,{token:e})))),myTenants:G([z('"tenants" must a string array or a boolean')],[B('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,T(c.post(l.myTenants,n,{token:t}))})),history:ht((e=>T(c.get(l.history,{token:e})))),isJwtExpired:ut(j),getTenants:ut(A),getJwtPermissions:ut(E),getJwtRoles:ut(U),getCurrentTenant:ut($),httpClient:c};var c})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))})),ft=Object.assign(gt,{DeliveryMethods:ae});
1
+ !function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function n(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((i=i.apply(e,t||[])).next())}))}function i(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function o(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;class r extends Error{}function s(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}function a(e,t){if("string"!=typeof e)throw new r("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,i=e.split(".")[n];if("string"!=typeof i)throw new r(`Invalid token specified: missing part #${n+1}`);let o;try{o=s(i)}catch(e){throw new r(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new r(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}r.prototype.name="InvalidTokenError";var l={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const c="<region>",d=`https://api.${c}descope.com`,u=6e5,h="dct",p=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};let g;const f=()=>{if(g)return g;const e=new Date,t=`${e.getUTCFullYear().toString()}-${(e.getUTCMonth()+1).toString().padStart(2,"0")}-${e.getUTCDate().toString().padStart(2,"0")}-${e.getUTCHours().toString().padStart(2,"0")}:${e.getUTCMinutes().toString().padStart(2,"0")}:${e.getUTCSeconds().toString().padStart(2,"0")}:${e.getUTCMilliseconds().toString()}`,n=Math.floor(1e3+9e3*Math.random());return g=`${t}-${n}`,g};var v;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(v||(v={}));const m=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(c,o?o+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,i)=>{r=`${r}${0===i?"?":""}${t}=${encodeURIComponent(n[t])}${i===e.length-1?"":"&"}`}))}return r},b=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,i])=>(e[n]=i,e)),e),e}),{})),w={"Content-Type":"application/json"},y=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},k=(e,t)=>{const n={"x-descope-sdk-session-id":f(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.44.3","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},I=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e},S=({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const l=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.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"),e?async(...t)=>{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");e.log((e=>p().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await n(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return p().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(i)),i}:n})(o,a),c=async o=>{var a;const c=(null==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:d,body:u,headers:h,queryParams:p,method:g,token:f}=c,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),S={headers:b(y(t,f),k(t,i),(null==n?void 0:n.baseHeaders)||{},I(v)?w:{},h),method:g,body:v};null!==s&&(S.credentials=s||"include");const O=await l(m({path:d,baseUrl:e,queryParams:p,projectId:t}),S);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(o,null==O?void 0:O.clone()),null==r?void 0:r.transformResponse){const e=await O.json(),t=((null===(a=O.headers)||void 0===a?void 0:a.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,i]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:i})}),{}),n=Object.assign(Object.assign({},O),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}return O};return{get:(e,{headers:t,queryParams:n,token:i}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:v.get,token:i}),post:(e,t,{headers:n,queryParams:i,token:o}={})=>c({path:e,headers:n,queryParams:i,body:t,method:v.post,token:o}),patch:(e,t,{headers:n,queryParams:i,token:o}={})=>c({path:e,headers:n,queryParams:i,body:t,method:v.patch,token:o}),put:(e,t,{headers:n,queryParams:i,token:o}={})=>c({path:e,headers:n,queryParams:i,body:t,method:v.put,token:o}),delete:(e,{headers:t,queryParams:n,token:i}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:v.delete,token:i}),hooks:r,buildUrl:(n,i)=>m({projectId:t,baseUrl:e,path:n,queryParams:i})}};var O=429;function C(e,t,n){var i;let o=x(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[h])===t)return(null==o?void 0:o[n])||[];o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[t]}const r=null==o?void 0:o[n];return Array.isArray(r)?r:[]}function x(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return a(e)}function j(e){const{exp:t}=x(e);return(new Date).getTime()/1e3>t}function A(e){let t=x(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function E(e,t){return C(e,t,"permissions")}function U(e,t){return C(e,t,"roles")}const R=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function T(e,t){var n;const i=await e,o={code:i.status,ok:i.ok,response:i},r=await i.clone().json();return i.ok?o.data=r:(o.error=r,i.status===O&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function $(e){var t;return(null===(t=x(e))||void 0===t?void 0:t[h])||""}const L=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),P=(e,t)=>(n=t)=>t=>{const i=e.filter((e=>e(t)));return!(i.length<e.length)&&(n?n.replace("{val}",t):i.join(" OR "))},N=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),_=e=>t=>e.test(t),M=_(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),W=_(/^\+[1-9]{1}[0-9]{3,14}$/),D=L(M,'"{val}" is not a valid email'),q=L(W,'"{val}" is not a valid phone number'),F=L((e=>e.length>=1),"Minimum length is 1");const K=L((e=>"string"==typeof e),"Input is not a string"),J=L((e=>Array.isArray(e)),"Input is not an array"),V=L((e=>"boolean"==typeof e),"Input is not a boolean"),H=L((e=>void 0===e),"Input is defined"),B=P([K(),H()],"Input is not a string or undefined"),z=P([J(),V()],"Input is not an array or boolean"),G=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>N(...e).validate(n[t]))),t(...n)),Z=e=>[K(`"${e}" must be a string`)],X=e=>[B(`"${e}" must be string or undefined`)],Y=e=>[K(`"${e}" must be a string`),F(`"${e}" must not be empty`)],Q=e=>[K(`"${e}" must be a string`),D()],ee=e=>[K(`"${e}" must be a string`),q()],te=G(Y("accessKey")),ne=e=>({exchange:te(((t,n)=>T(e.post(l.accessKey.exchange,{loginOptions:n},{token:t}))))}),ie=(e,t,n)=>(t.forEach((t=>{const i=t.split(".");let o=i.shift(),r=e;for(;i.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof r[o])throw Error(`"${t}" is not a function`);const s=r[o];r[o]=n(s)})),e),oe=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||u,u)});var re,se;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(re||(re={})),function(e){e.email="email"}(se||(se={}));const ae=Object.assign(Object.assign({},re),se);var le;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(le||(le={}));const ce=Y("loginId"),de=G(Y("token")),ue=G(ce),he=G(Y("pendingRef")),pe=G(ce,Q("email")),ge=e=>({verify:de((t=>T(e.post(l.enchantedLink.verify,{token:t})))),signIn:ue(((t,n,i,o)=>T(e.post(R(l.enchantedLink.signIn,ae.email),{loginId:t,URI:n,loginOptions:i},{token:o})))),signUpOrIn:ue(((t,n,i)=>T(e.post(R(l.enchantedLink.signUpOrIn,ae.email),{loginId:t,URI:n,loginOptions:i})))),signUp:ue(((t,n,i,o)=>T(e.post(R(l.enchantedLink.signUp,ae.email),{loginId:t,URI:n,user:i,loginOptions:o})))),waitForSession:he(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=oe(n);let s;const a=setInterval((async()=>{const n=await e.post(l.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(T(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:pe(((t,n,i,o,r)=>T(e.post(l.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o}))))}}),fe=G(Y("flowId")),ve=G(Y("executionId"),Y("stepId"),Y("interactionId")),me=e=>({start:fe(((t,n,i,o,r,s,a)=>T(e.post(l.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a})))),next:ve(((t,n,i,o,r,s)=>T(e.post(l.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s}))))}),be=Y("loginId"),we=G(Y("token")),ye=G(be),ke=G(be,ee("phone")),Ie=G(be,Q("email")),Se=Object.keys(ae).filter((e=>e!==re.voice)),Oe=e=>({verify:we((t=>T(e.post(l.magicLink.verify,{token:t})))),signIn:Se.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,i,o,r)=>T(e.post(R(l.magicLink.signIn,n),{loginId:t,URI:i,loginOptions:o},{token:r}))))})),{}),signUp:Se.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,i,o,r)=>T(e.post(R(l.magicLink.signUp,n),{loginId:t,URI:i,user:o,loginOptions:r}))))})),{}),signUpOrIn:Se.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,i,o)=>T(e.post(R(l.magicLink.signUpOrIn,n),{loginId:t,URI:i,loginOptions:o}))))})),{}),update:{email:Ie(((t,n,i,o,r)=>T(e.post(l.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(re).filter((e=>e!==re.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ke(((t,i,o,r,s)=>T(e.post(R(l.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var Ce;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(Ce||(Ce={}));const xe=G(Y("code")),je=e=>({start:Object.assign(((t,n,i,o,r)=>T(e.post(l.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(Ce).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>T(e.post(l.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:xe((t=>T(e.post(l.oauth.exchange,{code:t})))),startNative:(t,n,i)=>T(e.post(l.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>T(e.post(l.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>T(e.get(l.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>T(e.post(l.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>T(e.post(l.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),Ae=Y("appId"),Ee=G(Ae),Ue=e=>({connect:Ee(((t,n,i)=>T(e.post(l.outbound.connect,{appId:t,options:n},{token:i}))))}),Re=Y("loginId"),Te=G(Re,Y("code")),$e=G(Re),Le=G(Re,ee("phone")),Pe=G(Re,Q("email")),Ne=e=>({verify:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Te(((t,i)=>T(e.post(R(l.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:$e(((t,i,o)=>T(e.post(R(l.otp.signIn,n),{loginId:t,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:$e(((t,i,o)=>T(e.post(R(l.otp.signUp,n),{loginId:t,user:i,loginOptions:o}))))})),{}),signUpOrIn:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:$e(((t,i)=>T(e.post(R(l.otp.signUpOrIn,n),{loginId:t,loginOptions:i}))))})),{}),update:{email:Pe(((t,n,i,o)=>T(e.post(l.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(re).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Le(((t,i,o,r)=>T(e.post(R(l.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),_e=G(Y("tenant")),Me=G(Y("code")),We=e=>({start:_e(((t,n,i,o,r)=>T(e.post(l.saml.start,i||{},Object.assign({queryParams:Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r})},o&&{token:o}))))),exchange:Me((t=>T(e.post(l.saml.exchange,{code:t}))))}),De=Y("loginId"),qe=G(De,Y("code")),Fe=G(De),Ke=G(De),Je=e=>({signUp:Fe(((t,n)=>T(e.post(l.totp.signUp,{loginId:t,user:n})))),verify:qe(((t,n,i,o)=>T(e.post(l.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:Ke(((t,n)=>T(e.post(l.totp.update,{loginId:t},{token:n}))))}),Ve=Y("loginId"),He=Y("newPassword"),Be=G(Ve,Y("password")),ze=G(Ve),Ge=G(Ve,He),Ze=G(Ve,Y("oldPassword"),He),Xe=e=>({signUp:Be(((t,n,i,o)=>T(e.post(l.password.signUp,{loginId:t,password:n,user:i,loginOptions:o})))),signIn:Be(((t,n,i)=>T(e.post(l.password.signIn,{loginId:t,password:n,loginOptions:i})))),sendReset:ze(((t,n,i)=>T(e.post(l.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:Ge(((t,n,i)=>T(e.post(l.password.update,{loginId:t,newPassword:n},{token:i})))),replace:Ze(((t,n,i)=>T(e.post(l.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>T(e.get(l.password.policy))}),Ye=Z("loginId"),Qe=Y("loginId"),et=Y("origin"),tt=G(Qe,et,Y("name")),nt=G(Qe,et),it=G(Ye,et),ot=G(Qe,et,X("token")),rt=G(Y("transactionId"),Y("response")),st=e=>({signUp:{start:tt(((t,n,i,o)=>T(e.post(l.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,passkeyOptions:o})))),finish:rt(((t,n)=>T(e.post(l.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:it(((t,n,i,o,r)=>T(e.post(l.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:rt(((t,n)=>T(e.post(l.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:nt(((t,n,i)=>T(e.post(l.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:i}))))},update:{start:ot(((t,n,i,o)=>T(e.post(l.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o},{token:i})))),finish:rt(((t,n)=>T(e.post(l.webauthn.update.finish,{transactionId:t,response:n}))))}}),at=Z("loginId"),lt=G(at),ct=G(Y("pendingRef")),dt=e=>({signUpOrIn:lt(((t,n)=>T(e.post(l.notp.signUpOrIn,{loginId:t,loginOptions:n})))),signUp:lt(((t,n,i)=>T(e.post(l.notp.signUp,{loginId:t,user:n,loginOptions:i})))),signIn:lt(((t,n,i)=>T(e.post(l.notp.signIn,{loginId:t,loginOptions:n},{token:i})))),waitForSession:ct(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=oe(n);let s;const a=setInterval((async()=>{const n=await e.post(l.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(T(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),ut=G(Y("token")),ht=G(X("token"));var pt,gt=G([(pt=Y("projectId"),L(((e,t)=>n=>N(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=n.length;let o=0,r=e===Object(e)?e:void 0;for(;null!=r&&o<i;)r=r[n[o++]];return o&&o===i&&void 0!==r?r:void 0})(n,e)))("projectId",pt))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a})=>{return c=S({baseUrl:n||d,projectId:e,logger:t,hooks:i,cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:ne(c),otp:Ne(c),magicLink:Oe(c),enchantedLink:ge(c),oauth:je(c),outbound:Ue(c),saml:We(c),totp:Je(c),notp:dt(c),webauthn:st(c),password:Xe(c),flow:me(c),refresh:ht(((e,t,n)=>{const i={};return n&&(i.externalToken=n),T(c.post(l.refresh,i,{token:e,queryParams:t}))})),selectTenant:G([K("tenantId")],[B('"token" must be string or undefined')])(((e,t)=>T(c.post(l.selectTenant,{tenant:e},{token:t})))),logout:ht((e=>T(c.post(l.logout,{},{token:e})))),logoutAll:ht((e=>T(c.post(l.logoutAll,{},{token:e})))),me:ht((e=>T(c.get(l.me,{token:e})))),myTenants:G([z('"tenants" must a string array or a boolean')],[B('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,T(c.post(l.myTenants,n,{token:t}))})),history:ht((e=>T(c.get(l.history,{token:e})))),isJwtExpired:ut(j),getTenants:ut(A),getJwtPermissions:ut(E),getJwtRoles:ut(U),getCurrentTenant:ut($),httpClient:c};var c})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))})),ft=Object.assign(gt,{DeliveryMethods:ae});
2
2
  /*! js-cookie v3.0.5 | MIT */
3
- function vt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)e[i]=n[i]}return e}var mt=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=vt({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(i[a]=t.read(s,a),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",vt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,vt({},this.attributes,t))},withConverter:function(t){return e(vt({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var bt={default:"endpoint"},wt="Blocked by CSP",yt="The endpoint parameter is not a valid URL",kt="Failed to load the JS script of the agent",It="9319";function St(e,t){var n,i,o,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===wt||s===yt)n.exclude(),r=0;else if(s===It)n.exclude();else if(s===kt){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var Ot="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Ct=Ot;function xt(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:Ot,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return St(e,jt)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===It?new Error(kt):e}(e)})).then((function(t){var n=t[0],i=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function jt(e){return function(e,t,n){var i,o=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(yt);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(kt))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(wt)})).then(At)}function At(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==i?void 0:i.configurable)?delete e[t]:i&&!i.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(It);return n}const Et=e=>{try{return a(e).exp}catch(e){return null}},Ut=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Et(n)},Rt=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?Et(i):void 0)},Tt=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[i])||[]).concat((null==t?void 0:t[i])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},$t=async e=>{if(!(null==e?void 0:e.ok))return{};const n=await(null==e?void 0:e.clone().json());return(e=>{const{access_token:n,id_token:i,refresh_token:o,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:i,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||Rt(e),cookieExpiration:e.cookieExpiration||Ut(e)},s)})((null==n?void 0:n.authInfo)||n||{})},Lt=async e=>{const t=await $t(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Pt="undefined"!=typeof localStorage,Nt=(e,t)=>Pt&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),_t=e=>Pt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),Mt=e=>Pt&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Wt=(...e)=>{console.debug(...e)},Dt="3.2.0",qt="undefined"!=typeof window,Ft=Math.pow(2,31)-1,Kt=`https://descopecdn.com/npm/oidc-client-ts@${Dt}/dist/browser/oidc-client-ts.min.js`,Jt=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Dt}/dist/browser/oidc-client-ts.min.js`,Vt="DS",Ht="DSR",Bt="DSI";function zt(e=""){return _t(`${e}${Ht}`)||""}function Gt(e=""){return mt.get(Vt)||_t(`${e}${Vt}`)||""}function Zt(e=""){return _t(`${e}${Bt}`)||""}function Xt(e=""){Mt(`${e}${Ht}`),Mt(`${e}${Vt}`),Mt(`${e}${Bt}`),mt.remove(Vt)}const Yt=qt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Qt="vsid",en="vrid",tn="fp",nn=(e=!1)=>{const t=localStorage.getItem(tn);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},on=async(e,t=Yt)=>{try{if(nn())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=xt({apiKey:e,endpoint:[i.toString(),bt],scriptUrlPattern:[r,Ct]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Qt]:e,[en]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(tn,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},rn=e=>{const t=nn(!0);return t&&e.body&&(e.body.fpData=t),e},sn="descopeFlowNonce",an="X-Descope-Flow-Nonce",ln="/v1/flow/start",cn="/v1/flow/next",dn=(e,t=sn)=>`${t}${e}`,un=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},hn=e=>{var t;return e.path===cn&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?un(e.body.executionId):null},pn="dls_last_user_login_id",gn="dls_last_user_display_name",fn=()=>_t(pn),vn=()=>_t(gn),mn=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=fn(),r=vn();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)};function bn(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function wn(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Cn(n.publicKey.challenge),n.publicKey.user.id=Cn(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Cn(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:xn(n.rawId),type:n.type,response:{attestationObject:xn(n.response.attestationObject),clientDataJSON:xn(n.response.clientDataJSON)}});var n}async function yn(e){const t=Sn(e);return On(await navigator.credentials.get(t))}async function kn(e,t){const n=Sn(e);return n.signal=t.signal,n.mediation="conditional",On(await navigator.credentials.get(n))}async function In(e=!1){if(!qt)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Sn(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Cn(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Cn(e.id)})),n}function On(e){return JSON.stringify({id:e.id,rawId:xn(e.rawId),type:e.type,response:{authenticatorData:xn(e.response.authenticatorData),clientDataJSON:xn(e.response.clientDataJSON),signature:xn(e.response.signature),userHandle:e.response.userHandle?xn(e.response.userHandle):void 0}})}function Cn(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function xn(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var jn,An=(jn=e=>({async signUp(t,n,i){const o=await e.webauthn.signUp.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await wn(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,n){const i=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await yn(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(t,n){var i;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const t=await wn(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await yn(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,i){const o=await e.webauthn.update.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await wn(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:wn,get:yn,isSupported:In,conditional:kn}}),(...e)=>{const t=jn(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const En="/fedcm/config",Un=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function Rn(e,t){var n;try{await Tn(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Tn(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=Un(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(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?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void d()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var $n=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await In(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});let Ln;const Pn=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Pn(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Nn=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{Ln||(Ln=(async()=>{try{return require("oidc-client-ts")}catch(e){return Pn([Kt,Jt],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await Ln;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=t,s=(null==n?void 0:n.redirectUri)||window.location.href,a=(null==n?void 0:n.scope)||"openid email roles descope.custom_claims offline_access",l=`${r}_user`;let c=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(c=`${c}/${n.applicationId}`);const d={authority:c,client_id:t,redirect_uri:s,response_type:"code",scope:a,stateStore:new o({store:window.localStorage,prefix:r}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),(null==n?void 0:n.scope)&&(d.scope=n.scope),{client:new i(d),stateUserKey:l}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),window.localStorage.setItem(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(e={},t=!1)=>{const{client:n}=await i(),o=await n.createSigninRequest(e),{url:r}=o;return t||(window.location.href=r),{ok:!0,data:o}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:r}=await i(),s=(e=>{const t=window.localStorage.getItem(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||Zt(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return window.localStorage.removeItem(o),t||window.location.replace(s),r}}},_n=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return qt?(i&&o&&on(i).catch((()=>null)),e(Tt(r,{beforeRequest:rn}))):e(r)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);if(!i||"undefined"!=typeof window&&window.descopeBridge)return e(o);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let l,c;qt&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(Wt("Expiration time passed, refreshing session"),d.refresh(zt()||c))}));const d=e(Tt(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o}=await $t(t);if(401===(null==t?void 0:t.status))Wt("Received 401, canceling all timers"),r();else if(n||o){if(l=((e,t)=>{if(t)return new Date(1e3*t);Wt("Could not extract expiration time from session token, trying to decode the token");try{const t=a(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!l)return void Wt("Could not extract expiration time from session token");c=i;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>Ft&&(Wt(`Timeout is too large (${t}ms), setting it to ${Ft}ms`),t=Ft),t})(l);if(r(),e<=2e4)return void Wt("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Wt(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Wt("Refreshing session due to timer"),d.refresh(zt()||i)}),e)}}}));return ie(d,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Wt("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.33.3"},t.baseHeaders)}))),(e=>t=>{const n=bn(),i=bn(),o=bn(),r=e(Tt(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))i.pub(null),o.pub(null),n.pub(null);else{const e=await Lt(t);e&&o.pub(e);const{sessionJwt:r,sessionExpiration:s}=await $t(t);r&&i.pub(r),(s||r)&&n.pub(s||42)}}})),s=ie(r,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const r=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r}));return Object.assign(s,{onSessionTokenChange:i.sub,onUserChange:o.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{const{enableFlowNonce:i=!0,nonceStoragePrefix:o=sn}=n,r=t(n,["enableFlowNonce","nonceStoragePrefix"]);return i?(((e=sn)=>{try{if(!Pt)return;for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(n&&n.startsWith(e)){const t=_t(n);if(t)try{JSON.parse(t).expiry<Date.now()&&Mt(n)}catch(e){Mt(n)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}})(o),e(Tt(r,{afterRequest:async(e,t)=>{if(e.path!==ln&&e.path!==cn)return;const{nonce:n,executionId:i}=await(async(e,t)=>{try{const n=t.headers.get(an);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=hn(e)),{nonce:n,executionId:un(i)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&i&&((e,t,n,i=sn)=>{try{const o=dn(e,i),r=n?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:n};Nt(o,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(i,n,e.path===ln,o)},beforeRequest:e=>{if(e.path===cn){const t=hn(e);if(t){const n=((e,t=sn)=>{try{const n=dn(e,t),i=_t(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(((e,t=sn)=>{try{const n=dn(e,t);Mt(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):o.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,o);n&&(e.headers=e.headers||{},e.headers[an]=n)}}return e}}))):e(r)}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:fn,getLastUserDisplayName:vn});const s=e(Tt(r,{afterRequest:async(e,t)=>{var n;const i=await Lt(t),o=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],r=null==i?void 0:i.name;o&&((e=>{Nt(pn,e)})(o),(e=>{Nt(gn,e)})(r))}}));let a=ie(s,["flow.start"],mn);return a=ie(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(Mt(pn),Mt(gn)),i})(o)),Object.assign(a,{getLastUserLoginId:fn,getLastUserDisplayName:vn})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!qt)return e(s);const a=e(Tt(s,{beforeRequest:(l=r,e=>Object.assign(e,{token:e.token||zt(l)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||Xt(r):((e={},t=!1,n="")=>{var i;const{sessionJwt:o,refreshJwt:r}=e;if(r&&Nt(`${n}${Ht}`,r),o)if(t){const n=t.sameSite||"Strict",r=null===(i=t.secure)||void 0===i||i;!function(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(i);mt.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:r,secure:a})}}(Vt,o,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:r}))}else Nt(`${n}${Vt}`,o);e.idToken&&Nt(`${n}${Bt}`,e.idToken)})(await $t(t),o,r)}}));var l;const c=ie(a,["logout","logoutAll","oidc.logout"],(e=>t=>async(...n)=>{const i=await t(...n);return Xt(e),i})(r));return Object.assign(c,{getRefreshToken:()=>zt(r),getSessionToken:()=>Gt(r),getIdToken:()=>Zt(r)})}))((e=>{const t=ft(e),n=Nn(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async i=>{var o;if(e.oidcConfig)try{return await n.refreshToken(i),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}const r=Gt(),s=zt();let a="";if(e.getExternalToken)try{a=await(null===(o=e.getExternalToken)||void 0===o?void 0:o.call(e))}catch(e){Wt("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:r?"t":"f",dcr:s?"t":"f"},a)},logout:async i=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i)},flow:$n(t),webauthn:An(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){Rn(i,e)},requestAuthentication(e){Rn(i,e)}},async oneTap(e,t,n,o,r){await Tn(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(o+En),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>qt&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+En);try{const i={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var i,o})),Mn="undefined"!=typeof localStorage,Wn="J151000",Dn=Mn&&localStorage.getItem("base.content.url")||"",qn="base.ui.components.url";Mn&&localStorage.getItem(qn),Mn&&localStorage.getItem(qn);const Fn="descope-login-flow",Kn="code",Jn="redirect_mode",Vn="data-exclude-field",Hn="data-exclude-next",Bn="dls_last_auth",zn="state_id",Gn="saml_idp_state_id",Zn="saml_idp_username",Xn="descope_idp_initiated",Yn="sso_app_id",Qn="third_party_app_id",ei="third_party_app_state_id",ti="oidc_login_hint",ni="oidc_prompt",ii="oidc_error_redirect_uri",oi="application_scopes",ri="data-type",si="redirect",ai="poll",li="webauthnCreate",ci="webauthnGet",di="nativeBridge",ui="loadForm",hi="submit",pi="polling",gi=["descope-multi-select-combo-box","descope-text-area"],fi=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var vi;!function(e){e.backward="backward",e.forward="forward"}(vi||(vi={}));const mi=["descope-enriched-text"];function bi(e){return new URLSearchParams(window.location.search).get(e)}function wi(e){if(window.history.replaceState&&bi(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function yi(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?vi.forward:n<i?vi.backward:void 0}const ki=e=>{let[t="",n=""]=(bi(Fn)||"").split("_");const i=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||i&&i!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:i}};function Ii(){wi(Fn)}const Si=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Oi=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=ki(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&Ii();const r=bi("t")||void 0;r&&wi("t");const s=bi(Kn)||void 0;s&&wi(Kn);const a="popup"===bi(Jn);a&&wi(Jn);const l=bi("err")||void 0;l&&wi("err");const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:bi("ra-challenge"),redirectAuthCallbackUrl:bi("ra-callback"),redirectAuthBackupCallbackUri:bi("ra-backup-callback"),redirectAuthInitiator:bi("ra-initiator")},p=bi(zn);p&&wi(zn);const g=bi(Gn);g&&wi(Gn);const f=bi(Zn);g&&wi(Zn);const v=bi(Xn);v&&wi(Xn);const m=bi(Yn);m&&wi(Yn);const b=bi(Qn);b&&wi(Qn);const w=bi(ei);w&&wi(ei);const y=bi(oi);y&&wi(oi);const k=bi(ti);k&&wi(ti);const I=bi(ni);I&&wi(ni);const S=bi(ii);S&&wi(ii);return{executionId:n,stepId:i,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:g,samlIdpUsername:f,descopeIdpInitiated:"true"===v,ssoAppId:m,oidcLoginHint:k,oidcPrompt:I,oidcErrorRedirectUri:S,thirdPartyAppId:b,thirdPartyAppStateId:w,applicationScopes:y}}},Ci=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})},xi=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}};function ji(e,t,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),i(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const Ai=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:i,ssoAppId:o,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,thirdPartyAppId:l,thirdPartyAppStateId:c,applicationScopes:d})=>!(!e||t||n||i||o||r||s||a||l||c||d),Ei=e=>null==e?void 0:e.submit(),Ui=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Ri=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function Ti(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const $i=e=>{var t,n,i;const o=(r=e.screenState,s=(e,t)=>fi.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(r).filter((([e,t])=>!s(t,e)))));var r,s;const{screenState:{errorText:a,errorType:l}}=e;return(a||l)&&(o.error={text:a,type:l}),e.action&&(o.action=e.action),(null===(i=null===(n=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===n?void 0:n.thirdPartyAppApproveScopes)||void 0===i?void 0:i.data)&&(o.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),o},Li=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Pi(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Ni,_i,Mi,Wi;function Di(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Di(r,s))return!1}else if(r!==s)return!1}return!0}class qi{constructor(e={},{forceUpdate:t=!1}={}){Ni.set(this,void 0),_i.set(this,{}),Mi.set(this,0),Wi.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,Ni,"f")):e,n=Object.assign(Object.assign({},i(this,Ni,"f")),t),r=i(this,Ni,"f");o(this,Ni,n,"f"),Object.freeze(i(this,Ni,"f")),setTimeout((()=>{Object.values(i(this,_i,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const s=t(r),a=t(n);(i(this,Wi,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!Di(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},o(this,Ni,e,"f"),o(this,Wi,t,"f")}get current(){return Object.assign({},i(this,Ni,"f"))}set forceUpdate(e){o(this,Wi,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,Mi,i(this,Mi,"f")+1,"f"),i(this,_i,"f")[i(this,Mi,"f")]={cb:e,selector:t,forceUpdate:n},i(this,Mi,"f").toString()}unsubscribe(e){const t=!!i(this,_i,"f")[e];return t&&delete i(this,_i,"f")[e],t}unsubscribeAll(){return o(this,_i,{},"f"),!0}}Ni=new WeakMap,_i=new WeakMap,Mi=new WeakMap,Wi=new WeakMap;const Fi=["*","#","/","(",")","[","]","_","<",">","`"],Ki=e=>{const t=Fi.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")},Ji=["disabled"],Vi=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Vn}])`)).forEach((e=>{e.value=n}))}))},Hi=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),Bi=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?(e=>"string"!=typeof e?e:e.replace(Ki("\\"),"\\$1"))(Hi(t,i)):Hi(t,i))),zi=(e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(i=e.localName,mi.includes(i));var i;e.textContent=Bi(e.textContent,t,n);const o=e.getAttribute("href");o&&e.setAttribute("href",Bi(o,t))}))},Gi=(e,t,n)=>{e.querySelectorAll(`[${ri}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Zi=(e,t,n)=>{var i,o;const r=null===(i=customElements.get(t))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},Xi=(e,n,i,o,r)=>{var s,a;Gi(e,"totp-link",null===(s=null==n?void 0:n.totp)||void 0===s?void 0:s.provisionUrl),Gi(e,"notp-link",null===(a=null==n?void 0:n.notp)||void 0===a?void 0:a.redirectUrl),zi(e,n),((e,n,i)=>{if(!n)return;const{componentsDynamicAttrs:o}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});o&&Object.keys(o).forEach((e=>{const t=o[e];if(t){const{attributes:n}=t;n&&Object.keys(n).length&&(s[e]=n)}})),Object.keys(s).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const n=s[t];Object.keys(n).forEach((t=>{let o=n[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,i,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=Bi(e.value,t)}))}))})(e,n),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{Ji.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)},Yi=Ci((()=>n(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield ji(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}})))),Qi=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]},eo="dls_ab_testing_id",to={"lastAuth.loginId":{"not-empty":e=>!!e.loginId,empty:e=>!e.loginId},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||((e.abTestingKey||0)<n||(e.abTestingKey||0)>i)},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function no(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(Bn)))}catch(e){}return t}function io(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const oo=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const i=e(n);return i[t]=!0,i}},ro=["error","warn","info","debug"],so=oo((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,i(this,t,"m",r).call(this,console))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e||console),"f")}get logger(){return i(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return ro.reduce(((t,n)=>(t[n]=(...t)=>{var i;this.onLogEvent(n,t),null===(i=e[n])||void 0===i||i.call(e,...t)},t)),{})},s})),ao="undefined"!=typeof localStorage,lo=ao&&localStorage.getItem("base.content.url")||"",co=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,uo=oo((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&i(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),ho=oo((e=>{var t,n;const o=io(so,uo)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=i(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){i(this,t,"f")[e]||(i(this,t,"f")[e]=[]);const o=i(this,t,"f")[e].push(n);return()=>i(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),po=e=>t=>{var n,o,r;const s=io(so,uo,ho)(t),a=Object.keys(e);return r=class extends s{constructor(...e){super(...e),n.add(this),this.observeAttributes(a,i(this,n,"m",o).bind(this))}async init(){var e;a.forEach((e=>i(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},r};po.missingAttrValidator=co;const go=oo((e=>{const t=io(po({"project-id":co}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),fo=oo((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),vo="Trying the next fallback URL...",mo=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};function bo({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i="https://static.descope.com/pages"}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}const wo=oo((e=>{var t,n,r,s,a;const l=io(so,go,fo)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0),r.set(this,void 0)}async fetchStaticResource(e,n){const a=i(this,t,"m",s).call(this,e),l=Array.isArray(a)?e=>{if(e!==a.length-1){const{baseUrl:t}=a[e];o(this,r,t,"f")}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:i}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const r=o[e],s=e===o.length-1;try{const o=await mo(r.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${vo}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${vo}`)}}})(a,{cache:"default"},{logger:this.logger,onSuccess:l});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")}},n=new WeakMap,r=new WeakMap,t=new WeakSet,s=function(e){const t=lo||this.baseStaticUrl;if(t)return bo({projectId:this.projectId,filename:e,baseUrl:t});const s=i(this,n,"f")!==this.baseUrl,a=s&&!!this.baseUrl;s&&(o(this,n,this.baseUrl,"f"),o(this,r,void 0,"f"));const l=bo({projectId:this.projectId,filename:e,baseUrl:i(this,r,"f")});if(!a)return l;return[bo({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),l]},a})),yo=oo((e=>{var t,n;const o=io(po({"project-id":co}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return i(this,t,"f").set(e,n),()=>{i(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(i(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=i(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),ko=oo((e=>{var t,n,r,s,a;const l=io(wo,yo,uo)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),r.set(this,void 0),s.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,t,"m",n).bind(this))}get config(){return i(this,r,"f")||o(this,r,i(this,s,"f").call(this),"f"),i(this,r,"f")}},r=new WeakMap,s=new WeakMap,t=new WeakSet,n=function(){o(this,r,void 0,"f")},a})),Io=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],So=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},Oo=(e,t)=>new Promise(((n,i)=>{const o=(e=>{const t=document.createElement("script");return t.id=e,t})(e);o.onerror=e=>{o.setAttribute("status","error"),i(e)},o.onload=()=>{o.setAttribute("status","loaded"),n(o)},o.src=t.toString(),document.body.appendChild(o)})),Co=e=>"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))})),xo=oo((e=>{const t=io(so)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[]){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"`),(async(e,t)=>{for(const i of e){const{id:e,url:o}=i,r=(n=e,document.querySelector(`script#${n}`));if(r)try{return await Co(r),i}catch(e){t(i,!0)}else try{return await Oo(e,o),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="")=>e.reduce(((e,o)=>{const r=o;if(!r)return e;let s;try{s=new URL(r)}catch(e){throw new Error(`Invalid URL: ${r}`)}return"/"!==s.pathname||(s.pathname=`/npm/${t}@${n}/${i}`),[...e,{url:s,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${So(s)}`}]}),[]))([...i,this.baseCdnUrl,...Io],e,t,n),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),jo="base.ui.components.url",Ao=ao&&localStorage.getItem(jo),Eo=oo((e=>{var t,n,r,s,a,l;const c=io(so,ko,xo)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),r.set(this,void 0)}get descopeUi(){return i(this,r,"f")||o(this,r,i(this,t,"m",a).call(this),"f"),i(this,r,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>i(this,t,"m",s).call(this,e))))}},r=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},a=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{return await this.injectNpmLib("@descope/web-components-ui",await i(this,t,"m",n).call(this),"dist/umd/index.js",[Ao]),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},l})),Uo=oo((e=>{var t,n,o;const r=io(uo,ho)(e);return o=class extends r{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",i(this,t,"m",n).bind(this)),i(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){window.DESCOPE_NONCE=this.nonce},o}));class Ro{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const To=oo((e=>{const t=io(Uo)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new Ro(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),$o="content-root",Lo="root",Po=oo((e=>{const t=io(To)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${Lo}">\n <div id="${$o}"></div>\n </div>\n `,this.injectStyle(`\n #${Lo}, #${$o} {\n height: 100%;\n }\n #${Lo} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById($o),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Lo)}}})),No=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',_o=oo((e=>{var t,n,r,s,a,l,c,d,u,h,p,g,f,v;const m=io(po({theme:No}),wo,uo,Eo,ko,Po,ho,To)(e);return v=class extends m{constructor(){super(...arguments),t.add(this),n.set(this,void 0),r.set(this,void 0),p.set(this,(()=>{i(this,t,"m",g).call(this),i(this,f,"f").call(this,"os"===this.getAttribute("theme"))})),f.set(this,(e=>{var n,o,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===r||r.call(o,"change",(()=>i(this,t,"m",g).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,p,"f").call(this),await Promise.all([i(this,t,"m",l).call(this),i(this,t,"m",c).call(this)]),this.observeAttributes(["theme"],i(this,p,"f")),this.observeAttributes(["style-id"],(()=>{o(this,r,null,"f"),i(this,t,"m",u).call(this),i(this,t,"m",l).call(this),i(this,t,"m",c).call(this)}))}},n=new WeakMap,r=new WeakMap,p=new WeakMap,f=new WeakMap,t=new WeakSet,s=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},a=function(){return i(this,r,"f")||(o(this,r,i(this,t,"m",s).call(this),"f"),i(this,r,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,r,"f")},l=async function(){var e,r;const s=await i(this,t,"a",a);s&&(i(this,n,"f")||o(this,n,this.injectStyle(""),"f"),i(this,n,"f").replaceSync(((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||"")))},c=async function(){var e,n;const o=await i(this,t,"a",a);if(!o)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.components,dark:null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.components})},d=async function(){var e,t;const{projectConfig:n}=await this.config||{},i=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,r=i||o;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},u=async function(){const e=await i(this,t,"m",d).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},h=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},g=function(){i(this,t,"m",u).call(this),i(this,t,"m",h).call(this)},v})),Mo=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),Mo(e[i],`${t+i}.`));const r="object"==typeof e[i]?e[i]:{value:e[i]},s=Object.assign(Object.assign({},n),{[t+i]:r,[`form.${t}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),Wo=oo((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;i(this,t,"m",n).call(this)&&i(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},r}));var Do,qo,Fo,Ko,Jo,Vo,Ho,Bo,zo,Go,Zo,Xo,Yo,Qo,er,tr,nr,ir,or,rr,sr,ar;const lr=io(_o,wo,Wo,To)(HTMLElement);class cr extends lr{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),Do.add(this),Fo.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,Do,"m",sr).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)},debug:(e,t="")=>{this.logger.debug(e,t)}},Ko.set(this,new qi),Jo.set(this,new qi),Vo.set(this,{}),this.getComponentsContext=()=>i(this,Vo,"f"),this.nextRequestStatus=new qi({isLoading:!1}),Ho.set(this,void 0),Bo.set(this,{popstate:i(this,Do,"m",Yo).bind(this),componentsContext:i(this,Do,"m",ir).bind(this)}),zo.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,zo,e,"f"),i(this,Do,"m",Zo).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){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 e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}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(e=>{try{return Mo(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return e=this.formConfig,t="value",Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]])));var e,t}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const e=JSON.parse(this.getAttribute("outbound-app-scopes"));return e||null}catch(e){return null}}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig(),n="projectConfig"in t?null===(e=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 e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),i(this,Jo,"f").subscribe(i(this,Do,"m",rr).bind(this)),i(this,Jo,"f").update({isDebug:this.debug}),i(this,Do,"m",Xo).call(this),yield i(this,Do,"m",tr).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");i(this,Do,"m",ar).call(this);const{executionId:r,stepId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:g,ssoQueryParams:f}=Oi(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,Bo,"f").popstate),window.addEventListener("components-context",i(this,Bo,"f").componentsContext),i(this,Ko,"f").subscribe(i(this,Do,"m",er).bind(this)),i(this,Ko,"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,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:g},f)),o(this,Fo,!0,"f")}))}disconnectedCallback(){i(this,Ko,"f").unsubscribeAll(),i(this,Jo,"f").unsubscribeAll(),i(this,Do,"m",or).call(this),window.removeEventListener("popstate",i(this,Bo,"f").popstate),window.removeEventListener("components-context",i(this,Bo,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,Fo,"f")&&t!==n&&qo.observedAttributes.includes(e)){i(this,Do,"m",Xo).call(this);const o=null===t;i(this,Ko,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Ii()),{[Si(e)]:n,stepId:r,executionId:s}})),i(this,Jo,"f").update({isDebug:this.debug})}}}var dr,ur,hr,pr,gr,fr,vr,mr,br,wr,yr,kr,Ir,Sr,Or,Cr,xr,jr,Ar,Er,Ur,Rr,Tr,$r,Lr,Pr,Nr,_r,Mr,Wr,Dr,qr,Fr,Kr,Jr,Vr,Hr,Br,zr,Gr,Zr,Xr,Yr,Qr,es;qo=cr,Fo=new WeakMap,Ko=new WeakMap,Jo=new WeakMap,Vo=new WeakMap,Ho=new WeakMap,Bo=new WeakMap,zo=new WeakMap,Do=new WeakSet,Go=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},Zo=function(){i(this,Do,"m",Go).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Xo=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes"];qo.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Si(t)])throw Error(`${t} cannot be empty`)}))},Yo=function(){const{stepId:e,executionId:t}=ki(this.flowId);i(this,Ko,"f").update({stepId:e,executionId:t})},Qo=function(e,t){this.sdk=_n(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},qo.sdkConfigOverrides),{projectId:e,baseUrl:t})),["start","next"].forEach((e=>{const t=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>n(this,void 0,void 0,(function*(){try{return yield t(...e)}catch(e){return{error:{errorCode:Wn,errorDescription:e.toString()}}}}))}))},er=function(e,t,o){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(o("projectId")||o("baseUrl")){if(!t)return;i(this,Do,"m",Qo).call(this,t,n)}i(this,zo,"f").call(this,e)}))},tr=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,Do,"m",nr).call(this))}))},nr=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(Dn||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t](),headers:Object.fromEntries(n.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},ir=function(e){o(this,Vo,Object.assign(Object.assign({},i(this,Vo,"f")),e.detail),"f")},or=function(){var e;null===(e=i(this,Ho,"f"))||void 0===e||e.remove(),o(this,Ho,null,"f")},rr=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,Ho,document.createElement("descope-debugger"),"f"),Object.assign(i(this,Ho,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return rs})),document.body.appendChild(i(this,Ho,"f"))):i(this,Do,"m",or).call(this)}))},sr=function(e,t){var n;e&&this.debug&&(null===(n=i(this,Ho,"f"))||void 0===n||n.updateData({title:e,description:t}))},ar=function(){this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=gi.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||o||r)return;e.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((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}},cr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.43.15"}};class ts extends cr{static set sdkConfigOverrides(e){cr.sdkConfigOverrides=e}static get sdkConfigOverrides(){return cr.sdkConfigOverrides}constructor(){const e=new qi({deferredRedirect:!1});super(e.update.bind(e)),dr.add(this),this.stepState=new qi({}),ur.set(this,void 0),hr.set(this,null),pr.set(this,null),gr.set(this,{visibilitychange:i(this,dr,"m",fr).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},Sr.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},Cr.set(this,(e=>{const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?i(this,dr,"m",xr).call(this,t):t()})),jr.set(this,((e,t,r,s,a=!1)=>{if(this.flowState.current.action===ai){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),c=a?500:2e3;o(this,ur,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const o=this.sdk.flow.next(e,t,pi,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 e=d?1e3:6e3;u=yield ji(e,o)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,jr,"f").call(this,e,t,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===Wn)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,jr,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),i(this,jr,"f").call(this,e,t,r,s),i(this,Er,"f").call(this,u)}))),c),"f")}})),Ar.set(this,(()=>{clearTimeout(i(this,ur,"f")),o(this,ur,null,"f")})),Er.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,g,f;if(!(null==e?void 0:e.ok)){const o=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;i(this,dr,"m",Kr).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||o,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||c);const d=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==d&&"E103205"!==d||!this.isRestartOnError||i(this,dr,"m",Ir).call(this))}null===(d=null===(c=e.data)||void 0===c?void 0:c.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const v=null===(p=null===(h=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(g=e.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:b,lastAuth:w,action:y,openInNewTabUrl:k}=e.data;if(y!==ai&&i(this,Ar,"f").call(this),"completed"===m)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&Mn&&localStorage.setItem(Bn,JSON.stringify(e))}(w),void i(this,dr,"m",Kr).call(this,"success",b);k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:O,screen:C,redirect:x,webauthn:j,error:A,samlIdpResponse:E,nativeResponse:U}=e.data,R=Date.now();y!==ai?(this.loggerWrapper.info(`Step "${O||`#${S}`}" is ${m}`,"",{screen:C,status:m,stepId:S,stepName:O,action:y,error:A}),(null===(f=C.state)||void 0===f?void 0:f.clientScripts)&&o(this,pr,this.loadSdkScripts(C.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:O,executionId:I,action:y,redirectTo:null==x?void 0:x.url,redirectIsPopup:null==x?void 0:x.isPopup,screenId:null==C?void 0:C.id,screenState:null==C?void 0:C.state,webauthnTransactionId:null==j?void 0:j.transactionId,webauthnOptions:null==j?void 0:j.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,nativeResponseType:null==U?void 0:U.type,nativePayload:null==U?void 0:U.payload,reqTimestamp:R})):this.flowState.update({action:y,reqTimestamp:R})})),Ur.set(this,Ci((()=>n(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)}}))))),Dr.set(this,Ri(((e,t)=>n(this,void 0,void 0,(function*(){var n,o;if("true"===e.getAttribute("formnovalidate")||i(this,dr,"m",Lr).call(this)){const r=null==e?void 0:e.getAttribute("id");i(this,dr,"m",Nr).call(this,e);const s=yield i(this,dr,"m",Pr).call(this),a=(o=e,Array.from((null==o?void 0:o.attributes)||[]).reduce(((e,t)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return i?Object.assign(e,{[i]:t.value}):e}),{}));if(this.nextRequestStatus.update({isLoading:!0}),i(this,pr,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,pr,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const l=this.loadSdkScriptsModules();if(l.length>0){const e=l.filter((e=>"function"==typeof e.refresh)).map((e=>e.refresh()));e.length>0&&(yield ji(5e3,Promise.all(e),null))}const c=this.getComponentsContext(),d=Object.assign(Object.assign(Object.assign(Object.assign({},c),a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(r,d),this.nextRequestStatus.update({isLoading:!1}),i(this,dr,"m",_r).call(this,s)}}))))),this.flowState=e}nativeResume(e,t){var n,o,r,s,a;const l=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let{exchangeCode:e}=l;if(!e){e=null===(n=new URL(l.url).searchParams)||void 0===n?void 0:n.get(Kn)}null===(r=(o=this.nativeCallbacks).complete)||void 0===r||r.call(o,{exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(l.url),t=e.searchParams.get("t"),n=e.searchParams.get(Fn).split("_").pop();i(this,Ar,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=l;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=l,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(a=(s=this.nativeCallbacks).complete)||void 0===a||a.call(s,l)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>n=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Pi(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,i;const o=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(o){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=o;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}yield this.injectNpmLib("@descope/flow-scripts","1.0.6",`dist/${e.id}.js`);const r=null===(i=globalThis.descope)||void 0===i?void 0:i[e.id];return new Promise(((n,i)=>{try{const i=r(e.initArgs,{baseUrl:this.baseUrl},t(e,n));if(i){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=i,this.shadowRoot.appendChild(t),this.nextRequestStatus.subscribe((()=>{var t;this.loggerWrapper.debug("Unloading script",e.id),null===(t=i.stop)||void 0===t||t.call(i)}))}}catch(e){i(e)}}))}))))),o=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([i,o])}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),i(this,dr,"m",yr).call(this),window.addEventListener("visibilitychange",i(this,gr,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=i(this,hr,"f"))||void 0===e||e.abort(),o(this,hr,null,"f"),window.removeEventListener("visibilitychange",i(this,gr,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=Ti(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}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(e,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:g,screenId:f,screenState:v,redirectTo:m,redirectIsPopup:b,redirectUrl:w,token:y,code:k,isPopup:I,exchangeError:S,webauthnTransactionId:O,webauthnOptions:C,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:A,redirectAuthInitiator:E,locale:U,samlIdpResponseUrl:R,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:$,nativeResponseType:L,nativePayload:P,reqTimestamp:N}=e,_=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload","reqTimestamp"]);let M,W,D;const q=(()=>{const e=localStorage.getItem(eo);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(eo,e.toString()),e}return Number(e)})(),{outboundAppId:F}=this,{outboundAppScopes:K}=this,J=this.sdk.getLastUserLoginId(),V=yield this.getFlowConfig(),H=yield this.getProjectConfig(),B=Object.entries(H.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),z=j&&x?{callbackUrl:j,codeChallenge:x,backupCallbackUri:A}:void 0,G=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;let Z={};if(!p){const e=[...V.clientScripts||[],...V.sdkScripts||[]];if(V.conditions){let t=[];({startScreenId:M,conditionInteractionId:D,startScreenName:W,clientScripts:t,componentsConfig:Z}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:i})=>{var o;if("ELSE"===t)return!0;const r=null===(o=to[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:J,code:k,token:y,abTestingKey:q},V.conditions)),e.push(...t||[])}else V.condition?({startScreenId:M,conditionInteractionId:D}=((e,t)=>{var n;const i=null===(n=to[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!i)return{};const o=i(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(V.condition,{loginId:J,code:k,token:y,abTestingKey:q})):(W=V.startScreenName,M=V.startScreenId);if(o(this,pr,this.loadSdkScripts(e),"f"),V.fingerprintEnabled&&V.fingerprintKey?yield on(V.fingerprintKey,this.baseUrl):localStorage.removeItem(tn),!Ai(M,_)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:z},_),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:no(J),abTestingKey:q,locale:Ti(U).locale,nativeOptions:G,outboundAppId:F,outboundAppScopes:K}),D,"",H.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),_.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),_.oidcLoginHint?{externalId:_.oidcLoginHint}:{}));return i(this,Er,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(s("code")&&k&&s("isPopup")&&I)return window.opener.postMessage({action:"code",data:{code:k}},window.location.origin),void window.close();if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&S)){const e=yield this.sdk.flow.next(p,h,hi,V.version,H.componentsVersion,{token:y,exchangeCode:k,exchangeError:S});return i(this,Er,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===ui&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!R||!T)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),i(o)})(R,T,$||"",Ei)}if(g===si&&(s("redirectTo")||s("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("android"===E&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(b){((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,l=window.open(e,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);l.focus()})(m,"?",598,700);const e=t=>{if(t.origin!==window.location.origin)return;const{action:n,data:i}=t.data;"code"===n&&(window.removeEventListener("message",e),this.flowState.update({code:i.code}))};window.addEventListener("message",e)}else this.handleRedirect(m);return}if(g===li||g===ci){if(!O||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=i(this,hr,"f"))||void 0===l||l.abort(),o(this,hr,null,"f");try{e=g===li?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}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 n=yield this.sdk.flow.next(p,h,hi,V.version,H.componentsVersion,{transactionId:O,response:e,failure:t});i(this,Er,"f").call(this,n)}if(g===di)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,hi,V.version,H.componentsVersion,e);i(this,Er,"f").call(this,t)})),void i(this,dr,"m",br).call(this,L,P);if(s("action")&&i(this,jr,"f").call(this,p,h,V.version,H.componentsVersion),!f&&!M)return void this.loggerWrapper.warn("No screen was found to show");const X=M||f,Y=yield this.getHtmlFilenameWithLocale(U,X),{oidcLoginHint:Q,oidcPrompt:ee,oidcErrorRedirectUri:te,samlIdpUsername:ne}=_,ie={direction:yi(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:J,name:this.sdk.getLastUserDisplayName()||J},componentsConfig:Object.assign(Object.assign(Object.assign({},V.componentsConfig),Z),null==v?void 0:v.componentsConfig)}),htmlFilename:`${X}.html`,htmlLocaleFilename:Y,screenId:X,stepName:e.stepName||W,samlIdpUsername:ne,oidcLoginHint:Q,oidcPrompt:ee,oidcErrorRedirectUri:te,action:g},oe=no(J);Ai(M,_)?ie.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:z},_),{lastAuth:oe,preview:this.preview,abTestingKey:q,client:this.client}),w&&{redirectUrl:w}),{locale:Ti(U).locale,nativeOptions:G,outboundAppId:F,outboundAppScopes:K}),D,e,H.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),Li(t)),k&&{exchangeCode:k,idpInitiated:!0}),_.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}));return i(this,Er,"f").call(this,n),n})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(ie.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.next(p,h,e,V.version,H.componentsVersion,Li(t));return i(this,Er,"f").call(this,n),n}))),this.loggerWrapper.debug("Got a screen with id",ie.screenId),yield i(this,dr,"m",Or).call(this,ie),this.stepState.update(ie)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r;const{htmlFilename:s,htmlLocaleFilename:a,direction:l,next:c,screenState:d}=e;this.loggerWrapper.debug("Rendering a flow screen");const u=document.createElement("template");u.innerHTML=yield this.getPageContent(s,a);const h=u.content.cloneNode(!0),p=this.loadDescopeUiComponents(u);this.sdk.webauthn.helpers.isSupported()?yield i(this,dr,"m",Tr).call(this,h,c):h.querySelectorAll(`descope-button[${ri}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(o=d.form)||void 0===o?void 0:o.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),Xi(h,d,d.componentsConfig,this.formConfig,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(h,g);const f=()=>n(this,void 0,void 0,(function*(){var n,o;yield p;const r=this.contentRootElement;var s,a;s=r,a=null===(n=null==d?void 0:d.totp)||void 0===n?void 0:n.image,Zi(s,"descope-totp-image",a),((e,t)=>{Zi(e,"descope-notp-image",t)})(r,null===(o=null==d?void 0:d.notp)||void 0===o?void 0:o.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{t.querySelector(o)||i.debug(`Skipping css vars for component "${o}}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.info(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,h,d.cssVars,this.loggerWrapper),r.replaceChildren(h);const l=!t.htmlFilename;setTimeout((()=>{i(this,dr,"m",Mr).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var n;const i=()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))};if("true"===t.getAttribute("invalid")||(null===(n=t.value)||void 0===n?void 0:n.length))return void i();const o={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(o.timer),o.timer=void 0)};o.timer=setTimeout((()=>{e.removeEventListener("click",r),i(),o.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(r),((e,t)=>{Vi(e,null==t?void 0:t.inputs),Vi(e,null==t?void 0:t.form)})(r,d),i(this,dr,"m",$r).call(this,{isFirstScreen:l,isCustomScreen:!1,stepName:e.stepName}),xi(r,this.autoFocus,l)})),i(this,dr,"m",Fr).call(this,c);r.querySelector(`[${ri}="polling"]`)&&c(pi,{})}));l?i(this,dr,"m",xr).call(this,f):f()}))}}ur=new WeakMap,hr=new WeakMap,pr=new WeakMap,gr=new WeakMap,Sr=new WeakMap,Cr=new WeakMap,jr=new WeakMap,Ar=new WeakMap,Er=new WeakMap,Ur=new WeakMap,Dr=new WeakMap,dr=new WeakSet,fr=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},vr=function(e,t,o){return n(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=n,i(this,dr,"m",br).call(this,"beforeScreen",{screen:e,context:t})}))}))},mr=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,dr,"m",br).call(this,"afterScreen",{screen:e})},br=function(e,t){i(this,dr,"m",Kr).call(this,"bridge",{type:e,payload:t})},wr=function({errorText:e,errorType:t}){const n=()=>{var n;let i=e;try{i=(null===(n=this.errorTransformer)||void 0===n?void 0:n.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${ri}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",i)};this.addEventListener("screen-updated",n,{once:!0}),n()},yr=function(){var e,n,o;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=t(void 0===n?{}:n,["errorText","errorType"]),o=t(e,["screenState"]);return Object.assign(Object.assign({},o),{screenState:i})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,dr,"m",wr).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(i(this,dr,"m",kr).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0})},kr=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),xi(this.contentRootElement,this.autoFocus,!1))},Ir=function(){return n(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")}))},Or=function(e){return n(this,void 0,void 0,(function*(){var n;const r=Object.assign(Object.assign({},this.stepState.current),e),{next:s,stepName:a}=r,l=t(r,["next","stepName"]),c=$i(l);let d=yield i(this,dr,"m",vr).call(this,a,c,s);d||(d=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,c,s,this)));const u=!this.stepState.current.htmlFilename;if(i(this,Cr,"f").call(this,d),i(this,Sr,"f")!==d){const[e,t]=["flow","custom"].sort((()=>d?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,Sr,d,"f"),d?this.stepState.unsubscribeAll():i(this,dr,"m",yr).call(this)}d&&(this.loggerWrapper.debug("Showing a custom screen"),i(this,dr,"m",$r).call(this,{isFirstScreen:u,isCustomScreen:d,stepName:e.stepName})),this.stepState.forceUpdate=d}))},xr=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},Rr=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const n=`user-${t}`;e.setAttribute("name",n),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:n)}))}},Tr=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,hr,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Yi())){const{options:e,transactionId:r}=(yield i(this,Ur,"f").call(this))||{};e&&r&&(i(this,dr,"m",Rr).call(this,s),o(this,hr,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,hr,"f")).then((e=>n(this,void 0,void 0,(function*(){t(s.id,{transactionId:r,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},$r=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,dr,"m",Kr).call(this,"ready",{}),t||i(this,dr,"m",mr).call(this,n),i(this,dr,"m",Kr).call(this,"page-updated",{screenName:n}),i(this,dr,"m",Kr).call(this,"screen-updated",{screenName:n})},Lr=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,i;"slot"!==t.localName&&(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(i=t.checkValidity)||void 0===i?void 0:i.call(t)))})),e},Pr=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${Vn}])`));return(yield Promise.all(e.map((e=>n(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})),{})}))},Nr=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},_r=function(e={}){var t,n;const i=Ui(e,["externalId","email","phone"]),o=Ui(e,["newPassword","password"]);if(i&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:i,password:o});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},Mr=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,dr,"m",Wr).call(this,e)))},Wr=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),i=`input-${e.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),e.appendChild(o),t.setAttribute("slot",i),this.appendChild(t)}))},qr=function(e){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var n;(null===(n=t.checkValidity)||void 0===n?void 0:n.call(t))&&i(this,Dr,"f").call(this,t,e)}))}))},Fr=function(e){this.contentRootElement.querySelectorAll(`descope-button:not([${Hn}]), [data-type="button"]:not([${Hn}]`).forEach((t=>{t.onclick=()=>{i(this,Dr,"f").call(this,t,e)}})),i(this,dr,"m",qr).call(this,e),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Vn}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Kr=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",ts);const ns=document.createElement("template");ns.innerHTML='\n<div 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';const is=io(To)(HTMLElement);class os extends is{constructor(){super(),Jr.add(this),Vr.set(this,new qi({messages:[]})),Hr.set(this,void 0),Br.set(this,void 0),zr.set(this,void 0),Gr.set(this,{resize:i(this,Jr,"m",es).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ns.content.cloneNode(!0)),o(this,Hr,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Br,i(this,Hr,"f").querySelector(".content"),"f"),o(this,zr,i(this,Hr,"f").querySelector(".header"),"f"),i(this,Jr,"m",Zr).call(this)}updateData(e){i(this,Vr,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;null===(t=e.init)||void 0===t||t.call(this),((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Qi(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,Hr,"f"),i(this,zr,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Gr,"f").resize),(n=i(this,Hr,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&n.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},i(this,Hr,"f").onresize=i(this,Jr,"m",Qr).bind(this),i(this,Vr,"f").subscribe(i(this,Jr,"m",Xr).bind(this))}))}disconnectedCallback(){i(this,Vr,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Gr,"f").resize)}}Vr=new WeakMap,Hr=new WeakMap,Br=new WeakMap,zr=new WeakMap,Gr=new WeakMap,Jr=new WeakSet,Zr=function(){this.injectStyle('\n .debugger {\n all: initial;\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'),i(this,Hr,"f").style.top="32px",i(this,Hr,"f").style.left=window.innerWidth-300-32+"px"},Xr=function(e){i(this,Jr,"m",Yr).call(this,e),i(this,Jr,"m",Qr).call(this)},Yr=function(e){i(this,Br,"f").innerHTML=e.messages.map((e=>`\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 ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Qr=function(){i(this,Br,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,i=t.clientHeight>20;n||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},es=function(){const[e,t]=Qi(i(this,Hr,"f"),Number.parseInt(i(this,Hr,"f").style.left,10),Number.parseInt(i(this,Hr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Hr,"f").style.top=`${t}px`,i(this,Hr,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",os);var rs=Object.freeze({__proto__:null,default:os})}();
3
+ function vt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)e[i]=n[i]}return e}var mt=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=vt({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(i[a]=t.read(s,a),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",vt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,vt({},this.attributes,t))},withConverter:function(t){return e(vt({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var bt={default:"endpoint"},wt="Blocked by CSP",yt="The endpoint parameter is not a valid URL",kt="Failed to load the JS script of the agent",It="9319";function St(e,t){var n,i,o,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===wt||s===yt)n.exclude(),r=0;else if(s===It)n.exclude();else if(s===kt){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var Ot="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Ct=Ot;function xt(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:Ot,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return St(e,jt)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===It?new Error(kt):e}(e)})).then((function(t){var n=t[0],i=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function jt(e){return function(e,t,n){var i,o=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(yt);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(kt))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(wt)})).then(At)}function At(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==i?void 0:i.configurable)?delete e[t]:i&&!i.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(It);return n}const Et=e=>{try{return a(e).exp}catch(e){return null}},Ut=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:Et(n)},Rt=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?Et(i):void 0)},Tt=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[i])||[]).concat((null==t?void 0:t[i])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},$t=async e=>{if(!(null==e?void 0:e.ok))return{};const n=await(null==e?void 0:e.clone().json());return(e=>{const{access_token:n,id_token:i,refresh_token:o,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:i,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||Rt(e),cookieExpiration:e.cookieExpiration||Ut(e)},s)})((null==n?void 0:n.authInfo)||n||{})},Lt=async e=>{const t=await $t(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Pt="undefined"!=typeof localStorage,Nt=(e,t)=>Pt&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),_t=e=>Pt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),Mt=e=>Pt&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Wt=(...e)=>{console.debug(...e)},Dt="3.2.0",qt="undefined"!=typeof window,Ft=Math.pow(2,31)-1,Kt=`https://descopecdn.com/npm/oidc-client-ts@${Dt}/dist/browser/oidc-client-ts.min.js`,Jt=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Dt}/dist/browser/oidc-client-ts.min.js`,Vt="DS",Ht="DSR",Bt="DSI";function zt(e=""){return _t(`${e}${Ht}`)||""}function Gt(e=""){return mt.get(Vt)||_t(`${e}${Vt}`)||""}function Zt(e=""){return _t(`${e}${Bt}`)||""}function Xt(e=""){Mt(`${e}${Ht}`),Mt(`${e}${Vt}`),Mt(`${e}${Bt}`),mt.remove(Vt)}const Yt=qt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Qt="vsid",en="vrid",tn="fp",nn=(e=!1)=>{const t=localStorage.getItem(tn);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},on=async(e,t=Yt)=>{try{if(nn())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=xt({apiKey:e,endpoint:[i.toString(),bt],scriptUrlPattern:[r,Ct]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Qt]:e,[en]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(tn,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},rn=e=>{const t=nn(!0);return t&&e.body&&(e.body.fpData=t),e},sn="descopeFlowNonce",an="X-Descope-Flow-Nonce",ln="/v1/flow/start",cn="/v1/flow/next",dn=(e,t=sn)=>`${t}${e}`,un=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},hn=e=>{var t;return e.path===cn&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?un(e.body.executionId):null},pn="dls_last_user_login_id",gn="dls_last_user_display_name",fn=()=>_t(pn),vn=()=>_t(gn),mn=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=fn(),r=vn();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)};function bn(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function wn(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Cn(n.publicKey.challenge),n.publicKey.user.id=Cn(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Cn(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:xn(n.rawId),type:n.type,response:{attestationObject:xn(n.response.attestationObject),clientDataJSON:xn(n.response.clientDataJSON)}});var n}async function yn(e){const t=Sn(e);return On(await navigator.credentials.get(t))}async function kn(e,t){const n=Sn(e);return n.signal=t.signal,n.mediation="conditional",On(await navigator.credentials.get(n))}async function In(e=!1){if(!qt)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Sn(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Cn(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Cn(e.id)})),n}function On(e){return JSON.stringify({id:e.id,rawId:xn(e.rawId),type:e.type,response:{authenticatorData:xn(e.response.authenticatorData),clientDataJSON:xn(e.response.clientDataJSON),signature:xn(e.response.signature),userHandle:e.response.userHandle?xn(e.response.userHandle):void 0}})}function Cn(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function xn(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var jn,An=(jn=e=>({async signUp(t,n,i){const o=await e.webauthn.signUp.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await wn(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,n){const i=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await yn(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(t,n){var i;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const t=await wn(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await yn(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,i){const o=await e.webauthn.update.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await wn(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:wn,get:yn,isSupported:In,conditional:kn}}),(...e)=>{const t=jn(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const En="/fedcm/config",Un=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function Rn(e,t){var n;try{await Tn(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Tn(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=Un(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(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?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void d()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var $n=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await In(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});let Ln;const Pn=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Pn(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Nn=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{Ln||(Ln=(async()=>{try{return require("oidc-client-ts")}catch(e){return Pn([Kt,Jt],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await Ln;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=t,s=(null==n?void 0:n.redirectUri)||window.location.href,a=(null==n?void 0:n.scope)||"openid email roles descope.custom_claims offline_access",l=`${r}_user`;let c=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(c=`${c}/${n.applicationId}`);const d={authority:c,client_id:t,redirect_uri:s,response_type:"code",scope:a,stateStore:new o({store:window.localStorage,prefix:r}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),(null==n?void 0:n.scope)&&(d.scope=n.scope),{client:new i(d),stateUserKey:l}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),window.localStorage.setItem(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(e={},t=!1)=>{const{client:n}=await i(),o=await n.createSigninRequest(e),{url:r}=o;return t||(window.location.href=r),{ok:!0,data:o}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:r}=await i(),s=(e=>{const t=window.localStorage.getItem(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||Zt(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return window.localStorage.removeItem(o),t||window.location.replace(s),r}}},_n=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return qt?(i&&o&&on(i).catch((()=>null)),e(Tt(r,{beforeRequest:rn}))):e(r)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);if(!i||"undefined"!=typeof window&&window.descopeBridge)return e(o);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let l,c;qt&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(Wt("Expiration time passed, refreshing session"),d.refresh(zt()||c))}));const d=e(Tt(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o}=await $t(t);if(401===(null==t?void 0:t.status))Wt("Received 401, canceling all timers"),r();else if(n||o){if(l=((e,t)=>{if(t)return new Date(1e3*t);Wt("Could not extract expiration time from session token, trying to decode the token");try{const t=a(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!l)return void Wt("Could not extract expiration time from session token");c=i;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>Ft&&(Wt(`Timeout is too large (${t}ms), setting it to ${Ft}ms`),t=Ft),t})(l);if(r(),e<=2e4)return void Wt("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Wt(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Wt("Refreshing session due to timer"),d.refresh(zt()||i)}),e)}}}));return ie(d,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Wt("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.33.4"},t.baseHeaders)}))),(e=>t=>{const n=bn(),i=bn(),o=bn(),r=e(Tt(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))i.pub(null),o.pub(null),n.pub(null);else{const e=await Lt(t);e&&o.pub(e);const{sessionJwt:r,sessionExpiration:s}=await $t(t);r&&i.pub(r),(s||r)&&n.pub(s||42)}}})),s=ie(r,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const r=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r}));return Object.assign(s,{onSessionTokenChange:i.sub,onUserChange:o.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{const{enableFlowNonce:i=!0,nonceStoragePrefix:o=sn}=n,r=t(n,["enableFlowNonce","nonceStoragePrefix"]);return i?(((e=sn)=>{try{if(!Pt)return;for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(n&&n.startsWith(e)){const t=_t(n);if(t)try{JSON.parse(t).expiry<Date.now()&&Mt(n)}catch(e){Mt(n)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}})(o),e(Tt(r,{afterRequest:async(e,t)=>{if(e.path!==ln&&e.path!==cn)return;const{nonce:n,executionId:i}=await(async(e,t)=>{try{const n=t.headers.get(an);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=hn(e)),{nonce:n,executionId:un(i)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&i&&((e,t,n,i=sn)=>{try{const o=dn(e,i),r=n?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:n};Nt(o,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(i,n,e.path===ln,o)},beforeRequest:e=>{if(e.path===cn){const t=hn(e);if(t){const n=((e,t=sn)=>{try{const n=dn(e,t),i=_t(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(((e,t=sn)=>{try{const n=dn(e,t);Mt(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):o.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,o);n&&(e.headers=e.headers||{},e.headers[an]=n)}}return e}}))):e(r)}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:fn,getLastUserDisplayName:vn});const s=e(Tt(r,{afterRequest:async(e,t)=>{var n;const i=await Lt(t),o=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],r=null==i?void 0:i.name;o&&((e=>{Nt(pn,e)})(o),(e=>{Nt(gn,e)})(r))}}));let a=ie(s,["flow.start"],mn);return a=ie(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(Mt(pn),Mt(gn)),i})(o)),Object.assign(a,{getLastUserLoginId:fn,getLastUserDisplayName:vn})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!qt)return e(s);const a=e(Tt(s,{beforeRequest:(l=r,e=>Object.assign(e,{token:e.token||zt(l)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||Xt(r):((e={},t=!1,n="")=>{var i;const{sessionJwt:o,refreshJwt:r}=e;if(r&&Nt(`${n}${Ht}`,r),o)if(t){const n=t.sameSite||"Strict",r=null===(i=t.secure)||void 0===i||i;!function(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(i);mt.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:r,secure:a})}}(Vt,o,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:r}))}else Nt(`${n}${Vt}`,o);e.idToken&&Nt(`${n}${Bt}`,e.idToken)})(await $t(t),o,r)}}));var l;const c=ie(a,["logout","logoutAll","oidc.logout"],(e=>t=>async(...n)=>{const i=await t(...n);return Xt(e),i})(r));return Object.assign(c,{getRefreshToken:()=>zt(r),getSessionToken:()=>Gt(r),getIdToken:()=>Zt(r)})}))((e=>{const t=ft(e),n=Nn(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async i=>{var o;if(e.oidcConfig)try{return await n.refreshToken(i),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}const r=Gt(),s=zt();let a="";if(e.getExternalToken)try{a=await(null===(o=e.getExternalToken)||void 0===o?void 0:o.call(e))}catch(e){Wt("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:r?"t":"f",dcr:s?"t":"f"},a)},logout:async i=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i)},flow:$n(t),webauthn:An(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){Rn(i,e)},requestAuthentication(e){Rn(i,e)}},async oneTap(e,t,n,o,r){await Tn(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(o+En),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>qt&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+En);try{const i={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var i,o})),Mn="undefined"!=typeof localStorage,Wn="J151000",Dn=Mn&&localStorage.getItem("base.content.url")||"",qn="base.ui.components.url";Mn&&localStorage.getItem(qn),Mn&&localStorage.getItem(qn);const Fn="descope-login-flow",Kn="code",Jn="redirect_mode",Vn="data-exclude-field",Hn="data-exclude-next",Bn="dls_last_auth",zn="state_id",Gn="saml_idp_state_id",Zn="saml_idp_username",Xn="descope_idp_initiated",Yn="sso_app_id",Qn="third_party_app_id",ei="third_party_app_state_id",ti="oidc_login_hint",ni="oidc_prompt",ii="oidc_error_redirect_uri",oi="application_scopes",ri="data-type",si="redirect",ai="poll",li="webauthnCreate",ci="webauthnGet",di="nativeBridge",ui="loadForm",hi="submit",pi="polling",gi=["descope-multi-select-combo-box","descope-text-area"],fi=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var vi;!function(e){e.backward="backward",e.forward="forward"}(vi||(vi={}));const mi=["descope-enriched-text"];function bi(e){return new URLSearchParams(window.location.search).get(e)}function wi(e){if(window.history.replaceState&&bi(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function yi(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?vi.forward:n<i?vi.backward:void 0}const ki=e=>{let[t="",n=""]=(bi(Fn)||"").split("_");const i=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||i&&i!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:i}};function Ii(){wi(Fn)}const Si=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Oi=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=ki(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&Ii();const r=bi("t")||void 0;r&&wi("t");const s=bi(Kn)||void 0;s&&wi(Kn);const a="popup"===bi(Jn);a&&wi(Jn);const l=bi("err")||void 0;l&&wi("err");const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:bi("ra-challenge"),redirectAuthCallbackUrl:bi("ra-callback"),redirectAuthBackupCallbackUri:bi("ra-backup-callback"),redirectAuthInitiator:bi("ra-initiator")},p=bi(zn);p&&wi(zn);const g=bi(Gn);g&&wi(Gn);const f=bi(Zn);g&&wi(Zn);const v=bi(Xn);v&&wi(Xn);const m=bi(Yn);m&&wi(Yn);const b=bi(Qn);b&&wi(Qn);const w=bi(ei);w&&wi(ei);const y=bi(oi);y&&wi(oi);const k=bi(ti);k&&wi(ti);const I=bi(ni);I&&wi(ni);const S=bi(ii);S&&wi(ii);return{executionId:n,stepId:i,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:g,samlIdpUsername:f,descopeIdpInitiated:"true"===v,ssoAppId:m,oidcLoginHint:k,oidcPrompt:I,oidcErrorRedirectUri:S,thirdPartyAppId:b,thirdPartyAppStateId:w,applicationScopes:y}}},Ci=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})},xi=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}};function ji(e,t,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),i(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const Ai=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:i,ssoAppId:o,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,thirdPartyAppId:l,thirdPartyAppStateId:c,applicationScopes:d})=>!(!e||t||n||i||o||r||s||a||l||c||d),Ei=e=>null==e?void 0:e.submit(),Ui=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Ri=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function Ti(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const $i=e=>{var t,n,i;const o=(r=e.screenState,s=(e,t)=>fi.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(r).filter((([e,t])=>!s(t,e)))));var r,s;const{screenState:{errorText:a,errorType:l}}=e;return(a||l)&&(o.error={text:a,type:l}),e.action&&(o.action=e.action),(null===(i=null===(n=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===n?void 0:n.thirdPartyAppApproveScopes)||void 0===i?void 0:i.data)&&(o.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),o},Li=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Pi(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Ni,_i,Mi,Wi;function Di(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Di(r,s))return!1}else if(r!==s)return!1}return!0}class qi{constructor(e={},{forceUpdate:t=!1}={}){Ni.set(this,void 0),_i.set(this,{}),Mi.set(this,0),Wi.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,Ni,"f")):e,n=Object.assign(Object.assign({},i(this,Ni,"f")),t),r=i(this,Ni,"f");o(this,Ni,n,"f"),Object.freeze(i(this,Ni,"f")),setTimeout((()=>{Object.values(i(this,_i,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const s=t(r),a=t(n);(i(this,Wi,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!Di(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},o(this,Ni,e,"f"),o(this,Wi,t,"f")}get current(){return Object.assign({},i(this,Ni,"f"))}set forceUpdate(e){o(this,Wi,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,Mi,i(this,Mi,"f")+1,"f"),i(this,_i,"f")[i(this,Mi,"f")]={cb:e,selector:t,forceUpdate:n},i(this,Mi,"f").toString()}unsubscribe(e){const t=!!i(this,_i,"f")[e];return t&&delete i(this,_i,"f")[e],t}unsubscribeAll(){return o(this,_i,{},"f"),!0}}Ni=new WeakMap,_i=new WeakMap,Mi=new WeakMap,Wi=new WeakMap;const Fi=["*","#","/","(",")","[","]","_","<",">","`"],Ki=e=>{const t=Fi.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")},Ji=["disabled"],Vi=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Vn}])`)).forEach((e=>{e.value=n}))}))},Hi=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),Bi=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?(e=>"string"!=typeof e?e:e.replace(Ki("\\"),"\\$1"))(Hi(t,i)):Hi(t,i))),zi=(e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(i=e.localName,mi.includes(i));var i;e.textContent=Bi(e.textContent,t,n);const o=e.getAttribute("href");o&&e.setAttribute("href",Bi(o,t))}))},Gi=(e,t,n)=>{e.querySelectorAll(`[${ri}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Zi=(e,t,n)=>{var i,o;const r=null===(i=customElements.get(t))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},Xi=(e,n,i,o,r)=>{var s,a;Gi(e,"totp-link",null===(s=null==n?void 0:n.totp)||void 0===s?void 0:s.provisionUrl),Gi(e,"notp-link",null===(a=null==n?void 0:n.notp)||void 0===a?void 0:a.redirectUrl),zi(e,n),((e,n,i)=>{if(!n)return;const{componentsDynamicAttrs:o}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});o&&Object.keys(o).forEach((e=>{const t=o[e];if(t){const{attributes:n}=t;n&&Object.keys(n).length&&(s[e]=n)}})),Object.keys(s).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const n=s[t];Object.keys(n).forEach((t=>{let o=n[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,i,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=Bi(e.value,t)}))}))})(e,n),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{Ji.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)},Yi=Ci((()=>n(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield ji(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}})))),Qi=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]},eo="dls_ab_testing_id",to={"lastAuth.loginId":{"not-empty":e=>!!e.loginId,empty:e=>!e.loginId},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||((e.abTestingKey||0)<n||(e.abTestingKey||0)>i)},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function no(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(Bn)))}catch(e){}return t}function io(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const oo=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const i=e(n);return i[t]=!0,i}},ro=["error","warn","info","debug"],so=oo((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,i(this,t,"m",r).call(this,console))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e||console),"f")}get logger(){return i(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return ro.reduce(((t,n)=>(t[n]=(...t)=>{var i;this.onLogEvent(n,t),null===(i=e[n])||void 0===i||i.call(e,...t)},t)),{})},s})),ao="undefined"!=typeof localStorage,lo=ao&&localStorage.getItem("base.content.url")||"",co=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,uo=oo((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&i(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),ho=oo((e=>{var t,n;const o=io(so,uo)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=i(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){i(this,t,"f")[e]||(i(this,t,"f")[e]=[]);const o=i(this,t,"f")[e].push(n);return()=>i(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),po=e=>t=>{var n,o,r;const s=io(so,uo,ho)(t),a=Object.keys(e);return r=class extends s{constructor(...e){super(...e),n.add(this),this.observeAttributes(a,i(this,n,"m",o).bind(this))}async init(){var e;a.forEach((e=>i(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},r};po.missingAttrValidator=co;const go=oo((e=>{const t=io(po({"project-id":co}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),fo=oo((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),vo="Trying the next fallback URL...",mo=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};function bo({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i="https://static.descope.com/pages"}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}const wo=oo((e=>{var t,n,r,s,a;const l=io(so,go,fo)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0),r.set(this,void 0)}async fetchStaticResource(e,n){const a=i(this,t,"m",s).call(this,e),l=Array.isArray(a)?e=>{if(e!==a.length-1){const{baseUrl:t}=a[e];o(this,r,t,"f")}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:i}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const r=o[e],s=e===o.length-1;try{const o=await mo(r.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${vo}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${vo}`)}}})(a,{cache:"default"},{logger:this.logger,onSuccess:l});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")}},n=new WeakMap,r=new WeakMap,t=new WeakSet,s=function(e){const t=lo||this.baseStaticUrl;if(t)return bo({projectId:this.projectId,filename:e,baseUrl:t});const s=i(this,n,"f")!==this.baseUrl,a=s&&!!this.baseUrl;s&&(o(this,n,this.baseUrl,"f"),o(this,r,void 0,"f"));const l=bo({projectId:this.projectId,filename:e,baseUrl:i(this,r,"f")});if(!a)return l;return[bo({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),l]},a})),yo=oo((e=>{var t,n;const o=io(po({"project-id":co}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return i(this,t,"f").set(e,n),()=>{i(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(i(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=i(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),ko=oo((e=>{var t,n,r,s,a;const l=io(wo,yo,uo)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),r.set(this,void 0),s.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,t,"m",n).bind(this))}get config(){return i(this,r,"f")||o(this,r,i(this,s,"f").call(this),"f"),i(this,r,"f")}},r=new WeakMap,s=new WeakMap,t=new WeakSet,n=function(){o(this,r,void 0,"f")},a})),Io=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],So=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},Oo=(e,t)=>new Promise(((n,i)=>{const o=(e=>{const t=document.createElement("script");return t.id=e,t})(e);o.onerror=e=>{o.setAttribute("status","error"),i(e)},o.onload=()=>{o.setAttribute("status","loaded"),n(o)},o.src=t.toString(),document.body.appendChild(o)})),Co=e=>"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))})),xo=oo((e=>{const t=io(so)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[]){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"`),(async(e,t)=>{for(const i of e){const{id:e,url:o}=i,r=(n=e,document.querySelector(`script#${n}`));if(r)try{return await Co(r),i}catch(e){t(i,!0)}else try{return await Oo(e,o),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="")=>e.reduce(((e,o)=>{const r=o;if(!r)return e;let s;try{s=new URL(r)}catch(e){throw new Error(`Invalid URL: ${r}`)}return"/"!==s.pathname||(s.pathname=`/npm/${t}@${n}/${i}`),[...e,{url:s,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${So(s)}`}]}),[]))([...i,this.baseCdnUrl,...Io],e,t,n),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),jo="base.ui.components.url",Ao=ao&&localStorage.getItem(jo),Eo=oo((e=>{var t,n,r,s,a,l;const c=io(so,ko,xo)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),r.set(this,void 0)}get descopeUi(){return i(this,r,"f")||o(this,r,i(this,t,"m",a).call(this),"f"),i(this,r,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>i(this,t,"m",s).call(this,e))))}},r=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},a=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{return await this.injectNpmLib("@descope/web-components-ui",await i(this,t,"m",n).call(this),"dist/umd/index.js",[Ao]),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},l})),Uo=oo((e=>{var t,n,o;const r=io(uo,ho)(e);return o=class extends r{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",i(this,t,"m",n).bind(this)),i(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){window.DESCOPE_NONCE=this.nonce},o}));class Ro{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const To=oo((e=>{const t=io(Uo)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new Ro(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),$o="content-root",Lo="root",Po=oo((e=>{const t=io(To)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${Lo}">\n <div id="${$o}"></div>\n </div>\n `,this.injectStyle(`\n #${Lo}, #${$o} {\n height: 100%;\n }\n #${Lo} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById($o),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Lo)}}})),No=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',_o=oo((e=>{var t,n,r,s,a,l,c,d,u,h,p,g,f,v;const m=io(po({theme:No}),wo,uo,Eo,ko,Po,ho,To)(e);return v=class extends m{constructor(){super(...arguments),t.add(this),n.set(this,void 0),r.set(this,void 0),p.set(this,(()=>{i(this,t,"m",g).call(this),i(this,f,"f").call(this,"os"===this.getAttribute("theme"))})),f.set(this,(e=>{var n,o,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===r||r.call(o,"change",(()=>i(this,t,"m",g).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,p,"f").call(this),await Promise.all([i(this,t,"m",l).call(this),i(this,t,"m",c).call(this)]),this.observeAttributes(["theme"],i(this,p,"f")),this.observeAttributes(["style-id"],(()=>{o(this,r,null,"f"),i(this,t,"m",u).call(this),i(this,t,"m",l).call(this),i(this,t,"m",c).call(this)}))}},n=new WeakMap,r=new WeakMap,p=new WeakMap,f=new WeakMap,t=new WeakSet,s=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},a=function(){return i(this,r,"f")||(o(this,r,i(this,t,"m",s).call(this),"f"),i(this,r,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,r,"f")},l=async function(){var e,r;const s=await i(this,t,"a",a);s&&(i(this,n,"f")||o(this,n,this.injectStyle(""),"f"),i(this,n,"f").replaceSync(((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||"")))},c=async function(){var e,n;const o=await i(this,t,"a",a);if(!o)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.components,dark:null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.components})},d=async function(){var e,t;const{projectConfig:n}=await this.config||{},i=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,r=i||o;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},u=async function(){const e=await i(this,t,"m",d).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},h=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},g=function(){i(this,t,"m",u).call(this),i(this,t,"m",h).call(this)},v})),Mo=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),Mo(e[i],`${t+i}.`));const r="object"==typeof e[i]?e[i]:{value:e[i]},s=Object.assign(Object.assign({},n),{[t+i]:r,[`form.${t}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),Wo=oo((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;i(this,t,"m",n).call(this)&&i(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},r}));var Do,qo,Fo,Ko,Jo,Vo,Ho,Bo,zo,Go,Zo,Xo,Yo,Qo,er,tr,nr,ir,or,rr,sr,ar;const lr=io(_o,wo,Wo,To)(HTMLElement);class cr extends lr{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),Do.add(this),Fo.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,Do,"m",sr).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)},debug:(e,t="")=>{this.logger.debug(e,t)}},Ko.set(this,new qi),Jo.set(this,new qi),Vo.set(this,{}),this.getComponentsContext=()=>i(this,Vo,"f"),this.nextRequestStatus=new qi({isLoading:!1}),Ho.set(this,void 0),Bo.set(this,{popstate:i(this,Do,"m",Yo).bind(this),componentsContext:i(this,Do,"m",ir).bind(this)}),zo.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,zo,e,"f"),i(this,Do,"m",Zo).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){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 e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}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(e=>{try{return Mo(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return e=this.formConfig,t="value",Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]])));var e,t}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const e=JSON.parse(this.getAttribute("outbound-app-scopes"));return e||null}catch(e){return null}}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig(),n="projectConfig"in t?null===(e=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 e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),i(this,Jo,"f").subscribe(i(this,Do,"m",rr).bind(this)),i(this,Jo,"f").update({isDebug:this.debug}),i(this,Do,"m",Xo).call(this),yield i(this,Do,"m",tr).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");i(this,Do,"m",ar).call(this);const{executionId:r,stepId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:g,ssoQueryParams:f}=Oi(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,Bo,"f").popstate),window.addEventListener("components-context",i(this,Bo,"f").componentsContext),i(this,Ko,"f").subscribe(i(this,Do,"m",er).bind(this)),i(this,Ko,"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,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:g},f)),o(this,Fo,!0,"f")}))}disconnectedCallback(){i(this,Ko,"f").unsubscribeAll(),i(this,Jo,"f").unsubscribeAll(),i(this,Do,"m",or).call(this),window.removeEventListener("popstate",i(this,Bo,"f").popstate),window.removeEventListener("components-context",i(this,Bo,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,Fo,"f")&&t!==n&&qo.observedAttributes.includes(e)){i(this,Do,"m",Xo).call(this);const o=null===t;i(this,Ko,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Ii()),{[Si(e)]:n,stepId:r,executionId:s}})),i(this,Jo,"f").update({isDebug:this.debug})}}}var dr,ur,hr,pr,gr,fr,vr,mr,br,wr,yr,kr,Ir,Sr,Or,Cr,xr,jr,Ar,Er,Ur,Rr,Tr,$r,Lr,Pr,Nr,_r,Mr,Wr,Dr,qr,Fr,Kr,Jr,Vr,Hr,Br,zr,Gr,Zr,Xr,Yr,Qr,es;qo=cr,Fo=new WeakMap,Ko=new WeakMap,Jo=new WeakMap,Vo=new WeakMap,Ho=new WeakMap,Bo=new WeakMap,zo=new WeakMap,Do=new WeakSet,Go=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},Zo=function(){i(this,Do,"m",Go).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Xo=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes"];qo.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Si(t)])throw Error(`${t} cannot be empty`)}))},Yo=function(){const{stepId:e,executionId:t}=ki(this.flowId);i(this,Ko,"f").update({stepId:e,executionId:t})},Qo=function(e,t){this.sdk=_n(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},qo.sdkConfigOverrides),{projectId:e,baseUrl:t})),["start","next"].forEach((e=>{const t=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>n(this,void 0,void 0,(function*(){try{return yield t(...e)}catch(e){return{error:{errorCode:Wn,errorDescription:e.toString()}}}}))}))},er=function(e,t,o){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(o("projectId")||o("baseUrl")){if(!t)return;i(this,Do,"m",Qo).call(this,t,n)}i(this,zo,"f").call(this,e)}))},tr=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,Do,"m",nr).call(this))}))},nr=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(Dn||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t](),headers:Object.fromEntries(n.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},ir=function(e){o(this,Vo,Object.assign(Object.assign({},i(this,Vo,"f")),e.detail),"f")},or=function(){var e;null===(e=i(this,Ho,"f"))||void 0===e||e.remove(),o(this,Ho,null,"f")},rr=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,Ho,document.createElement("descope-debugger"),"f"),Object.assign(i(this,Ho,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return rs})),document.body.appendChild(i(this,Ho,"f"))):i(this,Do,"m",or).call(this)}))},sr=function(e,t){var n;e&&this.debug&&(null===(n=i(this,Ho,"f"))||void 0===n||n.updateData({title:e,description:t}))},ar=function(){this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=gi.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||o||r)return;e.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((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}},cr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.43.16"}};class ts extends cr{static set sdkConfigOverrides(e){cr.sdkConfigOverrides=e}static get sdkConfigOverrides(){return cr.sdkConfigOverrides}constructor(){const e=new qi({deferredRedirect:!1});super(e.update.bind(e)),dr.add(this),this.stepState=new qi({}),ur.set(this,void 0),hr.set(this,null),pr.set(this,null),gr.set(this,{visibilitychange:i(this,dr,"m",fr).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},Sr.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},Cr.set(this,(e=>{const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?i(this,dr,"m",xr).call(this,t):t()})),jr.set(this,((e,t,r,s,a=!1)=>{if(this.flowState.current.action===ai){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),c=a?500:2e3;o(this,ur,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const o=this.sdk.flow.next(e,t,pi,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 e=d?1e3:6e3;u=yield ji(e,o)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,jr,"f").call(this,e,t,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===Wn)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,jr,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),i(this,jr,"f").call(this,e,t,r,s),i(this,Er,"f").call(this,u)}))),c),"f")}})),Ar.set(this,(()=>{clearTimeout(i(this,ur,"f")),o(this,ur,null,"f")})),Er.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,g,f;if(!(null==e?void 0:e.ok)){const o=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;i(this,dr,"m",Kr).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||o,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||c);const d=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==d&&"E103205"!==d||!this.isRestartOnError||i(this,dr,"m",Ir).call(this))}null===(d=null===(c=e.data)||void 0===c?void 0:c.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const v=null===(p=null===(h=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(g=e.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:b,lastAuth:w,action:y,openInNewTabUrl:k}=e.data;if(y!==ai&&i(this,Ar,"f").call(this),"completed"===m)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&Mn&&localStorage.setItem(Bn,JSON.stringify(e))}(w),void i(this,dr,"m",Kr).call(this,"success",b);k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:O,screen:C,redirect:x,webauthn:j,error:A,samlIdpResponse:E,nativeResponse:U}=e.data,R=Date.now();y!==ai?(this.loggerWrapper.info(`Step "${O||`#${S}`}" is ${m}`,"",{screen:C,status:m,stepId:S,stepName:O,action:y,error:A}),(null===(f=C.state)||void 0===f?void 0:f.clientScripts)&&o(this,pr,this.loadSdkScripts(C.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:O,executionId:I,action:y,redirectTo:null==x?void 0:x.url,redirectIsPopup:null==x?void 0:x.isPopup,screenId:null==C?void 0:C.id,screenState:null==C?void 0:C.state,webauthnTransactionId:null==j?void 0:j.transactionId,webauthnOptions:null==j?void 0:j.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,nativeResponseType:null==U?void 0:U.type,nativePayload:null==U?void 0:U.payload,reqTimestamp:R})):this.flowState.update({action:y,reqTimestamp:R})})),Ur.set(this,Ci((()=>n(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)}}))))),Dr.set(this,Ri(((e,t)=>n(this,void 0,void 0,(function*(){var n,o;if("true"===e.getAttribute("formnovalidate")||i(this,dr,"m",Lr).call(this)){const r=null==e?void 0:e.getAttribute("id");i(this,dr,"m",Nr).call(this,e);const s=yield i(this,dr,"m",Pr).call(this),a=(o=e,Array.from((null==o?void 0:o.attributes)||[]).reduce(((e,t)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return i?Object.assign(e,{[i]:t.value}):e}),{}));if(this.nextRequestStatus.update({isLoading:!0}),i(this,pr,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,pr,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const l=this.loadSdkScriptsModules();if(l.length>0){const e=l.filter((e=>"function"==typeof e.refresh)).map((e=>e.refresh()));e.length>0&&(yield ji(5e3,Promise.all(e),null))}const c=this.getComponentsContext(),d=Object.assign(Object.assign(Object.assign(Object.assign({},c),a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(r,d),this.nextRequestStatus.update({isLoading:!1}),i(this,dr,"m",_r).call(this,s)}}))))),this.flowState=e}nativeResume(e,t){var n,o,r,s,a;const l=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let{exchangeCode:e}=l;if(!e){e=null===(n=new URL(l.url).searchParams)||void 0===n?void 0:n.get(Kn)}null===(r=(o=this.nativeCallbacks).complete)||void 0===r||r.call(o,{exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(l.url),t=e.searchParams.get("t"),n=e.searchParams.get(Fn).split("_").pop();i(this,Ar,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=l;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=l,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(a=(s=this.nativeCallbacks).complete)||void 0===a||a.call(s,l)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>n=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Pi(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,i;const o=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(o){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=o;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}yield this.injectNpmLib("@descope/flow-scripts","1.0.6",`dist/${e.id}.js`);const r=null===(i=globalThis.descope)||void 0===i?void 0:i[e.id];return new Promise(((n,i)=>{try{const i=r(e.initArgs,{baseUrl:this.baseUrl},t(e,n));if(i){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=i,this.shadowRoot.appendChild(t),this.nextRequestStatus.subscribe((()=>{var t;this.loggerWrapper.debug("Unloading script",e.id),null===(t=i.stop)||void 0===t||t.call(i)}))}}catch(e){i(e)}}))}))))),o=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([i,o])}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),i(this,dr,"m",yr).call(this),window.addEventListener("visibilitychange",i(this,gr,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=i(this,hr,"f"))||void 0===e||e.abort(),o(this,hr,null,"f"),window.removeEventListener("visibilitychange",i(this,gr,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=Ti(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}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(e,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:g,screenId:f,screenState:v,redirectTo:m,redirectIsPopup:b,redirectUrl:w,token:y,code:k,isPopup:I,exchangeError:S,webauthnTransactionId:O,webauthnOptions:C,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:A,redirectAuthInitiator:E,locale:U,samlIdpResponseUrl:R,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:$,nativeResponseType:L,nativePayload:P,reqTimestamp:N}=e,_=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload","reqTimestamp"]);let M,W,D;const q=(()=>{const e=localStorage.getItem(eo);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(eo,e.toString()),e}return Number(e)})(),{outboundAppId:F}=this,{outboundAppScopes:K}=this,J=this.sdk.getLastUserLoginId(),V=yield this.getFlowConfig(),H=yield this.getProjectConfig(),B=Object.entries(H.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),z=j&&x?{callbackUrl:j,codeChallenge:x,backupCallbackUri:A}:void 0,G=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;let Z={};if(!p){const e=[...V.clientScripts||[],...V.sdkScripts||[]];if(V.conditions){let t=[];({startScreenId:M,conditionInteractionId:D,startScreenName:W,clientScripts:t,componentsConfig:Z}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:i})=>{var o;if("ELSE"===t)return!0;const r=null===(o=to[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:J,code:k,token:y,abTestingKey:q},V.conditions)),e.push(...t||[])}else V.condition?({startScreenId:M,conditionInteractionId:D}=((e,t)=>{var n;const i=null===(n=to[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!i)return{};const o=i(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(V.condition,{loginId:J,code:k,token:y,abTestingKey:q})):(W=V.startScreenName,M=V.startScreenId);if(o(this,pr,this.loadSdkScripts(e),"f"),V.fingerprintEnabled&&V.fingerprintKey?yield on(V.fingerprintKey,this.baseUrl):localStorage.removeItem(tn),!Ai(M,_)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:z},_),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:no(J),abTestingKey:q,locale:Ti(U).locale,nativeOptions:G,outboundAppId:F,outboundAppScopes:K}),D,"",H.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),_.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),_.oidcLoginHint?{externalId:_.oidcLoginHint}:{}));return i(this,Er,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(s("code")&&k&&s("isPopup")&&I)return window.opener.postMessage({action:"code",data:{code:k}},window.location.origin),void window.close();if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&S)){const e=yield this.sdk.flow.next(p,h,hi,V.version,H.componentsVersion,{token:y,exchangeCode:k,exchangeError:S});return i(this,Er,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===ui&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!R||!T)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),i(o)})(R,T,$||"",Ei)}if(g===si&&(s("redirectTo")||s("deferredRedirect"))){if(!m)return void this.loggerWrapper.error("Did not get redirect url");if("android"===E&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(b){((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,l=window.open(e,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);l.focus()})(m,"?",598,700);const e=t=>{if(t.origin!==window.location.origin)return;const{action:n,data:i}=t.data;"code"===n&&(window.removeEventListener("message",e),this.flowState.update({code:i.code}))};window.addEventListener("message",e)}else this.handleRedirect(m);return}if(g===li||g===ci){if(!O||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=i(this,hr,"f"))||void 0===l||l.abort(),o(this,hr,null,"f");try{e=g===li?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}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 n=yield this.sdk.flow.next(p,h,hi,V.version,H.componentsVersion,{transactionId:O,response:e,failure:t});i(this,Er,"f").call(this,n)}if(g===di)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,hi,V.version,H.componentsVersion,e);i(this,Er,"f").call(this,t)})),void i(this,dr,"m",br).call(this,L,P);if(s("action")&&i(this,jr,"f").call(this,p,h,V.version,H.componentsVersion),!f&&!M)return void this.loggerWrapper.warn("No screen was found to show");const X=M||f,Y=yield this.getHtmlFilenameWithLocale(U,X),{oidcLoginHint:Q,oidcPrompt:ee,oidcErrorRedirectUri:te,samlIdpUsername:ne}=_,ie={direction:yi(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:J,name:this.sdk.getLastUserDisplayName()||J},componentsConfig:Object.assign(Object.assign(Object.assign({},V.componentsConfig),Z),null==v?void 0:v.componentsConfig)}),htmlFilename:`${X}.html`,htmlLocaleFilename:Y,screenId:X,stepName:e.stepName||W,samlIdpUsername:ne,oidcLoginHint:Q,oidcPrompt:ee,oidcErrorRedirectUri:te,action:g},oe=no(J);Ai(M,_)?ie.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:z},_),{lastAuth:oe,preview:this.preview,abTestingKey:q,client:this.client}),w&&{redirectUrl:w}),{locale:Ti(U).locale,nativeOptions:G,outboundAppId:F,outboundAppScopes:K}),D,e,H.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),Li(t)),k&&{exchangeCode:k,idpInitiated:!0}),_.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}));return i(this,Er,"f").call(this,n),n})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(ie.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.next(p,h,e,V.version,H.componentsVersion,Li(t));return i(this,Er,"f").call(this,n),n}))),this.loggerWrapper.debug("Got a screen with id",ie.screenId),yield i(this,dr,"m",Or).call(this,ie),this.stepState.update(ie)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r;const{htmlFilename:s,htmlLocaleFilename:a,direction:l,next:c,screenState:d}=e;this.loggerWrapper.debug("Rendering a flow screen");const u=document.createElement("template");u.innerHTML=yield this.getPageContent(s,a);const h=u.content.cloneNode(!0),p=this.loadDescopeUiComponents(u);this.sdk.webauthn.helpers.isSupported()?yield i(this,dr,"m",Tr).call(this,h,c):h.querySelectorAll(`descope-button[${ri}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(o=d.form)||void 0===o?void 0:o.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),Xi(h,d,d.componentsConfig,this.formConfig,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(h,g);const f=()=>n(this,void 0,void 0,(function*(){var n,o;yield p;const r=this.contentRootElement;var s,a;s=r,a=null===(n=null==d?void 0:d.totp)||void 0===n?void 0:n.image,Zi(s,"descope-totp-image",a),((e,t)=>{Zi(e,"descope-notp-image",t)})(r,null===(o=null==d?void 0:d.notp)||void 0===o?void 0:o.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{t.querySelector(o)||i.debug(`Skipping css vars for component "${o}}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.info(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,h,d.cssVars,this.loggerWrapper),r.replaceChildren(h);const l=!t.htmlFilename;setTimeout((()=>{i(this,dr,"m",Mr).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var n;const i=()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))};if("true"===t.getAttribute("invalid")||(null===(n=t.value)||void 0===n?void 0:n.length))return void i();const o={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(o.timer),o.timer=void 0)};o.timer=setTimeout((()=>{e.removeEventListener("click",r),i(),o.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(r),((e,t)=>{Vi(e,null==t?void 0:t.inputs),Vi(e,null==t?void 0:t.form)})(r,d),i(this,dr,"m",$r).call(this,{isFirstScreen:l,isCustomScreen:!1,stepName:e.stepName}),xi(r,this.autoFocus,l)})),i(this,dr,"m",Fr).call(this,c);r.querySelector(`[${ri}="polling"]`)&&c(pi,{})}));l?i(this,dr,"m",xr).call(this,f):f()}))}}ur=new WeakMap,hr=new WeakMap,pr=new WeakMap,gr=new WeakMap,Sr=new WeakMap,Cr=new WeakMap,jr=new WeakMap,Ar=new WeakMap,Er=new WeakMap,Ur=new WeakMap,Dr=new WeakMap,dr=new WeakSet,fr=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},vr=function(e,t,o){return n(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=n,i(this,dr,"m",br).call(this,"beforeScreen",{screen:e,context:t})}))}))},mr=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,dr,"m",br).call(this,"afterScreen",{screen:e})},br=function(e,t){i(this,dr,"m",Kr).call(this,"bridge",{type:e,payload:t})},wr=function({errorText:e,errorType:t}){const n=()=>{var n;let i=e;try{i=(null===(n=this.errorTransformer)||void 0===n?void 0:n.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${ri}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",i)};this.addEventListener("screen-updated",n,{once:!0}),n()},yr=function(){var e,n,o;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=t(void 0===n?{}:n,["errorText","errorType"]),o=t(e,["screenState"]);return Object.assign(Object.assign({},o),{screenState:i})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,dr,"m",wr).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(i(this,dr,"m",kr).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0})},kr=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),xi(this.contentRootElement,this.autoFocus,!1))},Ir=function(){return n(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")}))},Or=function(e){return n(this,void 0,void 0,(function*(){var n;const r=Object.assign(Object.assign({},this.stepState.current),e),{next:s,stepName:a}=r,l=t(r,["next","stepName"]),c=$i(l);let d=yield i(this,dr,"m",vr).call(this,a,c,s);d||(d=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,c,s,this)));const u=!this.stepState.current.htmlFilename;if(i(this,Cr,"f").call(this,d),i(this,Sr,"f")!==d){const[e,t]=["flow","custom"].sort((()=>d?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,Sr,d,"f"),d?this.stepState.unsubscribeAll():i(this,dr,"m",yr).call(this)}d&&(this.loggerWrapper.debug("Showing a custom screen"),i(this,dr,"m",$r).call(this,{isFirstScreen:u,isCustomScreen:d,stepName:e.stepName})),this.stepState.forceUpdate=d}))},xr=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},Rr=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const n=`user-${t}`;e.setAttribute("name",n),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:n)}))}},Tr=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,hr,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Yi())){const{options:e,transactionId:r}=(yield i(this,Ur,"f").call(this))||{};e&&r&&(i(this,dr,"m",Rr).call(this,s),o(this,hr,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,hr,"f")).then((e=>n(this,void 0,void 0,(function*(){t(s.id,{transactionId:r,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},$r=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,dr,"m",Kr).call(this,"ready",{}),t||i(this,dr,"m",mr).call(this,n),i(this,dr,"m",Kr).call(this,"page-updated",{screenName:n}),i(this,dr,"m",Kr).call(this,"screen-updated",{screenName:n})},Lr=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,i;"slot"!==t.localName&&(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(i=t.checkValidity)||void 0===i?void 0:i.call(t)))})),e},Pr=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${Vn}])`));return(yield Promise.all(e.map((e=>n(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})),{})}))},Nr=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},_r=function(e={}){var t,n;const i=Ui(e,["externalId","email","phone"]),o=Ui(e,["newPassword","password"]);if(i&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:i,password:o});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},Mr=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,dr,"m",Wr).call(this,e)))},Wr=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),i=`input-${e.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),e.appendChild(o),t.setAttribute("slot",i),this.appendChild(t)}))},qr=function(e){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var n;(null===(n=t.checkValidity)||void 0===n?void 0:n.call(t))&&i(this,Dr,"f").call(this,t,e)}))}))},Fr=function(e){this.contentRootElement.querySelectorAll(`descope-button:not([${Hn}]), [data-type="button"]:not([${Hn}]`).forEach((t=>{t.onclick=()=>{i(this,Dr,"f").call(this,t,e)}})),i(this,dr,"m",qr).call(this,e),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Vn}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Kr=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",ts);const ns=document.createElement("template");ns.innerHTML='\n<div 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';const is=io(To)(HTMLElement);class os extends is{constructor(){super(),Jr.add(this),Vr.set(this,new qi({messages:[]})),Hr.set(this,void 0),Br.set(this,void 0),zr.set(this,void 0),Gr.set(this,{resize:i(this,Jr,"m",es).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ns.content.cloneNode(!0)),o(this,Hr,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Br,i(this,Hr,"f").querySelector(".content"),"f"),o(this,zr,i(this,Hr,"f").querySelector(".header"),"f"),i(this,Jr,"m",Zr).call(this)}updateData(e){i(this,Vr,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;null===(t=e.init)||void 0===t||t.call(this),((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Qi(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,Hr,"f"),i(this,zr,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Gr,"f").resize),(n=i(this,Hr,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&n.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},i(this,Hr,"f").onresize=i(this,Jr,"m",Qr).bind(this),i(this,Vr,"f").subscribe(i(this,Jr,"m",Xr).bind(this))}))}disconnectedCallback(){i(this,Vr,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Gr,"f").resize)}}Vr=new WeakMap,Hr=new WeakMap,Br=new WeakMap,zr=new WeakMap,Gr=new WeakMap,Jr=new WeakSet,Zr=function(){this.injectStyle('\n .debugger {\n all: initial;\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'),i(this,Hr,"f").style.top="32px",i(this,Hr,"f").style.left=window.innerWidth-300-32+"px"},Xr=function(e){i(this,Jr,"m",Yr).call(this,e),i(this,Jr,"m",Qr).call(this)},Yr=function(e){i(this,Br,"f").innerHTML=e.messages.map((e=>`\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 ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Qr=function(){i(this,Br,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,i=t.clientHeight>20;n||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},es=function(){const[e,t]=Qi(i(this,Hr,"f"),Number.parseInt(i(this,Hr,"f").style.left,10),Number.parseInt(i(this,Hr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Hr,"f").style.top=`${t}px`,i(this,Hr,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",os);var rs=Object.freeze({__proto__:null,default:os})}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/web-component",
3
- "version": "3.43.15",
3
+ "version": "3.43.16",
4
4
  "author": "Descope Team <info@descope.com>",
5
5
  "homepage": "https://github.com/descope/descope-js",
6
6
  "bugs": {
@@ -70,10 +70,10 @@
70
70
  "dependencies": {
71
71
  "tslib": "2.8.1",
72
72
  "@fingerprintjs/fingerprintjs-pro": "3.11.6",
73
- "@descope/sdk-mixins": "0.13.5",
74
- "@descope/web-js-sdk": "1.33.3",
73
+ "@descope/sdk-helpers": "0.3.0",
74
+ "@descope/web-js-sdk": "1.33.4",
75
75
  "@descope/escape-markdown": "0.1.5",
76
- "@descope/sdk-helpers": "0.3.0"
76
+ "@descope/sdk-mixins": "0.13.5"
77
77
  },
78
78
  "overrides": {
79
79
  "terser": "5.37.0"