@descope/web-component 3.40.8 → 3.40.9
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/cjs/descope-wc/BaseDescopeWc.js +1 -1
- package/dist/cjs/descope-wc/DescopeWc.js +1 -1
- package/dist/cjs/descope-wc/DescopeWc.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/descope-wc/BaseDescopeWc.js +1 -1
- package/dist/esm/descope-wc/DescopeWc.js +1 -1
- package/dist/esm/descope-wc/DescopeWc.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function i(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.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,o=e.split(".")[n];if("string"!=typeof o)throw new r(`Invalid token specified: missing part #${n+1}`);let i;try{i=s(o)}catch(e){throw new r(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}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:o})=>{const i=o.slice(1,-27);t=t.replace(c,i?i+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{r=`${r}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return r},w=(...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,o])=>(e[n]=o,e)),e),e}),{})),b={"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.41.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:o,logger:i,hooks:r,cookiePolicy:s,fetch:a})=>{const l=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),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 o=await n(...t);return e[o.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()})(o)),o}:n})(i,a),c=async i=>{var a;const c=(null==r?void 0:r.beforeRequest)?r.beforeRequest(i):i,{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:w(y(t,f),k(o),(null==n?void 0:n.baseHeaders)||{},I(v)?b:{},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(i,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,o]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:o})}),{}),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:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:v.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>c({path:e,headers:n,queryParams:o,body:t,method:v.post,token:i}),patch:(e,t,{headers:n,queryParams:o,token:i}={})=>c({path:e,headers:n,queryParams:o,body:t,method:v.patch,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>c({path:e,headers:n,queryParams:o,body:t,method:v.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:v.delete,token:o}),hooks:r,buildUrl:(n,o)=>m({projectId:t,baseUrl:e,path:n,queryParams:o})}};var C=429;function O(e,t,n){var o;let i=x(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[h])===t)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[t]}const r=null==i?void 0:i[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 U(e){let t=x(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function A(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 o=await e,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=r:(i.error=r,o.status===C&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}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 o=e.filter((e=>e(t)));return!(o.length<e.length)&&(n?n.replace("{val}",t):o.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"),J=_((e=>void 0===e),"Input is defined"),H=$([B(),J()],"Input is not a string or undefined"),G=$([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=>[H(`"${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}))))}),oe=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let i=o.shift(),r=e;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const s=r[i];r[i]=n(s)})),e),ie=({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,o,i)=>R(e.post(T(l.enchantedLink.signIn,ae.email),{loginId:t,URI:n,loginOptions:o},{token:i})))),signUpOrIn:ue(((t,n,o)=>R(e.post(T(l.enchantedLink.signUpOrIn,ae.email),{loginId:t,URI:n,loginOptions:o})))),signUp:ue(((t,n,o,i)=>R(e.post(T(l.enchantedLink.signUp,ae.email),{loginId:t,URI:n,user:o,loginOptions:i})))),waitForSession:he(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=ie(n);let s;const a=setInterval((async()=>{const n=await e.post(l.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(R(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:pe(((t,n,o,i,r)=>R(e.post(l.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),fe=z(Z("flowId")),ve=z(Z("executionId"),Z("stepId"),Z("interactionId")),me=e=>({start:fe(((t,n,o,i,r,s,a)=>R(e.post(l.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a})))),next:ve(((t,n,o,i,r,s)=>R(e.post(l.flow.next,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),we=Z("loginId"),be=z(Z("token")),ye=z(we),ke=z(we,ee("phone")),Ie=z(we,Y("email")),Se=Object.keys(ae).filter((e=>e!==re.voice)),Ce=e=>({verify:be((t=>R(e.post(l.magicLink.verify,{token:t})))),signIn:Se.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,o,i,r)=>R(e.post(T(l.magicLink.signIn,n),{loginId:t,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:Se.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,o,i,r)=>R(e.post(T(l.magicLink.signUp,n),{loginId:t,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:Se.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,o,i)=>R(e.post(T(l.magicLink.signUpOrIn,n),{loginId:t,URI:o,loginOptions:i}))))})),{}),update:{email:Ie(((t,n,o,i,r)=>R(e.post(l.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(re).filter((e=>e!==re.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ke(((t,o,i,r,s)=>R(e.post(T(l.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:i},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,o,i)=>R(e.post(l.oauth.start,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:i}))),Object.keys(Oe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i)=>R(e.post(l.oauth.start,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i}))})),{})),exchange:xe((t=>R(e.post(l.oauth.exchange,{code:t})))),startNative:(t,n,o)=>R(e.post(l.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>R(e.post(l.oauth.finishNative,{provider:t,stateId:n,user:o,code:i,idToken:r})),getOneTapClientId:t=>R(e.get(l.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,i)=>R(e.post(l.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i})),exchangeOneTapIDToken:(t,n,o,i)=>R(e.post(l.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i}))}),Ue=Z("loginId"),Ae=z(Ue,Z("code")),Ee=z(Ue),Te=z(Ue,ee("phone")),Re=z(Ue,Y("email")),Le=e=>({verify:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ae(((t,o)=>R(e.post(T(l.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ee(((t,o,i)=>R(e.post(T(l.otp.signIn,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ee(((t,o,i)=>R(e.post(T(l.otp.signUp,n),{loginId:t,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ee(((t,o)=>R(e.post(T(l.otp.signUpOrIn,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:Re(((t,n,o,i)=>R(e.post(l.otp.update.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(re).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Te(((t,o,i,r)=>R(e.post(T(l.otp.update.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),_e=z(Z("tenant")),$e=z(Z("code")),Pe=e=>({start:_e(((t,n,o,i,r)=>R(e.post(l.saml.start,o||{},Object.assign({queryParams:Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r})},i&&{token:i}))))),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,o,i)=>R(e.post(l.totp.verify,{loginId:t,code:n,loginOptions:o},{token:i})))),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),Je=z(Fe,Be),He=z(Fe,Z("oldPassword"),Be),Ge=e=>({signUp:Ve(((t,n,o,i)=>R(e.post(l.password.signUp,{loginId:t,password:n,user:o,loginOptions:i})))),signIn:Ve(((t,n,o)=>R(e.post(l.password.signIn,{loginId:t,password:n,loginOptions:o})))),sendReset:Ke(((t,n,o)=>R(e.post(l.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:Je(((t,n,o)=>R(e.post(l.password.update,{loginId:t,newPassword:n},{token:o})))),replace:He(((t,n,o)=>R(e.post(l.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),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")),ot=e=>({signUp:{start:Ze(((t,n,o,i)=>R(e.post(l.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,passkeyOptions:i})))),finish:nt(((t,n)=>R(e.post(l.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:et(((t,n,o,i,r)=>R(e.post(l.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:nt(((t,n)=>R(e.post(l.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ye(((t,n,o)=>R(e.post(l.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:o}))))},update:{start:tt(((t,n,o,i)=>R(e.post(l.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i},{token:o})))),finish:nt(((t,n)=>R(e.post(l.webauthn.update.finish,{transactionId:t,response:n}))))}}),it=X("loginId"),rt=z(it),st=z(Z("pendingRef")),at=e=>({signUpOrIn:rt(((t,n)=>R(e.post(l.notp.signUpOrIn,{loginId:t,loginOptions:n})))),signUp:rt(((t,n,o)=>R(e.post(l.notp.signUp,{loginId:t,user:n,loginOptions:o})))),signIn:rt(((t,n,o)=>R(e.post(l.notp.signIn,{loginId:t,loginOptions:n},{token:o})))),waitForSession:st(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=ie(n);let s;const a=setInterval((async()=>{const n=await e.post(l.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(R(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({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("."),o=n.length;let i=0,r=e===Object(e)?e:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,e)))("projectId",dt))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},refreshCookieName:s,fetch:a})=>{return c=S({baseUrl:n||d,projectId:e,logger:t,hooks:o,cookiePolicy:i,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:ot(c),password:Ge(c),flow:me(c),refresh:ct(((e,t,n)=>{const o={};return n&&(o.externalToken=n),R(c.post(l.refresh,o,{token:e,queryParams:t}))})),selectTenant:z([B("tenantId")],[H('"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([G('"tenants" must a string array or a boolean')],[H('"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(U),getJwtPermissions:lt(A),getJwtRoles:lt(E),getCurrentTenant:lt(L),httpClient:c};var c})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const i=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.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});
|
|
1
|
+
!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{c(o.next(e))}catch(e){r(e)}}function a(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function i(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.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,o=e.split(".")[n];if("string"!=typeof o)throw new r(`Invalid token specified: missing part #${n+1}`);let i;try{i=s(o)}catch(e){throw new r(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new r(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}r.prototype.name="InvalidTokenError";var c={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 l="<region>",d=`https://api.${l}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:o})=>{const i=o.slice(1,-27);t=t.replace(l,i?i+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,o)=>{r=`${r}${0===o?"?":""}${t}=${encodeURIComponent(n[t])}${o===e.length-1?"":"&"}`}))}return r},w=(...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,o])=>(e[n]=o,e)),e),e}),{})),b={"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.41.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:o,logger:i,hooks:r,cookiePolicy:s,fetch:a})=>{const c=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),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 o=await n(...t);return e[o.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()})(o)),o}:n})(i,a),l=async i=>{var a;const l=(null==r?void 0:r.beforeRequest)?r.beforeRequest(i):i,{path:d,body:u,headers:h,queryParams:p,method:g,token:f}=l,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),S={headers:w(y(t,f),k(o),(null==n?void 0:n.baseHeaders)||{},I(v)?b:{},h),method:g,body:v};null!==s&&(S.credentials=s||"include");const C=await c(m({path:d,baseUrl:e,queryParams:p,projectId:t}),S);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(i,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,o]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:o})}),{}),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:o}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:v.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>l({path:e,headers:n,queryParams:o,body:t,method:v.post,token:i}),patch:(e,t,{headers:n,queryParams:o,token:i}={})=>l({path:e,headers:n,queryParams:o,body:t,method:v.patch,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>l({path:e,headers:n,queryParams:o,body:t,method:v.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:v.delete,token:o}),hooks:r,buildUrl:(n,o)=>m({projectId:t,baseUrl:e,path:n,queryParams:o})}};var C=429;function O(e,t,n){var o;let i=x(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[h])===t)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[t]}const r=null==i?void 0:i[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 U(e){let t=x(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function A(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 o=await e,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=r:(i.error=r,o.status===C&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}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 o=e.filter((e=>e(t)));return!(o.length<e.length)&&(n?n.replace("{val}",t):o.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-]+)*$/),W=D(/^\+[1-9]{1}[0-9]{3,14}$/),N=_(M,'"{val}" is not a valid email'),q=_(W,'"{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"),J=_((e=>void 0===e),"Input is defined"),H=$([B(),J()],"Input is not a string or undefined"),G=$([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=>[H(`"${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`),N()],ee=e=>[B(`"${e}" must be a string`),q()],te=z(Z("accessKey")),ne=e=>({exchange:te(((t,n)=>R(e.post(c.accessKey.exchange,{loginOptions:n},{token:t}))))}),oe=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let i=o.shift(),r=e;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const s=r[i];r[i]=n(s)})),e),ie=({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 ce;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(ce||(ce={}));const le=Z("loginId"),de=z(Z("token")),ue=z(le),he=z(Z("pendingRef")),pe=z(le,Y("email")),ge=e=>({verify:de((t=>R(e.post(c.enchantedLink.verify,{token:t})))),signIn:ue(((t,n,o,i)=>R(e.post(T(c.enchantedLink.signIn,ae.email),{loginId:t,URI:n,loginOptions:o},{token:i})))),signUpOrIn:ue(((t,n,o)=>R(e.post(T(c.enchantedLink.signUpOrIn,ae.email),{loginId:t,URI:n,loginOptions:o})))),signUp:ue(((t,n,o,i)=>R(e.post(T(c.enchantedLink.signUp,ae.email),{loginId:t,URI:n,user:o,loginOptions:i})))),waitForSession:he(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=ie(n);let s;const a=setInterval((async()=>{const n=await e.post(c.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(R(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:pe(((t,n,o,i,r)=>R(e.post(c.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),fe=z(Z("flowId")),ve=z(Z("executionId"),Z("stepId"),Z("interactionId")),me=e=>({start:fe(((t,n,o,i,r,s,a)=>R(e.post(c.flow.start,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,componentsVersion:r,flowVersions:s,input:a})))),next:ve(((t,n,o,i,r,s)=>R(e.post(c.flow.next,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),we=Z("loginId"),be=z(Z("token")),ye=z(we),ke=z(we,ee("phone")),Ie=z(we,Y("email")),Se=Object.keys(ae).filter((e=>e!==re.voice)),Ce=e=>({verify:be((t=>R(e.post(c.magicLink.verify,{token:t})))),signIn:Se.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,o,i,r)=>R(e.post(T(c.magicLink.signIn,n),{loginId:t,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:Se.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,o,i,r)=>R(e.post(T(c.magicLink.signUp,n),{loginId:t,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:Se.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ye(((t,o,i)=>R(e.post(T(c.magicLink.signUpOrIn,n),{loginId:t,URI:o,loginOptions:i}))))})),{}),update:{email:Ie(((t,n,o,i,r)=>R(e.post(c.magicLink.update.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(re).filter((e=>e!==re.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ke(((t,o,i,r,s)=>R(e.post(T(c.magicLink.update.phone,n),Object.assign({loginId:t,phone:o,URI:i},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,o,i)=>R(e.post(c.oauth.start,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:i}))),Object.keys(Oe).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i)=>R(e.post(c.oauth.start,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i}))})),{})),exchange:xe((t=>R(e.post(c.oauth.exchange,{code:t})))),startNative:(t,n,o)=>R(e.post(c.oauth.startNative,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>R(e.post(c.oauth.finishNative,{provider:t,stateId:n,user:o,code:i,idToken:r})),getOneTapClientId:t=>R(e.get(c.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,o,i)=>R(e.post(c.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i})),exchangeOneTapIDToken:(t,n,o,i)=>R(e.post(c.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:o,loginOptions:i}))}),Ue=Z("loginId"),Ae=z(Ue,Z("code")),Ee=z(Ue),Te=z(Ue,ee("phone")),Re=z(Ue,Y("email")),Le=e=>({verify:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ae(((t,o)=>R(e.post(T(c.otp.verify,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ee(((t,o,i)=>R(e.post(T(c.otp.signIn,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ee(((t,o,i)=>R(e.post(T(c.otp.signUp,n),{loginId:t,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(ae).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ee(((t,o)=>R(e.post(T(c.otp.signUpOrIn,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:Re(((t,n,o,i)=>R(e.post(c.otp.update.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(re).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Te(((t,o,i,r)=>R(e.post(T(c.otp.update.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),_e=z(Z("tenant")),$e=z(Z("code")),Pe=e=>({start:_e(((t,n,o,i,r)=>R(e.post(c.saml.start,o||{},Object.assign({queryParams:Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r})},i&&{token:i}))))),exchange:$e((t=>R(e.post(c.saml.exchange,{code:t}))))}),De=Z("loginId"),Me=z(De,Z("code")),We=z(De),Ne=z(De),qe=e=>({signUp:We(((t,n)=>R(e.post(c.totp.signUp,{loginId:t,user:n})))),verify:Me(((t,n,o,i)=>R(e.post(c.totp.verify,{loginId:t,code:n,loginOptions:o},{token:i})))),update:Ne(((t,n)=>R(e.post(c.totp.update,{loginId:t},{token:n}))))}),Fe=Z("loginId"),Be=Z("newPassword"),Ve=z(Fe,Z("password")),Ke=z(Fe),Je=z(Fe,Be),He=z(Fe,Z("oldPassword"),Be),Ge=e=>({signUp:Ve(((t,n,o,i)=>R(e.post(c.password.signUp,{loginId:t,password:n,user:o,loginOptions:i})))),signIn:Ve(((t,n,o)=>R(e.post(c.password.signIn,{loginId:t,password:n,loginOptions:o})))),sendReset:Ke(((t,n,o)=>R(e.post(c.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:o})))),update:Je(((t,n,o)=>R(e.post(c.password.update,{loginId:t,newPassword:n},{token:o})))),replace:He(((t,n,o)=>R(e.post(c.password.replace,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>R(e.get(c.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")),ot=e=>({signUp:{start:Ze(((t,n,o,i)=>R(e.post(c.webauthn.signUp.start,{user:{loginId:t,name:o},origin:n,passkeyOptions:i})))),finish:nt(((t,n)=>R(e.post(c.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:et(((t,n,o,i,r)=>R(e.post(c.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:r},{token:i})))),finish:nt(((t,n)=>R(e.post(c.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Ye(((t,n,o)=>R(e.post(c.webauthn.signUpOrIn.start,{loginId:t,origin:n,passkeyOptions:o}))))},update:{start:tt(((t,n,o,i)=>R(e.post(c.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:i},{token:o})))),finish:nt(((t,n)=>R(e.post(c.webauthn.update.finish,{transactionId:t,response:n}))))}}),it=X("loginId"),rt=z(it),st=z(Z("pendingRef")),at=e=>({signUpOrIn:rt(((t,n)=>R(e.post(c.notp.signUpOrIn,{loginId:t,loginOptions:n})))),signUp:rt(((t,n,o)=>R(e.post(c.notp.signUp,{loginId:t,user:n,loginOptions:o})))),signIn:rt(((t,n,o)=>R(e.post(c.notp.signIn,{loginId:t,loginOptions:n},{token:o})))),waitForSession:st(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=ie(n);let s;const a=setInterval((async()=>{const n=await e.post(c.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(R(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),ct=z(Z("token")),lt=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("."),o=n.length;let i=0,r=e===Object(e)?e:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,e)))("projectId",dt))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},refreshCookieName:s,fetch:a})=>{return l=S({baseUrl:n||d,projectId:e,logger:t,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:ne(l),otp:Le(l),magicLink:Ce(l),enchantedLink:ge(l),oauth:je(l),saml:Pe(l),totp:qe(l),notp:at(l),webauthn:ot(l),password:Ge(l),flow:me(l),refresh:lt(((e,t,n)=>{const o={};return n&&(o.externalToken=n),R(l.post(c.refresh,o,{token:e,queryParams:t}))})),selectTenant:z([B("tenantId")],[H('"token" must be string or undefined')])(((e,t)=>R(l.post(c.selectTenant,{tenant:e},{token:t})))),logout:lt((e=>R(l.post(c.logout,{},{token:e})))),logoutAll:lt((e=>R(l.post(c.logoutAll,{},{token:e})))),me:lt((e=>R(l.get(c.me,{token:e})))),myTenants:z([G('"tenants" must a string array or a boolean')],[H('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,R(l.post(c.myTenants,n,{token:t}))})),history:lt((e=>R(l.get(c.history,{token:e})))),isJwtExpired:ct(j),getTenants:ct(U),getJwtPermissions:ct(A),getJwtRoles:ct(E),getCurrentTenant:ct(L),httpClient:l};var l})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const i=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.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 o in n)e[o]=n[o]}return e}var gt=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=pt({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+r}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(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",wt="Failed to load the JS script of the agent",bt="9319";function yt(e,t){var n,o,i,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||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,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=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===bt)n.exclude();else if(s===wt){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!i.has(l)&&(i.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+o()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,o=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var o,i=t[0],r=t[1];return(o=r,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(i)}))}))};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 o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:kt,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(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===bt?new Error(wt):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function Ct(e){return function(e,t,n){var o,i=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),i=t.blockedURI;i!==n.href&&i!==n.protocol.slice(0,-1)&&i!==n.origin||(o=t,a())};i.addEventListener(r,s);var a=function(){return i.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(),o)return n(o);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 o=document.createElement("script"),i=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),t()},o.onerror=function(){i(),n(new Error(wt))},o.async=!0,o.src=e,r.appendChild(o)}))}(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,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(bt);return n}const xt=e=>{try{return a(e).exp}catch(e){return null}},jt=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:xt(n)},Ut=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?xt(o):void 0)},At=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Et=async e=>{if(!(null==e?void 0:e.ok))return{};const n=await(null==e?void 0:e.clone().json());return(e=>{const{access_token:n,id_token:o,refresh_token:i,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:o,refreshJwt:e.refreshJwt||i,sessionExpiration:e.sessionExpiration||Ut(e),cookieExpiration:e.cookieExpiration||jt(e)},s)})((null==n?void 0:n.authInfo)||n||{})},Tt=async e=>{const t=await Et(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Rt="undefined"!=typeof localStorage,Lt=(e,t)=>Rt&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),_t=e=>Rt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),$t=e=>Rt&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Pt=(...e)=>{console.debug(...e)},Dt="3.2.0",Mt="undefined"!=typeof window,Nt=Math.pow(2,31)-1,Wt=`https://descopecdn.com/npm/oidc-client-ts@${Dt}/dist/browser/oidc-client-ts.min.js`,qt=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Dt}/dist/browser/oidc-client-ts.min.js`,Ft="DS",Bt="DSR",Vt="DSI";function Kt(e=""){return _t(`${e}${Bt}`)||""}function Jt(e=""){return gt.get(Ft)||_t(`${e}${Ft}`)||""}function Ht(e=""){return _t(`${e}${Vt}`)||""}function Gt(e=""){$t(`${e}${Bt}`),$t(`${e}${Ft}`),$t(`${e}${Vt}`),gt.remove(Ft)}const zt=Mt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Xt="vsid",Qt="vrid",Zt="fp",Yt=(e=!1)=>{const t=localStorage.getItem(Zt);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},en=async(e,t=zt)=>{try{if(Yt())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=St({apiKey:e,endpoint:[o.toString(),ft],scriptUrlPattern:[r,It]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Xt]:e,[Qt]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(Zt,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},tn=e=>{const t=Yt(!0);return t&&e.body&&(e.body.fpData=t),e},nn="dls_last_user_login_id",on="dls_last_user_display_name",rn=()=>_t(nn),sn=()=>_t(on),an=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=rn(),r=sn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)};function ln(){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 cn(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=fn(n.publicKey.challenge),n.publicKey.user.id=fn(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=fn(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:vn(n.rawId),type:n.type,response:{attestationObject:vn(n.response.attestationObject),clientDataJSON:vn(n.response.clientDataJSON)}});var n}async function dn(e){const t=pn(e);return gn(await navigator.credentials.get(t))}async function un(e,t){const n=pn(e);return n.signal=t.signal,n.mediation="conditional",gn(await navigator.credentials.get(n))}async function hn(e=!1){if(!Mt)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 pn(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=fn(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=fn(e.id)})),n}function gn(e){return JSON.stringify({id:e.id,rawId:vn(e.rawId),type:e.type,response:{authenticatorData:vn(e.response.authenticatorData),clientDataJSON:vn(e.response.clientDataJSON),signature:vn(e.response.signature),userHandle:e.response.userHandle?vn(e.response.userHandle):void 0}})}function fn(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function vn(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var mn,wn=(mn=e=>({async signUp(t,n,o){const i=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await cn(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await dn(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(t,n){var o;const i=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const t=await cn(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await dn(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,t)}},async update(t,n,o){const i=await e.webauthn.update.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await cn(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:cn,get:dn,isSupported:hn,conditional:un}}),(...e)=>{const t=mn(...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 bn="/fedcm/config";async function yn(e,t){var n,o,i;try{const i=await async function(e,t="google",n,o,i){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(i&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==i||i(n),void d()}if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==o||o(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!i.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+i.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,o.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+i.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}catch(e){null===(i=null==t?void 0:t.onFailed)||void 0===i||i.call(t,e)}}var kn=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await hn(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});let In;const Sn=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const i=t();if(i)return n(i);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Sn(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Cn=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await(async(e,t,n)=>{In||(In=(async()=>{try{return require("oidc-client-ts")}catch(e){return Sn([Wt,qt],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await In;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=t,s=(null==n?void 0:n.redirectUri)||window.location.href,a=(null==n?void 0:n.scope)||"openid email roles descope.custom_claims offline_access",l=`${r}_user`;let c=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(c=`${c}/${n.applicationId}`);const d={authority:c,client_id:t,redirect_uri:s,response_type:"code",scope:a,stateStore:new i({store:window.localStorage,prefix:r}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),(null==n?void 0:n.scope)&&(d.scope=n.scope),{client:new o(d),stateUserKey:l}})(e,t,n)),{client:o,stateUserKey:i}},i=async(t="")=>{var n;const{client:i,stateUserKey:r}=await o(),s=await i.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),window.localStorage.setItem(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(e={},t=!1)=>{const{client:n}=await o(),i=await n.createSigninRequest(e),{url:r}=i;return t||(window.location.href=r),{ok:!0,data:i}},finishLogin:i,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await i(e)},refreshToken:async t=>{var n;const{client:i,stateUserKey:r}=await o(),s=(e=>{const t=window.localStorage.getItem(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await i.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:i}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||Ht(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return window.localStorage.removeItem(i),t||window.location.replace(s),r}}},On=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return Mt?(o&&i&&en(o).catch((()=>null)),e(At(r,{beforeRequest:tn}))):e(r)}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);if(!o)return e(i);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;Mt&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&l&&new Date>l&&(Pt("Expiration time passed, refreshing session"),d.refresh(Kt()||c))}));const d=e(At(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:i}=await Et(t);if(401===(null==t?void 0:t.status))Pt("Received 401, canceling all timers"),r();else if(n||i){if(l=((e,t)=>{if(t)return new Date(1e3*t);Pt("Could not extract expiration time from session token, trying to decode the token");try{const t=a(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,i),!l)return void Pt("Could not extract expiration time from session token");c=o;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>Nt&&(Pt(`Timeout is too large (${t}ms), setting it to ${Nt}ms`),t=Nt),t})(l);if(r(),e<=2e4)return void Pt("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Pt(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Pt("Refreshing session due to timer"),d.refresh(Kt()||o)}),e)}}}));return oe(d,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Pt("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.30.0"},t.baseHeaders)}))),(e=>t=>{const n=ln(),o=ln(),i=ln(),r=e(At(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))o.pub(null),i.pub(null),n.pub(null);else{const e=await Tt(t);e&&i.pub(e);const{sessionJwt:r,sessionExpiration:s}=await Et(t);r&&o.pub(r),(s||r)&&n.pub(s||42)}}})),s=oe(r,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const r=await e(...t);return o.pub(null),i.pub(null),n.pub(null),r}));return Object.assign(s,{onSessionTokenChange:o.sub,onUserChange:i.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(r),{getLastUserLoginId:rn,getLastUserDisplayName:sn});const s=e(At(r,{afterRequest:async(e,t)=>{var n;const o=await Tt(t),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((e=>{Lt(nn,e)})(i),(e=>{Lt(on,e)})(r))}}));let a=oe(s,["flow.start"],an);return a=oe(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||($t(nn),$t(on)),o})(i)),Object.assign(a,{getLastUserLoginId:rn,getLastUserDisplayName:sn})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!Mt)return e(s);const a=e(At(s,{beforeRequest:(l=r,e=>Object.assign(e,{token:e.token||Kt(l)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||Gt(r):((e={},t=!1,n="")=>{var o;const{sessionJwt:i,refreshJwt:r}=e;if(r&&Lt(`${n}${Bt}`,r),i)if(t){const n=t.sameSite||"Strict",r=null===(o=t.secure)||void 0===o||o;!function(e,t,n){if(t){const{cookieDomain:o,cookiePath:i,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);gt.set(e,t,{path:i,domain:c?o:void 0,expires:l,sameSite:r,secure:a})}}(Ft,i,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:r}))}else Lt(`${n}${Ft}`,i);e.idToken&&Lt(`${n}${Vt}`,e.idToken)})(await Et(t),i,r)}}));var l;const c=oe(a,["logout","logoutAll","oidc.logout"],(e=>t=>async(...n)=>{const o=await t(...n);return Gt(e),o})(r));return Object.assign(c,{getRefreshToken:()=>Kt(r),getSessionToken:()=>Jt(r),getIdToken:()=>Ht(r)})}))((e=>{const t=ht(e),n=Cn(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async o=>{var i;if(e.oidcConfig)try{return await n.refreshToken(o),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}const r=Jt(),s=Kt();let a="";if(e.getExternalToken)try{a=await(null===(i=e.getExternalToken)||void 0===i?void 0:i.call(e))}catch(e){Pt("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:r?"t":"f",dcr:s?"t":"f"},a)},logout:async o=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:o}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(o)},flow:kn(t),webauthn:wn(t),fedcm:(o=t,i=e.projectId,{onetap:{requestExchangeCode(e){yn(o,e)},requestAuthentication(e){yn(o,e)}},oneTap(e,t,n,i,r){yn(o,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:i,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:o.httpClient.buildUrl(i+bn),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(r.token)},isSupported:()=>Mt&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(i+bn);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var o,i})),xn="undefined"!=typeof localStorage,jn="J151000",Un=xn&&localStorage.getItem("base.content.url")||"",An="base.ui.components.url";xn&&localStorage.getItem(An),xn&&localStorage.getItem(An);const En="descope-login-flow",Tn="code",Rn="data-exclude-field",Ln="data-exclude-next",_n="dls_last_auth",$n="state_id",Pn="saml_idp_state_id",Dn="saml_idp_username",Mn="descope_idp_initiated",Nn="sso_app_id",Wn="third_party_app_id",qn="third_party_app_state_id",Fn="oidc_login_hint",Bn="oidc_prompt",Vn="oidc_error_redirect_uri",Kn="application_scopes",Jn="data-type",Hn="redirect",Gn="poll",zn="webauthnCreate",Xn="webauthnGet",Qn="nativeBridge",Zn="loadForm",Yn="submit",eo="polling",to=["descope-multi-select-combo-box","descope-text-area"],no=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var oo;!function(e){e.backward="backward",e.forward="forward"}(oo||(oo={}));const io=["descope-enriched-text"];function ro(e){return new URLSearchParams(window.location.search).get(e)}function so(e){if(window.history.replaceState&&ro(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 ao(e,t){if(!t)return;const n=+e,o=+t;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?oo.forward:n<o?oo.backward:void 0}const lo=e=>{let[t="",n=""]=(ro(En)||"").split("_");const o=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||o&&o!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:o}};function co(){so(En)}const uo=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),ho=(e,t)=>{const{executionId:n,stepId:o,executionFlowId:i}=lo(e);if(i&&e!==i)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&co();const r=ro("t")||void 0;r&&so("t");const s=ro(Tn)||void 0;s&&so(Tn);const a=ro("err")||void 0;a&&so("err");const{redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u}={redirectAuthCodeChallenge:ro("ra-challenge"),redirectAuthCallbackUrl:ro("ra-callback"),redirectAuthBackupCallbackUri:ro("ra-backup-callback"),redirectAuthInitiator:ro("ra-initiator")},h=ro($n);h&&so($n);const p=ro(Pn);p&&so(Pn);const g=ro(Dn);p&&so(Dn);const f=ro(Mn);f&&so(Mn);const v=ro(Nn);v&&so(Nn);const m=ro(Wn);m&&so(Wn);const w=ro(qn);w&&so(qn);const b=ro(Kn);b&&so(Kn);const y=ro(Fn);y&&so(Fn);const k=ro(Bn);k&&so(Bn);const I=ro(Vn);I&&so(Vn);return{executionId:n,stepId:o,token:r,code:s,exchangeError:a,redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u,ssoQueryParams:{oidcIdpStateId:h,samlIdpStateId:p,samlIdpUsername:g,descopeIdpInitiated:"true"===f,ssoAppId:v,oidcLoginHint:y,oidcPrompt:k,oidcErrorRedirectUri:I,thirdPartyAppId:m,thirdPartyAppStateId:w,applicationScopes:b}}},po=e=>{let t,n;return Object.assign(((...o)=>{return t&&(r=o,(i=t).length===r.length&&i.every(((e,t)=>e===r[t])))||(t=o,n=e(...o)),n;var i,r}),{reset:()=>{t=void 0,n=void 0}})};function go(e,t,n){return new Promise(((o,i)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?o(n):i(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),o(e))})).catch((e=>{r||(clearTimeout(s),i(e))}))}))}const fo=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,thirdPartyAppId:l,thirdPartyAppStateId:c,applicationScopes:d})=>!(!e||t||n||o||i||r||s||a||l||c||d),vo=e=>null==e?void 0:e.submit(),mo=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},wo=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function bo(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 yo=e=>{const t=(n=e.screenState,o=(e,t)=>no.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!o(t,e)))));var n,o;const{screenState:{errorText:i,errorType:r}}=e;return(i||r)&&(t.error={text:i,type:r}),t};var ko,Io,So,Co;function Oo(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Oo(r,s))return!1}else if(r!==s)return!1}return!0}class xo{constructor(e={},{forceUpdate:t=!1}={}){ko.set(this,void 0),Io.set(this,{}),So.set(this,0),Co.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,ko,"f")):e,n=Object.assign(Object.assign({},o(this,ko,"f")),t),r=o(this,ko,"f");i(this,ko,n,"f"),Object.freeze(o(this,ko,"f")),setTimeout((()=>{Object.values(o(this,Io,"f")).forEach((({cb:e,selector:t})=>{const i=t(r),s=t(n);!o(this,Co,"f")&&(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(s)?Oo(i,s):i===s)||e(s,i,((e,t)=>n=>e[n]!==t[n])(s,i))}))}),0)},i(this,ko,e,"f"),i(this,Co,t,"f")}get current(){return Object.assign({},o(this,ko,"f"))}set forceUpdate(e){i(this,Co,e,"f")}subscribe(e,t=e=>e){return i(this,So,o(this,So,"f")+1,"f"),o(this,Io,"f")[o(this,So,"f")]={cb:e,selector:t},o(this,So,"f").toString()}unsubscribe(e){const t=!!o(this,Io,"f")[e];return t&&delete o(this,Io,"f")[e],t}unsubscribeAll(){return i(this,Io,{},"f"),!0}}ko=new WeakMap,Io=new WeakMap,So=new WeakMap,Co=new WeakMap;const jo=["*","#","/","(",")","[","]","_","<",">","`"],Uo=e=>{const t=jo.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")},Ao=["disabled"],Eo=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Rn}])`)).forEach((e=>{e.value=n}))}))},To=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),Ro=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,o)=>n?(e=>"string"!=typeof e?e:e.replace(Uo("\\"),"\\$1"))(To(t,o)):To(t,o))),Lo=(e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(o=e.localName,io.includes(o));var o;e.textContent=Ro(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",Ro(i,t))}))},_o=(e,t,n)=>{e.querySelectorAll(`[${Jn}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},$o=(e,t,n)=>{var o,i;const r=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==e?void 0:e.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},Po=(e,n,o,i,r)=>{var s,a;_o(e,"totp-link",null===(s=null==n?void 0:n.totp)||void 0===s?void 0:s.provisionUrl),_o(e,"notp-link",null===(a=null==n?void 0:n.notp)||void 0===a?void 0:a.redirectUrl),Lo(e,n),((e,n,o)=>{if(!n)return;const{componentsDynamicAttrs:i}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});i&&Object.keys(i).forEach((e=>{const t=i[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 i=n[t];if("string"!=typeof i)try{i=JSON.stringify(i)}catch(e){o.error(`Could not stringify value "${i}" for "${t}"`,e.message),i=""}e.setAttribute(t,i)}))}))}))})(e,o,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=Ro(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])=>{Ao.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i)},Do=po((()=>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)))),o=(()=>{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 go(100,n,o)}catch(e){return console.error("Conditional login check failed",e),!1}})))),Mo=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]},No="dls_ab_testing_id",Wo={"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 qo(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(_n)))}catch(e){}return t}function Fo(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const Bo=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 o=e(n);return o[t]=!0,o}},Vo=["error","warn","info","debug"],Ko=Bo((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,console))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e||console),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return Vo.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),Jo="undefined"!=typeof localStorage,Ho=Jo&&localStorage.getItem("base.content.url")||"",Go=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,zo=Bo((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)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),Xo=Bo((e=>{var t,n;const i=Fo(Ko,zo)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const i=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(i,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})),Qo=e=>t=>{var n,i,r;const s=Fo(Ko,zo,Xo)(t),a=Object.keys(e);return r=class extends s{constructor(...e){super(...e),n.add(this),this.observeAttributes(a,o(this,n,"m",i).bind(this))}async init(){var e;a.forEach((e=>o(this,n,"m",i).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,i=function(t,n){const o=e[t],i="function"==typeof o?o(t,n):o;i&&this.logger.error(i)},r};Qo.missingAttrValidator=Go;const Zo=Bo((e=>{const t=Fo(Qo({"project-id":Go}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),Yo=Bo((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),ei="Trying the next fallback URL...";function ti({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o="https://static.descope.com/pages"}){const i=new URL(o);return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.baseUrl=o,i}const ni=Bo((e=>{var t,n,r,s,a;const l=Fo(Ko,Zo,Yo)(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=o(this,t,"m",s).call(this,e),l=Array.isArray(a)?e=>{if(e!==a.length-1){const{baseUrl:t}=a[e];i(this,r,t,"f")}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:o})=>{const i=Array.isArray(e)?e:[e];for(let e=0;e<i.length;e++){const r=i[e],s=e===i.length-1;try{const i=await fetch(r.toString(),t);if(i.ok)return null==o||o(e),i;const a=`Error fetching URL ${r} [${i.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${ei}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${ei}`)}}})(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=Ho||this.baseStaticUrl;if(t)return ti({projectId:this.projectId,filename:e,baseUrl:t});const s=o(this,n,"f")!==this.baseUrl,a=s&&!!this.baseUrl;s&&(i(this,n,this.baseUrl,"f"),i(this,r,void 0,"f"));const l=ti({projectId:this.projectId,filename:e,baseUrl:o(this,r,"f")});if(!a)return l;return[ti({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),l]},a})),oi=Bo((e=>{var t,n;const i=Fo(Qo({"project-id":Go}))(e);return n=class extends i{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return o(this,t,"f").set(e,n),()=>{o(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(o(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=o(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),ii=Bo((e=>{var t,n,r,s,a;const l=Fo(ni,oi,zo)(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",o(this,t,"m",n).bind(this))}get config(){return o(this,r,"f")||i(this,r,o(this,s,"f").call(this),"f"),o(this,r,"f")}},r=new WeakMap,s=new WeakMap,t=new WeakSet,n=function(){i(this,r,void 0,"f")},a})),ri="load-descope-ui",si="base.ui.components.url",ai=Jo&&localStorage.getItem(si)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",li=Jo&&localStorage.getItem(si)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",ci=Jo&&localStorage.getItem(si)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",di=e=>{const t=document.createElement("script");return t.id=e,t},ui=(e,t)=>e.replace("<version>",t),hi=Bo((e=>{var t,n,r,s,a,l,c,d,u,h,p,g;const f=Fo(Ko,ii)(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 o(this,u,"f")||i(this,u,o(this,t,"m",p).call(this),"f"),o(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=>o(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=o(this,n,"f"),i=o(this,r,"f");e[t]=[],e[i]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[i].push(t)}})},l=async function(e,n,i,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const a=di(i);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=ui(r,await o(this,t,"m",s).call(this))},c=function(e){e.addEventListener("error",(()=>{e[o(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}"`))),o(this,t,"m",l).call(this,[o(this,t,"m",l).bind(this,e[o(this,n,"f")],e[o(this,r,"f")],"load-descope-ui-fallback-script-2",ci),...e[o(this,n,"f")]],e[o(this,r,"f")],"load-descope-ui-fallback-script",li)})),e.addEventListener("load",(()=>{e[o(this,r,"f")].forEach((e=>e()))}))},d=async function(){if(document.querySelector(`script#${ri}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=di(ri);document.body.append(e),o(this,t,"m",a).call(this,e),o(this,t,"m",c).call(this,e),e.src=ui(this.baseCdnUrl||ai,await o(this,t,"m",s).call(this))}return document.getElementById(ri)},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),o(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})),pi="content-root",gi="root",fi=Bo((e=>class extends e{constructor(...e){var t,n,o,i;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${gi}">\n <div id="${pi}"></div>\n </div>\n `;const r=new CSSStyleSheet;r.replaceSync(`\n #${gi}, #${pi} {\n height: 100%;\n }\n #${gi} {\n position: relative;\n height: fit-content;\n }\n `),null!==(t=(i=this.shadowRoot).adoptedStyleSheets)&&void 0!==t||(i.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,r],this.contentRootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(pi),this.rootElement=null===(o=this.shadowRoot)||void 0===o?void 0:o.getElementById(gi)}})),vi=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',mi=Bo((e=>{var t,n,r,s,a,l,c,d,u,h,p,g,f,v;const m=Fo(Qo({theme:vi}),ni,zo,hi,ii,fi,Xo)(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,(()=>{o(this,t,"m",g).call(this),o(this,f,"f").call(this,"os"===this.getAttribute("theme"))})),f.set(this,(e=>{var n,i,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(i=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===i?void 0:i[s])||void 0===r||r.call(i,"change",(()=>o(this,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)),o(this,t,"m",l).call(this),o(this,t,"m",c).call(this),o(this,p,"f").call(this),this.observeAttributes(["theme"],o(this,p,"f")),this.observeAttributes(["style-id"],(()=>{i(this,r,null,"f"),o(this,t,"m",u).call(this),o(this,t,"m",l).call(this),o(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 o(this,r,"f")||(i(this,r,o(this,t,"m",s).call(this),"f"),o(this,r,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,r,"f")},l=async function(){var e,r,s,l;const c=await o(this,t,"a",a);c&&(o(this,n,"f")||(i(this,n,new CSSStyleSheet,"f"),null!==(e=(l=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(l.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,o(this,n,"f")]),o(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 i=Object.assign({},await o(this,t,"a",a));if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==i?void 0:i.light)||void 0===e?void 0:e.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},d=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],i=null==n?void 0:n.cssTemplate,r=o||i;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},u=async function(){const e=await o(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(){o(this,t,"m",u).call(this),o(this,t,"m",h).call(this)},v})),wi=(e,t="")=>Object.keys(e).reduce(((n,o)=>{var i;if("object"==typeof e[o]&&null!==e[o]&&!(null===(i=e[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),wi(e[o],`${t+o}.`));const r="object"==typeof e[o]?e[o]:{value:e[o]},s=Object.assign(Object.assign({},n),{[t+o]:r,[`form.${t}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),bi=Bo((e=>{var t,n,i,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;o(this,t,"m",n).call(this)&&o(this,t,"m",i).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)},i=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 yi,ki,Ii,Si,Ci,Oi,xi,ji,Ui,Ai,Ei,Ti,Ri,Li,_i,$i,Pi,Di,Mi,Ni,Wi,qi,Fi;const Bi=Fo(mi,ni,bi)(HTMLElement);class Vi extends Bi{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(),yi.add(this),Ii.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,yi,"m",Wi).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)}},Si.set(this,new xo),Ci.set(this,new xo),Oi.set(this,{}),this.getComponentsContext=()=>o(this,Oi,"f"),this.nextRequestStatus=new xo({isLoading:!1}),xi.set(this,void 0),ji.set(this,{popstate:o(this,yi,"m",Ri).bind(this),componentsContext:o(this,yi,"m",Di).bind(this)}),Ui.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,Ui,e,"f"),o(this,yi,"m",Ei).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 wi(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(),o=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=o.version)&&void 0!==t||(o.version=0),o}))}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),o(this,Ci,"f").subscribe(o(this,yi,"m",Ni).bind(this)),o(this,Ci,"f").update({isDebug:this.debug}),o(this,yi,"m",Ti).call(this),o(this,yi,"m",Fi).call(this),yield o(this,yi,"m",$i).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");o(this,yi,"m",qi).call(this);const{executionId:r,stepId:s,token:a,code:l,exchangeError:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p,ssoQueryParams:g}=ho(this.flowId,this.loggerWrapper);window.addEventListener("popstate",o(this,ji,"f").popstate),window.addEventListener("components-context",o(this,ji,"f").componentsContext),o(this,Si,"f").subscribe(o(this,yi,"m",_i).bind(this)),o(this,Si,"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)),i(this,Ii,!0,"f")}))}disconnectedCallback(){o(this,Si,"f").unsubscribeAll(),o(this,Ci,"f").unsubscribeAll(),o(this,yi,"m",Mi).call(this),window.removeEventListener("popstate",o(this,ji,"f").popstate),window.removeEventListener("components-context",o(this,ji,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&o(this,Ii,"f")&&t!==n&&ki.observedAttributes.includes(e)){o(this,yi,"m",Ti).call(this);const i=null===t;"nonce"===e&&o(this,yi,"m",Fi).call(this),o(this,Si,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,co()),{[uo(e)]:n,stepId:r,executionId:s}})),o(this,Ci,"f").update({isDebug:this.debug})}}}function Ki(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Ji,Hi,Gi,zi,Xi,Qi,Zi,Yi,er,tr,nr,or,ir,rr,sr,ar,lr,cr,dr,ur,hr,pr,gr,fr,vr,mr,wr,br,yr,kr,Ir,Sr,Cr,Or,xr,jr,Ur,Ar,Er,Tr;ki=Vi,Ii=new WeakMap,Si=new WeakMap,Ci=new WeakMap,Oi=new WeakMap,xi=new WeakMap,ji=new WeakMap,Ui=new WeakMap,yi=new WeakSet,Ai=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 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n "),null!==(e=(t=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(t.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,n]},Ei=function(){o(this,yi,"m",Ai).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Ti=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"];ki.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[uo(t)])throw Error(`${t} cannot be empty`)}))},Ri=function(){const{stepId:e,executionId:t}=lo(this.flowId);o(this,Si,"f").update({stepId:e,executionId:t})},Li=function(e,t){this.sdk=On(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},ki.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:jn,errorDescription:e.toString()}}}}))}))},_i=function(e,t,i){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(i("projectId")||i("baseUrl")){if(!t)return;o(this,yi,"m",Li).call(this,t,n)}o(this,Ui,"f").call(this,e)}))},$i=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield o(this,yi,"m",Pi).call(this))}))},Pi=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(Un||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.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}}))},Di=function(e){i(this,Oi,Object.assign(Object.assign({},o(this,Oi,"f")),e.detail),"f")},Mi=function(){var e;null===(e=o(this,xi,"f"))||void 0===e||e.remove(),i(this,xi,null,"f")},Ni=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,xi,document.createElement("descope-debugger"),"f"),Object.assign(o(this,xi,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return $r})),document.body.appendChild(o(this,xi,"f"))):o(this,yi,"m",Mi).call(this)}))},Wi=function(e,t){var n;e&&this.debug&&(null===(n=o(this,xi,"f"))||void 0===n||n.updateData({title:e,description:t}))},qi=function(){this.rootElement.onkeydown=e=>{var t,n,o;const i=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=to.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==e.key||i||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()}}},Fi=function(){this.getAttribute("nonce")&&(window.DESCOPE_NONCE=this.getAttribute("nonce"))},Vi.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.40.8"}};class Rr extends Vi{static set sdkConfigOverrides(e){Vi.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Vi.sdkConfigOverrides}constructor(){const e=new xo({deferredRedirect:!1});super(e.update.bind(e)),Ji.add(this),this.stepState=new xo({}),Hi.set(this,void 0),Gi.set(this,null),zi.set(this,null),Xi.set(this,{visibilitychange:o(this,Ji,"m",Qi).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var n;const i=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=i;if(!e){e=null===(n=new URL(i.url).searchParams)||void 0===n?void 0:n.get(Tn)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(i.url),t=e.searchParams.get("t"),n=e.searchParams.get(En).split("_").pop();o(this,rr,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else this.nativeComplete(i)},nr.set(this,(e=>{const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?o(this,Ji,"m",or).call(this,t):t()})),ir.set(this,((e,t,r,s,a=!1)=>{if(this.flowState.current.action===Gn){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),c=a?500:2e3;i(this,Hi,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const i=this.sdk.flow.next(e,t,eo,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 go(e,i)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void o(this,ir,"f").call(this,e,t,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===jn)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,ir,"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)),o(this,ir,"f").call(this,e,t,r,s),o(this,sr,"f").call(this,u)}))),c),"f")}})),rr.set(this,(()=>{clearTimeout(o(this,Hi,"f")),i(this,Hi,null,"f")})),sr.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 i=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}`;o(this,Ji,"m",yr).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:i}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||i,(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||o(this,Ji,"m",er).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:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,o):this.loggerWrapper.info(n,o)}));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:w,lastAuth:b,action:y}=e.data;if(y!==Gn&&o(this,rr,"f").call(this),"completed"===m)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&xn&&localStorage.setItem(_n,JSON.stringify(e))}(b),void o(this,Ji,"m",yr).call(this,"success",w);const{executionId:k,stepId:I,stepName:S,screen:C,redirect:O,openInNewTabUrl:x,webauthn:j,error:U,samlIdpResponse:A,nativeResponse:E}=e.data,T=Date.now();y!==Gn?(this.loggerWrapper.info(`Step "${S||`#${I}`}" is ${m}`,"",{screen:C,status:m,stepId:I,stepName:S,action:y,error:U}),(null===(f=C.state)||void 0===f?void 0:f.clientScripts)&&i(this,zi,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==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,nativeResponseType:null==E?void 0:E.type,nativePayload:null==E?void 0:E.payload,reqTimestamp:T})):this.flowState.update({action:y,reqTimestamp:T})})),ar.set(this,po((()=>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)}}))))),mr.set(this,wo(((e,t)=>n(this,void 0,void 0,(function*(){var n,i;if("true"===e.getAttribute("formnovalidate")||o(this,Ji,"m",ur).call(this)){const r=null==e?void 0:e.getAttribute("id");o(this,Ji,"m",pr).call(this,e);const s=yield o(this,Ji,"m",hr).call(this),a=(i=e,Array.from((null==i?void 0:i.attributes)||[]).reduce(((e,t)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return o?Object.assign(e,{[o]:t.value}):e}),{}));if(this.nextRequestStatus.update({isLoading:!0}),o(this,zi,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield o(this,zi,"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 go(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}),o(this,Ji,"m",gr).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:{[Ki(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 o=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var o;const i=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(i){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=i;return null===(o=null==t?void 0:t.start)||void 0===o||o.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 Dr})),t.default;case"fingerprint":return t=yield Promise.resolve().then((function(){return Nr})),t.default;case"fingerprintDescope":return t=yield Promise.resolve().then((function(){return qr})),t.default;case"grecaptcha":return t=yield Promise.resolve().then((function(){return Vr})),t.default;default:throw new Error(`Unknown script id: ${e}`)}}))}(e.id);return new Promise(((n,o)=>{try{const o=r(e.initArgs,{baseUrl:this.baseUrl},t(e,n));if(o){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=o,this.shadowRoot.appendChild(t),this.nextRequestStatus.subscribe((()=>{var t;this.loggerWrapper.debug("Unloading script",e.id),null===(t=o.stop)||void 0===t||t.call(o)}))}}catch(e){o(e)}}))}))))),i=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([o,i])}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)),o(this,Ji,"m",Yi).call(this),window.addEventListener("visibilitychange",o(this,Xi,"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=o(this,Gi,"f"))||void 0===e||e.abort(),i(this,Gi,null,"f"),window.removeEventListener("visibilitychange",o(this,Xi,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const o=bo(e),i=yield this.getTargetLocales();return i.includes(o.locale)?n=`${t}-${o.locale}.html`:i.includes(o.fallback)&&(n=`${t}-${o.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:w,redirectUrl:b,token:y,code:k,exchangeError:I,webauthnTransactionId:S,webauthnOptions:C,redirectAuthCodeChallenge:O,redirectAuthCallbackUrl:x,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:U,locale:A,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(No);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(No,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,J=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 H={};if(!p){const e=[...F.clientScripts||[],...F.sdkScripts||[]];if(F.conditions){let t=[];({startScreenId:D,conditionInteractionId:N,startScreenName:M,clientScripts:t,componentsConfig:H}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:o})=>{var i;if("ELSE"===t)return!0;const r=null===(i=Wo[t])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(e,o))}));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 o=null===(n=Wo[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!o)return{};const i=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==i?void 0:i.screenId,startScreenName:null==i?void 0:i.screenName,conditionInteractionId:null==i?void 0:i.interactionId}})(F.condition,{loginId:q,code:k,token:y,abTestingKey:W})):(M=F.startScreenName,D=F.startScreenId);if(i(this,zi,this.loadSdkScripts(e),"f"),F.fingerprintEnabled&&F.fingerprintKey?yield en(F.fingerprintKey,this.baseUrl):localStorage.removeItem(Zt),!fo(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}),b&&{redirectUrl:b}),{lastAuth:qo(q),abTestingKey:W,locale:bo(A).locale,nativeOptions:J}),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 o(this,sr,"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,Yn,F.version,B.componentsVersion,{token:y,exchangeCode:k,exchangeError:I});return o(this,sr,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===Zn&&["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,o)=>{const i=document.createElement("form");i.method="POST",i.action=e,i.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(i),o(i)})(E,T,R||"",vo)}if(g===Hn&&(s("redirectTo")||s("deferredRedirect")))return m?"android"===U&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(m):void this.loggerWrapper.error("Did not get redirect url");if(g===zn||g===Xn){if(!S||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=o(this,Gi,"f"))||void 0===l||l.abort(),i(this,Gi,null,"f");try{e=g===zn?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,Yn,F.version,B.componentsVersion,{transactionId:S,response:e,failure:t});o(this,sr,"f").call(this,n)}if(g===Qn)return this.nativeComplete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,Yn,F.version,B.componentsVersion,e);o(this,sr,"f").call(this,t)})),void o(this,Ji,"m",yr).call(this,"bridge",{type:L,payload:_});if(s("action")&&o(this,ir,"f").call(this,p,h,F.version,B.componentsVersion),!f&&!D)return void this.loggerWrapper.warn("No screen was found to show");const G=D||f,z=yield this.getHtmlFilenameWithLocale(A,G),{oidcLoginHint:X,oidcPrompt:Q,oidcErrorRedirectUri:Z,samlIdpUsername:Y}=P,ee={direction:ao(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),H),null==v?void 0:v.componentsConfig)}),htmlFilename:`${G}.html`,htmlLocaleFilename:z,screenId:G,stepName:e.stepName||M,samlIdpUsername:Y,oidcLoginHint:X,oidcPrompt:Q,oidcErrorRedirectUri:Z,openInNewTabUrl:w},te=qo(q);fo(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}),b&&{redirectUrl:b}),{locale:bo(A).locale,nativeOptions:J}),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 o(this,sr,"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 o(this,sr,"f").call(this,n),n}))),this.loggerWrapper.debug("Got a screen with id",ee.screenId),yield o(this,Ji,"m",tr).call(this,ee),this.stepState.update(ee)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var i,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 o(this,Ji,"m",cr).call(this,p,c):p.querySelectorAll(`descope-button[${Jn}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(i=d.form)||void 0===i?void 0:i.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),Po(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,i;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,$o(s,"descope-totp-image",a),((e,t)=>{$o(e,"descope-notp-image",t)})(r,null===(i=null==d?void 0:d.notp)||void 0===i?void 0:i.image),((e,t,n,o)=>{n&&Object.keys(n).forEach((i=>{t.querySelector(i)||o.debug(`Skipping css vars for component "${i}}"`,`Got css vars for component ${i} but Could not find it on next page`);const r=customElements.get(i);r?Object.keys(n[i]).forEach((t=>{var s;const a=n[i],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void o.info(`Could not find css variable name for ${t} in ${i}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):o.info(`Could not find component class for ${i}`,"Check if the component is registered")}))})(r,p,d.cssVars,this.loggerWrapper),r.replaceChildren(p);const l=!t.htmlFilename;setTimeout((()=>{o(this,Ji,"m",fr).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)=>{Eo(e,null==t?void 0:t.inputs),Eo(e,null==t?void 0:t.form)})(r,d),o(this,Ji,"m",dr).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)})),o(this,Ji,"m",br).call(this,c);r.querySelector(`[${Jn}="polling"]`)&&c(eo,{}),u&&!t.openInNewTabUrl&&window.open(u,"_blank")}));l?o(this,Ji,"m",or).call(this,v):v()}))}}Hi=new WeakMap,Gi=new WeakMap,zi=new WeakMap,Xi=new WeakMap,nr=new WeakMap,ir=new WeakMap,rr=new WeakMap,sr=new WeakMap,ar=new WeakMap,mr=new WeakMap,Ji=new WeakSet,Qi=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Zi=function({errorText:e,errorType:t}){const n=()=>{var n;let o=e;try{o=(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(`[${Jn}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",o)};this.addEventListener("screen-updated",n,{once:!0}),n()},Yi=function(){var e,n;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,o=t(void 0===n?{}:n,["errorText","errorType"]),i=t(e,["screenState"]);return Object.assign(Object.assign({},i),{screenState:o})})),null===(n=this.stepState)||void 0===n||n.subscribe(o(this,Ji,"m",Zi).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}}))},er=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")}))},tr=function(e){return n(this,void 0,void 0,(function*(){var n;const i=Object.assign(Object.assign({},this.stepState.current),e),{next:r,stepName:s}=i,a=t(i,["next","stepName"]),l=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,s,yo(a),r,this)),c=!this.stepState.current.htmlFilename;if(o(this,nr,"f").call(this,l),l){this.loggerWrapper.debug("Rendering a custom screen"),o(this,Ji,"m",dr).call(this,{isFirstScreen:c,stepName:e.stepName}),this.stepState.unsubscribeAll();const t=this.stepState.subscribe((()=>{this.stepState.unsubscribe(t),o(this,Ji,"m",Yi).call(this)}))}this.stepState.forceUpdate=l}))},or=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},lr=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)}))}},cr=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,Gi,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Do())){const{options:e,transactionId:r}=(yield o(this,ar,"f").call(this))||{};e&&r&&(o(this,Ji,"m",lr).call(this,s),i(this,Gi,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,o(this,Gi,"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)})))}}))},dr=function({isFirstScreen:e,stepName:t}){e&&o(this,Ji,"m",yr).call(this,"ready",{}),o(this,Ji,"m",yr).call(this,"page-updated",{screenName:t}),o(this,Ji,"m",yr).call(this,"screen-updated",{screenName:t})},ur=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,o;"slot"!==t.localName&&(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},hr=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${Rn}])`));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})),{})}))},pr=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},gr=function(e={}){var t,n;const o=mo(e,["externalId","email","phone"]),i=mo(e,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:i});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)}},fr=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>o(this,Ji,"m",vr).call(this,e)))},vr=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),o=`input-${e.id}-${n}`,i=document.createElement("slot");i.setAttribute("name",o),i.setAttribute("slot",n),e.appendChild(i),t.setAttribute("slot",o),this.appendChild(t)}))},wr=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))&&o(this,mr,"f").call(this,t,e)}))}))},br=function(e){this.contentRootElement.querySelectorAll(`descope-button:not([${Ln}]), [data-type="button"]:not([${Ln}]`).forEach((t=>{t.onclick=()=>{o(this,mr,"f").call(this,t,e)}})),o(this,Ji,"m",wr).call(this,e),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Rn}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},yr=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",Rr);const Lr=document.createElement("template");Lr.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 _r extends HTMLElement{constructor(){super(),kr.add(this),Ir.set(this,new xo({messages:[]})),Sr.set(this,void 0),Cr.set(this,void 0),Or.set(this,void 0),xr.set(this,{resize:o(this,kr,"m",Tr).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Lr.content.cloneNode(!0)),i(this,Sr,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Cr,o(this,Sr,"f").querySelector(".content"),"f"),i(this,Or,o(this,Sr,"f").querySelector(".header"),"f"),o(this,kr,"m",jr).call(this)}updateData(e){o(this,Ir,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Mo(e,e.offsetLeft-o,e.offsetTop-i,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})(o(this,Sr,"f"),o(this,Or,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,xr,"f").resize),(e=o(this,Sr,"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},o(this,Sr,"f").onresize=o(this,kr,"m",Er).bind(this),o(this,Ir,"f").subscribe(o(this,kr,"m",Ur).bind(this))}disconnectedCallback(){o(this,Ir,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,xr,"f").resize)}}Ir=new WeakMap,Sr=new WeakMap,Cr=new WeakMap,Or=new WeakMap,xr=new WeakMap,kr=new WeakSet,jr=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],o(this,Sr,"f").style.top="32px",o(this,Sr,"f").style.left=window.innerWidth-300-32+"px"},Ur=function(e){o(this,kr,"m",Ar).call(this,e),o(this,kr,"m",Er).call(this)},Ar=function(e){o(this,Cr,"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("")},Er=function(){o(this,Cr,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,o=t.clientHeight>20;n||o?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Tr=function(){const[e,t]=Mo(o(this,Sr,"f"),Number.parseInt(o(this,Sr,"f").style.left,10),Number.parseInt(o(this,Sr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Sr,"f").style.top=`${t}px`,o(this,Sr,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",_r);var $r=Object.freeze({__proto__:null,default:_r});const Pr='\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 Dr=Object.freeze({__proto__:null,default:(e,t,o)=>n(void 0,void 0,void 0,(function*(){const{siteId:t}=e,n=Pr.replace(/{{SITE_ID}}/g,t),i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("id",t),i.text=n,document.body.appendChild(i),document.addEventListener("ftr:tokenReady",(e=>{o(e.detail)}))}))});const Mr=(e,t,o)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:t,useCloudflareIntegration:n,cloudflareScriptUrl:i,cloudflareEndpointUrl:r}=e;let s=[];s=n&&r?[r,ft]:[ft];let a=[];if(n&&i){const e=new URL(i);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();o(d)}catch(e){console.warn("Could not load fingerprint",e)}}));var Nr=Object.freeze({__proto__:null,default:Mr,loadFingerprint:Mr});const Wr=(e,t,o)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:i,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:i,endpoint:[c.toString(),ft],scriptUrlPattern:[u,It]}),p=yield h,{requestId:g}=yield p.get();o(g)}catch(e){console.warn("Could not load descope fingerprint",e)}}));var qr=Object.freeze({__proto__:null,default:Wr,loadFingerprint:Wr});const Fr=105e3,Br=(e,t,o)=>{let i=(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):(o(e),i=(new Date).getTime(),s=setTimeout((()=>{l(t)}),Fr))})))}))},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()-i>Fr){c();const e=i;return u(),new Promise((t=>{const n=setTimeout((()=>{console.warn("reCAPTCHA token refresh timed out"),t()}),5e3),o=()=>{i!==e?(clearTimeout(n),t()):setTimeout(o,150)};o()}))}return Promise.resolve()}))}};var Vr=Object.freeze({__proto__:null,default:Br,loadGRecaptcha:Br})}();
|
|
3
|
+
function pt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var gt=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=pt({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+r}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(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",wt="Failed to load the JS script of the agent",bt="9319";function yt(e,t){var n,o,i,r,s,a=[],c=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||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,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=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===bt)n.exclude();else if(s===wt){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!i.has(c)&&(i.add(c),r=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=r?r:e.getTime()+o()-Date.now()]}]),l=c[0],d=c[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,o=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var o,i=t[0],r=t[1];return(o=r,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return u(i)}))}))};return u(l).then((function(e){return[e,a]}))}var kt="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",It=kt;function St(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:kt,l=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=l[0],u=l[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)}))}(c,s);return yt(e,Ct)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===bt?new Error(wt):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function Ct(e){return function(e,t,n){var o,i=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),i=t.blockedURI;i!==n.href&&i!==n.protocol.slice(0,-1)&&i!==n.origin||(o=t,a())};i.addEventListener(r,s);var a=function(){return i.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(),o)return n(o);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 o=document.createElement("script"),i=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),t()},o.onerror=function(){i(),n(new Error(wt))},o.async=!0,o.src=e,r.appendChild(o)}))}(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,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(bt);return n}const xt=e=>{try{return a(e).exp}catch(e){return null}},jt=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:xt(n)},Ut=e=>{const{expires_in:t,expires_at:n,access_token:o}=e;return n||(t?Math.floor(Date.now()/1e3)+t:o?xt(o):void 0)},At=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Et=async e=>{if(!(null==e?void 0:e.ok))return{};const n=await(null==e?void 0:e.clone().json());return(e=>{const{access_token:n,id_token:o,refresh_token:i,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:o,refreshJwt:e.refreshJwt||i,sessionExpiration:e.sessionExpiration||Ut(e),cookieExpiration:e.cookieExpiration||jt(e)},s)})((null==n?void 0:n.authInfo)||n||{})},Tt=async e=>{const t=await Et(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Rt="undefined"!=typeof localStorage,Lt=(e,t)=>Rt&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),_t=e=>Rt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),$t=e=>Rt&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Pt=(...e)=>{console.debug(...e)},Dt="3.2.0",Mt="undefined"!=typeof window,Wt=Math.pow(2,31)-1,Nt=`https://descopecdn.com/npm/oidc-client-ts@${Dt}/dist/browser/oidc-client-ts.min.js`,qt=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Dt}/dist/browser/oidc-client-ts.min.js`,Ft="DS",Bt="DSR",Vt="DSI";function Kt(e=""){return _t(`${e}${Bt}`)||""}function Jt(e=""){return gt.get(Ft)||_t(`${e}${Ft}`)||""}function Ht(e=""){return _t(`${e}${Vt}`)||""}function Gt(e=""){$t(`${e}${Bt}`),$t(`${e}${Ft}`),$t(`${e}${Vt}`),gt.remove(Ft)}const zt=Mt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Xt="vsid",Qt="vrid",Zt="fp",Yt=(e=!1)=>{const t=localStorage.getItem(Zt);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},en=async(e,t=zt)=>{try{if(Yt())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=St({apiKey:e,endpoint:[o.toString(),ft],scriptUrlPattern:[r,It]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({[Xt]:e,[Qt]:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(Zt,JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},tn=e=>{const t=Yt(!0);return t&&e.body&&(e.body.fpData=t),e},nn="dls_last_user_login_id",on="dls_last_user_display_name",rn=()=>_t(nn),sn=()=>_t(on),an=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=rn(),r=sn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)};function cn(){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 ln(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=fn(n.publicKey.challenge),n.publicKey.user.id=fn(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=fn(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:vn(n.rawId),type:n.type,response:{attestationObject:vn(n.response.attestationObject),clientDataJSON:vn(n.response.clientDataJSON)}});var n}async function dn(e){const t=pn(e);return gn(await navigator.credentials.get(t))}async function un(e,t){const n=pn(e);return n.signal=t.signal,n.mediation="conditional",gn(await navigator.credentials.get(n))}async function hn(e=!1){if(!Mt)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 pn(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=fn(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=fn(e.id)})),n}function gn(e){return JSON.stringify({id:e.id,rawId:vn(e.rawId),type:e.type,response:{authenticatorData:vn(e.response.authenticatorData),clientDataJSON:vn(e.response.clientDataJSON),signature:vn(e.response.signature),userHandle:e.response.userHandle?vn(e.response.userHandle):void 0}})}function fn(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function vn(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var mn,wn=(mn=e=>({async signUp(t,n,o){const i=await e.webauthn.signUp.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await ln(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,r)},async signIn(t,n){const o=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!o.ok)return o;const i=await dn(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,i)},async signUpOrIn(t,n){var o;const i=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!i.ok)return i;if(null===(o=i.data)||void 0===o?void 0:o.create){const t=await ln(i.data.options);return await e.webauthn.signUp.finish(i.data.transactionId,t)}{const t=await dn(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,t)}},async update(t,n,o){const i=await e.webauthn.update.start(t,window.location.origin,n,o);if(!i.ok)return i;const r=await ln(i.data.options);return await e.webauthn.update.finish(i.data.transactionId,r)},helpers:{create:ln,get:dn,isSupported:hn,conditional:un}}),(...e)=>{const t=mn(...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 bn="/fedcm/config";async function yn(e,t){var n,o,i;try{const i=await async function(e,t="google",n,o,i){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 c=a.data.clientId;return new Promise((e=>{var a,l;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===(l=null==n?void 0:n.use_fedcm_for_prompt)||void 0===l||l,client_id:c,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(i&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==i||i(n),void d()}if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==o||o(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!i.credential)return null;if(null==t?void 0:t.onCodeReceived){const o=await e.oauth.verifyOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!o.ok||!o.data)throw new Error("Failed to verify OneTap client ID for provider "+i.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,o.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(i.provider,i.credential,i.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+i.provider);null===(o=null==t?void 0:t.onAuthenticated)||void 0===o||o.call(t,n.data)}}catch(e){null===(i=null==t?void 0:t.onFailed)||void 0===i||i.call(t,e)}}var kn=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await hn(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});let In;const Sn=(e,t)=>new Promise(((n,o)=>{if(!e.length)return o(new Error("No URLs provided to loadScriptWithFallback"));const i=t();if(i)return n(i);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Sn(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Cn=(e,t,n)=>{const o=async()=>{let o,i;return o&&i||({client:o,stateUserKey:i}=await(async(e,t,n)=>{In||(In=(async()=>{try{return require("oidc-client-ts")}catch(e){return Sn([Nt,qt],(()=>window.oidc))}})());const{OidcClient:o,WebStorageStateStore:i}=await In;if(!o)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=t,s=(null==n?void 0:n.redirectUri)||window.location.href,a=(null==n?void 0:n.scope)||"openid email roles descope.custom_claims offline_access",c=`${r}_user`;let l=e.httpClient.buildUrl(t);(null==n?void 0:n.applicationId)&&(l=`${l}/${n.applicationId}`);const d={authority:l,client_id:t,redirect_uri:s,response_type:"code",scope:a,stateStore:new i({store:window.localStorage,prefix:r}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),(null==n?void 0:n.scope)&&(d.scope=n.scope),{client:new o(d),stateUserKey:c}})(e,t,n)),{client:o,stateUserKey:i}},i=async(t="")=>{var n;const{client:i,stateUserKey:r}=await o(),s=await i.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),window.localStorage.setItem(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(e={},t=!1)=>{const{client:n}=await o(),i=await n.createSigninRequest(e),{url:r}=i;return t||(window.location.href=r),{ok:!0,data:i}},finishLogin:i,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await i(e)},refreshToken:async t=>{var n;const{client:i,stateUserKey:r}=await o(),s=(e=>{const t=window.localStorage.getItem(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const c=await i.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(c)))),c},logout:async(e,t=!1)=>{const{client:n,stateUserKey:i}=await o();e||(e={}),e.id_token_hint=e.id_token_hint||Ht(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return window.localStorage.removeItem(i),t||window.location.replace(s),r}}},On=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return Mt?(o&&i&&en(o).catch((()=>null)),e(At(r,{beforeRequest:tn}))):e(r)}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);if(!o)return e(i);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,l;Mt&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(Pt("Expiration time passed, refreshing session"),d.refresh(Kt()||l))}));const d=e(At(i,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:o,sessionExpiration:i}=await Et(t);if(401===(null==t?void 0:t.status))Pt("Received 401, canceling all timers"),r();else if(n||i){if(c=((e,t)=>{if(t)return new Date(1e3*t);Pt("Could not extract expiration time from session token, trying to decode the token");try{const t=a(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,i),!c)return void Pt("Could not extract expiration time from session token");l=o;const e=(e=>{let t=((n=e)?n.getTime()-(new Date).getTime():0)-2e4;var n;return t>Wt&&(Pt(`Timeout is too large (${t}ms), setting it to ${Wt}ms`),t=Wt),t})(c);if(r(),e<=2e4)return void Pt("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Pt(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Pt("Refreshing session due to timer"),d.refresh(Kt()||o)}),e)}}}));return oe(d,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Pt("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.30.0"},t.baseHeaders)}))),(e=>t=>{const n=cn(),o=cn(),i=cn(),r=e(At(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))o.pub(null),i.pub(null),n.pub(null);else{const e=await Tt(t);e&&i.pub(e);const{sessionJwt:r,sessionExpiration:s}=await Et(t);r&&o.pub(r),(s||r)&&n.pub(s||42)}}})),s=oe(r,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const r=await e(...t);return o.pub(null),i.pub(null),n.pub(null),r}));return Object.assign(s,{onSessionTokenChange:o.sub,onUserChange:i.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(r),{getLastUserLoginId:rn,getLastUserDisplayName:sn});const s=e(At(r,{afterRequest:async(e,t)=>{var n;const o=await Tt(t),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((e=>{Lt(nn,e)})(i),(e=>{Lt(on,e)})(r))}}));let a=oe(s,["flow.start"],an);return a=oe(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||($t(nn),$t(on)),o})(i)),Object.assign(a,{getLastUserLoginId:rn,getLastUserDisplayName:sn})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!Mt)return e(s);const a=e(At(s,{beforeRequest:(c=r,e=>Object.assign(e,{token:e.token||Kt(c)})),afterRequest:async(e,t)=>{const n=/^\/v\d+\/mgmt\//.test(e.path);401===(null==t?void 0:t.status)?n||Gt(r):((e={},t=!1,n="")=>{var o;const{sessionJwt:i,refreshJwt:r}=e;if(r&&Lt(`${n}${Bt}`,r),i)if(t){const n=t.sameSite||"Strict",r=null===(o=t.secure)||void 0===o||o;!function(e,t,n){if(t){const{cookieDomain:o,cookiePath:i,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,c=new Date(1e3*s),l=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);gt.set(e,t,{path:i,domain:l?o:void 0,expires:c,sameSite:r,secure:a})}}(Ft,i,Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:r}))}else Lt(`${n}${Ft}`,i);e.idToken&&Lt(`${n}${Vt}`,e.idToken)})(await Et(t),i,r)}}));var c;const l=oe(a,["logout","logoutAll","oidc.logout"],(e=>t=>async(...n)=>{const o=await t(...n);return Gt(e),o})(r));return Object.assign(l,{getRefreshToken:()=>Kt(r),getSessionToken:()=>Jt(r),getIdToken:()=>Ht(r)})}))((e=>{const t=ht(e),n=Cn(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async o=>{var i;if(e.oidcConfig)try{return await n.refreshToken(o),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}const r=Jt(),s=Kt();let a="";if(e.getExternalToken)try{a=await(null===(i=e.getExternalToken)||void 0===i?void 0:i.call(e))}catch(e){Pt("Error getting external token while refreshing",e)}return t.refresh(o,{dcs:r?"t":"f",dcr:s?"t":"f"},a)},logout:async o=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:o}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(o)},flow:kn(t),webauthn:wn(t),fedcm:(o=t,i=e.projectId,{onetap:{requestExchangeCode(e){yn(o,e)},requestAuthentication(e){yn(o,e)}},oneTap(e,t,n,i,r){yn(o,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:i,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:o.httpClient.buildUrl(i+bn),clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return o.refresh(r.token)},isSupported:()=>Mt&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=o.httpClient.buildUrl(i+bn);try{const o={identity:{context:e||"signin",providers:[{configURL:n,clientId:i}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(o));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var o,i})),xn="undefined"!=typeof localStorage,jn="J151000",Un=xn&&localStorage.getItem("base.content.url")||"",An="base.ui.components.url";xn&&localStorage.getItem(An),xn&&localStorage.getItem(An);const En="descope-login-flow",Tn="code",Rn="data-exclude-field",Ln="data-exclude-next",_n="dls_last_auth",$n="state_id",Pn="saml_idp_state_id",Dn="saml_idp_username",Mn="descope_idp_initiated",Wn="sso_app_id",Nn="third_party_app_id",qn="third_party_app_state_id",Fn="oidc_login_hint",Bn="oidc_prompt",Vn="oidc_error_redirect_uri",Kn="application_scopes",Jn="data-type",Hn="redirect",Gn="poll",zn="webauthnCreate",Xn="webauthnGet",Qn="nativeBridge",Zn="loadForm",Yn="submit",eo="polling",to=["descope-multi-select-combo-box","descope-text-area"],no=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var oo;!function(e){e.backward="backward",e.forward="forward"}(oo||(oo={}));const io=["descope-enriched-text"];function ro(e){return new URLSearchParams(window.location.search).get(e)}function so(e){if(window.history.replaceState&&ro(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 ao(e,t){if(!t)return;const n=+e,o=+t;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?oo.forward:n<o?oo.backward:void 0}const co=e=>{let[t="",n=""]=(ro(En)||"").split("_");const o=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||o&&o!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:o}};function lo(){so(En)}const uo=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),ho=(e,t)=>{const{executionId:n,stepId:o,executionFlowId:i}=co(e);if(i&&e!==i)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&lo();const r=ro("t")||void 0;r&&so("t");const s=ro(Tn)||void 0;s&&so(Tn);const a=ro("err")||void 0;a&&so("err");const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u}={redirectAuthCodeChallenge:ro("ra-challenge"),redirectAuthCallbackUrl:ro("ra-callback"),redirectAuthBackupCallbackUri:ro("ra-backup-callback"),redirectAuthInitiator:ro("ra-initiator")},h=ro($n);h&&so($n);const p=ro(Pn);p&&so(Pn);const g=ro(Dn);p&&so(Dn);const f=ro(Mn);f&&so(Mn);const v=ro(Wn);v&&so(Wn);const m=ro(Nn);m&&so(Nn);const w=ro(qn);w&&so(qn);const b=ro(Kn);b&&so(Kn);const y=ro(Fn);y&&so(Fn);const k=ro(Bn);k&&so(Bn);const I=ro(Vn);I&&so(Vn);return{executionId:n,stepId:o,token:r,code:s,exchangeError:a,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:l,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:w,applicationScopes:b}}},po=e=>{let t,n;return Object.assign(((...o)=>{return t&&(r=o,(i=t).length===r.length&&i.every(((e,t)=>e===r[t])))||(t=o,n=e(...o)),n;var i,r}),{reset:()=>{t=void 0,n=void 0}})};function go(e,t,n){return new Promise(((o,i)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?o(n):i(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),o(e))})).catch((e=>{r||(clearTimeout(s),i(e))}))}))}const fo=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,thirdPartyAppId:c,thirdPartyAppStateId:l,applicationScopes:d})=>!(!e||t||n||o||i||r||s||a||c||l||d),vo=e=>null==e?void 0:e.submit(),mo=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},wo=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function bo(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 yo=e=>{const t=(n=e.screenState,o=(e,t)=>no.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!o(t,e)))));var n,o;const{screenState:{errorText:i,errorType:r}}=e;return(i||r)&&(t.error={text:i,type:r}),t};var ko,Io,So,Co;function Oo(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Oo(r,s))return!1}else if(r!==s)return!1}return!0}class xo{constructor(e={},{forceUpdate:t=!1}={}){ko.set(this,void 0),Io.set(this,{}),So.set(this,0),Co.set(this,!0),this.update=e=>{const t="function"==typeof e?e(o(this,ko,"f")):e,n=Object.assign(Object.assign({},o(this,ko,"f")),t),r=o(this,ko,"f");i(this,ko,n,"f"),Object.freeze(o(this,ko,"f")),setTimeout((()=>{Object.values(o(this,Io,"f")).forEach((({cb:e,selector:t})=>{const i=t(r),s=t(n);!o(this,Co,"f")&&(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(s)?Oo(i,s):i===s)||e(s,i,((e,t)=>n=>e[n]!==t[n])(s,i))}))}),0)},i(this,ko,e,"f"),i(this,Co,t,"f")}get current(){return Object.assign({},o(this,ko,"f"))}set forceUpdate(e){i(this,Co,e,"f")}subscribe(e,t=e=>e){return i(this,So,o(this,So,"f")+1,"f"),o(this,Io,"f")[o(this,So,"f")]={cb:e,selector:t},o(this,So,"f").toString()}unsubscribe(e){const t=!!o(this,Io,"f")[e];return t&&delete o(this,Io,"f")[e],t}unsubscribeAll(){return i(this,Io,{},"f"),!0}}ko=new WeakMap,Io=new WeakMap,So=new WeakMap,Co=new WeakMap;const jo=["*","#","/","(",")","[","]","_","<",">","`"],Uo=e=>{const t=jo.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")},Ao=["disabled"],Eo=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Rn}])`)).forEach((e=>{e.value=n}))}))},To=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),Ro=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,o)=>n?(e=>"string"!=typeof e?e:e.replace(Uo("\\"),"\\$1"))(To(t,o)):To(t,o))),Lo=(e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(o=e.localName,io.includes(o));var o;e.textContent=Ro(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",Ro(i,t))}))},_o=(e,t,n)=>{e.querySelectorAll(`[${Jn}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},$o=(e,t,n)=>{var o,i;const r=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==e?void 0:e.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},Po=(e,n,o,i,r)=>{var s,a;_o(e,"totp-link",null===(s=null==n?void 0:n.totp)||void 0===s?void 0:s.provisionUrl),_o(e,"notp-link",null===(a=null==n?void 0:n.notp)||void 0===a?void 0:a.redirectUrl),Lo(e,n),((e,n,o)=>{if(!n)return;const{componentsDynamicAttrs:i}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});i&&Object.keys(i).forEach((e=>{const t=i[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 i=n[t];if("string"!=typeof i)try{i=JSON.stringify(i)}catch(e){o.error(`Could not stringify value "${i}" for "${t}"`,e.message),i=""}e.setAttribute(t,i)}))}))}))})(e,o,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=Ro(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])=>{Ao.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i)},Do=po((()=>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)))),o=(()=>{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 go(100,n,o)}catch(e){return console.error("Conditional login check failed",e),!1}})))),Mo=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]},Wo="dls_ab_testing_id",No={"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 qo(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(_n)))}catch(e){}return t}function Fo(...e){return t=>e.reduce(((e,t)=>t(e)),t)}const Bo=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 o=e(n);return o[t]=!0,o}},Vo=["error","warn","info","debug"],Ko=Bo((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,console))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e||console),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return Vo.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),Jo="undefined"!=typeof localStorage,Ho=Jo&&localStorage.getItem("base.content.url")||"",Go=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,zo=Bo((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)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),Xo=Bo((e=>{var t,n;const i=Fo(Ko,zo)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const i=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(i,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})),Qo=e=>t=>{var n,i,r;const s=Fo(Ko,zo,Xo)(t),a=Object.keys(e);return r=class extends s{constructor(...e){super(...e),n.add(this),this.observeAttributes(a,o(this,n,"m",i).bind(this))}async init(){var e;a.forEach((e=>o(this,n,"m",i).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,i=function(t,n){const o=e[t],i="function"==typeof o?o(t,n):o;i&&this.logger.error(i)},r};Qo.missingAttrValidator=Go;const Zo=Bo((e=>{const t=Fo(Qo({"project-id":Go}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),Yo=Bo((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),ei="Trying the next fallback URL...";function ti({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o="https://static.descope.com/pages"}){const i=new URL(o);return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.baseUrl=o,i}const ni=Bo((e=>{var t,n,r,s,a;const c=Fo(Ko,Zo,Yo)(e);return a=class extends c{constructor(){super(...arguments),t.add(this),n.set(this,void 0),r.set(this,void 0)}async fetchStaticResource(e,n){const a=o(this,t,"m",s).call(this,e),c=Array.isArray(a)?e=>{if(e!==a.length-1){const{baseUrl:t}=a[e];i(this,r,t,"f")}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:o})=>{const i=Array.isArray(e)?e:[e];for(let e=0;e<i.length;e++){const r=i[e],s=e===i.length-1;try{const i=await fetch(r.toString(),t);if(i.ok)return null==o||o(e),i;const a=`Error fetching URL ${r} [${i.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${ei}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${ei}`)}}})(a,{cache:"default"},{logger:this.logger,onSuccess:c});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=Ho||this.baseStaticUrl;if(t)return ti({projectId:this.projectId,filename:e,baseUrl:t});const s=o(this,n,"f")!==this.baseUrl,a=s&&!!this.baseUrl;s&&(i(this,n,this.baseUrl,"f"),i(this,r,void 0,"f"));const c=ti({projectId:this.projectId,filename:e,baseUrl:o(this,r,"f")});if(!a)return c;return[ti({projectId:this.projectId,filename:e,baseUrl:this.baseUrl+"/pages"}),c]},a})),oi=Bo((e=>{var t,n;const i=Fo(Qo({"project-id":Go}))(e);return n=class extends i{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return o(this,t,"f").set(e,n),()=>{o(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(o(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!o(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=o(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),ii=Bo((e=>{var t,n,r,s,a;const c=Fo(ni,oi,zo)(e);return a=class extends c{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",o(this,t,"m",n).bind(this))}get config(){return o(this,r,"f")||i(this,r,o(this,s,"f").call(this),"f"),o(this,r,"f")}},r=new WeakMap,s=new WeakMap,t=new WeakSet,n=function(){i(this,r,void 0,"f")},a})),ri="load-descope-ui",si="base.ui.components.url",ai=Jo&&localStorage.getItem(si)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",ci=Jo&&localStorage.getItem(si)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",li=Jo&&localStorage.getItem(si)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",di=e=>{const t=document.createElement("script");return t.id=e,t},ui=(e,t)=>e.replace("<version>",t),hi=Bo((e=>{var t,n,r,s,a,c,l,d,u,h,p,g;const f=Fo(Ko,ii)(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 o(this,u,"f")||i(this,u,o(this,t,"m",p).call(this),"f"),o(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=>o(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=o(this,n,"f"),i=o(this,r,"f");e[t]=[],e[i]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[i].push(t)}})},c=async function(e,n,i,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const a=di(i);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=ui(r,await o(this,t,"m",s).call(this))},l=function(e){e.addEventListener("error",(()=>{e[o(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}"`))),o(this,t,"m",c).call(this,[o(this,t,"m",c).bind(this,e[o(this,n,"f")],e[o(this,r,"f")],"load-descope-ui-fallback-script-2",li),...e[o(this,n,"f")]],e[o(this,r,"f")],"load-descope-ui-fallback-script",ci)})),e.addEventListener("load",(()=>{e[o(this,r,"f")].forEach((e=>e()))}))},d=async function(){if(document.querySelector(`script#${ri}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=di(ri);document.body.append(e),o(this,t,"m",a).call(this,e),o(this,t,"m",l).call(this,e),e.src=ui(this.baseCdnUrl||ai,await o(this,t,"m",s).call(this))}return document.getElementById(ri)},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),o(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})),pi="content-root",gi="root",fi=Bo((e=>class extends e{constructor(...e){var t,n,o,i;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${gi}">\n <div id="${pi}"></div>\n </div>\n `;const r=new CSSStyleSheet;r.replaceSync(`\n #${gi}, #${pi} {\n height: 100%;\n }\n #${gi} {\n position: relative;\n height: fit-content;\n }\n `),null!==(t=(i=this.shadowRoot).adoptedStyleSheets)&&void 0!==t||(i.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,r],this.contentRootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(pi),this.rootElement=null===(o=this.shadowRoot)||void 0===o?void 0:o.getElementById(gi)}})),vi=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',mi=Bo((e=>{var t,n,r,s,a,c,l,d,u,h,p,g,f,v;const m=Fo(Qo({theme:vi}),ni,zo,hi,ii,fi,Xo)(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,(()=>{o(this,t,"m",g).call(this),o(this,f,"f").call(this,"os"===this.getAttribute("theme"))})),f.set(this,(e=>{var n,i,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(i=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===i?void 0:i[s])||void 0===r||r.call(i,"change",(()=>o(this,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)),o(this,t,"m",c).call(this),o(this,t,"m",l).call(this),o(this,p,"f").call(this),this.observeAttributes(["theme"],o(this,p,"f")),this.observeAttributes(["style-id"],(()=>{i(this,r,null,"f"),o(this,t,"m",u).call(this),o(this,t,"m",c).call(this),o(this,t,"m",l).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 o(this,r,"f")||(i(this,r,o(this,t,"m",s).call(this),"f"),o(this,r,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,r,"f")},c=async function(){var e,r,s,c;const l=await o(this,t,"a",a);l&&(o(this,n,"f")||(i(this,n,new CSSStyleSheet,"f"),null!==(e=(c=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(c.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,o(this,n,"f")]),o(this,n,"f").replaceSync(((null===(r=null==l?void 0:l.light)||void 0===r?void 0:r.globals)||"")+((null===(s=null==l?void 0:l.dark)||void 0===s?void 0:s.globals)||"")))},l=async function(){var e,n;const i=Object.assign({},await o(this,t,"a",a));if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==i?void 0:i.light)||void 0===e?void 0:e.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},d=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],i=null==n?void 0:n.cssTemplate,r=o||i;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},u=async function(){const e=await o(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(){o(this,t,"m",u).call(this),o(this,t,"m",h).call(this)},v})),wi=(e,t="")=>Object.keys(e).reduce(((n,o)=>{var i;if("object"==typeof e[o]&&null!==e[o]&&!(null===(i=e[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),wi(e[o],`${t+o}.`));const r="object"==typeof e[o]?e[o]:{value:e[o]},s=Object.assign(Object.assign({},n),{[t+o]:r,[`form.${t}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),bi=Bo((e=>{var t,n,i,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;o(this,t,"m",n).call(this)&&o(this,t,"m",i).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)},i=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 yi,ki,Ii,Si,Ci,Oi,xi,ji,Ui,Ai,Ei,Ti,Ri,Li,_i,$i,Pi,Di,Mi,Wi,Ni,qi,Fi;const Bi=Fo(mi,ni,bi)(HTMLElement);class Vi extends Bi{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(),yi.add(this),Ii.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,yi,"m",Ni).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)}},Si.set(this,new xo),Ci.set(this,new xo),Oi.set(this,{}),this.getComponentsContext=()=>o(this,Oi,"f"),this.nextRequestStatus=new xo({isLoading:!1}),xi.set(this,void 0),ji.set(this,{popstate:o(this,yi,"m",Ri).bind(this),componentsContext:o(this,yi,"m",Di).bind(this)}),Ui.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),i(this,Ui,e,"f"),o(this,yi,"m",Ei).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 wi(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(),o=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=o.version)&&void 0!==t||(o.version=0),o}))}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),o(this,Ci,"f").subscribe(o(this,yi,"m",Wi).bind(this)),o(this,Ci,"f").update({isDebug:this.debug}),o(this,yi,"m",Ti).call(this),o(this,yi,"m",Fi).call(this),yield o(this,yi,"m",$i).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");o(this,yi,"m",qi).call(this);const{executionId:r,stepId:s,token:a,code:c,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p,ssoQueryParams:g}=ho(this.flowId,this.loggerWrapper);window.addEventListener("popstate",o(this,ji,"f").popstate),window.addEventListener("components-context",o(this,ji,"f").componentsContext),o(this,Si,"f").subscribe(o(this,yi,"m",_i).bind(this)),o(this,Si,"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:c,exchangeError:l,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthCodeChallenge:h,redirectAuthInitiator:p},g)),i(this,Ii,!0,"f")}))}disconnectedCallback(){o(this,Si,"f").unsubscribeAll(),o(this,Ci,"f").unsubscribeAll(),o(this,yi,"m",Mi).call(this),window.removeEventListener("popstate",o(this,ji,"f").popstate),window.removeEventListener("components-context",o(this,ji,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&o(this,Ii,"f")&&t!==n&&ki.observedAttributes.includes(e)){o(this,yi,"m",Ti).call(this);const i=null===t;"nonce"===e&&o(this,yi,"m",Fi).call(this),o(this,Si,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,lo()),{[uo(e)]:n,stepId:r,executionId:s}})),o(this,Ci,"f").update({isDebug:this.debug})}}}function Ki(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Ji,Hi,Gi,zi,Xi,Qi,Zi,Yi,er,tr,nr,or,ir,rr,sr,ar,cr,lr,dr,ur,hr,pr,gr,fr,vr,mr,wr,br,yr,kr,Ir,Sr,Cr,Or,xr,jr,Ur,Ar,Er,Tr;ki=Vi,Ii=new WeakMap,Si=new WeakMap,Ci=new WeakMap,Oi=new WeakMap,xi=new WeakMap,ji=new WeakMap,Ui=new WeakMap,yi=new WeakSet,Ai=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 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n "),null!==(e=(t=this.shadowRoot).adoptedStyleSheets)&&void 0!==e||(t.adoptedStyleSheets=[]),this.shadowRoot.adoptedStyleSheets=[...this.shadowRoot.adoptedStyleSheets,n]},Ei=function(){o(this,yi,"m",Ai).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Ti=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"];ki.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[uo(t)])throw Error(`${t} cannot be empty`)}))},Ri=function(){const{stepId:e,executionId:t}=co(this.flowId);o(this,Si,"f").update({stepId:e,executionId:t})},Li=function(e,t){this.sdk=On(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},ki.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:jn,errorDescription:e.toString()}}}}))}))},_i=function(e,t,i){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(i("projectId")||i("baseUrl")){if(!t)return;o(this,yi,"m",Li).call(this,t,n)}o(this,Ui,"f").call(this,e)}))},$i=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield o(this,yi,"m",Pi).call(this))}))},Pi=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(Un||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.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}}))},Di=function(e){i(this,Oi,Object.assign(Object.assign({},o(this,Oi,"f")),e.detail),"f")},Mi=function(){var e;null===(e=o(this,xi,"f"))||void 0===e||e.remove(),i(this,xi,null,"f")},Wi=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,xi,document.createElement("descope-debugger"),"f"),Object.assign(o(this,xi,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return $r})),document.body.appendChild(o(this,xi,"f"))):o(this,yi,"m",Mi).call(this)}))},Ni=function(e,t){var n;e&&this.debug&&(null===(n=o(this,xi,"f"))||void 0===n||n.updateData({title:e,description:t}))},qi=function(){this.rootElement.onkeydown=e=>{var t,n,o;const i=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=to.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==e.key||i||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 c=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===c.length)"false"!==c[0].getAttribute("auto-submit")&&c[0].click();else if(0===c.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()}}},Fi=function(){this.getAttribute("nonce")&&(window.DESCOPE_NONCE=this.getAttribute("nonce"))},Vi.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.40.9"}};class Rr extends Vi{static set sdkConfigOverrides(e){Vi.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Vi.sdkConfigOverrides}constructor(){const e=new xo({deferredRedirect:!1});super(e.update.bind(e)),Ji.add(this),this.stepState=new xo({}),Hi.set(this,void 0),Gi.set(this,null),zi.set(this,null),Xi.set(this,{visibilitychange:o(this,Ji,"m",Qi).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var n;const i=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=i;if(!e){e=null===(n=new URL(i.url).searchParams)||void 0===n?void 0:n.get(Tn)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(i.url),t=e.searchParams.get("t"),n=e.searchParams.get(En).split("_").pop();o(this,rr,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else this.nativeComplete(i)},nr.set(this,(e=>{const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?o(this,Ji,"m",or).call(this,t):t()})),ir.set(this,((e,t,r,s,a=!1)=>{if(this.flowState.current.action===Gn){this.logger.debug("polling - Scheduling polling request");const c=Date.now(),l=a?500:2e3;i(this,Hi,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const i=this.sdk.flow.next(e,t,eo,r,s,{}),d=document.hidden&&!a&&Date.now()-c>l+500;let u;d&&this.logger.debug("polling - The polling seems to be throttled");try{const e=d?1e3:6e3;u=yield go(e,i)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void o(this,ir,"f").call(this,e,t,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===jn)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,ir,"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)),o(this,ir,"f").call(this,e,t,r,s),o(this,sr,"f").call(this,u)}))),l),"f")}})),rr.set(this,(()=>{clearTimeout(o(this,Hi,"f")),i(this,Hi,null,"f")})),sr.set(this,(e=>{var t,n,r,s,a,c,l,d,u,h,p,g,f;if(!(null==e?void 0:e.ok)){const i=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,l=`${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}`;o(this,Ji,"m",yr).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:l,errorMessage:i}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||i,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||l);const d=null===(c=null==e?void 0:e.error)||void 0===c?void 0:c.errorCode;return void("E102004"!==d&&"E103205"!==d||!this.isRestartOnError||o(this,Ji,"m",er).call(this))}null===(d=null===(l=e.data)||void 0===l?void 0:l.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,o):this.loggerWrapper.info(n,o)}));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:w,lastAuth:b,action:y,openInNewTabUrl:k}=e.data;if(y!==Gn&&o(this,rr,"f").call(this),"completed"===m)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&xn&&localStorage.setItem(_n,JSON.stringify(e))}(b),void o(this,Ji,"m",yr).call(this,"success",w);k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:C,screen:O,redirect:x,webauthn:j,error:U,samlIdpResponse:A,nativeResponse:E}=e.data,T=Date.now();y!==Gn?(this.loggerWrapper.info(`Step "${C||`#${S}`}" is ${m}`,"",{screen:O,status:m,stepId:S,stepName:C,action:y,error:U}),(null===(f=O.state)||void 0===f?void 0:f.clientScripts)&&i(this,zi,this.loadSdkScripts(O.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:C,executionId:I,action:y,redirectTo:null==x?void 0:x.url,screenId:null==O?void 0:O.id,screenState:null==O?void 0:O.state,webauthnTransactionId:null==j?void 0:j.transactionId,webauthnOptions:null==j?void 0:j.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,nativeResponseType:null==E?void 0:E.type,nativePayload:null==E?void 0:E.payload,reqTimestamp:T})):this.flowState.update({action:y,reqTimestamp:T})})),ar.set(this,po((()=>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)}}))))),mr.set(this,wo(((e,t)=>n(this,void 0,void 0,(function*(){var n,i;if("true"===e.getAttribute("formnovalidate")||o(this,Ji,"m",ur).call(this)){const r=null==e?void 0:e.getAttribute("id");o(this,Ji,"m",pr).call(this,e);const s=yield o(this,Ji,"m",hr).call(this),a=(i=e,Array.from((null==i?void 0:i.attributes)||[]).reduce(((e,t)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return o?Object.assign(e,{[o]:t.value}):e}),{}));if(this.nextRequestStatus.update({isLoading:!0}),o(this,zi,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield o(this,zi,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const c=this.loadSdkScriptsModules();if(c.length>0){const e=c.filter((e=>"function"==typeof e.refresh)).map((e=>e.refresh()));e.length>0&&(yield go(5e3,Promise.all(e),null))}const l=this.getComponentsContext(),d=Object.assign(Object.assign(Object.assign(Object.assign({},l),a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(r,d),this.nextRequestStatus.update({isLoading:!1}),o(this,Ji,"m",gr).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:{[Ki(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 o=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var o;const i=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(i){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=i;return null===(o=null==t?void 0:t.start)||void 0===o||o.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 Dr})),t.default;case"fingerprint":return t=yield Promise.resolve().then((function(){return Wr})),t.default;case"fingerprintDescope":return t=yield Promise.resolve().then((function(){return qr})),t.default;case"grecaptcha":return t=yield Promise.resolve().then((function(){return Vr})),t.default;default:throw new Error(`Unknown script id: ${e}`)}}))}(e.id);return new Promise(((n,o)=>{try{const o=r(e.initArgs,{baseUrl:this.baseUrl},t(e,n));if(o){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=o,this.shadowRoot.appendChild(t),this.nextRequestStatus.subscribe((()=>{var t;this.loggerWrapper.debug("Unloading script",e.id),null===(t=o.stop)||void 0===t||t.call(o)}))}}catch(e){o(e)}}))}))))),i=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([o,i])}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)),o(this,Ji,"m",Yi).call(this),window.addEventListener("visibilitychange",o(this,Xi,"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=o(this,Gi,"f"))||void 0===e||e.abort(),i(this,Gi,null,"f"),window.removeEventListener("visibilitychange",o(this,Xi,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const o=bo(e),i=yield this.getTargetLocales();return i.includes(o.locale)?n=`${t}-${o.locale}.html`:i.includes(o.fallback)&&(n=`${t}-${o.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,c;const{projectId:l,flowId:d,tenant:u,stepId:h,executionId:p,action:g,screenId:f,screenState:v,redirectTo:m,redirectUrl:w,token:b,code:y,exchangeError:k,webauthnTransactionId:I,webauthnOptions:S,redirectAuthCodeChallenge:C,redirectAuthCallbackUrl:O,redirectAuthBackupCallbackUri:x,redirectAuthInitiator:j,locale:U,samlIdpResponseUrl:A,samlIdpResponseSamlResponse:E,samlIdpResponseRelayState:T,nativeResponseType:R,nativePayload:L,reqTimestamp:_}=e,$=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload","reqTimestamp"]);let P,D,M;const W=(()=>{const e=localStorage.getItem(Wo);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(Wo,e.toString()),e}return Number(e)})(),N=this.sdk.getLastUserLoginId(),q=yield this.getFlowConfig(),F=yield this.getProjectConfig(),B=Object.entries(F.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),V=O&&C?{callbackUrl:O,codeChallenge:C,backupCallbackUri:x}:void 0,K=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;let J={};if(!p){const e=[...q.clientScripts||[],...q.sdkScripts||[]];if(q.conditions){let t=[];({startScreenId:P,conditionInteractionId:M,startScreenName:D,clientScripts:t,componentsConfig:J}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:o})=>{var i;if("ELSE"===t)return!0;const r=null===(i=No[t])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(e,o))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:N,code:y,token:b,abTestingKey:W},q.conditions)),e.push(...t||[])}else q.condition?({startScreenId:P,conditionInteractionId:M}=((e,t)=>{var n;const o=null===(n=No[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!o)return{};const i=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==i?void 0:i.screenId,startScreenName:null==i?void 0:i.screenName,conditionInteractionId:null==i?void 0:i.interactionId}})(q.condition,{loginId:N,code:y,token:b,abTestingKey:W})):(D=q.startScreenName,P=q.startScreenId);if(i(this,zi,this.loadSdkScripts(e),"f"),q.fingerprintEnabled&&q.fingerprintKey?yield en(q.fingerprintKey,this.baseUrl):localStorage.removeItem(Zt),!fo(P,$)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:V},$),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:qo(N),abTestingKey:W,locale:bo(U).locale,nativeOptions:K}),M,"",F.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),y?{exchangeCode:y,idpInitiated:!0}:{}),$.descopeIdpInitiated&&{idpInitiated:!0}),b?{token:b}:{}),$.oidcLoginHint?{externalId:$.oidcLoginHint}:{}));return o(this,sr,"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")&&b||s("code")&&y||s("exchangeError")&&k)){const e=yield this.sdk.flow.next(p,h,Yn,q.version,F.componentsVersion,{token:b,exchangeCode:y,exchangeError:k});return o(this,sr,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===Zn&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!A||!E)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=e,i.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(i),o(i)})(A,E,T||"",vo)}if(g===Hn&&(s("redirectTo")||s("deferredRedirect")))return m?"android"===j&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(m):void this.loggerWrapper.error("Did not get redirect url");if(g===zn||g===Xn){if(!I||!S)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(c=o(this,Gi,"f"))||void 0===c||c.abort(),i(this,Gi,null,"f");try{e=g===zn?yield this.sdk.webauthn.helpers.create(S):yield this.sdk.webauthn.helpers.get(S)}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,Yn,q.version,F.componentsVersion,{transactionId:I,response:e,failure:t});o(this,sr,"f").call(this,n)}if(g===Qn)return this.nativeComplete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,Yn,q.version,F.componentsVersion,e);o(this,sr,"f").call(this,t)})),void o(this,Ji,"m",yr).call(this,"bridge",{type:R,payload:L});if(s("action")&&o(this,ir,"f").call(this,p,h,q.version,F.componentsVersion),!f&&!P)return void this.loggerWrapper.warn("No screen was found to show");const H=P||f,G=yield this.getHtmlFilenameWithLocale(U,H),{oidcLoginHint:z,oidcPrompt:X,oidcErrorRedirectUri:Q,samlIdpUsername:Z}=$,Y={direction:ao(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:N,name:this.sdk.getLastUserDisplayName()||N},componentsConfig:Object.assign(Object.assign(Object.assign({},q.componentsConfig),J),null==v?void 0:v.componentsConfig)}),htmlFilename:`${H}.html`,htmlLocaleFilename:G,screenId:H,stepName:e.stepName||D,samlIdpUsername:Z,oidcLoginHint:z,oidcPrompt:X,oidcErrorRedirectUri:Q},ee=qo(N);fo(P,$)?Y.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:V},$),{lastAuth:ee,preview:this.preview,abTestingKey:W,client:this.client}),w&&{redirectUrl:w}),{locale:bo(U).locale,nativeOptions:K}),M,e,F.componentsVersion,B,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),t),y&&{exchangeCode:y,idpInitiated:!0}),$.descopeIdpInitiated&&{idpInitiated:!0}),b&&{token:b}));return o(this,sr,"f").call(this,n),n})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(Y.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=yield this.sdk.flow.next(p,h,e,q.version,F.componentsVersion,t);return o(this,sr,"f").call(this,n),n}))),this.loggerWrapper.debug("Got a screen with id",Y.screenId),yield o(this,Ji,"m",tr).call(this,Y),this.stepState.update(Y)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var i,r;const{htmlFilename:s,htmlLocaleFilename:a,direction:c,next:l,screenState:d}=e;this.loggerWrapper.debug("Rendering a flow screen");const u=document.createElement("template");u.innerHTML=yield this.getPageContent(s,a);const h=u.content.cloneNode(!0),p=this.loadDescopeUiComponents(u);this.sdk.webauthn.helpers.isSupported()?yield o(this,Ji,"m",lr).call(this,h,l):h.querySelectorAll(`descope-button[${Jn}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(i=d.form)||void 0===i?void 0:i.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),Po(h,d,d.componentsConfig,this.formConfig,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(h,g);const f=()=>n(this,void 0,void 0,(function*(){var n,i;yield p;const r=this.contentRootElement;var s,a;s=r,a=null===(n=null==d?void 0:d.totp)||void 0===n?void 0:n.image,$o(s,"descope-totp-image",a),((e,t)=>{$o(e,"descope-notp-image",t)})(r,null===(i=null==d?void 0:d.notp)||void 0===i?void 0:i.image),((e,t,n,o)=>{n&&Object.keys(n).forEach((i=>{t.querySelector(i)||o.debug(`Skipping css vars for component "${i}}"`,`Got css vars for component ${i} but Could not find it on next page`);const r=customElements.get(i);r?Object.keys(n[i]).forEach((t=>{var s;const a=n[i],c=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!c)return void o.info(`Could not find css variable name for ${t} in ${i}`,"Check if the css variable is defined in the component");const l=a[t];e.style.setProperty(c,l)})):o.info(`Could not find component class for ${i}`,"Check if the component is registered")}))})(r,h,d.cssVars,this.loggerWrapper),r.replaceChildren(h);const c=!t.htmlFilename;setTimeout((()=>{o(this,Ji,"m",fr).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)=>{Eo(e,null==t?void 0:t.inputs),Eo(e,null==t?void 0:t.form)})(r,d),o(this,Ji,"m",dr).call(this,{isFirstScreen:c,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,c)})),o(this,Ji,"m",br).call(this,l);r.querySelector(`[${Jn}="polling"]`)&&l(eo,{})}));c?o(this,Ji,"m",or).call(this,f):f()}))}}Hi=new WeakMap,Gi=new WeakMap,zi=new WeakMap,Xi=new WeakMap,nr=new WeakMap,ir=new WeakMap,rr=new WeakMap,sr=new WeakMap,ar=new WeakMap,mr=new WeakMap,Ji=new WeakSet,Qi=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Zi=function({errorText:e,errorType:t}){const n=()=>{var n;let o=e;try{o=(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(`[${Jn}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",o)};this.addEventListener("screen-updated",n,{once:!0}),n()},Yi=function(){var e,n;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,o=t(void 0===n?{}:n,["errorText","errorType"]),i=t(e,["screenState"]);return Object.assign(Object.assign({},i),{screenState:o})})),null===(n=this.stepState)||void 0===n||n.subscribe(o(this,Ji,"m",Zi).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}}))},er=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")}))},tr=function(e){return n(this,void 0,void 0,(function*(){var n;const i=Object.assign(Object.assign({},this.stepState.current),e),{next:r,stepName:s}=i,a=t(i,["next","stepName"]),c=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,s,yo(a),r,this)),l=!this.stepState.current.htmlFilename;if(o(this,nr,"f").call(this,c),c){this.loggerWrapper.debug("Rendering a custom screen"),o(this,Ji,"m",dr).call(this,{isFirstScreen:l,stepName:e.stepName}),this.stepState.unsubscribeAll();const t=this.stepState.subscribe((()=>{this.stepState.unsubscribe(t),o(this,Ji,"m",Yi).call(this)}))}this.stepState.forceUpdate=c}))},or=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},cr=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)}))}},lr=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,Gi,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Do())){const{options:e,transactionId:r}=(yield o(this,ar,"f").call(this))||{};e&&r&&(o(this,Ji,"m",cr).call(this,s),i(this,Gi,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,o(this,Gi,"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)})))}}))},dr=function({isFirstScreen:e,stepName:t}){e&&o(this,Ji,"m",yr).call(this,"ready",{}),o(this,Ji,"m",yr).call(this,"page-updated",{screenName:t}),o(this,Ji,"m",yr).call(this,"screen-updated",{screenName:t})},ur=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,o;"slot"!==t.localName&&(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},hr=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${Rn}])`));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})),{})}))},pr=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},gr=function(e={}){var t,n;const o=mo(e,["externalId","email","phone"]),i=mo(e,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:i});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)}},fr=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>o(this,Ji,"m",vr).call(this,e)))},vr=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),o=`input-${e.id}-${n}`,i=document.createElement("slot");i.setAttribute("name",o),i.setAttribute("slot",n),e.appendChild(i),t.setAttribute("slot",o),this.appendChild(t)}))},wr=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))&&o(this,mr,"f").call(this,t,e)}))}))},br=function(e){this.contentRootElement.querySelectorAll(`descope-button:not([${Ln}]), [data-type="button"]:not([${Ln}]`).forEach((t=>{t.onclick=()=>{o(this,mr,"f").call(this,t,e)}})),o(this,Ji,"m",wr).call(this,e),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Rn}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},yr=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",Rr);const Lr=document.createElement("template");Lr.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 _r extends HTMLElement{constructor(){super(),kr.add(this),Ir.set(this,new xo({messages:[]})),Sr.set(this,void 0),Cr.set(this,void 0),Or.set(this,void 0),xr.set(this,{resize:o(this,kr,"m",Tr).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Lr.content.cloneNode(!0)),i(this,Sr,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Cr,o(this,Sr,"f").querySelector(".content"),"f"),i(this,Or,o(this,Sr,"f").querySelector(".header"),"f"),o(this,kr,"m",jr).call(this)}updateData(e){o(this,Ir,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,c]=Mo(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(o(this,Sr,"f"),o(this,Or,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,xr,"f").resize),(e=o(this,Sr,"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},o(this,Sr,"f").onresize=o(this,kr,"m",Er).bind(this),o(this,Ir,"f").subscribe(o(this,kr,"m",Ur).bind(this))}disconnectedCallback(){o(this,Ir,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,xr,"f").resize)}}Ir=new WeakMap,Sr=new WeakMap,Cr=new WeakMap,Or=new WeakMap,xr=new WeakMap,kr=new WeakSet,jr=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],o(this,Sr,"f").style.top="32px",o(this,Sr,"f").style.left=window.innerWidth-300-32+"px"},Ur=function(e){o(this,kr,"m",Ar).call(this,e),o(this,kr,"m",Er).call(this)},Ar=function(e){o(this,Cr,"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("")},Er=function(){o(this,Cr,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,o=t.clientHeight>20;n||o?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Tr=function(){const[e,t]=Mo(o(this,Sr,"f"),Number.parseInt(o(this,Sr,"f").style.left,10),Number.parseInt(o(this,Sr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Sr,"f").style.top=`${t}px`,o(this,Sr,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",_r);var $r=Object.freeze({__proto__:null,default:_r});const Pr='\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 Dr=Object.freeze({__proto__:null,default:(e,t,o)=>n(void 0,void 0,void 0,(function*(){const{siteId:t}=e,n=Pr.replace(/{{SITE_ID}}/g,t),i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("id",t),i.text=n,document.body.appendChild(i),document.addEventListener("ftr:tokenReady",(e=>{o(e.detail)}))}))});const Mr=(e,t,o)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:t,useCloudflareIntegration:n,cloudflareScriptUrl:i,cloudflareEndpointUrl:r}=e;let s=[];s=n&&r?[r,ft]:[ft];let a=[];if(n&&i){const e=new URL(i);a=[`${e.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,It]}else a=[It];const c=St({apiKey:t,endpoint:s,scriptUrlPattern:a}),l=yield c,{requestId:d}=yield l.get();o(d)}catch(e){console.warn("Could not load fingerprint",e)}}));var Wr=Object.freeze({__proto__:null,default:Mr,loadFingerprint:Mr});const Nr=(e,t,o)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:i,cloudflareEndpointPath:r,cloudflareScriptPath:s}=e,{baseUrl:a}=t;let c;c=n?`https://${n}`:a||"https://api.descope.com";const l=new URL(c);l.pathname=r;const d=new URL(c);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=St({apiKey:i,endpoint:[l.toString(),ft],scriptUrlPattern:[u,It]}),p=yield h,{requestId:g}=yield p.get();o(g)}catch(e){console.warn("Could not load descope fingerprint",e)}}));var qr=Object.freeze({__proto__:null,default:Nr,loadFingerprint:Nr});const Fr=105e3,Br=(e,t,o)=>{let i=(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 c=(t,n)=>{t.ready((()=>{e.siteKey&&(null==t||t.execute(a,{action:"load"}).then(((e,n)=>{n?console.warn("could not execute recaptcha",n):(o(e),i=(new Date).getTime(),s=setTimeout((()=>{c(t)}),Fr))})))}))},l=()=>{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&&c(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"}),c(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:l,start:u,refresh:()=>n(void 0,void 0,void 0,(function*(){if(Date.now()-i>Fr){l();const e=i;return u(),new Promise((t=>{const n=setTimeout((()=>{console.warn("reCAPTCHA token refresh timed out"),t()}),5e3),o=()=>{i!==e?(clearTimeout(n),t()):setTimeout(o,150)};o()}))}return Promise.resolve()}))}};var Vr=Object.freeze({__proto__:null,default:Br,loadGRecaptcha:Br})}();
|