@descope/web-component 3.40.2 → 3.40.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
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"}},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=>{const t={"x-descope-sdk-session-id":f(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.40.0"};return e&&(t["x-descope-refresh-cookie-name"]=e),t},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(i),(null==n?void 0:n.baseHeaders)||{},I(v)?w:{},h),method:g,body:v};null!==s&&(S.credentials=s||"include");const C=await l(m({path:d,baseUrl:e,queryParams:p,projectId:t}),S);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(o,null==C?void 0:C.clone()),null==r?void 0:r.transformResponse){const e=await C.json(),t=((null===(a=C.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({},C),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}return C};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 C=429;function O(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 U(e,t){return O(e,t,"permissions")}function E(e,t){return O(e,t,"roles")}const T=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function R(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===C&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function L(e){var t;return(null===(t=x(e))||void 0===t?void 0:t[h])||""}const _=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),$=(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 "))},P=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),D=e=>t=>e.test(t),M=D(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),N=D(/^\+[1-9]{1}[0-9]{3,14}$/),W=_(M,'"{val}" is not a valid email'),q=_(N,'"{val}" is not a valid phone number'),F=_((e=>e.length>=1),"Minimum length is 1");const B=_((e=>"string"==typeof e),"Input is not a string"),V=_((e=>Array.isArray(e)),"Input is not an array"),K=_((e=>"boolean"==typeof e),"Input is not a boolean"),H=_((e=>void 0===e),"Input is defined"),G=$([B(),H()],"Input is not a string or undefined"),J=$([V(),K()],"Input is not an array or boolean"),z=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>P(...e).validate(n[t]))),t(...n)),X=e=>[B(`"${e}" must be a string`)],Q=e=>[G(`"${e}" must be string or undefined`)],Z=e=>[B(`"${e}" must be a string`),F(`"${e}" must not be empty`)],Y=e=>[B(`"${e}" must be a string`),W()],ee=e=>[B(`"${e}" must be a string`),q()],te=z(Z("accessKey")),ne=e=>({exchange:te(((t,n)=>R(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=Z("loginId"),de=z(Z("token")),ue=z(ce),he=z(Z("pendingRef")),pe=z(ce,Y("email")),ge=e=>({verify:de((t=>R(e.post(l.enchantedLink.verify,{token:t})))),signIn:ue(((t,n,i,o)=>R(e.post(T(l.enchantedLink.signIn,ae.email),{loginId:t,URI:n,loginOptions:i},{token:o})))),signUpOrIn:ue(((t,n,i)=>R(e.post(T(l.enchantedLink.signUpOrIn,ae.email),{loginId:t,URI:n,loginOptions:i})))),signUp:ue(((t,n,i,o)=>R(e.post(T(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(R(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)=>R(e.post(l.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o}))))}}),fe=z(Z("flowId")),ve=z(Z("executionId"),Z("stepId"),Z("interactionId")),me=e=>({start:fe(((t,n,i,o,r,s,a)=>R(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)=>R(e.post(l.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s}))))}),be=Z("loginId"),we=z(Z("token")),ye=z(be),ke=z(be,ee("phone")),Ie=z(be,Y("email")),Se=Object.keys(ae).filter((e=>e!==re.voice)),Ce=e=>({verify:we((t=>R(e.post(l.magicLink.verify,{token:t})))),signIn:Se.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,i,o,r)=>R(e.post(T(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)=>R(e.post(T(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)=>R(e.post(T(l.magicLink.signUpOrIn,n),{loginId:t,URI:i,loginOptions:o}))))})),{}),update:{email:Ie(((t,n,i,o,r)=>R(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)=>R(e.post(T(l.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var Oe;!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"}(Oe||(Oe={}));const xe=z(Z("code")),je=e=>({start:Object.assign(((t,n,i,o)=>R(e.post(l.oauth.start,i||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:o}))),Object.keys(Oe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o)=>R(e.post(l.oauth.start,i||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:o}))})),{})),exchange:xe((t=>R(e.post(l.oauth.exchange,{code:t})))),startNative:(t,n,i)=>R(e.post(l.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>R(e.post(l.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>R(e.get(l.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>R(e.post(l.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>R(e.post(l.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),Ae=Z("loginId"),Ue=z(Ae,Z("code")),Ee=z(Ae),Te=z(Ae,ee("phone")),Re=z(Ae,Y("email")),Le=e=>({verify:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ue(((t,i)=>R(e.post(T(l.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ee(((t,i,o)=>R(e.post(T(l.otp.signIn,n),{loginId:t,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ee(((t,i,o)=>R(e.post(T(l.otp.signUp,n),{loginId:t,user:i,loginOptions:o}))))})),{}),signUpOrIn:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ee(((t,i)=>R(e.post(T(l.otp.signUpOrIn,n),{loginId:t,loginOptions:i}))))})),{}),update:{email:Re(((t,n,i,o)=>R(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]:Te(((t,i,o,r)=>R(e.post(T(l.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),_e=z(Z("tenant")),$e=z(Z("code")),Pe=e=>({start:_e(((t,n,i,o,r)=>R(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:$e((t=>R(e.post(l.saml.exchange,{code:t}))))}),De=Z("loginId"),Me=z(De,Z("code")),Ne=z(De),We=z(De),qe=e=>({signUp:Ne(((t,n)=>R(e.post(l.totp.signUp,{loginId:t,user:n})))),verify:Me(((t,n,i,o)=>R(e.post(l.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:We(((t,n)=>R(e.post(l.totp.update,{loginId:t},{token:n}))))}),Fe=Z("loginId"),Be=Z("newPassword"),Ve=z(Fe,Z("password")),Ke=z(Fe),He=z(Fe,Be),Ge=z(Fe,Z("oldPassword"),Be),Je=e=>({signUp:Ve(((t,n,i,o)=>R(e.post(l.password.signUp,{loginId:t,password:n,user:i,loginOptions:o})))),signIn:Ve(((t,n,i)=>R(e.post(l.password.signIn,{loginId:t,password:n,loginOptions:i})))),sendReset:Ke(((t,n,i)=>R(e.post(l.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:He(((t,n,i)=>R(e.post(l.password.update,{loginId:t,newPassword:n},{token:i})))),replace:Ge(((t,n,i)=>R(e.post(l.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>R(e.get(l.password.policy))}),ze=X("loginId"),Xe=Z("loginId"),Qe=Z("origin"),Ze=z(Xe,Qe,Z("name")),Ye=z(Xe,Qe),et=z(ze,Qe),tt=z(Xe,Qe,Q("token")),nt=z(Z("transactionId"),Z("response")),it=e=>({signUp:{start:Ze(((t,n,i,o)=>R(e.post(l.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,passkeyOptions:o})))),finish:nt(((t,n)=>R(e.post(l.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:et(((t,n,i,o,r)=>R(e.post(l.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:nt(((t,n)=>R(e.post(l.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ye(((t,n,i)=>R(e.post(l.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:i}))))},update:{start:tt(((t,n,i,o)=>R(e.post(l.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o},{token:i})))),finish:nt(((t,n)=>R(e.post(l.webauthn.update.finish,{transactionId:t,response:n}))))}}),ot=X("loginId"),rt=z(ot),st=z(Z("pendingRef")),at=e=>({signUpOrIn:rt(((t,n)=>R(e.post(l.notp.signUpOrIn,{loginId:t,loginOptions:n})))),signUp:rt(((t,n,i)=>R(e.post(l.notp.signUp,{loginId:t,user:n,loginOptions:i})))),signIn:rt(((t,n,i)=>R(e.post(l.notp.signIn,{loginId:t,loginOptions:n},{token:i})))),waitForSession:st(((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(R(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),lt=z(Z("token")),ct=z(Q("token"));var dt,ut=z([(dt=Z("projectId"),_(((e,t)=>n=>P(...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",dt))())])((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:Le(c),magicLink:Ce(c),enchantedLink:ge(c),oauth:je(c),saml:Pe(c),totp:qe(c),notp:at(c),webauthn:it(c),password:Je(c),flow:me(c),refresh:ct(((e,t)=>R(c.post(l.refresh,{},{token:e,queryParams:t})))),selectTenant:z([B("tenantId")],[G('"token" must be string or undefined')])(((e,t)=>R(c.post(l.selectTenant,{tenant:e},{token:t})))),logout:ct((e=>R(c.post(l.logout,{},{token:e})))),logoutAll:ct((e=>R(c.post(l.logoutAll,{},{token:e})))),me:ct((e=>R(c.get(l.me,{token:e})))),myTenants:z([J('"tenants" must a string array or a boolean')],[G('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,R(c.post(l.myTenants,n,{token:t}))})),history:ct((e=>R(c.get(l.history,{token:e})))),isJwtExpired:lt(j),getTenants:lt(A),getJwtPermissions:lt(U),getJwtRoles:lt(E),getCurrentTenant:lt(L),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}}))})),ht=Object.assign(ut,{DeliveryMethods:ae});
2
2
  /*! js-cookie v3.0.5 | MIT */
3
- function pt(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 gt=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=pt({},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,"",pt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,pt({},this.attributes,t))},withConverter:function(t){return e(pt({},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 ft={default:"endpoint"},vt="Blocked by CSP",mt="The endpoint parameter is not a valid URL",bt="Failed to load the JS script of the agent",wt="9319";function yt(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===vt||s===mt)n.exclude(),r=0;else if(s===wt)n.exclude();else if(s===bt){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 kt="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",It=kt;function St(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:kt,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 yt(e,Ct)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===wt?new Error(bt):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 Ct(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(mt);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(bt))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(vt)})).then(Ot)}function Ot(){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(wt);return n}const xt=(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},jt=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},At=async e=>{const t=await jt(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Ut="undefined"!=typeof localStorage,Et=(e,t)=>Ut&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),Tt=e=>Ut&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),Rt=e=>Ut&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Lt=(...e)=>{console.debug(...e)},_t="undefined"!=typeof window,$t=Math.pow(2,31)-1,Pt="DS",Dt="DSR";function Mt(e=""){return Tt(`${e}${Dt}`)||""}function Nt(e=""){return gt.get(Pt)||Tt(`${e}${Pt}`)||""}function Wt(e=""){Rt(`${e}${Dt}`),Rt(`${e}${Pt}`),gt.remove(Pt)}const qt=_t&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Ft="vsid",Bt="vrid",Vt="fp",Kt=(e=!1)=>{const t=localStorage.getItem(Vt);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Ht=async(e,t=qt)=>{try{if(Kt())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=St({apiKey:e,endpoint:[i.toString(),ft],scriptUrlPattern:[r,It]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Ft]:e,[Bt]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(Vt,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Gt=e=>{const t=Kt(!0);return t&&e.body&&(e.body.fpData=t),e},Jt="dls_last_user_login_id",zt="dls_last_user_display_name",Xt=()=>Tt(Jt),Qt=()=>Tt(zt),Zt=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=Xt(),r=Qt();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)};function Yt(){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 en(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=an(n.publicKey.challenge),n.publicKey.user.id=an(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=an(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:ln(n.rawId),type:n.type,response:{attestationObject:ln(n.response.attestationObject),clientDataJSON:ln(n.response.clientDataJSON)}});var n}async function tn(e){const t=rn(e);return sn(await navigator.credentials.get(t))}async function nn(e,t){const n=rn(e);return n.signal=t.signal,n.mediation="conditional",sn(await navigator.credentials.get(n))}async function on(e=!1){if(!_t)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 rn(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=an(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=an(e.id)})),n}function sn(e){return JSON.stringify({id:e.id,rawId:ln(e.rawId),type:e.type,response:{authenticatorData:ln(e.response.authenticatorData),clientDataJSON:ln(e.response.clientDataJSON),signature:ln(e.response.signature),userHandle:e.response.userHandle?ln(e.response.userHandle):void 0}})}function an(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function ln(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var cn,dn=(cn=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 en(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 tn(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 en(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await tn(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 en(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:en,get:tn,isSupported:on,conditional:nn}}),(...e)=>{const t=cn(...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 un="/fedcm/config";async function hn(e,t){var n,i,o;try{const o=await async function(e,t="google",n,i,o){const r=(()=>{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)})(),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)}}catch(e){null===(o=null==t?void 0:t.onFailed)||void 0===o||o.call(t,e)}}var pn=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await on(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});const gn=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 _t?(i&&o&&Ht(i).catch((()=>null)),e(xt(r,{beforeRequest:Gt}))):e(r)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);if(!i)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;_t&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(Lt("Expiration time passed, refreshing session"),d.refresh(Mt()||c))}));const d=e(xt(o,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:i,sessionExpiration:o}=await jt(t);if(401===(null==t?void 0:t.status))Lt("Received 401, canceling all timers"),r();else if(i||o){if(l=((e,t)=>{if(t)return new Date(1e3*t);Lt("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}})(i,o),!l)return void Lt("Could not extract expiration time from session token");c=n;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>$t&&(Lt(`Timeout is too large (${t}ms), setting it to ${$t}ms`),t=$t),t})(l);if(r(),e<=2e4)return void Lt("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Lt(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Lt("Refreshing session due to timer"),d.refresh(Mt()||n)}),e)}}}));return ie(d,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return Lt("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.28.0"},t.baseHeaders)}))),(e=>t=>{const n=Yt(),i=Yt(),o=Yt(),r=e(xt(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 At(t);e&&o.pub(e);const{sessionJwt:r,sessionExpiration:s}=await jt(t);r&&i.pub(r),(s||r)&&n.pub(s||42)}}})),s=ie(r,["logout","logoutAll"],(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=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:Xt,getLastUserDisplayName:Qt});const s=e(xt(r,{afterRequest:async(e,t)=>{var n;const i=await At(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=>{Et(Jt,e)})(o),(e=>{Et(zt,e)})(r))}}));let a=ie(s,["flow.start"],Zt);return a=ie(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(Rt(Jt),Rt(zt)),i})(o)),Object.assign(a,{getLastUserLoginId:Xt,getLastUserDisplayName:Qt})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!_t)return e(s);const a=e(xt(s,{beforeRequest:(l=r,e=>Object.assign(e,{token:e.token||Mt(l)})),afterRequest:async(e,n)=>{const i=/^\/v\d+\/mgmt\//.test(e.path);401===(null==n?void 0:n.status)?i||Wt(r):((e={},n,i)=>{var o,{refreshJwt:r,sessionJwt:s}=e,a=t(e,["refreshJwt","sessionJwt"]);if(void 0===n&&(n=!1),void 0===i&&(i=""),r&&Et(`${i}${Dt}`,r),s)if(n){const e=n.sameSite||"Strict",t=null===(o=n.secure)||void 0===o||o;!function(e,t,{cookiePath:n,cookieDomain:i,cookieExpiration:o,cookieSameSite:r="Strict",cookieSecure:s=!0}){if(t){const a=new Date(1e3*o),l=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(i);gt.set(e,t,{path:n,domain:l?i:void 0,expires:a,sameSite:r,secure:s})}}(Pt,s,Object.assign(Object.assign({},a),{cookieSameSite:e,cookieSecure:t}))}else Et(`${i}${Pt}`,s)})(await jt(n),o,r)}}));var l;const c=ie(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return Wt(e),i})(r));return Object.assign(c,{getRefreshToken:()=>Mt(r),getSessionToken:()=>Nt(r)})}))(((...e)=>{const t=ht(...e);return Object.assign(Object.assign({},t),{refresh:e=>{const n=Nt(),i=Mt();return t.refresh(e,{dcs:n?"t":"f",dcr:i?"t":"f"})},flow:pn(t),webauthn:dn(t),fedcm:(n=t,i=e[0].projectId,{onetap:{requestExchangeCode(e){hn(n,e)},requestAuthentication(e){hn(n,e)}},oneTap(e,t,i,o,r){hn(n,{provider:e,oneTapConfig:t,loginOptions:i,onSkipped:o,onDismissed:r})},async launch(e){var t;const o={identity:{context:e||"signin",providers:[{configURL:n.httpClient.buildUrl(i+un),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return n.refresh(r.token)},isSupported:()=>_t&&"IdentityCredential"in window,async isLoggedIn(e){var t;const o=n.httpClient.buildUrl(i+un);try{const n={identity:{context:e||"signin",providers:[{configURL:o,clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return!!r&&!!r.token}catch(e){return!1}}})});var n,i})),fn="undefined"!=typeof localStorage,vn="J151000",mn=fn&&localStorage.getItem("base.content.url")||"",bn="base.ui.components.url";fn&&localStorage.getItem(bn),fn&&localStorage.getItem(bn);const wn="descope-login-flow",yn="code",kn="data-exclude-field",In="data-exclude-next",Sn="dls_last_auth",Cn="state_id",On="saml_idp_state_id",xn="saml_idp_username",jn="descope_idp_initiated",An="sso_app_id",Un="third_party_app_id",En="third_party_app_state_id",Tn="oidc_login_hint",Rn="oidc_prompt",Ln="oidc_error_redirect_uri",_n="application_scopes",$n="data-type",Pn="redirect",Dn="poll",Mn="webauthnCreate",Nn="webauthnGet",Wn="nativeBridge",qn="loadForm",Fn="submit",Bn="polling",Vn=["descope-multi-select-combo-box","descope-text-area"],Kn=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Hn;!function(e){e.backward="backward",e.forward="forward"}(Hn||(Hn={}));const Gn=["descope-enriched-text"];function Jn(e){return new URLSearchParams(window.location.search).get(e)}function zn(e){if(window.history.replaceState&&Jn(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 Xn(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?Hn.forward:n<i?Hn.backward:void 0}const Qn=e=>{let[t="",n=""]=(Jn(wn)||"").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 Zn(){zn(wn)}const Yn=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),ei=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=Qn(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&Zn();const r=Jn("t")||void 0;r&&zn("t");const s=Jn(yn)||void 0;s&&zn(yn);const a=Jn("err")||void 0;a&&zn("err");const{redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u}={redirectAuthCodeChallenge:Jn("ra-challenge"),redirectAuthCallbackUrl:Jn("ra-callback"),redirectAuthBackupCallbackUri:Jn("ra-backup-callback"),redirectAuthInitiator:Jn("ra-initiator")},h=Jn(Cn);h&&zn(Cn);const p=Jn(On);p&&zn(On);const g=Jn(xn);p&&zn(xn);const f=Jn(jn);f&&zn(jn);const v=Jn(An);v&&zn(An);const m=Jn(Un);m&&zn(Un);const b=Jn(En);b&&zn(En);const w=Jn(_n);w&&zn(_n);const y=Jn(Tn);y&&zn(Tn);const k=Jn(Rn);k&&zn(Rn);const I=Jn(Ln);I&&zn(Ln);return{executionId:n,stepId:i,token:r,code:s,exchangeError:a,redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u,ssoQueryParams:{oidcIdpStateId:h,samlIdpStateId:p,samlIdpUsername:g,descopeIdpInitiated:"true"===f,ssoAppId:v,oidcLoginHint:y,oidcPrompt:k,oidcErrorRedirectUri:I,thirdPartyAppId:m,thirdPartyAppStateId:b,applicationScopes:w}}},ti=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}})};function ni(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 ii=(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),oi=e=>null==e?void 0:e.submit(),ri=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},si=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function ai(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 li=e=>{const t=(n=e.screenState,i=(e,t)=>Kn.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!i(t,e)))));var n,i;const{screenState:{errorText:o,errorType:r}}=e;return(o||r)&&(t.error={text:o,type:r}),t};var ci,di,ui,hi;function pi(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(!pi(r,s))return!1}else if(r!==s)return!1}return!0}class gi{constructor(e={},{forceUpdate:t=!1}={}){ci.set(this,void 0),di.set(this,{}),ui.set(this,0),hi.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,ci,"f")):e,n=Object.assign(Object.assign({},i(this,ci,"f")),t),r=i(this,ci,"f");o(this,ci,n,"f"),Object.freeze(i(this,ci,"f")),setTimeout((()=>{Object.values(i(this,di,"f")).forEach((({cb:e,selector:t})=>{const o=t(r),s=t(n);!i(this,hi,"f")&&(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(s)?pi(o,s):o===s)||e(s,o,((e,t)=>n=>e[n]!==t[n])(s,o))}))}),0)},o(this,ci,e,"f"),o(this,hi,t,"f")}get current(){return Object.assign({},i(this,ci,"f"))}set forceUpdate(e){o(this,hi,e,"f")}subscribe(e,t=e=>e){return o(this,ui,i(this,ui,"f")+1,"f"),i(this,di,"f")[i(this,ui,"f")]={cb:e,selector:t},i(this,ui,"f").toString()}unsubscribe(e){const t=!!i(this,di,"f")[e];return t&&delete i(this,di,"f")[e],t}unsubscribeAll(){return o(this,di,{},"f"),!0}}ci=new WeakMap,di=new WeakMap,ui=new WeakMap,hi=new WeakMap;const fi=["*","#","/","(",")","[","]","_","<",">","`"],vi=e=>{const t=fi.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")},mi=["disabled"],bi=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${kn}])`)).forEach((e=>{e.value=n}))}))},wi=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),yi=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?(e=>"string"!=typeof e?e:e.replace(vi("\\"),"\\$1"))(wi(t,i)):wi(t,i))),ki=(e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(i=e.localName,Gn.includes(i));var i;e.textContent=yi(e.textContent,t,n);const o=e.getAttribute("href");o&&e.setAttribute("href",yi(o,t))}))},Ii=(e,t,n)=>{e.querySelectorAll(`[${$n}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Si=(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})`))},Ci=(e,n,i,o,r)=>{var s,a;Ii(e,"totp-link",null===(s=null==n?void 0:n.totp)||void 0===s?void 0:s.provisionUrl),Ii(e,"notp-link",null===(a=null==n?void 0:n.notp)||void 0===a?void 0:a.redirectUrl),ki(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=yi(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])=>{mi.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)},Oi=ti((()=>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 ni(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}})))),xi=(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))]},ji="dls_ab_testing_id",Ai={"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}};function Ui(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(Sn)))}catch(e){}return t}function Ei(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const Ti=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}},Ri=["error","warn","info","debug"],Li=Ti((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 Ri.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})),_i="undefined"!=typeof localStorage,$i=_i&&localStorage.getItem("base.content.url")||"",Pi=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,Di=Ti((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})),Mi=Ti((e=>{var t,n;const o=Ei(Li,Di)(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})),Ni=e=>t=>{var n,o,r;const s=Ei(Li,Di,Mi)(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};Ni.missingAttrValidator=Pi;const Wi=Ti((e=>{const t=Ei(Ni({"project-id":Pi}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),qi=Ti((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),Fi="Trying the next fallback URL...";function Bi({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 Vi=Ti((e=>{var t,n,r,s,a;const l=Ei(Li,Wi,qi)(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 fetch(r.toString(),t);if(o.ok)return null==i||i(e),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${Fi}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${Fi}`)}}})(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=$i||this.baseStaticUrl;if(t)return Bi({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=Bi({projectId:this.projectId,filename:e,baseUrl:i(this,r,"f")});if(!a)return l;return[Bi({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),l]},a})),Ki=Ti((e=>{var t,n;const o=Ei(Ni({"project-id":Pi}))(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})),Hi=Ti((e=>{var t,n,r,s,a;const l=Ei(Vi,Ki,Di)(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})),Gi="load-descope-ui",Ji="base.ui.components.url",zi=_i&&localStorage.getItem(Ji)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Xi=_i&&localStorage.getItem(Ji)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Qi=_i&&localStorage.getItem(Ji)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Zi=e=>{const t=document.createElement("script");return t.id=e,t},Yi=(e,t)=>e.replace("<version>",t),eo=Ti((e=>{var t,n,r,s,a,l,c,d,u,h,p,g;const f=Ei(Li,Hi)(e);return g=class extends f{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),r.set(this,Symbol("loadCbs")),u.set(this,void 0)}get descopeUi(){return i(this,u,"f")||o(this,u,i(this,t,"m",p).call(this),"f"),i(this,u,"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",h).call(this,e))))}get baseCdnUrl(){return this.getAttribute("base-cdn-url")}},n=new WeakMap,r=new WeakMap,u=new WeakMap,t=new WeakSet,s=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},a=function(e){const t=i(this,n,"f"),o=i(this,r,"f");e[t]=[],e[o]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[o].push(t)}})},l=async function(e,n,o,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const a=Zi(o);document.body.append(a),a.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${a.src}"`)))})),a.addEventListener("load",(()=>{n.forEach((e=>e()))})),a.src=Yi(r,await i(this,t,"m",s).call(this))},c=function(e){e.addEventListener("error",(()=>{e[i(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),i(this,t,"m",l).call(this,[i(this,t,"m",l).bind(this,e[i(this,n,"f")],e[i(this,r,"f")],"load-descope-ui-fallback-script-2",Qi),...e[i(this,n,"f")]],e[i(this,r,"f")],"load-descope-ui-fallback-script",Xi)})),e.addEventListener("load",(()=>{e[i(this,r,"f")].forEach((e=>e()))}))},d=async function(){if(document.querySelector(`script#${Gi}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=Zi(Gi);document.body.append(e),i(this,t,"m",a).call(this,e),i(this,t,"m",c).call(this,e),e.src=Yi(this.baseCdnUrl||zi,await i(this,t,"m",s).call(this))}return document.getElementById(Gi)},h=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(", ")}"`)},p=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),i(this,t,"m",d).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},g})),to="content-root",no="root",io=Ti((e=>class extends e{constructor(...e){var t,n,i,o;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${no}">\n <div id="${to}"></div>\n </div>\n `;const r=new CSSStyleSheet;r.replaceSync(`\n #${no}, #${to} {\n height: 100%;\n }\n #${no} {\n position: relative;\n height: fit-content;\n }\n `),null!==(t=(o=this.shadowRoot).adoptedStyleSheets)&&void 0!==t||(o.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,r],this.contentRootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(to),this.rootElement=null===(i=this.shadowRoot)||void 0===i?void 0:i.getElementById(no)}})),oo=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ro=Ti((e=>{var t,n,r,s,a,l,c,d,u,h,p,g,f,v;const m=Ei(Ni({theme:oo}),Vi,Di,eo,Hi,io,Mi)(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,t,"m",l).call(this),i(this,t,"m",c).call(this),i(this,p,"f").call(this),this.observeAttributes(["theme"],i(this,p,"f")),this.observeAttributes(["style-id"],(()=>{o(this,r,null,"f"),i(this,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,s,l;const c=await i(this,t,"a",a);c&&(i(this,n,"f")||(o(this,n,new CSSStyleSheet,"f"),null!==(e=(l=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(l.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,i(this,n,"f")]),i(this,n,"f").replaceSync(((null===(r=null==c?void 0:c.light)||void 0===r?void 0:r.globals)||"")+((null===(s=null==c?void 0:c.dark)||void 0===s?void 0:s.globals)||"")))},c=async function(){var e,n;const o=Object.assign({},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})),so=(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),so(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}),[]),ao=Ti((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 lo,co,uo,ho,po,go,fo,vo,mo,bo,wo,yo,ko,Io,So,Co,Oo,xo,jo,Ao,Uo,Eo,To;const Ro=Ei(ro,Vi,ao)(HTMLElement);class Lo extends Ro{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","nonce"]}constructor(e){super(),lo.add(this),uo.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,lo,"m",Uo).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)}},ho.set(this,new gi),po.set(this,new gi),go.set(this,{}),this.getComponentsContext=()=>i(this,go,"f"),this.nextRequestStatus=new gi({isLoading:!1}),fo.set(this,void 0),vo.set(this,{popstate:i(this,lo,"m",ko).bind(this),componentsContext:i(this,lo,"m",xo).bind(this)}),mo.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,mo,e,"f"),i(this,lo,"m",wo).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 so(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 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,po,"f").subscribe(i(this,lo,"m",Ao).bind(this)),i(this,po,"f").update({isDebug:this.debug}),i(this,lo,"m",yo).call(this),i(this,lo,"m",To).call(this),yield i(this,lo,"m",Co).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,lo,"m",Eo).call(this);const{executionId:r,stepId:s,token:a,code:l,exchangeError:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p,ssoQueryParams:g}=ei(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,vo,"f").popstate),window.addEventListener("components-context",i(this,vo,"f").componentsContext),i(this,ho,"f").subscribe(i(this,lo,"m",So).bind(this)),i(this,ho,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:a,code:l,exchangeError:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p},g)),o(this,uo,!0,"f")}))}disconnectedCallback(){i(this,ho,"f").unsubscribeAll(),i(this,po,"f").unsubscribeAll(),i(this,lo,"m",jo).call(this),window.removeEventListener("popstate",i(this,vo,"f").popstate),window.removeEventListener("components-context",i(this,vo,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,uo,"f")&&t!==n&&co.observedAttributes.includes(e)){i(this,lo,"m",yo).call(this);const o=null===t;"nonce"===e&&i(this,lo,"m",To).call(this),i(this,ho,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Zn()),{[Yn(e)]:n,stepId:r,executionId:s}})),i(this,po,"f").update({isDebug:this.debug})}}}function _o(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var $o,Po,Do,Mo,No,Wo,qo,Fo,Bo,Vo,Ko,Ho,Go,Jo,zo,Xo,Qo,Zo,Yo,er,tr,nr,ir,or,rr,sr,ar,lr,cr,dr,ur,hr,pr,gr,fr,vr,mr,br,wr,yr;co=Lo,uo=new WeakMap,ho=new WeakMap,po=new WeakMap,go=new WeakMap,fo=new WeakMap,vo=new WeakMap,mo=new WeakMap,lo=new WeakSet,bo=function(){var e,t;const n=new CSSStyleSheet;n.replaceSync("\n :host {\n all: initial;\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n transition: opacity 300ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n .hidden {\n display: none;\n }\n "),null!==(e=(t=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(t.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,n]},wo=function(){i(this,lo,"m",bo).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},yo=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","nonce"];co.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Yn(t)])throw Error(`${t} cannot be empty`)}))},ko=function(){const{stepId:e,executionId:t}=Qn(this.flowId);i(this,ho,"f").update({stepId:e,executionId:t})},Io=function(e,t){this.sdk=gn(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},co.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:vn,errorDescription:e.toString()}}}}))}))},So=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,lo,"m",Io).call(this,t,n)}i(this,mo,"f").call(this,e)}))},Co=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,lo,"m",Oo).call(this))}))},Oo=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(mn||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}}))},xo=function(e){o(this,go,Object.assign(Object.assign({},i(this,go,"f")),e.detail),"f")},jo=function(){var e;null===(e=i(this,fo,"f"))||void 0===e||e.remove(),o(this,fo,null,"f")},Ao=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,fo,document.createElement("descope-debugger"),"f"),Object.assign(i(this,fo,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Cr})),document.body.appendChild(i(this,fo,"f"))):i(this,lo,"m",jo).call(this)}))},Uo=function(e,t){var n;e&&this.debug&&(null===(n=i(this,fo,"f"))||void 0===n||n.updateData({title:e,description:t}))},Eo=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=Vn.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()}}},To=function(){this.getAttribute("nonce")&&(window.DESCOPE_NONCE=this.getAttribute("nonce"))},Lo.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.40.2"}};class kr extends Lo{static set sdkConfigOverrides(e){Lo.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Lo.sdkConfigOverrides}constructor(){const e=new gi({deferredRedirect:!1});super(e.update.bind(e)),$o.add(this),this.stepState=new gi({}),Po.set(this,void 0),Do.set(this,null),Mo.set(this,null),No.set(this,{visibilitychange:i(this,$o,"m",Wo).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var n;const o=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=o;if(!e){e=null===(n=new URL(o.url).searchParams)||void 0===n?void 0:n.get(yn)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(o.url),t=e.searchParams.get("t"),n=e.searchParams.get(wn).split("_").pop();i(this,Go,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else this.nativeComplete(o)},Ko.set(this,(e=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e)})),Ho.set(this,((e,t,r,s,a=!1)=>{if(this.flowState.current.action===Dn){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),c=a?500:2e3;o(this,Po,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const o=this.sdk.flow.next(e,t,Bn,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 ni(e,o)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,Ho,"f").call(this,e,t,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===vn)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,Ho,"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,Ho,"f").call(this,e,t,r,s),i(this,Jo,"f").call(this,u)}))),c),"f")}})),Go.set(this,(()=>{clearTimeout(i(this,Po,"f")),o(this,Po,null,"f")})),Jo.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,$o,"m",cr).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,$o,"m",Bo).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}=e.data;if(y!==Dn&&i(this,Go,"f").call(this),"completed"===m)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&fn&&localStorage.setItem(Sn,JSON.stringify(e))}(w),void i(this,$o,"m",cr).call(this,"success",b);const{executionId:k,stepId:I,stepName:S,screen:C,redirect:O,openInNewTabUrl:x,webauthn:j,error:A,samlIdpResponse:U,nativeResponse:E}=e.data,T=Date.now();y!==Dn?(this.loggerWrapper.info(`Step "${S||`#${I}`}" is ${m}`,"",{screen:C,status:m,stepId:I,stepName:S,action:y,error:A}),(null===(f=C.state)||void 0===f?void 0:f.clientScripts)&&o(this,Mo,this.loadSdkScripts(C.state.clientScripts),"f"),this.flowState.update({stepId:I,stepName:S,executionId:k,action:y,redirectTo:null==O?void 0:O.url,openInNewTabUrl:x,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==U?void 0:U.url,samlIdpResponseSamlResponse:null==U?void 0:U.samlResponse,samlIdpResponseRelayState:null==U?void 0:U.relayState,nativeResponseType:null==E?void 0:E.type,nativePayload:null==E?void 0:E.payload,reqTimestamp:T})):this.flowState.update({action:y,reqTimestamp:T})})),zo.set(this,ti((()=>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)}}))))),rr.set(this,si(((e,t)=>n(this,void 0,void 0,(function*(){var n,o;if("true"===e.getAttribute("formnovalidate")||i(this,$o,"m",Yo).call(this)){const r=null==e?void 0:e.getAttribute("id");i(this,$o,"m",tr).call(this,e);const s=yield i(this,$o,"m",er).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,Mo,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,Mo,"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 ni(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,$o,"m",nr).call(this,s)}}))))),this.flowState=e}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:{[_o(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 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===(i=null==t?void 0:t.start)||void 0===i||i.call(t),t}const r=yield function(e){return n(this,void 0,void 0,(function*(){let t;switch(e){case"forter":return t=yield Promise.resolve().then((function(){return xr})),t.default;case"fingerprint":return t=yield Promise.resolve().then((function(){return Ar})),t.default;case"fingerprintDescope":return t=yield Promise.resolve().then((function(){return Er})),t.default;case"grecaptcha":return t=yield Promise.resolve().then((function(){return Lr})),t.default;default:throw new Error(`Unknown script id: ${e}`)}}))}(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.isDescopeBridge)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,$o,"m",Fo).call(this),window.addEventListener("visibilitychange",i(this,No,"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,Do,"f"))||void 0===e||e.abort(),o(this,Do,null,"f"),window.removeEventListener("visibilitychange",i(this,No,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=ai(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,openInNewTabUrl:b,redirectUrl:w,token:y,code:k,exchangeError:I,webauthnTransactionId:S,webauthnOptions:C,redirectAuthCodeChallenge:O,redirectAuthCallbackUrl:x,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:A,locale:U,samlIdpResponseUrl:E,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:R,nativeResponseType:L,nativePayload:_,reqTimestamp:$}=e,P=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload","reqTimestamp"]);let D,M,N;const W=(()=>{const e=localStorage.getItem(ji);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(ji,e.toString()),e}return Number(e)})(),q=this.sdk.getLastUserLoginId(),F=yield this.getFlowConfig(),B=yield this.getProjectConfig(),V=Object.entries(B.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),K=x&&O?{callbackUrl:x,codeChallenge:O,backupCallbackUri:j}:void 0,H=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;let G={};if(!p){const e=[...F.clientScripts||[],...F.sdkScripts||[]];if(F.conditions){let t=[];({startScreenId:D,conditionInteractionId:N,startScreenName:M,clientScripts:t,componentsConfig:G}=((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=Ai[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:q,code:k,token:y,abTestingKey:W},F.conditions)),e.push(...t||[])}else F.condition?({startScreenId:D,conditionInteractionId:N}=((e,t)=>{var n;const i=null===(n=Ai[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}})(F.condition,{loginId:q,code:k,token:y,abTestingKey:W})):(M=F.startScreenName,D=F.startScreenId);if(o(this,Mo,this.loadSdkScripts(e),"f"),F.fingerprintEnabled&&F.fingerprintKey?yield Ht(F.fingerprintKey,this.baseUrl):localStorage.removeItem(Vt),!ii(D,P)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:K},P),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:Ui(q),abTestingKey:W,locale:ai(U).locale,nativeOptions:H}),N,"",B.componentsVersion,V,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),P.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),P.oidcLoginHint?{externalId:P.oidcLoginHint}:{}));return i(this,Jo,"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(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&I)){const e=yield this.sdk.flow.next(p,h,Fn,F.version,B.componentsVersion,{token:y,exchangeCode:k,exchangeError:I});return i(this,Jo,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===qn&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!E||!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)})(E,T,R||"",oi)}if(g===Pn&&(s("redirectTo")||s("deferredRedirect")))return m?"android"===A&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(m):void this.loggerWrapper.error("Did not get redirect url");if(g===Mn||g===Nn){if(!S||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=i(this,Do,"f"))||void 0===l||l.abort(),o(this,Do,null,"f");try{e=g===Mn?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,Fn,F.version,B.componentsVersion,{transactionId:S,response:e,failure:t});i(this,Jo,"f").call(this,n)}if(g===Wn)return this.nativeComplete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,Fn,F.version,B.componentsVersion,e);i(this,Jo,"f").call(this,t)})),void i(this,$o,"m",cr).call(this,"bridge",{type:L,payload:_});if(s("action")&&i(this,Ho,"f").call(this,p,h,F.version,B.componentsVersion),!f&&!D)return void this.loggerWrapper.warn("No screen was found to show");const J=D||f,z=yield this.getHtmlFilenameWithLocale(U,J),{oidcLoginHint:X,oidcPrompt:Q,oidcErrorRedirectUri:Z,samlIdpUsername:Y}=P,ee={direction:Xn(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:q,name:this.sdk.getLastUserDisplayName()||q},componentsConfig:Object.assign(Object.assign(Object.assign({},F.componentsConfig),G),null==v?void 0:v.componentsConfig)}),htmlFilename:`${J}.html`,htmlLocaleFilename:z,screenId:J,stepName:e.stepName||M,samlIdpUsername:Y,oidcLoginHint:X,oidcPrompt:Q,oidcErrorRedirectUri:Z,openInNewTabUrl:b},te=Ui(q);ii(D,P)?ee.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:K},P),{lastAuth:te,preview:this.preview,abTestingKey:W,client:this.client}),w&&{redirectUrl:w}),{locale:ai(U).locale,nativeOptions:H}),N,e,B.componentsVersion,V,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),t),k&&{exchangeCode:k,idpInitiated:!0}),P.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}));return i(this,Jo,"f").call(this,n),n})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(ee.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.next(p,h,e,F.version,B.componentsVersion,t);return i(this,Jo,"f").call(this,n),n}))),this.loggerWrapper.debug("Got a screen with id",ee.screenId),yield i(this,$o,"m",Vo).call(this,ee),this.stepState.update(ee)}))}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,openInNewTabUrl:u}=e;this.loggerWrapper.debug("Rendering a flow screen");const h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),g=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield i(this,$o,"m",Qo).call(this,p,c):p.querySelectorAll(`descope-button[${$n}="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),Ci(p,d,d.componentsConfig,this.formConfig,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(p,f);const v=()=>n(this,void 0,void 0,(function*(){var n,o;yield g;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,Si(s,"descope-totp-image",a),((e,t)=>{Si(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,p,d.cssVars,this.loggerWrapper),r.replaceChildren(p);const l=!t.htmlFilename;setTimeout((()=>{i(this,$o,"m",ir).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((e=>{e.addEventListener("blur",(()=>{var t;const n=e.focus;e.focus=()=>{},null===(t=e.reportValidity)||void 0===t||t.call(e),setTimeout((()=>{e.focus=n}))}))}))})(r),((e,t)=>{bi(e,null==t?void 0:t.inputs),bi(e,null==t?void 0:t.form)})(r,d),i(this,$o,"m",Zo).call(this,{isFirstScreen:l,stepName:e.stepName}),((e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(r,this.autoFocus,l)})),i(this,$o,"m",ar).call(this,c);r.querySelector(`[${$n}="polling"]`)&&c(Bn,{}),u&&!t.openInNewTabUrl&&window.open(u,"_blank")}));l?i(this,$o,"m",lr).call(this,v,l):v()}))}}Po=new WeakMap,Do=new WeakMap,Mo=new WeakMap,No=new WeakMap,Ko=new WeakMap,Ho=new WeakMap,Go=new WeakMap,Jo=new WeakMap,zo=new WeakMap,rr=new WeakMap,$o=new WeakSet,Wo=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},qo=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(`[${$n}="${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()},Fo=function(){var e,n;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,$o,"m",qo).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}}))},Bo=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")}))},Vo=function(e){return n(this,void 0,void 0,(function*(){var n;const o=Object.assign(Object.assign({},this.stepState.current),e),{next:r,stepName:s}=o,a=t(o,["next","stepName"]),l=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,s,li(a),r,this));if(l){this.loggerWrapper.debug("Rendering a custom screen"),this.contentRootElement.innerHTML="",i(this,$o,"m",Zo).call(this,{isFirstScreen:!this.stepState.current.htmlFilename,stepName:e.stepName}),this.stepState.unsubscribeAll();const t=this.stepState.subscribe((()=>{this.stepState.unsubscribe(t),i(this,$o,"m",Fo).call(this)}))}this.stepState.forceUpdate=l,i(this,Ko,"f").call(this,l)}))},Xo=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)}))}},Qo=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,Do,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Oi())){const{options:e,transactionId:r}=(yield i(this,zo,"f").call(this))||{};e&&r&&(i(this,$o,"m",Xo).call(this,s),o(this,Do,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,Do,"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)})))}}))},Zo=function({isFirstScreen:e,stepName:t}){e&&i(this,$o,"m",cr).call(this,"ready",{}),i(this,$o,"m",cr).call(this,"page-updated",{screenName:t}),i(this,$o,"m",cr).call(this,"screen-updated",{screenName:t})},Yo=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},er=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${kn}])`));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})),{})}))},tr=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},nr=function(e={}){var t,n;const i=ri(e,["externalId","email","phone"]),o=ri(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)}},ir=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,$o,"m",or).call(this,e)))},or=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)}))},sr=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,rr,"f").call(this,t,e)}))}))},ar=function(e){this.contentRootElement.querySelectorAll(`descope-button:not([${In}]), [data-type="button"]:not([${In}]`).forEach((t=>{t.onclick=()=>{i(this,rr,"f").call(this,t,e)}})),i(this,$o,"m",sr).call(this,e),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${kn}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},lr=function(e,t){this.contentRootElement.addEventListener("transitionend",(()=>{this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0});const n=t===Hn.forward?"slide-forward":"slide-backward";Array.from(this.contentRootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(n)})),this.contentRootElement.classList.add("fade-out")},cr=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",kr);const Ir=document.createElement("template");Ir.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';class Sr extends HTMLElement{constructor(){super(),dr.add(this),ur.set(this,new gi({messages:[]})),hr.set(this,void 0),pr.set(this,void 0),gr.set(this,void 0),fr.set(this,{resize:i(this,dr,"m",yr).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ir.content.cloneNode(!0)),o(this,hr,this.shadowRoot.querySelector(".debugger"),"f"),o(this,pr,i(this,hr,"f").querySelector(".content"),"f"),o(this,gr,i(this,hr,"f").querySelector(".header"),"f"),i(this,dr,"m",vr).call(this)}updateData(e){i(this,ur,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((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]=xi(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,gr,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,fr,"f").resize),(e=i(this,hr,"f")).onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight},i(this,hr,"f").onresize=i(this,dr,"m",wr).bind(this),i(this,ur,"f").subscribe(i(this,dr,"m",mr).bind(this))}disconnectedCallback(){i(this,ur,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,fr,"f").resize)}}ur=new WeakMap,hr=new WeakMap,pr=new WeakMap,gr=new WeakMap,fr=new WeakMap,dr=new WeakSet,vr=function(){var e,t;const n=new CSSStyleSheet;n.replaceSync('\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),null!==(e=(t=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(t.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,n],i(this,hr,"f").style.top="32px",i(this,hr,"f").style.left=window.innerWidth-300-32+"px"},mr=function(e){i(this,dr,"m",br).call(this,e),i(this,dr,"m",wr).call(this)},br=function(e){i(this,pr,"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("")},wr=function(){i(this,pr,"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)}))},yr=function(){const[e,t]=xi(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",Sr);var Cr=Object.freeze({__proto__:null,default:Sr});const Or='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n';var xr=Object.freeze({__proto__:null,default:(e,t,i)=>n(void 0,void 0,void 0,(function*(){const{siteId:t}=e,n=Or.replace(/{{SITE_ID}}/g,t),o=document.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("id",t),o.text=n,document.body.appendChild(o),document.addEventListener("ftr:tokenReady",(e=>{i(e.detail)}))}))});const jr=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:t,useCloudflareIntegration:n,cloudflareScriptUrl:o,cloudflareEndpointUrl:r}=e;let s=[];s=n&&r?[r,ft]:[ft];let a=[];if(n&&o){const e=new URL(o);a=[`${e.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,It]}else a=[It];const l=St({apiKey:t,endpoint:s,scriptUrlPattern:a}),c=yield l,{requestId:d}=yield c.get();i(d)}catch(e){console.warn("Could not load fingerprint",e)}}));var Ar=Object.freeze({__proto__:null,default:jr,loadFingerprint:jr});const Ur=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:o,cloudflareEndpointPath:r,cloudflareScriptPath:s}=e,{baseUrl:a}=t;let l;l=n?`https://${n}`:a||"https://api.descope.com";const c=new URL(l);c.pathname=r;const d=new URL(l);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=St({apiKey:o,endpoint:[c.toString(),ft],scriptUrlPattern:[u,It]}),p=yield h,{requestId:g}=yield p.get();i(g)}catch(e){console.warn("Could not load descope fingerprint",e)}}));var Er=Object.freeze({__proto__:null,default:Ur,loadFingerprint:Ur});const Tr=105e3,Rr=(e,t,i)=>{let o=(new Date).getTime();const r=()=>{var t;return e.enterprise?null===(t=window.grecaptcha)||void 0===t?void 0:t.enterprise:window.grecaptcha};let s,a;const l=(t,n)=>{t.ready((()=>{e.siteKey&&(null==t||t.execute(a,{action:"load"}).then(((e,n)=>{n?console.warn("could not execute recaptcha",n):(i(e),o=(new Date).getTime(),s=setTimeout((()=>{l(t)}),Tr))})))}))},c=()=>{clearTimeout(s)},d=(()=>{const e=document.createElement("div");return e.style.display="none",e.id="recaptcha",document.body.appendChild(e)})(),u=()=>{const e=r();e&&l(e)};return window.onRecaptchaLoadCallback=()=>{const t=d;if(t.hasChildNodes())return;const n=r();n&&setTimeout((()=>{a=n.render(t,{sitekey:e.siteKey,badge:"inline",size:"invisible"}),l(n)}),0)},(()=>{const t=document.createElement("script");t.src=(()=>{const t=new URL("https://www.google.com/recaptcha/");return t.pathname+=(e.enterprise?"enterprise":"api")+".js",t.searchParams.append("onload","onRecaptchaLoadCallback"),t.searchParams.append("render","explicit"),t.toString()})(),t.async=!0,t.id="recaptcha-script",t.defer=!0,document.body.appendChild(t)})(),{stop:c,start:u,refresh:()=>n(void 0,void 0,void 0,(function*(){if(Date.now()-o>Tr){c();const e=o;return u(),new Promise((t=>{const n=setTimeout((()=>{console.warn("reCAPTCHA token refresh timed out"),t()}),5e3),i=()=>{o!==e?(clearTimeout(n),t()):setTimeout(i,150)};i()}))}return Promise.resolve()}))}};var Lr=Object.freeze({__proto__:null,default:Rr,loadGRecaptcha:Rr})}();
3
+ function pt(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 gt=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=pt({},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,"",pt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,pt({},this.attributes,t))},withConverter:function(t){return e(pt({},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 ft={default:"endpoint"},vt="Blocked by CSP",mt="The endpoint parameter is not a valid URL",bt="Failed to load the JS script of the agent",wt="9319";function yt(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===vt||s===mt)n.exclude(),r=0;else if(s===wt)n.exclude();else if(s===bt){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 kt="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",It=kt;function St(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:kt,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 yt(e,Ct)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===wt?new Error(bt):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 Ct(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(mt);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(bt))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(vt)})).then(Ot)}function Ot(){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(wt);return n}const xt=(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},jt=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},At=async e=>{const t=await jt(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Ut="undefined"!=typeof localStorage,Et=(e,t)=>Ut&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),Tt=e=>Ut&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),Rt=e=>Ut&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Lt=(...e)=>{console.debug(...e)},_t="undefined"!=typeof window,$t=Math.pow(2,31)-1,Pt="DS",Dt="DSR";function Mt(e=""){return Tt(`${e}${Dt}`)||""}function Nt(e=""){return gt.get(Pt)||Tt(`${e}${Pt}`)||""}function Wt(e=""){Rt(`${e}${Dt}`),Rt(`${e}${Pt}`),gt.remove(Pt)}const qt=_t&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Ft="vsid",Bt="vrid",Vt="fp",Kt=(e=!1)=>{const t=localStorage.getItem(Vt);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Ht=async(e,t=qt)=>{try{if(Kt())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=St({apiKey:e,endpoint:[i.toString(),ft],scriptUrlPattern:[r,It]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Ft]:e,[Bt]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(Vt,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Gt=e=>{const t=Kt(!0);return t&&e.body&&(e.body.fpData=t),e},Jt="dls_last_user_login_id",zt="dls_last_user_display_name",Xt=()=>Tt(Jt),Qt=()=>Tt(zt),Zt=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=Xt(),r=Qt();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)};function Yt(){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 en(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=an(n.publicKey.challenge),n.publicKey.user.id=an(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=an(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:ln(n.rawId),type:n.type,response:{attestationObject:ln(n.response.attestationObject),clientDataJSON:ln(n.response.clientDataJSON)}});var n}async function tn(e){const t=rn(e);return sn(await navigator.credentials.get(t))}async function nn(e,t){const n=rn(e);return n.signal=t.signal,n.mediation="conditional",sn(await navigator.credentials.get(n))}async function on(e=!1){if(!_t)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 rn(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=an(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=an(e.id)})),n}function sn(e){return JSON.stringify({id:e.id,rawId:ln(e.rawId),type:e.type,response:{authenticatorData:ln(e.response.authenticatorData),clientDataJSON:ln(e.response.clientDataJSON),signature:ln(e.response.signature),userHandle:e.response.userHandle?ln(e.response.userHandle):void 0}})}function an(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function ln(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var cn,dn=(cn=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 en(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 tn(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 en(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await tn(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 en(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:en,get:tn,isSupported:on,conditional:nn}}),(...e)=>{const t=cn(...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 un="/fedcm/config";async function hn(e,t){var n,i,o;try{const o=await async function(e,t="google",n,i,o){const r=(()=>{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)})(),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)}}catch(e){null===(o=null==t?void 0:t.onFailed)||void 0===o||o.call(t,e)}}var pn=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await on(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});const gn=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 _t?(i&&o&&Ht(i).catch((()=>null)),e(xt(r,{beforeRequest:Gt}))):e(r)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);if(!i)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;_t&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(Lt("Expiration time passed, refreshing session"),d.refresh(Mt()||c))}));const d=e(xt(o,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:i,sessionExpiration:o}=await jt(t);if(401===(null==t?void 0:t.status))Lt("Received 401, canceling all timers"),r();else if(i||o){if(l=((e,t)=>{if(t)return new Date(1e3*t);Lt("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}})(i,o),!l)return void Lt("Could not extract expiration time from session token");c=n;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>$t&&(Lt(`Timeout is too large (${t}ms), setting it to ${$t}ms`),t=$t),t})(l);if(r(),e<=2e4)return void Lt("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Lt(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Lt("Refreshing session due to timer"),d.refresh(Mt()||n)}),e)}}}));return ie(d,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return Lt("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.28.0"},t.baseHeaders)}))),(e=>t=>{const n=Yt(),i=Yt(),o=Yt(),r=e(xt(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 At(t);e&&o.pub(e);const{sessionJwt:r,sessionExpiration:s}=await jt(t);r&&i.pub(r),(s||r)&&n.pub(s||42)}}})),s=ie(r,["logout","logoutAll"],(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=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:Xt,getLastUserDisplayName:Qt});const s=e(xt(r,{afterRequest:async(e,t)=>{var n;const i=await At(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=>{Et(Jt,e)})(o),(e=>{Et(zt,e)})(r))}}));let a=ie(s,["flow.start"],Zt);return a=ie(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(Rt(Jt),Rt(zt)),i})(o)),Object.assign(a,{getLastUserLoginId:Xt,getLastUserDisplayName:Qt})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!_t)return e(s);const a=e(xt(s,{beforeRequest:(l=r,e=>Object.assign(e,{token:e.token||Mt(l)})),afterRequest:async(e,n)=>{const i=/^\/v\d+\/mgmt\//.test(e.path);401===(null==n?void 0:n.status)?i||Wt(r):((e={},n,i)=>{var o,{refreshJwt:r,sessionJwt:s}=e,a=t(e,["refreshJwt","sessionJwt"]);if(void 0===n&&(n=!1),void 0===i&&(i=""),r&&Et(`${i}${Dt}`,r),s)if(n){const e=n.sameSite||"Strict",t=null===(o=n.secure)||void 0===o||o;!function(e,t,{cookiePath:n,cookieDomain:i,cookieExpiration:o,cookieSameSite:r="Strict",cookieSecure:s=!0}){if(t){const a=new Date(1e3*o),l=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(i);gt.set(e,t,{path:n,domain:l?i:void 0,expires:a,sameSite:r,secure:s})}}(Pt,s,Object.assign(Object.assign({},a),{cookieSameSite:e,cookieSecure:t}))}else Et(`${i}${Pt}`,s)})(await jt(n),o,r)}}));var l;const c=ie(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return Wt(e),i})(r));return Object.assign(c,{getRefreshToken:()=>Mt(r),getSessionToken:()=>Nt(r)})}))(((...e)=>{const t=ht(...e);return Object.assign(Object.assign({},t),{refresh:e=>{const n=Nt(),i=Mt();return t.refresh(e,{dcs:n?"t":"f",dcr:i?"t":"f"})},flow:pn(t),webauthn:dn(t),fedcm:(n=t,i=e[0].projectId,{onetap:{requestExchangeCode(e){hn(n,e)},requestAuthentication(e){hn(n,e)}},oneTap(e,t,i,o,r){hn(n,{provider:e,oneTapConfig:t,loginOptions:i,onSkipped:o,onDismissed:r})},async launch(e){var t;const o={identity:{context:e||"signin",providers:[{configURL:n.httpClient.buildUrl(i+un),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return n.refresh(r.token)},isSupported:()=>_t&&"IdentityCredential"in window,async isLoggedIn(e){var t;const o=n.httpClient.buildUrl(i+un);try{const n={identity:{context:e||"signin",providers:[{configURL:o,clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return!!r&&!!r.token}catch(e){return!1}}})});var n,i})),fn="undefined"!=typeof localStorage,vn="J151000",mn=fn&&localStorage.getItem("base.content.url")||"",bn="base.ui.components.url";fn&&localStorage.getItem(bn),fn&&localStorage.getItem(bn);const wn="descope-login-flow",yn="code",kn="data-exclude-field",In="data-exclude-next",Sn="dls_last_auth",Cn="state_id",On="saml_idp_state_id",xn="saml_idp_username",jn="descope_idp_initiated",An="sso_app_id",Un="third_party_app_id",En="third_party_app_state_id",Tn="oidc_login_hint",Rn="oidc_prompt",Ln="oidc_error_redirect_uri",_n="application_scopes",$n="data-type",Pn="redirect",Dn="poll",Mn="webauthnCreate",Nn="webauthnGet",Wn="nativeBridge",qn="loadForm",Fn="submit",Bn="polling",Vn=["descope-multi-select-combo-box","descope-text-area"],Kn=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Hn;!function(e){e.backward="backward",e.forward="forward"}(Hn||(Hn={}));const Gn=["descope-enriched-text"];function Jn(e){return new URLSearchParams(window.location.search).get(e)}function zn(e){if(window.history.replaceState&&Jn(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 Xn(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?Hn.forward:n<i?Hn.backward:void 0}const Qn=e=>{let[t="",n=""]=(Jn(wn)||"").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 Zn(){zn(wn)}const Yn=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),ei=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=Qn(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&Zn();const r=Jn("t")||void 0;r&&zn("t");const s=Jn(yn)||void 0;s&&zn(yn);const a=Jn("err")||void 0;a&&zn("err");const{redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u}={redirectAuthCodeChallenge:Jn("ra-challenge"),redirectAuthCallbackUrl:Jn("ra-callback"),redirectAuthBackupCallbackUri:Jn("ra-backup-callback"),redirectAuthInitiator:Jn("ra-initiator")},h=Jn(Cn);h&&zn(Cn);const p=Jn(On);p&&zn(On);const g=Jn(xn);p&&zn(xn);const f=Jn(jn);f&&zn(jn);const v=Jn(An);v&&zn(An);const m=Jn(Un);m&&zn(Un);const b=Jn(En);b&&zn(En);const w=Jn(_n);w&&zn(_n);const y=Jn(Tn);y&&zn(Tn);const k=Jn(Rn);k&&zn(Rn);const I=Jn(Ln);I&&zn(Ln);return{executionId:n,stepId:i,token:r,code:s,exchangeError:a,redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u,ssoQueryParams:{oidcIdpStateId:h,samlIdpStateId:p,samlIdpUsername:g,descopeIdpInitiated:"true"===f,ssoAppId:v,oidcLoginHint:y,oidcPrompt:k,oidcErrorRedirectUri:I,thirdPartyAppId:m,thirdPartyAppStateId:b,applicationScopes:w}}},ti=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}})};function ni(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 ii=(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),oi=e=>null==e?void 0:e.submit(),ri=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},si=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function ai(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 li=e=>{const t=(n=e.screenState,i=(e,t)=>Kn.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!i(t,e)))));var n,i;const{screenState:{errorText:o,errorType:r}}=e;return(o||r)&&(t.error={text:o,type:r}),t};var ci,di,ui,hi;function pi(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(!pi(r,s))return!1}else if(r!==s)return!1}return!0}class gi{constructor(e={},{forceUpdate:t=!1}={}){ci.set(this,void 0),di.set(this,{}),ui.set(this,0),hi.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,ci,"f")):e,n=Object.assign(Object.assign({},i(this,ci,"f")),t),r=i(this,ci,"f");o(this,ci,n,"f"),Object.freeze(i(this,ci,"f")),setTimeout((()=>{Object.values(i(this,di,"f")).forEach((({cb:e,selector:t})=>{const o=t(r),s=t(n);!i(this,hi,"f")&&(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(s)?pi(o,s):o===s)||e(s,o,((e,t)=>n=>e[n]!==t[n])(s,o))}))}),0)},o(this,ci,e,"f"),o(this,hi,t,"f")}get current(){return Object.assign({},i(this,ci,"f"))}set forceUpdate(e){o(this,hi,e,"f")}subscribe(e,t=e=>e){return o(this,ui,i(this,ui,"f")+1,"f"),i(this,di,"f")[i(this,ui,"f")]={cb:e,selector:t},i(this,ui,"f").toString()}unsubscribe(e){const t=!!i(this,di,"f")[e];return t&&delete i(this,di,"f")[e],t}unsubscribeAll(){return o(this,di,{},"f"),!0}}ci=new WeakMap,di=new WeakMap,ui=new WeakMap,hi=new WeakMap;const fi=["*","#","/","(",")","[","]","_","<",">","`"],vi=e=>{const t=fi.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")},mi=["disabled"],bi=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${kn}])`)).forEach((e=>{e.value=n}))}))},wi=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),yi=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?(e=>"string"!=typeof e?e:e.replace(vi("\\"),"\\$1"))(wi(t,i)):wi(t,i))),ki=(e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(i=e.localName,Gn.includes(i));var i;e.textContent=yi(e.textContent,t,n);const o=e.getAttribute("href");o&&e.setAttribute("href",yi(o,t))}))},Ii=(e,t,n)=>{e.querySelectorAll(`[${$n}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Si=(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})`))},Ci=(e,n,i,o,r)=>{var s,a;Ii(e,"totp-link",null===(s=null==n?void 0:n.totp)||void 0===s?void 0:s.provisionUrl),Ii(e,"notp-link",null===(a=null==n?void 0:n.notp)||void 0===a?void 0:a.redirectUrl),ki(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=yi(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])=>{mi.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)},Oi=ti((()=>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 ni(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}})))),xi=(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))]},ji="dls_ab_testing_id",Ai={"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}};function Ui(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(Sn)))}catch(e){}return t}function Ei(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const Ti=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}},Ri=["error","warn","info","debug"],Li=Ti((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 Ri.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})),_i="undefined"!=typeof localStorage,$i=_i&&localStorage.getItem("base.content.url")||"",Pi=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,Di=Ti((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})),Mi=Ti((e=>{var t,n;const o=Ei(Li,Di)(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})),Ni=e=>t=>{var n,o,r;const s=Ei(Li,Di,Mi)(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};Ni.missingAttrValidator=Pi;const Wi=Ti((e=>{const t=Ei(Ni({"project-id":Pi}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),qi=Ti((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),Fi="Trying the next fallback URL...";function Bi({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 Vi=Ti((e=>{var t,n,r,s,a;const l=Ei(Li,Wi,qi)(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 fetch(r.toString(),t);if(o.ok)return null==i||i(e),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${Fi}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${Fi}`)}}})(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=$i||this.baseStaticUrl;if(t)return Bi({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=Bi({projectId:this.projectId,filename:e,baseUrl:i(this,r,"f")});if(!a)return l;return[Bi({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),l]},a})),Ki=Ti((e=>{var t,n;const o=Ei(Ni({"project-id":Pi}))(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})),Hi=Ti((e=>{var t,n,r,s,a;const l=Ei(Vi,Ki,Di)(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})),Gi="load-descope-ui",Ji="base.ui.components.url",zi=_i&&localStorage.getItem(Ji)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Xi=_i&&localStorage.getItem(Ji)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Qi=_i&&localStorage.getItem(Ji)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Zi=e=>{const t=document.createElement("script");return t.id=e,t},Yi=(e,t)=>e.replace("<version>",t),eo=Ti((e=>{var t,n,r,s,a,l,c,d,u,h,p,g;const f=Ei(Li,Hi)(e);return g=class extends f{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),r.set(this,Symbol("loadCbs")),u.set(this,void 0)}get descopeUi(){return i(this,u,"f")||o(this,u,i(this,t,"m",p).call(this),"f"),i(this,u,"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",h).call(this,e))))}get baseCdnUrl(){return this.getAttribute("base-cdn-url")}},n=new WeakMap,r=new WeakMap,u=new WeakMap,t=new WeakSet,s=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},a=function(e){const t=i(this,n,"f"),o=i(this,r,"f");e[t]=[],e[o]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[o].push(t)}})},l=async function(e,n,o,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const a=Zi(o);document.body.append(a),a.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${a.src}"`)))})),a.addEventListener("load",(()=>{n.forEach((e=>e()))})),a.src=Yi(r,await i(this,t,"m",s).call(this))},c=function(e){e.addEventListener("error",(()=>{e[i(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),i(this,t,"m",l).call(this,[i(this,t,"m",l).bind(this,e[i(this,n,"f")],e[i(this,r,"f")],"load-descope-ui-fallback-script-2",Qi),...e[i(this,n,"f")]],e[i(this,r,"f")],"load-descope-ui-fallback-script",Xi)})),e.addEventListener("load",(()=>{e[i(this,r,"f")].forEach((e=>e()))}))},d=async function(){if(document.querySelector(`script#${Gi}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=Zi(Gi);document.body.append(e),i(this,t,"m",a).call(this,e),i(this,t,"m",c).call(this,e),e.src=Yi(this.baseCdnUrl||zi,await i(this,t,"m",s).call(this))}return document.getElementById(Gi)},h=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(", ")}"`)},p=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),i(this,t,"m",d).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},g})),to="content-root",no="root",io=Ti((e=>class extends e{constructor(...e){var t,n,i,o;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${no}">\n <div id="${to}"></div>\n </div>\n `;const r=new CSSStyleSheet;r.replaceSync(`\n #${no}, #${to} {\n height: 100%;\n }\n #${no} {\n position: relative;\n height: fit-content;\n }\n `),null!==(t=(o=this.shadowRoot).adoptedStyleSheets)&&void 0!==t||(o.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,r],this.contentRootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(to),this.rootElement=null===(i=this.shadowRoot)||void 0===i?void 0:i.getElementById(no)}})),oo=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ro=Ti((e=>{var t,n,r,s,a,l,c,d,u,h,p,g,f,v;const m=Ei(Ni({theme:oo}),Vi,Di,eo,Hi,io,Mi)(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,t,"m",l).call(this),i(this,t,"m",c).call(this),i(this,p,"f").call(this),this.observeAttributes(["theme"],i(this,p,"f")),this.observeAttributes(["style-id"],(()=>{o(this,r,null,"f"),i(this,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,s,l;const c=await i(this,t,"a",a);c&&(i(this,n,"f")||(o(this,n,new CSSStyleSheet,"f"),null!==(e=(l=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(l.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,i(this,n,"f")]),i(this,n,"f").replaceSync(((null===(r=null==c?void 0:c.light)||void 0===r?void 0:r.globals)||"")+((null===(s=null==c?void 0:c.dark)||void 0===s?void 0:s.globals)||"")))},c=async function(){var e,n;const o=Object.assign({},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})),so=(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),so(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}),[]),ao=Ti((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 lo,co,uo,ho,po,go,fo,vo,mo,bo,wo,yo,ko,Io,So,Co,Oo,xo,jo,Ao,Uo,Eo,To;const Ro=Ei(ro,Vi,ao)(HTMLElement);class Lo extends Ro{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","nonce"]}constructor(e){super(),lo.add(this),uo.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,lo,"m",Uo).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)}},ho.set(this,new gi),po.set(this,new gi),go.set(this,{}),this.getComponentsContext=()=>i(this,go,"f"),this.nextRequestStatus=new gi({isLoading:!1}),fo.set(this,void 0),vo.set(this,{popstate:i(this,lo,"m",ko).bind(this),componentsContext:i(this,lo,"m",xo).bind(this)}),mo.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,mo,e,"f"),i(this,lo,"m",wo).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 so(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 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,po,"f").subscribe(i(this,lo,"m",Ao).bind(this)),i(this,po,"f").update({isDebug:this.debug}),i(this,lo,"m",yo).call(this),i(this,lo,"m",To).call(this),yield i(this,lo,"m",Co).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,lo,"m",Eo).call(this);const{executionId:r,stepId:s,token:a,code:l,exchangeError:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p,ssoQueryParams:g}=ei(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,vo,"f").popstate),window.addEventListener("components-context",i(this,vo,"f").componentsContext),i(this,ho,"f").subscribe(i(this,lo,"m",So).bind(this)),i(this,ho,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:a,code:l,exchangeError:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p},g)),o(this,uo,!0,"f")}))}disconnectedCallback(){i(this,ho,"f").unsubscribeAll(),i(this,po,"f").unsubscribeAll(),i(this,lo,"m",jo).call(this),window.removeEventListener("popstate",i(this,vo,"f").popstate),window.removeEventListener("components-context",i(this,vo,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,uo,"f")&&t!==n&&co.observedAttributes.includes(e)){i(this,lo,"m",yo).call(this);const o=null===t;"nonce"===e&&i(this,lo,"m",To).call(this),i(this,ho,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Zn()),{[Yn(e)]:n,stepId:r,executionId:s}})),i(this,po,"f").update({isDebug:this.debug})}}}function _o(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var $o,Po,Do,Mo,No,Wo,qo,Fo,Bo,Vo,Ko,Ho,Go,Jo,zo,Xo,Qo,Zo,Yo,er,tr,nr,ir,or,rr,sr,ar,lr,cr,dr,ur,hr,pr,gr,fr,vr,mr,br,wr,yr;co=Lo,uo=new WeakMap,ho=new WeakMap,po=new WeakMap,go=new WeakMap,fo=new WeakMap,vo=new WeakMap,mo=new WeakMap,lo=new WeakSet,bo=function(){var e,t;const n=new CSSStyleSheet;n.replaceSync("\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 300ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n .hidden {\n display: none;\n }\n "),null!==(e=(t=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(t.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,n]},wo=function(){i(this,lo,"m",bo).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},yo=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","nonce"];co.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Yn(t)])throw Error(`${t} cannot be empty`)}))},ko=function(){const{stepId:e,executionId:t}=Qn(this.flowId);i(this,ho,"f").update({stepId:e,executionId:t})},Io=function(e,t){this.sdk=gn(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},co.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:vn,errorDescription:e.toString()}}}}))}))},So=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,lo,"m",Io).call(this,t,n)}i(this,mo,"f").call(this,e)}))},Co=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,lo,"m",Oo).call(this))}))},Oo=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(mn||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}}))},xo=function(e){o(this,go,Object.assign(Object.assign({},i(this,go,"f")),e.detail),"f")},jo=function(){var e;null===(e=i(this,fo,"f"))||void 0===e||e.remove(),o(this,fo,null,"f")},Ao=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,fo,document.createElement("descope-debugger"),"f"),Object.assign(i(this,fo,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Cr})),document.body.appendChild(i(this,fo,"f"))):i(this,lo,"m",jo).call(this)}))},Uo=function(e,t){var n;e&&this.debug&&(null===(n=i(this,fo,"f"))||void 0===n||n.updateData({title:e,description:t}))},Eo=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=Vn.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()}}},To=function(){this.getAttribute("nonce")&&(window.DESCOPE_NONCE=this.getAttribute("nonce"))},Lo.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.40.3"}};class kr extends Lo{static set sdkConfigOverrides(e){Lo.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Lo.sdkConfigOverrides}constructor(){const e=new gi({deferredRedirect:!1});super(e.update.bind(e)),$o.add(this),this.stepState=new gi({}),Po.set(this,void 0),Do.set(this,null),Mo.set(this,null),No.set(this,{visibilitychange:i(this,$o,"m",Wo).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var n;const o=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=o;if(!e){e=null===(n=new URL(o.url).searchParams)||void 0===n?void 0:n.get(yn)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(o.url),t=e.searchParams.get("t"),n=e.searchParams.get(wn).split("_").pop();i(this,Go,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else this.nativeComplete(o)},Ko.set(this,(e=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e)})),Ho.set(this,((e,t,r,s,a=!1)=>{if(this.flowState.current.action===Dn){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),c=a?500:2e3;o(this,Po,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const o=this.sdk.flow.next(e,t,Bn,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 ni(e,o)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,Ho,"f").call(this,e,t,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===vn)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,Ho,"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,Ho,"f").call(this,e,t,r,s),i(this,Jo,"f").call(this,u)}))),c),"f")}})),Go.set(this,(()=>{clearTimeout(i(this,Po,"f")),o(this,Po,null,"f")})),Jo.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,$o,"m",cr).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,$o,"m",Bo).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}=e.data;if(y!==Dn&&i(this,Go,"f").call(this),"completed"===m)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&fn&&localStorage.setItem(Sn,JSON.stringify(e))}(w),void i(this,$o,"m",cr).call(this,"success",b);const{executionId:k,stepId:I,stepName:S,screen:C,redirect:O,openInNewTabUrl:x,webauthn:j,error:A,samlIdpResponse:U,nativeResponse:E}=e.data,T=Date.now();y!==Dn?(this.loggerWrapper.info(`Step "${S||`#${I}`}" is ${m}`,"",{screen:C,status:m,stepId:I,stepName:S,action:y,error:A}),(null===(f=C.state)||void 0===f?void 0:f.clientScripts)&&o(this,Mo,this.loadSdkScripts(C.state.clientScripts),"f"),this.flowState.update({stepId:I,stepName:S,executionId:k,action:y,redirectTo:null==O?void 0:O.url,openInNewTabUrl:x,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==U?void 0:U.url,samlIdpResponseSamlResponse:null==U?void 0:U.samlResponse,samlIdpResponseRelayState:null==U?void 0:U.relayState,nativeResponseType:null==E?void 0:E.type,nativePayload:null==E?void 0:E.payload,reqTimestamp:T})):this.flowState.update({action:y,reqTimestamp:T})})),zo.set(this,ti((()=>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)}}))))),rr.set(this,si(((e,t)=>n(this,void 0,void 0,(function*(){var n,o;if("true"===e.getAttribute("formnovalidate")||i(this,$o,"m",Yo).call(this)){const r=null==e?void 0:e.getAttribute("id");i(this,$o,"m",tr).call(this,e);const s=yield i(this,$o,"m",er).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,Mo,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,Mo,"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 ni(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,$o,"m",nr).call(this,s)}}))))),this.flowState=e}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:{[_o(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 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===(i=null==t?void 0:t.start)||void 0===i||i.call(t),t}const r=yield function(e){return n(this,void 0,void 0,(function*(){let t;switch(e){case"forter":return t=yield Promise.resolve().then((function(){return xr})),t.default;case"fingerprint":return t=yield Promise.resolve().then((function(){return Ar})),t.default;case"fingerprintDescope":return t=yield Promise.resolve().then((function(){return Er})),t.default;case"grecaptcha":return t=yield Promise.resolve().then((function(){return Lr})),t.default;default:throw new Error(`Unknown script id: ${e}`)}}))}(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.isDescopeBridge)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,$o,"m",Fo).call(this),window.addEventListener("visibilitychange",i(this,No,"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,Do,"f"))||void 0===e||e.abort(),o(this,Do,null,"f"),window.removeEventListener("visibilitychange",i(this,No,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=ai(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,openInNewTabUrl:b,redirectUrl:w,token:y,code:k,exchangeError:I,webauthnTransactionId:S,webauthnOptions:C,redirectAuthCodeChallenge:O,redirectAuthCallbackUrl:x,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:A,locale:U,samlIdpResponseUrl:E,samlIdpResponseSamlResponse:T,samlIdpResponseRelayState:R,nativeResponseType:L,nativePayload:_,reqTimestamp:$}=e,P=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload","reqTimestamp"]);let D,M,N;const W=(()=>{const e=localStorage.getItem(ji);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(ji,e.toString()),e}return Number(e)})(),q=this.sdk.getLastUserLoginId(),F=yield this.getFlowConfig(),B=yield this.getProjectConfig(),V=Object.entries(B.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),K=x&&O?{callbackUrl:x,codeChallenge:O,backupCallbackUri:j}:void 0,H=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;let G={};if(!p){const e=[...F.clientScripts||[],...F.sdkScripts||[]];if(F.conditions){let t=[];({startScreenId:D,conditionInteractionId:N,startScreenName:M,clientScripts:t,componentsConfig:G}=((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=Ai[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:q,code:k,token:y,abTestingKey:W},F.conditions)),e.push(...t||[])}else F.condition?({startScreenId:D,conditionInteractionId:N}=((e,t)=>{var n;const i=null===(n=Ai[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}})(F.condition,{loginId:q,code:k,token:y,abTestingKey:W})):(M=F.startScreenName,D=F.startScreenId);if(o(this,Mo,this.loadSdkScripts(e),"f"),F.fingerprintEnabled&&F.fingerprintKey?yield Ht(F.fingerprintKey,this.baseUrl):localStorage.removeItem(Vt),!ii(D,P)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:K},P),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:Ui(q),abTestingKey:W,locale:ai(U).locale,nativeOptions:H}),N,"",B.componentsVersion,V,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),P.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),P.oidcLoginHint?{externalId:P.oidcLoginHint}:{}));return i(this,Jo,"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(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&I)){const e=yield this.sdk.flow.next(p,h,Fn,F.version,B.componentsVersion,{token:y,exchangeCode:k,exchangeError:I});return i(this,Jo,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===qn&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!E||!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)})(E,T,R||"",oi)}if(g===Pn&&(s("redirectTo")||s("deferredRedirect")))return m?"android"===A&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(m):void this.loggerWrapper.error("Did not get redirect url");if(g===Mn||g===Nn){if(!S||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=i(this,Do,"f"))||void 0===l||l.abort(),o(this,Do,null,"f");try{e=g===Mn?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,Fn,F.version,B.componentsVersion,{transactionId:S,response:e,failure:t});i(this,Jo,"f").call(this,n)}if(g===Wn)return this.nativeComplete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,Fn,F.version,B.componentsVersion,e);i(this,Jo,"f").call(this,t)})),void i(this,$o,"m",cr).call(this,"bridge",{type:L,payload:_});if(s("action")&&i(this,Ho,"f").call(this,p,h,F.version,B.componentsVersion),!f&&!D)return void this.loggerWrapper.warn("No screen was found to show");const J=D||f,z=yield this.getHtmlFilenameWithLocale(U,J),{oidcLoginHint:X,oidcPrompt:Q,oidcErrorRedirectUri:Z,samlIdpUsername:Y}=P,ee={direction:Xn(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:q,name:this.sdk.getLastUserDisplayName()||q},componentsConfig:Object.assign(Object.assign(Object.assign({},F.componentsConfig),G),null==v?void 0:v.componentsConfig)}),htmlFilename:`${J}.html`,htmlLocaleFilename:z,screenId:J,stepName:e.stepName||M,samlIdpUsername:Y,oidcLoginHint:X,oidcPrompt:Q,oidcErrorRedirectUri:Z,openInNewTabUrl:b},te=Ui(q);ii(D,P)?ee.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:K},P),{lastAuth:te,preview:this.preview,abTestingKey:W,client:this.client}),w&&{redirectUrl:w}),{locale:ai(U).locale,nativeOptions:H}),N,e,B.componentsVersion,V,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),t),k&&{exchangeCode:k,idpInitiated:!0}),P.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y}));return i(this,Jo,"f").call(this,n),n})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(ee.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.next(p,h,e,F.version,B.componentsVersion,t);return i(this,Jo,"f").call(this,n),n}))),this.loggerWrapper.debug("Got a screen with id",ee.screenId),yield i(this,$o,"m",Vo).call(this,ee),this.stepState.update(ee)}))}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,openInNewTabUrl:u}=e;this.loggerWrapper.debug("Rendering a flow screen");const h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),g=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield i(this,$o,"m",Qo).call(this,p,c):p.querySelectorAll(`descope-button[${$n}="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),Ci(p,d,d.componentsConfig,this.formConfig,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(p,f);const v=()=>n(this,void 0,void 0,(function*(){var n,o;yield g;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,Si(s,"descope-totp-image",a),((e,t)=>{Si(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,p,d.cssVars,this.loggerWrapper),r.replaceChildren(p);const l=!t.htmlFilename;setTimeout((()=>{i(this,$o,"m",ir).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((e=>{e.addEventListener("blur",(()=>{var t;const n=e.focus;e.focus=()=>{},null===(t=e.reportValidity)||void 0===t||t.call(e),setTimeout((()=>{e.focus=n}))}))}))})(r),((e,t)=>{bi(e,null==t?void 0:t.inputs),bi(e,null==t?void 0:t.form)})(r,d),i(this,$o,"m",Zo).call(this,{isFirstScreen:l,stepName:e.stepName}),((e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(r,this.autoFocus,l)})),i(this,$o,"m",ar).call(this,c);r.querySelector(`[${$n}="polling"]`)&&c(Bn,{}),u&&!t.openInNewTabUrl&&window.open(u,"_blank")}));l?i(this,$o,"m",lr).call(this,v,l):v()}))}}Po=new WeakMap,Do=new WeakMap,Mo=new WeakMap,No=new WeakMap,Ko=new WeakMap,Ho=new WeakMap,Go=new WeakMap,Jo=new WeakMap,zo=new WeakMap,rr=new WeakMap,$o=new WeakSet,Wo=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},qo=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(`[${$n}="${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()},Fo=function(){var e,n;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,$o,"m",qo).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}}))},Bo=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")}))},Vo=function(e){return n(this,void 0,void 0,(function*(){var n;const o=Object.assign(Object.assign({},this.stepState.current),e),{next:r,stepName:s}=o,a=t(o,["next","stepName"]),l=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,s,li(a),r,this));if(l){this.loggerWrapper.debug("Rendering a custom screen"),this.contentRootElement.innerHTML="",i(this,$o,"m",Zo).call(this,{isFirstScreen:!this.stepState.current.htmlFilename,stepName:e.stepName}),this.stepState.unsubscribeAll();const t=this.stepState.subscribe((()=>{this.stepState.unsubscribe(t),i(this,$o,"m",Fo).call(this)}))}this.stepState.forceUpdate=l,i(this,Ko,"f").call(this,l)}))},Xo=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)}))}},Qo=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,Do,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Oi())){const{options:e,transactionId:r}=(yield i(this,zo,"f").call(this))||{};e&&r&&(i(this,$o,"m",Xo).call(this,s),o(this,Do,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,Do,"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)})))}}))},Zo=function({isFirstScreen:e,stepName:t}){e&&i(this,$o,"m",cr).call(this,"ready",{}),i(this,$o,"m",cr).call(this,"page-updated",{screenName:t}),i(this,$o,"m",cr).call(this,"screen-updated",{screenName:t})},Yo=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},er=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${kn}])`));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})),{})}))},tr=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},nr=function(e={}){var t,n;const i=ri(e,["externalId","email","phone"]),o=ri(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)}},ir=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,$o,"m",or).call(this,e)))},or=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)}))},sr=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,rr,"f").call(this,t,e)}))}))},ar=function(e){this.contentRootElement.querySelectorAll(`descope-button:not([${In}]), [data-type="button"]:not([${In}]`).forEach((t=>{t.onclick=()=>{i(this,rr,"f").call(this,t,e)}})),i(this,$o,"m",sr).call(this,e),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${kn}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},lr=function(e,t){this.contentRootElement.addEventListener("transitionend",(()=>{this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0});const n=t===Hn.forward?"slide-forward":"slide-backward";Array.from(this.contentRootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(n)})),this.contentRootElement.classList.add("fade-out")},cr=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",kr);const Ir=document.createElement("template");Ir.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';class Sr extends HTMLElement{constructor(){super(),dr.add(this),ur.set(this,new gi({messages:[]})),hr.set(this,void 0),pr.set(this,void 0),gr.set(this,void 0),fr.set(this,{resize:i(this,dr,"m",yr).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ir.content.cloneNode(!0)),o(this,hr,this.shadowRoot.querySelector(".debugger"),"f"),o(this,pr,i(this,hr,"f").querySelector(".content"),"f"),o(this,gr,i(this,hr,"f").querySelector(".header"),"f"),i(this,dr,"m",vr).call(this)}updateData(e){i(this,ur,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((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]=xi(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,gr,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,fr,"f").resize),(e=i(this,hr,"f")).onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight},i(this,hr,"f").onresize=i(this,dr,"m",wr).bind(this),i(this,ur,"f").subscribe(i(this,dr,"m",mr).bind(this))}disconnectedCallback(){i(this,ur,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,fr,"f").resize)}}ur=new WeakMap,hr=new WeakMap,pr=new WeakMap,gr=new WeakMap,fr=new WeakMap,dr=new WeakSet,vr=function(){var e,t;const n=new CSSStyleSheet;n.replaceSync('\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'),null!==(e=(t=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(t.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,n],i(this,hr,"f").style.top="32px",i(this,hr,"f").style.left=window.innerWidth-300-32+"px"},mr=function(e){i(this,dr,"m",br).call(this,e),i(this,dr,"m",wr).call(this)},br=function(e){i(this,pr,"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("")},wr=function(){i(this,pr,"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)}))},yr=function(){const[e,t]=xi(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",Sr);var Cr=Object.freeze({__proto__:null,default:Sr});const Or='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n';var xr=Object.freeze({__proto__:null,default:(e,t,i)=>n(void 0,void 0,void 0,(function*(){const{siteId:t}=e,n=Or.replace(/{{SITE_ID}}/g,t),o=document.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("id",t),o.text=n,document.body.appendChild(o),document.addEventListener("ftr:tokenReady",(e=>{i(e.detail)}))}))});const jr=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:t,useCloudflareIntegration:n,cloudflareScriptUrl:o,cloudflareEndpointUrl:r}=e;let s=[];s=n&&r?[r,ft]:[ft];let a=[];if(n&&o){const e=new URL(o);a=[`${e.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,It]}else a=[It];const l=St({apiKey:t,endpoint:s,scriptUrlPattern:a}),c=yield l,{requestId:d}=yield c.get();i(d)}catch(e){console.warn("Could not load fingerprint",e)}}));var Ar=Object.freeze({__proto__:null,default:jr,loadFingerprint:jr});const Ur=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:o,cloudflareEndpointPath:r,cloudflareScriptPath:s}=e,{baseUrl:a}=t;let l;l=n?`https://${n}`:a||"https://api.descope.com";const c=new URL(l);c.pathname=r;const d=new URL(l);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=St({apiKey:o,endpoint:[c.toString(),ft],scriptUrlPattern:[u,It]}),p=yield h,{requestId:g}=yield p.get();i(g)}catch(e){console.warn("Could not load descope fingerprint",e)}}));var Er=Object.freeze({__proto__:null,default:Ur,loadFingerprint:Ur});const Tr=105e3,Rr=(e,t,i)=>{let o=(new Date).getTime();const r=()=>{var t;return e.enterprise?null===(t=window.grecaptcha)||void 0===t?void 0:t.enterprise:window.grecaptcha};let s,a;const l=(t,n)=>{t.ready((()=>{e.siteKey&&(null==t||t.execute(a,{action:"load"}).then(((e,n)=>{n?console.warn("could not execute recaptcha",n):(i(e),o=(new Date).getTime(),s=setTimeout((()=>{l(t)}),Tr))})))}))},c=()=>{clearTimeout(s)},d=(()=>{const e=document.createElement("div");return e.style.display="none",e.id="recaptcha",document.body.appendChild(e)})(),u=()=>{const e=r();e&&l(e)};return window.onRecaptchaLoadCallback=()=>{const t=d;if(t.hasChildNodes())return;const n=r();n&&setTimeout((()=>{a=n.render(t,{sitekey:e.siteKey,badge:"inline",size:"invisible"}),l(n)}),0)},(()=>{const t=document.createElement("script");t.src=(()=>{const t=new URL("https://www.google.com/recaptcha/");return t.pathname+=(e.enterprise?"enterprise":"api")+".js",t.searchParams.append("onload","onRecaptchaLoadCallback"),t.searchParams.append("render","explicit"),t.toString()})(),t.async=!0,t.id="recaptcha-script",t.defer=!0,document.body.appendChild(t)})(),{stop:c,start:u,refresh:()=>n(void 0,void 0,void 0,(function*(){if(Date.now()-o>Tr){c();const e=o;return u(),new Promise((t=>{const n=setTimeout((()=>{console.warn("reCAPTCHA token refresh timed out"),t()}),5e3),i=()=>{o!==e?(clearTimeout(n),t()):setTimeout(i,150)};i()}))}return Promise.resolve()}))}};var Lr=Object.freeze({__proto__:null,default:Rr,loadGRecaptcha:Rr})}();