@descope/web-component 4.7.5 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/constants/index.js +1 -1
- package/dist/cjs/constants/index.js.map +1 -1
- 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/esm/constants/index.js +1 -1
- package/dist/esm/constants/index.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/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function n(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((i=i.apply(e,t||[])).next())}))}function i(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function o(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),(e=>"string"==typeof e?e:"boolean"==typeof e?String(e):(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(n))})),t},l=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const i=e(n);return i[t]=!0,i}};var c,d,u,h;function p(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!p(r,s))return!1}else if(r!==s)return!1}return!0}let g=class{constructor(e={},{forceUpdate:t=!1}={}){c.set(this,void 0),d.set(this,{}),u.set(this,0),h.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,c,"f")):e,n=Object.assign(Object.assign({},i(this,c,"f")),t);if(i(this,h,"f")||!p(i(this,c,"f"),n)){const e=i(this,c,"f");o(this,c,n,"f"),Object.freeze(i(this,c,"f")),setTimeout((()=>{Object.values(i(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,c,e,"f"),o(this,h,t,"f")}get current(){return Object.assign({},i(this,c,"f"))}subscribe(e){return o(this,u,i(this,u,"f")+1,"f"),i(this,d,"f")[i(this,u,"f")]=e,i(this,u,"f").toString()}unsubscribe(e){const t=!!i(this,d,"f")[e];return t&&delete i(this,d,"f")[e],t}unsubscribeAll(){return o(this,d,{},"f"),!0}};c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap;const f=e=>String(null!=e?e:"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");function v(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:""}}class m extends Error{}function b(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 w(e,t){if("string"!=typeof e)throw new m("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,i=e.split(".")[n];if("string"!=typeof i)throw new m(`Invalid token specified: missing part #${n+1}`);let o;try{o=b(i)}catch(e){throw new m(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new m(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}m.prototype.name="InvalidTokenError";var y={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",phone:"/v1/auth/enchantedlink/update/phone"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},sso:{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"},emailVerification:{start:"/v1/auth/emailverification/start"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-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",event:"/v1/flow/event"}};const k="<region>",I=`https://api.${k}descope.com`,S=6e5,C=()=>{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},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},O=[503,520,521,522,524,530],x=[100,5e3,5e3],A=e=>new Promise((t=>setTimeout(t,e))),E=e=>async function(...t){let n=await e(...t);const i=!!(null==(o=t[1])?void 0:o.disableRetry);var o;let r=0;for(;!i&&O.includes(n.status)&&r<x.length;)await A(x[r]),n=await e(...t),r++;r>0&&(n.retries=r);const s=await n.text();return n.text=()=>Promise.resolve(s),n.json=()=>Promise.resolve(JSON.parse(s)),n.clone=()=>n,n},j=(e,t)=>{const 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 function(...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=>C().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await E(n)(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return C().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(i)),i}:E(n)};let R;const U=()=>{if(R)return R;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 R=`${t}-${n}`,R};var T;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(T||(T={}));const $=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(k,o?o+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,i)=>{r=`${r}${0===i?"?":""}${t}=${encodeURIComponent(n[t])}${i===e.length-1?"":"&"}`}))}return r},L=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),P={"Content-Type":"application/json"},W=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},M=(e,t)=>{const n={"x-descope-sdk-session-id":U(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.78.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},N=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var _=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||I,c=j(o,a),d=async e=>{var o;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:g,token:f,keepalive:v,disableRetry:m}=a,b=(e=>void 0===e?void 0:JSON.stringify(e))(u),w=Object.assign(Object.assign({headers:L(W(t,f),M(t,i),(null==n?void 0:n.baseHeaders)||{},N(b)?P:{},h),method:g,body:b},v?{keepalive:!0}:{}),m?{disableRetry:!0}:{});null!==s&&(w.credentials=s||"include");const y=await c($({path:d,baseUrl:l,queryParams:p,projectId:t}),w);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==y?void 0:y.clone()),null==r?void 0:r.transformResponse){const e=await y.json(),t=(k=(null===(o=y.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function i(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function o(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,l=!1;for(;i();)if(","===e.charAt(n)){for(s=n,n+=1,i(),a=n;n<e.length&&o();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(r,e.length))}return t}(k).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.create(null),{json:()=>Promise.resolve(e),cookies:t}),i=new Proxy(y,{get:(e,t)=>{if(t in n)return n[t];const i=e[t];return"function"==typeof i?i.bind(e):i},set:(e,t,i)=>(n[t]=i,!0),has:(e,t)=>t in n||t in e});return n.clone=()=>i,r.transformResponse(i)}var k;return y};return{get:(e,{headers:t,queryParams:n,token:i,keepalive:o,disableRetry:r}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:T.get,token:i,keepalive:o,disableRetry:r}),post:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:i,body:t,method:T.post,token:o,keepalive:r,disableRetry:s}),patch:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:i,body:t,method:T.patch,token:o,keepalive:r,disableRetry:s}),put:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:i,body:t,method:T.put,token:o,keepalive:r,disableRetry:s}),delete:(e,{headers:t,queryParams:n,token:i,keepalive:o,disableRetry:r}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:T.delete,token:i,keepalive:o,disableRetry:r}),hooks:r,buildUrl:(e,n)=>$({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},D=429;function q(e,t,n){var i;let o=F(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o.dct)===t)return(null==o?void 0:o[n])||[];o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[t]}const r=null==o?void 0:o[n];return Array.isArray(r)?r:[]}function F(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return w(e)}function V(e){const{exp:t}=F(e);return(new Date).getTime()/1e3>t}function J(e){let t=F(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function H(e,t){return q(e,t,"permissions")}function K(e,t){return q(e,t,"roles")}const z=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function B(e,t){var n,i;const o=await e,r={code:o.status,ok:o.ok,response:o},s=await o.clone().json();if(o.ok)r.data=s;else{r.error=s,o.status===D&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0});const e=null===(i=o.headers)||void 0===i?void 0:i.get("cf-ray");e&&r.error&&Object.assign(r.error,{traceId:e})}return r}function G(e){var t;return(null===(t=F(e))||void 0===t?void 0:t.dct)||""}const Z=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),X=(e,t)=>(n=t)=>t=>{const i=e.filter((e=>e(t)));return!(i.length<e.length)&&(n?n.replace("{val}",t):i.join(" OR "))},Q=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Y=e=>t=>e.test(t),ee=Y(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),te=Y(/^\+[1-9]{1}[0-9]{3,14}$/),ne=Z(ee,'"{val}" is not a valid email'),ie=Z(te,'"{val}" is not a valid phone number'),oe=Z((e=>e.length>=1),"Minimum length is 1");const re=Z((e=>"string"==typeof e),"Input is not a string"),se=Z((e=>Array.isArray(e)),"Input is not an array"),ae=Z((e=>"boolean"==typeof e),"Input is not a boolean"),le=Z((e=>void 0===e),"Input is defined"),ce=X([re(),le()],"Input is not a string or undefined"),de=X([se(),ae()],"Input is not an array or boolean"),ue=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Q(...e).validate(n[t]))),t(...n)),he=e=>[re(`"${e}" must be a string`)],pe=e=>[ce(`"${e}" must be string or undefined`)],ge=e=>[re(`"${e}" must be a string`),oe(`"${e}" must not be empty`)],fe=e=>[re(`"${e}" must be a string`),ne()],ve=e=>[re(`"${e}" must be a string`),ie()],me=ue(ge("accessKey")),be=e=>({exchange:me(((t,n)=>B(e.post(y.accessKey.exchange,{loginOptions:n},{token:t}))))}),we=(e,t,n)=>(t.forEach((t=>{const i=t.split(".");let o=i.shift(),r=e;for(;i.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof r[o])throw Error(`"${t}" is not a function`);const s=r[o];r[o]=n(s)})),e),ye=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||S,S)});var ke,Ie;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(ke||(ke={})),function(e){e.email="email"}(Ie||(Ie={}));const Se=Object.assign(Object.assign({},ke),Ie);var Ce;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Ce||(Ce={}));const Oe=ge("loginId"),xe=ue(ge("token")),Ae=ue(Oe),Ee=ue(ge("pendingRef")),je=ue(Oe,ve("phone")),Re=ue(Oe,fe("email")),Ue=e=>{const n=n=>(i,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return B(e.post(z(y.enchantedLink.signIn,n),{loginId:i,URI:o,loginOptions:l,providerId:a},{token:s}))},i=n=>(i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(z(y.enchantedLink.signUpOrIn,n),{loginId:i,URI:o,loginOptions:a,providerId:s}))},o=n=>(i,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return B(e.post(z(y.enchantedLink.signUp,n),{loginId:i,URI:o,user:r,loginOptions:l,providerId:a}))};return{verify:xe((t=>B(e.post(y.enchantedLink.verify,{token:t})))),signIn:Ae(n(Se.email)),signInWithPhone:Ae(n(ke.sms)),signUpOrIn:Ae(i(Se.email)),signUpOrInWithPhone:Ae(i(ke.sms)),signUp:Ae(o(Se.email)),signUpWithPhone:Ae(o(ke.sms)),waitForSession:Ee(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=ye(n);let s;const a=setInterval((async()=>{const n=await e.post(y.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(B(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Re(((t,n,i,o,r)=>B(e.post(y.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:{sms:je(((t,n,i,o,r)=>B(e.post(z(y.enchantedLink.update.phone,ke.sms),Object.assign({loginId:t,phone:n,URI:i},r),{token:o}))))}}}},Te=ue(ge("flowId")),$e=ue(ge("executionId"),ge("stepId"),ge("interactionId")),Le=ue(ge("executionId")),Pe=e=>({start:Te(((t,n,i,o,r,s,a,l=!1)=>B(e.post(y.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:$e(((t,n,i,o,r,s,a=!1,l)=>B(e.post(y.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s,isCustomScreen:a,options:l})))),event:Le(((t,n,i)=>B(e.post(y.flow.event,{executionId:t,events:n},{keepalive:i,disableRetry:!0}))))}),We=ge("loginId"),Me=ue(ge("token")),Ne=ue(We);ue(ge("pendingRef"));const _e=ue(We,ve("phone")),De=ue(We,fe("email")),qe=Object.keys(Se).filter((e=>e!==ke.voice&&e!==ke.im)),Fe=e=>({verify:Me((t=>B(e.post(y.magicLink.verify,{token:t})))),signIn:qe.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Ne(((n,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return B(e.post(z(y.magicLink.signIn,i),{loginId:n,URI:o,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:qe.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Ne(((n,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return B(e.post(z(y.magicLink.signUp,i),{loginId:n,URI:o,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:qe.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Ne(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(z(y.magicLink.signUpOrIn,i),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:De(((t,n,i,o,r)=>B(e.post(y.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(ke).filter((e=>e!==ke.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:_e(((t,i,o,r,s)=>B(e.post(z(y.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var Ve;!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"}(Ve||(Ve={}));const Je=ue(ge("code")),He=e=>({start:Object.assign(((t,n,i,o,r)=>B(e.post(y.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(Ve).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>B(e.post(y.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:Je((t=>B(e.post(y.oauth.exchange,{code:t})))),startNative:(t,n,i)=>B(e.post(y.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>B(e.post(y.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>B(e.get(y.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>B(e.post(y.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>B(e.post(y.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),Ke=ge("appId"),ze=ue(Ke),Be=e=>({connect:ze(((t,n,i)=>{const o=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,B(e.post(y.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:n},{token:i}))}))}),Ge=ge("loginId"),Ze=ue(Ge,ge("code")),Xe=ue(Ge),Qe=ue(Ge,ve("phone")),Ye=ue(Ge,fe("email")),et=e=>({verify:Object.keys(Se).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ze(((t,i)=>B(e.post(z(y.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(Se).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Xe(((n,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return B(e.post(z(y.otp.signIn,i),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Se).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Xe(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(z(y.otp.signUp,i),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Se).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Xe(((n,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return B(e.post(z(y.otp.signUpOrIn,i),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:Ye(((t,n,i,o)=>B(e.post(y.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(ke).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,i,o,r)=>B(e.post(z(y.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),tt=ue(ge("tenant")),nt=ue(ge("code")),it=e=>({start:tt(((t,n,i,o,r,s,a,l)=>B(e.post(y.sso.start,i||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},o&&{token:o}))))),exchange:nt((t=>B(e.post(y.sso.exchange,{code:t}))))}),ot=ge("loginId"),rt=ue(ot,ge("code")),st=ue(ot),at=ue(ot),lt=e=>({signUp:st(((t,n)=>B(e.post(y.totp.signUp,{loginId:t,user:n})))),verify:rt(((t,n,i,o)=>B(e.post(y.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:at(((t,n)=>B(e.post(y.totp.update,{loginId:t},{token:n}))))}),ct=e=>({start:()=>B(e.post(y.emailVerification.start,{}))}),dt=ge("loginId"),ut=ge("newPassword"),ht=ue(dt,ge("password")),pt=ue(dt),gt=ue(dt,ut),ft=ue(dt,ge("oldPassword"),ut),vt=e=>({signUp:ht(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(y.password.signUp,{loginId:n,password:i,user:o,loginOptions:a,providerId:s}))})),signIn:ht(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return B(e.post(y.password.signIn,{loginId:n,password:i,loginOptions:s,providerId:r}))})),sendReset:pt(((t,n,i)=>B(e.post(y.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:gt(((t,n,i)=>B(e.post(y.password.update,{loginId:t,newPassword:n},{token:i})))),replace:ft(((t,n,i)=>B(e.post(y.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>B(e.get(y.password.policy))}),mt=he("loginId"),bt=ge("loginId"),wt=he("origin"),yt=ue(bt,wt,ge("name")),kt=ue(bt,wt),It=ue(mt,wt),St=ue(bt,wt,pe("token")),Ct=ue(ge("transactionId"),ge("response")),Ot=e=>({signUp:{start:yt(((t,n,i,o,r)=>B(e.post(y.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,loginOptions:r,passkeyOptions:o})))),finish:Ct(((t,n)=>B(e.post(y.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:It(((t,n,i,o,r)=>B(e.post(y.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:Ct(((t,n)=>B(e.post(y.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:kt(((t,n,i,o)=>B(e.post(y.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i}))))},update:{start:St(((t,n,i,o,r)=>B(e.post(y.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o,mfa:r},{token:i})))),finish:Ct(((t,n)=>B(e.post(y.webauthn.update.finish,{transactionId:t,response:n}))))}}),xt=he("loginId"),At=ue(xt),Et=ue(ge("pendingRef")),jt=e=>({signUpOrIn:At(((n,i={})=>{var{providerId:o}=i,r=t(i,["providerId"]);return B(e.post(y.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:o}))})),signUp:At(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return B(e.post(y.notp.signUp,{loginId:n,user:i,providerId:r,loginOptions:s}))})),signIn:At(((n,i={},o)=>{var{providerId:r}=i,s=t(i,["providerId"]);return B(e.post(y.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:o}))})),waitForSession:Et(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=ye(n);let s;const a=setInterval((async()=>{const n=await e.post(y.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(B(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Rt=ue(ge("token")),Ut=ue(pe("token"));var Tt,$t=ue([(Tt=ge("projectId"),Z(((e,t)=>n=>Q(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=n.length;let o=0,r=e===Object(e)?e:void 0;for(;null!=r&&o<i;)r=r[n[o++]];return o&&o===i&&void 0!==r?r:void 0})(n,e)))("projectId",Tt))())])((e=>{const{projectId:t,logger:n,baseUrl:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=_({baseUrl:i,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:be(l),otp:et(l),magicLink:Fe(l),enchantedLink:Ue(l),oauth:He(l),outbound:Be(l),sso:it(l),saml:it(l),totp:lt(l),notp:jt(l),webauthn:Ot(l),password:vt(l),flow:Pe(l),emailVerification:ct(l),refresh:Ut(((e,t,n,i)=>{const o={};n&&(o.externalToken=n);const r=i?y.tryRefresh:y.refresh;return B(l.post(r,o,{token:e,queryParams:t}))})),selectTenant:ue([re("tenantId")],[ce('"token" must be string or undefined')])(((e,t)=>B(l.post(y.selectTenant,{tenant:e},{token:t})))),logout:Ut((e=>B(l.post(y.logout,{},{token:e})))),logoutAll:Ut((e=>B(l.post(y.logoutAll,{},{token:e})))),me:Ut((e=>B(l.get(y.me,{token:e})))),myTenants:ue([de('"tenants" must a string array or a boolean')],[ce('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,B(l.post(y.myTenants,n,{token:t}))})),history:Ut((e=>B(l.get(y.history,{token:e})))),isJwtExpired:Rt(V),getTenants:Rt(J),getJwtPermissions:Rt(H),getJwtRoles:Rt(K),getCurrentTenant:Rt(G),httpClient:l};var l})),Lt=Object.assign($t,{DeliveryMethods:Se});
|
|
2
|
-
/*! js-cookie v3.0.8 | MIT */function Pt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)"__proto__"!==i&&(e[i]=n[i])}return e}var Wt=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=Pt({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(a in i||(i[a]=t.read(s,a)),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",Pt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Pt({},this.attributes,t))},withConverter:function(t){return e(Pt({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var Mt={default:"endpoint"},Nt="Blocked by CSP",_t="The endpoint parameter is not a valid URL",Dt="Failed to load the JS script of the agent",qt="9319";function Ft(e,t){var n,i,o,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===Nt||s===_t)n.exclude(),r=0;else if(s===qt)n.exclude();else if(s===Dt){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var Vt="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Jt=Vt;function Ht(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:Vt,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return Ft(e,Kt)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===qt?new Error(Dt):e}(e)})).then((function(t){var n=t[0],i=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function Kt(e){return function(e,t,n){var i,o=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(_t);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(Dt))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(Nt)})).then(zt)}function zt(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==i?void 0:i.configurable)?delete e[t]:i&&!i.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(qt);return n}const Bt="3.2.0",Gt="undefined"!=typeof window,Zt=Math.pow(2,31)-1,Xt=2e4,Qt=`https://descopecdn.com/npm/oidc-client-ts@${Bt}/dist/browser/oidc-client-ts.min.js`,Yt=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Bt}/dist/browser/oidc-client-ts.min.js`,en=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let tn;const nn=e=>{try{return w(e).exp}catch(e){return null}},on=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:nn(n)},rn=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?nn(i):void 0)},sn=e=>{const{access_token:n,id_token:i,refresh_token:o,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:i,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||rn(e),cookieExpiration:e.cookieExpiration||on(e)},s)},an=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[i])||[]).concat((null==t?void 0:t[i])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},ln=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return sn(n)},cn=()=>Gt&&!!window.descopeBridge,dn=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return en.includes(n)},un=void 0!==tn||Gt&&void 0!==window.localStorage,hn=(e,t)=>{var n,i;return null===(i=null===(n=tn||Gt&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},pn=e=>{var t,n;return null===(n=null===(t=tn||Gt&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},gn=e=>{var t,n;return null===(n=null===(t=tn||Gt&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},fn=e=>{var t,n,i,o,r;return null!==(r=null!==(n=null===(t=null==tn?void 0:tn.key)||void 0===t?void 0:t.call(tn,e))&&void 0!==n?n:Gt&&(null===(o=null===(i=window.localStorage)||void 0===i?void 0:i.key)||void 0===o?void 0:o.call(i,e)))&&void 0!==r?r:null},vn=e=>{var t,n;return Gt&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},mn=e=>{var t,n;try{Gt&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},bn=(...e)=>{console.debug(...e)},wn=(...e)=>{console.warn(...e)},yn=e=>e?e.getTime()-(new Date).getTime():0,kn="DS",In="DSR",Sn="DSI",Cn="DSRCN";function On(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=xn(i);Wt.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:r,secure:a})}}function xn(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const An=e=>(null==e?void 0:e.cookieName)||kn,En=e=>(null==e?void 0:e.cookieName)||In;function jn(e="",t){return Wt.get(En(t))||pn(`${e}${In}`)||""}function Rn(e="",t){return Wt.get(An(t))||pn(`${e}${kn}`)||""}function Un(e=""){return pn(`${e}${Sn}`)||""}function Tn(e="",t,n,i){gn(`${e}${In}`),gn(`${e}${kn}`),gn(`${e}${Sn}`),gn(`${e}${Cn}`);const o=An(t);Wt.remove(o,null==i?void 0:i.session);const r=En(n);Wt.remove(r,null==i?void 0:i.refresh)}const $n=(e,t,n)=>i=>{const o=Object.assign(i,{token:i.token||jn(e,t)});if(!n){const t=function(e=""){return pn(`${e}${Cn}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return pn(`${e}DTD`)||""}(e);r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":r}));const s=function(e=""){return pn(`${e}DKD`)||""}(e);return s&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-known-device-token":s})),o},Ln=Gt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Pn="vsid",Wn="vrid",Mn="fp",Nn=(e=!1)=>{const t=pn(Mn);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},_n=async(e,t=Ln)=>{try{if(Nn())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=Ht({apiKey:e,endpoint:[i.toString(),Mt],scriptUrlPattern:[r,Jt]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Pn]:e,[Wn]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};hn(Mn,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Dn=e=>{const t=Nn(!0);return t&&e.body&&(e.body.fpData=t),e},qn="descopeFlowNonce",Fn="X-Descope-Flow-Nonce",Vn="/v1/flow/start",Jn="/v1/flow/next",Hn=(e,t=qn)=>`${t}${e}`,Kn=(e,t=qn)=>{try{const n=Hn(e,t),i=pn(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(zn(e,t),null):{value:o.value,seq:o.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},zn=(e,t=qn)=>{try{const n=Hn(e,t);gn(n)}catch(e){console.error("Error removing flow nonce:",e)}},Bn=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Gn=e=>{var t;return e.path===Jn&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Bn(e.body.executionId):null},Zn="dls_last_user_login_id",Xn="dls_last_user_display_name",Qn=e=>hn(Zn,e),Yn=()=>pn(Zn),ei=()=>pn(Xn),ti=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=Yn(),r=ei();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)},ni="DSLI",ii=e=>async(...t)=>{const n=await e(...t);return mn(ni),n};function oi(){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 ri(e,t){const n=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=hi(n.publicKey.challenge),n.publicKey.user.id=hi(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=hi(e.id)})),n}(e);t&&(n.signal=t.signal);try{return i=await navigator.credentials.create(n),JSON.stringify({id:i.id,rawId:pi(i.rawId),type:i.type,response:{attestationObject:pi(i.response.attestationObject),clientDataJSON:pi(i.response.clientDataJSON)}})}catch(e){throw await li(e,n,!0)}var i}async function si(e,t){const n=di(e);t&&(n.signal=t.signal);try{return ui(await navigator.credentials.get(n))}catch(e){throw await li(e,n,!1)}}async function ai(e,t){const n=di(e);n.signal=t.signal,n.mediation="conditional";try{return ui(await navigator.credentials.get(n))}catch(e){throw await li(e,n,!1)}}async function li(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var i,o;const r=null==e?void 0:e.name;if("AbortError"===r&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===r&&n)return"authenticator_already_registered";if("NotSupportedError"===r)return"no_supported_algorithm";if("ConstraintError"===r)return"authenticator_constraints_unsupported";if("SecurityError"===r){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await ci())return"webauthn_unsupported";const s="platform"===(null===(o=null===(i=null==t?void 0:t.publicKey)||void 0===i?void 0:i.authenticatorSelection)||void 0===o?void 0:o.authenticatorAttachment);return n&&s&&!await ci(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function ci(e=!1){var t,n;if(!Gt)return Promise.resolve(!1);if(cn()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const i=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return i&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():i}function di(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=hi(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=hi(e.id)})),n}function ui(e){return JSON.stringify({id:e.id,rawId:pi(e.rawId),type:e.type,response:{authenticatorData:pi(e.response.authenticatorData),clientDataJSON:pi(e.response.clientDataJSON),signature:pi(e.response.signature),userHandle:e.response.userHandle?pi(e.response.userHandle):void 0}})}function hi(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function pi(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var gi,fi=(gi=e=>({async signUp(t,n,i){const o=await e.webauthn.signUp.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await ri(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,n){const i=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await si(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(t,n){var i;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const t=await ri(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await si(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,i){const o=await e.webauthn.update.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await ri(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:ri,get:si,isSupported:ci,conditional:ai}}),(...e)=>{const t=gi(...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 vi="/fedcm/config";async function mi(e,t){var n;try{await bi(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function bi(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=(()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)})(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void d()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var wi=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await ci(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});let yi;const ki=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{ki(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Ii=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{yi||(yi=(async()=>{try{return require("oidc-client-ts")}catch(e){return ki([Qt,Yt],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await yi;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new i(d),stateUserKey:l}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),hn(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(t={},n=!1)=>{var o;const{client:r}=await i(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:r}=await i(),s=(e=>{const t=pn(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||Un(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return gn(o),t||window.location.replace(s),r}}},Si=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,tn=n,e(t)}),(e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return Gt?(i&&o&&_n(i).catch((()=>null)),e(an(r,{beforeRequest:Dn}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.54.7"},t.baseHeaders)}))),(e=>t=>{const n=oi(),i=oi(),o=oi(),r=oi(),s=e(an(t,{afterRequest:async(e,t)=>{if(dn(e,t))bn("Session invalidated, notifying subscribers with empty values"),i.pub(null),o.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await ln(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await ln(t);s&&i.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=we(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:i.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var i;const{enableFlowNonce:o=!0,nonceStoragePrefix:r=qn}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!o)return e(s);((e=qn)=>{try{if(!un)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(i=null!==(t=null==tn?void 0:tn.length)&&void 0!==t?t:Gt&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==i?i:0);o++){const t=fn(o);if(t&&t.startsWith(e)){const n=pn(t);if(n)try{JSON.parse(n).expiry<Date.now()&&gn(t)}catch(e){gn(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,i})(r);const a=e(an(s,{afterRequest:async(e,t)=>{var n;if(e.path!==Vn&&e.path!==Jn)return;const{nonce:i,seq:o,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(Fn),i=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const i=Number(n);return Number.isSafeInteger(i)?i:void 0})(n);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=Gn(e)),{nonce:n,seq:i,executionId:Bn(o)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!i||!s)return;const a=e.path===Vn,l=null===(n=Kn(s,r))||void 0===n?void 0:n.seq;!a&&void 0!==o&&void 0!==l&&o<=l||((e,t,n,i=qn,o)=>{try{const r=Hn(e,i),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:o};hn(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,i,a,r,null!=o?o:a?void 0:l)},beforeRequest:e=>{if(e.path===Jn){const t=Gn(e);if(t){const n=((e,t=qn)=>{var n,i;return null!==(i=null===(n=Kn(e,t))||void 0===n?void 0:n.value)&&void 0!==i?i:null})(t,r);n&&(e.headers=e.headers||{},e.headers[Fn]=n)}}return e}}));if(null===(i=a.flow)||void 0===i?void 0:i.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const i=e;let o;e=new Promise((e=>{o=e})),await i;try{return await t(...n)}finally{o()}}}return a}),(e=>t=>{const n=e(an(t,{afterRequest:async(e,t)=>{if(dn(e,t))return void mn(ni);const n=await ln(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,i;try{Gt&&(null===(i=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i||i.call(n,e,t))}catch(e){}})(ni,String(n.sessionExpiration))}}));return we(n,["logout","logoutAll","oidc.logout"],ii)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);const r=!!i,s="object"==typeof i&&(null==i?void 0:i.customActivityTracking);if(!r||cn())return Object.assign(e(o),{markUserActive:()=>{wn("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;s&&(bn("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Gt&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(bn("Expiration time passed, refreshing session"),f())}));const g=e(an(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o,nextRefreshSeconds:r}=await ln(t);if(dn(e,t))bn("Session invalidated, canceling all timers"),a(),c=void 0;else if(n||o){if(c=((e,t)=>{if(t)return new Date(1e3*t);bn("Could not extract expiration time from session token, trying to decode the token");try{const t=w(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!c)return void bn("Could not extract expiration time from session token");d=i,h=r>0;let e=((e,t)=>{let n;return t>0?(n=1e3*t,bn(`Using provided nextRefreshSeconds: ${t}s`)):n=yn(e)-Xt,n>Zt&&(bn(`Timeout is too large (${n}ms), setting it to ${Zt}ms`),n=Zt),n})(c,r);a(),e<=Xt&&(e=Math.max(yn(c),Xt));const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});bn(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Gt&&"hidden"===document.visibilityState)bn("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return bn("Skipping refresh due to timer - user is idle"),void(p=!0);bn("Refreshing session due to timer"),f()}}),e)}}})),f=()=>g.refresh(jn()||d).catch((e=>{wn("Automatic session refresh failed",e)}));return Object.assign(we(g,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return bn("Clearing all timers"),a(),n})),{markUserActive:u?()=>{bn("markUserActive() called"),h||bn("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(bn("User became active after skipped refresh, triggering refresh"),p=!1,a(),f())}:()=>{wn("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:Yn,getLastUserDisplayName:ei});const s=e(an(r,{afterRequest:async(e,t)=>{var n;const{userInfo:i,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=sn((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],s=null==i?void 0:i.name;r?(Qn(r),(e=>{hn(Xn,e)})(s)):(null==o?void 0:o.loginId)&&Qn(o.loginId)}}));let a=we(s,["flow.start"],ti);return a=we(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(gn(Zn),gn(Xn)),i})(o)),Object.assign(a,{getLastUserLoginId:Yn,getLastUserDisplayName:ei})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!i||!Gt)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(an(Object.assign({refreshCookieName:a},l),{beforeRequest:$n(s,r,a),afterRequest:async(e,t)=>{if(dn(e,t))bn("Session invalidated, clearing persisted tokens"),Tn(s,o,r,c);else{const e=await ln(t);e.cookieName?hn(`${s||""}${Cn}`,e.cookieName):e.refreshJwt&&gn(`${s||""}${Cn}`);const n=((e={},t=!1,n="",i=!1)=>{var o,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d,knownDeviceJwt:u}=e;let h;if(c)if(i){gn(`${n}${In}`);const t=i.sameSite||"Strict",s=null===(o=i.secure)||void 0===o||o,a=null!==(r=i.domain)&&void 0!==r?r:e.cookieDomain,l=En(i);s&&"https:"!==window.location.protocol&&wn("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});On(l,c,d);const u=xn(a);h=Object.assign(Object.assign({},h),{refresh:{path:d.cookiePath,domain:u?a:void 0}})}else{const e=En(i);Wt.remove(e),hn(`${n}${In}`,c)}if(l)if(t){const n=t.sameSite||"Strict",i=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=An(t);i&&"https:"!==window.location.protocol&&wn("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i,cookieDomain:o});On(r,l,c);const d=xn(o);h=Object.assign(Object.assign({},h),{session:{path:c.cookiePath,domain:d?o:void 0}})}else hn(`${n}${kn}`,l);return e.idToken&&hn(`${n}${Sn}`,e.idToken),d&&hn(`${n}DTD`,d),u&&hn(`${n}DKD`,u),h})(e,o,s,r);n&&(c=n)}}})),u=we(d,["logout","logoutAll","oidc.logout"],((e,t,n,i)=>o=>async(...r)=>{const s=await o(...r);return Tn(e,t,n,null==i?void 0:i()),s})(s,o,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>jn(s,r),getSessionToken:()=>Rn(s,o),getIdToken:()=>Un(s)})}))((e=>{const t=Lt(e),n=Ii(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var r;if(cn())return bn(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(i),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&Gt&&void 0!==window.localStorage&&!vn(ni)&&!pn(Zn)&&!vn("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=Rn(),a=jn();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){bn("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:s?"t":"f",dcr:a?"t":"f"},l,o)},logout:async i=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i)},flow:wi(t),webauthn:fi(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){mi(i,e)},requestAuthentication(e){mi(i,e)}},async oneTap(e,t,n,o,r){await bi(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(o+vi),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>Gt&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+vi);try{const i={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var i,o})),Ci="undefined"!=typeof localStorage,Oi="J151000",xi="E103205",Ai="E108201",Ei=Ci&&localStorage.getItem("base.content.url")||"",ji="base.ui.components.url";Ci&&localStorage.getItem(ji),Ci&&localStorage.getItem(ji);const Ri="descope-login-flow",Ui="code",Ti="redirect_mode",$i="err",Li="popup_opener_origin",Pi="data-exclude-field",Wi="data-exclude-next",Mi="dls_last_auth",Ni="dls_last_submitted_login_id",_i="dls_sso_run_",Di="state_id",qi="saml_idp_state_id",Fi="wsfed_idp_state_id",Vi="saml_idp_username",Ji="descope_idp_initiated",Hi="sso_app_id",Ki="custom_app_id",zi="third_party_app_id",Bi="third_party_app_state_id",Gi="oidc_login_hint",Zi="oidc_prompt",Xi="oidc_resource",Qi="oidc_error_redirect_uri",Yi="application_scopes",eo="data-type",to="redirect",no="poll",io="webauthnCreate",oo="webauthnGet",ro="nativeBridge",so="loadForm",ao="submit",lo="polling",co=["descope-multi-select-combo-box","descope-text-area"],uo="dls_last_auth_in_flight",ho=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts","data","totp","notp","sentTo","sso","selfProvisionDomains"],po=["hide","disable","read-only"],go="hidden";function fo(e,t){const n=e.closest(`.${go}`);return!!n&&n!==t}const vo=/(["\\])/g;function mo(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(vo,"\\$1")}function bo(e,t){return Array.from(e.querySelectorAll(`[id="${mo(t)}"]`))}function wo(e,t,n){return Object.keys(t).forEach((i=>{const o=t[i];n[i]!==o&&bo(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.remove(go);break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,o)))})),Object.keys(n).forEach((i=>{const o=n[i],r=t[i];o!==r&&bo(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.add(go);break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,o)))})),Object.assign({},n)}var yo;!function(e){e.backward="backward",e.forward="forward"}(yo||(yo={}));const ko=new Set,Io=(e,t)=>({origin:window.location.origin,pathname:window.location.pathname,hash:window.location.hash,projectId:e,flowId:t}),So=(e,t)=>`dls_sso_query_params_${e}_${t}`,Co=e=>Object.values(null!=e?e:{}).some(Boolean),Oo=Object.keys({oidcIdpStateId:!0,samlIdpStateId:!0,wsfedIdpStateId:!0,samlIdpUsername:!0,descopeIdpInitiated:!0,ssoAppId:!0,customAppId:!0,oidcLoginHint:!0,oidcPrompt:!0,oidcErrorRedirectUri:!0,oidcResource:!0,thirdPartyAppId:!0,thirdPartyAppStateId:!0,applicationScopes:!0}),xo=e=>Oo.reduce(((t,n)=>(null==e?void 0:e[n])?Object.assign(t,{[n]:e[n]}):t),{}),Ao=e=>{var t,n;const i=(null===(t=null==e?void 0:e.params)||void 0===t?void 0:t.oidcIdpStateId)&&(null===(n=null==e?void 0:e.params)||void 0===n?void 0:n.oidcErrorRedirectUri)?864e5:6e5;return Date.now()-e.ts<i},Eo=()=>{var e,t,n;try{const[i]=null!==(n=null===(t=null===(e=window.performance)||void 0===e?void 0:e.getEntriesByType)||void 0===t?void 0:t.call(e,"navigation"))&&void 0!==n?n:[],o=i;if("reload"!==(null==o?void 0:o.type)||!o.name)return!1;const r=new URL(o.name,window.location.href);return r.origin===window.location.origin&&r.pathname===window.location.pathname&&r.hash===window.location.hash}catch(e){return!1}},jo=(e,t)=>(null==e?void 0:e.origin)===t.origin&&(null==e?void 0:e.pathname)===t.pathname&&(null==e?void 0:e.hash)===t.hash&&(null==e?void 0:e.projectId)===t.projectId&&(null==e?void 0:e.flowId)===t.flowId,Ro=(e,t,n,i=Date.now())=>{var o;if(Co(e))try{const r={params:e,scope:Io(t,n),ts:i};null===(o=window.sessionStorage)||void 0===o||o.setItem(So(t,n),JSON.stringify(r))}catch(e){}},Uo=(e,t)=>{var n;try{const i=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(So(e,t));if(!i)return;const o=JSON.parse(i);return jo(null==o?void 0:o.scope,Io(e,t))?o.ts:void 0}catch(e){return}},To=e=>`${_i}${e}`,$o=()=>{var e;return null!==(e=window.localStorage)&&void 0!==e?e:null},Lo=()=>{try{const e=$o();if(!e)return;const t=[];for(let n=0;n<e.length;n+=1){const i=e.key(n);(null==i?void 0:i.startsWith(_i))&&t.push(i)}t.forEach((t=>{let n=!0;try{n=!Ao(JSON.parse(e.getItem(t)))}catch(e){}n&&e.removeItem(t)}))}catch(e){}},Po=(e,t,n,i)=>{var o,r;const s=(e=>{const t=Object.assign({},e);return delete t.oidcLoginHint,delete t.samlIdpUsername,t})(t);if(e&&Co(s)){try{const t={params:s,ts:null!==(o=Uo(n,i))&&void 0!==o?o:Date.now(),projectId:n};null===(r=$o())||void 0===r||r.setItem(To(e),JSON.stringify(t))}catch(e){}Lo()}},Wo=(e,t)=>{var n,i;try{const o=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(So(e,t));if(!o)return;const r=JSON.parse(o);jo(null==r?void 0:r.scope,Io(e,t))&&(null===(i=window.sessionStorage)||void 0===i||i.removeItem(So(e,t)))}catch(e){}},Mo=(e,t)=>Wo(e,t),No=["descope-enriched-text"];function _o(e){return new URLSearchParams(window.location.search).get(e)}function Do(e){if(window.history.replaceState&&_o(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())}}const qo=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||""};function Fo(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?yo.forward:n<i?yo.backward:void 0}const Vo=e=>{let[t="",n=""]=(_o(Ri)||"").split("_");const i=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||i&&i!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:i}};function Jo(){Do(Ri)}function Ho(e){try{const{origin:t}=new URL(e);return"null"===t?void 0:t}catch(e){return}}function Ko(e){const t=Ho(e);if(t)return t===window.location.origin||Ho(function(){const e=new URLSearchParams(window.location.search).getAll(Li);return 1===e.length?e[0]:void 0}())===t?t:void 0}const zo=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Bo=(e,t,n)=>{const{executionId:i,stepId:o,executionFlowId:r}=Vo(e);if(r&&e!==r)return n.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(i||o)&&Jo();const s=_o("t")||void 0;s&&Do("t");const a=_o(Ui)||void 0;a&&Do(Ui);const l="popup"===_o(Ti);l&&Do(Ti);const c=_o($i)||void 0;c&&Do($i);const{redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p}={redirectAuthCodeChallenge:_o("ra-challenge"),redirectAuthCallbackUrl:_o("ra-callback"),redirectAuthBackupCallbackUri:_o("ra-backup-callback"),redirectAuthInitiator:_o("ra-initiator")},g=_o(Di);g&&Do(Di);const f=_o(qi);f&&Do(qi);const v=_o(Fi);v&&Do(Fi);const m=_o(Vi);f&&Do(Vi);const b=_o(Ji);b&&Do(Ji);const w=_o(Hi);w&&Do(Hi);const y=_o(Ki);y&&Do(Ki);const k=_o(zi);k&&Do(zi);const I=_o(Bi);I&&Do(Bi);const S=_o(Yi);S&&Do(Yi);const C=_o(Gi);C&&Do(Gi);const O=_o(Zi);O&&Do(Zi);const x=_o(Qi);x&&Do(Qi);const A=_o(Xi);A&&Do(Xi);const E={oidcIdpStateId:g,samlIdpStateId:f,wsfedIdpStateId:v,samlIdpUsername:m,descopeIdpInitiated:"true"===b,ssoAppId:w,customAppId:y,oidcLoginHint:C,oidcPrompt:O,oidcErrorRedirectUri:x,oidcResource:A,thirdPartyAppId:k,thirdPartyAppStateId:I,applicationScopes:S},j=((e,t)=>{const n=(e=>[e.origin,e.pathname,e.hash,e.projectId,e.flowId].join("|"))(Io(e,t));return!ko.has(n)&&(ko.add(n),!0)})(t,e);let R=E,U=null;if(Lo(),Co(E))Ro(E,t,e);else if(i)U=((e,t,n)=>{var i;if(!e)return null;try{const o=null===(i=$o())||void 0===i?void 0:i.getItem(To(e));if(!o)return null;const r=JSON.parse(o),s=xo(null==r?void 0:r.params);return(null==r?void 0:r.projectId)===t&&Co(s)&&Ao(r)?(Ro(s,t,n,r.ts),s):null}catch(e){return null}})(qo(i),t,e);else if(!r){const i=j?((e,t)=>{var n;if(!Eo())return null;try{const i=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(So(e,t));if(!i)return null;const o=JSON.parse(i);return jo(null==o?void 0:o.scope,Io(e,t))&&Ao(o)?o.params:null}catch(e){return null}})(t,e):null;i?(n.debug("Restored SSO query params after a page reload"),R=i):((e,t)=>{Eo()||Wo(e,t)})(t,e)}return{executionId:i,stepId:o,token:s,code:a,isPopup:l,exchangeError:c,redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p,ssoQueryParams:R,adoptedSsoQueryParams:U}},Go=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})},Zo=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=Array.from(e.querySelectorAll('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])')).find((t=>!fo(t,e)));setTimeout((()=>{null==t||t.focus()}))}};function Xo(e,t,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),i(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const Qo=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:i,samlIdpUsername:o,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||n||i||o||r||s||a||l||c||d||u||h||p),Yo=(e,t,n)=>{const i=document.createElement("input");return i.type="hidden",i.name=e,i.value=t,n&&i.setAttribute("role",n),i},er=e=>null==e?void 0:e.submit(),tr=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},nr=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}},ir={minLength:"data-password-policy-value-minlength",strength:"data-password-policy-value-passwordstrength",disallowedChars:"data-password-policy-value-disallowedchars",email:"data-password-policy-value-email",reuse:"data-password-policy-value-reuse",activePolicies:"active-policies",availablePolicies:"available-policies"},or=(e,t)=>{var n;const i=null==e?void 0:e.componentsDynamicAttrs;if(!i)return;const o=Object.entries(i).find((([e])=>(e=>{var t;return null===(t=e.match(/\[data-name=["']([^"']+)["']\]/))||void 0===t?void 0:t[1]})(e)===t));return null===(n=null==o?void 0:o[1])||void 0===n?void 0:n.attributes},rr=[{key:"totp",from:e=>e.totp},{key:"notp",from:e=>e.notp},{key:"sentTo",from:e=>e.sentTo},{key:"sso",from:e=>e.sso},{key:"selfProvisionDomains",from:e=>e.selfProvisionDomains},{key:"inboundAppApproveScopes",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.thirdPartyAppApproveScopes)||void 0===n?void 0:n.data}},{key:"securityQuestionsSetup",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqSetup}},{key:"securityQuestionsVerify",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqVerify}},{key:"userTenants",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userSelectedTenant)||void 0===n?void 0:n.data}},{key:"userRoles",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userRoles)||void 0===n?void 0:n.data}},{key:"ssoApplications",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoApplications)||void 0===n?void 0:n.data}},{key:"ssoConfigurations",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoConfigurations)||void 0===n?void 0:n.data}},{key:"samlAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlMappings)||void 0===n?void 0:n.options}},{key:"oidcAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.oidcMappings)||void 0===n?void 0:n.options}},{key:"samlGroupMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlGroupMappings)||void 0===n?void 0:n.options}},{key:"passwordPolicy",from:e=>{var t;return(e=>{if(!e)return;const t=Object.fromEntries(Object.entries(ir).map((([t,n])=>[t,e[n]])).filter((([,e])=>void 0!==e)));return Object.keys(t).length?t:void 0})(null===(t=e.componentsConfig)||void 0===t?void 0:t.newPassword)}},{key:"recoveryCodes",from:e=>(e=>{const t=or(e,"recoveryCodes");if(t)return Array.isArray(t.data)?t.data.map((e=>e.value)):[]})(e.componentsConfig)},{key:"outboundApp",from:e=>(e=>{const t=or(e,"outboundApp");if(t)return{label:t.label,iconSrc:t["icon-src"],appId:t["data-descope-outbound-oauth-app-id"]}})(e.componentsConfig)}],sr=e=>{const t=(n=e.screenState,i=(e,t)=>ho.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!i(t,e)))));var n,i;const{screenState:{errorText:o,errorType:r}}=e;(o||r)&&(t.error={text:o,type:r}),e.action&&(t.action=e.action);const s=(e=>{if(!e)return;const t={};return rr.forEach((({key:n,from:i})=>{const o=i(e);void 0!==o&&(t[n]=o)})),Object.keys(t).length?t:void 0})(e.screenState);return s&&(t.data=s),t},ar=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function lr(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}const cr=(e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,l=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",c=window.open(l,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return c.location.href=e,c.focus(),c};var dr,ur,hr,pr;function gr(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!gr(r,s))return!1}else if(r!==s)return!1}return!0}class fr{constructor(e={},{forceUpdate:t=!1}={}){dr.set(this,void 0),ur.set(this,{}),hr.set(this,0),pr.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,dr,"f")):e,n=Object.assign(Object.assign({},i(this,dr,"f")),t),r=i(this,dr,"f");o(this,dr,n,"f"),Object.freeze(i(this,dr,"f")),setTimeout((()=>{Object.values(i(this,ur,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const s=t(r),a=t(n);(i(this,pr,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!gr(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},o(this,dr,e,"f"),o(this,pr,t,"f")}get current(){return Object.assign({},i(this,dr,"f"))}set forceUpdate(e){o(this,pr,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,hr,i(this,hr,"f")+1,"f"),i(this,ur,"f")[i(this,hr,"f")]={cb:e,selector:t,forceUpdate:n},i(this,hr,"f").toString()}unsubscribe(e){const t=!!i(this,ur,"f")[e];return t&&delete i(this,ur,"f")[e],t}unsubscribeAll(){return o(this,ur,{},"f"),!0}}dr=new WeakMap,ur=new WeakMap,hr=new WeakMap,pr=new WeakMap;const vr=/[\\*#/()[\]_<>`]/g,mr=["disabled"],br=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Pi}])`)).forEach((e=>{e.value=n}))}))},wr=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),yr=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>{return n?"string"!=typeof(o=String(wr(t,i)))?o:o.replace(vr,"\\$&"):wr(t,i);var o})),kr=(e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(i=e.localName,No.includes(i));var i;e.textContent=yr(e.textContent,t,n);const o=e.getAttribute("href");o&&e.setAttribute("href",yr(o,t))}))},Ir=(e,t,n)=>{e.querySelectorAll(`[${eo}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Sr=(e,t,n)=>{var i,o;const r=null===(i=customElements.get(t))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},Cr=(e,n,i,o)=>{var r,s;Ir(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),Ir(e,"notp-link",null===(s=null==n?void 0:n.notp)||void 0===s?void 0:s.redirectUrl),kr(e,n),((e,n,i)=>{if(!n)return;const{componentsDynamicAttrs:o}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});o&&Object.keys(o).forEach((e=>{const t=o[e];if(t){const{attributes:n}=t;n&&Object.keys(n).length&&(s[e]=n)}})),Object.keys(s).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const n=s[t];Object.keys(n).forEach((t=>{let o=n[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==n?void 0:n.componentsConfig,o),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=yr(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])=>{mr.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i)},Or=Go((()=>n(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield Xo(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}})))),xr=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};let Ar;const Er=(e,t)=>{Ar?Ar.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},jr=e=>Ar?Ar.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,Rr="dls_ab_testing_id",Ur={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)}},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||((e.abTestingKey||0)<n||(e.abTestingKey||0)>i)},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function Tr(e,t){const n={};try{Object.assign(n,JSON.parse(jr(Mi)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function $r(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||Er(Mi,JSON.stringify(e)))}function Lr(){try{return JSON.parse(jr(uo)||"{}")}catch(e){return{}}}function Pr(e){try{t=uo,Ar?Ar.removeItem(t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(t)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}var t}const Wr=["error","warn","info","debug"],Mr={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},Nr=l((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,i(this,t,"m",r).call(this,Mr))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e||Mr),"f")}get logger(){return i(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return Wr.reduce(((t,n)=>(t[n]=(...t)=>{var i;this.onLogEvent(n,t),null===(i=e[n])||void 0===i||i.call(e,...t)},t)),{})},s})),_r="undefined"!=typeof localStorage,Dr="https://static.descope.com/pages",qr="https://static2.descope.com/pages",Fr=_r&&localStorage.getItem("base.content.url")||"",Vr=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,Jr=l((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&i(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),Hr=l((e=>{var t,n;const o=r(Nr,Jr)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=i(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&e.oldValue!==n.getAttribute(e.attributeName)&&o(e.attributeName)}))})).observe(n,{attributes:!0,attributeOldValue:!0})}observeAttribute(e,n){i(this,t,"f")[e]||(i(this,t,"f")[e]=[]);const o=i(this,t,"f")[e].push(n);return()=>i(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),Kr=e=>t=>{var n,o,s;const a=r(Nr,Jr,Hr)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,i(this,n,"m",o).bind(this))}async init(){var e;l.forEach((e=>i(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},s};Kr.missingAttrValidator=Vr;const zr=l((e=>{const t=r(Kr({"project-id":Vr}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),Br=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),Gr="Trying the next fallback URL...",Zr=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};const Xr=l((e=>{var t,n,s,a,l,c,d;const u=r(Nr,zr,Br)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const r=i(this,t,"m",l).call(this,e),c=Array.isArray(r)?e=>{const{baseUrl:t}=r[e];o(this,s,t,"f");for(let t=0;t<e;t++){const e=r[t].baseUrl;i(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:i}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const r=o[e],s=e===o.length-1;try{const o=await Zr(r.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${Gr}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${Gr}`)}}})(r,{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,s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const r=Fr||this.baseStaticUrl;if(r)return i(this,t,"m",c).call(this,e,r);i(this,n,"f")!==this.baseUrl&&(o(this,n,this.baseUrl,"f"),o(this,s,void 0,"f"),i(this,a,"f").clear());const l=[];if(i(this,s,"f"))l.push(i(this,t,"m",c).call(this,e,i(this,s,"f"))),i(this,s,"f")===Dr&&l.push(i(this,t,"m",c).call(this,e,qr));else{const n=this.baseUrl+"/pages";this.baseUrl&&!i(this,a,"f").has(n)&&l.push(i(this,t,"m",c).call(this,e,n)),i(this,a,"f").has(Dr)||l.push(i(this,t,"m",c).call(this,e,Dr)),l.push(i(this,t,"m",c).call(this,e,qr))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i=Dr}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}({projectId:this.projectId,filename:e,baseUrl:t})},d})),Qr=l((e=>{var t,n;const o=r(Kr({"project-id":Vr}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return i(this,t,"f").set(e,n),()=>{i(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(i(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=i(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),Yr=l((e=>{var t,n,s,a,l;const c=r(Xr,Qr,Jr)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,t,"m",n).bind(this))}get config(){return i(this,s,"f")||o(this,s,i(this,a,"f").call(this),"f"),i(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,s,void 0,"f")},l})),es=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],ts=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},ns=(e,t,n)=>new Promise(((i,o)=>{const r=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);r.onerror=e=>{r.setAttribute("status","error"),o(e)},r.onload=()=>{r.setAttribute("status","loaded"),i(r)},r.src=t.toString(),document.body.appendChild(r)})),is=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},os=l((e=>{const t=r(Nr)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const i of e){const{id:e,url:o,integrity:r}=i,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await is(s,r),i}catch(e){t(i,!0)}else try{return await ns(e,o,r),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="",o)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${i}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${ts(a)}`};return o&&(l.integrity=o),[...e,l]}),[]))([...i,this.baseCdnUrl,...es],e,t,n,o),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),rs="base.ui.components.url",ss=_r&&localStorage.getItem(rs),as=l((e=>{var t,n,s,a,l,c,d;const u=r(Nr,Yr,os)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return i(this,a,"f")||o(this,a,i(this,t,"m",c).call(this),"f"),i(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>i(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=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(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await i(this,t,"m",n).call(this),o=ss?void 0:await i(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[ss],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),ls=l((e=>{var t,n,o;const s=r(Jr,Hr)(e);return o=class extends s{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",i(this,t,"m",n).bind(this)),i(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class cs{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const ds=l((e=>{const t=r(ls)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new cs(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),us="content-root",hs="root",ps=l((e=>{const t=r(ds)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${hs}">\n <div id="${us}"></div>\n </div>\n `,this.injectStyle(`\n #${hs}, #${us} {\n height: 100%;\n }\n #${hs} {\n position: relative;\n height: fit-content;\n }\n #${hs}:has(> #${us} > #ROOT[st-host-height="100%"]) {\n height: 100%;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(us),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(hs)}}})),gs=(e,t,n="")=>Object.entries(e).reduce(((e,[i,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(i))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${i}`:i;if("object"==typeof o&&null!==o)return e+gs(o,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(o);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),""),fs=e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)};function vs(e,t){const n=Object.assign({},e);for(const[e,i]of Object.entries(t||{}))if(null!=i)if("object"==typeof i){if(0===Object.keys(i).length)continue;n[e]=vs(n[e]||{},i)}else n[e]="string"==typeof i?(n[e]||"")+i:i;return n}const ms=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",bs=l((e=>{const t=r(Kr({tenant:ms}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),ws=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ys=l((e=>{var t,n,s,a,l,c,d,u,h,p,g,f,v,m,b,w,y,k,I,S,C,O,x;const A=r(Kr({theme:ws}),bs,Xr,Jr,as,Yr,ps,Hr,ds)(e);return x=class extends A{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,void 0),c.set(this,void 0),d.set(this,void 0),S.set(this,(()=>{i(this,t,"m",C).call(this),i(this,O,"f").call(this,"os"===this.getAttribute("theme"))})),O.set(this,(e=>{var n,o,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===r||r.call(o,"change",(()=>i(this,t,"m",C).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"}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,S,"f").call(this),await Promise.all([i(this,t,"m",p).call(this),i(this,t,"m",v).call(this),i(this,t,"m",b).call(this)]),i(this,t,"m",m).call(this),this.observeAttributes(["theme"],i(this,S,"f")),this.observeAttributes(["theme-override"],(()=>i(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{o(this,d,null,"f"),i(this,t,"m",v).call(this),i(this,t,"m",b).call(this),i(this,t,"m",k).call(this)})),this.observeAttributes(["style-id"],(()=>{o(this,c,null,"f"),i(this,t,"m",y).call(this),i(this,t,"m",p).call(this),i(this,t,"m",b).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,d=new WeakMap,S=new WeakMap,O=new WeakMap,t=new WeakSet,l=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,i,o,r,s,a;const l=null===(o=null===(i=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===i?void 0:i.colors)||void 0===o?void 0:o.primary,c=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${gs({colors:{primary:l,secondary:c}},(e=>this.logger.error(e)))}}`:""})).join(""):""},u=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")}},h=function(){return i(this,c,"f")||(o(this,c,i(this,t,"m",u).call(this),"f"),i(this,c,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,c,"f")},p=async function(){var e,r;const s=await i(this,t,"a",h);if(!s)return;const a=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||"");i(this,n,"f")?i(this,n,"f").replaceSync(a):o(this,n,this.injectStyle(a,{prepend:!0}),"f")},g=async function(){const e=this.tenantId;if(e)try{const{body:t}=await this.fetchStaticResource(`${e}/theme.json`,"json");return t}catch(e){this.logger.warn("No tenant style exists, using project default theme.")}},f=function(){return i(this,d,"f")||o(this,d,i(this,t,"m",g).call(this),"f"),i(this,d,"f")},v=async function(){var e,n,r,a;if(!this.tenantId)return void(null===(e=i(this,s,"f"))||void 0===e||e.replaceSync(""));const l=await i(this,t,"a",f);if(!l)return void(null===(n=i(this,s,"f"))||void 0===n||n.replaceSync(""));const c=((null===(r=l.light)||void 0===r?void 0:r.globals)||"")+((null===(a=l.dark)||void 0===a?void 0:a.globals)||"");i(this,s,"f")?i(this,s,"f").replaceSync(c):o(this,s,this.injectStyle(c),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=i(this,a,"f"))||void 0===e||e.replaceSync(""));const n=i(this,t,"m",l).call(this);i(this,a,"f")?i(this,a,"f").replaceSync(n):o(this,a,this.injectStyle(n),"f")},b=async function(){var e,n,o,r;const s=await i(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const l=await i(this,t,"a",f);a.componentsThemeManager.themes={light:vs((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.components)||{},(null===(n=null==l?void 0:l.light)||void 0===n?void 0:n.components)||{}),dark:vs((null===(o=null==s?void 0:s.dark)||void 0===o?void 0:o.components)||{},(null===(r=null==l?void 0:l.dark)||void 0===r?void 0:r.components)||{})}},w=async function(){var e,t;const{projectConfig:n}=await this.config||{},i=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,r=i||o;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},y=async function(){const e=await i(this,t,"m",w).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),fs(e.url))})):this.logger.debug("No fonts to load"),i(this,t,"m",k).call(this)},k=async function(){var e;if(!this.tenantId)return;const n=await i(this,t,"a",f),o=null===(e=null==n?void 0:n[this.theme])||void 0===e?void 0:e.fonts;Object.values(o||{}).forEach((e=>{(null==e?void 0:e.url)&&(this.logger.debug(`Loading tenant font from URL "${e.url}"`),fs(e.url))}))},I=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)},C=function(){i(this,t,"m",y).call(this),i(this,t,"m",I).call(this)},x})),ks=_r&&localStorage.getItem("base.debug.logs.url"),Is=l((e=>{const t=r(Kr({"flow-id":Vr}))(e);return class extends t{get flowId(){return this.getAttribute("flow-id")}}}));function Ss(e){const t=Math.floor(e/1e3);if(t<60)return`${t} seconds`;const n=Math.floor(t/60);if(n<60)return`${n} minutes`;const i=Math.floor(n/60);return i<24?`${i} hours`:`${Math.floor(i/24)} days`}const Cs=l((e=>{var t,n,s,a,l,c,d,u,h,p,g,f;const v=r(os,Nr,Jr,Yr,zr,Is)(e);return f=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,null),s.set(this,!1),a.set(this,null),g.set(this,null)}get telemetryManager(){return i(this,n,"f")}updateTelemetryContext(e){if(i(this,n,"f"))try{i(this,n,"f").updateContext(e)}catch(e){this.logger.error("Error updating telemetry context:",e)}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this));const n=this.sdkVersion||"1.0.0";o(this,g,i(this,t,"m",h).call(this).then((e=>i(this,t,"m",l).call(this,e,{projectId:this.projectId,flowId:this.flowId,sdkVersion:n}))).catch((e=>{this.logger.error("Failed to start telemetry:",e)})),"f")}get telemetryReady(){var e;return null!==(e=i(this,g,"f"))&&void 0!==e?e:Promise.resolve()}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),i(this,t,"m",d).call(this)}},n=new WeakMap,s=new WeakMap,a=new WeakMap,g=new WeakMap,t=new WeakSet,l=async function(e,r){if(null==e?void 0:e.enabled)if(i(this,s,"f"))this.logger.debug("Telemetry already initialized");else if(e.expiration&&Date.now()>=e.expiration)this.logger.info(`Telemetry expiration time has passed (${new Date(e.expiration).toISOString()}), skipping initialization`);else try{this.logger.debug("Initializing telemetry...");const a=e.version||"latest";await this.injectNpmLib("@descope/debug-logs",a,"dist/index.js",[ks]);const l=window.DescopeDebugLogs;if(!l)throw new Error("DescopeDebugLogs not found after loading @descope/debug-logs. This likely means the UMD build failed to load from CDN.");if(o(this,n,new l({enabled:!0,rumConfig:e.rumConfig,capture:e.capture},{projectId:r.projectId,flowId:r.flowId,version:r.sdkVersion||"1.0.0"},this.logger),"f"),!i(this,n,"f").isReady())return this.logger.error("Telemetry manager failed to initialize (RUM client not ready)"),void o(this,n,null,"f");o(this,s,!0,"f"),this.logger.info("Telemetry initialized successfully"),e.expiration&&i(this,t,"m",c).call(this,e.expiration)}catch(e){this.logger.error("Failed to initialize telemetry:",e),o(this,s,!1,"f")}else this.logger.debug("Telemetry is disabled, skipping initialization")},c=function(e){const n=e-Date.now();if(n<=0)return this.logger.info("Telemetry expiration time reached, shutting down"),void i(this,t,"m",d).call(this);const r=864e5,s=Math.min(n,r);n>r&&this.logger.warn(`Telemetry expiration is beyond maximum timeout (${Ss(n)}). Setting to maximum.`),this.logger.info(`Telemetry will expire at ${new Date(e).toISOString()} (in ${Ss(s)})`),o(this,a,setTimeout((()=>{this.logger.info("Telemetry expiration time reached, shutting down"),i(this,t,"m",d).call(this)}),s),"f")},d=function(){if(i(this,a,"f")&&(clearTimeout(i(this,a,"f")),o(this,a,null,"f")),i(this,n,"f"))try{this.logger.debug("Shutting down telemetry..."),i(this,n,"f").shutdown(),o(this,n,null,"f"),o(this,s,!1,"f"),this.logger.info("Telemetry shutdown complete")}catch(e){this.logger.error("Error shutting down telemetry:",e)}},u=function(e){return Boolean((null==e?void 0:e.applicationId)&&(null==e?void 0:e.identityPoolId)&&(null==e?void 0:e.region))},h=async function(){var e;const n=await this.config,o=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.telemetry;let r;try{const e=Number("");r={enabled:"true"==="".toLowerCase(),rumConfig:Object.assign({applicationId:"",identityPoolId:"",region:"",sessionSampleRate:Number.isFinite(e)&&e>0?e:1},"")}}catch(e){r={enabled:!1,rumConfig:{applicationId:"",identityPoolId:"",region:"",sessionSampleRate:1}}}const s=Object.assign(Object.assign(Object.assign({},r),o),{rumConfig:Object.assign(Object.assign({},r.rumConfig),null==o?void 0:o.rumConfig),capture:i(this,t,"m",p).call(this,null==o?void 0:o.capture)});return s.enabled&&!i(this,t,"m",u).call(this,s.rumConfig)&&(this.logger.warn("Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization."),s.enabled=!1),o||(s.expiration=Date.now()+3e5,this.logger.debug("No backend telemetry config present; applying a 5-minute safety cap on the session.")),s},p=function(e){const t=null==e?void 0:e.dom;return!1===t?Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:!1}):Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:Object.assign(Object.assign({throttleMs:2e3},"object"==typeof t?t:{}),{rootElement:this.shadowRoot})})},f})),Os=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if(Array.isArray(e[i]))return Object.assign(Object.assign({},n),{[i]:{value:e[i].map((e=>"object"==typeof e&&null!==e?Os(e):e))}});if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),Os(e[i],`${t+i}.`));const r="object"==typeof e[i]?e[i]:{value:e[i]},s=Object.assign(Object.assign({},n),{[t+i]:r,[`form.${t}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),xs=l((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;i(this,t,"m",n).call(this)&&i(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},r}));l((e=>{var t,n,s,a,l,c,d;return d=class extends(r(Jr,Nr)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),"debug"===e&&i(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&i(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=i(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(i(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return mc})),document.body.appendChild(i(this,n,"f"))},l=function(){this.debug?i(this,t,"m",a).call(this):i(this,t,"m",s).call(this)},c=function(e,t){var o;e&&(null===(o=i(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},d}));const As="descope-modal";var Es,js,Rs,Us,Ts;class $s{constructor(e,t){Es.set(this,void 0),this.nodeName="",o(this,Es,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const i="function"==typeof e?e():e;i&&(clearInterval(n),t(i))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(i(this,Es,"f"))}get ele(){var e,t;const n="function"==typeof i(this,Es,"f")?i(this,Es,"f").call(this):i(this,Es,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}}Es=new WeakMap;class Ls extends $s{constructor(...e){super(...e),js.add(this),Rs.set(this,void 0),Us.set(this,void 0),this.nodeName="descope-modal",i(this,js,"m",Ts).call(this)}get isOpen(){var e;return"true"===(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("opened"))}get isClosed(){return!this.isOpen}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),i(this,js,"m",Ts).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),i(this,Rs,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,Rs,"f").content.cloneNode(!0)))}setContent(e){o(this,Rs,e,"f"),this.reset()}remove(){var e,t;null===(e=i(this,Us,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}}Rs=new WeakMap,Us=new WeakMap,js=new WeakSet,Ts=function(){if(i(this,Us,"f"))return;const e=this.ele;e&&(o(this,Us,new MutationObserver((t=>{t.forEach(((n,i)=>{var o;const r="true"===n.oldValue,s=t[i+1]?t[i+1].oldValue:e.getAttribute("opened");r&&"true"!==s&&(null===(o=this.afterClose)||void 0===o||o.call(this))}))})),"f"),i(this,Us,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};class Ps extends $s{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}}const Ws=l((e=>{var t,n;const o=r(Jr,ps,as)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Ls{setContent(t){e(t),super.setContent(t)}}})())}get modalDriverClass(){return i(this,t,"f")}createModal(e,n=i(this,t,"f")){const o=((e={})=>{const t=document.createElement(As);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(o),new n(o,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([As]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n}));l((e=>class extends(Ws(e)){createFlowModal(e){const t=this.modalDriverClass;return this.createModal(e,class extends t{setContent(e){const t=e.content.querySelector("descope-wc");t&&!t.hasAttribute("lazy-start")&&t.setAttribute("lazy-start","true"),super.setContent(e)}async open(){var e,t,n;await super.open(),null===(n=null===(t=null===(e=this.ele)||void 0===e?void 0:e.querySelector("descope-wc"))||void 0===t?void 0:t.start)||void 0===n||n.call(t)}})}}));const Ms="descope-notification";l((e=>{var t,n;const o=r(Jr,ps,as)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Ps{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(Ms);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(i(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([Ms])}},t=new WeakMap,n})),l((e=>class extends(Nr(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}}));const Ns=l((e=>{const t=r(Kr({"widget-id":Vr}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}}));l((e=>{const t=r(Yr,Ns)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}async getHostedPageBaseUrl(){var e;const t=await this.config;return null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.hostedPageBaseUrl}}})),l((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=v(this.locale);return[...new Set([e,t].filter(Boolean))]}firstAvailableLocale(e){var t;const n=(null!=e?e:[]).map((e=>e.toLowerCase()));return null!==(t=this.localeCandidates.find((e=>n.includes(e))))&&void 0!==t?t:""}})),l((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),l((e=>{var n,o,r;return r=class extends(ys(e)){constructor(){super(...arguments),n.add(this)}get clientInput(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get formInput(){return this.getAttribute("form")||void 0}createFlowTemplate(e){var{flowId:r,client:s,form:l}=e,c=t(e,["flowId","client","form"]);return a(Object.assign({projectId:this.getAttribute("project-id"),flowId:r,baseUrl:this.getAttribute("base-url")||"",baseStaticUrl:this.getAttribute("base-static-url")||"",baseCdnUrl:this.getAttribute("base-cdn-url")||"",refreshCookieName:this.getAttribute("refresh-cookie-name")||"",theme:this.theme,"style-id":this.styleId,locale:this.getAttribute("locale")||"",form:i(this,n,"m",o).call(this,l),client:Object.assign(Object.assign({},this.clientInput),s)},c))}},n=new WeakSet,o=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},r}));const _s=/(["\\])/g;function Ds(e,t){return Array.from(e.querySelectorAll(`[data-id="${n=t,"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(n):n.replace(_s,"\\$1")}"]`));var n}function qs(e,t){e&&t&&Object.entries(t).forEach((([t,n])=>{Ds(e,t).forEach((e=>function(e,t){var n;switch(t){case"hide":e.setAttribute("hidden",""),null===(n=e.style)||void 0===n||n.setProperty("display","none","important");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,n)))}))}l((e=>{var t,n,s,a,l,c;const d=r(Nr,ps)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,{})}async init(){var e,r;if("true"===this.getAttribute("mock"))return o(this,n,Promise.resolve({}),"f"),void await(null===(e=super.init)||void 0===e?void 0:e.call(this));const s=i(this,t,"m",a).call(this);o(this,n,i(this,t,"m",l).call(this,s),"f"),await(null===(r=super.init)||void 0===r?void 0:r.call(this))}async onWidgetRootReady(){var e,t;await(null===(e=super.onWidgetRootReady)||void 0===e?void 0:e.call(this)),o(this,s,null!==(t=await i(this,n,"f"))&&void 0!==t?t:{},"f"),qs(this.contentRootElement,i(this,s,"f"))}async reevaluateComponentsState(){const e=i(this,t,"m",a).call(this);var n,r;n=this.contentRootElement,r=i(this,s,"f"),n&&r&&Object.entries(r).forEach((([e,t])=>{Ds(n,e).forEach((e=>function(e,t){var n;switch(t){case"hide":e.removeAttribute("hidden"),null===(n=e.style)||void 0===n||n.removeProperty("display");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,t)))})),o(this,s,await i(this,t,"m",l).call(this,e),"f"),qs(this.contentRootElement,i(this,s,"f"))}},n=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(){var e;const t=null===(e=this.api)||void 0===e?void 0:e.httpClient;if(!t)throw new Error("componentsConditionsMixin: the widget sdk must expose `httpClient`. Compose apiMixin and return `webSdk.httpClient` from createSdk.");return t},l=async function(e){var t;try{const n=await e.get("/v1/mgmt/widget/components-state");if(!(null==n?void 0:n.ok))return{};const i=await n.json();return null!==(t=null==i?void 0:i.componentsState)&&void 0!==t?t:{}}catch(e){return this.logger.debug("components-conditions: failed to fetch, showing all components",null==e?void 0:e.message),{}}},c}));const Fs=["input","change"];function Vs(e){if("number"==typeof e&&Number.isFinite(e))return{value:e,ok:!0};if("boolean"==typeof e)return{value:e?1:0,ok:!0};if("string"==typeof e){if(""===e.trim())return{value:0,ok:!1};const t=Number(e);if(Number.isFinite(t))return{value:t,ok:!0}}return{value:0,ok:!1}}function Js(e){return null==e?"":"string"==typeof e?e:"boolean"==typeof e?e?"true":"false":"number"==typeof e?Number.isFinite(e)?String(e):"":String(e)}function Hs(e){if("boolean"==typeof e)return{value:e,ok:!0};if("string"==typeof e){if("true"===e)return{value:!0,ok:!0};if("false"===e)return{value:!1,ok:!0}}return"number"==typeof e?{value:0!==e,ok:!0}:{value:!1,ok:!1}}function Ks(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function zs(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const Bs=new Map;const Gs={equal:(e,t)=>e===t||Js(e)===Js(t),"not-equal":(e,t)=>e!==t&&Js(e)!==Js(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(Js(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(Js(t)),"greater-than":(e,t)=>{const n=Vs(e),i=Vs(t);return n.ok&&i.ok&&n.value>i.value},"greater-than-or-equal":(e,t)=>{const n=Vs(e),i=Vs(t);return n.ok&&i.ok&&n.value>=i.value},"less-than":(e,t)=>{const n=Vs(e),i=Vs(t);return n.ok&&i.ok&&n.value<i.value},"less-than-or-equal":(e,t)=>{const n=Vs(e),i=Vs(t);return n.ok&&i.ok&&n.value<=i.value},empty:e=>zs(e),"not-empty":e=>!zs(e),"is-true":e=>{const t=Hs(e);return t.ok&&t.value},"is-false":e=>{const t=Hs(e);return t.ok&&!t.value},in:(e,t)=>{const n=Ks(t);return null!==n&&n.includes(e)},"not-in":(e,t)=>{const n=Ks(t);return null!==n&&!n.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const n=function(e){var t;if(Bs.has(e))return null!==(t=Bs.get(e))&&void 0!==t?t:null;let n;try{n=new RegExp(e)}catch(e){n=null}return Bs.set(e,n),n}(Js(t));return null!==n&&n.test(e)}};function Zs(e,t){var n;if(e)return"form"===e.kind&&e.form?t[e.form]:"list"===e.kind?(null!==(n=e.items)&&void 0!==n?n:[]).map((e=>Zs(e,t))):e.value}function Xs(e,t){const n=Gs[e.operator];if(!n)return!1;return n(Zs(e.target,t),Zs(e.predicate,t))}function Qs(e,t){var n;return(null!==(n=e.rules)&&void 0!==n?n:[]).some((e=>function(e,t){var n;const i=null!==(n=e.atomicConditions)&&void 0!==n?n:[];return!!i.length&&(e.logicalOr?i.some((e=>Xs(e,t))):i.every((e=>Xs(e,t))))}(e,t)))}function Ys(e,t){const n={};return(null!=e?e:[]).forEach((e=>{var i;Qs(e,t)&&(null!==(i=e.componentIds)&&void 0!==i?i:[]).forEach((t=>{n[t]=e.action}))})),n}const ea="component-conditions:";function ta(e){return e instanceof HTMLInputElement?"checkbox"===e.type?e.checked:e.value:"checked"in e?e.checked:"value"in e?e.value:void 0}function na(e,t){const n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every((n=>e[n]===t[n]))}function ia(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function oa(e,t,n){const i={};return n.forEach((n=>{e[n]?i[n]=e[n]:t[n]&&(i[n]=t[n])})),i}const ra=l((e=>{var t,n,s,a,l,c;const d=r(Nr)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,ia())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{po.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${po.map((e=>`"${e}"`)).join(", ")}`)})),wo(e,{},t))}initRealtimeConditions(e,r){var a,c,d,u;i(this,t,"m",l).call(this);const h=null!==(a=null==r?void 0:r.realtimeComponentsConditions)&&void 0!==a?a:[];if(!h.length)return void this.logger.debug(`${ea} no real-time rules to apply on this screen`);this.logger.info(`${ea} found ${h.length} real-time rule(s) for this screen`);const p={};Object.entries(null!==(c=null==r?void 0:r.form)&&void 0!==c?c:{}).forEach((([e,t])=>{p[`form.${e}`]=t})),function(e){const t=new Set,n=e=>{var i;e&&("form"===e.kind&&e.form?t.add(e.form):"list"===e.kind&&(null!==(i=e.items)&&void 0!==i?i:[]).forEach(n))};return(null!=e?e:[]).forEach((e=>{var t;return(null!==(t=e.rules)&&void 0!==t?t:[]).forEach((e=>{var t;return(null!==(t=e.atomicConditions)&&void 0!==t?t:[]).forEach((e=>{n(e.target),n(e.predicate)}))}))})),t}(h).forEach((t=>{const n=function(e,t){const n=t.startsWith("form.")?t.slice(5):t;return e.querySelector(`[name="${mo(t)}"]`)||e.querySelector(`[name="${mo(n)}"]`)}(e,t);if(!n)return;const i=ta(n);void 0!==i&&(p[t]=i)}));const g=function(e){const t=new Set;return(null!=e?e:[]).forEach((e=>{var n;(null!==(n=e.componentIds)&&void 0!==n?n:[]).forEach((e=>t.add(e)))})),t}(h),f={},v={};Object.entries(null!==(d=null==r?void 0:r.componentsState)&&void 0!==d?d:{}).forEach((([e,t])=>{g.has(e)&&(v[e]=t)})),Object.entries(null!==(u=null==r?void 0:r.serverOnlyComponentsState)&&void 0!==u?u:{}).forEach((([e,t])=>{g.has(e)&&(f[e]=t)}));const m={conditions:h,touchedIds:g,snapshot:p,applied:v,serverBaseline:f,debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:e},b=oa(Ys(h,p),f,g);na(v,b)||(m.applied=wo(e,v,b)),m.inputHandler=e=>i(this,t,"m",s).call(this,e),Fs.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${ea} listening for "${Fs.join('" and "')}" events on form fields; ${Object.keys(v).length} component(s) start hidden / disabled / read-only by these rules`);const w=this.nextRequestStatus;if(null==w?void 0:w.subscribe){const e=({isLoading:e})=>{m.paused=e,e&&m.debounceTimer&&(clearTimeout(m.debounceTimer),m.debounceTimer=null)},t=w.subscribe(e);m.unsubscribePauseListener=()=>{var e;null!=t&&(null===(e=w.unsubscribe)||void 0===e||e.call(w,t))}}o(this,n,m,"f")}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(e){var o,r;const s=i(this,n,"f");if(!s.root||s.paused)return;const l=e.target;if(!l)return;if(null===(o=l.hasAttribute)||void 0===o?void 0:o.call(l,Pi))return;const c=null===(r=l.getAttribute)||void 0===r?void 0:r.call(l,"name");if(!c)return;const d=function(e){return e.startsWith("form.")?e:`form.${e}`}(c);s.snapshot[d]=ta(l),s.debounceTimer&&clearTimeout(s.debounceTimer),s.debounceTimer=setTimeout((()=>{s.debounceTimer=null,i(this,t,"m",a).call(this)}),50)},a=function(){const e=i(this,n,"f");if(!e.root)return;let t;try{t=oa(Ys(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${ea} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const o=e.applied;na(o,t)||(this.logger.debug(`${ea} form changed — updating components: was ${JSON.stringify(o)}, now ${JSON.stringify(t)}`),e.applied=wo(e.root,o,t))},l=function(){const e=i(this,n,"f");e.debounceTimer&&clearTimeout(e.debounceTimer),e.unsubscribePauseListener&&e.unsubscribePauseListener(),e.root&&Fs.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)})),o(this,n,ia(),"f")},c})),sa="project-id",aa="flow-id",la=e=>{const t=(e=>{const t=e.getAttribute(sa),n=e.getAttribute(aa);return t&&n?Array.from(e.ownerDocument.querySelectorAll("descope-wc")).filter((e=>e.getAttribute(sa)===t&&e.getAttribute(aa)===n)):[]})(e);return t.length>1&&t[0]!==e},ca=l((e=>{var t,n,s,a;const l=r(Nr)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}connectedCallback(){var e;null===(e=super.connectedCallback)||void 0===e||e.call(this),i(this,t,"m",s).call(this)}attributeChangedCallback(e,n,o){var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),n===o||e!==sa&&e!==aa||i(this,t,"m",s).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){queueMicrotask((()=>{if(!this.isConnected)return;const e=this.getAttribute(sa),t=this.getAttribute(aa),r=`${e}|${t}`;i(this,n,"f")!==r&&la(this)&&(o(this,n,r,"f"),this.logger.warn("Multiple Descope flow components detected on the same page",`The same flow ("${t}") and project ("${e}") are running more than once on this page. This is not supported and may cause the flow to behave unexpectedly.`))}))},a})),da=["externalId","email","phone"],ua=["newPassword","password"],ha="data-username-anchor",pa=e=>{var t;if(!e)return"";try{const n=null===(t=window.sessionStorage)||void 0===t?void 0:t.getItem(Ni);if(!n)return"";const i=JSON.parse(n);return i.executionId===e&&i.loginId||""}catch(e){return""}},ga=(e,t,n,i)=>{var o;const r=(null==n?void 0:n.email)||(null===(o=null==n?void 0:n.loginIds)||void 0===o?void 0:o[0]);(e=>e.querySelector("descope-new-password")||e.querySelector("descope-password"))(t)?r?(e=>{const t=['input[autocomplete="username"]',...da.map((e=>`[name="${e}"]`))].join(", ");return e.some((e=>e.querySelector(t)))})([e,t])?i.debug("Username anchor: screen already has an identifier field"):(i.debug("Username anchor: injecting hidden username input"),e.appendChild((e=>{const t=document.createElement("input");return t.setAttribute("autocomplete","username"),t.setAttribute("name","username"),t.setAttribute("type","email"),t.setAttribute("readonly","true"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-hidden","true"),t.setAttribute(Pi,"true"),t.setAttribute(ha,"true"),t.setAttribute("value",e),t.value=e,Object.assign(t.style,{position:"absolute",opacity:"0",pointerEvents:"none",height:"0",border:"0"}),t})(r))):i.debug("Username anchor: no user identifier available"):i.debug("Username anchor: no password component on screen")},fa=l((e=>{var t,n,s,a,l;const c=r(Nr)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}updateScreenUser(e){var r,l,c;o(this,n,{email:null==e?void 0:e.email,loginIds:(null===(r=null==e?void 0:e.loginIds)||void 0===r?void 0:r.length)?e.loginIds:[pa(i(this,t,"a",a))||(null===(c=null===(l=i(this,t,"a",s).sdk)||void 0===l?void 0:l.getLastUserLoginId)||void 0===c?void 0:c.call(l))].filter(Boolean)},"f")}updateUsernameAnchor(){document.querySelectorAll(`[${ha}="true"]`).forEach((e=>e.remove())),ga(this,i(this,t,"a",s).contentRootElement,i(this,n,"f"),this.logger)}captureLastSubmittedLoginId(e={},n){const o=tr(e,da);o&&((e,t)=>{var n;if(e&&t)try{null===(n=window.sessionStorage)||void 0===n||n.setItem(Ni,JSON.stringify({executionId:t,loginId:e}))}catch(e){}})(o,n||i(this,t,"a",a))}storeCredentials(e={}){var t,o,r,s,a,l;const c=tr(e,da)||(null===(t=i(this,n,"f"))||void 0===t?void 0:t.email)||(null===(r=null===(o=i(this,n,"f"))||void 0===o?void 0:o.loginIds)||void 0===r?void 0:r[0]),d=tr(e,ua);if(c&&d)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:c,password:d});null===(l=null===(a=null===(s=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===s?void 0:s.store)||void 0===a?void 0:a.call(s,e))||void 0===l||l.catch((e=>{this.logger.debug("Could not store credentials",null==e?void 0:e.message)}))}catch(e){this.logger.warn("Could not store credentials",e.message)}}},n=new WeakMap,t=new WeakSet,s=function(){return this},a=function(){var e,n;return(null===(n=null===(e=i(this,t,"a",s).flowState)||void 0===e?void 0:e.current)||void 0===n?void 0:n.executionId)||""},l})),va="data-evp-token",ma='descope-email-field[email-verification="true"]',ba=e=>{e.querySelectorAll(`[${va}]`).forEach((e=>e.remove()))},wa=l((e=>{var t,s,a,l,c,d,u;const h=r(Nr)(e);return u=class extends h{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,!1),l.set(this,0),c.set(this,(e=>{(e=>e.composedPath().some((e=>e instanceof Element&&e.matches(ma))))(e)&&(o(this,a,"focusin"===e.type,"f"),"focusout"===e.type&&o(this,l,Date.now(),"f"))}))}clearEmailVerification(){o(this,s,void 0,"f"),o(this,a,!1,"f"),o(this,l,0,"f"),ba(this)}startEmailVerification(e){var n,r,a;const l=null===(n=i(this,t,"a",d).sdk)||void 0===n?void 0:n.emailVerification;if(!(l&&(()=>{var e,t;return!!(null===(t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands)||void 0===t?void 0:t.some((({brand:e})=>"Google Chrome"===e)))})()&&(u=e,u.querySelector(ma))&&this.closest("form")))return;var u;null===(r=this.shadowRoot)||void 0===r||r.addEventListener("focusin",i(this,c,"f")),null===(a=this.shadowRoot)||void 0===a||a.addEventListener("focusout",i(this,c,"f"));const h=l.start().then((e=>{var t,n;e.ok&&(null===(t=e.data)||void 0===t?void 0:t.nonce)?i(this,s,"f")===h&&((e,t)=>{const n=document.createElement("input");n.type="hidden",n.setAttribute("autocomplete","email-verification-token"),n.setAttribute(Pi,"true"),n.setAttribute(va,"true"),n.nonce=t,n.setAttribute("nonce",t),e.appendChild(n)})(this,e.data.nonce):this.logger.warn("Email verification start failed",null===(n=e.error)||void 0===n?void 0:n.errorDescription)})).catch((e=>{this.logger.warn("Email verification start failed",null==e?void 0:e.message)}));o(this,s,h,"f")}emailVerificationToken(e){return n(this,void 0,void 0,(function*(){var t,n;if("true"===e.getAttribute("formnovalidate")||!this.querySelector(`[${va}]`)||!(null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(ma))||void 0===n?void 0:n.value))return"";i(this,a,"f")&&(()=>{var e;let t=document.activeElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.activeElement;)t=t.shadowRoot.activeElement;t instanceof HTMLElement&&t.blur()})();const o=i(this,l,"f")+900-Date.now();o>0&&(yield new Promise((e=>{setTimeout(e,o)})));const r=(e=>{const t=e.querySelector(`[${va}]`),n=e.closest("form");if(!t||!n)return"";let i="";const o=e=>{e.target===n&&(e.preventDefault(),e.stopImmediatePropagation(),i=t.value,t.value="")};window.addEventListener("submit",o,!0);const{noValidate:r}=n;n.noValidate=!0;try{n.requestSubmit()}finally{n.noValidate=r,window.removeEventListener("submit",o,!0)}return i})(this);return r&&ba(this),r}))}},s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,d=function(){return this},u})),ya=e=>`${e.screenId}|${e.field}|${e.rule}`,ka=()=>{try{return crypto.randomUUID()}catch(e){return`${Date.now()}-${Math.round(1e9*Math.random())}`}},Ia=l((e=>{var t,n,s,a,l,c,d,u,h,p,g,f,v,m,b,w,y,k,I,S;const C=r(Nr)(e);return S=class extends C{constructor(){super(...arguments),t.add(this),n.set(this,[]),s.set(this,void 0),a.set(this,void 0),l.set(this,new Set),c.set(this,!1),d.set(this,0),u.set(this,void 0),h.set(this,!1),p.set(this,(()=>i(this,t,"m",w).call(this,!1))),g.set(this,(()=>{"hidden"===document.visibilityState&&i(this,t,"m",w).call(this,!0)})),f.set(this,(()=>i(this,t,"m",w).call(this,!0)))}setValidationTrackingEnabled(e){i(this,h,"f")!==e&&(o(this,h,e,"f"),e||i(this,t,"m",b).call(this))}setValidationTrackingSender(e){o(this,u,e,"f")}setValidationTrackingExecution(e){i(this,h,"f")&&e&&i(this,n,"f").length&&(o(this,s,e,"f"),i(this,t,"m",w).call(this,!1))}trackValidationErrors(e,n){var o,r;try{i(this,t,"m",v).call(this,e,n)}catch(e){null===(r=null===(o=this.logger)||void 0===o?void 0:o.debug)||void 0===r||r.call(o,"Failed to track validation errors",String(e))}}teardownValidationTracking(){i(this,t,"m",w).call(this,!1),o(this,d,i(this,d,"f")+1,"f"),i(this,l,"f").forEach(clearTimeout),i(this,l,"f").clear(),i(this,c,"f")&&(o(this,c,!1,"f"),this.removeEventListener("screen-updated",i(this,p,"f")),this.removeEventListener("success",i(this,p,"f")),this.removeEventListener("error",i(this,p,"f")),document.removeEventListener("visibilitychange",i(this,g,"f")),window.removeEventListener("pagehide",i(this,f,"f")))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,p=new WeakMap,g=new WeakMap,f=new WeakMap,t=new WeakSet,v=function(e,r){if(!i(this,h,"f")||!(null==e?void 0:e.length))return;const a=r||{};i(this,t,"m",I).call(this),e.forEach((e=>{if(i(this,n,"f").length>=20)return;const r=((e,t)=>{var n;const i=null===(n=null==e?void 0:e.getAttribute)||void 0===n?void 0:n.call(e,"name");return i?{id:ka(),field:i,rule:(o=e.validity,r=e.type,o?o.badInput?"bad-input":o.valueMissing?"required":o.typeMismatch?"email"===r||"url"===r?r:"type-mismatch":o.patternMismatch?"pattern":o.tooShort?"too-short":o.tooLong?"too-long":o.rangeUnderflow||o.rangeOverflow||o.stepMismatch?"range":o.customError?"custom":"unknown":"unknown"),message:e.validationMessage||"",screenId:t.screenId||"",screenName:t.screenName||"",ts:Date.now()}:null;var o,r})(e,a);if(!r)return;const l=ya(r);i(this,n,"f").some((e=>ya(e)===l))||(i(this,n,"f").push(r),o(this,s,a.executionId||i(this,s,"f"),"f"),i(this,n,"f").length>=20&&i(this,t,"m",w).call(this,!1))})),i(this,n,"f").length>=20?i(this,t,"m",w).call(this,!1):i(this,t,"m",m).call(this)},m=function(){clearTimeout(i(this,a,"f")),o(this,a,setTimeout((()=>i(this,t,"m",w).call(this,!1)),2e3),"f")},b=function(){clearTimeout(i(this,a,"f")),o(this,d,i(this,d,"f")+1,"f"),i(this,l,"f").forEach(clearTimeout),i(this,l,"f").clear(),o(this,n,[],"f"),o(this,s,void 0,"f")},w=function(e){var r,l;if(clearTimeout(i(this,a,"f")),!i(this,n,"f").length)return void o(this,s,void 0,"f");if(!i(this,s,"f"))return;if(!i(this,u,"f"))return;const c=i(this,n,"f"),h=i(this,s,"f");o(this,n,[],"f"),o(this,s,void 0,"f");try{const n={executionId:h,events:c};e?i(this,u,"f").call(this,n,{keepalive:!0}).catch((()=>{})):i(this,t,"m",y).call(this,n,2,i(this,d,"f"))}catch(e){null===(l=null===(r=this.logger)||void 0===r?void 0:r.debug)||void 0===l||l.call(r,"Failed to send validation events",String(e))}},y=function(e,n,o){i(this,u,"f").call(this,e,{keepalive:!1}).then((r=>{!r.ok&&r.retryable&&n>0&&i(this,t,"m",k).call(this,e,n,o)})).catch((()=>{n>0&&i(this,t,"m",k).call(this,e,n,o)}))},k=function(e,n,o){if(o!==i(this,d,"f"))return;const r=setTimeout((()=>{i(this,l,"f").delete(r),o===i(this,d,"f")&&i(this,t,"m",y).call(this,e,n-1,o)}),800*(2-n+1));i(this,l,"f").add(r)},I=function(){i(this,c,"f")||(o(this,c,!0,"f"),this.addEventListener("screen-updated",i(this,p,"f")),this.addEventListener("success",i(this,p,"f")),this.addEventListener("error",i(this,p,"f")),document.addEventListener("visibilitychange",i(this,g,"f")),window.addEventListener("pagehide",i(this,f,"f")))},S}));var Sa,Ca,Oa,xa,Aa,Ea,ja,Ra,Ua,Ta,$a,La,Pa,Wa,Ma,Na,_a,Da,qa,Fa,Va,Ja,Ha,Ka,za,Ba,Ga;const Za=r(ys,Xr,xs,ra,ca,fa,wa,ds,Cs,Ia)(HTMLElement);class Xa extends Za{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","send-session-token","style-id"]}get adoptedSsoQueryParams(){return i(this,Aa,"f")}constructor(e){super(),Sa.add(this),this.sdkVersion="4.7.5",Oa.set(this,!1),xa.set(this,void 0),Aa.set(this,null),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,Sa,"m",Ga).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)}},Ea.set(this,new fr),ja.set(this,new fr),Ra.set(this,{}),this.getComponentsContext=()=>i(this,Ra,"f"),this.nextRequestStatus=new fr({isLoading:!1}),Ua.set(this,void 0),Ta.set(this,{popstate:i(this,Sa,"m",Ma).bind(this),componentsContext:i(this,Sa,"m",Va).bind(this)}),$a.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),Ja.set(this,void 0),Ha.set(this,void 0),o(this,$a,e,"f"),i(this,Sa,"m",Pa).call(this)}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}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 sendSessionToken(){return"true"===this.getAttribute("send-session-token")}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return Os(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return e=this.formConfig,t="value",Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]])));var e,t}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const e=JSON.parse(this.getAttribute("outbound-app-scopes"));return e||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return i(this,xa,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");o(this,xa,e,"f"),(e=>{Ar=e})(e)}get lazyStart(){return"true"===this.getAttribute("lazy-start")}start(){var e;null===(e=i(this,Ha,"f"))||void 0===e||e.call(this),o(this,Ja,Promise.resolve(),"f")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=co.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||e.defaultPrevented||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig(),n="projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{};return n||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),i(this,ja,"f").subscribe(i(this,Sa,"m",Ba).bind(this)),i(this,ja,"f").update({isDebug:this.debug}),i(this,Sa,"m",Wa).call(this),yield i(this,Sa,"m",qa).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");const{executionId:r,stepId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:g,ssoQueryParams:f,adoptedSsoQueryParams:v}=Bo(this.flowId,this.projectId,this.loggerWrapper);o(this,Aa,null!=v?v:null,"f"),window.addEventListener("popstate",i(this,Ta,"f").popstate),window.addEventListener("components-context",i(this,Ta,"f").componentsContext),i(this,Ea,"f").subscribe(i(this,Sa,"m",Da).bind(this)),i(this,Ea,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:g},f)),o(this,Oa,!0,"f")}))}disconnectedCallback(){var e;i(this,Ea,"f").unsubscribeAll(),i(this,ja,"f").unsubscribeAll(),i(this,Sa,"m",za).call(this),window.removeEventListener("popstate",i(this,Ta,"f").popstate),window.removeEventListener("components-context",i(this,Ta,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,t,n){var o;if(null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,e,t,n),this.shadowRoot.isConnected&&i(this,Oa,"f")&&t!==n&&Ca.observedAttributes.includes(e)){i(this,Sa,"m",Wa).call(this);const o=null===t;i(this,Ea,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Jo()),{[zo(e)]:n,stepId:r,executionId:s}})),i(this,ja,"f").update({isDebug:this.debug})}}}var Qa,Ya,el,tl,nl,il,ol,rl,sl,al,ll,cl,dl,ul,hl,pl,gl,fl,vl,ml,bl,wl,yl,kl,Il,Sl,Cl,Ol,xl,Al,El,jl,Rl,Ul,Tl,$l,Ll,Pl,Wl,Ml,Nl,_l,Dl,ql,Fl,Vl;Ca=Xa,Oa=new WeakMap,xa=new WeakMap,Aa=new WeakMap,Ea=new WeakMap,ja=new WeakMap,Ra=new WeakMap,Ua=new WeakMap,Ta=new WeakMap,$a=new WeakMap,Ja=new WeakMap,Ha=new WeakMap,Sa=new WeakSet,La=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},Pa=function(){i(this,Sa,"m",La).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Wa=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","send-session-token","style-id","outbound-app-id","outbound-app-scopes","theme-override"];Ca.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[zo(t)])throw Error(`${t} cannot be empty`)}))},Ma=function(){const{stepId:e,executionId:t}=Vo(this.flowId);t&&i(this,Ea,"f").update({stepId:e,executionId:t})},Na=function(e,t){Si&&"function"==typeof Si||this.logger.error("SDK was not loaded properly",Si,JSON.stringify(Si));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},Ca.sdkConfigOverrides),{projectId:e,baseUrl:t});i(this,xa,"f")&&(o.customStorage=i(this,xa,"f")),this.sdk=Si(o);const r={start:1,next:7};["start","next"].forEach((e=>{const t=function(e,t,i){return(...o)=>n(this,void 0,void 0,(function*(){let n;const r=i+1;for(let s=0;s<r;s++)try{return yield e(...o)}catch(e){n=e,s<i&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw n}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...o)=>n(this,void 0,void 0,(function*(){const n=[...o],s=r[e],a=i(this,Sa,"m",_a).call(this,n[s]);void 0!==a&&(n[s]=a);try{return yield t(...n)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:Oi,errorDescription:t.toString()}}}}))}));const s=this.sdk.flow.start;this.sdk.flow.start=(...e)=>n(this,void 0,void 0,(function*(){return yield i(this,Sa,"m",Ka).call(this),s.apply(this.sdk.flow,e)}))},_a=function(e){if(!this.sendSessionToken)return e;const t=null==Rn?void 0:Rn(this.storagePrefix);return t?Object.assign(Object.assign({},null!=e?e:{}),{sessionJwt:t}):e},Da=function(e,t,o){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(o("projectId")||o("baseUrl")){if(!t)return;i(this,Sa,"m",Na).call(this,t,n)}i(this,$a,"f").call(this,e)}))},qa=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,Sa,"m",Fa).call(this))}))},Fa=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(Ei||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t](),headers:Object.fromEntries(n.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},Va=function(e){o(this,Ra,Object.assign(Object.assign({},i(this,Ra,"f")),e.detail),"f")},Ka=function(){return this.lazyStart?(i(this,Ja,"f")||o(this,Ja,new Promise((e=>{o(this,Ha,e,"f")})),"f"),i(this,Ja,"f")):Promise.resolve()},za=function(){var e;null===(e=i(this,Ua,"f"))||void 0===e||e.remove(),o(this,Ua,null,"f")},Ba=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,Ua,document.createElement("descope-debugger"),"f"),Object.assign(i(this,Ua,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return kc})),document.body.appendChild(i(this,Ua,"f"))):i(this,Sa,"m",za).call(this)}))},Ga=function(e,t){var n;e&&this.debug&&(null===(n=i(this,Ua,"f"))||void 0===n||n.updateData({title:e,description:t}))},Xa.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.7.5"}};const Jl="__descope_webauthn_timed_out__";class Hl extends Xa{static set sdkConfigOverrides(e){Xa.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Xa.sdkConfigOverrides}constructor(){const e=new fr({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),Qa.add(this),this.stepState=new fr({}),Ya.set(this,void 0),el.set(this,null),tl.set(this,null),nl.set(this,{visibilitychange:i(this,Qa,"m",il).bind(this)}),this.bridgeVersion=Hl.bridgeVersion,ol.set(this,void 0),this.nativeCallbacks={},hl.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},fl.set(this,(e=>{e&&this.clearEmailVerification();const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?i(this,Qa,"m",vl).call(this,t):t()})),ml.set(this,((e,t,r,s,a=!1)=>{const l=[xi,"E103202",Ai];if(this.flowState.current.action===no){if(i(this,wl,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;o(this,Ya,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,o;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,lo,r,s,{}),h=document.hidden&&!a&&Date.now()-c>d+500;let p;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;p=yield Xo(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,ml,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===Oi)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,ml,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==p?void 0:p.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(p.error,null,4)),(null===(o=null==p?void 0:p.error)||void 0===o?void 0:o.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):i(this,ml,"f").call(this,e,t,r,s),i(this,yl,"f").call(this,p)}))),d),"f")}})),bl.set(this,(()=>{clearTimeout(i(this,Ya,"f")),o(this,Ya,null,"f")})),wl.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),yl.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,g,f;if(!(null==e?void 0:e.ok)){const o=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;i(this,Qa,"m",Fl).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||o,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||c);const d=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==d&&d!==xi&&d!==Ai||!this.isRestartOnError||i(this,Qa,"m",ul).call(this))}null===(d=null===(c=e.data)||void 0===c?void 0:c.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const v=null===(p=null===(h=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(g=e.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:b,lastAuth:w,action:y,openInNewTabUrl:k}=e.data;if(y!==no&&i(this,bl,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&$r(Object.assign(Object.assign({},w),{lastUsedPerScreen:Lr()})),Pr(this.loggerWrapper);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),this.setValidationTrackingExecution(e.data.executionId),Mo(this.projectId,this.flowId),void i(this,Qa,"m",Fl).call(this,"success",t)}this.storeLastAuthenticatedUser&&$r(w,!0),k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:C,screen:O,redirect:x,webauthn:A,error:E,samlIdpResponse:j,wsFedIdpResponse:R,nativeResponse:U}=e.data,T=Date.now();y!==no?(this.loggerWrapper.info(`Step "${C||`#${S}`}" is ${m}`,"",{screen:O,status:m,stepId:S,stepName:C,action:y,error:E}),(null===(f=O.state)||void 0===f?void 0:f.clientScripts)&&o(this,tl,this.loadSdkScripts(O.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:C,executionId:I,action:y,redirectTo:null==x?void 0:x.url,redirectIsPopup:null==x?void 0:x.isPopup,screenId:null==O?void 0:O.id,screenState:null==O?void 0:O.state,webauthnTransactionId:null==A?void 0:A.transactionId,webauthnOptions:null==A?void 0:A.options,samlIdpResponseUrl:null==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.relayState,wsFedIdpResponseUrl:null==R?void 0:R.url,wsFedIdpResponseWresult:null==R?void 0:R.wresult,wsFedIdpResponseWctx:null==R?void 0:R.wctx,nativeResponseType:null==U?void 0:U.type,nativePayload:null==U?void 0:U.payload,reqTimestamp:T})):this.flowState.update({action:y,reqTimestamp:T})})),kl.set(this,Go((()=>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)}}))))),Ol.set(this,void 0),xl.set(this,void 0),Tl.set(this,null),Wl.set(this,nr(((e,t,o)=>n(this,void 0,void 0,(function*(){var n,r;if("true"!==e.getAttribute("loading")&&"true"!==e.getAttribute("disabled")){if("true"===e.getAttribute("formnovalidate")||i(this,Qa,"m",Rl).call(this)){const s=null==e?void 0:e.getAttribute("id");i(this,Qa,"m",_l).call(this,e,s,o);const a=i(this,Qa,"m",$l).call(this,e);try{const o=yield i(this,Qa,"m",Ul).call(this),a=(r=e,Array.from((null==r?void 0:r.attributes)||[]).reduce(((e,t)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return i?Object.assign(e,{[i]:t.value}):e}),{}));this.nextRequestStatus.update({isLoading:!0});const l=yield this.emailVerificationToken(e),c=Object.assign(Object.assign(Object.assign(Object.assign({},a),o),{origin:i(this,Qa,"a",jl)}),l&&{evpToken:l}),d=yield t(s,c);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(o,null===(n=null==d?void 0:d.data)||void 0===n?void 0:n.executionId),this.storeCredentials(o)}catch(e){throw a(),e}}}else this.loggerWrapper.debug("Submit already in flight, ignoring")}))))),this.flowState=e,this.setValidationTrackingSender(((e,t)=>n(this,[e,t],void 0,(function*({executionId:e,events:t},{keepalive:n}){const i=yield this.sdk.flow.event(e,t,n);return{ok:i.ok,retryable:i.code>=500||429===i.code}}))))}nativeResume(e,t){var n,o,r,s,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const i=new URL(c.url);t=null===(n=i.searchParams)||void 0===n?void 0:n.get(Ui),e=(null===(o=i.searchParams)||void 0===o?void 0:o.get($i))||void 0}null===(s=(r=this.nativeCallbacks).complete)||void 0===s||s.call(r,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(c.url),t=e.searchParams.get("t"),n=e.searchParams.get(Ri).split("_").pop();i(this,bl,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=c;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=c,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(l=(a=this.nativeCallbacks).complete)||void 0===l||l.call(a,c)}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:{[lr(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=e=>n(this,void 0,void 0,(function*(){var n,i,o;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}(null===(i=globalThis.descope)||void 0===i?void 0:i[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.22",`dist/${e.id}.js`));const s=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((n,i)=>{try{const i=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,n),this.loggerWrapper);if(i){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=i,this.shadowRoot.appendChild(t);const o=this.nextRequestStatus.subscribe((()=>{var n;this.loggerWrapper.debug("Stopping script",e.id),(null===(n=i.stop)||void 0===n?void 0:n.call(i))&&(this.nextRequestStatus.unsubscribe(o),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}));"function"==typeof i.present&&n(e.id)}}catch(e){i(e)}}))})),o=Promise.all((null!=e?e:[]).map((e=>i(e).catch((t=>(this.loggerWrapper.warn(`Sdk script ${e.id} failed to load, continuing without it`,null==t?void 0:t.message),null))))));let r;const s=new Promise((e=>{r=setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([o,s]).finally((()=>clearTimeout(r))).catch((e=>(this.loggerWrapper.warn("Sdk scripts failed to load, continuing without them",null==e?void 0:e.message),null)))}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){var e,t;if(!window.descopeBridge)return this._init();this.lazyInit=this._init,o(this,ol,null===(t=null===(e=null===window||void 0===window?void 0:window.descopeBridge)||void 0===e?void 0:e.registerFlow)||void 0===t?void 0:t.call(e,this),"f")}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),i(this,Qa,"m",cl).call(this),window.addEventListener("visibilitychange",i(this,nl,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e,t,n;super.disconnectedCallback(),this.teardownValidationTracking(),i(this,ol,"f")&&(null===(t=null===(e=window.descopeBridge)||void 0===e?void 0:e.unregisterFlow)||void 0===t||t.call(e,i(this,ol,"f")),o(this,ol,void 0,"f")),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),i(this,bl,"f").call(this),null===(n=i(this,el,"f"))||void 0===n||n.abort(),o(this,el,null,"f"),this.clearEmailVerification(),window.removeEventListener("visibilitychange",i(this,nl,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=v(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:g,screenId:f,screenState:m,redirectTo:b,redirectIsPopup:w,redirectUrl:y,token:k,code:I,isPopup:S,exchangeError:C,webauthnTransactionId:O,webauthnOptions:x,redirectAuthCodeChallenge:A,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:R,locale:U,samlIdpResponseUrl:T,samlIdpResponseSamlResponse:$,samlIdpResponseRelayState:L,wsFedIdpResponseUrl:P,wsFedIdpResponseWresult:W,wsFedIdpResponseWctx:M,nativeResponseType:N,nativePayload:_,reqTimestamp:D}=e,q=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let F,V,J;s("executionId")&&p&&Po(qo(p),xo(q),c,d);const H=(()=>{const e=jr(Rr);if(!e){const e=Math.floor(100*Math.random()+1);return Er(Rr,e.toString()),e}return Number(e)})(),{outboundAppId:K,outboundAppScopes:z}=this,B=this.sdk.getLastUserLoginId();s("flowId")&&this.setValidationTrackingEnabled(!1);const G=yield this.getFlowConfig();i(this,Qa,"m",Al).call(this,G,p,s);const Z=yield this.getProjectConfig(),X=Object.entries(Z.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Q=E&&A?{callbackUrl:E,codeChallenge:A,backupCallbackUri:j}:void 0,Y=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let ee={};if(!p){Pr(this.loggerWrapper);const e=[...G.clientScripts||[],...G.sdkScripts||[]];if(G.conditions){let t=[];({startScreenId:F,conditionInteractionId:J,startScreenName:V,clientScripts:t,componentsConfig:ee}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:i})=>{var o;if("ELSE"===t)return!0;const r=null===(o=Ur[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:B,code:I,token:k,abTestingKey:H,lastAuth:Tr(B,this.loggerWrapper)},G.conditions)),e.push(...t||[])}else G.condition?({startScreenId:F,startScreenName:V,conditionInteractionId:J}=((e,t)=>{var n;const i=null===(n=Ur[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!i)return{};const o=i(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(G.condition,{loginId:B,code:I,token:k,abTestingKey:H,lastAuth:Tr(B,this.loggerWrapper)})):(V=G.startScreenName,F=G.startScreenId);if(o(this,Ol,F,"f"),o(this,xl,V,"f"),o(this,tl,this.loadSdkScripts(e),"f"),G.fingerprintEnabled&&G.fingerprintKey?yield _n(G.fingerprintKey,this.baseUrl):gn(Mn),!Qo(F,q)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Q},q),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:Tr(B,this.loggerWrapper),abTestingKey:H,locale:v(U).locale,nativeOptions:Y,outboundAppId:K,outboundAppScopes:z}),J,"",Z.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:i(this,Qa,"a",jl)},this.formConfigValues),I?{exchangeCode:I,idpInitiated:!0}:{}),q.descopeIdpInitiated&&{idpInitiated:!0}),k?{token:k}:{}),q.oidcLoginHint?{externalId:q.oidcLoginHint}:{}));return i(this,yl,"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(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:S,code:I,exchangeError:C,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),S&&(s("code")&&I||s("exchangeError")&&C))return void i(this,Qa,"m",Vl).call(this,p,I,C);if(p&&(s("token")&&k||s("code")&&I||s("exchangeError")&&C)){const e=yield this.sdk.flow.next(p,h,ao,G.version,Z.componentsVersion,{token:k,exchangeCode:I,exchangeError:C,origin:i(this,Qa,"a",jl)});return i(this,yl,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===so&&T&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!$)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(Yo("SAMLResponse",t,"saml-response")),o.appendChild(Yo("RelayState",n,"saml-relay-state")),document.body.appendChild(o),i(o)})(T,$,L||"",er)}if(g===so&&P&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>s(e)))){if(!W)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(Yo("wa","wsignin1.0")),o.appendChild(Yo("wresult",t)),o.appendChild(Yo("wctx",n)),document.body.appendChild(o),i(o)})(P,W,M||"",er)}if(g===to&&(s("redirectTo")||s("deferredRedirect"))){if(!b)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===b)return;if("android"===R&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${w}`),w){this.loggerWrapper.debug("Opening redirect in popup");const e=cr(b,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));let n=!1;const o=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const i=t?this.popupOrigin:window.location.origin;if(e.origin!==i)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${i}"`);const{action:o,data:r}=e.data||{};"code"===o&&(n=!0,this.flowState.update({code:r.code,exchangeError:r.exchangeError}))};let r;this.loggerWrapper.debug("Starting popup closed detection");const s=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(s),i(this,Qa,"m",Fl).call(this,"popupclosed",{abandoned:!n}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==r||r())}),1e3);if(t)window.addEventListener("message",o),r=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",o)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=o,r=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else((e,t,n,i,o)=>{var r;if(null==n?void 0:n.oidcErrorRedirectUri){try{const t=new URL(e,window.location.href),i=new URL(n.oidcErrorRedirectUri);if(t.origin!==i.origin||t.pathname!==i.pathname)return}catch(e){return}Mo(i,o);try{t&&(null===(r=$o())||void 0===r||r.removeItem(To(t)))}catch(e){}}})(b,qo(p),Object.assign(Object.assign({},this.adoptedSsoQueryParams),xo(q)),c,d),this.handleRedirect(b),this.flowState.update({redirectTo:"no-op"}),i(this,Qa,"m",Fl).call(this,"popupclosed",{});return}if(g===io||g===oo){if(!O||!x)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");null===(l=i(this,el,"f"))||void 0===l||l.abort(),o(this,el,null,"f");const e=yield i(this,Qa,"m",gl).call(this,g,x),t=yield this.sdk.flow.next(p,h,ao,G.version,Z.componentsVersion,Object.assign({transactionId:O},e));i(this,yl,"f").call(this,t)}if(g===ro)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,ao,G.version,Z.componentsVersion,e);i(this,yl,"f").call(this,t)})),i(this,Qa,"m",al).call(this,N,_),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&i(this,ml,"f").call(this,p,h,G.version,Z.componentsVersion),!f&&!F)return void this.loggerWrapper.warn("No screen was found to show");const te=F||f,ne=yield this.getHtmlFilenameWithLocale(U,te),{oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,samlIdpUsername:ae}=q,le={direction:Fo(h,r.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:B,name:this.sdk.getLastUserDisplayName()||B},componentsConfig:Object.assign(Object.assign(Object.assign({},G.componentsConfig),ee),null==m?void 0:m.componentsConfig)}),htmlFilename:`${te}.html`,htmlLocaleFilename:ne,screenId:te,stepName:e.stepName||V,samlIdpUsername:ae,oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,action:g,locale:v(U).locale},ce=Tr(B,this.loggerWrapper);Qo(F,q)?le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==G?void 0:G.clientScripts)||[];yield i(this,Qa,"m",Ml).call(this,n);const o=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Q},q),{lastAuth:ce,preview:this.preview,abTestingKey:H,client:this.client}),y&&{redirectUrl:y}),{locale:v(U).locale,nativeOptions:Y,outboundAppId:K,outboundAppScopes:z}),J,e,Z.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:i(this,Qa,"a",jl)},this.formConfigValues),this.getComponentsContext()),ar(t)),I&&{exchangeCode:I,idpInitiated:!0}),q.descopeIdpInitiated&&{idpInitiated:!0}),k&&{token:k}),le.next.isCustomScreen);return i(this,yl,"f").call(this,o),o})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==m?void 0:m.clientScripts)||[];yield i(this,Qa,"m",Ml).call(this,n);const o=yield this.sdk.flow.next(p,h,e,G.version,Z.componentsVersion,Object.assign(Object.assign({origin:i(this,Qa,"a",jl)},this.getComponentsContext()),ar(t)),le.next.isCustomScreen);return i(this,yl,"f").call(this,o),o}))),this.loggerWrapper.debug("Got a screen with id",le.screenId),yield i(this,Qa,"m",pl).call(this,le),this.stepState.update(le)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r,s;const{htmlFilename:a,htmlLocaleFilename:l,direction:c,next:d,screenState:u,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen"),this.clearEmailVerification(),this.updateScreenUser(null==u?void 0:u.user);const p=document.createElement("template");p.innerHTML=yield this.getPageContent(a,l);const g=p.content.cloneNode(!0),f=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield i(this,Qa,"m",Sl).call(this,g,d):g.querySelectorAll(`descope-button[${eo}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(o=u.form)||void 0===o?void 0:o.loginId)||(null===(r=u.form)||void 0===r?void 0:r.email)||(u.form||(u.form={}),u.form.loginId=e.samlIdpUsername,u.form.email=e.samlIdpUsername),Cr(g,u,this.formConfig,this.loggerWrapper),this.applyComponentsState(g,null==u?void 0:u.componentsState),this.startEmailVerification(g);const{geo:v}=null!==(s=yield this.getExecutionContext())&&void 0!==s?s:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([n,i])=>{Array.from(e.querySelectorAll(`[${n}="${i}"]`)).forEach((e=>{e.setAttribute(n,t||i)}))}))})(g,v),((e,t)=>{let n=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(n=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`[${t}="${i}"]`)).forEach((e=>{e.setAttribute(t,n||i)}))}))})(g,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,o;yield f;const r=this.contentRootElement;var s,a;s=r,a=null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image,Sr(s,"descope-totp-image",a),((e,t)=>{Sr(e,"descope-notp-image",t)})(r,null===(o=null==u?void 0:u.notp)||void 0===o?void 0:o.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{if(!t.querySelector(o))return void i.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,g,u.cssVars,this.loggerWrapper),r.replaceChildren(g);const l=!t.htmlFilename;setTimeout((()=>{i(this,Qa,"m",Ll).call(this),this.updateUsernameAnchor(),this.validateOnBlur&&((e,t)=>{e.querySelectorAll("*[name]").forEach((n=>{n.addEventListener("blur",(()=>{var i;if(fo(n,e))return;const o=()=>{var e;const i=n.focus;n.focus=()=>{};const o=null===(e=n.reportValidity)||void 0===e?void 0:e.call(n);t&&!1===o&&t(n),setTimeout((()=>{n.focus=i}))};if("true"===n.getAttribute("invalid")||(null===(i=n.value)||void 0===i?void 0:i.length))return void o();const r={timer:void 0},s=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(r.timer),r.timer=void 0)};r.timer=setTimeout((()=>{e.removeEventListener("click",s),o(),r.timer=void 0}),150),e.addEventListener("click",s,{once:!0})}))}))})(r,(e=>this.trackValidationErrors([e],i(this,Qa,"a",El)))),((e,t)=>{br(e,null==t?void 0:t.inputs),br(e,null==t?void 0:t.form)})(r,u),this.initRealtimeConditions(r,u),i(this,Qa,"m",Cl).call(this,{isFirstScreen:l,isCustomScreen:!1,stepName:e.stepName}),Zo(r,this.autoFocus,l),i(this,Qa,"m",Dl).call(this,h)})),i(this,Qa,"m",ql).call(this,d,h);r.querySelector(`[${eo}="polling"]`)&&d(lo,{})}));c?i(this,Qa,"m",vl).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${Pi}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}Ya=new WeakMap,el=new WeakMap,tl=new WeakMap,nl=new WeakMap,ol=new WeakMap,hl=new WeakMap,fl=new WeakMap,ml=new WeakMap,bl=new WeakMap,wl=new WeakMap,yl=new WeakMap,kl=new WeakMap,Ol=new WeakMap,xl=new WeakMap,Tl=new WeakMap,Wl=new WeakMap,Qa=new WeakSet,il=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},rl=function(e,t,o){return n(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=n,i(this,Qa,"m",al).call(this,"beforeScreen",{screen:e,context:t})}))}))},sl=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,Qa,"m",al).call(this,"afterScreen",{screen:e})},al=function(e,t){i(this,Qa,"m",Fl).call(this,"bridge",{type:e,payload:t})},ll=function({errorText:e,errorType:t}){const n=()=>{var n;let i=e;try{i=(null===(n=this.errorTransformer)||void 0===n?void 0:n.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${eo}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",i)};this.addEventListener("screen-updated",n,{once:!0}),n()},cl=function(){var e,n,o,r;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=void 0===n?{}:n,{errorText:o,errorType:r}=i,s=t(i,["errorText","errorType"]),a=t(e,["screenState"]);return Object.assign(Object.assign({},a),{screenState:s})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,Qa,"m",ll).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(i(this,Qa,"m",dl).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(r=this.flowState)||void 0===r||r.subscribe((({screenId:e,executionId:t})=>{var n;try{this.updateTelemetryContext({screenId:e,executionId:t})}catch(e){null===(n=this.logger)||void 0===n||n.error("Error updating telemetry screenId:",e)}}),(e=>({screenId:e.screenId,executionId:e.executionId})))},dl=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Zo(this.contentRootElement,this.autoFocus,!1))},ul=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(Object.assign({stepId:null,executionId:null},this.adoptedSsoQueryParams))):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},pl=function(e){return n(this,void 0,void 0,(function*(){var n;const r=Object.assign(Object.assign({},this.stepState.current),e),{next:s,stepName:a}=r,l=t(r,["next","stepName"]),c=sr(l);let d=yield i(this,Qa,"m",rl).call(this,a,c,s);d||(d=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,c,s,this)));const u=!this.stepState.current.htmlFilename;if(i(this,fl,"f").call(this,d),s&&(s.isCustomScreen=d),i(this,hl,"f")!==d){const[e,t]=["flow","custom"].sort((()=>d?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,hl,d,"f"),d?this.stepState.unsubscribeAll():i(this,Qa,"m",cl).call(this)}d?(this.loggerWrapper.debug("Showing a custom screen"),i(this,Qa,"m",Cl).call(this,{isFirstScreen:u,isCustomScreen:d,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=d}))},gl=function(e,t){return n(this,void 0,void 0,(function*(){const n=new AbortController;try{const i=e===io?this.sdk.webauthn.helpers.create(t,n):this.sdk.webauthn.helpers.get(t,n),o=yield Xo(9e4,i,Jl);return o!==Jl?{response:o}:(n.abort(),this.loggerWrapper.warn("WebAuthn operation timed out after 90000ms"),{failure:"AbortError",failureReason:"aborted",failureMessage:"Passkey operation timed out"})}catch(e){return"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),{failure:e.name,failureReason:e.reason,failureMessage:e.message}}}))},vl=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")},Il=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)}))}},Sl=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,el,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Or())){const{options:e,transactionId:r}=(yield i(this,kl,"f").call(this))||{};e&&r&&(i(this,Qa,"m",Il).call(this,s),o(this,el,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,el,"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)})))}}))},Cl=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,Qa,"m",Fl).call(this,"ready",{}),t||i(this,Qa,"m",sl).call(this,n),i(this,Qa,"m",Fl).call(this,"page-updated",{screenName:n}),i(this,Qa,"m",Fl).call(this,"screen-updated",{screenName:n})},Al=function(e,t,n){this.setValidationTrackingEnabled(!!e.clientValidationTrackingEnabled),t&&n("executionId")&&this.setValidationTrackingExecution(t)},El=function(){var e,t,n,o,r,s,a;const l=null===(e=this.flowState)||void 0===e?void 0:e.current;return(null==l?void 0:l.executionId)?{executionId:l.executionId,screenId:l.screenId,screenName:(null===(a=null===(s=this.stepState)||void 0===s?void 0:s.current)||void 0===a?void 0:a.stepName)||l.stepName}:{executionId:void 0,screenId:null!==(t=i(this,Ol,"f"))&&void 0!==t?t:null==l?void 0:l.screenId,screenName:null!==(n=i(this,xl,"f"))&&void 0!==n?n:(null===(r=null===(o=this.stepState)||void 0===o?void 0:o.current)||void 0===r?void 0:r.stepName)||(null==l?void 0:l.stepName)}},jl=function(){var e;return(null===(e=this.nativeOptions)||void 0===e?void 0:e.origin)||window.location.origin},Rl=function(){let e=!0;const t=[];return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((n=>{var i,o,r;"slot"===n.localName||fo(n,this.contentRootElement)||(null===(i=n.reportValidity)||void 0===i||i.call(n),n.validity&&!n.validity.valid&&t.push(n),e&&(e=null===(r=null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))||void 0===r||r))})),t.length&&this.trackValidationErrors(t,i(this,Qa,"a",El)),e},Ul=function(){return n(this,void 0,void 0,(function*(){const e=this.getInputs();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})),{})}))},$l=function(e){var t,r;const s=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),a=(null===(r=null===(t=this.flowState.current)||void 0===t?void 0:t.screenState)||void 0===r?void 0:r.clientScripts)||[];e.setAttribute("loading","true"),s.forEach((e=>e.setAttribute("disabled","true")));const l=()=>{e.removeAttribute("loading"),s.forEach((e=>{e.removeAttribute("disabled")}))},c=e=>n(this,void 0,void 0,(function*(){var t;this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",c);if(!0===(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.abandoned)&&a.length)return o(this,tl,(()=>n(this,void 0,void 0,(function*(){try{yield this.loadSdkScripts(a)}catch(e){this.loggerWrapper.warn("Failed to refresh client scripts on popup close",null==e?void 0:e.message)}})))(),"f"),void l();l();const i=yield this.getFlowConfig(),r=[...i.clientScripts||[],...i.sdkScripts||[]];this.loadSdkScripts(r)})),d=()=>{var e;window.removeEventListener("pageshow",i(this,Tl,"f")),o(this,Tl,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),c())}),"f"),window.addEventListener("pageshow",i(this,Tl,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&c(),this.removeEventListener("popupclosed",c),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},u=this.nextRequestStatus.subscribe((({isLoading:e})=>{e?this.addEventListener("popupclosed",c,{once:!0}):(this.nextRequestStatus.unsubscribe(u),"success"===this.flowStatus?(this.removeEventListener("popupclosed",c),l()):d())}));return l},Ll=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,Qa,"m",Pl).call(this,e)))},Pl=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),i=`input-${e.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),e.appendChild(o),t.setAttribute("slot",i),this.appendChild(t)}))},Ml=function(e){return n(this,void 0,void 0,(function*(){if(i(this,tl,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,tl,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),n=e.map((e=>e.id));for(const e of t)if(n.includes(e.id))try{if("function"==typeof e.present){(yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`)}}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const o=[];for(const e of t)"function"==typeof e.refresh&&o.push(e.refresh());if(o.length>0)try{yield Xo(5e3,Promise.all(o),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Nl=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var o;(null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))&&i(this,Wl,"f").call(this,n,e,t)}))}))},_l=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=Lr();n[e]=t,Er(uo,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},Dl=function(e){var t;const n=null===(t=Tr(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const i=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);i&&o&&(o.replaceWith(i),i.appendChild(o))},ql=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${Wi}]), [data-type="button"]:not([${Wi}]`).forEach((n=>{n.onclick=()=>{i(this,Wl,"f").call(this,n,e,t)}})),i(this,Qa,"m",Nl).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Pi}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Fl=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},Vl=function(e,t,n){var i;const[o,r]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],s="descope-wc"===o&&!!r,a=s?Ko(r):void 0;s&&!a&&this.loggerWrapper.warn("Popup opener origin is not approved for this project, add it to the approved domains to send the OAuth result to it",r);const l={data:{code:t,exchangeError:n},action:"code"};if(a){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",a);try{window.opener.postMessage(l,a)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(l),t.close()}try{window.close()}catch(e){}},Hl.bridgeVersion=3,customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Hl);const Kl=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};var zl,Bl,Gl,Zl,Xl,Ql,Yl,ec,tc,nc;const ic=document.createElement("template");ic.innerHTML='\n<div class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n';const oc=r(ds)(HTMLElement);let rc=class extends oc{constructor(){var e;super(),zl.add(this),Bl.set(this,new g({messages:[]})),Gl.set(this,void 0),Zl.set(this,void 0),Xl.set(this,void 0),Ql.set(this,{resize:i(this,zl,"m",nc).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(ic.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),o(this,Gl,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Gl,"f").style.top="32px",i(this,Gl,"f").style.left=window.innerWidth-300-32+"px",o(this,Zl,i(this,Gl,"f").querySelector(".content"),"f"),o(this,Xl,i(this,Gl,"f").querySelector(".header"),"f")}updateData(e){i(this,Bl,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Kl(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,Gl,"f"),i(this,Xl,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Ql,"f").resize),(e=i(this,Gl,"f")).onmousemove=t=>{var n;const i=t.target;(i.w&&i.w!==i.offsetWidth||i.h&&i.h!==i.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),i.w=i.offsetWidth,i.h=i.offsetHeight},i(this,Gl,"f").onresize=i(this,zl,"m",tc).bind(this),i(this,Bl,"f").subscribe(i(this,zl,"m",Yl).bind(this))}disconnectedCallback(){i(this,Bl,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Ql,"f").resize)}};Bl=new WeakMap,Gl=new WeakMap,Zl=new WeakMap,Xl=new WeakMap,Ql=new WeakMap,zl=new WeakSet,Yl=function(e){i(this,zl,"m",ec).call(this,e),i(this,zl,"m",tc).call(this)},ec=function(e){i(this,Zl,"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 ${f(e.title)}\n </div>\n <div class="msg_desc">\n ${f(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},tc=function(){i(this,Zl,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),i=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;i||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},nc=function(){const[e,t]=Kl(i(this,Gl,"f"),Number.parseInt(i(this,Gl,"f").style.left,10),Number.parseInt(i(this,Gl,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Gl,"f").style.top=`${t}px`,i(this,Gl,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",rc);var sc,ac,lc,cc,dc,uc,hc,pc,gc,fc,vc,mc=Object.freeze({__proto__:null});const bc=document.createElement("template");bc.innerHTML='\n<div class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n';const wc=r(ds)(HTMLElement);class yc extends wc{constructor(){super(),sc.add(this),ac.set(this,new fr({messages:[]})),lc.set(this,void 0),cc.set(this,void 0),dc.set(this,void 0),uc.set(this,{resize:i(this,sc,"m",vc).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(bc.content.cloneNode(!0)),o(this,lc,this.shadowRoot.querySelector(".debugger"),"f"),o(this,cc,i(this,lc,"f").querySelector(".content"),"f"),o(this,dc,i(this,lc,"f").querySelector(".header"),"f"),i(this,sc,"m",hc).call(this)}updateData(e){i(this,ac,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;null===(t=e.init)||void 0===t||t.call(this),((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=xr(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,lc,"f"),i(this,dc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,uc,"f").resize),(n=i(this,lc,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&n.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},i(this,lc,"f").onresize=i(this,sc,"m",fc).bind(this),i(this,ac,"f").subscribe(i(this,sc,"m",pc).bind(this))}))}disconnectedCallback(){i(this,ac,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,uc,"f").resize)}}ac=new WeakMap,lc=new WeakMap,cc=new WeakMap,dc=new WeakMap,uc=new WeakMap,sc=new WeakSet,hc=function(){this.injectStyle('\n .debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),i(this,lc,"f").style.top="32px",i(this,lc,"f").style.left=window.innerWidth-300-32+"px"},pc=function(e){i(this,sc,"m",gc).call(this,e),i(this,sc,"m",fc).call(this)},gc=function(e){i(this,cc,"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 ${f(e.title)}\n </div>\n <div class="msg_desc">\n ${f(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},fc=function(){i(this,cc,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,i=t.clientHeight>20;n||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},vc=function(){const[e,t]=xr(i(this,lc,"f"),Number.parseInt(i(this,lc,"f").style.left,10),Number.parseInt(i(this,lc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,lc,"f").style.top=`${t}px`,i(this,lc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",yc);var kc=Object.freeze({__proto__:null,default:yc})}();
|
|
1
|
+
!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function n(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((i=i.apply(e,t||[])).next())}))}function i(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function o(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=(e={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),(e=>"string"==typeof e?e:"boolean"==typeof e?String(e):(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(n))})),t},l=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const i=e(n);return i[t]=!0,i}};var c,d,u,h;function p(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!p(r,s))return!1}else if(r!==s)return!1}return!0}let g=class{constructor(e={},{forceUpdate:t=!1}={}){c.set(this,void 0),d.set(this,{}),u.set(this,0),h.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,c,"f")):e,n=Object.assign(Object.assign({},i(this,c,"f")),t);if(i(this,h,"f")||!p(i(this,c,"f"),n)){const e=i(this,c,"f");o(this,c,n,"f"),Object.freeze(i(this,c,"f")),setTimeout((()=>{Object.values(i(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,c,e,"f"),o(this,h,t,"f")}get current(){return Object.assign({},i(this,c,"f"))}subscribe(e){return o(this,u,i(this,u,"f")+1,"f"),i(this,d,"f")[i(this,u,"f")]=e,i(this,u,"f").toString()}unsubscribe(e){const t=!!i(this,d,"f")[e];return t&&delete i(this,d,"f")[e],t}unsubscribeAll(){return o(this,d,{},"f"),!0}};c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap;const f=e=>String(null!=e?e:"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");function v(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:""}}class m extends Error{}function b(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 w(e,t){if("string"!=typeof e)throw new m("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,i=e.split(".")[n];if("string"!=typeof i)throw new m(`Invalid token specified: missing part #${n+1}`);let o;try{o=b(i)}catch(e){throw new m(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new m(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}m.prototype.name="InvalidTokenError";var y={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",phone:"/v1/auth/enchantedlink/update/phone"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},sso:{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"},emailVerification:{start:"/v1/auth/emailverification/start"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-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",event:"/v1/flow/event"}};const k="<region>",I=`https://api.${k}descope.com`,S=6e5,C=()=>{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},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},O=[503,520,521,522,524,530],x=[100,5e3,5e3],A=e=>new Promise((t=>setTimeout(t,e))),E=e=>async function(...t){let n=await e(...t);const i=!!(null==(o=t[1])?void 0:o.disableRetry);var o;let r=0;for(;!i&&O.includes(n.status)&&r<x.length;)await A(x[r]),n=await e(...t),r++;r>0&&(n.retries=r);const s=await n.text();return n.text=()=>Promise.resolve(s),n.json=()=>Promise.resolve(JSON.parse(s)),n.clone=()=>n,n},j=(e,t)=>{const 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 function(...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=>C().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await E(n)(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return C().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(i)),i}:E(n)};let R;const U=()=>{if(R)return R;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 R=`${t}-${n}`,R};var T;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(T||(T={}));const $=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(k,o?o+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,i)=>{r=`${r}${0===i?"?":""}${t}=${encodeURIComponent(n[t])}${i===e.length-1?"":"&"}`}))}return r},L=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),P={"Content-Type":"application/json"},W=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},M=(e,t)=>{const n={"x-descope-sdk-session-id":U(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.79.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},N=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var _=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||I,c=j(o,a),d=async e=>{var o;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:g,token:f,keepalive:v,disableRetry:m}=a,b=(e=>void 0===e?void 0:JSON.stringify(e))(u),w=Object.assign(Object.assign({headers:L(W(t,f),M(t,i),(null==n?void 0:n.baseHeaders)||{},N(b)?P:{},h),method:g,body:b},v?{keepalive:!0}:{}),m?{disableRetry:!0}:{});null!==s&&(w.credentials=s||"include");const y=await c($({path:d,baseUrl:l,queryParams:p,projectId:t}),w);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==y?void 0:y.clone()),null==r?void 0:r.transformResponse){const e=await y.json(),t=(k=(null===(o=y.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function i(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function o(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,l=!1;for(;i();)if(","===e.charAt(n)){for(s=n,n+=1,i(),a=n;n<e.length&&o();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(r,e.length))}return t}(k).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.create(null),{json:()=>Promise.resolve(e),cookies:t}),i=new Proxy(y,{get:(e,t)=>{if(t in n)return n[t];const i=e[t];return"function"==typeof i?i.bind(e):i},set:(e,t,i)=>(n[t]=i,!0),has:(e,t)=>t in n||t in e});return n.clone=()=>i,r.transformResponse(i)}var k;return y};return{get:(e,{headers:t,queryParams:n,token:i,keepalive:o,disableRetry:r}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:T.get,token:i,keepalive:o,disableRetry:r}),post:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:i,body:t,method:T.post,token:o,keepalive:r,disableRetry:s}),patch:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:i,body:t,method:T.patch,token:o,keepalive:r,disableRetry:s}),put:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:i,body:t,method:T.put,token:o,keepalive:r,disableRetry:s}),delete:(e,{headers:t,queryParams:n,token:i,keepalive:o,disableRetry:r}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:T.delete,token:i,keepalive:o,disableRetry:r}),hooks:r,buildUrl:(e,n)=>$({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},D=429;function q(e,t,n){var i;let o=F(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o.dct)===t)return(null==o?void 0:o[n])||[];o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[t]}const r=null==o?void 0:o[n];return Array.isArray(r)?r:[]}function F(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return w(e)}function V(e){const{exp:t}=F(e);return(new Date).getTime()/1e3>t}function J(e){let t=F(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function H(e,t){return q(e,t,"permissions")}function K(e,t){return q(e,t,"roles")}const z=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function B(e,t){var n,i;const o=await e,r={code:o.status,ok:o.ok,response:o},s=await o.clone().json();if(o.ok)r.data=s;else{r.error=s,o.status===D&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0});const e=null===(i=o.headers)||void 0===i?void 0:i.get("cf-ray");e&&r.error&&Object.assign(r.error,{traceId:e})}return r}function G(e){var t;return(null===(t=F(e))||void 0===t?void 0:t.dct)||""}const Z=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),X=(e,t)=>(n=t)=>t=>{const i=e.filter((e=>e(t)));return!(i.length<e.length)&&(n?n.replace("{val}",t):i.join(" OR "))},Q=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Y=e=>t=>e.test(t),ee=Y(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),te=Y(/^\+[1-9]{1}[0-9]{3,14}$/),ne=Z(ee,'"{val}" is not a valid email'),ie=Z(te,'"{val}" is not a valid phone number'),oe=Z((e=>e.length>=1),"Minimum length is 1");const re=Z((e=>"string"==typeof e),"Input is not a string"),se=Z((e=>Array.isArray(e)),"Input is not an array"),ae=Z((e=>"boolean"==typeof e),"Input is not a boolean"),le=Z((e=>void 0===e),"Input is defined"),ce=X([re(),le()],"Input is not a string or undefined"),de=X([se(),ae()],"Input is not an array or boolean"),ue=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Q(...e).validate(n[t]))),t(...n)),he=e=>[re(`"${e}" must be a string`)],pe=e=>[ce(`"${e}" must be string or undefined`)],ge=e=>[re(`"${e}" must be a string`),oe(`"${e}" must not be empty`)],fe=e=>[re(`"${e}" must be a string`),ne()],ve=e=>[re(`"${e}" must be a string`),ie()],me=ue(ge("accessKey")),be=e=>({exchange:me(((t,n)=>B(e.post(y.accessKey.exchange,{loginOptions:n},{token:t}))))}),we=(e,t,n)=>(t.forEach((t=>{const i=t.split(".");let o=i.shift(),r=e;for(;i.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof r[o])throw Error(`"${t}" is not a function`);const s=r[o];r[o]=n(s)})),e),ye=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||S,S)});var ke,Ie;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(ke||(ke={})),function(e){e.email="email"}(Ie||(Ie={}));const Se=Object.assign(Object.assign({},ke),Ie);var Ce;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Ce||(Ce={}));const Oe=ge("loginId"),xe=ue(ge("token")),Ae=ue(Oe),Ee=ue(ge("pendingRef")),je=ue(Oe,ve("phone")),Re=ue(Oe,fe("email")),Ue=e=>{const n=n=>(i,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return B(e.post(z(y.enchantedLink.signIn,n),{loginId:i,URI:o,loginOptions:l,providerId:a},{token:s}))},i=n=>(i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(z(y.enchantedLink.signUpOrIn,n),{loginId:i,URI:o,loginOptions:a,providerId:s}))},o=n=>(i,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return B(e.post(z(y.enchantedLink.signUp,n),{loginId:i,URI:o,user:r,loginOptions:l,providerId:a}))};return{verify:xe((t=>B(e.post(y.enchantedLink.verify,{token:t})))),signIn:Ae(n(Se.email)),signInWithPhone:Ae(n(ke.sms)),signUpOrIn:Ae(i(Se.email)),signUpOrInWithPhone:Ae(i(ke.sms)),signUp:Ae(o(Se.email)),signUpWithPhone:Ae(o(ke.sms)),waitForSession:Ee(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=ye(n);let s;const a=setInterval((async()=>{const n=await e.post(y.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(B(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Re(((t,n,i,o,r)=>B(e.post(y.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:{sms:je(((t,n,i,o,r)=>B(e.post(z(y.enchantedLink.update.phone,ke.sms),Object.assign({loginId:t,phone:n,URI:i},r),{token:o}))))}}}},Te=ue(ge("flowId")),$e=ue(ge("executionId"),ge("stepId"),ge("interactionId")),Le=ue(ge("executionId")),Pe=e=>({start:Te(((t,n,i,o,r,s,a,l=!1)=>B(e.post(y.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:$e(((t,n,i,o,r,s,a=!1,l)=>B(e.post(y.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s,isCustomScreen:a,options:l})))),event:Le(((t,n,i)=>B(e.post(y.flow.event,{executionId:t,events:n},{keepalive:i,disableRetry:!0}))))}),We=ge("loginId"),Me=ue(ge("token")),Ne=ue(We);ue(ge("pendingRef"));const _e=ue(We,ve("phone")),De=ue(We,fe("email")),qe=Object.keys(Se).filter((e=>e!==ke.voice&&e!==ke.im)),Fe=e=>({verify:Me((t=>B(e.post(y.magicLink.verify,{token:t})))),signIn:qe.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Ne(((n,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return B(e.post(z(y.magicLink.signIn,i),{loginId:n,URI:o,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:qe.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Ne(((n,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return B(e.post(z(y.magicLink.signUp,i),{loginId:n,URI:o,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:qe.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Ne(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(z(y.magicLink.signUpOrIn,i),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:De(((t,n,i,o,r)=>B(e.post(y.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(ke).filter((e=>e!==ke.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:_e(((t,i,o,r,s)=>B(e.post(z(y.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var Ve;!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"}(Ve||(Ve={}));const Je=ue(ge("code")),He=e=>({start:Object.assign(((t,n,i,o,r)=>B(e.post(y.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(Ve).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>B(e.post(y.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:Je((t=>B(e.post(y.oauth.exchange,{code:t})))),startNative:(t,n,i)=>B(e.post(y.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>B(e.post(y.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>B(e.get(y.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>B(e.post(y.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>B(e.post(y.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),Ke=ge("appId"),ze=ue(Ke),Be=e=>({connect:ze(((t,n,i)=>{const o=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,B(e.post(y.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:n},{token:i}))}))}),Ge=ge("loginId"),Ze=ue(Ge,ge("code")),Xe=ue(Ge),Qe=ue(Ge,ve("phone")),Ye=ue(Ge,fe("email")),et=e=>({verify:Object.keys(Se).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ze(((t,i)=>B(e.post(z(y.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(Se).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Xe(((n,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return B(e.post(z(y.otp.signIn,i),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Se).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Xe(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(z(y.otp.signUp,i),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Se).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Xe(((n,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return B(e.post(z(y.otp.signUpOrIn,i),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:Ye(((t,n,i,o)=>B(e.post(y.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(ke).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Qe(((t,i,o,r)=>B(e.post(z(y.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),tt=ue(ge("tenant")),nt=ue(ge("code")),it=e=>({start:tt(((t,n,i,o,r,s,a,l)=>B(e.post(y.sso.start,i||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},o&&{token:o}))))),exchange:nt((t=>B(e.post(y.sso.exchange,{code:t}))))}),ot=ge("loginId"),rt=ue(ot,ge("code")),st=ue(ot),at=ue(ot),lt=e=>({signUp:st(((t,n)=>B(e.post(y.totp.signUp,{loginId:t,user:n})))),verify:rt(((t,n,i,o)=>B(e.post(y.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:at(((t,n)=>B(e.post(y.totp.update,{loginId:t},{token:n}))))}),ct=e=>({start:()=>B(e.post(y.emailVerification.start,{}))}),dt=ge("loginId"),ut=ge("newPassword"),ht=ue(dt,ge("password")),pt=ue(dt),gt=ue(dt,ut),ft=ue(dt,ge("oldPassword"),ut),vt=e=>({signUp:ht(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return B(e.post(y.password.signUp,{loginId:n,password:i,user:o,loginOptions:a,providerId:s}))})),signIn:ht(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return B(e.post(y.password.signIn,{loginId:n,password:i,loginOptions:s,providerId:r}))})),sendReset:pt(((t,n,i)=>B(e.post(y.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:gt(((t,n,i)=>B(e.post(y.password.update,{loginId:t,newPassword:n},{token:i})))),replace:ft(((t,n,i)=>B(e.post(y.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>B(e.get(y.password.policy))}),mt=he("loginId"),bt=ge("loginId"),wt=he("origin"),yt=ue(bt,wt,ge("name")),kt=ue(bt,wt),It=ue(mt,wt),St=ue(bt,wt,pe("token")),Ct=ue(ge("transactionId"),ge("response")),Ot=e=>({signUp:{start:yt(((t,n,i,o,r)=>B(e.post(y.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,loginOptions:r,passkeyOptions:o})))),finish:Ct(((t,n)=>B(e.post(y.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:It(((t,n,i,o,r)=>B(e.post(y.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:Ct(((t,n)=>B(e.post(y.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:kt(((t,n,i,o)=>B(e.post(y.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i}))))},update:{start:St(((t,n,i,o,r)=>B(e.post(y.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o,mfa:r},{token:i})))),finish:Ct(((t,n)=>B(e.post(y.webauthn.update.finish,{transactionId:t,response:n}))))}}),xt=he("loginId"),At=ue(xt),Et=ue(ge("pendingRef")),jt=e=>({signUpOrIn:At(((n,i={})=>{var{providerId:o}=i,r=t(i,["providerId"]);return B(e.post(y.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:o}))})),signUp:At(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return B(e.post(y.notp.signUp,{loginId:n,user:i,providerId:r,loginOptions:s}))})),signIn:At(((n,i={},o)=>{var{providerId:r}=i,s=t(i,["providerId"]);return B(e.post(y.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:o}))})),waitForSession:Et(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=ye(n);let s;const a=setInterval((async()=>{const n=await e.post(y.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(B(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Rt=ue(ge("token")),Ut=ue(pe("token")),Tt=e=>{const t={};return(null==e?void 0:e.ssoLogout)&&(t.ssoLogout=!0),(null==e?void 0:e.redirectUrl)&&(t.redirectUrl=e.redirectUrl),t};var $t,Lt=ue([($t=ge("projectId"),Z(((e,t)=>n=>Q(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=n.length;let o=0,r=e===Object(e)?e:void 0;for(;null!=r&&o<i;)r=r[n[o++]];return o&&o===i&&void 0!==r?r:void 0})(n,e)))("projectId",$t))())])((e=>{const{projectId:t,logger:n,baseUrl:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=_({baseUrl:i,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:be(l),otp:et(l),magicLink:Fe(l),enchantedLink:Ue(l),oauth:He(l),outbound:Be(l),sso:it(l),saml:it(l),totp:lt(l),notp:jt(l),webauthn:Ot(l),password:vt(l),flow:Pe(l),emailVerification:ct(l),refresh:Ut(((e,t,n,i)=>{const o={};n&&(o.externalToken=n);const r=i?y.tryRefresh:y.refresh;return B(l.post(r,o,{token:e,queryParams:t}))})),selectTenant:ue([re("tenantId")],[ce('"token" must be string or undefined')])(((e,t)=>B(l.post(y.selectTenant,{tenant:e},{token:t})))),logout:Ut(((e,t)=>B(l.post(y.logout,Tt(t),{token:e})))),logoutAll:Ut(((e,t)=>B(l.post(y.logoutAll,Tt(t),{token:e})))),me:Ut((e=>B(l.get(y.me,{token:e})))),myTenants:ue([de('"tenants" must a string array or a boolean')],[ce('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,B(l.post(y.myTenants,n,{token:t}))})),history:Ut((e=>B(l.get(y.history,{token:e})))),isJwtExpired:Rt(V),getTenants:Rt(J),getJwtPermissions:Rt(H),getJwtRoles:Rt(K),getCurrentTenant:Rt(G),httpClient:l};var l})),Pt=Object.assign(Lt,{DeliveryMethods:Se});
|
|
2
|
+
/*! js-cookie v3.0.8 | MIT */function Wt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)"__proto__"!==i&&(e[i]=n[i])}return e}var Mt=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=Wt({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(a in i||(i[a]=t.read(s,a)),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",Wt({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,Wt({},this.attributes,t))},withConverter:function(t){return e(Wt({},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 Nt={default:"endpoint"},_t="Blocked by CSP",Dt="The endpoint parameter is not a valid URL",qt="Failed to load the JS script of the agent",Ft="9319";function Vt(e,t){var n,i,o,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===_t||s===Dt)n.exclude(),r=0;else if(s===Ft)n.exclude();else if(s===qt){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var Jt="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Ht=Jt;function Kt(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:Jt,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return Vt(e,zt)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Ft?new Error(qt):e}(e)})).then((function(t){var n=t[0],i=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function zt(e){return function(e,t,n){var i,o=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(Dt);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(qt))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(_t)})).then(Bt)}function Bt(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==i?void 0:i.configurable)?delete e[t]:i&&!i.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(Ft);return n}const Gt="3.2.0",Zt="undefined"!=typeof window,Xt=Math.pow(2,31)-1,Qt=2e4,Yt=`https://descopecdn.com/npm/oidc-client-ts@${Gt}/dist/browser/oidc-client-ts.min.js`,en=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Gt}/dist/browser/oidc-client-ts.min.js`,tn=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let nn;const on=e=>{try{return w(e).exp}catch(e){return null}},rn=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:on(n)},sn=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?on(i):void 0)},an=e=>{const{access_token:n,id_token:i,refresh_token:o,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:i,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||sn(e),cookieExpiration:e.cookieExpiration||rn(e)},s)},ln=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[i])||[]).concat((null==t?void 0:t[i])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},cn=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return an(n)},dn=()=>Zt&&!!window.descopeBridge,un=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return tn.includes(n)},hn=void 0!==nn||Zt&&void 0!==window.localStorage,pn=(e,t)=>{var n,i;return null===(i=null===(n=nn||Zt&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},gn=e=>{var t,n;return null===(n=null===(t=nn||Zt&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},fn=e=>{var t,n;return null===(n=null===(t=nn||Zt&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},vn=e=>{var t,n,i,o,r;return null!==(r=null!==(n=null===(t=null==nn?void 0:nn.key)||void 0===t?void 0:t.call(nn,e))&&void 0!==n?n:Zt&&(null===(o=null===(i=window.localStorage)||void 0===i?void 0:i.key)||void 0===o?void 0:o.call(i,e)))&&void 0!==r?r:null},mn=e=>{var t,n;return Zt&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},bn=e=>{var t,n;try{Zt&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},wn=(...e)=>{console.debug(...e)},yn=(...e)=>{console.warn(...e)},kn=e=>e?e.getTime()-(new Date).getTime():0,In="DS",Sn="DSR",Cn="DSI",On="DSRCN";function xn(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=An(i);Mt.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:r,secure:a})}}function An(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const En=e=>(null==e?void 0:e.cookieName)||In,jn=e=>(null==e?void 0:e.cookieName)||Sn;function Rn(e="",t){return Mt.get(jn(t))||gn(`${e}${Sn}`)||""}function Un(e="",t){return Mt.get(En(t))||gn(`${e}${In}`)||""}function Tn(e=""){return gn(`${e}${Cn}`)||""}function $n(e="",t,n,i){fn(`${e}${Sn}`),fn(`${e}${In}`),fn(`${e}${Cn}`),fn(`${e}${On}`);const o=En(t);Mt.remove(o,null==i?void 0:i.session);const r=jn(n);Mt.remove(r,null==i?void 0:i.refresh)}const Ln=(e,t,n)=>i=>{const o=Object.assign(i,{token:i.token||Rn(e,t)});if(!n){const t=function(e=""){return gn(`${e}${On}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return gn(`${e}DTD`)||""}(e);r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":r}));const s=function(e=""){return gn(`${e}DKD`)||""}(e);return s&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-known-device-token":s})),o},Pn=Zt&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Wn="vsid",Mn="vrid",Nn="fp",_n=(e=!1)=>{const t=gn(Nn);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Dn=async(e,t=Pn)=>{try{if(_n())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=Kt({apiKey:e,endpoint:[i.toString(),Nt],scriptUrlPattern:[r,Ht]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Wn]:e,[Mn]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};pn(Nn,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},qn=e=>{const t=_n(!0);return t&&e.body&&(e.body.fpData=t),e},Fn="descopeFlowNonce",Vn="X-Descope-Flow-Nonce",Jn="/v1/flow/start",Hn="/v1/flow/next",Kn=(e,t=Fn)=>`${t}${e}`,zn=(e,t=Fn)=>{try{const n=Kn(e,t),i=gn(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(Bn(e,t),null):{value:o.value,seq:o.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},Bn=(e,t=Fn)=>{try{const n=Kn(e,t);fn(n)}catch(e){console.error("Error removing flow nonce:",e)}},Gn=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Zn=e=>{var t;return e.path===Hn&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Gn(e.body.executionId):null},Xn="dls_last_user_login_id",Qn="dls_last_user_display_name",Yn=e=>pn(Xn,e),ei=()=>gn(Xn),ti=()=>gn(Qn),ni=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=ei(),r=ti();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)},ii="DSLI",oi=e=>async(...t)=>{const n=await e(...t);return bn(ii),n};function ri(){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 si(e,t){const n=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=pi(n.publicKey.challenge),n.publicKey.user.id=pi(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=pi(e.id)})),n}(e);t&&(n.signal=t.signal);try{return i=await navigator.credentials.create(n),JSON.stringify({id:i.id,rawId:gi(i.rawId),type:i.type,authenticatorAttachment:null!==(o=i.authenticatorAttachment)&&void 0!==o?o:void 0,response:{attestationObject:gi(i.response.attestationObject),clientDataJSON:gi(i.response.clientDataJSON)}})}catch(e){throw await ci(e,n,!0)}var i,o}async function ai(e,t){const n=ui(e);t&&(n.signal=t.signal);try{return hi(await navigator.credentials.get(n))}catch(e){throw await ci(e,n,!1)}}async function li(e,t){const n=ui(e);n.signal=t.signal,n.mediation="conditional";try{return hi(await navigator.credentials.get(n))}catch(e){throw await ci(e,n,!1)}}async function ci(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var i,o;const r=null==e?void 0:e.name;if("AbortError"===r&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===r&&n)return"authenticator_already_registered";if("NotSupportedError"===r)return"no_supported_algorithm";if("ConstraintError"===r)return"authenticator_constraints_unsupported";if("SecurityError"===r){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await di())return"webauthn_unsupported";const s="platform"===(null===(o=null===(i=null==t?void 0:t.publicKey)||void 0===i?void 0:i.authenticatorSelection)||void 0===o?void 0:o.authenticatorAttachment);return n&&s&&!await di(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function di(e=!1){var t,n;if(!Zt)return Promise.resolve(!1);if(dn()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const i=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return i&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():i}function ui(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=pi(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=pi(e.id)})),n}function hi(e){var t;return JSON.stringify({id:e.id,rawId:gi(e.rawId),type:e.type,authenticatorAttachment:null!==(t=e.authenticatorAttachment)&&void 0!==t?t:void 0,response:{authenticatorData:gi(e.response.authenticatorData),clientDataJSON:gi(e.response.clientDataJSON),signature:gi(e.response.signature),userHandle:e.response.userHandle?gi(e.response.userHandle):void 0}})}function pi(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function gi(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var fi,vi=(fi=e=>({async signUp(t,n,i){const o=await e.webauthn.signUp.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await si(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,n){const i=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await ai(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(t,n){var i;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const t=await si(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await ai(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,i){const o=await e.webauthn.update.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await si(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:si,get:ai,isSupported:di,conditional:li}}),(...e)=>{const t=fi(...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 mi="/fedcm/config";async function bi(e,t){var n;try{await wi(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function wi(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=(()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)})(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void d()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var yi=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await di(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});let ki;const Ii=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Ii(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Si=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{ki||(ki=(async()=>{try{return require("oidc-client-ts")}catch(e){return Ii([Yt,en],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await ki;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new i(d),stateUserKey:l}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),pn(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(t={},n=!1)=>{var o;const{client:r}=await i(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:r}=await i(),s=(e=>{const t=gn(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||Tn(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return fn(o),t||window.location.replace(s),r}}},Ci=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,nn=n,e(t)}),(e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return Zt?(i&&o&&Dn(i).catch((()=>null)),e(ln(r,{beforeRequest:qn}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.55.0"},t.baseHeaders)}))),(e=>t=>{const n=ri(),i=ri(),o=ri(),r=ri(),s=e(ln(t,{afterRequest:async(e,t)=>{if(un(e,t))wn("Session invalidated, notifying subscribers with empty values"),i.pub(null),o.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await cn(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await cn(t);s&&i.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=we(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:i.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var i;const{enableFlowNonce:o=!0,nonceStoragePrefix:r=Fn}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!o)return e(s);((e=Fn)=>{try{if(!hn)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(i=null!==(t=null==nn?void 0:nn.length)&&void 0!==t?t:Zt&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==i?i:0);o++){const t=vn(o);if(t&&t.startsWith(e)){const n=gn(t);if(n)try{JSON.parse(n).expiry<Date.now()&&fn(t)}catch(e){fn(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,i})(r);const a=e(ln(s,{afterRequest:async(e,t)=>{var n;if(e.path!==Jn&&e.path!==Hn)return;const{nonce:i,seq:o,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(Vn),i=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const i=Number(n);return Number.isSafeInteger(i)?i:void 0})(n);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=Zn(e)),{nonce:n,seq:i,executionId:Gn(o)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!i||!s)return;const a=e.path===Jn,l=null===(n=zn(s,r))||void 0===n?void 0:n.seq;!a&&void 0!==o&&void 0!==l&&o<=l||((e,t,n,i=Fn,o)=>{try{const r=Kn(e,i),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:o};pn(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,i,a,r,null!=o?o:a?void 0:l)},beforeRequest:e=>{if(e.path===Hn){const t=Zn(e);if(t){const n=((e,t=Fn)=>{var n,i;return null!==(i=null===(n=zn(e,t))||void 0===n?void 0:n.value)&&void 0!==i?i:null})(t,r);n&&(e.headers=e.headers||{},e.headers[Vn]=n)}}return e}}));if(null===(i=a.flow)||void 0===i?void 0:i.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const i=e;let o;e=new Promise((e=>{o=e})),await i;try{return await t(...n)}finally{o()}}}return a}),(e=>t=>{const n=e(ln(t,{afterRequest:async(e,t)=>{if(un(e,t))return void bn(ii);const n=await cn(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,i;try{Zt&&(null===(i=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i||i.call(n,e,t))}catch(e){}})(ii,String(n.sessionExpiration))}}));return we(n,["logout","logoutAll","oidc.logout"],oi)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);const r=!!i,s="object"==typeof i&&(null==i?void 0:i.customActivityTracking);if(!r||dn())return Object.assign(e(o),{markUserActive:()=>{yn("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;s&&(wn("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Zt&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(wn("Expiration time passed, refreshing session"),f())}));const g=e(ln(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o,nextRefreshSeconds:r}=await cn(t);if(un(e,t))wn("Session invalidated, canceling all timers"),a(),c=void 0;else if(n||o){if(c=((e,t)=>{if(t)return new Date(1e3*t);wn("Could not extract expiration time from session token, trying to decode the token");try{const t=w(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!c)return void wn("Could not extract expiration time from session token");d=i,h=r>0;let e=((e,t)=>{let n;return t>0?(n=1e3*t,wn(`Using provided nextRefreshSeconds: ${t}s`)):n=kn(e)-Qt,n>Xt&&(wn(`Timeout is too large (${n}ms), setting it to ${Xt}ms`),n=Xt),n})(c,r);a(),e<=Qt&&(e=Math.max(kn(c),Qt));const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});wn(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Zt&&"hidden"===document.visibilityState)wn("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return wn("Skipping refresh due to timer - user is idle"),void(p=!0);wn("Refreshing session due to timer"),f()}}),e)}}})),f=()=>g.refresh(Rn()||d).catch((e=>{yn("Automatic session refresh failed",e)}));return Object.assign(we(g,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return wn("Clearing all timers"),a(),n})),{markUserActive:u?()=>{wn("markUserActive() called"),h||wn("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(wn("User became active after skipped refresh, triggering refresh"),p=!1,a(),f())}:()=>{yn("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:ei,getLastUserDisplayName:ti});const s=e(ln(r,{afterRequest:async(e,t)=>{var n;const{userInfo:i,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=an((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],s=null==i?void 0:i.name;r?(Yn(r),(e=>{pn(Qn,e)})(s)):(null==o?void 0:o.loginId)&&Yn(o.loginId)}}));let a=we(s,["flow.start"],ni);return a=we(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(fn(Xn),fn(Qn)),i})(o)),Object.assign(a,{getLastUserLoginId:ei,getLastUserDisplayName:ti})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!i||!Zt)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(ln(Object.assign({refreshCookieName:a},l),{beforeRequest:Ln(s,r,a),afterRequest:async(e,t)=>{if(un(e,t))wn("Session invalidated, clearing persisted tokens"),$n(s,o,r,c);else{const e=await cn(t);e.cookieName?pn(`${s||""}${On}`,e.cookieName):e.refreshJwt&&fn(`${s||""}${On}`);const n=((e={},t=!1,n="",i=!1)=>{var o,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d,knownDeviceJwt:u}=e;let h;if(c)if(i){fn(`${n}${Sn}`);const t=i.sameSite||"Strict",s=null===(o=i.secure)||void 0===o||o,a=null!==(r=i.domain)&&void 0!==r?r:e.cookieDomain,l=jn(i);s&&"https:"!==window.location.protocol&&yn("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});xn(l,c,d);const u=An(a);h=Object.assign(Object.assign({},h),{refresh:{path:d.cookiePath,domain:u?a:void 0}})}else{const e=jn(i);Mt.remove(e),pn(`${n}${Sn}`,c)}if(l)if(t){const n=t.sameSite||"Strict",i=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=En(t);i&&"https:"!==window.location.protocol&&yn("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i,cookieDomain:o});xn(r,l,c);const d=An(o);h=Object.assign(Object.assign({},h),{session:{path:c.cookiePath,domain:d?o:void 0}})}else pn(`${n}${In}`,l);return e.idToken&&pn(`${n}${Cn}`,e.idToken),d&&pn(`${n}DTD`,d),u&&pn(`${n}DKD`,u),h})(e,o,s,r);n&&(c=n)}}})),u=we(d,["logout","logoutAll","oidc.logout"],((e,t,n,i)=>o=>async(...r)=>{const s=await o(...r);return $n(e,t,n,null==i?void 0:i()),s})(s,o,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>Rn(s,r),getSessionToken:()=>Un(s,o),getIdToken:()=>Tn(s)})}))((e=>{const t=Pt(e),n=Si(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var r;if(dn())return wn(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(i),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&Zt&&void 0!==window.localStorage&&!mn(ii)&&!gn(Xn)&&!mn("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=Un(),a=Rn();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){wn("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:s?"t":"f",dcr:a?"t":"f"},l,o)},logout:async(i,o)=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i,o)},flow:yi(t),webauthn:vi(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){bi(i,e)},requestAuthentication(e){bi(i,e)}},async oneTap(e,t,n,o,r){await wi(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(o+mi),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>Zt&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+mi);try{const i={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var i,o})),Oi="undefined"!=typeof localStorage,xi="J151000",Ai="E103205",Ei="E108201",ji=Oi&&localStorage.getItem("base.content.url")||"",Ri="base.ui.components.url";Oi&&localStorage.getItem(Ri),Oi&&localStorage.getItem(Ri);const Ui="descope-login-flow",Ti="code",$i="redirect_mode",Li="err",Pi="popup_opener_origin",Wi="data-exclude-field",Mi="data-exclude-next",Ni="dls_last_auth",_i="dls_last_submitted_login_id",Di="dls_sso_run_",qi="state_id",Fi="saml_idp_state_id",Vi="wsfed_idp_state_id",Ji="saml_idp_username",Hi="descope_idp_initiated",Ki="sso_app_id",zi="custom_app_id",Bi="third_party_app_id",Gi="third_party_app_state_id",Zi="oidc_login_hint",Xi="oidc_prompt",Qi="oidc_resource",Yi="oidc_error_redirect_uri",eo="application_scopes",to="data-type",no="redirect",io="poll",oo="webauthnCreate",ro="webauthnGet",so="nativeBridge",ao="loadForm",lo="submit",co="polling",uo=["descope-multi-select-combo-box","descope-text-area"],ho="dls_last_auth_in_flight",po=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts","data","totp","notp","sentTo","sso","selfProvisionDomains"],go=["hide","disable","read-only"],fo="hidden";function vo(e,t){const n=e.closest(`.${fo}`);return!!n&&n!==t}const mo=/(["\\])/g;function bo(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(mo,"\\$1")}function wo(e,t){return Array.from(e.querySelectorAll(`[id="${bo(t)}"]`))}function yo(e,t,n){return Object.keys(t).forEach((i=>{const o=t[i];n[i]!==o&&wo(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.remove(fo);break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,o)))})),Object.keys(n).forEach((i=>{const o=n[i],r=t[i];o!==r&&wo(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.add(fo);break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,o)))})),Object.assign({},n)}var ko;!function(e){e.backward="backward",e.forward="forward"}(ko||(ko={}));const Io=new Set,So=(e,t)=>({origin:window.location.origin,pathname:window.location.pathname,hash:window.location.hash,projectId:e,flowId:t}),Co=(e,t)=>`dls_sso_query_params_${e}_${t}`,Oo=e=>Object.values(null!=e?e:{}).some(Boolean),xo=Object.keys({oidcIdpStateId:!0,samlIdpStateId:!0,wsfedIdpStateId:!0,samlIdpUsername:!0,descopeIdpInitiated:!0,ssoAppId:!0,customAppId:!0,oidcLoginHint:!0,oidcPrompt:!0,oidcErrorRedirectUri:!0,oidcResource:!0,thirdPartyAppId:!0,thirdPartyAppStateId:!0,applicationScopes:!0}),Ao=e=>xo.reduce(((t,n)=>(null==e?void 0:e[n])?Object.assign(t,{[n]:e[n]}):t),{}),Eo=e=>{var t,n;const i=(null===(t=null==e?void 0:e.params)||void 0===t?void 0:t.oidcIdpStateId)&&(null===(n=null==e?void 0:e.params)||void 0===n?void 0:n.oidcErrorRedirectUri)?864e5:6e5;return Date.now()-e.ts<i},jo=()=>{var e,t,n;try{const[i]=null!==(n=null===(t=null===(e=window.performance)||void 0===e?void 0:e.getEntriesByType)||void 0===t?void 0:t.call(e,"navigation"))&&void 0!==n?n:[],o=i;if("reload"!==(null==o?void 0:o.type)||!o.name)return!1;const r=new URL(o.name,window.location.href);return r.origin===window.location.origin&&r.pathname===window.location.pathname&&r.hash===window.location.hash}catch(e){return!1}},Ro=(e,t)=>(null==e?void 0:e.origin)===t.origin&&(null==e?void 0:e.pathname)===t.pathname&&(null==e?void 0:e.hash)===t.hash&&(null==e?void 0:e.projectId)===t.projectId&&(null==e?void 0:e.flowId)===t.flowId,Uo=(e,t,n,i=Date.now())=>{var o;if(Oo(e))try{const r={params:e,scope:So(t,n),ts:i};null===(o=window.sessionStorage)||void 0===o||o.setItem(Co(t,n),JSON.stringify(r))}catch(e){}},To=(e,t)=>{var n;try{const i=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(Co(e,t));if(!i)return;const o=JSON.parse(i);return Ro(null==o?void 0:o.scope,So(e,t))?o.ts:void 0}catch(e){return}},$o=e=>`${Di}${e}`,Lo=()=>{var e;return null!==(e=window.localStorage)&&void 0!==e?e:null},Po=()=>{try{const e=Lo();if(!e)return;const t=[];for(let n=0;n<e.length;n+=1){const i=e.key(n);(null==i?void 0:i.startsWith(Di))&&t.push(i)}t.forEach((t=>{let n=!0;try{n=!Eo(JSON.parse(e.getItem(t)))}catch(e){}n&&e.removeItem(t)}))}catch(e){}},Wo=(e,t,n,i)=>{var o,r;const s=(e=>{const t=Object.assign({},e);return delete t.oidcLoginHint,delete t.samlIdpUsername,t})(t);if(e&&Oo(s)){try{const t={params:s,ts:null!==(o=To(n,i))&&void 0!==o?o:Date.now(),projectId:n};null===(r=Lo())||void 0===r||r.setItem($o(e),JSON.stringify(t))}catch(e){}Po()}},Mo=(e,t)=>{var n,i;try{const o=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(Co(e,t));if(!o)return;const r=JSON.parse(o);Ro(null==r?void 0:r.scope,So(e,t))&&(null===(i=window.sessionStorage)||void 0===i||i.removeItem(Co(e,t)))}catch(e){}},No=(e,t)=>Mo(e,t),_o=["descope-enriched-text"];function Do(e){return new URLSearchParams(window.location.search).get(e)}function qo(e){if(window.history.replaceState&&Do(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())}}const Fo=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||""};function Vo(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?ko.forward:n<i?ko.backward:void 0}const Jo=e=>{let[t="",n=""]=(Do(Ui)||"").split("_");const i=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||i&&i!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:i}};function Ho(){qo(Ui)}function Ko(e){try{const{origin:t}=new URL(e);return"null"===t?void 0:t}catch(e){return}}function zo(e){const t=Ko(e);if(t)return t===window.location.origin||Ko(function(){const e=new URLSearchParams(window.location.search).getAll(Pi);return 1===e.length?e[0]:void 0}())===t?t:void 0}const Bo=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Go=(e,t,n)=>{const{executionId:i,stepId:o,executionFlowId:r}=Jo(e);if(r&&e!==r)return n.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(i||o)&&Ho();const s=Do("t")||void 0;s&&qo("t");const a=Do(Ti)||void 0;a&&qo(Ti);const l="popup"===Do($i);l&&qo($i);const c=Do(Li)||void 0;c&&qo(Li);const{redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p}={redirectAuthCodeChallenge:Do("ra-challenge"),redirectAuthCallbackUrl:Do("ra-callback"),redirectAuthBackupCallbackUri:Do("ra-backup-callback"),redirectAuthInitiator:Do("ra-initiator")},g=Do(qi);g&&qo(qi);const f=Do(Fi);f&&qo(Fi);const v=Do(Vi);v&&qo(Vi);const m=Do(Ji);f&&qo(Ji);const b=Do(Hi);b&&qo(Hi);const w=Do(Ki);w&&qo(Ki);const y=Do(zi);y&&qo(zi);const k=Do(Bi);k&&qo(Bi);const I=Do(Gi);I&&qo(Gi);const S=Do(eo);S&&qo(eo);const C=Do(Zi);C&&qo(Zi);const O=Do(Xi);O&&qo(Xi);const x=Do(Yi);x&&qo(Yi);const A=Do(Qi);A&&qo(Qi);const E={oidcIdpStateId:g,samlIdpStateId:f,wsfedIdpStateId:v,samlIdpUsername:m,descopeIdpInitiated:"true"===b,ssoAppId:w,customAppId:y,oidcLoginHint:C,oidcPrompt:O,oidcErrorRedirectUri:x,oidcResource:A,thirdPartyAppId:k,thirdPartyAppStateId:I,applicationScopes:S},j=((e,t)=>{const n=(e=>[e.origin,e.pathname,e.hash,e.projectId,e.flowId].join("|"))(So(e,t));return!Io.has(n)&&(Io.add(n),!0)})(t,e);let R=E,U=null;if(Po(),Oo(E))Uo(E,t,e);else if(i)U=((e,t,n)=>{var i;if(!e)return null;try{const o=null===(i=Lo())||void 0===i?void 0:i.getItem($o(e));if(!o)return null;const r=JSON.parse(o),s=Ao(null==r?void 0:r.params);return(null==r?void 0:r.projectId)===t&&Oo(s)&&Eo(r)?(Uo(s,t,n,r.ts),s):null}catch(e){return null}})(Fo(i),t,e);else if(!r){const i=j?((e,t)=>{var n;if(!jo())return null;try{const i=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(Co(e,t));if(!i)return null;const o=JSON.parse(i);return Ro(null==o?void 0:o.scope,So(e,t))&&Eo(o)?o.params:null}catch(e){return null}})(t,e):null;i?(n.debug("Restored SSO query params after a page reload"),R=i):((e,t)=>{jo()||Mo(e,t)})(t,e)}return{executionId:i,stepId:o,token:s,code:a,isPopup:l,exchangeError:c,redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p,ssoQueryParams:R,adoptedSsoQueryParams:U}},Zo=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})},Xo=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=Array.from(e.querySelectorAll('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])')).find((t=>!vo(t,e)));setTimeout((()=>{null==t||t.focus()}))}};function Qo(e,t,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),i(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const Yo=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:i,samlIdpUsername:o,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||n||i||o||r||s||a||l||c||d||u||h||p),er=(e,t,n)=>{const i=document.createElement("input");return i.type="hidden",i.name=e,i.value=t,n&&i.setAttribute("role",n),i},tr=e=>null==e?void 0:e.submit(),nr=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},ir=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}},or={minLength:"data-password-policy-value-minlength",strength:"data-password-policy-value-passwordstrength",disallowedChars:"data-password-policy-value-disallowedchars",email:"data-password-policy-value-email",reuse:"data-password-policy-value-reuse",activePolicies:"active-policies",availablePolicies:"available-policies"},rr=(e,t)=>{var n;const i=null==e?void 0:e.componentsDynamicAttrs;if(!i)return;const o=Object.entries(i).find((([e])=>(e=>{var t;return null===(t=e.match(/\[data-name=["']([^"']+)["']\]/))||void 0===t?void 0:t[1]})(e)===t));return null===(n=null==o?void 0:o[1])||void 0===n?void 0:n.attributes},sr=[{key:"totp",from:e=>e.totp},{key:"notp",from:e=>e.notp},{key:"sentTo",from:e=>e.sentTo},{key:"sso",from:e=>e.sso},{key:"selfProvisionDomains",from:e=>e.selfProvisionDomains},{key:"inboundAppApproveScopes",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.thirdPartyAppApproveScopes)||void 0===n?void 0:n.data}},{key:"securityQuestionsSetup",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqSetup}},{key:"securityQuestionsVerify",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqVerify}},{key:"userTenants",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userSelectedTenant)||void 0===n?void 0:n.data}},{key:"userRoles",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userRoles)||void 0===n?void 0:n.data}},{key:"ssoApplications",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoApplications)||void 0===n?void 0:n.data}},{key:"ssoConfigurations",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoConfigurations)||void 0===n?void 0:n.data}},{key:"samlAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlMappings)||void 0===n?void 0:n.options}},{key:"oidcAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.oidcMappings)||void 0===n?void 0:n.options}},{key:"samlGroupMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlGroupMappings)||void 0===n?void 0:n.options}},{key:"passwordPolicy",from:e=>{var t;return(e=>{if(!e)return;const t=Object.fromEntries(Object.entries(or).map((([t,n])=>[t,e[n]])).filter((([,e])=>void 0!==e)));return Object.keys(t).length?t:void 0})(null===(t=e.componentsConfig)||void 0===t?void 0:t.newPassword)}},{key:"recoveryCodes",from:e=>(e=>{const t=rr(e,"recoveryCodes");if(t)return Array.isArray(t.data)?t.data.map((e=>e.value)):[]})(e.componentsConfig)},{key:"outboundApp",from:e=>(e=>{const t=rr(e,"outboundApp");if(t)return{label:t.label,iconSrc:t["icon-src"],appId:t["data-descope-outbound-oauth-app-id"]}})(e.componentsConfig)}],ar=e=>{const t=(n=e.screenState,i=(e,t)=>po.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!i(t,e)))));var n,i;const{screenState:{errorText:o,errorType:r}}=e;(o||r)&&(t.error={text:o,type:r}),e.action&&(t.action=e.action);const s=(e=>{if(!e)return;const t={};return sr.forEach((({key:n,from:i})=>{const o=i(e);void 0!==o&&(t[n]=o)})),Object.keys(t).length?t:void 0})(e.screenState);return s&&(t.data=s),t},lr=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function cr(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}const dr=(e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,l=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",c=window.open(l,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return c.location.href=e,c.focus(),c};var ur,hr,pr,gr;function fr(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!fr(r,s))return!1}else if(r!==s)return!1}return!0}class vr{constructor(e={},{forceUpdate:t=!1}={}){ur.set(this,void 0),hr.set(this,{}),pr.set(this,0),gr.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,ur,"f")):e,n=Object.assign(Object.assign({},i(this,ur,"f")),t),r=i(this,ur,"f");o(this,ur,n,"f"),Object.freeze(i(this,ur,"f")),setTimeout((()=>{Object.values(i(this,hr,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const s=t(r),a=t(n);(i(this,gr,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!fr(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},o(this,ur,e,"f"),o(this,gr,t,"f")}get current(){return Object.assign({},i(this,ur,"f"))}set forceUpdate(e){o(this,gr,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,pr,i(this,pr,"f")+1,"f"),i(this,hr,"f")[i(this,pr,"f")]={cb:e,selector:t,forceUpdate:n},i(this,pr,"f").toString()}unsubscribe(e){const t=!!i(this,hr,"f")[e];return t&&delete i(this,hr,"f")[e],t}unsubscribeAll(){return o(this,hr,{},"f"),!0}}ur=new WeakMap,hr=new WeakMap,pr=new WeakMap,gr=new WeakMap;const mr=/[\\*#/()[\]_<>`]/g,br=["disabled"],wr=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Wi}])`)).forEach((e=>{e.value=n}))}))},yr=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),kr=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>{return n?"string"!=typeof(o=String(yr(t,i)))?o:o.replace(mr,"\\$&"):yr(t,i);var o})),Ir=(e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(i=e.localName,_o.includes(i));var i;e.textContent=kr(e.textContent,t,n);const o=e.getAttribute("href");o&&e.setAttribute("href",kr(o,t))}))},Sr=(e,t,n)=>{e.querySelectorAll(`[${to}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Cr=(e,t,n)=>{var i,o;const r=null===(i=customElements.get(t))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},Or=(e,n,i,o)=>{var r,s;Sr(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),Sr(e,"notp-link",null===(s=null==n?void 0:n.notp)||void 0===s?void 0:s.redirectUrl),Ir(e,n),((e,n,i)=>{if(!n)return;const{componentsDynamicAttrs:o}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});o&&Object.keys(o).forEach((e=>{const t=o[e];if(t){const{attributes:n}=t;n&&Object.keys(n).length&&(s[e]=n)}})),Object.keys(s).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const n=s[t];Object.keys(n).forEach((t=>{let o=n[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==n?void 0:n.componentsConfig,o),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=kr(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])=>{br.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i)},xr=Zo((()=>n(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield Qo(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}})))),Ar=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};let Er;const jr=(e,t)=>{Er?Er.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},Rr=e=>Er?Er.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,Ur="dls_ab_testing_id",Tr={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)}},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||((e.abTestingKey||0)<n||(e.abTestingKey||0)>i)},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function $r(e,t){const n={};try{Object.assign(n,JSON.parse(Rr(Ni)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function Lr(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||jr(Ni,JSON.stringify(e)))}function Pr(){try{return JSON.parse(Rr(ho)||"{}")}catch(e){return{}}}function Wr(e){try{t=ho,Er?Er.removeItem(t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(t)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}var t}const Mr=["error","warn","info","debug"],Nr={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},_r=l((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,i(this,t,"m",r).call(this,Nr))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e||Nr),"f")}get logger(){return i(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return Mr.reduce(((t,n)=>(t[n]=(...t)=>{var i;this.onLogEvent(n,t),null===(i=e[n])||void 0===i||i.call(e,...t)},t)),{})},s})),Dr="undefined"!=typeof localStorage,qr="https://static.descope.com/pages",Fr="https://static2.descope.com/pages",Vr=Dr&&localStorage.getItem("base.content.url")||"",Jr=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,Hr=l((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&i(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),Kr=l((e=>{var t,n;const o=r(_r,Hr)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=i(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&e.oldValue!==n.getAttribute(e.attributeName)&&o(e.attributeName)}))})).observe(n,{attributes:!0,attributeOldValue:!0})}observeAttribute(e,n){i(this,t,"f")[e]||(i(this,t,"f")[e]=[]);const o=i(this,t,"f")[e].push(n);return()=>i(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),zr=e=>t=>{var n,o,s;const a=r(_r,Hr,Kr)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,i(this,n,"m",o).bind(this))}async init(){var e;l.forEach((e=>i(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},s};zr.missingAttrValidator=Jr;const Br=l((e=>{const t=r(zr({"project-id":Jr}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),Gr=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),Zr="Trying the next fallback URL...",Xr=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};const Qr=l((e=>{var t,n,s,a,l,c,d;const u=r(_r,Br,Gr)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const r=i(this,t,"m",l).call(this,e),c=Array.isArray(r)?e=>{const{baseUrl:t}=r[e];o(this,s,t,"f");for(let t=0;t<e;t++){const e=r[t].baseUrl;i(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:i}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const r=o[e],s=e===o.length-1;try{const o=await Xr(r.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${Zr}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${Zr}`)}}})(r,{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,s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const r=Vr||this.baseStaticUrl;if(r)return i(this,t,"m",c).call(this,e,r);i(this,n,"f")!==this.baseUrl&&(o(this,n,this.baseUrl,"f"),o(this,s,void 0,"f"),i(this,a,"f").clear());const l=[];if(i(this,s,"f"))l.push(i(this,t,"m",c).call(this,e,i(this,s,"f"))),i(this,s,"f")===qr&&l.push(i(this,t,"m",c).call(this,e,Fr));else{const n=this.baseUrl+"/pages";this.baseUrl&&!i(this,a,"f").has(n)&&l.push(i(this,t,"m",c).call(this,e,n)),i(this,a,"f").has(qr)||l.push(i(this,t,"m",c).call(this,e,qr)),l.push(i(this,t,"m",c).call(this,e,Fr))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i=qr}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}({projectId:this.projectId,filename:e,baseUrl:t})},d})),Yr=l((e=>{var t,n;const o=r(zr({"project-id":Jr}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return i(this,t,"f").set(e,n),()=>{i(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(i(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=i(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),es=l((e=>{var t,n,s,a,l;const c=r(Qr,Yr,Hr)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,t,"m",n).bind(this))}get config(){return i(this,s,"f")||o(this,s,i(this,a,"f").call(this),"f"),i(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,s,void 0,"f")},l})),ts=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],ns=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},is=(e,t,n)=>new Promise(((i,o)=>{const r=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);r.onerror=e=>{r.setAttribute("status","error"),o(e)},r.onload=()=>{r.setAttribute("status","loaded"),i(r)},r.src=t.toString(),document.body.appendChild(r)})),os=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},rs=l((e=>{const t=r(_r)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const i of e){const{id:e,url:o,integrity:r}=i,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await os(s,r),i}catch(e){t(i,!0)}else try{return await is(e,o,r),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="",o)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${i}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${ns(a)}`};return o&&(l.integrity=o),[...e,l]}),[]))([...i,this.baseCdnUrl,...ts],e,t,n,o),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),ss="base.ui.components.url",as=Dr&&localStorage.getItem(ss),ls=l((e=>{var t,n,s,a,l,c,d;const u=r(_r,es,rs)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return i(this,a,"f")||o(this,a,i(this,t,"m",c).call(this),"f"),i(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>i(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=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(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await i(this,t,"m",n).call(this),o=as?void 0:await i(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[as],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),cs=l((e=>{var t,n,o;const s=r(Hr,Kr)(e);return o=class extends s{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",i(this,t,"m",n).bind(this)),i(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class ds{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const us=l((e=>{const t=r(cs)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new ds(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),hs="content-root",ps="root",gs=l((e=>{const t=r(us)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${ps}">\n <div id="${hs}"></div>\n </div>\n `,this.injectStyle(`\n #${ps}, #${hs} {\n height: 100%;\n }\n #${ps} {\n position: relative;\n height: fit-content;\n }\n #${ps}:has(> #${hs} > #ROOT[st-host-height="100%"]) {\n height: 100%;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(hs),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(ps)}}})),fs=(e,t,n="")=>Object.entries(e).reduce(((e,[i,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(i))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${i}`:i;if("object"==typeof o&&null!==o)return e+fs(o,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(o);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),""),vs=e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)};function ms(e,t){const n=Object.assign({},e);for(const[e,i]of Object.entries(t||{}))if(null!=i)if("object"==typeof i){if(0===Object.keys(i).length)continue;n[e]=ms(n[e]||{},i)}else n[e]="string"==typeof i?(n[e]||"")+i:i;return n}const bs=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",ws=l((e=>{const t=r(zr({tenant:bs}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),ys=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ks=l((e=>{var t,n,s,a,l,c,d,u,h,p,g,f,v,m,b,w,y,k,I,S,C,O,x;const A=r(zr({theme:ys}),ws,Qr,Hr,ls,es,gs,Kr,us)(e);return x=class extends A{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,void 0),c.set(this,void 0),d.set(this,void 0),S.set(this,(()=>{i(this,t,"m",C).call(this),i(this,O,"f").call(this,"os"===this.getAttribute("theme"))})),O.set(this,(e=>{var n,o,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===r||r.call(o,"change",(()=>i(this,t,"m",C).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"}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,S,"f").call(this),await Promise.all([i(this,t,"m",p).call(this),i(this,t,"m",v).call(this),i(this,t,"m",b).call(this)]),i(this,t,"m",m).call(this),this.observeAttributes(["theme"],i(this,S,"f")),this.observeAttributes(["theme-override"],(()=>i(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{o(this,d,null,"f"),i(this,t,"m",v).call(this),i(this,t,"m",b).call(this),i(this,t,"m",k).call(this)})),this.observeAttributes(["style-id"],(()=>{o(this,c,null,"f"),i(this,t,"m",y).call(this),i(this,t,"m",p).call(this),i(this,t,"m",b).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,d=new WeakMap,S=new WeakMap,O=new WeakMap,t=new WeakSet,l=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,i,o,r,s,a;const l=null===(o=null===(i=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===i?void 0:i.colors)||void 0===o?void 0:o.primary,c=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${fs({colors:{primary:l,secondary:c}},(e=>this.logger.error(e)))}}`:""})).join(""):""},u=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")}},h=function(){return i(this,c,"f")||(o(this,c,i(this,t,"m",u).call(this),"f"),i(this,c,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,c,"f")},p=async function(){var e,r;const s=await i(this,t,"a",h);if(!s)return;const a=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||"");i(this,n,"f")?i(this,n,"f").replaceSync(a):o(this,n,this.injectStyle(a,{prepend:!0}),"f")},g=async function(){const e=this.tenantId;if(e)try{const{body:t}=await this.fetchStaticResource(`${e}/theme.json`,"json");return t}catch(e){this.logger.warn("No tenant style exists, using project default theme.")}},f=function(){return i(this,d,"f")||o(this,d,i(this,t,"m",g).call(this),"f"),i(this,d,"f")},v=async function(){var e,n,r,a;if(!this.tenantId)return void(null===(e=i(this,s,"f"))||void 0===e||e.replaceSync(""));const l=await i(this,t,"a",f);if(!l)return void(null===(n=i(this,s,"f"))||void 0===n||n.replaceSync(""));const c=((null===(r=l.light)||void 0===r?void 0:r.globals)||"")+((null===(a=l.dark)||void 0===a?void 0:a.globals)||"");i(this,s,"f")?i(this,s,"f").replaceSync(c):o(this,s,this.injectStyle(c),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=i(this,a,"f"))||void 0===e||e.replaceSync(""));const n=i(this,t,"m",l).call(this);i(this,a,"f")?i(this,a,"f").replaceSync(n):o(this,a,this.injectStyle(n),"f")},b=async function(){var e,n,o,r;const s=await i(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const l=await i(this,t,"a",f);a.componentsThemeManager.themes={light:ms((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.components)||{},(null===(n=null==l?void 0:l.light)||void 0===n?void 0:n.components)||{}),dark:ms((null===(o=null==s?void 0:s.dark)||void 0===o?void 0:o.components)||{},(null===(r=null==l?void 0:l.dark)||void 0===r?void 0:r.components)||{})}},w=async function(){var e,t;const{projectConfig:n}=await this.config||{},i=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,r=i||o;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},y=async function(){const e=await i(this,t,"m",w).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),vs(e.url))})):this.logger.debug("No fonts to load"),i(this,t,"m",k).call(this)},k=async function(){var e;if(!this.tenantId)return;const n=await i(this,t,"a",f),o=null===(e=null==n?void 0:n[this.theme])||void 0===e?void 0:e.fonts;Object.values(o||{}).forEach((e=>{(null==e?void 0:e.url)&&(this.logger.debug(`Loading tenant font from URL "${e.url}"`),vs(e.url))}))},I=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)},C=function(){i(this,t,"m",y).call(this),i(this,t,"m",I).call(this)},x})),Is=Dr&&localStorage.getItem("base.debug.logs.url"),Ss=l((e=>{const t=r(zr({"flow-id":Jr}))(e);return class extends t{get flowId(){return this.getAttribute("flow-id")}}}));function Cs(e){const t=Math.floor(e/1e3);if(t<60)return`${t} seconds`;const n=Math.floor(t/60);if(n<60)return`${n} minutes`;const i=Math.floor(n/60);return i<24?`${i} hours`:`${Math.floor(i/24)} days`}const Os=l((e=>{var t,n,s,a,l,c,d,u,h,p,g,f;const v=r(rs,_r,Hr,es,Br,Ss)(e);return f=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,null),s.set(this,!1),a.set(this,null),g.set(this,null)}get telemetryManager(){return i(this,n,"f")}updateTelemetryContext(e){if(i(this,n,"f"))try{i(this,n,"f").updateContext(e)}catch(e){this.logger.error("Error updating telemetry context:",e)}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this));const n=this.sdkVersion||"1.0.0";o(this,g,i(this,t,"m",h).call(this).then((e=>i(this,t,"m",l).call(this,e,{projectId:this.projectId,flowId:this.flowId,sdkVersion:n}))).catch((e=>{this.logger.error("Failed to start telemetry:",e)})),"f")}get telemetryReady(){var e;return null!==(e=i(this,g,"f"))&&void 0!==e?e:Promise.resolve()}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),i(this,t,"m",d).call(this)}},n=new WeakMap,s=new WeakMap,a=new WeakMap,g=new WeakMap,t=new WeakSet,l=async function(e,r){if(null==e?void 0:e.enabled)if(i(this,s,"f"))this.logger.debug("Telemetry already initialized");else if(e.expiration&&Date.now()>=e.expiration)this.logger.info(`Telemetry expiration time has passed (${new Date(e.expiration).toISOString()}), skipping initialization`);else try{this.logger.debug("Initializing telemetry...");const a=e.version||"latest";await this.injectNpmLib("@descope/debug-logs",a,"dist/index.js",[Is]);const l=window.DescopeDebugLogs;if(!l)throw new Error("DescopeDebugLogs not found after loading @descope/debug-logs. This likely means the UMD build failed to load from CDN.");if(o(this,n,new l({enabled:!0,rumConfig:e.rumConfig,capture:e.capture},{projectId:r.projectId,flowId:r.flowId,version:r.sdkVersion||"1.0.0"},this.logger),"f"),!i(this,n,"f").isReady())return this.logger.error("Telemetry manager failed to initialize (RUM client not ready)"),void o(this,n,null,"f");o(this,s,!0,"f"),this.logger.info("Telemetry initialized successfully"),e.expiration&&i(this,t,"m",c).call(this,e.expiration)}catch(e){this.logger.error("Failed to initialize telemetry:",e),o(this,s,!1,"f")}else this.logger.debug("Telemetry is disabled, skipping initialization")},c=function(e){const n=e-Date.now();if(n<=0)return this.logger.info("Telemetry expiration time reached, shutting down"),void i(this,t,"m",d).call(this);const r=864e5,s=Math.min(n,r);n>r&&this.logger.warn(`Telemetry expiration is beyond maximum timeout (${Cs(n)}). Setting to maximum.`),this.logger.info(`Telemetry will expire at ${new Date(e).toISOString()} (in ${Cs(s)})`),o(this,a,setTimeout((()=>{this.logger.info("Telemetry expiration time reached, shutting down"),i(this,t,"m",d).call(this)}),s),"f")},d=function(){if(i(this,a,"f")&&(clearTimeout(i(this,a,"f")),o(this,a,null,"f")),i(this,n,"f"))try{this.logger.debug("Shutting down telemetry..."),i(this,n,"f").shutdown(),o(this,n,null,"f"),o(this,s,!1,"f"),this.logger.info("Telemetry shutdown complete")}catch(e){this.logger.error("Error shutting down telemetry:",e)}},u=function(e){return Boolean((null==e?void 0:e.applicationId)&&(null==e?void 0:e.identityPoolId)&&(null==e?void 0:e.region))},h=async function(){var e;const n=await this.config,o=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.telemetry;let r;try{const e=Number("");r={enabled:"true"==="".toLowerCase(),rumConfig:Object.assign({applicationId:"",identityPoolId:"",region:"",sessionSampleRate:Number.isFinite(e)&&e>0?e:1},"")}}catch(e){r={enabled:!1,rumConfig:{applicationId:"",identityPoolId:"",region:"",sessionSampleRate:1}}}const s=Object.assign(Object.assign(Object.assign({},r),o),{rumConfig:Object.assign(Object.assign({},r.rumConfig),null==o?void 0:o.rumConfig),capture:i(this,t,"m",p).call(this,null==o?void 0:o.capture)});return s.enabled&&!i(this,t,"m",u).call(this,s.rumConfig)&&(this.logger.warn("Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization."),s.enabled=!1),o||(s.expiration=Date.now()+3e5,this.logger.debug("No backend telemetry config present; applying a 5-minute safety cap on the session.")),s},p=function(e){const t=null==e?void 0:e.dom;return!1===t?Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:!1}):Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:Object.assign(Object.assign({throttleMs:2e3},"object"==typeof t?t:{}),{rootElement:this.shadowRoot})})},f})),xs=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if(Array.isArray(e[i]))return Object.assign(Object.assign({},n),{[i]:{value:e[i].map((e=>"object"==typeof e&&null!==e?xs(e):e))}});if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),xs(e[i],`${t+i}.`));const r="object"==typeof e[i]?e[i]:{value:e[i]},s=Object.assign(Object.assign({},n),{[t+i]:r,[`form.${t}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),As=l((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;i(this,t,"m",n).call(this)&&i(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},r}));l((e=>{var t,n,s,a,l,c,d;return d=class extends(r(Hr,_r)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),"debug"===e&&i(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&i(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=i(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(i(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return wc})),document.body.appendChild(i(this,n,"f"))},l=function(){this.debug?i(this,t,"m",a).call(this):i(this,t,"m",s).call(this)},c=function(e,t){var o;e&&(null===(o=i(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},d}));const Es="descope-modal";var js,Rs,Us,Ts,$s;class Ls{constructor(e,t){js.set(this,void 0),this.nodeName="",o(this,js,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const i="function"==typeof e?e():e;i&&(clearInterval(n),t(i))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(i(this,js,"f"))}get ele(){var e,t;const n="function"==typeof i(this,js,"f")?i(this,js,"f").call(this):i(this,js,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}}js=new WeakMap;class Ps extends Ls{constructor(...e){super(...e),Rs.add(this),Us.set(this,void 0),Ts.set(this,void 0),this.nodeName="descope-modal",i(this,Rs,"m",$s).call(this)}get isOpen(){var e;return"true"===(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("opened"))}get isClosed(){return!this.isOpen}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),i(this,Rs,"m",$s).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),i(this,Us,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,Us,"f").content.cloneNode(!0)))}setContent(e){o(this,Us,e,"f"),this.reset()}remove(){var e,t;null===(e=i(this,Ts,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}}Us=new WeakMap,Ts=new WeakMap,Rs=new WeakSet,$s=function(){if(i(this,Ts,"f"))return;const e=this.ele;e&&(o(this,Ts,new MutationObserver((t=>{t.forEach(((n,i)=>{var o;const r="true"===n.oldValue,s=t[i+1]?t[i+1].oldValue:e.getAttribute("opened");r&&"true"!==s&&(null===(o=this.afterClose)||void 0===o||o.call(this))}))})),"f"),i(this,Ts,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};class Ws extends Ls{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}}const Ms=l((e=>{var t,n;const o=r(Hr,gs,ls)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Ps{setContent(t){e(t),super.setContent(t)}}})())}get modalDriverClass(){return i(this,t,"f")}createModal(e,n=i(this,t,"f")){const o=((e={})=>{const t=document.createElement(Es);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(o),new n(o,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Es]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n}));l((e=>class extends(Ms(e)){createFlowModal(e){const t=this.modalDriverClass;return this.createModal(e,class extends t{setContent(e){const t=e.content.querySelector("descope-wc");t&&!t.hasAttribute("lazy-start")&&t.setAttribute("lazy-start","true"),super.setContent(e)}async open(){var e,t,n;await super.open(),null===(n=null===(t=null===(e=this.ele)||void 0===e?void 0:e.querySelector("descope-wc"))||void 0===t?void 0:t.start)||void 0===n||n.call(t)}})}}));const Ns="descope-notification";l((e=>{var t,n;const o=r(Hr,gs,ls)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Ws{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(Ns);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(i(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([Ns])}},t=new WeakMap,n})),l((e=>class extends(_r(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}}));const _s=l((e=>{const t=r(zr({"widget-id":Jr}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}}));l((e=>{const t=r(es,_s)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}async getHostedPageBaseUrl(){var e;const t=await this.config;return null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.hostedPageBaseUrl}}})),l((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=v(this.locale);return[...new Set([e,t].filter(Boolean))]}firstAvailableLocale(e){var t;const n=(null!=e?e:[]).map((e=>e.toLowerCase()));return null!==(t=this.localeCandidates.find((e=>n.includes(e))))&&void 0!==t?t:""}})),l((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),l((e=>{var n,o,r;return r=class extends(ks(e)){constructor(){super(...arguments),n.add(this)}get clientInput(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get formInput(){return this.getAttribute("form")||void 0}createFlowTemplate(e){var{flowId:r,client:s,form:l}=e,c=t(e,["flowId","client","form"]);return a(Object.assign({projectId:this.getAttribute("project-id"),flowId:r,baseUrl:this.getAttribute("base-url")||"",baseStaticUrl:this.getAttribute("base-static-url")||"",baseCdnUrl:this.getAttribute("base-cdn-url")||"",refreshCookieName:this.getAttribute("refresh-cookie-name")||"",theme:this.theme,"style-id":this.styleId,locale:this.getAttribute("locale")||"",form:i(this,n,"m",o).call(this,l),client:Object.assign(Object.assign({},this.clientInput),s)},c))}},n=new WeakSet,o=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},r}));const Ds=/(["\\])/g;function qs(e,t){return Array.from(e.querySelectorAll(`[data-id="${n=t,"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(n):n.replace(Ds,"\\$1")}"]`));var n}function Fs(e,t){e&&t&&Object.entries(t).forEach((([t,n])=>{qs(e,t).forEach((e=>function(e,t){var n;switch(t){case"hide":e.setAttribute("hidden",""),null===(n=e.style)||void 0===n||n.setProperty("display","none","important");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,n)))}))}l((e=>{var t,n,s,a,l,c;const d=r(_r,gs)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,{})}async init(){var e,r;if("true"===this.getAttribute("mock"))return o(this,n,Promise.resolve({}),"f"),void await(null===(e=super.init)||void 0===e?void 0:e.call(this));const s=i(this,t,"m",a).call(this);o(this,n,i(this,t,"m",l).call(this,s),"f"),await(null===(r=super.init)||void 0===r?void 0:r.call(this))}async onWidgetRootReady(){var e,t;await(null===(e=super.onWidgetRootReady)||void 0===e?void 0:e.call(this)),o(this,s,null!==(t=await i(this,n,"f"))&&void 0!==t?t:{},"f"),Fs(this.contentRootElement,i(this,s,"f"))}async reevaluateComponentsState(){const e=i(this,t,"m",a).call(this);var n,r;n=this.contentRootElement,r=i(this,s,"f"),n&&r&&Object.entries(r).forEach((([e,t])=>{qs(n,e).forEach((e=>function(e,t){var n;switch(t){case"hide":e.removeAttribute("hidden"),null===(n=e.style)||void 0===n||n.removeProperty("display");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,t)))})),o(this,s,await i(this,t,"m",l).call(this,e),"f"),Fs(this.contentRootElement,i(this,s,"f"))}},n=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(){var e;const t=null===(e=this.api)||void 0===e?void 0:e.httpClient;if(!t)throw new Error("componentsConditionsMixin: the widget sdk must expose `httpClient`. Compose apiMixin and return `webSdk.httpClient` from createSdk.");return t},l=async function(e){var t;try{const n=await e.get("/v1/mgmt/widget/components-state");if(!(null==n?void 0:n.ok))return{};const i=await n.json();return null!==(t=null==i?void 0:i.componentsState)&&void 0!==t?t:{}}catch(e){return this.logger.debug("components-conditions: failed to fetch, showing all components",null==e?void 0:e.message),{}}},c}));const Vs=["input","change"];function Js(e){if("number"==typeof e&&Number.isFinite(e))return{value:e,ok:!0};if("boolean"==typeof e)return{value:e?1:0,ok:!0};if("string"==typeof e){if(""===e.trim())return{value:0,ok:!1};const t=Number(e);if(Number.isFinite(t))return{value:t,ok:!0}}return{value:0,ok:!1}}function Hs(e){return null==e?"":"string"==typeof e?e:"boolean"==typeof e?e?"true":"false":"number"==typeof e?Number.isFinite(e)?String(e):"":String(e)}function Ks(e){if("boolean"==typeof e)return{value:e,ok:!0};if("string"==typeof e){if("true"===e)return{value:!0,ok:!0};if("false"===e)return{value:!1,ok:!0}}return"number"==typeof e?{value:0!==e,ok:!0}:{value:!1,ok:!1}}function zs(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function Bs(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const Gs=new Map;const Zs={equal:(e,t)=>e===t||Hs(e)===Hs(t),"not-equal":(e,t)=>e!==t&&Hs(e)!==Hs(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(Hs(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(Hs(t)),"greater-than":(e,t)=>{const n=Js(e),i=Js(t);return n.ok&&i.ok&&n.value>i.value},"greater-than-or-equal":(e,t)=>{const n=Js(e),i=Js(t);return n.ok&&i.ok&&n.value>=i.value},"less-than":(e,t)=>{const n=Js(e),i=Js(t);return n.ok&&i.ok&&n.value<i.value},"less-than-or-equal":(e,t)=>{const n=Js(e),i=Js(t);return n.ok&&i.ok&&n.value<=i.value},empty:e=>Bs(e),"not-empty":e=>!Bs(e),"is-true":e=>{const t=Ks(e);return t.ok&&t.value},"is-false":e=>{const t=Ks(e);return t.ok&&!t.value},in:(e,t)=>{const n=zs(t);return null!==n&&n.includes(e)},"not-in":(e,t)=>{const n=zs(t);return null!==n&&!n.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const n=function(e){var t;if(Gs.has(e))return null!==(t=Gs.get(e))&&void 0!==t?t:null;let n;try{n=new RegExp(e)}catch(e){n=null}return Gs.set(e,n),n}(Hs(t));return null!==n&&n.test(e)}};function Xs(e,t){var n;if(e)return"form"===e.kind&&e.form?t[e.form]:"list"===e.kind?(null!==(n=e.items)&&void 0!==n?n:[]).map((e=>Xs(e,t))):e.value}function Qs(e,t){const n=Zs[e.operator];if(!n)return!1;return n(Xs(e.target,t),Xs(e.predicate,t))}function Ys(e,t){var n;return(null!==(n=e.rules)&&void 0!==n?n:[]).some((e=>function(e,t){var n;const i=null!==(n=e.atomicConditions)&&void 0!==n?n:[];return!!i.length&&(e.logicalOr?i.some((e=>Qs(e,t))):i.every((e=>Qs(e,t))))}(e,t)))}function ea(e,t){const n={};return(null!=e?e:[]).forEach((e=>{var i;Ys(e,t)&&(null!==(i=e.componentIds)&&void 0!==i?i:[]).forEach((t=>{n[t]=e.action}))})),n}const ta="component-conditions:";function na(e){return e instanceof HTMLInputElement?"checkbox"===e.type?e.checked:e.value:"checked"in e?e.checked:"value"in e?e.value:void 0}function ia(e,t){const n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every((n=>e[n]===t[n]))}function oa(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function ra(e,t,n){const i={};return n.forEach((n=>{e[n]?i[n]=e[n]:t[n]&&(i[n]=t[n])})),i}const sa=l((e=>{var t,n,s,a,l,c;const d=r(_r)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,oa())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{go.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${go.map((e=>`"${e}"`)).join(", ")}`)})),yo(e,{},t))}initRealtimeConditions(e,r){var a,c,d,u;i(this,t,"m",l).call(this);const h=null!==(a=null==r?void 0:r.realtimeComponentsConditions)&&void 0!==a?a:[];if(!h.length)return void this.logger.debug(`${ta} no real-time rules to apply on this screen`);this.logger.info(`${ta} found ${h.length} real-time rule(s) for this screen`);const p={};Object.entries(null!==(c=null==r?void 0:r.form)&&void 0!==c?c:{}).forEach((([e,t])=>{p[`form.${e}`]=t})),function(e){const t=new Set,n=e=>{var i;e&&("form"===e.kind&&e.form?t.add(e.form):"list"===e.kind&&(null!==(i=e.items)&&void 0!==i?i:[]).forEach(n))};return(null!=e?e:[]).forEach((e=>{var t;return(null!==(t=e.rules)&&void 0!==t?t:[]).forEach((e=>{var t;return(null!==(t=e.atomicConditions)&&void 0!==t?t:[]).forEach((e=>{n(e.target),n(e.predicate)}))}))})),t}(h).forEach((t=>{const n=function(e,t){const n=t.startsWith("form.")?t.slice(5):t;return e.querySelector(`[name="${bo(t)}"]`)||e.querySelector(`[name="${bo(n)}"]`)}(e,t);if(!n)return;const i=na(n);void 0!==i&&(p[t]=i)}));const g=function(e){const t=new Set;return(null!=e?e:[]).forEach((e=>{var n;(null!==(n=e.componentIds)&&void 0!==n?n:[]).forEach((e=>t.add(e)))})),t}(h),f={},v={};Object.entries(null!==(d=null==r?void 0:r.componentsState)&&void 0!==d?d:{}).forEach((([e,t])=>{g.has(e)&&(v[e]=t)})),Object.entries(null!==(u=null==r?void 0:r.serverOnlyComponentsState)&&void 0!==u?u:{}).forEach((([e,t])=>{g.has(e)&&(f[e]=t)}));const m={conditions:h,touchedIds:g,snapshot:p,applied:v,serverBaseline:f,debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:e},b=ra(ea(h,p),f,g);ia(v,b)||(m.applied=yo(e,v,b)),m.inputHandler=e=>i(this,t,"m",s).call(this,e),Vs.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${ta} listening for "${Vs.join('" and "')}" events on form fields; ${Object.keys(v).length} component(s) start hidden / disabled / read-only by these rules`);const w=this.nextRequestStatus;if(null==w?void 0:w.subscribe){const e=({isLoading:e})=>{m.paused=e,e&&m.debounceTimer&&(clearTimeout(m.debounceTimer),m.debounceTimer=null)},t=w.subscribe(e);m.unsubscribePauseListener=()=>{var e;null!=t&&(null===(e=w.unsubscribe)||void 0===e||e.call(w,t))}}o(this,n,m,"f")}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(e){var o,r;const s=i(this,n,"f");if(!s.root||s.paused)return;const l=e.target;if(!l)return;if(null===(o=l.hasAttribute)||void 0===o?void 0:o.call(l,Wi))return;const c=null===(r=l.getAttribute)||void 0===r?void 0:r.call(l,"name");if(!c)return;const d=function(e){return e.startsWith("form.")?e:`form.${e}`}(c);s.snapshot[d]=na(l),s.debounceTimer&&clearTimeout(s.debounceTimer),s.debounceTimer=setTimeout((()=>{s.debounceTimer=null,i(this,t,"m",a).call(this)}),50)},a=function(){const e=i(this,n,"f");if(!e.root)return;let t;try{t=ra(ea(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${ta} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const o=e.applied;ia(o,t)||(this.logger.debug(`${ta} form changed — updating components: was ${JSON.stringify(o)}, now ${JSON.stringify(t)}`),e.applied=yo(e.root,o,t))},l=function(){const e=i(this,n,"f");e.debounceTimer&&clearTimeout(e.debounceTimer),e.unsubscribePauseListener&&e.unsubscribePauseListener(),e.root&&Vs.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)})),o(this,n,oa(),"f")},c})),aa="project-id",la="flow-id",ca=e=>{const t=(e=>{const t=e.getAttribute(aa),n=e.getAttribute(la);return t&&n?Array.from(e.ownerDocument.querySelectorAll("descope-wc")).filter((e=>e.getAttribute(aa)===t&&e.getAttribute(la)===n)):[]})(e);return t.length>1&&t[0]!==e},da=l((e=>{var t,n,s,a;const l=r(_r)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}connectedCallback(){var e;null===(e=super.connectedCallback)||void 0===e||e.call(this),i(this,t,"m",s).call(this)}attributeChangedCallback(e,n,o){var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),n===o||e!==aa&&e!==la||i(this,t,"m",s).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){queueMicrotask((()=>{if(!this.isConnected)return;const e=this.getAttribute(aa),t=this.getAttribute(la),r=`${e}|${t}`;i(this,n,"f")!==r&&ca(this)&&(o(this,n,r,"f"),this.logger.warn("Multiple Descope flow components detected on the same page",`The same flow ("${t}") and project ("${e}") are running more than once on this page. This is not supported and may cause the flow to behave unexpectedly.`))}))},a})),ua=["externalId","email","phone"],ha=["newPassword","password"],pa="data-username-anchor",ga=e=>{var t;if(!e)return"";try{const n=null===(t=window.sessionStorage)||void 0===t?void 0:t.getItem(_i);if(!n)return"";const i=JSON.parse(n);return i.executionId===e&&i.loginId||""}catch(e){return""}},fa=(e,t,n,i)=>{var o;const r=(null==n?void 0:n.email)||(null===(o=null==n?void 0:n.loginIds)||void 0===o?void 0:o[0]);(e=>e.querySelector("descope-new-password")||e.querySelector("descope-password"))(t)?r?(e=>{const t=['input[autocomplete="username"]',...ua.map((e=>`[name="${e}"]`))].join(", ");return e.some((e=>e.querySelector(t)))})([e,t])?i.debug("Username anchor: screen already has an identifier field"):(i.debug("Username anchor: injecting hidden username input"),e.appendChild((e=>{const t=document.createElement("input");return t.setAttribute("autocomplete","username"),t.setAttribute("name","username"),t.setAttribute("type","email"),t.setAttribute("readonly","true"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-hidden","true"),t.setAttribute(Wi,"true"),t.setAttribute(pa,"true"),t.setAttribute("value",e),t.value=e,Object.assign(t.style,{position:"absolute",opacity:"0",pointerEvents:"none",height:"0",border:"0"}),t})(r))):i.debug("Username anchor: no user identifier available"):i.debug("Username anchor: no password component on screen")},va=l((e=>{var t,n,s,a,l;const c=r(_r)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}updateScreenUser(e){var r,l,c;o(this,n,{email:null==e?void 0:e.email,loginIds:(null===(r=null==e?void 0:e.loginIds)||void 0===r?void 0:r.length)?e.loginIds:[ga(i(this,t,"a",a))||(null===(c=null===(l=i(this,t,"a",s).sdk)||void 0===l?void 0:l.getLastUserLoginId)||void 0===c?void 0:c.call(l))].filter(Boolean)},"f")}updateUsernameAnchor(){document.querySelectorAll(`[${pa}="true"]`).forEach((e=>e.remove())),fa(this,i(this,t,"a",s).contentRootElement,i(this,n,"f"),this.logger)}captureLastSubmittedLoginId(e={},n){const o=nr(e,ua);o&&((e,t)=>{var n;if(e&&t)try{null===(n=window.sessionStorage)||void 0===n||n.setItem(_i,JSON.stringify({executionId:t,loginId:e}))}catch(e){}})(o,n||i(this,t,"a",a))}storeCredentials(e={}){var t,o,r,s,a,l;const c=nr(e,ua)||(null===(t=i(this,n,"f"))||void 0===t?void 0:t.email)||(null===(r=null===(o=i(this,n,"f"))||void 0===o?void 0:o.loginIds)||void 0===r?void 0:r[0]),d=nr(e,ha);if(c&&d)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:c,password:d});null===(l=null===(a=null===(s=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===s?void 0:s.store)||void 0===a?void 0:a.call(s,e))||void 0===l||l.catch((e=>{this.logger.debug("Could not store credentials",null==e?void 0:e.message)}))}catch(e){this.logger.warn("Could not store credentials",e.message)}}},n=new WeakMap,t=new WeakSet,s=function(){return this},a=function(){var e,n;return(null===(n=null===(e=i(this,t,"a",s).flowState)||void 0===e?void 0:e.current)||void 0===n?void 0:n.executionId)||""},l})),ma="data-evp-token",ba='descope-email-field[email-verification="true"]',wa=e=>{e.querySelectorAll(`[${ma}]`).forEach((e=>e.remove()))},ya=l((e=>{var t,s,a,l,c,d,u;const h=r(_r)(e);return u=class extends h{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,!1),l.set(this,0),c.set(this,(e=>{(e=>e.composedPath().some((e=>e instanceof Element&&e.matches(ba))))(e)&&(o(this,a,"focusin"===e.type,"f"),"focusout"===e.type&&o(this,l,Date.now(),"f"))}))}clearEmailVerification(){o(this,s,void 0,"f"),o(this,a,!1,"f"),o(this,l,0,"f"),wa(this)}startEmailVerification(e){var n,r,a;const l=null===(n=i(this,t,"a",d).sdk)||void 0===n?void 0:n.emailVerification;if(!(l&&(()=>{var e,t;return!!(null===(t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands)||void 0===t?void 0:t.some((({brand:e})=>"Google Chrome"===e)))})()&&(u=e,u.querySelector(ba))&&this.closest("form")))return;var u;null===(r=this.shadowRoot)||void 0===r||r.addEventListener("focusin",i(this,c,"f")),null===(a=this.shadowRoot)||void 0===a||a.addEventListener("focusout",i(this,c,"f"));const h=l.start().then((e=>{var t,n;e.ok&&(null===(t=e.data)||void 0===t?void 0:t.nonce)?i(this,s,"f")===h&&((e,t)=>{const n=document.createElement("input");n.type="hidden",n.setAttribute("autocomplete","email-verification-token"),n.setAttribute(Wi,"true"),n.setAttribute(ma,"true"),n.nonce=t,n.setAttribute("nonce",t),e.appendChild(n)})(this,e.data.nonce):this.logger.warn("Email verification start failed",null===(n=e.error)||void 0===n?void 0:n.errorDescription)})).catch((e=>{this.logger.warn("Email verification start failed",null==e?void 0:e.message)}));o(this,s,h,"f")}emailVerificationToken(e){return n(this,void 0,void 0,(function*(){var t,n;if("true"===e.getAttribute("formnovalidate")||!this.querySelector(`[${ma}]`)||!(null===(n=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(ba))||void 0===n?void 0:n.value))return"";i(this,a,"f")&&(()=>{var e;let t=document.activeElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.activeElement;)t=t.shadowRoot.activeElement;t instanceof HTMLElement&&t.blur()})();const o=i(this,l,"f")+900-Date.now();o>0&&(yield new Promise((e=>{setTimeout(e,o)})));const r=(e=>{const t=e.querySelector(`[${ma}]`),n=e.closest("form");if(!t||!n)return"";let i="";const o=e=>{e.target===n&&(e.preventDefault(),e.stopImmediatePropagation(),i=t.value,t.value="")};window.addEventListener("submit",o,!0);const{noValidate:r}=n;n.noValidate=!0;try{n.requestSubmit()}finally{n.noValidate=r,window.removeEventListener("submit",o,!0)}return i})(this);return r&&wa(this),r}))}},s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,d=function(){return this},u})),ka=e=>`${e.screenId}|${e.field}|${e.rule}`,Ia=()=>{try{return crypto.randomUUID()}catch(e){return`${Date.now()}-${Math.round(1e9*Math.random())}`}},Sa=l((e=>{var t,n,s,a,l,c,d,u,h,p,g,f,v,m,b,w,y,k,I,S;const C=r(_r)(e);return S=class extends C{constructor(){super(...arguments),t.add(this),n.set(this,[]),s.set(this,void 0),a.set(this,void 0),l.set(this,new Set),c.set(this,!1),d.set(this,0),u.set(this,void 0),h.set(this,!1),p.set(this,(()=>i(this,t,"m",w).call(this,!1))),g.set(this,(()=>{"hidden"===document.visibilityState&&i(this,t,"m",w).call(this,!0)})),f.set(this,(()=>i(this,t,"m",w).call(this,!0)))}setValidationTrackingEnabled(e){i(this,h,"f")!==e&&(o(this,h,e,"f"),e||i(this,t,"m",b).call(this))}setValidationTrackingSender(e){o(this,u,e,"f")}setValidationTrackingExecution(e){i(this,h,"f")&&e&&i(this,n,"f").length&&(o(this,s,e,"f"),i(this,t,"m",w).call(this,!1))}trackValidationErrors(e,n){var o,r;try{i(this,t,"m",v).call(this,e,n)}catch(e){null===(r=null===(o=this.logger)||void 0===o?void 0:o.debug)||void 0===r||r.call(o,"Failed to track validation errors",String(e))}}teardownValidationTracking(){i(this,t,"m",w).call(this,!1),o(this,d,i(this,d,"f")+1,"f"),i(this,l,"f").forEach(clearTimeout),i(this,l,"f").clear(),i(this,c,"f")&&(o(this,c,!1,"f"),this.removeEventListener("screen-updated",i(this,p,"f")),this.removeEventListener("success",i(this,p,"f")),this.removeEventListener("error",i(this,p,"f")),document.removeEventListener("visibilitychange",i(this,g,"f")),window.removeEventListener("pagehide",i(this,f,"f")))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,p=new WeakMap,g=new WeakMap,f=new WeakMap,t=new WeakSet,v=function(e,r){if(!i(this,h,"f")||!(null==e?void 0:e.length))return;const a=r||{};i(this,t,"m",I).call(this),e.forEach((e=>{if(i(this,n,"f").length>=20)return;const r=((e,t)=>{var n;const i=null===(n=null==e?void 0:e.getAttribute)||void 0===n?void 0:n.call(e,"name");return i?{id:Ia(),field:i,rule:(o=e.validity,r=e.type,o?o.badInput?"bad-input":o.valueMissing?"required":o.typeMismatch?"email"===r||"url"===r?r:"type-mismatch":o.patternMismatch?"pattern":o.tooShort?"too-short":o.tooLong?"too-long":o.rangeUnderflow||o.rangeOverflow||o.stepMismatch?"range":o.customError?"custom":"unknown":"unknown"),message:e.validationMessage||"",screenId:t.screenId||"",screenName:t.screenName||"",ts:Date.now()}:null;var o,r})(e,a);if(!r)return;const l=ka(r);i(this,n,"f").some((e=>ka(e)===l))||(i(this,n,"f").push(r),o(this,s,a.executionId||i(this,s,"f"),"f"),i(this,n,"f").length>=20&&i(this,t,"m",w).call(this,!1))})),i(this,n,"f").length>=20?i(this,t,"m",w).call(this,!1):i(this,t,"m",m).call(this)},m=function(){clearTimeout(i(this,a,"f")),o(this,a,setTimeout((()=>i(this,t,"m",w).call(this,!1)),2e3),"f")},b=function(){clearTimeout(i(this,a,"f")),o(this,d,i(this,d,"f")+1,"f"),i(this,l,"f").forEach(clearTimeout),i(this,l,"f").clear(),o(this,n,[],"f"),o(this,s,void 0,"f")},w=function(e){var r,l;if(clearTimeout(i(this,a,"f")),!i(this,n,"f").length)return void o(this,s,void 0,"f");if(!i(this,s,"f"))return;if(!i(this,u,"f"))return;const c=i(this,n,"f"),h=i(this,s,"f");o(this,n,[],"f"),o(this,s,void 0,"f");try{const n={executionId:h,events:c};e?i(this,u,"f").call(this,n,{keepalive:!0}).catch((()=>{})):i(this,t,"m",y).call(this,n,2,i(this,d,"f"))}catch(e){null===(l=null===(r=this.logger)||void 0===r?void 0:r.debug)||void 0===l||l.call(r,"Failed to send validation events",String(e))}},y=function(e,n,o){i(this,u,"f").call(this,e,{keepalive:!1}).then((r=>{!r.ok&&r.retryable&&n>0&&i(this,t,"m",k).call(this,e,n,o)})).catch((()=>{n>0&&i(this,t,"m",k).call(this,e,n,o)}))},k=function(e,n,o){if(o!==i(this,d,"f"))return;const r=setTimeout((()=>{i(this,l,"f").delete(r),o===i(this,d,"f")&&i(this,t,"m",y).call(this,e,n-1,o)}),800*(2-n+1));i(this,l,"f").add(r)},I=function(){i(this,c,"f")||(o(this,c,!0,"f"),this.addEventListener("screen-updated",i(this,p,"f")),this.addEventListener("success",i(this,p,"f")),this.addEventListener("error",i(this,p,"f")),document.addEventListener("visibilitychange",i(this,g,"f")),window.addEventListener("pagehide",i(this,f,"f")))},S}));var Ca,Oa,xa,Aa,Ea,ja,Ra,Ua,Ta,$a,La,Pa,Wa,Ma,Na,_a,Da,qa,Fa,Va,Ja,Ha,Ka,za,Ba,Ga,Za;const Xa=r(ks,Qr,As,sa,da,va,ya,us,Os,Sa)(HTMLElement);class Qa extends Xa{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","send-session-token","style-id"]}get adoptedSsoQueryParams(){return i(this,Ea,"f")}constructor(e){super(),Ca.add(this),this.sdkVersion="4.8.0",xa.set(this,!1),Aa.set(this,void 0),Ea.set(this,null),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,Ca,"m",Za).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)}},ja.set(this,new vr),Ra.set(this,new vr),Ua.set(this,{}),this.getComponentsContext=()=>i(this,Ua,"f"),this.nextRequestStatus=new vr({isLoading:!1}),Ta.set(this,void 0),$a.set(this,{popstate:i(this,Ca,"m",Na).bind(this),componentsContext:i(this,Ca,"m",Ja).bind(this)}),La.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),Ha.set(this,void 0),Ka.set(this,void 0),o(this,La,e,"f"),i(this,Ca,"m",Wa).call(this)}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}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 sendSessionToken(){return"true"===this.getAttribute("send-session-token")}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return xs(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return e=this.formConfig,t="value",Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]])));var e,t}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{const e=JSON.parse(this.getAttribute("outbound-app-scopes"));return e||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return i(this,Aa,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");o(this,Aa,e,"f"),(e=>{Er=e})(e)}get lazyStart(){return"true"===this.getAttribute("lazy-start")}start(){var e;null===(e=i(this,Ka,"f"))||void 0===e||e.call(this),o(this,Ha,Promise.resolve(),"f")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=uo.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||e.defaultPrevented||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig(),n="projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{};return n||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),i(this,Ra,"f").subscribe(i(this,Ca,"m",Ga).bind(this)),i(this,Ra,"f").update({isDebug:this.debug}),i(this,Ca,"m",Ma).call(this),yield i(this,Ca,"m",Fa).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");const{executionId:r,stepId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:g,ssoQueryParams:f,adoptedSsoQueryParams:v}=Go(this.flowId,this.projectId,this.loggerWrapper);o(this,Ea,null!=v?v:null,"f"),window.addEventListener("popstate",i(this,$a,"f").popstate),window.addEventListener("components-context",i(this,$a,"f").componentsContext),i(this,ja,"f").subscribe(i(this,Ca,"m",qa).bind(this)),i(this,ja,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:g},f)),o(this,xa,!0,"f")}))}disconnectedCallback(){var e;i(this,ja,"f").unsubscribeAll(),i(this,Ra,"f").unsubscribeAll(),i(this,Ca,"m",Ba).call(this),window.removeEventListener("popstate",i(this,$a,"f").popstate),window.removeEventListener("components-context",i(this,$a,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,t,n){var o;if(null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,e,t,n),this.shadowRoot.isConnected&&i(this,xa,"f")&&t!==n&&Oa.observedAttributes.includes(e)){i(this,Ca,"m",Ma).call(this);const o=null===t;i(this,ja,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Ho()),{[Bo(e)]:n,stepId:r,executionId:s}})),i(this,Ra,"f").update({isDebug:this.debug})}}}var Ya,el,tl,nl,il,ol,rl,sl,al,ll,cl,dl,ul,hl,pl,gl,fl,vl,ml,bl,wl,yl,kl,Il,Sl,Cl,Ol,xl,Al,El,jl,Rl,Ul,Tl,$l,Ll,Pl,Wl,Ml,Nl,_l,Dl,ql,Fl,Vl,Jl,Hl;Oa=Qa,xa=new WeakMap,Aa=new WeakMap,Ea=new WeakMap,ja=new WeakMap,Ra=new WeakMap,Ua=new WeakMap,Ta=new WeakMap,$a=new WeakMap,La=new WeakMap,Ha=new WeakMap,Ka=new WeakMap,Ca=new WeakSet,Pa=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},Wa=function(){i(this,Ca,"m",Pa).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Ma=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","send-session-token","style-id","outbound-app-id","outbound-app-scopes","theme-override"];Oa.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Bo(t)])throw Error(`${t} cannot be empty`)}))},Na=function(){const{stepId:e,executionId:t}=Jo(this.flowId);t&&i(this,ja,"f").update({stepId:e,executionId:t})},_a=function(e,t){Ci&&"function"==typeof Ci||this.logger.error("SDK was not loaded properly",Ci,JSON.stringify(Ci));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},Oa.sdkConfigOverrides),{projectId:e,baseUrl:t});i(this,Aa,"f")&&(o.customStorage=i(this,Aa,"f")),this.sdk=Ci(o);const r={start:1,next:7};["start","next"].forEach((e=>{const t=function(e,t,i){return(...o)=>n(this,void 0,void 0,(function*(){let n;const r=i+1;for(let s=0;s<r;s++)try{return yield e(...o)}catch(e){n=e,s<i&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw n}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...o)=>n(this,void 0,void 0,(function*(){const n=[...o],s=r[e],a=i(this,Ca,"m",Da).call(this,n[s]);void 0!==a&&(n[s]=a);try{return yield t(...n)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:xi,errorDescription:t.toString()}}}}))}));const s=this.sdk.flow.start;this.sdk.flow.start=(...e)=>n(this,void 0,void 0,(function*(){return yield i(this,Ca,"m",za).call(this),s.apply(this.sdk.flow,e)}))},Da=function(e){if(!this.sendSessionToken)return e;const t=null==Un?void 0:Un(this.storagePrefix);return t?Object.assign(Object.assign({},null!=e?e:{}),{sessionJwt:t}):e},qa=function(e,t,o){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(o("projectId")||o("baseUrl")){if(!t)return;i(this,Ca,"m",_a).call(this,t,n)}i(this,La,"f").call(this,e)}))},Fa=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,Ca,"m",Va).call(this))}))},Va=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(ji||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t](),headers:Object.fromEntries(n.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},Ja=function(e){o(this,Ua,Object.assign(Object.assign({},i(this,Ua,"f")),e.detail),"f")},za=function(){return this.lazyStart?(i(this,Ha,"f")||o(this,Ha,new Promise((e=>{o(this,Ka,e,"f")})),"f"),i(this,Ha,"f")):Promise.resolve()},Ba=function(){var e;null===(e=i(this,Ta,"f"))||void 0===e||e.remove(),o(this,Ta,null,"f")},Ga=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,Ta,document.createElement("descope-debugger"),"f"),Object.assign(i(this,Ta,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Sc})),document.body.appendChild(i(this,Ta,"f"))):i(this,Ca,"m",Ba).call(this)}))},Za=function(e,t){var n;e&&this.debug&&(null===(n=i(this,Ta,"f"))||void 0===n||n.updateData({title:e,description:t}))},Qa.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.8.0"}};const Kl="__descope_webauthn_timed_out__";class zl extends Qa{static set sdkConfigOverrides(e){Qa.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Qa.sdkConfigOverrides}constructor(){const e=new vr({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),Ya.add(this),this.stepState=new vr({}),el.set(this,void 0),tl.set(this,null),nl.set(this,null),il.set(this,new Map),ol.set(this,{visibilitychange:i(this,Ya,"m",rl).bind(this)}),this.bridgeVersion=zl.bridgeVersion,sl.set(this,void 0),this.nativeCallbacks={},gl.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},ml.set(this,(e=>{e&&this.clearEmailVerification();const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?i(this,Ya,"m",bl).call(this,t):t()})),wl.set(this,((e,t,r,s,a=!1)=>{const l=[Ai,"E103202",Ei];if(this.flowState.current.action===io){if(i(this,kl,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;o(this,el,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,o;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,co,r,s,{}),h=document.hidden&&!a&&Date.now()-c>d+500;let p;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;p=yield Qo(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,wl,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===xi)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,wl,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==p?void 0:p.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(p.error,null,4)),(null===(o=null==p?void 0:p.error)||void 0===o?void 0:o.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):i(this,wl,"f").call(this,e,t,r,s),i(this,Il,"f").call(this,p)}))),d),"f")}})),yl.set(this,(()=>{clearTimeout(i(this,el,"f")),o(this,el,null,"f")})),kl.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),Il.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,g,f;if(!(null==e?void 0:e.ok)){const o=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;i(this,Ya,"m",Jl).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||o,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||c);const d=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==d&&d!==Ai&&d!==Ei||!this.isRestartOnError||i(this,Ya,"m",pl).call(this))}null===(d=null===(c=e.data)||void 0===c?void 0:c.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const v=null===(p=null===(h=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(g=e.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:b,lastAuth:w,action:y,openInNewTabUrl:k}=e.data;if(y!==io&&i(this,yl,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&Lr(Object.assign(Object.assign({},w),{lastUsedPerScreen:Pr()})),Wr(this.loggerWrapper);const t=Object.assign({},b);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),this.setValidationTrackingExecution(e.data.executionId),No(this.projectId,this.flowId),void i(this,Ya,"m",Jl).call(this,"success",t)}this.storeLastAuthenticatedUser&&Lr(w,!0),k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:C,screen:O,redirect:x,webauthn:A,error:E,samlIdpResponse:j,wsFedIdpResponse:R,nativeResponse:U}=e.data,T=Date.now();y!==io?(this.loggerWrapper.info(`Step "${C||`#${S}`}" is ${m}`,"",{screen:O,status:m,stepId:S,stepName:C,action:y,error:E}),(null===(f=O.state)||void 0===f?void 0:f.clientScripts)&&o(this,nl,this.loadSdkScripts(O.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:C,executionId:I,action:y,redirectTo:null==x?void 0:x.url,redirectIsPopup:null==x?void 0:x.isPopup,screenId:null==O?void 0:O.id,screenState:null==O?void 0:O.state,webauthnTransactionId:null==A?void 0:A.transactionId,webauthnOptions:null==A?void 0:A.options,samlIdpResponseUrl:null==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.relayState,wsFedIdpResponseUrl:null==R?void 0:R.url,wsFedIdpResponseWresult:null==R?void 0:R.wresult,wsFedIdpResponseWctx:null==R?void 0:R.wctx,nativeResponseType:null==U?void 0:U.type,nativePayload:null==U?void 0:U.payload,reqTimestamp:T})):this.flowState.update({action:y,reqTimestamp:T})})),Sl.set(this,Zo((()=>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)}}))))),Al.set(this,void 0),El.set(this,void 0),Ll.set(this,null),Nl.set(this,ir(((e,t,o)=>n(this,void 0,void 0,(function*(){var n,r;if("true"!==e.getAttribute("loading")&&"true"!==e.getAttribute("disabled")){if("true"===e.getAttribute("formnovalidate")||i(this,Ya,"m",Tl).call(this)){const s=null==e?void 0:e.getAttribute("id");i(this,Ya,"m",ql).call(this,e,s,o);const a=i(this,Ya,"m",Pl).call(this,e);try{const o=yield i(this,Ya,"m",$l).call(this),a=(r=e,Array.from((null==r?void 0:r.attributes)||[]).reduce(((e,t)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return i?Object.assign(e,{[i]:t.value}):e}),{}));this.nextRequestStatus.update({isLoading:!0});const l=yield this.emailVerificationToken(e),c=Object.assign(Object.assign(Object.assign(Object.assign({},a),o),{origin:i(this,Ya,"a",Ul)}),l&&{evpToken:l}),d=yield t(s,c);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(o,null===(n=null==d?void 0:d.data)||void 0===n?void 0:n.executionId),this.storeCredentials(o)}catch(e){throw a(),e}}}else this.loggerWrapper.debug("Submit already in flight, ignoring")}))))),this.flowState=e,this.setValidationTrackingSender(((e,t)=>n(this,[e,t],void 0,(function*({executionId:e,events:t},{keepalive:n}){const i=yield this.sdk.flow.event(e,t,n);return{ok:i.ok,retryable:i.code>=500||429===i.code}}))))}nativeResume(e,t){var n,o,r,s,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const i=new URL(c.url);t=null===(n=i.searchParams)||void 0===n?void 0:n.get(Ti),e=(null===(o=i.searchParams)||void 0===o?void 0:o.get(Li))||void 0}null===(s=(r=this.nativeCallbacks).complete)||void 0===s||s.call(r,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(c.url),t=e.searchParams.get("t"),n=e.searchParams.get(Ui).split("_").pop();i(this,yl,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=c;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=c,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(l=(a=this.nativeCallbacks).complete)||void 0===l||l.call(a,c)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){const t=this.preview?null==e?void 0:e.filter((e=>"clientSignals"!==e.id)):e;if(!(null==t?void 0:t.length))return null;const o=(e,t)=>n=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[cr(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${t.map((e=>e.id)).join(", ")}`);const r=e=>n(this,void 0,void 0,(function*(){var t,n,s;const a=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(a){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:n}=a;return null===(t=null==n?void 0:n.start)||void 0===t||t.call(n),n}if(!(null===(n=globalThis.descope)||void 0===n?void 0:n[e.id])){const t=i(this,il,"f").get(e.id);if(t)return yield t,r(e);const n=this.injectNpmLib("@descope/flow-scripts","1.0.22",`dist/${e.id}.js`);i(this,il,"f").set(e.id,n);try{yield n}finally{i(this,il,"f").delete(e.id)}}const l=null===(s=globalThis.descope)||void 0===s?void 0:s[e.id];return new Promise(((t,n)=>{try{const n=l(e.initArgs,{baseUrl:this.baseUrl,ref:this},o(e,t),this.loggerWrapper);if(n){const i=document.createElement("div");i.setAttribute("data-script-id",e.id),i.moduleRes=n,this.shadowRoot.appendChild(i);const o=this.nextRequestStatus.subscribe((()=>{var t;this.loggerWrapper.debug("Stopping script",e.id),(null===(t=n.stop)||void 0===t?void 0:t.call(n))&&(this.nextRequestStatus.unsubscribe(o),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(i))}));"function"==typeof n.present&&t(e.id)}}catch(e){n(e)}}))})),s=Promise.all((null!=t?t:[]).map((e=>r(e).catch((t=>(this.loggerWrapper.warn(`Sdk script ${e.id} failed to load, continuing without it`,null==t?void 0:t.message),null))))));let a;const l=new Promise((e=>{a=setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([s,l]).finally((()=>clearTimeout(a))).catch((e=>(this.loggerWrapper.warn("Sdk scripts failed to load, continuing without them",null==e?void 0:e.message),null)))}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){var e,t;if(!window.descopeBridge)return this._init();this.lazyInit=this._init,o(this,sl,null===(t=null===(e=null===window||void 0===window?void 0:window.descopeBridge)||void 0===e?void 0:e.registerFlow)||void 0===t?void 0:t.call(e,this),"f")}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),i(this,Ya,"m",ul).call(this),window.addEventListener("visibilitychange",i(this,ol,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e,t,n;super.disconnectedCallback(),this.teardownValidationTracking(),i(this,sl,"f")&&(null===(t=null===(e=window.descopeBridge)||void 0===e?void 0:e.unregisterFlow)||void 0===t||t.call(e,i(this,sl,"f")),o(this,sl,void 0,"f")),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),i(this,yl,"f").call(this),null===(n=i(this,tl,"f"))||void 0===n||n.abort(),o(this,tl,null,"f"),this.clearEmailVerification(),window.removeEventListener("visibilitychange",i(this,ol,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=v(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:g,screenId:f,screenState:m,redirectTo:b,redirectIsPopup:w,redirectUrl:y,token:k,code:I,isPopup:S,exchangeError:C,webauthnTransactionId:O,webauthnOptions:x,redirectAuthCodeChallenge:A,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:R,locale:U,samlIdpResponseUrl:T,samlIdpResponseSamlResponse:$,samlIdpResponseRelayState:L,wsFedIdpResponseUrl:P,wsFedIdpResponseWresult:W,wsFedIdpResponseWctx:M,nativeResponseType:N,nativePayload:_,reqTimestamp:D}=e,q=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let F,V,J;s("executionId")&&p&&Wo(Fo(p),Ao(q),c,d);const H=(()=>{const e=Rr(Ur);if(!e){const e=Math.floor(100*Math.random()+1);return jr(Ur,e.toString()),e}return Number(e)})(),{outboundAppId:K,outboundAppScopes:z}=this,B=this.sdk.getLastUserLoginId();s("flowId")&&this.setValidationTrackingEnabled(!1);const G=yield this.getFlowConfig();i(this,Ya,"m",jl).call(this,G,p,s);const Z=yield this.getProjectConfig(),X=Object.entries(Z.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Q=E&&A?{callbackUrl:E,codeChallenge:A,backupCallbackUri:j}:void 0,Y=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let ee={};if(!p){Wr(this.loggerWrapper);const e=[...G.clientScripts||[],...G.sdkScripts||[]];if(G.conditions){let t=[];({startScreenId:F,conditionInteractionId:J,startScreenName:V,clientScripts:t,componentsConfig:ee}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:i})=>{var o;if("ELSE"===t)return!0;const r=null===(o=Tr[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:B,code:I,token:k,abTestingKey:H,lastAuth:$r(B,this.loggerWrapper)},G.conditions)),e.push(...t||[])}else G.condition?({startScreenId:F,startScreenName:V,conditionInteractionId:J}=((e,t)=>{var n;const i=null===(n=Tr[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!i)return{};const o=i(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(G.condition,{loginId:B,code:I,token:k,abTestingKey:H,lastAuth:$r(B,this.loggerWrapper)})):(V=G.startScreenName,F=G.startScreenId);if(o(this,Al,F,"f"),o(this,El,V,"f"),o(this,nl,this.loadSdkScripts(e),"f"),G.fingerprintEnabled&&G.fingerprintKey?yield Dn(G.fingerprintKey,this.baseUrl):fn(Nn),!Yo(F,q)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Q},q),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:$r(B,this.loggerWrapper),preview:this.preview,abTestingKey:H,locale:v(U).locale,nativeOptions:Y,outboundAppId:K,outboundAppScopes:z}),J,"",Z.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:i(this,Ya,"a",Ul)},this.formConfigValues),I?{exchangeCode:I,idpInitiated:!0}:{}),q.descopeIdpInitiated&&{idpInitiated:!0}),k?{token:k}:{}),q.oidcLoginHint?{externalId:q.oidcLoginHint}:{}));return i(this,Il,"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(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:S,code:I,exchangeError:C,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),S&&(s("code")&&I||s("exchangeError")&&C))return void i(this,Ya,"m",Hl).call(this,p,I,C);if(p&&(s("token")&&k||s("code")&&I||s("exchangeError")&&C)){const e=yield this.sdk.flow.next(p,h,lo,G.version,Z.componentsVersion,{token:k,exchangeCode:I,exchangeError:C,origin:i(this,Ya,"a",Ul)});return i(this,Il,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===ao&&T&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!$)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(er("SAMLResponse",t,"saml-response")),o.appendChild(er("RelayState",n,"saml-relay-state")),document.body.appendChild(o),i(o)})(T,$,L||"",tr)}if(g===ao&&P&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>s(e)))){if(!W)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(er("wa","wsignin1.0")),o.appendChild(er("wresult",t)),o.appendChild(er("wctx",n)),document.body.appendChild(o),i(o)})(P,W,M||"",tr)}if(g===no&&(s("redirectTo")||s("deferredRedirect"))){if(!b)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===b)return;if("android"===R&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${w}`),w){this.loggerWrapper.debug("Opening redirect in popup");const e=dr(b,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));let n=!1;const o=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const i=t?this.popupOrigin:window.location.origin;if(e.origin!==i)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${i}"`);const{action:o,data:r}=e.data||{};"code"===o&&(n=!0,this.flowState.update({code:r.code,exchangeError:r.exchangeError}))};let r;this.loggerWrapper.debug("Starting popup closed detection");const s=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(s),i(this,Ya,"m",Jl).call(this,"popupclosed",{abandoned:!n}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==r||r())}),1e3);if(t)window.addEventListener("message",o),r=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",o)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=o,r=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else((e,t,n,i,o)=>{var r;if(null==n?void 0:n.oidcErrorRedirectUri){try{const t=new URL(e,window.location.href),i=new URL(n.oidcErrorRedirectUri);if(t.origin!==i.origin||t.pathname!==i.pathname)return}catch(e){return}No(i,o);try{t&&(null===(r=Lo())||void 0===r||r.removeItem($o(t)))}catch(e){}}})(b,Fo(p),Object.assign(Object.assign({},this.adoptedSsoQueryParams),Ao(q)),c,d),this.handleRedirect(b),this.flowState.update({redirectTo:"no-op"}),i(this,Ya,"m",Jl).call(this,"popupclosed",{});return}if(g===oo||g===ro){if(!O||!x)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");null===(l=i(this,tl,"f"))||void 0===l||l.abort(),o(this,tl,null,"f");const e=yield i(this,Ya,"m",vl).call(this,g,x),t=yield this.sdk.flow.next(p,h,lo,G.version,Z.componentsVersion,Object.assign({transactionId:O},e));i(this,Il,"f").call(this,t)}if(g===so)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,lo,G.version,Z.componentsVersion,e);i(this,Il,"f").call(this,t)})),i(this,Ya,"m",cl).call(this,N,_),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&i(this,wl,"f").call(this,p,h,G.version,Z.componentsVersion),!f&&!F)return void this.loggerWrapper.warn("No screen was found to show");const te=F||f,ne=yield this.getHtmlFilenameWithLocale(U,te),{oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,samlIdpUsername:ae}=q,le={direction:Vo(h,r.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:B,name:this.sdk.getLastUserDisplayName()||B},componentsConfig:Object.assign(Object.assign(Object.assign({},G.componentsConfig),ee),null==m?void 0:m.componentsConfig)}),htmlFilename:`${te}.html`,htmlLocaleFilename:ne,screenId:te,stepName:e.stepName||V,samlIdpUsername:ae,oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,action:g,locale:v(U).locale},ce=$r(B,this.loggerWrapper);Yo(F,q)?le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==G?void 0:G.clientScripts)||[];yield i(this,Ya,"m",_l).call(this,n);const o=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Q},q),{lastAuth:ce,preview:this.preview,abTestingKey:H,client:this.client}),y&&{redirectUrl:y}),{locale:v(U).locale,nativeOptions:Y,outboundAppId:K,outboundAppScopes:z}),J,e,Z.componentsVersion,X,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:i(this,Ya,"a",Ul)},this.formConfigValues),this.getComponentsContext()),lr(t)),I&&{exchangeCode:I,idpInitiated:!0}),q.descopeIdpInitiated&&{idpInitiated:!0}),k&&{token:k}),le.next.isCustomScreen);return i(this,Il,"f").call(this,o),o})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==m?void 0:m.clientScripts)||[];yield i(this,Ya,"m",_l).call(this,n);const o=yield this.sdk.flow.next(p,h,e,G.version,Z.componentsVersion,Object.assign(Object.assign({origin:i(this,Ya,"a",Ul)},this.getComponentsContext()),lr(t)),le.next.isCustomScreen);return i(this,Il,"f").call(this,o),o}))),this.loggerWrapper.debug("Got a screen with id",le.screenId),yield i(this,Ya,"m",fl).call(this,le),this.stepState.update(le)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r,s;const{htmlFilename:a,htmlLocaleFilename:l,direction:c,next:d,screenState:u,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen"),this.clearEmailVerification(),this.updateScreenUser(null==u?void 0:u.user);const p=document.createElement("template");p.innerHTML=yield this.getPageContent(a,l);const g=p.content.cloneNode(!0),f=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield i(this,Ya,"m",Ol).call(this,g,d):g.querySelectorAll(`descope-button[${to}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(o=u.form)||void 0===o?void 0:o.loginId)||(null===(r=u.form)||void 0===r?void 0:r.email)||(u.form||(u.form={}),u.form.loginId=e.samlIdpUsername,u.form.email=e.samlIdpUsername),Or(g,u,this.formConfig,this.loggerWrapper),this.applyComponentsState(g,null==u?void 0:u.componentsState),this.startEmailVerification(g);const{geo:v}=null!==(s=yield this.getExecutionContext())&&void 0!==s?s:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([n,i])=>{Array.from(e.querySelectorAll(`[${n}="${i}"]`)).forEach((e=>{e.setAttribute(n,t||i)}))}))})(g,v),((e,t)=>{let n=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(n=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`[${t}="${i}"]`)).forEach((e=>{e.setAttribute(t,n||i)}))}))})(g,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,o;yield f;const r=this.contentRootElement;var s,a;s=r,a=null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image,Cr(s,"descope-totp-image",a),((e,t)=>{Cr(e,"descope-notp-image",t)})(r,null===(o=null==u?void 0:u.notp)||void 0===o?void 0:o.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{if(!t.querySelector(o))return void i.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,g,u.cssVars,this.loggerWrapper),r.replaceChildren(g);const l=!t.htmlFilename;setTimeout((()=>{i(this,Ya,"m",Wl).call(this),this.updateUsernameAnchor(),this.validateOnBlur&&((e,t)=>{e.querySelectorAll("*[name]").forEach((n=>{n.addEventListener("blur",(()=>{var i;if(vo(n,e))return;const o=()=>{var e;const i=n.focus;n.focus=()=>{};const o=null===(e=n.reportValidity)||void 0===e?void 0:e.call(n);t&&!1===o&&t(n),setTimeout((()=>{n.focus=i}))};if("true"===n.getAttribute("invalid")||(null===(i=n.value)||void 0===i?void 0:i.length))return void o();const r={timer:void 0},s=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(r.timer),r.timer=void 0)};r.timer=setTimeout((()=>{e.removeEventListener("click",s),o(),r.timer=void 0}),150),e.addEventListener("click",s,{once:!0})}))}))})(r,(e=>this.trackValidationErrors([e],i(this,Ya,"a",Rl)))),((e,t)=>{wr(e,null==t?void 0:t.inputs),wr(e,null==t?void 0:t.form)})(r,u),this.initRealtimeConditions(r,u),i(this,Ya,"m",xl).call(this,{isFirstScreen:l,isCustomScreen:!1,stepName:e.stepName}),Xo(r,this.autoFocus,l),i(this,Ya,"m",Fl).call(this,h)})),i(this,Ya,"m",Vl).call(this,d,h);r.querySelector(`[${to}="polling"]`)&&d(co,{})}));c?i(this,Ya,"m",bl).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${Wi}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}el=new WeakMap,tl=new WeakMap,nl=new WeakMap,il=new WeakMap,ol=new WeakMap,sl=new WeakMap,gl=new WeakMap,ml=new WeakMap,wl=new WeakMap,yl=new WeakMap,kl=new WeakMap,Il=new WeakMap,Sl=new WeakMap,Al=new WeakMap,El=new WeakMap,Ll=new WeakMap,Nl=new WeakMap,Ya=new WeakSet,rl=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},al=function(e,t,o){return n(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=n,i(this,Ya,"m",cl).call(this,"beforeScreen",{screen:e,context:t})}))}))},ll=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,Ya,"m",cl).call(this,"afterScreen",{screen:e})},cl=function(e,t){i(this,Ya,"m",Jl).call(this,"bridge",{type:e,payload:t})},dl=function({errorText:e,errorType:t}){const n=()=>{var n;let i=e;try{i=(null===(n=this.errorTransformer)||void 0===n?void 0:n.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${to}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",i)};this.addEventListener("screen-updated",n,{once:!0}),n()},ul=function(){var e,n,o,r;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=void 0===n?{}:n,{errorText:o,errorType:r}=i,s=t(i,["errorText","errorType"]),a=t(e,["screenState"]);return Object.assign(Object.assign({},a),{screenState:s})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,Ya,"m",dl).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(i(this,Ya,"m",hl).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(r=this.flowState)||void 0===r||r.subscribe((({screenId:e,executionId:t})=>{var n;try{this.updateTelemetryContext({screenId:e,executionId:t})}catch(e){null===(n=this.logger)||void 0===n||n.error("Error updating telemetry screenId:",e)}}),(e=>({screenId:e.screenId,executionId:e.executionId})))},hl=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Xo(this.contentRootElement,this.autoFocus,!1))},pl=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(Object.assign({stepId:null,executionId:null},this.adoptedSsoQueryParams))):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},fl=function(e){return n(this,void 0,void 0,(function*(){var n;const r=Object.assign(Object.assign({},this.stepState.current),e),{next:s,stepName:a}=r,l=t(r,["next","stepName"]),c=ar(l);let d=yield i(this,Ya,"m",al).call(this,a,c,s);d||(d=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,c,s,this)));const u=!this.stepState.current.htmlFilename;if(i(this,ml,"f").call(this,d),s&&(s.isCustomScreen=d),i(this,gl,"f")!==d){const[e,t]=["flow","custom"].sort((()=>d?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,gl,d,"f"),d?this.stepState.unsubscribeAll():i(this,Ya,"m",ul).call(this)}d?(this.loggerWrapper.debug("Showing a custom screen"),i(this,Ya,"m",xl).call(this,{isFirstScreen:u,isCustomScreen:d,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=d}))},vl=function(e,t){return n(this,void 0,void 0,(function*(){const n=new AbortController;try{const i=e===oo?this.sdk.webauthn.helpers.create(t,n):this.sdk.webauthn.helpers.get(t,n),o=yield Qo(9e4,i,Kl);return o!==Kl?{response:o}:(n.abort(),this.loggerWrapper.warn("WebAuthn operation timed out after 90000ms"),{failure:"AbortError",failureReason:"aborted",failureMessage:"Passkey operation timed out"})}catch(e){return"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),{failure:e.name,failureReason:e.reason,failureMessage:e.message}}}))},bl=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")},Cl=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)}))}},Ol=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,tl,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield xr())){const{options:e,transactionId:r}=(yield i(this,Sl,"f").call(this))||{};e&&r&&(i(this,Ya,"m",Cl).call(this,s),o(this,tl,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,tl,"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)})))}}))},xl=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,Ya,"m",Jl).call(this,"ready",{}),t||i(this,Ya,"m",ll).call(this,n),i(this,Ya,"m",Jl).call(this,"page-updated",{screenName:n}),i(this,Ya,"m",Jl).call(this,"screen-updated",{screenName:n})},jl=function(e,t,n){this.setValidationTrackingEnabled(!!e.clientValidationTrackingEnabled),t&&n("executionId")&&this.setValidationTrackingExecution(t)},Rl=function(){var e,t,n,o,r,s,a;const l=null===(e=this.flowState)||void 0===e?void 0:e.current;return(null==l?void 0:l.executionId)?{executionId:l.executionId,screenId:l.screenId,screenName:(null===(a=null===(s=this.stepState)||void 0===s?void 0:s.current)||void 0===a?void 0:a.stepName)||l.stepName}:{executionId:void 0,screenId:null!==(t=i(this,Al,"f"))&&void 0!==t?t:null==l?void 0:l.screenId,screenName:null!==(n=i(this,El,"f"))&&void 0!==n?n:(null===(r=null===(o=this.stepState)||void 0===o?void 0:o.current)||void 0===r?void 0:r.stepName)||(null==l?void 0:l.stepName)}},Ul=function(){var e;return(null===(e=this.nativeOptions)||void 0===e?void 0:e.origin)||window.location.origin},Tl=function(){let e=!0;const t=[];return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((n=>{var i,o,r;"slot"===n.localName||vo(n,this.contentRootElement)||(null===(i=n.reportValidity)||void 0===i||i.call(n),n.validity&&!n.validity.valid&&t.push(n),e&&(e=null===(r=null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))||void 0===r||r))})),t.length&&this.trackValidationErrors(t,i(this,Ya,"a",Rl)),e},$l=function(){return n(this,void 0,void 0,(function*(){const e=this.getInputs();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})),{})}))},Pl=function(e){var t,r;const s=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),a=(null===(r=null===(t=this.flowState.current)||void 0===t?void 0:t.screenState)||void 0===r?void 0:r.clientScripts)||[];e.setAttribute("loading","true"),s.forEach((e=>e.setAttribute("disabled","true")));const l=()=>{e.removeAttribute("loading"),s.forEach((e=>{e.removeAttribute("disabled")}))},c=e=>n(this,void 0,void 0,(function*(){var t;this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",c);if(!0===(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.abandoned)&&a.length)return o(this,nl,(()=>n(this,void 0,void 0,(function*(){try{yield this.loadSdkScripts(a)}catch(e){this.loggerWrapper.warn("Failed to refresh client scripts on popup close",null==e?void 0:e.message)}})))(),"f"),void l();l();const i=yield this.getFlowConfig(),r=[...i.clientScripts||[],...i.sdkScripts||[]];this.loadSdkScripts(r)})),d=()=>{var e;window.removeEventListener("pageshow",i(this,Ll,"f")),o(this,Ll,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),c())}),"f"),window.addEventListener("pageshow",i(this,Ll,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&c(),this.removeEventListener("popupclosed",c),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},u=this.nextRequestStatus.subscribe((({isLoading:e})=>{e?this.addEventListener("popupclosed",c,{once:!0}):(this.nextRequestStatus.unsubscribe(u),"success"===this.flowStatus?(this.removeEventListener("popupclosed",c),l()):d())}));return l},Wl=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()));this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,Ya,"m",Ml).call(this,e)))},Ml=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),i=`input-${e.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),e.appendChild(o),t.setAttribute("slot",i),this.appendChild(t)}))},_l=function(e){return n(this,void 0,void 0,(function*(){if(i(this,nl,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,nl,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),n=e.map((e=>e.id));for(const e of t)if(n.includes(e.id))try{if("function"==typeof e.present){(yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`)}}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const o=[];for(const e of t)"function"==typeof e.refresh&&o.push(e.refresh());if(o.length>0)try{yield Qo(5e3,Promise.all(o),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Dl=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var o;(null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))&&i(this,Nl,"f").call(this,n,e,t)}))}))},ql=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=Pr();n[e]=t,jr(ho,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},Fl=function(e){var t;const n=null===(t=$r(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const i=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);i&&o&&(o.replaceWith(i),i.appendChild(o))},Vl=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${Mi}]), [data-type="button"]:not([${Mi}]`).forEach((n=>{n.onclick=()=>{i(this,Nl,"f").call(this,n,e,t)}})),i(this,Ya,"m",Dl).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${Wi}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Jl=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},Hl=function(e,t,n){var i;const[o,r]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],s="descope-wc"===o&&!!r,a=s?zo(r):void 0;s&&!a&&this.loggerWrapper.warn("Popup opener origin is not approved for this project, add it to the approved domains to send the OAuth result to it",r);const l={data:{code:t,exchangeError:n},action:"code"};if(a){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",a);try{window.opener.postMessage(l,a)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(l),t.close()}try{window.close()}catch(e){}},zl.bridgeVersion=3,customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",zl);const Bl=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};var Gl,Zl,Xl,Ql,Yl,ec,tc,nc,ic,oc;const rc=document.createElement("template");rc.innerHTML='\n<div class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n';const sc=r(us)(HTMLElement);let ac=class extends sc{constructor(){var e;super(),Gl.add(this),Zl.set(this,new g({messages:[]})),Xl.set(this,void 0),Ql.set(this,void 0),Yl.set(this,void 0),ec.set(this,{resize:i(this,Gl,"m",oc).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(rc.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),o(this,Xl,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Xl,"f").style.top="32px",i(this,Xl,"f").style.left=window.innerWidth-300-32+"px",o(this,Ql,i(this,Xl,"f").querySelector(".content"),"f"),o(this,Yl,i(this,Xl,"f").querySelector(".header"),"f")}updateData(e){i(this,Zl,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Bl(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,Xl,"f"),i(this,Yl,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,ec,"f").resize),(e=i(this,Xl,"f")).onmousemove=t=>{var n;const i=t.target;(i.w&&i.w!==i.offsetWidth||i.h&&i.h!==i.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),i.w=i.offsetWidth,i.h=i.offsetHeight},i(this,Xl,"f").onresize=i(this,Gl,"m",ic).bind(this),i(this,Zl,"f").subscribe(i(this,Gl,"m",tc).bind(this))}disconnectedCallback(){i(this,Zl,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,ec,"f").resize)}};Zl=new WeakMap,Xl=new WeakMap,Ql=new WeakMap,Yl=new WeakMap,ec=new WeakMap,Gl=new WeakSet,tc=function(e){i(this,Gl,"m",nc).call(this,e),i(this,Gl,"m",ic).call(this)},nc=function(e){i(this,Ql,"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 ${f(e.title)}\n </div>\n <div class="msg_desc">\n ${f(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},ic=function(){i(this,Ql,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),i=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;i||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},oc=function(){const[e,t]=Bl(i(this,Xl,"f"),Number.parseInt(i(this,Xl,"f").style.left,10),Number.parseInt(i(this,Xl,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Xl,"f").style.top=`${t}px`,i(this,Xl,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",ac);var lc,cc,dc,uc,hc,pc,gc,fc,vc,mc,bc,wc=Object.freeze({__proto__:null});const yc=document.createElement("template");yc.innerHTML='\n<div class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n';const kc=r(us)(HTMLElement);class Ic extends kc{constructor(){super(),lc.add(this),cc.set(this,new vr({messages:[]})),dc.set(this,void 0),uc.set(this,void 0),hc.set(this,void 0),pc.set(this,{resize:i(this,lc,"m",bc).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(yc.content.cloneNode(!0)),o(this,dc,this.shadowRoot.querySelector(".debugger"),"f"),o(this,uc,i(this,dc,"f").querySelector(".content"),"f"),o(this,hc,i(this,dc,"f").querySelector(".header"),"f"),i(this,lc,"m",gc).call(this)}updateData(e){i(this,cc,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;null===(t=e.init)||void 0===t||t.call(this),((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=Ar(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,dc,"f"),i(this,hc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,pc,"f").resize),(n=i(this,dc,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&n.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},i(this,dc,"f").onresize=i(this,lc,"m",mc).bind(this),i(this,cc,"f").subscribe(i(this,lc,"m",fc).bind(this))}))}disconnectedCallback(){i(this,cc,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,pc,"f").resize)}}cc=new WeakMap,dc=new WeakMap,uc=new WeakMap,hc=new WeakMap,pc=new WeakMap,lc=new WeakSet,gc=function(){this.injectStyle('\n .debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),i(this,dc,"f").style.top="32px",i(this,dc,"f").style.left=window.innerWidth-300-32+"px"},fc=function(e){i(this,lc,"m",vc).call(this,e),i(this,lc,"m",mc).call(this)},vc=function(e){i(this,uc,"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 ${f(e.title)}\n </div>\n <div class="msg_desc">\n ${f(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},mc=function(){i(this,uc,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,i=t.clientHeight>20;n||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},bc=function(){const[e,t]=Ar(i(this,dc,"f"),Number.parseInt(i(this,dc,"f").style.left,10),Number.parseInt(i(this,dc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,dc,"f").style.top=`${t}px`,i(this,dc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Ic);var Sc=Object.freeze({__proto__:null,default:Ic})}();
|