@descope/user-profile-widget 0.2.3 → 0.2.4
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/index.js +6 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +94 -94
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* @descope/user-profile-widget v0.2.
|
|
3
|
+
* @descope/user-profile-widget v0.2.4
|
|
4
4
|
*/
|
|
5
|
-
this["descope-user-profile-widget"]=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=>{let t,n;return(...i)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,i)||(t=i,n=e(...i)),n)},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 f=class{constructor(e={},{updateOnlyOnChange:t=!0}={}){c.set(this,void 0),d.set(this,{}),u.set(this,0),h.set(this,!1),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;class g extends Error{}function v(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 m(e,t){if("string"!=typeof e)throw new g("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 g(`Invalid token specified: missing part #${n+1}`);let o;try{o=v(i)}catch(e){throw new g(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new g(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}g.prototype.name="InvalidTokenError";var b="/v1/auth/accesskey/exchange",w="/v1/auth/otp/verify",y="/v1/auth/otp/signin",k="/v1/auth/otp/signup",I={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},S="/v1/auth/otp/signup-in",C="/v1/auth/magiclink/verify",j="/v1/auth/magiclink/signin",x="/v1/auth/magiclink/signup",A={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},E="/v1/auth/magiclink/signup-in",O="/v1/auth/enchantedlink/verify",U="/v1/auth/enchantedlink/signin",_="/v1/auth/enchantedlink/signup",R="/v1/auth/enchantedlink/pending-session",T={email:"/v1/auth/enchantedlink/update/email"},M="/v1/auth/enchantedlink/signup-in",L="/v1/auth/oauth/authorize",P="/v1/auth/oauth/exchange",$="v1/auth/oauth/native/start",W="v1/auth/oauth/native/finish",D="/v1/auth/saml/authorize",N="/v1/auth/saml/exchange",F="/v1/auth/totp/verify",q="/v1/auth/totp/signup",z="/v1/auth/totp/update",B="/v1/auth/notp/whatsapp/signin",V="/v1/auth/notp/whatsapp/signup",H="/v1/auth/notp/whatsapp/signup-in",K="/v1/auth/notp/pending-session",G={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},J={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},X={start:"/v1/auth/webauthn/signup-in/start"},Y={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},Z="/v1/auth/password/signup",Q="/v1/auth/password/signin",ee="/v1/auth/password/reset",te="/v1/auth/password/update",ne="/v1/auth/password/replace",ie="/v1/auth/password/policy",oe="/v1/auth/refresh",re="/v1/auth/tenant/select",se="/v1/auth/logout",ae="/v1/auth/logoutall",le="/v1/auth/me",ce="/v1/auth/me/tenants",de="/v1/auth/me/history",ue="/v1/flow/start",he="/v1/flow/next";const pe="<region>",fe=`https://api.${pe}descope.com`,ge=6e5,ve="dct",me=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};let be;const we=()=>{if(be)return be;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 be=`${t}-${n}`,be};var ye;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(ye||(ye={}));const ke=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(pe,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},Ie=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,i])=>(e[n]=i,e)),e),e}),{})),Se={"Content-Type":"application/json"},Ce=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},je=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e},xe=({baseUrl:e,projectId:t,baseConfig:n,logger:i,hooks:o,cookiePolicy:r,fetch:s})=>{const a=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>me().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await n(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return me().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(i)),i}:n})(i,s),l=async i=>{var s;const l=(null==o?void 0:o.beforeRequest)?o.beforeRequest(i):i,{path:c,body:d,headers:u,queryParams:h,method:p,token:f}=l,g=(e=>void 0===e?void 0:JSON.stringify(e))(d),v={headers:Ie(Ce(t,f),{"x-descope-sdk-session-id":we(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.33.0"},(null==n?void 0:n.baseHeaders)||{},je(g)?Se:{},u),method:p,body:g};null!==r&&(v.credentials=r||"include");const m=await a(ke({path:c,baseUrl:e,queryParams:h,projectId:t}),v);if((null==o?void 0:o.afterRequest)&&await o.afterRequest(i,null==m?void 0:m.clone()),null==o?void 0:o.transformResponse){const e=await m.json(),t=((null===(s=m.headers)||void 0===s?void 0:s.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,i]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:i})}),{}),n=Object.assign(Object.assign({},m),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,o.transformResponse(n)}return m};return{get:(e,{headers:t,queryParams:n,token:i}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:ye.get,token:i}),post:(e,t,{headers:n,queryParams:i,token:o}={})=>l({path:e,headers:n,queryParams:i,body:t,method:ye.post,token:o}),patch:(e,t,{headers:n,queryParams:i,token:o}={})=>l({path:e,headers:n,queryParams:i,body:t,method:ye.patch,token:o}),put:(e,t,{headers:n,queryParams:i,token:o}={})=>l({path:e,headers:n,queryParams:i,body:t,method:ye.put,token:o}),delete:(e,{headers:t,queryParams:n,token:i}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:ye.delete,token:i}),hooks:o,buildUrl:(n,i)=>ke({projectId:t,baseUrl:e,path:n,queryParams:i})}};var Ae=429;function Ee(e,t,n){var i;let o=Oe(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[ve])===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 Oe(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return m(e)}function Ue(e){const{exp:t}=Oe(e);return(new Date).getTime()/1e3>t}function _e(e){let t=Oe(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Re(e,t){return Ee(e,t,"permissions")}function Te(e,t){return Ee(e,t,"roles")}const Me=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Le(e,t){var n;const i=await e,o={code:i.status,ok:i.ok,response:i},r=await i.clone().json();return i.ok?o.data=t?t(r):r:(o.error=r,i.status===Ae&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}const Pe=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),$e=(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 "))},We=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),De=e=>t=>e.test(t),Ne=De(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Fe=De(/^\+[1-9]{1}[0-9]{3,14}$/),qe=Pe(Ne,'"{val}" is not a valid email'),ze=Pe(Fe,'"{val}" is not a valid phone number'),Be=Pe((e=>e.length>=1),"Minimum length is 1");const Ve=Pe((e=>"string"==typeof e),"Input is not a string"),He=Pe((e=>Array.isArray(e)),"Input is not an array"),Ke=Pe((e=>"boolean"==typeof e),"Input is not a boolean"),Ge=Pe((e=>void 0===e),"Input is defined"),Je=$e([Ve(),Ge()],"Input is not a string or undefined"),Xe=$e([He(),Ke()],"Input is not an array or boolean"),Ye=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>We(...e).validate(n[t]))),t(...n)),Ze=e=>[Ve(`"${e}" must be a string`)],Qe=e=>[Ve(`"${e}" must be a string`),Be(`"${e}" must not be empty`)],et=e=>[Ve(`"${e}" must be a string`),qe()],tt=e=>[Ve(`"${e}" must be a string`),ze()],nt=Ye(Qe("accessKey")),it=e=>({exchange:nt(((t,n)=>Le(e.post(b,{loginOptions:n},{token:t}))))}),ot=(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),rt=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||ge,ge)});var st,at;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(st||(st={})),function(e){e.email="email"}(at||(at={}));const lt=Object.assign(Object.assign({},st),at);var ct;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(ct||(ct={}));const dt=Qe("loginId"),ut=Ye(Qe("token")),ht=Ye(dt),pt=Ye(Qe("pendingRef")),ft=Ye(dt,et("email")),gt=e=>({verify:ut((t=>Le(e.post(O,{token:t})))),signIn:ht(((t,n,i,o)=>Le(e.post(Me(U,lt.email),{loginId:t,URI:n,loginOptions:i},{token:o})))),signUpOrIn:ht(((t,n,i)=>Le(e.post(Me(M,lt.email),{loginId:t,URI:n,loginOptions:i})))),signUp:ht(((t,n,i,o)=>Le(e.post(Me(_,lt.email),{loginId:t,URI:n,user:i,loginOptions:o})))),waitForSession:pt(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=rt(n);let s;const a=setInterval((async()=>{const n=await e.post(R,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(Le(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:ft(((t,n,i,o,r)=>Le(e.post(T.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o}))))}}),vt=Ye(Qe("flowId")),mt=Ye(Qe("executionId"),Qe("stepId"),Qe("interactionId")),bt=e=>({start:vt(((t,n,i,o,r,s,a)=>Le(e.post(ue,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a})))),next:mt(((t,n,i,o,r,s)=>Le(e.post(he,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s}))))}),wt=Qe("loginId"),yt=Ye(Qe("token")),kt=Ye(wt),It=Ye(wt,tt("phone")),St=Ye(wt,et("email")),Ct=Object.keys(lt).filter((e=>e!==st.voice)),jt=e=>({verify:yt((t=>Le(e.post(C,{token:t})))),signIn:Ct.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:kt(((t,i,o,r)=>Le(e.post(Me(j,n),{loginId:t,URI:i,loginOptions:o},{token:r}))))})),{}),signUp:Ct.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:kt(((t,i,o,r)=>Le(e.post(Me(x,n),{loginId:t,URI:i,user:o,loginOptions:r}))))})),{}),signUpOrIn:Ct.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:kt(((t,i,o)=>Le(e.post(Me(E,n),{loginId:t,URI:i,loginOptions:o}))))})),{}),update:{email:St(((t,n,i,o,r)=>Le(e.post(A.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(st).filter((e=>e!==st.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:It(((t,i,o,r,s)=>Le(e.post(Me(A.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var xt;!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"}(xt||(xt={}));const At=Ye(Qe("code")),Et=e=>({start:Object.assign(((t,n,i,o)=>Le(e.post(L,i||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:o}))),Object.keys(xt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o)=>Le(e.post(L,i||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:o}))})),{})),exchange:At((t=>Le(e.post(P,{code:t})))),startNative:(t,n,i)=>Le(e.post($,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>Le(e.post(W,{provider:t,stateId:n,user:i,code:o,idToken:r}))}),Ot=Qe("loginId"),Ut=Ye(Ot,Qe("code")),_t=Ye(Ot),Rt=Ye(Ot,tt("phone")),Tt=Ye(Ot,et("email")),Mt=e=>({verify:Object.keys(lt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ut(((t,i)=>Le(e.post(Me(w,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(lt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:_t(((t,i,o)=>Le(e.post(Me(y,n),{loginId:t,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(lt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:_t(((t,i,o)=>Le(e.post(Me(k,n),{loginId:t,user:i,loginOptions:o}))))})),{}),signUpOrIn:Object.keys(lt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:_t(((t,i)=>Le(e.post(Me(S,n),{loginId:t,loginOptions:i}))))})),{}),update:{email:Tt(((t,n,i,o)=>Le(e.post(I.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(st).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Rt(((t,i,o,r)=>Le(e.post(Me(I.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),Lt=Ye(Qe("tenant")),Pt=Ye(Qe("code")),$t=e=>({start:Lt(((t,n,i,o)=>Le(e.post(D,i||{},{queryParams:{tenant:t,redirectURL:n},token:o})))),exchange:Pt((t=>Le(e.post(N,{code:t}))))}),Wt=Qe("loginId"),Dt=Ye(Wt,Qe("code")),Nt=Ye(Wt),Ft=Ye(Wt),qt=e=>({signUp:Nt(((t,n)=>Le(e.post(q,{loginId:t,user:n})))),verify:Dt(((t,n,i,o)=>Le(e.post(F,{loginId:t,code:n,loginOptions:i},{token:o})))),update:Ft(((t,n)=>Le(e.post(z,{loginId:t},{token:n}))))}),zt=Qe("loginId"),Bt=Qe("newPassword"),Vt=Ye(zt,Qe("password")),Ht=Ye(zt),Kt=Ye(zt,Bt),Gt=Ye(zt,Qe("oldPassword"),Bt),Jt=e=>({signUp:Vt(((t,n,i,o)=>Le(e.post(Z,{loginId:t,password:n,user:i,loginOptions:o})))),signIn:Vt(((t,n,i)=>Le(e.post(Q,{loginId:t,password:n,loginOptions:i})))),sendReset:Ht(((t,n,i)=>Le(e.post(ee,{loginId:t,redirectUrl:n,templateOptions:i})))),update:Kt(((t,n,i)=>Le(e.post(te,{loginId:t,newPassword:n},{token:i})))),replace:Gt(((t,n,i)=>Le(e.post(ne,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>Le(e.get(ie))}),Xt=Ze("loginId"),Yt=Qe("loginId"),Zt=Qe("origin"),Qt=Ye(Yt,Zt,Qe("name")),en=Ye(Yt,Zt),tn=Ye(Xt,Zt),nn=Ye(Yt,Zt,Qe("token")),on=Ye(Qe("transactionId"),Qe("response")),rn=e=>({signUp:{start:Qt(((t,n,i,o)=>Le(e.post(G.start,{user:{loginId:t,name:i},origin:n,passkeyOptions:o})))),finish:on(((t,n)=>Le(e.post(G.finish,{transactionId:t,response:n}))))},signIn:{start:tn(((t,n,i,o,r)=>Le(e.post(J.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:on(((t,n)=>Le(e.post(J.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:en(((t,n,i)=>Le(e.post(X.start,{loginId:t,origin:n,passkeyOptions:i}))))},update:{start:nn(((t,n,i,o)=>Le(e.post(Y.start,{loginId:t,origin:n,passkeyOptions:o},{token:i})))),finish:on(((t,n)=>Le(e.post(Y.finish,{transactionId:t,response:n}))))}}),sn=Ze("loginId"),an=Ye(sn),ln=Ye(Qe("pendingRef")),cn=e=>({signUpOrIn:an(((t,n)=>Le(e.post(H,{loginId:t,loginOptions:n})))),signUp:an(((t,n,i)=>Le(e.post(V,{loginId:t,user:n,loginOptions:i})))),signIn:an(((t,n,i)=>Le(e.post(B,{loginId:t,loginOptions:n},{token:i})))),waitForSession:ln(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=rt(n);let s;const a=setInterval((async()=>{const n=await e.post(K,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(Le(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),dn=Ye(Qe("token")),un=Ye([Je('"token" must be string or undefined')]);var hn,pn=Ye([(hn=Qe("projectId"),Pe(((e,t)=>n=>We(...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",hn))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:i,cookiePolicy:o,baseHeaders:r={},fetch:s})=>{return a=xe({baseUrl:n||fe,projectId:e,logger:t,hooks:i,cookiePolicy:o,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:it(a),otp:Mt(a),magicLink:jt(a),enchantedLink:gt(a),oauth:Et(a),saml:$t(a),totp:qt(a),notp:cn(a),webauthn:rn(a),password:Jt(a),flow:bt(a),refresh:un(((e,t)=>Le(a.post(oe,{},{token:e,queryParams:t})))),selectTenant:Ye([Ve("tenantId")],[Je('"token" must be string or undefined')])(((e,t)=>Le(a.post(re,{tenant:e},{token:t})))),logout:un((e=>Le(a.post(se,{},{token:e})))),logoutAll:un((e=>Le(a.post(ae,{},{token:e})))),me:un((e=>Le(a.get(le,{token:e})))),myTenants:Ye([Xe('"tenants" must a string array or a boolean')],[Je('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,Le(a.post(ce,n,{token:t}))})),history:un((e=>Le(a.get(de,{token:e})))),isJwtExpired:dn(Ue),getTenants:dn(_e),getJwtPermissions:dn(Re),getJwtRoles:dn(Te),httpClient:a};var a})(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}}))})),fn=Object.assign(pn,{DeliveryMethods:lt});
|
|
5
|
+
this["descope-user-profile-widget"]=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=>{let t,n;return(...i)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,i)||(t=i,n=e(...i)),n)},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 f=class{constructor(e={},{updateOnlyOnChange:t=!0}={}){c.set(this,void 0),d.set(this,{}),u.set(this,0),h.set(this,!1),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 g=["error","warn","info","debug"],v=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,console))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e||console),"f")}get logger(){return i(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return g.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})),m="undefined"!=typeof localStorage,b=m&&localStorage.getItem("base.content.url")||"",w=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,y=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})),k=l((e=>{var t,n;const o=r(v,y)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=i(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){i(this,t,"f")[e]||(i(this,t,"f")[e]=[]);const o=i(this,t,"f")[e].push(n);return()=>i(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),I=e=>t=>{var n,o,s;const a=r(v,y,k)(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};I.missingAttrValidator=w;const S=l((e=>{const t=r(I({"project-id":w}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),C=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}}));const x=l((e=>{const t=r(v,S,C)(e);return class extends t{async fetchStaticResource(e,t){const n=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(b||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:e,baseUrl:this.baseStaticUrl}),i=await fetch(n,{cache:"default"});return i.ok||this.logger.error(`Error fetching URL ${n} [${i.status}]`),{body:await i[t](),headers:Object.fromEntries(i.headers.entries())}}get baseStaticUrl(){return this.getAttribute("base-static-url")}}})),j=l((e=>{var t,n,s;const a=r(x)(e);return s=class extends a{constructor(){super(...arguments),t.set(this,void 0),n.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")}}))}get config(){return i(this,t,"f")||o(this,t,i(this,n,"f").call(this),"f"),i(this,t,"f")}},t=new WeakMap,n=new WeakMap,s})),A=l((e=>{var t,n,s,a,l,c,d;return d=class extends(r(y,v)(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 vc})),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})),E="load-descope-ui",O="base.ui.components.url",U=m&&localStorage.getItem(O)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",_=m&&localStorage.getItem(O)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",R=m&&localStorage.getItem(O)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",T=e=>{const t=document.createElement("script");return t.id=e,t},M=(e,t)=>e.replace("<version>",t),L=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g;const m=r(v,j)(e);return g=class extends m{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),s.set(this,Symbol("loadCbs")),h.set(this,void 0)}get descopeUi(){return i(this,h,"f")||o(this,h,i(this,t,"m",f).call(this),"f"),i(this,h,"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",p).call(this,e))))}},n=new WeakMap,s=new WeakMap,h=new WeakMap,t=new WeakSet,a=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},l=function(e){const t=i(this,n,"f"),o=i(this,s,"f");e[t]=[],e[o]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[o].push(t)}})},c=async function(e,n,o,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const s=T(o);document.body.append(s),s.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${s.src}"`)))})),s.addEventListener("load",(()=>{n.forEach((e=>e()))})),s.src=M(r,await i(this,t,"m",a).call(this))},d=function(e){e.addEventListener("error",(()=>{e[i(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),i(this,t,"m",c).call(this,[i(this,t,"m",c).bind(this,e[i(this,n,"f")],e[i(this,s,"f")],"load-descope-ui-fallback-script-2",R),...e[i(this,n,"f")]],e[i(this,s,"f")],"load-descope-ui-fallback-script",_)})),e.addEventListener("load",(()=>{e[i(this,s,"f")].forEach((e=>e()))}))},u=async function(){if(document.querySelector(`script#${E}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=T(E);document.body.append(e),i(this,t,"m",l).call(this,e),i(this,t,"m",d).call(this,e),e.src=M(U,await i(this,t,"m",a).call(this))}return document.getElementById(E)},p=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(", ")}"`)},f=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),i(this,t,"m",u).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},g})),P="content-root",$="root",W=l((e=>class extends e{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${$}, #${P} {\n height: 100%;\n }\n #${$} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${$}">\n <div id="${P}"></div>\n </div>\n `,this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(P),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById($)}})),D="descope-modal";var N;let F=class{constructor(e,t){N.set(this,void 0),this.nodeName="",o(this,N,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,N,"f"))}get ele(){var e,t;const n="function"==typeof i(this,N,"f")?i(this,N,"f").call(this):i(this,N,"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)}};N=new WeakMap;let q=class extends F{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};var z;let B=class extends F{constructor(){super(...arguments),z.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),i(this,z,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,z,"f").content.cloneNode(!0)))}setContent(e){o(this,z,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};z=new WeakMap;let V=class extends F{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()}},H=class extends F{constructor(){super(...arguments),this.nodeName="descope-avatar"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}set image(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("img",e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}},K=class extends F{constructor(){super(...arguments),this.nodeName="descope-user-attribute"}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",e)}set badgeLabel(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("badge-label",e)}get label(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("label"))||""}get editFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("edit-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("delete-flow-id"))||""}onEditClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("edit-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("edit-clicked",e)}}onDeleteClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("delete-clicked",e)}}},G=class extends F{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,n;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(n=this.ele)||void 0===n||n.removeAttribute("fulfilled")}onButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}},J=class extends F{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}};const X=l((e=>{var t,n;const o=r(y,W,L)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends B{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(D);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;this.loadDescopeUiComponents([D]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),Y="descope-notification";l((e=>{var t,n;const o=r(y,W,L)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends V{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(Y);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([Y])}},t=new WeakMap,n}));const Z=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Q=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m;const b=r(I({theme:Z}),x,y,L,j,W,k)(e);return m=class extends b{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),f.set(this,(()=>{i(this,t,"m",g).call(this),i(this,v,"f").call(this,"os"===this.getAttribute("theme"))})),v.set(this,(e=>{var n,o,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===r||r.call(o,"change",(()=>i(this,t,"m",g).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",c).call(this),i(this,t,"m",d).call(this),i(this,f,"f").call(this),this.observeAttributes(["theme"],i(this,f,"f")),this.observeAttributes(["style-id"],(()=>{o(this,s,null,"f"),i(this,t,"m",h).call(this),i(this,t,"m",c).call(this),i(this,t,"m",d).call(this)}))}},n=new WeakMap,s=new WeakMap,f=new WeakMap,v=new WeakMap,t=new WeakSet,a=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(O))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(O),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},l=function(){return i(this,s,"f")||(o(this,s,i(this,t,"m",a).call(this),"f"),i(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,s,"f")},c=async function(){var e,r;const s=await i(this,t,"a",l);s&&(i(this,n,"f")||(o(this,n,document.createElement("style"),"f"),i(this,n,"f").id="global-style",this.shadowRoot.appendChild(i(this,n,"f"))),i(this,n,"f").innerText=((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)||""))},d=async function(){var e,n;const o=Object.assign({},await i(this,t,"a",l));if(!o)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.components,dark:null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.components})},u=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},h=async function(){const e=await i(this,t,"m",u).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},p=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},g=function(){i(this,t,"m",h).call(this),i(this,t,"m",p).call(this)},m}));var ee=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),te=()=>Math.random().toString(36).substring(7).split("").join("."),ne={INIT:`@@redux/INIT${te()}`,REPLACE:`@@redux/REPLACE${te()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${te()}`};function ie(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function oe(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function re(e){let t=typeof e;return t=oe(e),t}function se(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${re(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(`Expected the enhancer to be a function. Instead, received: '${re(n)}'`);return n(se)(e,t)}let i=e,o=t,r=new Map,s=r,a=0,l=!1;function c(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${re(e)}'`);if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;c();const n=a++;return s.set(n,e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,c(),s.delete(n),r=null}}}function h(e){if(!ie(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${re(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error(`Action "type" property must be a string. Instead, the actual type was: '${re(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,o=i(o,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:ne.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${re(e)}`);i=e,h({type:ne.REPLACE})},[ee]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${re(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[ee](){return this}}}}}function ae(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function le(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];void 0===e[o]&&ae(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const i=Object.keys(n);let o,r;o={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:ne.INIT}))throw new Error(`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:ne.PROBE_UNKNOWN_ACTION()}))throw new Error(`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${ne.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){r=e}return function(e={},t){if(r)throw r;{const i=function(e,t,n,i){const o=Object.keys(t),r=n&&n.type===ne.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!ie(e))return`The ${r} has unexpected type of "${re(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!i[e]));return s.forEach((e=>{i[e]=!0})),n&&n.type===ne.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);i&&ae(i)}let s=!1;const a={};for(let o=0;o<i.length;o++){const r=i[o],l=n[r],c=e[r],d=l(c,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=d,s=s||d!==c}return s=s||i.length!==Object.keys(e).length,s?a:e}}function ce(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function de(e){return ie(e)&&"type"in e&&"string"==typeof e.type}var ue=Symbol.for("immer-nothing"),he=Symbol.for("immer-draftable"),pe=Symbol.for("immer-state"),fe=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function ge(e,...t){{const n=fe[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}}var ve=Object.getPrototypeOf;function me(e){return!!e&&!!e[pe]}function be(e){return!!e&&(ye(e)||Array.isArray(e)||!!e[he]||!!e.constructor?.[he]||xe(e)||je(e))}var we=Object.prototype.constructor.toString();function ye(e){if(!e||"object"!=typeof e)return!1;const t=ve(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===we}function ke(e,t){0===Ie(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function Ie(e){const t=e[pe];return t?t.type_:Array.isArray(e)?1:xe(e)?2:je(e)?3:0}function Se(e,t){return 2===Ie(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ce(e,t,n){const i=Ie(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function xe(e){return e instanceof Map}function je(e){return e instanceof Set}function Ae(e){return e.copy_||e.base_}function Ee(e,t){if(xe(e))return new Map(e);if(je(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&ye(e)){if(!ve(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[pe];let i=Reflect.ownKeys(n);for(let t=0;t<i.length;t++){const o=i[t],r=n[o];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[o]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[o]})}return Object.create(ve(e),n)}function Oe(e,t=!1){return _e(e)||me(e)||!be(e)||(Ie(e)>1&&(e.set=e.add=e.clear=e.delete=Ue),Object.freeze(e),t&&ke(e,((e,t)=>Oe(t,!0)))),e}function Ue(){ge(2)}function _e(e){return Object.isFrozen(e)}var Re,Te={};function Me(e){const t=Te[e];return t||ge(0,e),t}function Le(){return Re}function Pe(e,t){t&&(Me("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function $e(e){We(e),e.drafts_.forEach(Ne),e.drafts_=null}function We(e){e===Re&&(Re=e.parent_)}function De(e){return Re={drafts_:[],parent_:Re,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ne(e){const t=e[pe];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Fe(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[pe].modified_&&($e(t),ge(4)),be(e)&&(e=qe(t,e),t.parent_||Be(t,e)),t.patches_&&Me("Patches").generateReplacementPatches_(n[pe].base_,e,t.patches_,t.inversePatches_)):e=qe(t,n,[]),$e(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ue?e:void 0}function qe(e,t,n){if(_e(t))return t;const i=t[pe];if(!i)return ke(t,((o,r)=>ze(e,i,t,o,r,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return Be(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const t=i.copy_;let o=t,r=!1;3===i.type_&&(o=new Set(t),t.clear(),r=!0),ke(o,((o,s)=>ze(e,i,t,o,s,n,r))),Be(e,t,!1),n&&e.patches_&&Me("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function ze(e,t,n,i,o,r,s){if(o===n&&ge(5),me(o)){const s=qe(e,o,r&&t&&3!==t.type_&&!Se(t.assigned_,i)?r.concat(i):void 0);if(Ce(n,i,s),!me(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(be(o)&&!_e(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;qe(e,o),t&&t.scope_.parent_||Be(e,o)}}function Be(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Oe(t,n)}var Ve={get(e,t){if(t===pe)return e;const n=Ae(e);if(!Se(n,t))return function(e,t,n){const i=Ge(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}(e,n,t);const i=n[t];return e.finalized_||!be(i)?i:i===Ke(e.base_,t)?(Xe(e),e.copy_[t]=Ye(i,e)):i},has:(e,t)=>t in Ae(e),ownKeys:e=>Reflect.ownKeys(Ae(e)),set(e,t,n){const i=Ge(Ae(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=Ke(Ae(e),t),o=i?.[pe];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,i)&&(void 0!==n||Se(e.base_,t)))return!0;Xe(e),Je(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==Ke(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Xe(e),Je(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Ae(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){ge(11)},getPrototypeOf:e=>ve(e.base_),setPrototypeOf(){ge(12)}},He={};function Ke(e,t){const n=e[pe];return(n?Ae(n):e)[t]}function Ge(e,t){if(!(t in e))return;let n=ve(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=ve(n)}}function Je(e){e.modified_||(e.modified_=!0,e.parent_&&Je(e.parent_))}function Xe(e){e.copy_||(e.copy_=Ee(e.base_,e.scope_.immer_.useStrictShallowCopy_))}ke(Ve,((e,t)=>{He[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),He.deleteProperty=function(e,t){return isNaN(parseInt(t))&&ge(13),He.set.call(this,e,t,void 0)},He.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&ge(14),Ve.set.call(this,e[0],t,n,e[0])};function Ye(e,t){const n=xe(e)?Me("MapSet").proxyMap_(e,t):je(e)?Me("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:Le(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,r=Ve;n&&(o=[i],r=He);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return i.draft_=a,i.revoke_=s,a}(e,t);return(t?t.scope_:Le()).drafts_.push(n),n}function Ze(e){return me(e)||ge(10,e),Qe(e)}function Qe(e){if(!be(e)||_e(e))return e;const t=e[pe];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Ee(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Ee(e,!0);return ke(n,((e,t)=>{Ce(n,e,Qe(t))})),t&&(t.finalized_=!1),n}var et=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const i=this;return function(e=n,...o){return i.produce(e,(e=>t.call(this,e,...o)))}}let i;if("function"!=typeof t&&ge(6),void 0!==n&&"function"!=typeof n&&ge(7),be(e)){const o=De(this),r=Ye(e,void 0);let s=!0;try{i=t(r),s=!1}finally{s?$e(o):We(o)}return Pe(o,n),Fe(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===ue&&(i=void 0),this.autoFreeze_&&Oe(i,!0),n){const t=[],o=[];Me("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}ge(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,i;const o=this.produce(e,t,((e,t)=>{n=e,i=t}));return[o,n,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){be(e)||ge(8),me(e)&&(e=Ze(e));const t=De(this),n=Ye(e,void 0);return n[pe].isManual_=!0,We(t),n}finishDraft(e,t){const n=e&&e[pe];n&&n.isManual_||ge(9);const{scope_:i}=n;return Pe(i,t),Fe(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}n>-1&&(t=t.slice(n+1));const i=Me("Patches").applyPatches_;return me(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},tt=et.produce;et.produceWithPatches.bind(et),et.setAutoFreeze.bind(et),et.setUseStrictShallowCopy.bind(et),et.applyPatches.bind(et),et.createDraft.bind(et),et.finishDraft.bind(et);var nt=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},it=(e,t,n)=>{const{memoize:i,memoizeOptions:o}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=i((()=>({})),...o);if(!(a.apply(null,r)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:r,secondInputs:s,stack:e})}},ot={inputStabilityCheck:"once",identityFunctionCheck:"once"};var rt=e=>Array.isArray(e)?e:[e];function st(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function at(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var lt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},ct=0,dt=1;function ut(){return{s:ct,v:void 0,o:null,p:null}}function ht(e,t={}){let n=ut();const{resultEqualityCheck:i}=t;let o,r=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const i=e.get(n);void 0===i?(t=ut(),e.set(n,t)):t=i}else{let e=t.p;null===e&&(t.p=e=new Map);const i=e.get(n);void 0===i?(t=ut(),e.set(n,t)):t=i}}const a=t;let l;if(t.s===dt)l=t.v;else if(l=e.apply(null,arguments),r++,i){const e=o?.deref?.()??o;null!=e&&i(e,l)&&(l=e,0!==r&&r--);o="object"==typeof l&&null!==l||"function"==typeof l?new lt(l):l}return a.s=dt,a.v=l,l}return s.clearCache=()=>{n=ut(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function pt(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,i=(...e)=>{let t,i=0,o=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:l,memoizeOptions:c=[],argsMemoize:d=ht,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=rt(c),f=rt(u),g=st(e),v=l((function(){return i++,s.apply(null,arguments)}),...p);let m=!0;const b=d((function(){o++;const e=at(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...ot,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:nt},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:it}}})(m,h);if(n.shouldRun&&n.run(s,e,t),i.shouldRun){const t=at(g,arguments);i.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(b,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:l,argsMemoize:d})};return Object.assign(i,{withTypes:()=>i}),i}var ft=pt(ht),gt=Object.assign(((e,t=ft)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e),i=t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,i)=>(e[n[i]]=t,e)),{})));return i}),{withTypes:()=>gt});function vt(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var mt=vt(),bt=vt;((...e)=>{const t=pt(...e)})(ht);var wt="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?ce:ce.apply(null,arguments)},yt=e=>e&&"function"==typeof e.match;function kt(e,t){function n(...n){if(t){let i=t(...n);if(!i)throw new Error("prepareAction did not return an object");return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>de(t)&&t.type===e,n}function It(e){return"function"==typeof e&&"type"in e&&yt(e)}function St(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var Ct=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function xt(e){return be(e)?tt(e,(()=>{})):e}function jt(e,t,n){if(e.has(t)){let i=e.get(t);return n.update&&(i=n.update(i,t,e),e.set(t,i)),i}if(!n.insert)throw new Error("No insert provided for key not already in map");const i=n.insert(t,e);return e.set(t,i),i}function At(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Et(e,t,n){const i=Ot(e,t,n);return{detectMutations:()=>Ut(e,t,i,n)}}function Ot(e,t=[],n,i="",o=new Set){const r={value:n};if(!e(n)&&!o.has(n)){o.add(n),r.children={};for(const o in n){const s=i?i+"."+o:o;t.length&&-1!==t.indexOf(s)||(r.children[o]=Ot(e,t,n[o],s))}}return r}function Ut(e,t=[],n,i,o=!1,r=""){const s=n?n.value:void 0,a=s===i;if(o&&!a&&!Number.isNaN(i))return{wasMutated:!0,path:r};if(e(s)||e(i))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in i)l[e]=!0;const c=t.length>0;for(let o in l){const s=r?r+"."+o:o;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=Ut(e,t,n.children[o],i[o],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function _t(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||ie(e)}function Rt(e,t="",n=_t,i,o=[],r){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=i?i(e):Object.entries(e),l=o.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=Rt(c,a,n,i,o,r),s))return s}return r&&Tt(e)&&r.add(e),!1}function Tt(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Tt(t))return!1;return!0}function Mt(e){return"boolean"==typeof e}var Lt=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=e??{};let r=new Ct;if(t&&(Mt(t)?r.push(mt):r.push(bt(t.extraArgument))),n){let e={};Mt(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,i,o){return JSON.stringify(e,n(t,o),i)},n=function(e,t){let n=[],i=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+i.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?i.splice(s,1/0,o):i.push(o),~n.indexOf(r)&&(r=t.call(this,o,r))}else n.push(r);return null==e?r:e.call(this,o,r)}},{isImmutable:i=At,ignoredPaths:o,warnAfter:r=32}=e;const s=Et.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=s(i);return a=>l=>{const c=St(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(l);return c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(l)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),c.warnIfExceeded(),d}}}}(e))}if(i){let e={};Mt(i)||(e=i),r.push(function(e={}){{const{isSerializable:t=_t,getEntries:n,ignoredActions:i=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:l=!1,disableCache:c=!1}=e,d=!c&&WeakSet?new WeakSet:void 0;return e=>c=>u=>{if(!de(u))return c(u);const h=c(u),p=St(s,"SerializableStateInvariantMiddleware");return l||i.length&&-1!==i.indexOf(u.type)||p.measureTime((()=>{const e=Rt(u,"",t,n,o,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const i=Rt(e.getState(),"",t,n,r,d);if(i){const{keyPath:e,value:t}=i;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(o){let e={};Mt(o)||(e=o),r.unshift(function(e={}){const{isActionCreator:t=It}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return r},Pt=e=>t=>{setTimeout(t,e)},$t="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Pt(10),Wt=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new Ct(e);return n&&i.push(((e={type:"raf"})=>t=>(...n)=>{const i=t(...n);let o=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?$t:"callback"===e.type?e.queueNotification:Pt(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},i,{subscribe(e){const t=i.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,r=!o,r&&(s||(s=!0,l(c))),i.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),i};function Dt(e){const t=Lt(),{reducer:n,middleware:i,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!ie(n))throw new Error("`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=le(n)}if(i&&"function"!=typeof i)throw new Error("`middleware` field must be a callback");if("function"==typeof i){if(l=i(t),!Array.isArray(l))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else l=t();if(l.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let c=ce;o&&(c=wt({trace:!0,..."object"==typeof o&&o}));const d=function(...e){return t=>(n,i)=>{const o=t(n,i);let r=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:o.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=ce(...a)(o.dispatch),{...o,dispatch:r}}}(...l),u=Wt(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");l.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return se(a,r,c(...h))}function Nt(e){const t={},n=[];let i;const o={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(i)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,o},addMatcher(e,t){if(i)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(i)throw new Error("`builder.addDefaultCase` can only be called once");return i=e,o}};return e(o),[t,n,i]}function Ft(...e){return t=>e.some((e=>((e,t)=>yt(e)?e.match(t):e(t))(e,t)))}var qt=["name","message","stack","code"],zt=class{constructor(e,t){this.payload=e,this.meta=t}_type},Bt=class{constructor(e,t){this.payload=e,this.meta=t}_type},Vt=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of qt)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},Ht=(()=>{function e(e,t,n){const i=kt(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=kt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=kt(e+"/rejected",((e,t,i,o,r)=>({payload:o,error:(n&&n.serializeError||Vt)(e||"Rejected"),meta:{...r||{},arg:i,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,l)=>{const c=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let r=n?.condition?.(e,{getState:a,extra:l});if(null!==(f=r)&&"object"==typeof f&&"function"==typeof f.then&&(r=await r),!1===r||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(o(c,e,n?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new zt(e,t),fulfillWithValue:(e,t)=>new Bt(e,t)})).then((t=>{if(t instanceof zt)throw t;return t instanceof Bt?i(t.payload,c,e,t.meta):i(t,c,e)}))])}catch(t){p=t instanceof zt?r(null,c,e,t.payload,t.meta):r(t,c,e)}var f;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:c,arg:e,unwrap:()=>p.then(Kt)})}}),{pending:o,rejected:r,fulfilled:i,settled:Ft(r,i),typePrefix:e})}return e.withTypes=()=>e,e})();function Kt(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var Gt=Symbol.for("rtk-slice-createasyncthunk");function Jt(e,t){return`${e}/${t}`}function Xt(e,t,n,i){function o(o,...r){let s=n.call(e,o);if(void 0===s){if(!i)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return o.unwrapped=t,o}var Yt=function({creators:e}={}){const t=e?.asyncThunk?.[Gt];return function(e){const{name:n,reducerPath:i=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function l(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],i]="function"==typeof e.extraReducers?Nt(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[i,o,r]=Nt(t);if(function(e){return"function"==typeof e}(e))n=()=>xt(e());else{const t=xt(e);n=()=>t}function s(e=n(),t){let s=[i[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,n)=>{if(n){if(me(e)){const i=n(e,t);return void 0===i?e:i}if(be(e))return tt(e,(e=>n(e,t)));{const i=n(e,t);if(void 0===i){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return i}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);i&&e.addDefaultCase(i)}))}r.forEach((i=>{const r=o[i],s={reducerName:i,type:Jt(n,i),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},i,o){let r,s;if("reducer"in i){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(i))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=i.reducer,s=i.prepare}else r=i;o.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?kt(e,s):kt(e))}(s,r,a):function({type:e,reducerName:t},n,i,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:l,settled:c,options:d}=n,u=o(e,r,d);i.exposeAction(t,u),s&&i.addCase(u.fulfilled,s);a&&i.addCase(u.pending,a);l&&i.addCase(u.rejected,l);c&&i.addMatcher(u.settled,c);i.exposeCaseReducer(t,{fulfilled:s||Zt,pending:a||Zt,rejected:l||Zt,settled:c||Zt})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:i,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const n=jt(d,this,{insert:()=>new WeakMap});return jt(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=Xt(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const i=t??this.reducerPath;return e.inject({reducerPath:i,reducer:this.reducer},n),{...this,reducerPath:i}}};return h}}();function Zt(){}var Qt="listenerMiddleware";kt(`${Qt}/add`),kt(`${Qt}/removeAll`),kt(`${Qt}/remove`);const en=e=>l((t=>{const n=Yt(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(v)(t)){constructor(...e){super(...e);const t=Dt({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...n)=>{const i=await t.dispatch(e(...n));try{Kt(i)}catch(e){this.logger.error(e.message,i.type,e.stack)}return i},r=Object.keys(i).reduce(((e,t)=>(e[t]=o(i[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));l((e=>class extends(v(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 tn=l((e=>class extends e{get baseStaticUrl(){return this.getAttribute("base-static-url")||""}})),nn=(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),n)})),t};function on(e){return new URLSearchParams(window.location.search).get(e)}const rn=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},sn=Ht("users/me",((e,{extra:{api:t}})=>t.user.me())),an=rn(sn)({onFulfilled:(e,t)=>{e.me.data=t.payload}},(ln=e=>e.me,{onFulfilled:e=>{ln(e).loading=!1},onPending:e=>{ln(e).loading=!0,ln(e).error=null},onRejected:(e,t)=>{ln(e).loading=!1,ln(e).error=t.error}}));var ln;const cn={action:sn,reducer:an},dn=Ht("users/logout",((e,{extra:{api:t}})=>t.user.logout())),un={action:dn,reducer:rn(dn)({})},hn={me:{loading:!1,error:null,data:{}}};class pn extends Error{}function fn(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 gn(e,t){if("string"!=typeof e)throw new pn("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 pn(`Invalid token specified: missing part #${n+1}`);let o;try{o=fn(i)}catch(e){throw new pn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new pn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}pn.prototype.name="InvalidTokenError";var vn="/v1/auth/accesskey/exchange",mn="/v1/auth/otp/verify",bn="/v1/auth/otp/signin",wn="/v1/auth/otp/signup",yn={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},kn="/v1/auth/otp/signup-in",In="/v1/auth/magiclink/verify",Sn="/v1/auth/magiclink/signin",Cn="/v1/auth/magiclink/signup",xn={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},jn="/v1/auth/magiclink/signup-in",An="/v1/auth/enchantedlink/verify",En="/v1/auth/enchantedlink/signin",On="/v1/auth/enchantedlink/signup",Un="/v1/auth/enchantedlink/pending-session",_n={email:"/v1/auth/enchantedlink/update/email"},Rn="/v1/auth/enchantedlink/signup-in",Tn="/v1/auth/oauth/authorize",Mn="/v1/auth/oauth/exchange",Ln="v1/auth/oauth/native/start",Pn="v1/auth/oauth/native/finish",$n="/v1/auth/saml/authorize",Wn="/v1/auth/saml/exchange",Dn="/v1/auth/totp/verify",Nn="/v1/auth/totp/signup",Fn="/v1/auth/totp/update",qn="/v1/auth/notp/whatsapp/signin",zn="/v1/auth/notp/whatsapp/signup",Bn="/v1/auth/notp/whatsapp/signup-in",Vn="/v1/auth/notp/pending-session",Hn={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},Kn={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Gn={start:"/v1/auth/webauthn/signup-in/start"},Jn={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},Xn="/v1/auth/password/signup",Yn="/v1/auth/password/signin",Zn="/v1/auth/password/reset",Qn="/v1/auth/password/update",ei="/v1/auth/password/replace",ti="/v1/auth/password/policy",ni="/v1/auth/refresh",ii="/v1/auth/tenant/select",oi="/v1/auth/logout",ri="/v1/auth/logoutall",si="/v1/auth/me",ai="/v1/auth/me/tenants",li="/v1/auth/me/history",ci="/v1/flow/start",di="/v1/flow/next";const ui="<region>",hi=`https://api.${ui}descope.com`,pi=6e5,fi="dct",gi=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};let vi;const mi=()=>{if(vi)return vi;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 vi=`${t}-${n}`,vi};var bi;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(bi||(bi={}));const wi=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(ui,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},yi=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,i])=>(e[n]=i,e)),e),e}),{})),ki={"Content-Type":"application/json"},Ii=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Si=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e},Ci=({baseUrl:e,projectId:t,baseConfig:n,logger:i,hooks:o,cookiePolicy:r,fetch:s})=>{const a=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>gi().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await n(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return gi().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(i)),i}:n})(i,s),l=async i=>{var s;const l=(null==o?void 0:o.beforeRequest)?o.beforeRequest(i):i,{path:c,body:d,headers:u,queryParams:h,method:p,token:f}=l,g=(e=>void 0===e?void 0:JSON.stringify(e))(d),v={headers:yi(Ii(t,f),{"x-descope-sdk-session-id":mi(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.33.0"},(null==n?void 0:n.baseHeaders)||{},Si(g)?ki:{},u),method:p,body:g};null!==r&&(v.credentials=r||"include");const m=await a(wi({path:c,baseUrl:e,queryParams:h,projectId:t}),v);if((null==o?void 0:o.afterRequest)&&await o.afterRequest(i,null==m?void 0:m.clone()),null==o?void 0:o.transformResponse){const e=await m.json(),t=((null===(s=m.headers)||void 0===s?void 0:s.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,i]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:i})}),{}),n=Object.assign(Object.assign({},m),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,o.transformResponse(n)}return m};return{get:(e,{headers:t,queryParams:n,token:i}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:bi.get,token:i}),post:(e,t,{headers:n,queryParams:i,token:o}={})=>l({path:e,headers:n,queryParams:i,body:t,method:bi.post,token:o}),patch:(e,t,{headers:n,queryParams:i,token:o}={})=>l({path:e,headers:n,queryParams:i,body:t,method:bi.patch,token:o}),put:(e,t,{headers:n,queryParams:i,token:o}={})=>l({path:e,headers:n,queryParams:i,body:t,method:bi.put,token:o}),delete:(e,{headers:t,queryParams:n,token:i}={})=>l({path:e,headers:t,queryParams:n,body:void 0,method:bi.delete,token:i}),hooks:o,buildUrl:(n,i)=>wi({projectId:t,baseUrl:e,path:n,queryParams:i})}};var xi=429;function ji(e,t,n){var i;let o=Ai(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[fi])===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 Ai(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return gn(e)}function Ei(e){const{exp:t}=Ai(e);return(new Date).getTime()/1e3>t}function Oi(e){let t=Ai(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Ui(e,t){return ji(e,t,"permissions")}function _i(e,t){return ji(e,t,"roles")}const Ri=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Ti(e,t){var n;const i=await e,o={code:i.status,ok:i.ok,response:i},r=await i.clone().json();return i.ok?o.data=t?t(r):r:(o.error=r,i.status===xi&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}const Mi=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Li=(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 "))},Pi=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),$i=e=>t=>e.test(t),Wi=$i(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Di=$i(/^\+[1-9]{1}[0-9]{3,14}$/),Ni=Mi(Wi,'"{val}" is not a valid email'),Fi=Mi(Di,'"{val}" is not a valid phone number'),qi=Mi((e=>e.length>=1),"Minimum length is 1");const zi=Mi((e=>"string"==typeof e),"Input is not a string"),Bi=Mi((e=>Array.isArray(e)),"Input is not an array"),Vi=Mi((e=>"boolean"==typeof e),"Input is not a boolean"),Hi=Mi((e=>void 0===e),"Input is defined"),Ki=Li([zi(),Hi()],"Input is not a string or undefined"),Gi=Li([Bi(),Vi()],"Input is not an array or boolean"),Ji=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Pi(...e).validate(n[t]))),t(...n)),Xi=e=>[zi(`"${e}" must be a string`)],Yi=e=>[zi(`"${e}" must be a string`),qi(`"${e}" must not be empty`)],Zi=e=>[zi(`"${e}" must be a string`),Ni()],Qi=e=>[zi(`"${e}" must be a string`),Fi()],eo=Ji(Yi("accessKey")),to=e=>({exchange:eo(((t,n)=>Ti(e.post(vn,{loginOptions:n},{token:t}))))}),no=(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),io=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||pi,pi)});var oo,ro;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(oo||(oo={})),function(e){e.email="email"}(ro||(ro={}));const so=Object.assign(Object.assign({},oo),ro);var ao;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(ao||(ao={}));const lo=Yi("loginId"),co=Ji(Yi("token")),uo=Ji(lo),ho=Ji(Yi("pendingRef")),po=Ji(lo,Zi("email")),fo=e=>({verify:co((t=>Ti(e.post(An,{token:t})))),signIn:uo(((t,n,i,o)=>Ti(e.post(Ri(En,so.email),{loginId:t,URI:n,loginOptions:i},{token:o})))),signUpOrIn:uo(((t,n,i)=>Ti(e.post(Ri(Rn,so.email),{loginId:t,URI:n,loginOptions:i})))),signUp:uo(((t,n,i,o)=>Ti(e.post(Ri(On,so.email),{loginId:t,URI:n,user:i,loginOptions:o})))),waitForSession:ho(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=io(n);let s;const a=setInterval((async()=>{const n=await e.post(Un,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(Ti(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:po(((t,n,i,o,r)=>Ti(e.post(_n.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o}))))}}),go=Ji(Yi("flowId")),vo=Ji(Yi("executionId"),Yi("stepId"),Yi("interactionId")),mo=e=>({start:go(((t,n,i,o,r,s,a)=>Ti(e.post(ci,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a})))),next:vo(((t,n,i,o,r,s)=>Ti(e.post(di,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s}))))}),bo=Yi("loginId"),wo=Ji(Yi("token")),yo=Ji(bo),ko=Ji(bo,Qi("phone")),Io=Ji(bo,Zi("email")),So=Object.keys(so).filter((e=>e!==oo.voice)),Co=e=>({verify:wo((t=>Ti(e.post(In,{token:t})))),signIn:So.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:yo(((t,i,o,r)=>Ti(e.post(Ri(Sn,n),{loginId:t,URI:i,loginOptions:o},{token:r}))))})),{}),signUp:So.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:yo(((t,i,o,r)=>Ti(e.post(Ri(Cn,n),{loginId:t,URI:i,user:o,loginOptions:r}))))})),{}),signUpOrIn:So.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:yo(((t,i,o)=>Ti(e.post(Ri(jn,n),{loginId:t,URI:i,loginOptions:o}))))})),{}),update:{email:Io(((t,n,i,o,r)=>Ti(e.post(xn.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(oo).filter((e=>e!==oo.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:ko(((t,i,o,r,s)=>Ti(e.post(Ri(xn.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var xo;!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"}(xo||(xo={}));const jo=Ji(Yi("code")),Ao=e=>({start:Object.assign(((t,n,i,o)=>Ti(e.post(Tn,i||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:o}))),Object.keys(xo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o)=>Ti(e.post(Tn,i||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:o}))})),{})),exchange:jo((t=>Ti(e.post(Mn,{code:t})))),startNative:(t,n,i)=>Ti(e.post(Ln,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>Ti(e.post(Pn,{provider:t,stateId:n,user:i,code:o,idToken:r}))}),Eo=Yi("loginId"),Oo=Ji(Eo,Yi("code")),Uo=Ji(Eo),_o=Ji(Eo,Qi("phone")),Ro=Ji(Eo,Zi("email")),To=e=>({verify:Object.keys(so).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Oo(((t,i)=>Ti(e.post(Ri(mn,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(so).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Uo(((t,i,o)=>Ti(e.post(Ri(bn,n),{loginId:t,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(so).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Uo(((t,i,o)=>Ti(e.post(Ri(wn,n),{loginId:t,user:i,loginOptions:o}))))})),{}),signUpOrIn:Object.keys(so).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Uo(((t,i)=>Ti(e.post(Ri(kn,n),{loginId:t,loginOptions:i}))))})),{}),update:{email:Ro(((t,n,i,o)=>Ti(e.post(yn.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(oo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:_o(((t,i,o,r)=>Ti(e.post(Ri(yn.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),Mo=Ji(Yi("tenant")),Lo=Ji(Yi("code")),Po=e=>({start:Mo(((t,n,i,o)=>Ti(e.post($n,i||{},{queryParams:{tenant:t,redirectURL:n},token:o})))),exchange:Lo((t=>Ti(e.post(Wn,{code:t}))))}),$o=Yi("loginId"),Wo=Ji($o,Yi("code")),Do=Ji($o),No=Ji($o),Fo=e=>({signUp:Do(((t,n)=>Ti(e.post(Nn,{loginId:t,user:n})))),verify:Wo(((t,n,i,o)=>Ti(e.post(Dn,{loginId:t,code:n,loginOptions:i},{token:o})))),update:No(((t,n)=>Ti(e.post(Fn,{loginId:t},{token:n}))))}),qo=Yi("loginId"),zo=Yi("newPassword"),Bo=Ji(qo,Yi("password")),Vo=Ji(qo),Ho=Ji(qo,zo),Ko=Ji(qo,Yi("oldPassword"),zo),Go=e=>({signUp:Bo(((t,n,i,o)=>Ti(e.post(Xn,{loginId:t,password:n,user:i,loginOptions:o})))),signIn:Bo(((t,n,i)=>Ti(e.post(Yn,{loginId:t,password:n,loginOptions:i})))),sendReset:Vo(((t,n,i)=>Ti(e.post(Zn,{loginId:t,redirectUrl:n,templateOptions:i})))),update:Ho(((t,n,i)=>Ti(e.post(Qn,{loginId:t,newPassword:n},{token:i})))),replace:Ko(((t,n,i)=>Ti(e.post(ei,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>Ti(e.get(ti))}),Jo=Xi("loginId"),Xo=Yi("loginId"),Yo=Yi("origin"),Zo=Ji(Xo,Yo,Yi("name")),Qo=Ji(Xo,Yo),er=Ji(Jo,Yo),tr=Ji(Xo,Yo,Yi("token")),nr=Ji(Yi("transactionId"),Yi("response")),ir=e=>({signUp:{start:Zo(((t,n,i,o)=>Ti(e.post(Hn.start,{user:{loginId:t,name:i},origin:n,passkeyOptions:o})))),finish:nr(((t,n)=>Ti(e.post(Hn.finish,{transactionId:t,response:n}))))},signIn:{start:er(((t,n,i,o,r)=>Ti(e.post(Kn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:nr(((t,n)=>Ti(e.post(Kn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Qo(((t,n,i)=>Ti(e.post(Gn.start,{loginId:t,origin:n,passkeyOptions:i}))))},update:{start:tr(((t,n,i,o)=>Ti(e.post(Jn.start,{loginId:t,origin:n,passkeyOptions:o},{token:i})))),finish:nr(((t,n)=>Ti(e.post(Jn.finish,{transactionId:t,response:n}))))}}),or=Xi("loginId"),rr=Ji(or),sr=Ji(Yi("pendingRef")),ar=e=>({signUpOrIn:rr(((t,n)=>Ti(e.post(Bn,{loginId:t,loginOptions:n})))),signUp:rr(((t,n,i)=>Ti(e.post(zn,{loginId:t,user:n,loginOptions:i})))),signIn:rr(((t,n,i)=>Ti(e.post(qn,{loginId:t,loginOptions:n},{token:i})))),waitForSession:sr(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=io(n);let s;const a=setInterval((async()=>{const n=await e.post(Vn,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(Ti(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),lr=Ji(Yi("token")),cr=Ji([Ki('"token" must be string or undefined')]);var dr,ur=Ji([(dr=Yi("projectId"),Mi(((e,t)=>n=>Pi(...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",dr))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:i,cookiePolicy:o,baseHeaders:r={},fetch:s})=>{return a=Ci({baseUrl:n||hi,projectId:e,logger:t,hooks:i,cookiePolicy:o,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:to(a),otp:To(a),magicLink:Co(a),enchantedLink:fo(a),oauth:Ao(a),saml:Po(a),totp:Fo(a),notp:ar(a),webauthn:ir(a),password:Go(a),flow:mo(a),refresh:cr(((e,t)=>Ti(a.post(ni,{},{token:e,queryParams:t})))),selectTenant:Ji([zi("tenantId")],[Ki('"token" must be string or undefined')])(((e,t)=>Ti(a.post(ii,{tenant:e},{token:t})))),logout:cr((e=>Ti(a.post(oi,{},{token:e})))),logoutAll:cr((e=>Ti(a.post(ri,{},{token:e})))),me:cr((e=>Ti(a.get(si,{token:e})))),myTenants:Ji([Gi('"tenants" must a string array or a boolean')],[Ki('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,Ti(a.post(ai,n,{token:t}))})),history:cr((e=>Ti(a.get(li,{token:e})))),isJwtExpired:lr(Ei),getTenants:lr(Oi),getJwtPermissions:lr(Ui),getJwtRoles:lr(_i),httpClient:a};var a})(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}}))})),hr=Object.assign(ur,{DeliveryMethods:so});
|
|
6
6
|
/*! js-cookie v3.0.5 | MIT */
|
|
7
|
-
function gn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)e[i]=n[i]}return e}var vn=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=gn({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(i[a]=t.read(s,a),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",gn({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,gn({},this.attributes,t))},withConverter:function(t){return e(gn({},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 mn={default:"endpoint"},bn="Blocked by CSP",wn="The endpoint parameter is not a valid URL",yn="Failed to load the JS script of the agent",kn="9319";function In(e,t){var n,i,o,r,s=[],a=(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===bn||s===wn)n.exclude(),r=0;else if(s===kn)n.exclude();else if(s===yn){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()]}]),l=a[0],c=a[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var d=function(e){var n=new Date,i=function(t){return s.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(s.length>=5)throw e;var t=c(n,e);if(!t)throw e;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return d(o)}))}))};return d(l).then((function(e){return[e,s]}))}var Sn="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Cn=Sn;function jn(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:Sn,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.9.9"):e}))}(String(e),t)}))}(l,s);return In(e,xn)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===kn?new Error(yn):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 xn(e){return function(e,t,n,i){var o,r=document,s="securitypolicyviolation",a=function(t){var n=new URL(e,location.href),i=t.blockedURI;i!==n.href&&i!==n.protocol.slice(0,-1)&&i!==n.origin||(o=t,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return null==i||i.then(l,l),Promise.resolve().then(t).then((function(e){return l(),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(l(),o)return n(o);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(wn);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(yn))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(bn)})).then(An)}function An(){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(kn);return n}const En=(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},On=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},Un=async e=>{const t=await On(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},_n="undefined"!=typeof localStorage,Rn=(e,t)=>_n&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),Tn=e=>_n&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),Mn=e=>_n&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Ln=(...e)=>{console.debug(...e)},Pn="undefined"!=typeof window,$n=Math.pow(2,31)-1,Wn="DS",Dn="DSR";function Nn(e=""){return Tn(`${e}${Dn}`)||""}function Fn(e=""){return vn.get(Wn)||Tn(`${e}${Wn}`)||""}function qn(e=""){Mn(`${e}${Dn}`),Mn(`${e}${Wn}`),vn.remove(Wn)}const zn=Pn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",Bn="vsid",Vn="vrid",Hn="fp",Kn=(e=!1)=>{const t=localStorage.getItem(Hn);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Gn=async(e,t=zn)=>{try{if(Kn())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=jn({apiKey:e,endpoint:[i.toString(),mn],scriptUrlPattern:[r,Cn]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[Bn]:e,[Vn]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(Hn,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Jn=()=>{localStorage.removeItem(Hn)},Xn=e=>{const t=Kn(!0);return t&&e.body&&(e.body.fpData=t),e},Yn="dls_last_user_login_id",Zn="dls_last_user_display_name",Qn=()=>Tn(Yn),ei=()=>Tn(Zn),ti=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=Qn(),r=ei();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)};function ni(){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 ii(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ci(n.publicKey.challenge),n.publicKey.user.id=ci(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=ci(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:di(n.rawId),type:n.type,response:{attestationObject:di(n.response.attestationObject),clientDataJSON:di(n.response.clientDataJSON)}});var n}async function oi(e){const t=ai(e);return li(await navigator.credentials.get(t))}async function ri(e,t){const n=ai(e);return n.signal=t.signal,n.mediation="conditional",li(await navigator.credentials.get(n))}async function si(e=!1){if(!Pn)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function ai(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=ci(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=ci(e.id)})),n}function li(e){return JSON.stringify({id:e.id,rawId:di(e.rawId),type:e.type,response:{authenticatorData:di(e.response.authenticatorData),clientDataJSON:di(e.response.clientDataJSON),signature:di(e.response.signature),userHandle:e.response.userHandle?di(e.response.userHandle):void 0}})}function ci(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function di(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ui,hi=(ui=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 ii(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 oi(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 ii(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await oi(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 ii(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:ii,get:oi,isSupported:si,conditional:ri}}),(...e)=>{const t=ui(...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 pi="/fedcm/config",fi=(e,t)=>({async oneTap(t,n,i,o,r){const s=null!=t?t:"google",a=await e.oauth.startNative(s,i,!0);if(!a.ok)return a;const{clientId:l,stateId:c,nonce:d}=a.data,u=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")}}))}();return new Promise((t=>{var i,a;u.initialize(Object.assign(Object.assign({},n),{itp_support:null===(i=null==n?void 0:n.itp_support)||void 0===i||i,use_fedcm_for_prompt:null===(a=null==n?void 0:n.use_fedcm_for_prompt)||void 0===a||a,client_id:l,callback:n=>{t(e.oauth.finishNative(s,c,"","",n.credential))},nonce:d})),u.prompt((e=>{var t,n;if(r&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);null==r||r(n)}else if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);null==o||o(t)}}))}))},async launch(n){var i;const o={identity:{context:n||"signin",providers:[{configURL:e.httpClient.buildUrl(t+pi),clientId:t}]}},r=await(null===(i=navigator.credentials)||void 0===i?void 0:i.get(o));return e.refresh(r.token)},isSupported:()=>Pn&&"IdentityCredential"in window,async isLoggedIn(n){var i;const o=e.httpClient.buildUrl(t+pi);try{const e={identity:{context:n||"signin",providers:[{configURL:o,clientId:t}]}},r=await(null===(i=navigator.credentials)||void 0===i?void 0:i.get(e));return!!r&&!!r.token}catch(e){return!1}}});var gi=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await si(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});const vi=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return Pn?(i&&o&&Gn(i).catch((()=>null)),e(En(r,{beforeRequest:Xn}))):e(r)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);if(!i)return e(o);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,l;Pn&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(Ln("Expiration time passed, refreshing session"),c.refresh(Nn()||l))}));const c=e(En(o,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:i}=await On(t);if(401===(null==t?void 0:t.status))Ln("Received 401, canceling all timers"),r();else if(i){if(a=(e=>{try{const t=m(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(i),!a)return void Ln("Could not extract expiration time from session token");l=n;let e=((o=a)?o.getTime()-(new Date).getTime():0)-2e4;e>$n&&(Ln(`Timeout is too large (${e}ms), setting it to ${$n}ms`),e=$n),r();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Ln(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Ln("Refreshing session due to timer"),c.refresh(Nn()||n)}),e)}var o}}));return ot(c,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return Ln("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.23.0"},t.baseHeaders)}))),(e=>t=>{const n=ni(),i=ni(),o=e(En(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))n.pub(null),i.pub(null);else{const e=await Un(t);e&&i.pub(e);const{sessionJwt:o}=await On(t);o&&n.pub(o)}}})),r=ot(o,["logout","logoutAll"],(e=>async(...t)=>{const o=await e(...t);return n.pub(null),i.pub(null),o}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:i.sub})}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:Qn,getLastUserDisplayName:ei});const s=e(En(r,{afterRequest:async(e,t)=>{var n;const i=await Un(t),o=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],r=null==i?void 0:i.name;o&&((e=>{Rn(Yn,e)})(o),(e=>{Rn(Zn,e)})(r))}}));let a=ot(s,["flow.start"],ti);return a=ot(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(Mn(Yn),Mn(Zn)),i})(o)),Object.assign(a,{getLastUserLoginId:Qn,getLastUserDisplayName:ei})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!Pn)return e(s);const a=e(En(s,{beforeRequest:(l=r,e=>Object.assign(e,{token:e.token||Nn(l)})),afterRequest:async(e,n)=>{const i=/^\/v\d+\/mgmt\//.test(e.path);401===(null==n?void 0:n.status)?i||qn(r):((e={},n,i)=>{var{refreshJwt:o,sessionJwt:r}=e,s=t(e,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===i&&(i=""),o&&Rn(`${i}${Dn}`,o),r&&(n?function(e,t,{cookiePath:n,cookieDomain:i,cookieExpiration:o}){if(t){const r=new Date(1e3*o),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(i);vn.set(e,t,{path:n,domain:s?i:void 0,expires:r,sameSite:"Strict",secure:!0})}}(Wn,r,s):Rn(`${i}${Wn}`,r))})(await On(n),o,r)}}));var l;const c=ot(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return qn(e),i})(r));return Object.assign(c,{getRefreshToken:()=>Nn(r),getSessionToken:()=>Fn(r)})}))(((...e)=>{const t=fn(...e);return Object.assign(Object.assign({},t),{refresh:e=>{const n=Fn();return t.refresh(e,{dcs:n?"t":"f"})},flow:gi(t),webauthn:hi(t),fedcm:fi(t,e[0].projectId)})})),mi="undefined"!=typeof localStorage,bi="J151000",wi=mi&&localStorage.getItem("base.content.url")||"",yi="config.json",ki="base.ui.components.url";mi&&localStorage.getItem(ki),mi&&localStorage.getItem(ki);const Ii="descope-login-flow",Si="code",Ci="data-exclude-field",ji="dls_last_auth",xi="state_id",Ai="saml_idp_state_id",Ei="saml_idp_username",Oi="descope_idp_initiated",Ui="sso_app_id",_i="third_party_app_id",Ri="third_party_app_state_id",Ti="oidc_login_hint",Mi="oidc_prompt",Li="oidc_error_redirect_uri",Pi="application_scopes",$i="data-type",Wi="redirect",Di="poll",Ni="webauthnCreate",Fi="webauthnGet",qi="nativeBridge",zi="loadForm",Bi="submit",Vi="polling",Hi=["descope-multi-select-combo-box","descope-text-area"];var Ki;!function(e){e.backward="backward",e.forward="forward"}(Ki||(Ki={}));const Gi=["descope-enriched-text"];function Ji(e){return new URLSearchParams(window.location.search).get(e)}function Xi(e){if(window.history.replaceState&&Ji(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function Yi(e,t){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||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}function Zi({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(wi||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}function Qi(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?Ki.forward:n<i?Ki.backward:void 0}const eo=()=>{const[e="",t=""]=(Ji(Ii)||"").split("_");return{executionId:e,stepId:t}};function to(){Xi(Ii)}const no=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),io=()=>{const{executionId:e,stepId:t}=eo();(e||t)&&to();const n=Ji("t")||void 0;n&&Xi("t");const i=Ji(Si)||void 0;i&&Xi(Si);const o=Ji("err")||void 0;o&&Xi("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:Ji("ra-challenge"),redirectAuthCallbackUrl:Ji("ra-callback"),redirectAuthBackupCallbackUri:Ji("ra-backup-callback"),redirectAuthInitiator:Ji("ra-initiator")},c=Ji(xi);c&&Xi(xi);const d=Ji(Ai);d&&Xi(Ai);const u=Ji(Ei);d&&Xi(Ei);const h=Ji(Oi);h&&Xi(Oi);const p=Ji(Ui);p&&Xi(Ui);const f=Ji(_i);f&&Xi(_i);const g=Ji(Ri);g&&Xi(Ri);const v=Ji(Pi);v&&Xi(Pi);const m=Ji(Ti);m&&Xi(Ti);const b=Ji(Mi);b&&Xi(Mi);const w=Ji(Li);return w&&Xi(Li),{executionId:e,stepId:t,token:n,code:i,exchangeError:o,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,ssoQueryParams:{oidcIdpStateId:c,samlIdpStateId:d,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:p,oidcLoginHint:m,oidcPrompt:b,oidcErrorRedirectUri:w,thirdPartyAppId:f,thirdPartyAppStateId:g,applicationScopes:v}}},oo=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})};function ro(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 so=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:i,ssoAppId:o,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,thirdPartyAppId:l,thirdPartyAppStateId:c,applicationScopes:d})=>!(!e||t||n||i||o||r||s||a||l||c||d),ao=e=>null==e?void 0:e.submit(),lo=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},co=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function uo(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:""}}var ho,po,fo,go;function vo(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(!vo(r,s))return!1}else if(r!==s)return!1}return!0}let mo=class{constructor(e={},{updateOnlyOnChange:t=!0}={}){ho.set(this,void 0),po.set(this,{}),fo.set(this,0),go.set(this,!1),this.update=e=>{const t="function"==typeof e?e(i(this,ho,"f")):e,n=Object.assign(Object.assign({},i(this,ho,"f")),t);if(!i(this,go,"f")||!vo(i(this,ho,"f"),n)){const e=i(this,ho,"f");o(this,ho,n,"f"),Object.freeze(i(this,ho,"f")),setTimeout((()=>{Object.values(i(this,po,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,ho,e,"f"),o(this,go,t,"f")}get current(){return Object.assign({},i(this,ho,"f"))}subscribe(e){return o(this,fo,i(this,fo,"f")+1,"f"),i(this,po,"f")[i(this,fo,"f")]=e,i(this,fo,"f").toString()}unsubscribe(e){const t=!!i(this,po,"f")[e];return t&&delete i(this,po,"f")[e],t}unsubscribeAll(){return o(this,po,{},"f"),!0}};ho=new WeakMap,po=new WeakMap,fo=new WeakMap,go=new WeakMap;const bo=["*","#","/","(",")","[","]","_","<",">","`"],wo=e=>"string"!=typeof e?e:e.replace((e=>{const t=bo.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),yo=["disabled"],ko=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Ci}])`)).forEach((e=>{e.value=n}))}))},Io=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),So=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?wo(Io(t,i)):Io(t,i))),Co=(e,t,n)=>{e.querySelectorAll(`[${$i}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},jo=(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})`))},xo=(e,t,n,i,o,r)=>{var s,a;let l=null==t?void 0:t.errorText;try{l=(null==o?void 0:o({text:null==t?void 0:t.errorText,type:null==t?void 0:t.errorType}))||(null==t?void 0:t.errorText)}catch(e){r.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${$i}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(e,"error-message",l),Co(e,"totp-link",null===(s=null==t?void 0:t.totp)||void 0===s?void 0:s.provisionUrl),Co(e,"notp-link",null===(a=null==t?void 0:t.notp)||void 0===a?void 0:a.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(e=>Gi.includes(e))(e.localName);e.textContent=So(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",So(i,t))}))})(e,t),((e,t,n)=>{t&&Object.keys(t).forEach((i=>{e.querySelectorAll(`[name=${i}]`).forEach((e=>{const o=t[i];Object.keys(o).forEach((t=>{let i=o[t];if("string"!=typeof i)try{i=JSON.stringify(i)}catch(e){n.error(`Could not stringify value "${i}" for "${t}"`,e.message),i=""}e.setAttribute(t,i)}))}))}))})(e,n,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=So(e.value,t)}))}))})(e,t),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{yo.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i)},Ao=oo((()=>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 ro(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}})))),Eo={"lastAuth.loginId":{"not-empty":e=>!!e.loginId,empty:e=>!e.loginId},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t}};function Oo(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(ji)))}catch(e){}return t}const Uo="dls_ab_testing_id",_o=["error","warn","info","debug"],Ro=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,console))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e),"f")}get logger(){return i(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return _o.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})),To="undefined"!=typeof localStorage,Mo=To&&localStorage.getItem("base.content.url")||"",Lo=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,Po=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})),$o=l((e=>{var t,n;const o=r(Ro,Po)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=i(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){i(this,t,"f")[e]||(i(this,t,"f")[e]=[]);const o=i(this,t,"f")[e].push(n);return()=>i(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),Wo=e=>t=>{var n,o,s;const a=r(Ro,Po,$o)(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;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),l.forEach((e=>i(this,n,"m",o).call(this,e,this.getAttribute(e))))}},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};Wo.missingAttrValidator=Lo;const Do=l((e=>{const t=r(Wo({"project-id":Lo}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),No=l((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}}));const Fo=l((e=>{const t=r(Ro,Do,No)(e);return class extends t{async fetchStaticResource(e,t){const n=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(Mo||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:e,baseUrl:this.baseStaticUrl}),i=await fetch(n,{cache:"default"});return i.ok||this.logger.error(`Error fetching URL ${n} [${i.status}]`),{body:await i[t](),headers:Object.fromEntries(i.headers.entries())}}get baseStaticUrl(){return this.getAttribute("base-static-url")}}})),qo=l((e=>{var t,n,s;const a=r(Fo)(e);return s=class extends a{constructor(){super(...arguments),t.set(this,void 0),n.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")}}))}get config(){return i(this,t,"f")||o(this,t,i(this,n,"f").call(this),"f"),i(this,t,"f")}},t=new WeakMap,n=new WeakMap,s})),zo="load-descope-ui",Bo="base.ui.components.url",Vo=To&&localStorage.getItem(Bo)||"https://descopecdn.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Ho=To&&localStorage.getItem(Bo)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Ko=To&&localStorage.getItem(Bo)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Go=e=>{const t=document.createElement("script");return t.id=e,t},Jo=(e,t)=>e.replace("<version>",t),Xo=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g;const v=r(Ro,qo)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),s.set(this,Symbol("loadCbs")),h.set(this,void 0)}get descopeUi(){return i(this,h,"f")||o(this,h,i(this,t,"m",f).call(this),"f"),i(this,h,"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",p).call(this,e))))}},n=new WeakMap,s=new WeakMap,h=new WeakMap,t=new WeakSet,a=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},l=function(e){const t=i(this,n,"f"),o=i(this,s,"f");e[t]=[],e[o]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[o].push(t)}})},c=async function(e,n,o,r){this.logger.debug("Trying to load DescopeUI from a fallback URL");const s=Go(o);document.body.append(s),s.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${s.src}"`)))})),s.addEventListener("load",(()=>{n.forEach((e=>e()))})),s.src=Jo(r,await i(this,t,"m",a).call(this))},d=function(e){e.addEventListener("error",(()=>{e[i(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),i(this,t,"m",c).call(this,[i(this,t,"m",c).bind(this,e[i(this,n,"f")],e[i(this,s,"f")],"load-descope-ui-fallback-script-2",Ko),...e[i(this,n,"f")]],e[i(this,s,"f")],"load-descope-ui-fallback-script",Ho)})),e.addEventListener("load",(()=>{e[i(this,s,"f")].forEach((e=>e()))}))},u=async function(){if(document.querySelector(`script#${zo}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=Go(zo);document.body.append(e),i(this,t,"m",l).call(this,e),i(this,t,"m",d).call(this,e),e.src=Jo(Vo,await i(this,t,"m",a).call(this))}return document.getElementById(zo)},p=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(", ")}"`)},f=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),i(this,t,"m",u).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},g})),Yo="content-root",Zo="root",Qo=l((e=>class extends e{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${Zo}, #${Yo} {\n height: 100%;\n }\n #${Zo} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${Zo}">\n <div id="${Yo}"></div>\n </div>\n `,this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(Yo),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Zo)}})),er=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',tr=l((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m;const b=r(Wo({theme:er}),Fo,Po,Xo,qo,Qo,$o)(e);return m=class extends b{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),f.set(this,(()=>{i(this,t,"m",g).call(this),i(this,v,"f").call(this,"os"===this.getAttribute("theme"))})),v.set(this,(e=>{var n,o,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===r||r.call(o,"change",(()=>i(this,t,"m",g).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",c).call(this),i(this,t,"m",d).call(this),i(this,f,"f").call(this),this.observeAttributes(["theme"],i(this,f,"f")),this.observeAttributes(["style-id"],(()=>{o(this,s,null,"f"),i(this,t,"m",h).call(this),i(this,t,"m",c).call(this),i(this,t,"m",d).call(this)}))}},n=new WeakMap,s=new WeakMap,f=new WeakMap,v=new WeakMap,t=new WeakSet,a=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(Bo))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(Bo),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},l=function(){return i(this,s,"f")||(o(this,s,i(this,t,"m",a).call(this),"f"),i(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,s,"f")},c=async function(){var e,r;const s=await i(this,t,"a",l);s&&(i(this,n,"f")||(o(this,n,document.createElement("style"),"f"),i(this,n,"f").id="global-style",this.shadowRoot.appendChild(i(this,n,"f"))),i(this,n,"f").innerText=((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)||""))},d=async function(){var e,n;const o=Object.assign({},await i(this,t,"a",l));if(!o)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==o?void 0:o.light)||void 0===e?void 0:e.components,dark:null===(n=null==o?void 0:o.dark)||void 0===n?void 0:n.components})},u=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},h=async function(){const e=await i(this,t,"m",u).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},p=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},g=function(){i(this,t,"m",h).call(this),i(this,t,"m",p).call(this)},m})),nr=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})),ir=document.createElement("template");ir.innerHTML="\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n display: flex;\n\t\t}\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t";const or=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),or(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}),[]);var rr,sr,ar,lr,cr,dr,ur,hr,pr,fr,gr,vr,mr,br,wr,yr,kr,Ir,Sr,Cr,jr;const xr=r(tr,nr)(HTMLElement);class Ar extends xr{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),rr.add(this),ar.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,rr,"m",Cr).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)}},lr.set(this,new mo),cr.set(this,new mo),dr.set(this,{}),this.getComponentsContext=()=>i(this,dr,"f"),this.nextRequestStatus=new mo({isLoading:!1}),ur.set(this,void 0),hr.set(this,{popstate:i(this,rr,"m",vr).bind(this),componentsContext:i(this,rr,"m",kr).bind(this)}),pr.set(this,void 0),this.getConfig=oo((()=>n(this,void 0,void 0,(function*(){const e=Zi({projectId:this.projectId,filename:yi,baseUrl:this.baseStaticUrl});try{const{body:t,headers:n}=yield Yi(e,"json");return{projectConfig:t,executionContext:{geo:n["x-geo"]}}}catch(e){return{isMissingConfig:!0}}})))),o(this,pr,e,"f"),i(this,rr,"m",fr).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return or(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]]))))(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:e}=yield this.getConfig();return e}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:e}=yield this.getConfig();return e}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e,t;return(null===(t=null===(e=yield this.getConfig())||void 0===e?void 0:e.projectConfig)||void 0===t?void 0:t.componentsVersion)||(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,cr,"f").subscribe(i(this,rr,"m",Sr).bind(this)),i(this,cr,"f").update({isDebug:this.debug}),i(this,rr,"m",gr).call(this),yield i(this,rr,"m",wr).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield this.getConfig()).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");i(this,rr,"m",jr).call(this);const{executionId:n,stepId:r,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,ssoQueryParams:p}=io();window.addEventListener("popstate",i(this,hr,"f").popstate),window.addEventListener("components-context",i(this,hr,"f").componentsContext),i(this,lr,"f").subscribe(i(this,rr,"m",br).bind(this)),i(this,lr,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:r,executionId:n,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h},p)),o(this,ar,!0,"f")}))}disconnectedCallback(){i(this,lr,"f").unsubscribeAll(),i(this,cr,"f").unsubscribeAll(),i(this,rr,"m",Ir).call(this),window.removeEventListener("popstate",i(this,hr,"f").popstate),window.removeEventListener("components-context",i(this,hr,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,ar,"f")&&t!==n&&sr.observedAttributes.includes(e)){i(this,rr,"m",gr).call(this);const o=null===t;i(this,lr,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,to()),{[no(e)]:n,stepId:r,executionId:s}})),i(this,cr,"f").update({isDebug:this.debug})}}}function Er(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Or,Ur,_r,Rr,Tr,Mr,Lr,Pr,$r,Wr,Dr,Nr,Fr,qr,zr,Br,Vr,Hr,Kr,Gr,Jr,Xr,Yr;sr=Ar,ar=new WeakMap,lr=new WeakMap,cr=new WeakMap,dr=new WeakMap,ur=new WeakMap,hr=new WeakMap,pr=new WeakMap,rr=new WeakSet,fr=function(){this.shadowRoot.appendChild(ir.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},gr=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];sr.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[no(t)])throw Error(`${t} cannot be empty`)}))},vr=function(){const{stepId:e,executionId:t}=eo();i(this,lr,"f").update({stepId:e,executionId:t})},mr=function(e,t){this.sdk=vi(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},sr.sdkConfigOverrides),{projectId:e,baseUrl:t})),["start","next"].forEach((e=>{const t=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>n(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield t(...e)}catch(e){return{error:{errorCode:bi,errorDescription:e.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},br=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,rr,"m",mr).call(this,t,n)}i(this,pr,"f").call(this,e)}))},wr=function(){return n(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield i(this,rr,"m",yr).call(this))}))},yr=function(){return n(this,void 0,void 0,(function*(){const e=Zi({projectId:this.projectId,filename:yi,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield Yi(e,"json"),!0}catch(e){return!1}}))},kr=function(e){o(this,dr,Object.assign(Object.assign({},i(this,dr,"f")),e.detail),"f")},Ir=function(){var e;null===(e=i(this,ur,"f"))||void 0===e||e.remove(),o(this,ur,null,"f")},Sr=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,ur,document.createElement("descope-debugger"),"f"),Object.assign(i(this,ur,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return pc})),document.body.appendChild(i(this,ur,"f"))):i(this,rr,"m",Ir).call(this)}))},Cr=function(e,t){var n;e&&this.debug&&(null===(n=i(this,ur,"f"))||void 0===n||n.updateData({title:e,description:t}))},jr=function(){this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=Hi.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}},Ar.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.31.2"}};class Zr extends Ar{static set sdkConfigOverrides(e){Ar.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Ar.sdkConfigOverrides}constructor(){const e=new mo({deferredRedirect:!1});super(e.update.bind(e)),Or.add(this),this.stepState=new mo({},{updateOnlyOnChange:!1}),Ur.set(this,void 0),_r.set(this,null),Rr.set(this,{visibilitychange:i(this,Or,"m",Tr).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var n;const o=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=o;e||(e=null===(n=new URL(o.url).searchParams)||void 0===n?void 0:n.get(Si)),this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(o.url),t=e.searchParams.get("t"),n=e.searchParams.get(Ii).split("_").pop();i(this,Pr,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else this.nativeComplete(o)},Lr.set(this,((e,t,r,s,a=!1)=>{if(this.flowState.current.action===Di){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),c=a?500:2e3;o(this,Ur,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const o=this.sdk.flow.next(e,t,Vi,r,s,{}),d=document.hidden&&!a&&Date.now()-l>c+500;let u;d&&this.logger.debug("polling - The polling seems to be throttled");try{const e=d?1e3:6e3;u=yield ro(e,o)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,Lr,"f").call(this,e,t,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===bi)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,Lr,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),i(this,$r,"f").call(this,u),i(this,Lr,"f").call(this,e,t,r,s)}))),c),"f")}})),Pr.set(this,(()=>{clearTimeout(i(this,Ur,"f")),o(this,Ur,null,"f")})),$r.set(this,(e=>{var t,n,o,r,s,a,l,c,d,u,h,p;if(!(null==e?void 0:e.ok)){const l=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===(o=null==e?void 0:e.response)||void 0===o?void 0:o.statusText}`;i(this,Or,"m",Yr).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:l}),this.loggerWrapper.error((null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorDescription)||l,(null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorMessage)||c);const d=null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorCode;return void("E102004"!==d&&"E103205"!==d||!this.isRestartOnError||i(this,Or,"m",Mr).call(this))}null===(c=null===(l=e.data)||void 0===l?void 0:l.runnerLogs)||void 0===c||c.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 f=null===(h=null===(u=null===(d=e.data)||void 0===d?void 0:d.screen)||void 0===u?void 0:u.state)||void 0===h?void 0:h.errorText;(null===(p=e.data)||void 0===p?void 0:p.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${f?`${f} - `:""}${e.data.error.message}`):f&&this.loggerWrapper.error(f);const{status:g,authInfo:v,lastAuth:m}=e.data;if("completed"===g)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&mi&&localStorage.setItem(ji,JSON.stringify(e))}(m),void i(this,Or,"m",Yr).call(this,"success",v);const{executionId:b,stepId:w,stepName:y,action:k,screen:I,redirect:S,openInNewTabUrl:C,webauthn:j,error:x,samlIdpResponse:A,nativeResponse:E}=e.data;k!==Di?(this.loggerWrapper.info(`Step "${y||`#${w}`}" is ${g}`,"",{screen:I,status:g,stepId:w,stepName:y,action:k,error:x}),this.flowState.update({stepId:w,executionId:b,action:k,redirectTo:null==S?void 0:S.url,openInNewTabUrl:C,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==j?void 0:j.transactionId,webauthnOptions:null==j?void 0:j.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,nativeResponseType:null==E?void 0:E.type,nativePayload:null==E?void 0:E.payload})):this.flowState.update({action:k})})),Wr.set(this,oo((()=>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)}}))))),Kr.set(this,co(((e,t)=>n(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||i(this,Or,"m",Fr).call(this)){const o=null==e?void 0:e.getAttribute("id");i(this,Or,"m",zr).call(this,e);const r=yield i(this,Or,"m",qr).call(this),s=(e=>Array.from((null==e?void 0:e.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}),{}))(e),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),r),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin}),c=yield this.getFlowConfig(),d=yield this.getProjectConfig(),u=yield t(o,c.version,d.componentsVersion,l);i(this,$r,"f").call(this,u),i(this,Or,"m",Br).call(this,r)}}))))),this.flowState=e}loadSdkScripts(){return n(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>n(this,void 0,void 0,(function*(){(yield function(e){return n(this,void 0,void 0,(function*(){let t;switch(e){case"forter":return t=yield Promise.resolve().then((function(){return fc})),t.default;case"fingerprint":return t=yield Promise.resolve().then((function(){return vc})),t.default;case"fingerprintDescope":return t=yield Promise.resolve().then((function(){return bc})),t.default;default:throw new Error(`Unknown script id: ${e}`)}}))}(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Er(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n,o;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(n=this.stepState)||void 0===n||n.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",i(this,Rr,"f").visibilitychange)),yield null===(o=e.init)||void 0===o?void 0:o.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=i(this,_r,"f"))||void 0===e||e.abort(),o(this,_r,null,"f"),window.removeEventListener("visibilitychange",i(this,Rr,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=uo(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 Yi(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 Yi(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:f,screenId:g,screenState:v,redirectTo:m,openInNewTabUrl:b,redirectUrl:w,token:y,code:k,exchangeError:I,webauthnTransactionId:S,webauthnOptions:C,redirectAuthCodeChallenge:j,redirectAuthCallbackUrl:x,redirectAuthBackupCallbackUri:A,redirectAuthInitiator:E,locale:O,samlIdpResponseUrl:U,samlIdpResponseSamlResponse:_,samlIdpResponseRelayState:R,nativeResponseType:T,nativePayload:M}=e,L=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload"]);let P,$;const W=(()=>{const e=localStorage.getItem(Uo);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(Uo,e.toString()),e}return Number(e)})(),D=this.sdk.getLastUserLoginId(),N=yield this.getFlowConfig(),F=yield this.getProjectConfig(),q=Object.entries(F.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),z=x&&j?{callbackUrl:x,codeChallenge:j,backupCallbackUri:A}:void 0,B=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;if(!p&&(this.loadSdkScripts(),N.fingerprintEnabled&&N.fingerprintKey?yield Gn(N.fingerprintKey,this.baseUrl):Jn(),N.conditions?({startScreenId:P,conditionInteractionId:$}=((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=Eo[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:D,code:k,token:y,abTestingKey:W},N.conditions)):N.condition?({startScreenId:P,conditionInteractionId:$}=((e,t)=>{var n;const i=null===(n=Eo[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,conditionInteractionId:null==o?void 0:o.interactionId}})(N.condition,{loginId:D,code:k,token:y,abTestingKey:W})):P=N.startScreenId,!so(P,L))){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:z},L),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:Oo(D),abTestingKey:W,locale:uo(O).locale,nativeOptions:B}),$,"",F.componentsVersion,q,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),L.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),L.oidcLoginHint?{externalId:L.oidcLoginHint}:{}));return i(this,$r,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&I)){const e=yield this.sdk.flow.next(p,h,Bi,N.version,F.componentsVersion,{token:y,exchangeCode:k,exchangeError:I});return i(this,$r,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===zi&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!U||!_)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),i(o)})(U,_,R||"",ao)}if(f===Wi&&(s("redirectTo")||s("deferredRedirect")))return m?"android"===E&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(m):void this.loggerWrapper.error("Did not get redirect url");if(f===Ni||f===Fi){if(!S||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=i(this,_r,"f"))||void 0===l||l.abort(),o(this,_r,null,"f");try{e=f===Ni?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const n=yield this.sdk.flow.next(p,h,Bi,N.version,F.componentsVersion,{transactionId:S,response:e,failure:t});i(this,$r,"f").call(this,n)}if(f===qi)return this.nativeComplete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,Bi,N.version,F.componentsVersion,e);i(this,$r,"f").call(this,t)})),void i(this,Or,"m",Yr).call(this,"bridge",{type:T,payload:M});if(i(this,Lr,"f").call(this,p,h,N.version,F.componentsVersion),!g&&!P)return void this.loggerWrapper.warn("No screen was found to show");const V=P||g,H=yield this.getHtmlFilenameWithLocale(O,V),{oidcLoginHint:K,oidcPrompt:G,oidcErrorRedirectUri:J,samlIdpUsername:X}=L,Y={direction:Qi(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:D,name:this.sdk.getLastUserDisplayName()||D}}),htmlUrl:Zi({projectId:c,filename:`${V}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:H&&Zi({projectId:c,filename:H,baseUrl:this.baseStaticUrl}),samlIdpUsername:X,oidcLoginHint:K,oidcPrompt:G,oidcErrorRedirectUri:J,openInNewTabUrl:b},Z=Oo(D);so(P,L)?Y.next=(e,t,n,i)=>this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:z},L),{lastAuth:Z,preview:this.preview,abTestingKey:W,client:this.client}),w&&{redirectUrl:w}),{locale:uo(O).locale,nativeOptions:B}),$,e,n,q,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),i),k&&{exchangeCode:k,idpInitiated:!0}),L.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(Y.next=(...e)=>this.sdk.flow.next(p,h,...e)),this.stepState.update(Y)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r;const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:c,screenState:d,openInNewTabUrl:u}=e,h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield i(this,Or,"m",Nr).call(this,p,c):(e=>{e.querySelectorAll(`descope-button[${$i}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(p),!e.samlIdpUsername||(null===(o=d.form)||void 0===o?void 0:o.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),xo(p,d,d.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(p,g);const v=()=>n(this,void 0,void 0,(function*(){var e,n;yield f;const o=this.shadowRoot.querySelector("div");((e,t)=>{jo(e,"descope-totp-image",t)})(o,null===(e=null==d?void 0:d.totp)||void 0===e?void 0:e.image),((e,t)=>{jo(e,"descope-notp-image",t)})(o,null===(n=null==d?void 0:d.notp)||void 0===n?void 0:n.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{t.querySelector(o)||i.debug(`Skipping css vars for component "${o}}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.info(`Could not find component class for ${o}`,"Check if the component is registered")}))})(o,p,d.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(p);const r=!t.htmlUrl;if(setTimeout((()=>{i(this,Or,"m",Vr).call(this),((e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(this.rootElement,this.autoFocus,r),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((e=>{e.addEventListener("blur",(()=>{var t;const n=e.focus;e.focus=()=>{},null===(t=e.reportValidity)||void 0===t||t.call(e),setTimeout((()=>{e.focus=n}))}))}))})(this.rootElement),((e,t)=>{ko(e,null==t?void 0:t.inputs),ko(e,null==t?void 0:t.form)})(this.rootElement,d)})),i(this,Or,"m",Jr).call(this,c),r&&i(this,Or,"m",Yr).call(this,"ready",{}),i(this,Or,"m",Yr).call(this,"page-updated",{}),this.rootElement.querySelector(`[${$i}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),n=yield c(Vi,e.version,t.componentsVersion,{});i(this,$r,"f").call(this,n)}u&&!t.openInNewTabUrl&&window.open(u,"_blank")}));l?i(this,Or,"m",Xr).call(this,v,l):v()}))}}Ur=new WeakMap,_r=new WeakMap,Rr=new WeakMap,Lr=new WeakMap,Pr=new WeakMap,$r=new WeakMap,Wr=new WeakMap,Kr=new WeakMap,Or=new WeakSet,Tr=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Mr=function(){return n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.getConfig.reset(),e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},Dr=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)}))}},Nr=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,_r,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Ao())){const{options:e,transactionId:r}=(yield i(this,Wr,"f").call(this))||{};if(e&&r){i(this,Or,"m",Dr).call(this,s),o(this,_r,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(e,i(this,_r,"f")).then((e=>n(this,void 0,void 0,(function*(){const n=yield t(s.id,a.version,l.componentsVersion,{transactionId:r,response:e});i(this,$r,"f").call(this,n)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},Fr=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,i;"slot"!==t.localName&&(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(i=t.checkValidity)||void 0===i?void 0:i.call(t)))})),e},qr=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${Ci}])`));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})),{})}))},zr=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},Br=function(e={}){var t,n;const i=lo(e,["externalId","email","phone"]),o=lo(e,["newPassword","password"]);if(i&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:i,password:o});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},Vr=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.rootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,Or,"m",Hr).call(this,e)))},Hr=function(e){e&&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)}))},Gr=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var n;(null===(n=t.checkValidity)||void 0===n?void 0:n.call(t))&&i(this,Kr,"f").call(this,t,e)}))}))},Jr=function(e){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((t=>{t.onclick=()=>{i(this,Kr,"f").call(this,t,e)}})),i(this,Or,"m",Gr).call(this,e)},Xr=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const n=t===Ki.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(n)})),this.rootElement.classList.add("fade-out")},Yr=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Zr);const Qr=l((e=>{var t,n,s,a,l,c,d;return d=class extends(r(Po,Ro)(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 Rc})),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})),es="descope-modal";var ts;let ns=class{constructor(e,t){ts.set(this,void 0),this.nodeName="",o(this,ts,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,ts,"f"))}get ele(){var e,t;const n="function"==typeof i(this,ts,"f")?i(this,ts,"f").call(this):i(this,ts,"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)}};ts=new WeakMap;let is=class extends ns{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};var os;class rs extends ns{constructor(){super(...arguments),os.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),i(this,os,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,os,"f").content.cloneNode(!0)))}setContent(e){o(this,os,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}}os=new WeakMap;let ss=class extends ns{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()}},as=class extends ns{constructor(){super(...arguments),this.nodeName="descope-avatar"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}set image(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("img",e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}},ls=class extends ns{constructor(){super(...arguments),this.nodeName="descope-user-attribute"}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",e)}set badgeLabel(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("badge-label",e)}get label(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("label"))||""}get editFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("edit-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("delete-flow-id"))||""}onEditClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("edit-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("edit-clicked",e)}}onDeleteClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("delete-clicked",e)}}},cs=class extends ns{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,n;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(n=this.ele)||void 0===n||n.removeAttribute("fulfilled")}onButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}};class ds extends ns{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}}const us=l((e=>{var t,n;const o=r(Po,Qo,Xo)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends rs{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((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(n),new(i(this,t,"f"))(n,{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})),hs="descope-notification";l((e=>{var t,n;const o=r(Po,Qo,Xo)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ss{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(hs);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([hs])}},t=new WeakMap,n}));var ps=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),fs=()=>Math.random().toString(36).substring(7).split("").join("."),gs={INIT:`@@redux/INIT${fs()}`,REPLACE:`@@redux/REPLACE${fs()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${fs()}`};function vs(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function ms(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function bs(e){let t=typeof e;return t=ms(e),t}function ws(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${bs(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(`Expected the enhancer to be a function. Instead, received: '${bs(n)}'`);return n(ws)(e,t)}let i=e,o=t,r=new Map,s=r,a=0,l=!1;function c(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${bs(e)}'`);if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;c();const n=a++;return s.set(n,e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,c(),s.delete(n),r=null}}}function h(e){if(!vs(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${bs(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error(`Action "type" property must be a string. Instead, the actual type was: '${bs(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,o=i(o,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:gs.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${bs(e)}`);i=e,h({type:gs.REPLACE})},[ps]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${bs(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[ps](){return this}}}}}function ys(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function ks(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];void 0===e[o]&&ys(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const i=Object.keys(n);let o,r;o={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:gs.INIT}))throw new Error(`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:gs.PROBE_UNKNOWN_ACTION()}))throw new Error(`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${gs.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){r=e}return function(e={},t){if(r)throw r;{const i=function(e,t,n,i){const o=Object.keys(t),r=n&&n.type===gs.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!vs(e))return`The ${r} has unexpected type of "${bs(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!i[e]));return s.forEach((e=>{i[e]=!0})),n&&n.type===gs.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);i&&ys(i)}let s=!1;const a={};for(let o=0;o<i.length;o++){const r=i[o],l=n[r],c=e[r],d=l(c,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=d,s=s||d!==c}return s=s||i.length!==Object.keys(e).length,s?a:e}}function Is(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Ss(e){return vs(e)&&"type"in e&&"string"==typeof e.type}var Cs=Symbol.for("immer-nothing"),js=Symbol.for("immer-draftable"),xs=Symbol.for("immer-state"),As=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function Es(e,...t){{const n=As[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}}var Os=Object.getPrototypeOf;function Us(e){return!!e&&!!e[xs]}function _s(e){return!!e&&(Ts(e)||Array.isArray(e)||!!e[js]||!!e.constructor?.[js]||Ws(e)||Ds(e))}var Rs=Object.prototype.constructor.toString();function Ts(e){if(!e||"object"!=typeof e)return!1;const t=Os(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Rs}function Ms(e,t){0===Ls(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function Ls(e){const t=e[xs];return t?t.type_:Array.isArray(e)?1:Ws(e)?2:Ds(e)?3:0}function Ps(e,t){return 2===Ls(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function $s(e,t,n){const i=Ls(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function Ws(e){return e instanceof Map}function Ds(e){return e instanceof Set}function Ns(e){return e.copy_||e.base_}function Fs(e,t){if(Ws(e))return new Map(e);if(Ds(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Ts(e)){if(!Os(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[xs];let i=Reflect.ownKeys(n);for(let t=0;t<i.length;t++){const o=i[t],r=n[o];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[o]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[o]})}return Object.create(Os(e),n)}function qs(e,t=!1){return Bs(e)||Us(e)||!_s(e)||(Ls(e)>1&&(e.set=e.add=e.clear=e.delete=zs),Object.freeze(e),t&&Ms(e,((e,t)=>qs(t,!0)))),e}function zs(){Es(2)}function Bs(e){return Object.isFrozen(e)}var Vs,Hs={};function Ks(e){const t=Hs[e];return t||Es(0,e),t}function Gs(){return Vs}function Js(e,t){t&&(Ks("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Xs(e){Ys(e),e.drafts_.forEach(Qs),e.drafts_=null}function Ys(e){e===Vs&&(Vs=e.parent_)}function Zs(e){return Vs={drafts_:[],parent_:Vs,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Qs(e){const t=e[xs];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function ea(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[xs].modified_&&(Xs(t),Es(4)),_s(e)&&(e=ta(t,e),t.parent_||ia(t,e)),t.patches_&&Ks("Patches").generateReplacementPatches_(n[xs].base_,e,t.patches_,t.inversePatches_)):e=ta(t,n,[]),Xs(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Cs?e:void 0}function ta(e,t,n){if(Bs(t))return t;const i=t[xs];if(!i)return Ms(t,((o,r)=>na(e,i,t,o,r,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return ia(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const t=i.copy_;let o=t,r=!1;3===i.type_&&(o=new Set(t),t.clear(),r=!0),Ms(o,((o,s)=>na(e,i,t,o,s,n,r))),ia(e,t,!1),n&&e.patches_&&Ks("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function na(e,t,n,i,o,r,s){if(o===n&&Es(5),Us(o)){const s=ta(e,o,r&&t&&3!==t.type_&&!Ps(t.assigned_,i)?r.concat(i):void 0);if($s(n,i,s),!Us(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(_s(o)&&!Bs(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ta(e,o),t&&t.scope_.parent_||ia(e,o)}}function ia(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&qs(t,n)}var oa={get(e,t){if(t===xs)return e;const n=Ns(e);if(!Ps(n,t))return function(e,t,n){const i=aa(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}(e,n,t);const i=n[t];return e.finalized_||!_s(i)?i:i===sa(e.base_,t)?(ca(e),e.copy_[t]=da(i,e)):i},has:(e,t)=>t in Ns(e),ownKeys:e=>Reflect.ownKeys(Ns(e)),set(e,t,n){const i=aa(Ns(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=sa(Ns(e),t),o=i?.[xs];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,i)&&(void 0!==n||Ps(e.base_,t)))return!0;ca(e),la(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==sa(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,ca(e),la(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Ns(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){Es(11)},getPrototypeOf:e=>Os(e.base_),setPrototypeOf(){Es(12)}},ra={};function sa(e,t){const n=e[xs];return(n?Ns(n):e)[t]}function aa(e,t){if(!(t in e))return;let n=Os(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Os(n)}}function la(e){e.modified_||(e.modified_=!0,e.parent_&&la(e.parent_))}function ca(e){e.copy_||(e.copy_=Fs(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Ms(oa,((e,t)=>{ra[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),ra.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Es(13),ra.set.call(this,e,t,void 0)},ra.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Es(14),oa.set.call(this,e[0],t,n,e[0])};function da(e,t){const n=Ws(e)?Ks("MapSet").proxyMap_(e,t):Ds(e)?Ks("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:Gs(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,r=oa;n&&(o=[i],r=ra);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return i.draft_=a,i.revoke_=s,a}(e,t);return(t?t.scope_:Gs()).drafts_.push(n),n}function ua(e){return Us(e)||Es(10,e),ha(e)}function ha(e){if(!_s(e)||Bs(e))return e;const t=e[xs];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Fs(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Fs(e,!0);return Ms(n,((e,t)=>{$s(n,e,ha(t))})),t&&(t.finalized_=!1),n}var pa=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const i=this;return function(e=n,...o){return i.produce(e,(e=>t.call(this,e,...o)))}}let i;if("function"!=typeof t&&Es(6),void 0!==n&&"function"!=typeof n&&Es(7),_s(e)){const o=Zs(this),r=da(e,void 0);let s=!0;try{i=t(r),s=!1}finally{s?Xs(o):Ys(o)}return Js(o,n),ea(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===Cs&&(i=void 0),this.autoFreeze_&&qs(i,!0),n){const t=[],o=[];Ks("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}Es(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,i;const o=this.produce(e,t,((e,t)=>{n=e,i=t}));return[o,n,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){_s(e)||Es(8),Us(e)&&(e=ua(e));const t=Zs(this),n=da(e,void 0);return n[xs].isManual_=!0,Ys(t),n}finishDraft(e,t){const n=e&&e[xs];n&&n.isManual_||Es(9);const{scope_:i}=n;return Js(i,t),ea(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}n>-1&&(t=t.slice(n+1));const i=Ks("Patches").applyPatches_;return Us(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},fa=pa.produce;pa.produceWithPatches.bind(pa),pa.setAutoFreeze.bind(pa),pa.setUseStrictShallowCopy.bind(pa),pa.applyPatches.bind(pa),pa.createDraft.bind(pa),pa.finishDraft.bind(pa);var ga=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},va=(e,t,n)=>{const{memoize:i,memoizeOptions:o}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=i((()=>({})),...o);if(!(a.apply(null,r)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:r,secondInputs:s,stack:e})}},ma={inputStabilityCheck:"once",identityFunctionCheck:"once"};var ba=e=>Array.isArray(e)?e:[e];function wa(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function ya(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var ka="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Ia=0,Sa=1;function Ca(){return{s:Ia,v:void 0,o:null,p:null}}function ja(e,t={}){let n=Ca();const{resultEqualityCheck:i}=t;let o,r=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const i=e.get(n);void 0===i?(t=Ca(),e.set(n,t)):t=i}else{let e=t.p;null===e&&(t.p=e=new Map);const i=e.get(n);void 0===i?(t=Ca(),e.set(n,t)):t=i}}const a=t;let l;if(t.s===Sa)l=t.v;else if(l=e.apply(null,arguments),r++,i){const e=o?.deref?.()??o;null!=e&&i(e,l)&&(l=e,0!==r&&r--);o="object"==typeof l&&null!==l||"function"==typeof l?new ka(l):l}return a.s=Sa,a.v=l,l}return s.clearCache=()=>{n=Ca(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function xa(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,i=(...e)=>{let t,i=0,o=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:l,memoizeOptions:c=[],argsMemoize:d=ja,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=ba(c),f=ba(u),g=wa(e),v=l((function(){return i++,s.apply(null,arguments)}),...p);let m=!0;const b=d((function(){o++;const e=ya(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...ma,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:ga},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:va}}})(m,h);if(n.shouldRun&&n.run(s,e,t),i.shouldRun){const t=ya(g,arguments);i.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(b,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:l,argsMemoize:d})};return Object.assign(i,{withTypes:()=>i}),i}var Aa=xa(ja),Ea=Object.assign(((e,t=Aa)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e);return t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,i)=>(e[n[i]]=t,e)),{})))}),{withTypes:()=>Ea});function Oa(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var Ua=Oa(),_a=Oa;((...e)=>{const t=xa(...e)})(ja);var Ra="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Is:Is.apply(null,arguments)},Ta=e=>e&&"function"==typeof e.match;function Ma(e,t){function n(...n){if(t){let i=t(...n);if(!i)throw new Error("prepareAction did not return an object");return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Ss(t)&&t.type===e,n}function La(e){return"function"==typeof e&&"type"in e&&Ta(e)}function Pa(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var $a=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Wa(e){return _s(e)?fa(e,(()=>{})):e}function Da(e,t,n){if(e.has(t)){let i=e.get(t);return n.update&&(i=n.update(i,t,e),e.set(t,i)),i}if(!n.insert)throw new Error("No insert provided for key not already in map");const i=n.insert(t,e);return e.set(t,i),i}function Na(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Fa(e,t,n){const i=qa(e,t,n);return{detectMutations:()=>za(e,t,i,n)}}function qa(e,t=[],n,i="",o=new Set){const r={value:n};if(!e(n)&&!o.has(n)){o.add(n),r.children={};for(const o in n){const s=i?i+"."+o:o;t.length&&-1!==t.indexOf(s)||(r.children[o]=qa(e,t,n[o],s))}}return r}function za(e,t=[],n,i,o=!1,r=""){const s=n?n.value:void 0,a=s===i;if(o&&!a&&!Number.isNaN(i))return{wasMutated:!0,path:r};if(e(s)||e(i))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in i)l[e]=!0;const c=t.length>0;for(let o in l){const s=r?r+"."+o:o;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=za(e,t,n.children[o],i[o],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Ba(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||vs(e)}function Va(e,t="",n=Ba,i,o=[],r){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=i?i(e):Object.entries(e),l=o.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=Va(c,a,n,i,o,r),s))return s}return r&&Ha(e)&&r.add(e),!1}function Ha(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Ha(t))return!1;return!0}function Ka(e){return"boolean"==typeof e}var Ga=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=e??{};let r=new $a;if(t&&(Ka(t)?r.push(Ua):r.push(_a(t.extraArgument))),n){let e={};Ka(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,i,o){return JSON.stringify(e,n(t,o),i)},n=function(e,t){let n=[],i=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+i.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?i.splice(s,1/0,o):i.push(o),~n.indexOf(r)&&(r=t.call(this,o,r))}else n.push(r);return null==e?r:e.call(this,o,r)}},{isImmutable:i=Na,ignoredPaths:o,warnAfter:r=32}=e;const s=Fa.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=s(i);return a=>l=>{const c=Pa(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(l);return c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(l)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),c.warnIfExceeded(),d}}}}(e))}if(i){let e={};Ka(i)||(e=i),r.push(function(e={}){{const{isSerializable:t=Ba,getEntries:n,ignoredActions:i=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:l=!1,disableCache:c=!1}=e,d=!c&&WeakSet?new WeakSet:void 0;return e=>c=>u=>{if(!Ss(u))return c(u);const h=c(u),p=Pa(s,"SerializableStateInvariantMiddleware");return l||i.length&&-1!==i.indexOf(u.type)||p.measureTime((()=>{const e=Va(u,"",t,n,o,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const i=Va(e.getState(),"",t,n,r,d);if(i){const{keyPath:e,value:t}=i;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(o){let e={};Ka(o)||(e=o),r.unshift(function(e={}){const{isActionCreator:t=La}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return r},Ja=e=>t=>{setTimeout(t,e)},Xa="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Ja(10),Ya=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new $a(e);return n&&i.push(((e={type:"raf"})=>t=>(...n)=>{const i=t(...n);let o=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?Xa:"callback"===e.type?e.queueNotification:Ja(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},i,{subscribe(e){const t=i.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,r=!o,r&&(s||(s=!0,l(c))),i.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),i};function Za(e){const t=Ga(),{reducer:n,middleware:i,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!vs(n))throw new Error("`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=ks(n)}if(i&&"function"!=typeof i)throw new Error("`middleware` field must be a callback");if("function"==typeof i){if(l=i(t),!Array.isArray(l))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else l=t();if(l.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let c=Is;o&&(c=Ra({trace:!0,..."object"==typeof o&&o}));const d=function(...e){return t=>(n,i)=>{const o=t(n,i);let r=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:o.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=Is(...a)(o.dispatch),{...o,dispatch:r}}}(...l),u=Ya(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");l.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return ws(a,r,c(...h))}function Qa(e){const t={},n=[];let i;const o={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(i)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,o},addMatcher(e,t){if(i)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(i)throw new Error("`builder.addDefaultCase` can only be called once");return i=e,o}};return e(o),[t,n,i]}function el(...e){return t=>e.some((e=>((e,t)=>Ta(e)?e.match(t):e(t))(e,t)))}var tl=["name","message","stack","code"],nl=class{constructor(e,t){this.payload=e,this.meta=t}_type},il=class{constructor(e,t){this.payload=e,this.meta=t}_type},ol=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of tl)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},rl=(()=>{function e(e,t,n){const i=Ma(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=Ma(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Ma(e+"/rejected",((e,t,i,o,r)=>({payload:o,error:(n&&n.serializeError||ol)(e||"Rejected"),meta:{...r||{},arg:i,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,l)=>{const c=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let r=n?.condition?.(e,{getState:a,extra:l});if(null!==(f=r)&&"object"==typeof f&&"function"==typeof f.then&&(r=await r),!1===r||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(o(c,e,n?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new nl(e,t),fulfillWithValue:(e,t)=>new il(e,t)})).then((t=>{if(t instanceof nl)throw t;return t instanceof il?i(t.payload,c,e,t.meta):i(t,c,e)}))])}catch(t){p=t instanceof nl?r(null,c,e,t.payload,t.meta):r(t,c,e)}var f;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:c,arg:e,unwrap:()=>p.then(sl)})}}),{pending:o,rejected:r,fulfilled:i,settled:el(r,i),typePrefix:e})}return e.withTypes=()=>e,e})();function sl(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var al=Symbol.for("rtk-slice-createasyncthunk");function ll(e,t){return`${e}/${t}`}function cl(e,t,n,i){function o(o,...r){let s=n.call(e,o);if(void 0===s){if(!i)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return o.unwrapped=t,o}var dl=function({creators:e}={}){const t=e?.asyncThunk?.[al];return function(e){const{name:n,reducerPath:i=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function l(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],i]="function"==typeof e.extraReducers?Qa(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[i,o,r]=Qa(t);if(function(e){return"function"==typeof e}(e))n=()=>Wa(e());else{const t=Wa(e);n=()=>t}function s(e=n(),t){let s=[i[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,n)=>{if(n){if(Us(e)){const i=n(e,t);return void 0===i?e:i}if(_s(e))return fa(e,(e=>n(e,t)));{const i=n(e,t);if(void 0===i){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return i}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);i&&e.addDefaultCase(i)}))}r.forEach((i=>{const r=o[i],s={reducerName:i,type:ll(n,i),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},i,o){let r,s;if("reducer"in i){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(i))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=i.reducer,s=i.prepare}else r=i;o.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Ma(e,s):Ma(e))}(s,r,a):function({type:e,reducerName:t},n,i,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:l,settled:c,options:d}=n,u=o(e,r,d);i.exposeAction(t,u),s&&i.addCase(u.fulfilled,s);a&&i.addCase(u.pending,a);l&&i.addCase(u.rejected,l);c&&i.addMatcher(u.settled,c);i.exposeCaseReducer(t,{fulfilled:s||ul,pending:a||ul,rejected:l||ul,settled:c||ul})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:i,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const n=Da(d,this,{insert:()=>new WeakMap});return Da(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=cl(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const i=t??this.reducerPath;return e.inject({reducerPath:i,reducer:this.reducer},n),{...this,reducerPath:i}}};return h}}();function ul(){}var hl="listenerMiddleware";Ma(`${hl}/add`),Ma(`${hl}/removeAll`),Ma(`${hl}/remove`);const pl=e=>l((t=>{const n=dl(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(Ro)(t)){constructor(...e){super(...e);const t=Za({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...n)=>{const i=await t.dispatch(e(...n));try{sl(i)}catch(e){this.logger.error(e.message,i.type,e.stack)}return i},r=Object.keys(i).reduce(((e,t)=>(e[t]=o(i[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));l((e=>class extends(Ro(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 fl=l((e=>class extends e{get baseStaticUrl(){return this.getAttribute("base-static-url")||""}})),gl=(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),n)})),t};function vl(e){return new URLSearchParams(window.location.search).get(e)}const ml=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},bl=rl("users/me",((e,{extra:{api:t}})=>t.user.me())),wl=ml(bl)({onFulfilled:(e,t)=>{e.me.data=t.payload}},(yl=e=>e.me,{onFulfilled:e=>{yl(e).loading=!1},onPending:e=>{yl(e).loading=!0,yl(e).error=null},onRejected:(e,t)=>{yl(e).loading=!1,yl(e).error=t.error}}));var yl;const kl={action:bl,reducer:wl},Il=rl("users/logout",((e,{extra:{api:t}})=>t.user.logout())),Sl={action:Il,reducer:ml(Il)({})},Cl={me:{loading:!1,error:null,data:{}}},jl={me:"/v1/auth/me"},xl=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),Al=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return xl();const i=yield e.get(jl.me);return yield(e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(i),i.json()}))}),El=l((e=>{var t,s,a,l;const c=r(Do,$o,Ro,No)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return i(this,s,"f")||i(this,t,"m",a).call(this),i(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url"],(()=>{i(this,s,"f")&&i(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),o(this,s,((e,t,i)=>{const o=vi(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.2.3"}}));return{user:Object.assign(Object.assign({},Al({httpClient:o.httpClient,mock:t})),{logout:t?()=>n(void 0,void 0,void 0,(function*(){})):o.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl},"true"===this.mock,this.widgetId),"f")},l})),Ol=l((e=>{const t=r(pl({name:"widget",initialState:Cl,reducers:{},extraReducers:e=>{kl.reducer(e),Sl.reducer(e)},asyncActions:{getMe:kl.action,logout:Sl.action}}),Po,Ro,El)(e);return class extends t{constructor(...e){super(...e),this.state=Cl,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Ul="widget-flow",_l=l((e=>{var t,o,s;return s=class extends(r(Po,us,Ol,Ro)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const r=vl(Ul);r&&(!function(e){if(window.history.replaceState&&vl(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())}}(Ul),i(this,t,"m",o).call(this,r))}))}},t=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(gl({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl}));new ds((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},s})),Rl=e=>e.me.data,Tl=Aa(Rl,(e=>e.picture)),Ml=Aa(Rl,(e=>e.email)),Ll=Aa(Rl,(e=>e.verifiedEmail)),Pl=Aa(Rl,(e=>e.name)),$l=Aa(Rl,(e=>e.phone)),Wl=Aa(Rl,(e=>e.verifiedPhone)),Dl=Aa(Rl,(e=>e.webauthn));Aa(Rl,(e=>e.password));const Nl=Aa(Rl,(e=>e.customAttributes)),Fl=l((e=>{const t=r(Fo,Wo({"widget-id":Wo.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return n(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),ql=l((e=>{var t,o,a;return a=class extends(r(Ro,Po,Xo,Qo,Fl,Ol)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([this.actions.getMe(),i(this,t,"m",o).call(this)]),this.onWidgetRootReady()}))}},t=new WeakSet,o=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),zl=l((e=>{var t,s,l,c,d,u,h,p,f;return f=class extends(r(Ol,Ro,ql,us,fl)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),h.set(this,a((e=>{this.avatar.image=e}))),p.set(this,a((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",u).call(this),i(this,t,"m",c).call(this),i(this,h,"f").call(this,Tl(this.state)),i(this,p,"f").call(this,Pl(this.state)),this.subscribe(i(this,h,"f").bind(this),Tl),this.subscribe(i(this,p,"f").bind(this),Pl)}))}},s=new WeakMap,l=new WeakMap,h=new WeakMap,p=new WeakMap,t=new WeakSet,c=function(){this.avatar.flowId&&(o(this,s,this.createModal({"data-id":"update-pic"}),"f"),o(this,l,new ds((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",d).bind(this),i(this,t,"m",d).call(this))},d=function(){i(this,s,"f").setContent(gl({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.avatar=new as((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},f})),Bl=l((e=>{var t,s,l,c,d,u,h,p,f,g,v,m,b;return b=class extends(r(Ol,Ro,ql,us)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.emailUserAttr.value=e}))),m.set(this,a((e=>{this.emailUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Ml(this.state)),i(this,m,"f").call(this,Ll(this.state)),this.subscribe(i(this,v,"f").bind(this),Ml),this.subscribe(i(this,m,"f").bind(this),Ll)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.emailUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-email"}),"f"),o(this,l,new ds((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this))},h=function(){i(this,s,"f").setContent(gl({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.emailUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-email"}),"f"),o(this,d,new ds((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this))},f=function(){i(this,c,"f").setContent(gl({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr=new ls((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.emailUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),Vl=l((e=>{var t,o,s;return s=class extends(r(Ol,Ro,ql,us)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",o).call(this)}))}},t=new WeakSet,o=function(){this.logout=new is((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>n(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},s})),Hl=l((e=>{var t,s,l,c,d,u,h,p,f,g,v,m;return m=class extends(r(Ol,Ro,ql,us)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.nameUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Pl(this.state)),this.subscribe(i(this,v,"f").bind(this),Pl)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.nameUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-name"}),"f"),o(this,l,new ds((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this))},h=function(){i(this,s,"f").setContent(gl({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.nameUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-name"}),"f"),o(this,d,new ds((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this))},f=function(){i(this,c,"f").setContent(gl({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr=new ls((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.nameUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},m})),Kl=l((e=>{var t,s,l,c,d,u,h,p;return p=class extends(r(Ol,Ro,ql,us)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),h.set(this,a((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",u).call(this),i(this,t,"m",c).call(this),i(this,h,"f").call(this,Dl(this.state)),this.subscribe(i(this,h,"f").bind(this),Dl)}))}},s=new WeakMap,l=new WeakMap,h=new WeakMap,t=new WeakSet,c=function(){this.passkeyUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"passkey"}),"f"),o(this,l,new ds((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",d).bind(this),i(this,t,"m",d).call(this))},d=function(){i(this,s,"f").setContent(gl({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.passkeyUserAuthMethod=new cs((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},p})),Gl=l((e=>{var t,s,a,l,c,d,u;return u=class extends(r(Ol,Ro,ql,us)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",d).call(this),i(this,t,"m",l).call(this)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(){this.passwordUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"password"}),"f"),o(this,a,new ds((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",c).bind(this),i(this,t,"m",c).call(this))},c=function(){i(this,s,"f").setContent(gl({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,a,"f").onSuccess((()=>{i(this,s,"f").close()}))},d=function(){this.passwordUserAuthMethod=new cs((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},u})),Jl=l((e=>{var t,s,l,c,d,u,h,p,f,g,v,m,b;return b=class extends(r(Ol,Ro,ql,us)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.phoneUserAttr.value=e}))),m.set(this,a((e=>{this.phoneUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,$l(this.state)),i(this,m,"f").call(this,Wl(this.state)),this.subscribe(i(this,v,"f").bind(this),$l),this.subscribe(i(this,m,"f").bind(this),Wl)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.phoneUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-phone"}),"f"),o(this,l,new ds((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this))},h=function(){i(this,s,"f").setContent(gl({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.phoneUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-phone"}),"f"),o(this,d,new ds((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this))},f=function(){i(this,c,"f").setContent(gl({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr=new ls((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.phoneUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b}));var Xl;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Xl||(Xl={}));const Yl=l((e=>{var t,o,s,l,c,d,u,h,p,f,g;return o=class extends(r(Ol,Ro,ql,us)(e)){constructor(){super(...arguments),t.add(this),s.set(this,{}),l.set(this,{}),c.set(this,{}),d.set(this,{}),p.set(this,a((e=>{var n;const r=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(r).forEach((n=>{const r=n.getAttribute("data-id").replace("customAttributes.",""),s=n.getAttribute("data-type")||Xl.TEXT,a=e[r],l=new ls(n,{logger:this.logger});l.value=o.getFormattedValue(s,a),i(this,t,"m",f).call(this,n,r,l),i(this,t,"m",g).call(this,n,r,l)}))})))}static getFormattedValue(e,t){return e===Xl.DATE&&t?new Date(t).toLocaleString():e===Xl.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,p,"f").call(this,Nl(this.state)),this.subscribe(i(this,p,"f").bind(this),Nl)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,p=new WeakMap,t=new WeakSet,u=function(e){var t,n;null===(t=i(this,s,"f")[e])||void 0===t||t.setContent(gl({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),null===(n=i(this,l,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,s,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},h=function(e){var t,n;null===(t=i(this,c,"f")[e])||void 0===t||t.setContent(gl({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),null===(n=i(this,d,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,c,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},f=function(e,n,o){const r=e.getAttribute("edit-flow-id");r&&(i(this,s,"f")[r]=this.createModal({"data-id":`edit-${n}`}),i(this,l,"f")[r]=new ds((()=>{var e,t;return null===(t=null===(e=i(this,s,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,s,"f")[r].afterClose=i(this,t,"m",u).bind(this,r),o.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,s,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",u).call(this,r))},g=function(e,n,o){const r=e.getAttribute("delete-flow-id");r&&(i(this,c,"f")[r]=this.createModal({"data-id":`delete-${n}`}),i(this,d,"f")[r]=new ds((()=>{var e,t;return null===(t=null===(e=i(this,c,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,c,"f")[r].afterClose=i(this,t,"m",h).bind(this,r),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,c,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",h).call(this,r))},o})),Zl=l((e=>class extends(r(Qr,tr,_l,Yl,Bl,zl,Hl,Jl,Kl,Gl,Vl)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Ql=r((e=>class extends(Zl(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),Zr.sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.2.3"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",Ql);const ec=(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 tc,nc,ic,oc,rc,sc,ac,lc,cc,dc;const uc=document.createElement("template");uc.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class hc extends HTMLElement{constructor(){super(),tc.add(this),nc.set(this,new mo({messages:[]})),ic.set(this,void 0),oc.set(this,void 0),rc.set(this,void 0),sc.set(this,{resize:i(this,tc,"m",dc).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(uc.content.cloneNode(!0)),o(this,ic,this.shadowRoot.querySelector(".debugger"),"f"),o(this,oc,i(this,ic,"f").querySelector(".content"),"f"),o(this,rc,i(this,ic,"f").querySelector(".header"),"f")}updateData(e){i(this,nc,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){((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]=ec(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,ic,"f"),i(this,rc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,sc,"f").resize),(e=>{e.onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight}})(i(this,ic,"f")),i(this,ic,"f").onresize=i(this,tc,"m",cc).bind(this),i(this,nc,"f").subscribe(i(this,tc,"m",ac).bind(this))}disconnectedCallback(){i(this,nc,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,sc,"f").resize)}}nc=new WeakMap,ic=new WeakMap,oc=new WeakMap,rc=new WeakMap,sc=new WeakMap,tc=new WeakSet,ac=function(e){i(this,tc,"m",lc).call(this,e),i(this,tc,"m",cc).call(this)},lc=function(e){i(this,oc,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},cc=function(){i(this,oc,"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)}))},dc=function(){const[e,t]=ec(i(this,ic,"f"),Number.parseInt(i(this,ic,"f").style.left,10),Number.parseInt(i(this,ic,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,ic,"f").style.top=`${t}px`,i(this,ic,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",hc);var pc=Object.freeze({__proto__:null,default:hc});var fc=Object.freeze({__proto__:null,default:(e,t,i)=>n(void 0,void 0,void 0,(function*(){const{siteId:t}=e,n='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n'.replace(/{{SITE_ID}}/g,t),o=document.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("id",t),o.text=n,document.body.appendChild(o),document.addEventListener("ftr:tokenReady",(e=>{i(e.detail)}))}))});const gc=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:t,useCloudflareIntegration:n,cloudflareScriptUrl:o,cloudflareEndpointUrl:r}=e;let s=[];s=n&&r?[r,mn]:[mn];let a=[];if(n&&o){a=[`${new URL(o).toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,Cn]}else a=[Cn];const l=jn({apiKey:t,endpoint:s,scriptUrlPattern:a}),c=yield l,{requestId:d}=yield c.get();i(d)}catch(e){console.warn("Could not load fingerprint",e)}}));var vc=Object.freeze({__proto__:null,default:gc,loadFingerprint:gc});const mc=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:o,cloudflareEndpointPath:r,cloudflareScriptPath:s}=e,{baseUrl:a}=t;let l;l=n?`https://${n}`:a||"https://api.descope.com";const c=new URL(l);c.pathname=r;const d=new URL(l);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=jn({apiKey:o,endpoint:[c.toString(),mn],scriptUrlPattern:[u,Cn]}),p=yield h,{requestId:f}=yield p.get();i(f)}catch(e){console.warn("Could not load descope fingerprint",e)}}));var bc=Object.freeze({__proto__:null,default:mc,loadFingerprint:mc});const wc=(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 yc,kc,Ic,Sc,Cc,jc,xc,Ac,Ec,Oc;const Uc=document.createElement("template");Uc.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class _c extends HTMLElement{constructor(){var e;super(),yc.add(this),kc.set(this,new f({messages:[]})),Ic.set(this,void 0),Sc.set(this,void 0),Cc.set(this,void 0),jc.set(this,{resize:i(this,yc,"m",Oc).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(Uc.content.cloneNode(!0)),o(this,Ic,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Sc,i(this,Ic,"f").querySelector(".content"),"f"),o(this,Cc,i(this,Ic,"f").querySelector(".header"),"f")}updateData(e){i(this,kc,"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]=wc(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,Ic,"f"),i(this,Cc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,jc,"f").resize),(e=i(this,Ic,"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,Ic,"f").onresize=i(this,yc,"m",Ec).bind(this),i(this,kc,"f").subscribe(i(this,yc,"m",xc).bind(this))}disconnectedCallback(){i(this,kc,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,jc,"f").resize)}}kc=new WeakMap,Ic=new WeakMap,Sc=new WeakMap,Cc=new WeakMap,jc=new WeakMap,yc=new WeakSet,xc=function(e){i(this,yc,"m",Ac).call(this,e),i(this,yc,"m",Ec).call(this)},Ac=function(e){i(this,Sc,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Ec=function(){i(this,Sc,"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]=wc(i(this,Ic,"f"),Number.parseInt(i(this,Ic,"f").style.left,10),Number.parseInt(i(this,Ic,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Ic,"f").style.top=`${t}px`,i(this,Ic,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",_c);var Rc=Object.freeze({__proto__:null,default:_c});return Ql}();
|
|
7
|
+
function pr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)e[i]=n[i]}return e}var fr=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=pr({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(i[a]=t.read(s,a),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",pr({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,pr({},this.attributes,t))},withConverter:function(t){return e(pr({},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 gr={default:"endpoint"},vr="Blocked by CSP",mr="The endpoint parameter is not a valid URL",br="Failed to load the JS script of the agent",wr="9319";function yr(e,t){var n,i,o,r,s=[],a=(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===vr||s===mr)n.exclude(),r=0;else if(s===wr)n.exclude();else if(s===br){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()]}]),l=a[0],c=a[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var d=function(e){var n=new Date,i=function(t){return s.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(s.length>=5)throw e;var t=c(n,e);if(!t)throw e;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return d(o)}))}))};return d(l).then((function(e){return[e,s]}))}var kr="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Ir=kr;function Sr(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:kr,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.9.9"):e}))}(String(e),t)}))}(l,s);return yr(e,Cr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===wr?new Error(br):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 Cr(e){return function(e,t,n,i){var o,r=document,s="securitypolicyviolation",a=function(t){var n=new URL(e,location.href),i=t.blockedURI;i!==n.href&&i!==n.protocol.slice(0,-1)&&i!==n.origin||(o=t,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return null==i||i.then(l,l),Promise.resolve().then(t).then((function(e){return l(),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(l(),o)return n(o);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(mr);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(br))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(vr)})).then(xr)}function xr(){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(wr);return n}const jr=(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},Ar=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},Er=async e=>{const t=await Ar(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Or="undefined"!=typeof localStorage,Ur=(e,t)=>Or&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),_r=e=>Or&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),Rr=e=>Or&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Tr=(...e)=>{console.debug(...e)},Mr="undefined"!=typeof window,Lr=Math.pow(2,31)-1,Pr="DS",$r="DSR";function Wr(e=""){return _r(`${e}${$r}`)||""}function Dr(e=""){return fr.get(Pr)||_r(`${e}${Pr}`)||""}function Nr(e=""){Rr(`${e}${$r}`),Rr(`${e}${Pr}`),fr.remove(Pr)}const Fr=Mr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",qr="vsid",zr="vrid",Br="fp",Vr=(e=!1)=>{const t=localStorage.getItem(Br);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Hr=async(e,t=Fr)=>{try{if(Vr())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=Sr({apiKey:e,endpoint:[i.toString(),gr],scriptUrlPattern:[r,Ir]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[qr]:e,[zr]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem(Br,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Kr=()=>{localStorage.removeItem(Br)},Gr=e=>{const t=Vr(!0);return t&&e.body&&(e.body.fpData=t),e},Jr="dls_last_user_login_id",Xr="dls_last_user_display_name",Yr=()=>_r(Jr),Zr=()=>_r(Xr),Qr=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=Yr(),r=Zr();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)};function es(){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 ts(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=as(n.publicKey.challenge),n.publicKey.user.id=as(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=as(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:ls(n.rawId),type:n.type,response:{attestationObject:ls(n.response.attestationObject),clientDataJSON:ls(n.response.clientDataJSON)}});var n}async function ns(e){const t=rs(e);return ss(await navigator.credentials.get(t))}async function is(e,t){const n=rs(e);return n.signal=t.signal,n.mediation="conditional",ss(await navigator.credentials.get(n))}async function os(e=!1){if(!Mr)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function rs(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=as(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=as(e.id)})),n}function ss(e){return JSON.stringify({id:e.id,rawId:ls(e.rawId),type:e.type,response:{authenticatorData:ls(e.response.authenticatorData),clientDataJSON:ls(e.response.clientDataJSON),signature:ls(e.response.signature),userHandle:e.response.userHandle?ls(e.response.userHandle):void 0}})}function as(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function ls(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var cs,ds=(cs=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 ts(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 ns(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 ts(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await ns(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 ts(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:ts,get:ns,isSupported:os,conditional:is}}),(...e)=>{const t=cs(...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 us="/fedcm/config",hs=(e,t)=>({async oneTap(t,n,i,o,r){const s=null!=t?t:"google",a=await e.oauth.startNative(s,i,!0);if(!a.ok)return a;const{clientId:l,stateId:c,nonce:d}=a.data,u=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")}}))}();return new Promise((t=>{var i,a;u.initialize(Object.assign(Object.assign({},n),{itp_support:null===(i=null==n?void 0:n.itp_support)||void 0===i||i,use_fedcm_for_prompt:null===(a=null==n?void 0:n.use_fedcm_for_prompt)||void 0===a||a,client_id:l,callback:n=>{t(e.oauth.finishNative(s,c,"","",n.credential))},nonce:d})),u.prompt((e=>{var t,n;if(r&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);null==r||r(n)}else if(o&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);null==o||o(t)}}))}))},async launch(n){var i;const o={identity:{context:n||"signin",providers:[{configURL:e.httpClient.buildUrl(t+us),clientId:t}]}},r=await(null===(i=navigator.credentials)||void 0===i?void 0:i.get(o));return e.refresh(r.token)},isSupported:()=>Mr&&"IdentityCredential"in window,async isLoggedIn(n){var i;const o=e.httpClient.buildUrl(t+us);try{const e={identity:{context:n||"signin",providers:[{configURL:o,clientId:t}]}},r=await(null===(i=navigator.credentials)||void 0===i?void 0:i.get(e));return!!r&&!!r.token}catch(e){return!1}}});var ps=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await os(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});const fs=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return Mr?(i&&o&&Hr(i).catch((()=>null)),e(jr(r,{beforeRequest:Gr}))):e(r)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);if(!i)return e(o);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,l;Mr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(Tr("Expiration time passed, refreshing session"),c.refresh(Wr()||l))}));const c=e(jr(o,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:i}=await Ar(t);if(401===(null==t?void 0:t.status))Tr("Received 401, canceling all timers"),r();else if(i){if(a=(e=>{try{const t=gn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(i),!a)return void Tr("Could not extract expiration time from session token");l=n;let e=((o=a)?o.getTime()-(new Date).getTime():0)-2e4;e>Lr&&(Tr(`Timeout is too large (${e}ms), setting it to ${Lr}ms`),e=Lr),r();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Tr(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Tr("Refreshing session due to timer"),c.refresh(Wr()||n)}),e)}var o}}));return no(c,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return Tr("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.23.1"},t.baseHeaders)}))),(e=>t=>{const n=es(),i=es(),o=e(jr(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))n.pub(null),i.pub(null);else{const e=await Er(t);e&&i.pub(e);const{sessionJwt:o}=await Ar(t);o&&n.pub(o)}}})),r=no(o,["logout","logoutAll"],(e=>async(...t)=>{const o=await e(...t);return n.pub(null),i.pub(null),o}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:i.sub})}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:Yr,getLastUserDisplayName:Zr});const s=e(jr(r,{afterRequest:async(e,t)=>{var n;const i=await Er(t),o=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],r=null==i?void 0:i.name;o&&((e=>{Ur(Jr,e)})(o),(e=>{Ur(Xr,e)})(r))}}));let a=no(s,["flow.start"],Qr);return a=no(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(Rr(Jr),Rr(Xr)),i})(o)),Object.assign(a,{getLastUserLoginId:Yr,getLastUserDisplayName:Zr})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!i||!Mr)return e(s);const a=e(jr(s,{beforeRequest:(l=r,e=>Object.assign(e,{token:e.token||Wr(l)})),afterRequest:async(e,n)=>{const i=/^\/v\d+\/mgmt\//.test(e.path);401===(null==n?void 0:n.status)?i||Nr(r):((e={},n,i)=>{var{refreshJwt:o,sessionJwt:r}=e,s=t(e,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===i&&(i=""),o&&Ur(`${i}${$r}`,o),r&&(n?function(e,t,{cookiePath:n,cookieDomain:i,cookieExpiration:o}){if(t){const r=new Date(1e3*o),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(i);fr.set(e,t,{path:n,domain:s?i:void 0,expires:r,sameSite:"Strict",secure:!0})}}(Pr,r,s):Ur(`${i}${Pr}`,r))})(await Ar(n),o,r)}}));var l;const c=no(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return Nr(e),i})(r));return Object.assign(c,{getRefreshToken:()=>Wr(r),getSessionToken:()=>Dr(r)})}))(((...e)=>{const t=hr(...e);return Object.assign(Object.assign({},t),{refresh:e=>{const n=Dr();return t.refresh(e,{dcs:n?"t":"f"})},flow:ps(t),webauthn:ds(t),fedcm:hs(t,e[0].projectId)})})),gs={me:"/v1/auth/me"},vs=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),ms=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return vs();const i=yield e.get(gs.me);return yield(e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(i),i.json()}))}),bs=l((e=>{var t,s,a,l;const c=r(S,k,v,C)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return i(this,s,"f")||i(this,t,"m",a).call(this),i(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url"],(()=>{i(this,s,"f")&&i(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),o(this,s,((e,t,i)=>{const o=fs(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.2.4"}}));return{user:Object.assign(Object.assign({},ms({httpClient:o.httpClient,mock:t})),{logout:t?()=>n(void 0,void 0,void 0,(function*(){})):o.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl},"true"===this.mock,this.widgetId),"f")},l})),ws=l((e=>{const t=r(en({name:"widget",initialState:hn,reducers:{},extraReducers:e=>{cn.reducer(e),un.reducer(e)},asyncActions:{getMe:cn.action,logout:un.action}}),y,v,bs)(e);return class extends t{constructor(...e){super(...e),this.state=hn,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),ys="widget-flow",ks=l((e=>{var t,o,s;return s=class extends(r(y,X,ws,v)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const r=on(ys);r&&(!function(e){if(window.history.replaceState&&on(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())}}(ys),i(this,t,"m",o).call(this,r))}))}},t=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(nn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl}));new J((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},s})),Is=e=>e.me.data,Ss=ft(Is,(e=>e.picture)),Cs=ft(Is,(e=>e.email)),xs=ft(Is,(e=>e.verifiedEmail)),js=ft(Is,(e=>e.name)),As=ft(Is,(e=>e.phone)),Es=ft(Is,(e=>e.verifiedPhone)),Os=ft(Is,(e=>e.webauthn));ft(Is,(e=>e.password));const Us=ft(Is,(e=>e.customAttributes)),_s=l((e=>{const t=r(x,I({"widget-id":I.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return n(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Rs=l((e=>{var t,o,a;return a=class extends(r(v,y,L,W,_s,ws)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([this.actions.getMe(),i(this,t,"m",o).call(this)]),this.onWidgetRootReady()}))}},t=new WeakSet,o=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),Ts=l((e=>{var t,s,l,c,d,u,h,p,f;return f=class extends(r(ws,v,Rs,X,tn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),h.set(this,a((e=>{this.avatar.image=e}))),p.set(this,a((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",u).call(this),i(this,t,"m",c).call(this),i(this,h,"f").call(this,Ss(this.state)),i(this,p,"f").call(this,js(this.state)),this.subscribe(i(this,h,"f").bind(this),Ss),this.subscribe(i(this,p,"f").bind(this),js)}))}},s=new WeakMap,l=new WeakMap,h=new WeakMap,p=new WeakMap,t=new WeakSet,c=function(){this.avatar.flowId&&(o(this,s,this.createModal({"data-id":"update-pic"}),"f"),o(this,l,new J((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",d).bind(this),i(this,t,"m",d).call(this))},d=function(){i(this,s,"f").setContent(nn({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.avatar=new H((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},f})),Ms=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,b,w;return w=class extends(r(ws,v,Rs,X)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.emailUserAttr.value=e}))),b.set(this,a((e=>{this.emailUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,m,"f").call(this,Cs(this.state)),i(this,b,"f").call(this,xs(this.state)),this.subscribe(i(this,m,"f").bind(this),Cs),this.subscribe(i(this,b,"f").bind(this),xs)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,b=new WeakMap,t=new WeakSet,u=function(){this.emailUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-email"}),"f"),o(this,l,new J((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this))},h=function(){i(this,s,"f").setContent(nn({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.emailUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-email"}),"f"),o(this,d,new J((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this))},f=function(){i(this,c,"f").setContent(nn({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr=new K((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.emailUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},w})),Ls=l((e=>{var t,o,s;return s=class extends(r(ws,v,Rs,X)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",o).call(this)}))}},t=new WeakSet,o=function(){this.logout=new q((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>n(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},s})),Ps=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,b;return b=class extends(r(ws,v,Rs,X)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.nameUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,m,"f").call(this,js(this.state)),this.subscribe(i(this,m,"f").bind(this),js)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.nameUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-name"}),"f"),o(this,l,new J((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this))},h=function(){i(this,s,"f").setContent(nn({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.nameUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-name"}),"f"),o(this,d,new J((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this))},f=function(){i(this,c,"f").setContent(nn({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr=new K((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.nameUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},b})),$s=l((e=>{var t,s,l,c,d,u,h,p;return p=class extends(r(ws,v,Rs,X)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),h.set(this,a((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",u).call(this),i(this,t,"m",c).call(this),i(this,h,"f").call(this,Os(this.state)),this.subscribe(i(this,h,"f").bind(this),Os)}))}},s=new WeakMap,l=new WeakMap,h=new WeakMap,t=new WeakSet,c=function(){this.passkeyUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"passkey"}),"f"),o(this,l,new J((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",d).bind(this),i(this,t,"m",d).call(this))},d=function(){i(this,s,"f").setContent(nn({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.passkeyUserAuthMethod=new G((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},p})),Ws=l((e=>{var t,s,a,l,c,d,u;return u=class extends(r(ws,v,Rs,X)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",d).call(this),i(this,t,"m",l).call(this)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(){this.passwordUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"password"}),"f"),o(this,a,new J((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",c).bind(this),i(this,t,"m",c).call(this))},c=function(){i(this,s,"f").setContent(nn({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,a,"f").onSuccess((()=>{i(this,s,"f").close()}))},d=function(){this.passwordUserAuthMethod=new G((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},u})),Ds=l((e=>{var t,s,l,c,d,u,h,p,f,g,m,b,w;return w=class extends(r(ws,v,Rs,X)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.phoneUserAttr.value=e}))),b.set(this,a((e=>{this.phoneUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,m,"f").call(this,As(this.state)),i(this,b,"f").call(this,Es(this.state)),this.subscribe(i(this,m,"f").bind(this),As),this.subscribe(i(this,b,"f").bind(this),Es)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,b=new WeakMap,t=new WeakSet,u=function(){this.phoneUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-phone"}),"f"),o(this,l,new J((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this))},h=function(){i(this,s,"f").setContent(nn({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.phoneUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-phone"}),"f"),o(this,d,new J((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this))},f=function(){i(this,c,"f").setContent(nn({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr=new K((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.phoneUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},w}));var Ns;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Ns||(Ns={}));const Fs=l((e=>{var t,o,s,l,c,d,u,h,p,f,g;return o=class extends(r(ws,v,Rs,X)(e)){constructor(){super(...arguments),t.add(this),s.set(this,{}),l.set(this,{}),c.set(this,{}),d.set(this,{}),p.set(this,a((e=>{var n;const r=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(r).forEach((n=>{const r=n.getAttribute("data-id").replace("customAttributes.",""),s=n.getAttribute("data-type")||Ns.TEXT,a=e[r],l=new K(n,{logger:this.logger});l.value=o.getFormattedValue(s,a),i(this,t,"m",f).call(this,n,r,l),i(this,t,"m",g).call(this,n,r,l)}))})))}static getFormattedValue(e,t){return e===Ns.DATE&&t?new Date(t).toLocaleString():e===Ns.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,p,"f").call(this,Us(this.state)),this.subscribe(i(this,p,"f").bind(this),Us)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,p=new WeakMap,t=new WeakSet,u=function(e){var t,n;null===(t=i(this,s,"f")[e])||void 0===t||t.setContent(nn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),null===(n=i(this,l,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,s,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},h=function(e){var t,n;null===(t=i(this,c,"f")[e])||void 0===t||t.setContent(nn({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),null===(n=i(this,d,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,c,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},f=function(e,n,o){const r=e.getAttribute("edit-flow-id");r&&(i(this,s,"f")[r]=this.createModal({"data-id":`edit-${n}`}),i(this,l,"f")[r]=new J((()=>{var e,t;return null===(t=null===(e=i(this,s,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,s,"f")[r].afterClose=i(this,t,"m",u).bind(this,r),o.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,s,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",u).call(this,r))},g=function(e,n,o){const r=e.getAttribute("delete-flow-id");r&&(i(this,c,"f")[r]=this.createModal({"data-id":`delete-${n}`}),i(this,d,"f")[r]=new J((()=>{var e,t;return null===(t=null===(e=i(this,c,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,c,"f")[r].afterClose=i(this,t,"m",h).bind(this,r),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,c,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",h).call(this,r))},o})),qs=l((e=>class extends(r(A,Q,ks,Fs,Ms,Ts,Ps,Ds,$s,Ws,Ls)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),zs=r((e=>class extends(qs(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return nc})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.2.4"}}}))}}))(HTMLElement),Bs="undefined"!=typeof localStorage,Vs="J151000",Hs=Bs&&localStorage.getItem("base.content.url")||"",Ks="config.json",Gs="base.ui.components.url";Bs&&localStorage.getItem(Gs),Bs&&localStorage.getItem(Gs);const Js="descope-login-flow",Xs="code",Ys="data-exclude-field",Zs="dls_last_auth",Qs="state_id",ea="saml_idp_state_id",ta="saml_idp_username",na="descope_idp_initiated",ia="sso_app_id",oa="third_party_app_id",ra="third_party_app_state_id",sa="oidc_login_hint",aa="oidc_prompt",la="oidc_error_redirect_uri",ca="application_scopes",da="data-type",ua="redirect",ha="poll",pa="webauthnCreate",fa="webauthnGet",ga="nativeBridge",va="loadForm",ma="submit",ba="polling",wa=["descope-multi-select-combo-box","descope-text-area"];var ya;!function(e){e.backward="backward",e.forward="forward"}(ya||(ya={}));const ka=["descope-enriched-text"];function Ia(e){return new URLSearchParams(window.location.search).get(e)}function Sa(e){if(window.history.replaceState&&Ia(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function Ca(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||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}function xa({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(Hs||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}function ja(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?ya.forward:n<i?ya.backward:void 0}const Aa=e=>{let[t="",n=""]=(Ia(Js)||"").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 Ea(){Sa(Js)}const Oa=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Ua=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=Aa(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&Ea();const r=Ia("t")||void 0;r&&Sa("t");const s=Ia(Xs)||void 0;s&&Sa(Xs);const a=Ia("err")||void 0;a&&Sa("err");const{redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u}={redirectAuthCodeChallenge:Ia("ra-challenge"),redirectAuthCallbackUrl:Ia("ra-callback"),redirectAuthBackupCallbackUri:Ia("ra-backup-callback"),redirectAuthInitiator:Ia("ra-initiator")},h=Ia(Qs);h&&Sa(Qs);const p=Ia(ea);p&&Sa(ea);const f=Ia(ta);p&&Sa(ta);const g=Ia(na);g&&Sa(na);const v=Ia(ia);v&&Sa(ia);const m=Ia(oa);m&&Sa(oa);const b=Ia(ra);b&&Sa(ra);const w=Ia(ca);w&&Sa(ca);const y=Ia(sa);y&&Sa(sa);const k=Ia(aa);k&&Sa(aa);const I=Ia(la);return I&&Sa(la),{executionId:n,stepId:i,token:r,code:s,exchangeError:a,redirectAuthCodeChallenge:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthInitiator:u,ssoQueryParams:{oidcIdpStateId:h,samlIdpStateId:p,samlIdpUsername:f,descopeIdpInitiated:"true"===g,ssoAppId:v,oidcLoginHint:y,oidcPrompt:k,oidcErrorRedirectUri:I,thirdPartyAppId:m,thirdPartyAppStateId:b,applicationScopes:w}}},_a=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})};function Ra(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 Ta=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:i,ssoAppId:o,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a,thirdPartyAppId:l,thirdPartyAppStateId:c,applicationScopes:d})=>!(!e||t||n||i||o||r||s||a||l||c||d),Ma=e=>null==e?void 0:e.submit(),La=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Pa=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function $a(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:""}}var Wa,Da,Na,Fa;function qa(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(!qa(r,s))return!1}else if(r!==s)return!1}return!0}let za=class{constructor(e={},{updateOnlyOnChange:t=!0}={}){Wa.set(this,void 0),Da.set(this,{}),Na.set(this,0),Fa.set(this,!1),this.update=e=>{const t="function"==typeof e?e(i(this,Wa,"f")):e,n=Object.assign(Object.assign({},i(this,Wa,"f")),t);if(!i(this,Fa,"f")||!qa(i(this,Wa,"f"),n)){const e=i(this,Wa,"f");o(this,Wa,n,"f"),Object.freeze(i(this,Wa,"f")),setTimeout((()=>{Object.values(i(this,Da,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,Wa,e,"f"),o(this,Fa,t,"f")}get current(){return Object.assign({},i(this,Wa,"f"))}subscribe(e){return o(this,Na,i(this,Na,"f")+1,"f"),i(this,Da,"f")[i(this,Na,"f")]=e,i(this,Na,"f").toString()}unsubscribe(e){const t=!!i(this,Da,"f")[e];return t&&delete i(this,Da,"f")[e],t}unsubscribeAll(){return o(this,Da,{},"f"),!0}};Wa=new WeakMap,Da=new WeakMap,Na=new WeakMap,Fa=new WeakMap;const Ba=["*","#","/","(",")","[","]","_","<",">","`"],Va=e=>"string"!=typeof e?e:e.replace((e=>{const t=Ba.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),Ha=["disabled"],Ka=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Ys}])`)).forEach((e=>{e.value=n}))}))},Ga=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),Ja=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?Va(Ga(t,i)):Ga(t,i))),Xa=(e,t,n)=>{e.querySelectorAll(`[${da}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Ya=(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})`))},Za=(e,t,n,i,o,r)=>{var s,a;let l=null==t?void 0:t.errorText;try{l=(null==o?void 0:o({text:null==t?void 0:t.errorText,type:null==t?void 0:t.errorType}))||(null==t?void 0:t.errorText)}catch(e){r.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${da}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(e,"error-message",l),Xa(e,"totp-link",null===(s=null==t?void 0:t.totp)||void 0===s?void 0:s.provisionUrl),Xa(e,"notp-link",null===(a=null==t?void 0:t.notp)||void 0===a?void 0:a.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(e=>ka.includes(e))(e.localName);e.textContent=Ja(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",Ja(i,t))}))})(e,t),((e,t,n)=>{t&&Object.keys(t).forEach((i=>{e.querySelectorAll(`[name=${i}]`).forEach((e=>{const o=t[i];Object.keys(o).forEach((t=>{let i=o[t];if("string"!=typeof i)try{i=JSON.stringify(i)}catch(e){n.error(`Could not stringify value "${i}" for "${t}"`,e.message),i=""}e.setAttribute(t,i)}))}))}))})(e,n,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=Ja(e.value,t)}))}))})(e,t),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{Ha.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i)},Qa=(e,t)=>{Ya(e,"descope-totp-image",t)},el=(e,t)=>{Ya(e,"descope-notp-image",t)},tl=_a((()=>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 Ra(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}})))),nl={"lastAuth.loginId":{"not-empty":e=>!!e.loginId,empty:e=>!e.loginId},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t}};function il(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(Zs)))}catch(e){}return t}const ol="dls_ab_testing_id",rl=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})),sl=document.createElement("template");sl.innerHTML="\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n display: flex;\n\t\t}\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t";const al=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),al(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}),[]);var ll,cl,dl,ul,hl,pl,fl,gl,vl,ml,bl,wl,yl,kl,Il,Sl,Cl,xl,jl,Al,El;const Ol=r(Q,rl)(HTMLElement);class Ul extends Ol{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),ll.add(this),dl.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,ll,"m",Al).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)}},ul.set(this,new za),hl.set(this,new za),pl.set(this,{}),this.getComponentsContext=()=>i(this,pl,"f"),this.nextRequestStatus=new za({isLoading:!1}),fl.set(this,void 0),gl.set(this,{popstate:i(this,ll,"m",wl).bind(this),componentsContext:i(this,ll,"m",Cl).bind(this)}),vl.set(this,void 0),this.getConfig=_a((()=>n(this,void 0,void 0,(function*(){const e=xa({projectId:this.projectId,filename:Ks,baseUrl:this.baseStaticUrl});try{const{body:t,headers:n}=yield Ca(e,"json");return{projectConfig:t,executionContext:{geo:n["x-geo"]}}}catch(e){return{isMissingConfig:!0}}})))),o(this,vl,e,"f"),i(this,ll,"m",ml).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return al(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]]))))(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:e}=yield this.getConfig();return e}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:e}=yield this.getConfig();return e}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e,t;return(null===(t=null===(e=yield this.getConfig())||void 0===e?void 0:e.projectConfig)||void 0===t?void 0:t.componentsVersion)||(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,hl,"f").subscribe(i(this,ll,"m",jl).bind(this)),i(this,hl,"f").update({isDebug:this.debug}),i(this,ll,"m",bl).call(this),yield i(this,ll,"m",Il).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield this.getConfig()).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");i(this,ll,"m",El).call(this);const{executionId:n,stepId:r,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,ssoQueryParams:p}=Ua(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,gl,"f").popstate),window.addEventListener("components-context",i(this,gl,"f").componentsContext),i(this,ul,"f").subscribe(i(this,ll,"m",kl).bind(this)),i(this,ul,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:r,executionId:n,token:s,code:a,exchangeError:l,redirectAuthCallbackUrl:c,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h},p)),o(this,dl,!0,"f")}))}disconnectedCallback(){i(this,ul,"f").unsubscribeAll(),i(this,hl,"f").unsubscribeAll(),i(this,ll,"m",xl).call(this),window.removeEventListener("popstate",i(this,gl,"f").popstate),window.removeEventListener("components-context",i(this,gl,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,dl,"f")&&t!==n&&cl.observedAttributes.includes(e)){i(this,ll,"m",bl).call(this);const o=null===t;i(this,ul,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Ea()),{[Oa(e)]:n,stepId:r,executionId:s}})),i(this,hl,"f").update({isDebug:this.debug})}}}function _l(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Rl,Tl,Ml,Ll,Pl,$l,Wl,Dl,Nl,Fl,ql,zl,Bl,Vl,Hl,Kl,Gl,Jl,Xl,Yl,Zl,Ql,ec;cl=Ul,dl=new WeakMap,ul=new WeakMap,hl=new WeakMap,pl=new WeakMap,fl=new WeakMap,gl=new WeakMap,vl=new WeakMap,ll=new WeakSet,ml=function(){this.shadowRoot.appendChild(sl.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},bl=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];cl.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Oa(t)])throw Error(`${t} cannot be empty`)}))},wl=function(){const{stepId:e,executionId:t}=Aa(this.flowId);i(this,ul,"f").update({stepId:e,executionId:t})},yl=function(e,t){this.sdk=fs(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},cl.sdkConfigOverrides),{projectId:e,baseUrl:t})),["start","next"].forEach((e=>{const t=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>n(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield t(...e)}catch(e){return{error:{errorCode:Vs,errorDescription:e.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},kl=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,ll,"m",yl).call(this,t,n)}i(this,vl,"f").call(this,e)}))},Il=function(){return n(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield i(this,ll,"m",Sl).call(this))}))},Sl=function(){return n(this,void 0,void 0,(function*(){const e=xa({projectId:this.projectId,filename:Ks,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield Ca(e,"json"),!0}catch(e){return!1}}))},Cl=function(e){o(this,pl,Object.assign(Object.assign({},i(this,pl,"f")),e.detail),"f")},xl=function(){var e;null===(e=i(this,fl,"f"))||void 0===e||e.remove(),o(this,fl,null,"f")},jl=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,fl,document.createElement("descope-debugger"),"f"),Object.assign(i(this,fl,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Uc})),document.body.appendChild(i(this,fl,"f"))):i(this,ll,"m",xl).call(this)}))},Al=function(e,t){var n;e&&this.debug&&(null===(n=i(this,fl,"f"))||void 0===n||n.updateData({title:e,description:t}))},El=function(){this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=wa.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}},Ul.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.31.3"}};class tc extends Ul{static set sdkConfigOverrides(e){Ul.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Ul.sdkConfigOverrides}constructor(){const e=new za({deferredRedirect:!1});super(e.update.bind(e)),Rl.add(this),this.stepState=new za({},{updateOnlyOnChange:!1}),Tl.set(this,void 0),Ml.set(this,null),Ll.set(this,{visibilitychange:i(this,Rl,"m",Pl).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var n;const o=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=o;e||(e=null===(n=new URL(o.url).searchParams)||void 0===n?void 0:n.get(Xs)),this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(o.url),t=e.searchParams.get("t"),n=e.searchParams.get(Js).split("_").pop();i(this,Dl,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else this.nativeComplete(o)},Wl.set(this,((e,t,r,s,a=!1)=>{if(this.flowState.current.action===ha){this.logger.debug("polling - Scheduling polling request");const l=Date.now(),c=a?500:2e3;o(this,Tl,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;this.logger.debug("polling - Calling next");const o=this.sdk.flow.next(e,t,ba,r,s,{}),d=document.hidden&&!a&&Date.now()-l>c+500;let u;d&&this.logger.debug("polling - The polling seems to be throttled");try{const e=d?1e3:6e3;u=yield Ra(e,o)}catch(n){return this.logger.warn(`polling - The ${d?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,Wl,"f").call(this,e,t,r,s,d)}if((null===(n=null==u?void 0:u.error)||void 0===n?void 0:n.errorCode)===Vs)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==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),i(this,Nl,"f").call(this,u),i(this,Wl,"f").call(this,e,t,r,s)}))),c),"f")}})),Dl.set(this,(()=>{clearTimeout(i(this,Tl,"f")),o(this,Tl,null,"f")})),Nl.set(this,(e=>{var t,n,o,r,s,a,l,c,d,u,h,p;if(!(null==e?void 0:e.ok)){const l=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===(o=null==e?void 0:e.response)||void 0===o?void 0:o.statusText}`;i(this,Rl,"m",ec).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:l}),this.loggerWrapper.error((null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorDescription)||l,(null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorMessage)||c);const d=null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorCode;return void("E102004"!==d&&"E103205"!==d||!this.isRestartOnError||i(this,Rl,"m",$l).call(this))}null===(c=null===(l=e.data)||void 0===l?void 0:l.runnerLogs)||void 0===c||c.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 f=null===(h=null===(u=null===(d=e.data)||void 0===d?void 0:d.screen)||void 0===u?void 0:u.state)||void 0===h?void 0:h.errorText;(null===(p=e.data)||void 0===p?void 0:p.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${f?`${f} - `:""}${e.data.error.message}`):f&&this.loggerWrapper.error(f);const{status:g,authInfo:v,lastAuth:m}=e.data;if("completed"===g)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&Bs&&localStorage.setItem(Zs,JSON.stringify(e))}(m),void i(this,Rl,"m",ec).call(this,"success",v);const{executionId:b,stepId:w,stepName:y,action:k,screen:I,redirect:S,openInNewTabUrl:C,webauthn:x,error:j,samlIdpResponse:A,nativeResponse:E}=e.data;k!==ha?(this.loggerWrapper.info(`Step "${y||`#${w}`}" is ${g}`,"",{screen:I,status:g,stepId:w,stepName:y,action:k,error:j}),this.flowState.update({stepId:w,executionId:b,action:k,redirectTo:null==S?void 0:S.url,openInNewTabUrl:C,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==x?void 0:x.transactionId,webauthnOptions:null==x?void 0:x.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,nativeResponseType:null==E?void 0:E.type,nativePayload:null==E?void 0:E.payload})):this.flowState.update({action:k})})),Fl.set(this,_a((()=>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)}}))))),Xl.set(this,Pa(((e,t)=>n(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||i(this,Rl,"m",Bl).call(this)){const o=null==e?void 0:e.getAttribute("id");i(this,Rl,"m",Hl).call(this,e);const r=yield i(this,Rl,"m",Vl).call(this),s=(e=>Array.from((null==e?void 0:e.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}),{}))(e),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),r),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin}),c=yield this.getFlowConfig(),d=yield this.getProjectConfig(),u=yield t(o,c.version,d.componentsVersion,l);i(this,Nl,"f").call(this,u),i(this,Rl,"m",Kl).call(this,r)}}))))),this.flowState=e}loadSdkScripts(){return n(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>n(this,void 0,void 0,(function*(){(yield function(e){return n(this,void 0,void 0,(function*(){let t;switch(e){case"forter":return t=yield Promise.resolve().then((function(){return _c})),t.default;case"fingerprint":return t=yield Promise.resolve().then((function(){return Tc})),t.default;case"fingerprintDescope":return t=yield Promise.resolve().then((function(){return Lc})),t.default;default:throw new Error(`Unknown script id: ${e}`)}}))}(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[_l(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n,o;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(n=this.stepState)||void 0===n||n.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",i(this,Ll,"f").visibilitychange)),yield null===(o=e.init)||void 0===o?void 0:o.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=i(this,Ml,"f"))||void 0===e||e.abort(),o(this,Ml,null,"f"),window.removeEventListener("visibilitychange",i(this,Ll,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=$a(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 Ca(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 Ca(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:f,screenId:g,screenState:v,redirectTo:m,openInNewTabUrl:b,redirectUrl:w,token:y,code:k,exchangeError:I,webauthnTransactionId:S,webauthnOptions:C,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:A,redirectAuthInitiator:E,locale:O,samlIdpResponseUrl:U,samlIdpResponseSamlResponse:_,samlIdpResponseRelayState:R,nativeResponseType:T,nativePayload:M}=e,L=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload"]);let P,$;const W=(()=>{const e=localStorage.getItem(ol);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(ol,e.toString()),e}return Number(e)})(),D=this.sdk.getLastUserLoginId(),N=yield this.getFlowConfig(),F=yield this.getProjectConfig(),q=Object.entries(F.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),z=j&&x?{callbackUrl:j,codeChallenge:x,backupCallbackUri:A}:void 0,B=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;if(!p&&(this.loadSdkScripts(),N.fingerprintEnabled&&N.fingerprintKey?yield Hr(N.fingerprintKey,this.baseUrl):Kr(),N.conditions?({startScreenId:P,conditionInteractionId:$}=((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=nl[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:D,code:k,token:y,abTestingKey:W},N.conditions)):N.condition?({startScreenId:P,conditionInteractionId:$}=((e,t)=>{var n;const i=null===(n=nl[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,conditionInteractionId:null==o?void 0:o.interactionId}})(N.condition,{loginId:D,code:k,token:y,abTestingKey:W})):P=N.startScreenId,!Ta(P,L))){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:z},L),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:il(D),abTestingKey:W,locale:$a(O).locale,nativeOptions:B}),$,"",F.componentsVersion,q,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),L.descopeIdpInitiated&&{idpInitiated:!0}),y?{token:y}:{}),L.oidcLoginHint?{externalId:L.oidcLoginHint}:{}));return i(this,Nl,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}if(p&&(s("token")&&y||s("code")&&k||s("exchangeError")&&I)){const e=yield this.sdk.flow.next(p,h,ma,N.version,F.componentsVersion,{token:y,exchangeCode:k,exchangeError:I});return i(this,Nl,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===va&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!U||!_)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),i(o)})(U,_,R||"",Ma)}if(f===ua&&(s("redirectTo")||s("deferredRedirect")))return m?"android"===E&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(m):void this.loggerWrapper.error("Did not get redirect url");if(f===pa||f===fa){if(!S||!C)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=i(this,Ml,"f"))||void 0===l||l.abort(),o(this,Ml,null,"f");try{e=f===pa?yield this.sdk.webauthn.helpers.create(C):yield this.sdk.webauthn.helpers.get(C)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const n=yield this.sdk.flow.next(p,h,ma,N.version,F.componentsVersion,{transactionId:S,response:e,failure:t});i(this,Nl,"f").call(this,n)}if(f===ga)return this.nativeComplete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,ma,N.version,F.componentsVersion,e);i(this,Nl,"f").call(this,t)})),void i(this,Rl,"m",ec).call(this,"bridge",{type:T,payload:M});if(i(this,Wl,"f").call(this,p,h,N.version,F.componentsVersion),!g&&!P)return void this.loggerWrapper.warn("No screen was found to show");const V=P||g,H=yield this.getHtmlFilenameWithLocale(O,V),{oidcLoginHint:K,oidcPrompt:G,oidcErrorRedirectUri:J,samlIdpUsername:X}=L,Y={direction:ja(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:D,name:this.sdk.getLastUserDisplayName()||D}}),htmlUrl:xa({projectId:c,filename:`${V}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:H&&xa({projectId:c,filename:H,baseUrl:this.baseStaticUrl}),samlIdpUsername:X,oidcLoginHint:K,oidcPrompt:G,oidcErrorRedirectUri:J,openInNewTabUrl:b},Z=il(D);Ta(P,L)?Y.next=(e,t,n,i)=>this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:z},L),{lastAuth:Z,preview:this.preview,abTestingKey:W,client:this.client}),w&&{redirectUrl:w}),{locale:$a(O).locale,nativeOptions:B}),$,e,n,q,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),i),k&&{exchangeCode:k,idpInitiated:!0}),L.descopeIdpInitiated&&{idpInitiated:!0}),y&&{token:y})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(Y.next=(...e)=>this.sdk.flow.next(p,h,...e)),this.stepState.update(Y)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r;const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:c,screenState:d,openInNewTabUrl:u}=e,h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield i(this,Rl,"m",zl).call(this,p,c):(e=>{e.querySelectorAll(`descope-button[${da}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(p),!e.samlIdpUsername||(null===(o=d.form)||void 0===o?void 0:o.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),Za(p,d,d.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(p,g);const v=()=>n(this,void 0,void 0,(function*(){var e,n;yield f;const o=this.shadowRoot.querySelector("div");Qa(o,null===(e=null==d?void 0:d.totp)||void 0===e?void 0:e.image),el(o,null===(n=null==d?void 0:d.notp)||void 0===n?void 0:n.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{t.querySelector(o)||i.debug(`Skipping css vars for component "${o}}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.info(`Could not find component class for ${o}`,"Check if the component is registered")}))})(o,p,d.cssVars,this.loggerWrapper),this.rootElement.replaceChildren(p);const r=!t.htmlUrl;if(setTimeout((()=>{i(this,Rl,"m",Gl).call(this),((e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(this.rootElement,this.autoFocus,r),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((e=>{e.addEventListener("blur",(()=>{var t;const n=e.focus;e.focus=()=>{},null===(t=e.reportValidity)||void 0===t||t.call(e),setTimeout((()=>{e.focus=n}))}))}))})(this.rootElement),((e,t)=>{Ka(e,null==t?void 0:t.inputs),Ka(e,null==t?void 0:t.form)})(this.rootElement,d)})),i(this,Rl,"m",Zl).call(this,c),r&&i(this,Rl,"m",ec).call(this,"ready",{}),i(this,Rl,"m",ec).call(this,"page-updated",{}),this.rootElement.querySelector(`[${da}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),n=yield c(ba,e.version,t.componentsVersion,{});i(this,Nl,"f").call(this,n)}u&&!t.openInNewTabUrl&&window.open(u,"_blank")}));l?i(this,Rl,"m",Ql).call(this,v,l):v()}))}}Tl=new WeakMap,Ml=new WeakMap,Ll=new WeakMap,Wl=new WeakMap,Dl=new WeakMap,Nl=new WeakMap,Fl=new WeakMap,Xl=new WeakMap,Rl=new WeakSet,Pl=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},$l=function(){return n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.getConfig.reset(),e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},ql=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)}))}},zl=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,Ml,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield tl())){const{options:e,transactionId:r}=(yield i(this,Fl,"f").call(this))||{};if(e&&r){i(this,Rl,"m",ql).call(this,s),o(this,Ml,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(e,i(this,Ml,"f")).then((e=>n(this,void 0,void 0,(function*(){const n=yield t(s.id,a.version,l.componentsVersion,{transactionId:r,response:e});i(this,Nl,"f").call(this,n)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},Bl=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,i;"slot"!==t.localName&&(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(i=t.checkValidity)||void 0===i?void 0:i.call(t)))})),e},Vl=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${Ys}])`));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})),{})}))},Hl=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},Kl=function(e={}){var t,n;const i=La(e,["externalId","email","phone"]),o=La(e,["newPassword","password"]);if(i&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:i,password:o});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},Gl=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.rootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,Rl,"m",Jl).call(this,e)))},Jl=function(e){e&&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)}))},Yl=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var n;(null===(n=t.checkValidity)||void 0===n?void 0:n.call(t))&&i(this,Xl,"f").call(this,t,e)}))}))},Zl=function(e){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((t=>{t.onclick=()=>{i(this,Xl,"f").call(this,t,e)}})),i(this,Rl,"m",Yl).call(this,e)},Ql=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const n=t===ya.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(n)})),this.rootElement.classList.add("fade-out")},ec=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",tc);var nc=Object.freeze({__proto__:null,default:tc});customElements.define("descope-user-profile-widget",zs);const ic=(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 oc,rc,sc,ac,lc,cc,dc,uc,hc,pc;const fc=document.createElement("template");fc.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class gc extends HTMLElement{constructor(){var e;super(),oc.add(this),rc.set(this,new f({messages:[]})),sc.set(this,void 0),ac.set(this,void 0),lc.set(this,void 0),cc.set(this,{resize:i(this,oc,"m",pc).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(fc.content.cloneNode(!0)),o(this,sc,this.shadowRoot.querySelector(".debugger"),"f"),o(this,ac,i(this,sc,"f").querySelector(".content"),"f"),o(this,lc,i(this,sc,"f").querySelector(".header"),"f")}updateData(e){i(this,rc,"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]=ic(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,sc,"f"),i(this,lc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,cc,"f").resize),(e=i(this,sc,"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,sc,"f").onresize=i(this,oc,"m",hc).bind(this),i(this,rc,"f").subscribe(i(this,oc,"m",dc).bind(this))}disconnectedCallback(){i(this,rc,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,cc,"f").resize)}}rc=new WeakMap,sc=new WeakMap,ac=new WeakMap,lc=new WeakMap,cc=new WeakMap,oc=new WeakSet,dc=function(e){i(this,oc,"m",uc).call(this,e),i(this,oc,"m",hc).call(this)},uc=function(e){i(this,ac,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},hc=function(){i(this,ac,"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)}))},pc=function(){const[e,t]=ic(i(this,sc,"f"),Number.parseInt(i(this,sc,"f").style.left,10),Number.parseInt(i(this,sc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,sc,"f").style.top=`${t}px`,i(this,sc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",gc);var vc=Object.freeze({__proto__:null,default:gc});const mc=(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 bc,wc,yc,kc,Ic,Sc,Cc,xc,jc,Ac;const Ec=document.createElement("template");Ec.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class Oc extends HTMLElement{constructor(){super(),bc.add(this),wc.set(this,new za({messages:[]})),yc.set(this,void 0),kc.set(this,void 0),Ic.set(this,void 0),Sc.set(this,{resize:i(this,bc,"m",Ac).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ec.content.cloneNode(!0)),o(this,yc,this.shadowRoot.querySelector(".debugger"),"f"),o(this,kc,i(this,yc,"f").querySelector(".content"),"f"),o(this,Ic,i(this,yc,"f").querySelector(".header"),"f")}updateData(e){i(this,wc,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){((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]=mc(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,yc,"f"),i(this,Ic,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Sc,"f").resize),(e=>{e.onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight}})(i(this,yc,"f")),i(this,yc,"f").onresize=i(this,bc,"m",jc).bind(this),i(this,wc,"f").subscribe(i(this,bc,"m",Cc).bind(this))}disconnectedCallback(){i(this,wc,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Sc,"f").resize)}}wc=new WeakMap,yc=new WeakMap,kc=new WeakMap,Ic=new WeakMap,Sc=new WeakMap,bc=new WeakSet,Cc=function(e){i(this,bc,"m",xc).call(this,e),i(this,bc,"m",jc).call(this)},xc=function(e){i(this,kc,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},jc=function(){i(this,kc,"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)}))},Ac=function(){const[e,t]=mc(i(this,yc,"f"),Number.parseInt(i(this,yc,"f").style.left,10),Number.parseInt(i(this,yc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,yc,"f").style.top=`${t}px`,i(this,yc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Oc);var Uc=Object.freeze({__proto__:null,default:Oc});var _c=Object.freeze({__proto__:null,default:(e,t,i)=>n(void 0,void 0,void 0,(function*(){const{siteId:t}=e,n='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n'.replace(/{{SITE_ID}}/g,t),o=document.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("id",t),o.text=n,document.body.appendChild(o),document.addEventListener("ftr:tokenReady",(e=>{i(e.detail)}))}))});const Rc=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:t,useCloudflareIntegration:n,cloudflareScriptUrl:o,cloudflareEndpointUrl:r}=e;let s=[];s=n&&r?[r,gr]:[gr];let a=[];if(n&&o){a=[`${new URL(o).toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,Ir]}else a=[Ir];const l=Sr({apiKey:t,endpoint:s,scriptUrlPattern:a}),c=yield l,{requestId:d}=yield c.get();i(d)}catch(e){console.warn("Could not load fingerprint",e)}}));var Tc=Object.freeze({__proto__:null,default:Rc,loadFingerprint:Rc});const Mc=(e,t,i)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:o,cloudflareEndpointPath:r,cloudflareScriptPath:s}=e,{baseUrl:a}=t;let l;l=n?`https://${n}`:a||"https://api.descope.com";const c=new URL(l);c.pathname=r;const d=new URL(l);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=Sr({apiKey:o,endpoint:[c.toString(),gr],scriptUrlPattern:[u,Ir]}),p=yield h,{requestId:f}=yield p.get();i(f)}catch(e){console.warn("Could not load descope fingerprint",e)}}));var Lc=Object.freeze({__proto__:null,default:Mc,loadFingerprint:Mc});return zs}();
|
|
8
8
|
//# sourceMappingURL=index.js.map
|